Skip to content

Commit 4116f06

Browse files
make agent-kube-namespace as mandatory (#474)
1 parent efb66d9 commit 4116f06

File tree

4 files changed

+20
-5
lines changed

4 files changed

+20
-5
lines changed

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,12 @@ const installAgentCmd = new Command({
9090
.option('skip-cluster-test', {
9191
describe: 'Do not run cluster acceptance test',
9292
})
93+
.option('agent-kube-context-name', {
94+
describe: 'Agent kubernetes context (on attach)',
95+
})
96+
.option('agent-kube-namespace', {
97+
describe: 'Agent\'s namespace (on attach)',
98+
})
9399
.option('verbose', {
94100
describe: 'Print logs',
95101
}),
@@ -114,6 +120,8 @@ const installAgentCmd = new Command({
114120
terminateProcess,
115121
'set-value': setValue,
116122
'set-file': setFile,
123+
'agent-kube-context-name': agentKubeContextName,
124+
'agent-kube-namespace': agentKubeNamespace,
117125
} = argv;
118126
let agent;
119127
let {
@@ -126,6 +134,9 @@ const installAgentCmd = new Command({
126134
if (!kubeNamespace) {
127135
kubeNamespace = defaultNamespace;
128136
}
137+
if (installRuntime && !agentKubeNamespace) {
138+
throw new Error('agent-kube-namespace is a mandatory parameter when installing runtime');
139+
}
129140

130141
if (!token) { // Create an agent if not provided
131142
name = name || await newAgentName(kubeContextName, kubeNamespace);
@@ -202,6 +213,8 @@ const installAgentCmd = new Command({
202213
'storage-class-name': storageClassName,
203214
'set-value': setValue,
204215
'set-file': setFile,
216+
'agent-kube-namespace': agentKubeNamespace,
217+
'agent-kube-context-name': agentKubeContextName,
205218
verbose,
206219
terminateProcess,
207220
});

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,8 @@ const initCmd = new Command({
338338
terminateProcess: false,
339339
'set-value': setValue,
340340
'set-file': setFile,
341+
'agent-kube-context-name': kubeContextName,
342+
'agent-kube-namespace': kubeNamespace,
341343
};
342344
const [runnerErr, runtimeName] = await to(installAgent.handler(agentInstallOptions));
343345
await handleError(runnerErr, 'Runner installation failed', progressReporter, installationProgress.events.RUNNER_INSTALLED);

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ async function newRuntimeName(kubeContextName, kubeNamespace) {
2626
let suggestName;
2727
// eslint-disable-next-line no-constant-condition
2828
while (true) {
29-
suggestName = `${defaultName.slice(0, maxRuntimeNameLength - 2)}_${i}`;
29+
suggestName = `${defaultName.slice(0, maxRuntimeNameLength - 1 - i.toString().length)}_${i}`;
3030
if (!reNames.has(suggestName)) {
3131
break;
3232
}
@@ -91,9 +91,6 @@ const installRuntimeCmd = new Command({
9191
.option('attach-runtime', {
9292
describe: 'if set to true, auto attach runtime to agent (need to provide ....)',
9393
})
94-
.option('agent-kube-namespace', {
95-
describe: 'Agent\'s namespace',
96-
})
9794
.option('agent-kube-config-path', {
9895
describe: 'Path to kubeconfig file for the agent (default is $HOME/.kube/config)',
9996
})
@@ -150,6 +147,9 @@ const installRuntimeCmd = new Command({
150147
if (!kubeNamespace) {
151148
kubeNamespace = defaultNamespace;
152149
}
150+
if (attachRuntime && !agentKubeNamespace) {
151+
throw new Error('agent-kube-namespace is a mandatory parameter');
152+
}
153153

154154
// parse kubeNodeSelector in form key1=value1,key2=value2 to {key1: value1, key2: value2}
155155
const kubeNodeSelectorObj = {};

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.64.2",
3+
"version": "0.64.3",
44
"description": "Codefresh command line utility",
55
"main": "index.js",
66
"preferGlobal": true,

0 commit comments

Comments
 (0)