Skip to content

Commit

Permalink
fix app proxy bypass bug (#657)
Browse files Browse the repository at this point in the history
  • Loading branch information
roi-codefresh authored Apr 27, 2021
1 parent 4bb35b9 commit 9da53b5
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 18 deletions.
8 changes: 8 additions & 0 deletions lib/interface/cli/commands/app-proxy/install.cmd.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,12 @@ const installAppProxyHandler = new Command({
.option('ingress-class', {
describe: 'the ingress class that will be used by the app-proxy ingress',
type: 'string',
})
.option('bypass-download', {
describe: 'Will bypass the attempt to download the installer. Instead, will immediately attempt to'
+ ' use the binary from the components folder',
default: false,
type: 'boolean',
}),

handler: async (_argv) => {
Expand All @@ -104,6 +110,7 @@ const installAppProxyHandler = new Command({
'set-value': setValues,
'ingress-class': ingressClass,
noExit,
'bypass-download': bypassDownload,
} = argv;
let {
host,
Expand Down Expand Up @@ -164,6 +171,7 @@ const installAppProxyHandler = new Command({
kubeContextName,
kubeNamespace,
dockerRegistry,
bypassDownload,
valuesFile: values,
setValue: setValues,
verbose,
Expand Down
9 changes: 8 additions & 1 deletion lib/interface/cli/commands/app-proxy/uninstall.cmd.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,12 @@ const uninstallAppProxyHandler = new Command({
})
.option('verbose', {
describe: 'Print logs',
})
.option('bypass-download', {
describe: 'Will bypass the attempt to download the installer. Instead, will immediately attempt to'
+ ' use the binary from the components folder',
default: false,
type: 'boolean',
}),
handler: async (_argv) => {
const argv = mergeWithValues(_argv);
Expand All @@ -87,6 +93,7 @@ const uninstallAppProxyHandler = new Command({
values,
'set-value': setValues,
noExit,
'bypass-download': bypassDownload,
} = argv;
let {
'kube-namespace': kubeNamespace,
Expand Down Expand Up @@ -145,7 +152,7 @@ const uninstallAppProxyHandler = new Command({
verbose,
valuesFile: values,
setValue: setValues,

bypassDownload,
}));
await handleError(uninstallErr, 'Failed to uninstall app-proxy');

Expand Down
8 changes: 8 additions & 0 deletions lib/interface/cli/commands/app-proxy/upgrade.cmd.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,12 @@ const upgradeAppProxyHandler = new Command({
})
.option('verbose', {
describe: 'Print logs',
})
.option('bypass-download', {
describe: 'Will bypass the attempt to download the installer. Instead, will immediately attempt to'
+ ' use the binary from the components folder',
default: false,
type: 'boolean',
}),
handler: async (_argv) => {
const argv = mergeWithValues(_argv);
Expand All @@ -59,6 +65,7 @@ const upgradeAppProxyHandler = new Command({
values,
'set-value': setValues,
noExit,
'bypass-download': bypassDownload,
} = argv;
let {
'kube-namespace': kubeNamespace,
Expand Down Expand Up @@ -87,6 +94,7 @@ const upgradeAppProxyHandler = new Command({
verbose,
valuesFile: values,
setValue: setValues,
bypassDownload,
}));
handleError(upgradeErr, 'Failed to upgrade app-proxy');

Expand Down
24 changes: 14 additions & 10 deletions lib/interface/cli/commands/hybrid/helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ const DEMO_STEP_IMAGE = {
'docker.io': 'alpine:latest',
'quay.io': 'quay.io/codefresh/alpine:3.11',
'gcr.io': 'gcr.io/google-containers/alpine-with-bash',
default: 'quay.io/codefresh/alpine:3.11'
}
default: 'quay.io/codefresh/alpine:3.11',
};

const maxRuntimeNameLength = 63;
const DefaultLogFormatter = 'plain';
Expand Down Expand Up @@ -156,10 +156,10 @@ async function updateTestPipelineRuntime(pipeline, runtimeName, pipelineName, do
name: runtimeName,
};

let demoStepImage = DEMO_STEP_IMAGE[dockerRegistry] || DEMO_STEP_IMAGE.default;
const demoStepImage = DEMO_STEP_IMAGE[dockerRegistry] || DEMO_STEP_IMAGE.default;

_pipeline.spec.steps.test.image = demoStepImage;

await sdk.pipelines.replace(
{ name: _pipeline.metadata.name },
{
Expand Down Expand Up @@ -375,11 +375,11 @@ async function attemptDownload(location, component) {
return await to(downloader.download(component));
}

async function downloadVeonona(location = CODEFRESH_PATH, bypassDownload = false) {
async function downloadVeonona(location = CODEFRESH_PATH, bypassDownload = false) {
if (await bypassDownloadSuccess(bypassDownload, components.venona.local.dir, components.venona.local.binary)) {
return path.resolve(process.cwd(), INSTALLATION_DEFAULTS.COMPONENTS_FOLDER);
}

const [error] = await attemptDownload(location, components.venona);
if (error) {
if (await bypassDownloadSuccess(!bypassDownload, components.venona.local.dir, components.venona.local.binary)) {
Expand All @@ -395,7 +395,7 @@ async function downloadVeonona(location = CODEFRESH_PATH, bypassDownload = false

async function downloadProvider({ provider, location = CODEFRESH_PATH }, bypassDownload = false) {
const localSettings = components.gitops[provider].local;

if (await bypassDownloadSuccess(bypassDownload, localSettings.dir, localSettings.binary)) {
return path.resolve(process.cwd(), INSTALLATION_DEFAULTS.COMPONENTS_FOLDER);
}
Expand Down Expand Up @@ -429,7 +429,7 @@ async function downloadSteveDore(location = CODEFRESH_PATH, bypassDownload = fal
return location;
}

async function downloadHybridComponents(location, bypassDownload = false) {
async function downloadHybridComponents(location, bypassDownload = false) {
await downloadVeonona(location, bypassDownload);
console.log(`Kubernetes components installer downloaded successfully to ${location} `);
await downloadSteveDore(location, bypassDownload);
Expand Down Expand Up @@ -494,7 +494,7 @@ async function runClusterAcceptanceTests({
await componentRunner.run(components.venona, cmd);
}

async function runUpgrade({ kubeNamespace, kubeContextName }) {
async function runUpgrade({ kubeNamespace, kubeContextName, bypassDownload }) {
const binLocation = await downloadVeonona(undefined, bypassDownload);
const componentRunner = new Runner(binLocation);
const cmd = ['upgrade', '--log-formtter', DefaultLogFormatter];
Expand Down Expand Up @@ -531,7 +531,7 @@ async function installAgent({
setValue, // --set-value
setFile, // --set-file
}) {
const binLocation = await downloadVeonona(undefined, bypassDownload);
const binLocation = await downloadVeonona(undefined, bypassDownload);
const componentRunner = new Runner(binLocation);
const cmd = [
'install',
Expand Down Expand Up @@ -695,6 +695,7 @@ async function installAppProxy({
verbose, // --verbose
dockerRegistry, // --docker-registry
logFormatting = DefaultLogFormatter, // --log-formtter
bypassDownload, // --bypass-download
valuesFile, // --values
setValue, // --set-value
setFile, // --set-file
Expand Down Expand Up @@ -771,6 +772,7 @@ async function unInstallAppProxy({
kubeNamespace, // --kube-namespace
kubeConfigPath, // --kube-config-path
verbose, // --verbose
bypassDownload, // --bypass-download
logFormatting = DefaultLogFormatter, // --log-formtter
valuesFile, // --values
setValue, // --set-value
Expand Down Expand Up @@ -812,6 +814,7 @@ async function upgradeAppProxy({
kubeNamespace, // --kube-namespace
kubeConfigPath, // --kube-config-path
verbose, // --verbose
bypassDownload, // --bypass-download
logFormatting = DefaultLogFormatter, // --log-formtter
valuesFile, // --values
setValue, // --set-value
Expand Down Expand Up @@ -971,6 +974,7 @@ async function newAgentName(kubeContextName, kubeNamespace, agents) {

return name;
}

function keyValueAsStringToObject(nodeSelectorStr) {
if (nodeSelectorStr) {
const kubeNodeSelectorObj = {};
Expand Down
13 changes: 7 additions & 6 deletions lib/interface/cli/commands/hybrid/init.cmd.js
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ const initCmd = new Command({
describe: 'Will save all of the manifests to be deployed on the cluster to: ./manifests/',
default: false,
type: 'boolean',
})
})
.option('bypass-download', {
describe: 'Will bypass the attempt to download the installer. Instead, will immediately attempt to use the binary from the components folder',
default: false,
Expand Down Expand Up @@ -284,7 +284,7 @@ const initCmd = new Command({
userVolumeMounts,
userVolumes,
'dry-run': dryRun,
'bypass-download': bypassDownload
'bypass-download': bypassDownload,
} = _argv;

const shouldUseHelm = !!helmValuesFile;
Expand Down Expand Up @@ -747,6 +747,7 @@ const initCmd = new Command({
valuesFile,
setValue,
setFile,
bypassDownload,
appProxyHost,
appProxyIngressClass,
dryRun,
Expand Down Expand Up @@ -924,20 +925,20 @@ const initCmd = new Command({
installationPlan.getContext('runtimeName'),
INSTALLATION_DEFAULTS.DEMO_PIPELINE_NAME,
['echo hello Codefresh Runner!'],
dockerRegistry
dockerRegistry,
);
},
installationEvent: installationProgress.events.PIPELINE_CREATED,
});
} else {
installationPlan.addStep({
installationPlan.addStep({
name: 'update test pipeline runtime',
func: async () => {
await updateTestPipelineRuntime(
await updateTestPipelineRuntime(
undefined,
installationPlan.getContext('runtimeName'),
INSTALLATION_DEFAULTS.DEMO_PIPELINE_NAME,
dockerRegistry
dockerRegistry,
);
},
errMessage: colors.yellow('*warning* could not update test pipeline runtime, you can' +
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "codefresh",
"version": "0.75.15",
"version": "0.75.16",
"description": "Codefresh command line utility",
"main": "index.js",
"preferGlobal": true,
Expand Down

0 comments on commit 9da53b5

Please sign in to comment.