Skip to content

Commit a3ab32a

Browse files
Saas 7914 - add docker-registry option to runner init (#530)
1 parent 2e41b10 commit a3ab32a

File tree

7 files changed

+51
-1
lines changed

7 files changed

+51
-1
lines changed

lib/interface/cli/commands/agent/install.cmd.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,10 @@ const installAgentCmd = new Command({
7272
.option('agent-kube-namespace', {
7373
describe: 'Agent\'s namespace (on attach)',
7474
})
75+
.option('docker-registry', {
76+
describe: 'The prefix for the container registry that will be used for pulling the required components images. Example: --docker-registry="docker.io"',
77+
type: 'string',
78+
})
7579
.option('verbose', {
7680
describe: 'Print logs',
7781
}),
@@ -99,6 +103,7 @@ const installAgentCmd = new Command({
99103
'set-file': setFile,
100104
'agent-kube-context-name': agentKubeContextName,
101105
'agent-kube-namespace': agentKubeNamespace,
106+
'docker-registry': dockerRegistry,
102107
envVars,
103108
} = argv;
104109
let agent;
@@ -163,6 +168,7 @@ const installAgentCmd = new Command({
163168
dryRun,
164169
inCluster,
165170
kubeNodeSelector,
171+
dockerRegistry,
166172
kubernetesRunnerType,
167173
tolerations,
168174
kubeConfigPath,

lib/interface/cli/commands/hybrid/helper.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -405,6 +405,7 @@ async function installAgent({
405405
agentId, // --agnetId
406406
kubeContextName, // kube-context-name
407407
kubeNamespace, // --kube-namespace
408+
dockerRegistry, // --docker-registry
408409
token, // --agentToken
409410
kubeNodeSelector, // --kube-node-selector
410411
dryRun, // --dryRun
@@ -439,6 +440,10 @@ async function installAgent({
439440
cmd.push(kubeNodeSelector);
440441
}
441442

443+
if (dockerRegistry) {
444+
cmd.push(`--docker-registry=${dockerRegistry}`);
445+
}
446+
442447
if (token) {
443448
cmd.push(`--agentToken=${token}`);
444449
}
@@ -478,6 +483,7 @@ async function installRuntime({
478483
token, // --agent-token
479484
kubeContextName, // kube-context-name
480485
kubeNamespace, // --kube-namespace
486+
dockerRegistry, // --docker-registry
481487
dryRun, // --dryRun
482488
inCluster, // -inCluster
483489
kubernetesRunnerType, // --kubernetes-runner-type
@@ -507,6 +513,10 @@ async function installRuntime({
507513
logFormatting,
508514
];
509515

516+
if (dockerRegistry) {
517+
cmd.push(`--docker-registry=${dockerRegistry}`);
518+
}
519+
510520
if (dryRun) {
511521
cmd.push('--dry-run');
512522
}

lib/interface/cli/commands/hybrid/init.cmd.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,10 @@ const initCmd = new Command({
125125
.option('storage-class-name', {
126126
describe: 'Set a name of your custom storage class',
127127
})
128+
.option('docker-registry', {
129+
describe: 'The prefix for the container registry that will be used for pulling the required components images. Example: --docker-registry="docker.io"',
130+
type: 'string',
131+
})
128132
.option('kube-config-path', {
129133
describe: 'Path to kubeconfig file (default is $HOME/.kube/config)',
130134
})
@@ -183,6 +187,7 @@ const initCmd = new Command({
183187
'set-file': setFile,
184188
'skip-cluster-test': skipClusterTest,
185189
'install-monitor': installMonitor,
190+
'docker-registry': dockerRegistry,
186191
} = _argv;
187192
let {
188193
'kube-context-name': kubeContextName,
@@ -397,6 +402,7 @@ const initCmd = new Command({
397402
kubeNodeSelector,
398403
tolerations,
399404
kubeConfigPath,
405+
dockerRegistry,
400406
verbose,
401407
agentId: installationPlan.getContext('agentName'),
402408
envVars: serealizeToKeyValuePairs(envVars),
@@ -487,6 +493,7 @@ const initCmd = new Command({
487493
kubeConfigPath,
488494
verbose,
489495
kubeNodeSelector,
496+
dockerRegistry,
490497
setValue,
491498
setFile,
492499
storageClassName,
@@ -548,6 +555,7 @@ const initCmd = new Command({
548555
'cluster-id': kubeContextName,
549556
'kube-context-name': kubeContextName,
550557
'kube-namespace': kubeNamespace,
558+
'docker-registry': dockerRegistry,
551559
token: _.get(sdk, 'config.context.token'),
552560
verbose,
553561
noExit: true, // to prevent if from calling inner: process.exit()

lib/interface/cli/commands/hybrid/upgrade.cmd.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,10 +89,21 @@ const upgradeCmd = new Command({
8989

9090
const [listAgentsErr, agents] = await to(sdk.agents.list({ }));
9191
await handleError(listAgentsErr, 'Failed to get agents');
92+
const agentsByName = agents.reduce((acc, cur) => ({ ...acc, [cur.name]: cur }), {});
9293

9394
console.log(colors.green('This upgrader will guide you through the runner upgrade process'));
9495

9596
let runtimeVersion;
97+
98+
if (agentName && agentsByName[agentName]) {
99+
const agent = agentsByName[agentName];
100+
const attachedRuntimes = agent.runtimes || [];
101+
if (attachedRuntimes.length === 1) {
102+
[runtimeName] = attachedRuntimes;
103+
console.log(`Chose to upgrade runner: "${colors.cyan(agentName)}" and runtime: "${colors.cyan(runtimeName)}"`);
104+
}
105+
}
106+
96107
if (!runtimeName) {
97108
const runtimesWithVersions = getRuntimesWithVersions(runtimes, agents);
98109
if (!_.size(runtimesWithVersions)) {

lib/interface/cli/commands/monitor/install.cmd.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@ const installMonitorCmd = new Command({
3333
.option('kube-namespace', {
3434
describe: 'Name of the namespace on which monitor should be installed [$CF_ARG_KUBE_NAMESPACE]',
3535
})
36+
.option('docker-registry', {
37+
describe: 'The prefix for the container registry that will be used for pulling the required components images. Example: --docker-registry="docker.io"',
38+
type: 'string',
39+
})
3640
.option('verbose', {
3741
describe: 'Print logs',
3842
}),
@@ -44,6 +48,7 @@ const installMonitorCmd = new Command({
4448
token,
4549
'kube-context-name': kubeContextName,
4650
'kube-namespace': kubeNamespace,
51+
'docker-registry': dockerRegistry,
4752
verbose,
4853
// noExit,
4954
} = argv;
@@ -90,6 +95,10 @@ const installMonitorCmd = new Command({
9095
commands.push(`--log-formtter=${DefaultLogFormatter}`);
9196
}
9297

98+
if (dockerRegistry) {
99+
commands.push(`--docker-registry=${dockerRegistry}`);
100+
}
101+
93102
await componentRunner.run(components.venona, commands);
94103
},
95104
});

lib/interface/cli/commands/runtimeEnvironments/install.cmd.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,10 @@ const installRuntimeCmd = new Command({
6666
.option('kube-node-selector', {
6767
describe: 'The kubernetes node selector "key=value" to be used by runner build resources (default is no node selector) (string)',
6868
})
69+
.option('docker-registry', {
70+
describe: 'The prefix for the container registry that will be used for pulling the required components images. Example: --docker-registry="docker.io"',
71+
type: 'string',
72+
})
6973
.option('set-value', {
7074
describe: 'Set values for templates, example: --set-value LocalVolumesDir=/mnt/disks/ssd0/codefresh-volumes',
7175
})
@@ -132,6 +136,7 @@ const installRuntimeCmd = new Command({
132136
'attach-runtime': attachRuntime,
133137
'cluster-service-account': clusterServiceAccount,
134138
'make-default-runtime': shouldMakeDefaultRe,
139+
'docker-registry': dockerRegistry,
135140
terminateProcess,
136141
} = argv;
137142

@@ -252,6 +257,7 @@ const installRuntimeCmd = new Command({
252257
inCluster,
253258
kubernetesRunnerType,
254259
kubeConfigPath,
260+
dockerRegistry,
255261
verbose,
256262
kubeNodeSelector,
257263
setValue,

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "codefresh",
3-
"version": "0.70.3",
3+
"version": "0.70.4",
44
"description": "Codefresh command line utility",
55
"main": "index.js",
66
"preferGlobal": true,

0 commit comments

Comments
 (0)