Skip to content

make agent-kube-namespace as mandatory #474

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 24, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions lib/interface/cli/commands/agent/install.cmd.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,12 @@ const installAgentCmd = new Command({
.option('skip-cluster-test', {
describe: 'Do not run cluster acceptance test',
})
.option('agent-kube-context-name', {
describe: 'Agent kubernetes context (on attach)',
})
.option('agent-kube-namespace', {
describe: 'Agent\'s namespace (on attach)',
})
.option('verbose', {
describe: 'Print logs',
}),
Expand All @@ -114,6 +120,8 @@ const installAgentCmd = new Command({
terminateProcess,
'set-value': setValue,
'set-file': setFile,
'agent-kube-context-name': agentKubeContextName,
'agent-kube-namespace': agentKubeNamespace,
} = argv;
let agent;
let {
Expand All @@ -126,6 +134,9 @@ const installAgentCmd = new Command({
if (!kubeNamespace) {
kubeNamespace = defaultNamespace;
}
if (installRuntime && !agentKubeNamespace) {
throw new Error('agent-kube-namespace is a mandatory parameter when installing runtime');
}

if (!token) { // Create an agent if not provided
name = name || await newAgentName(kubeContextName, kubeNamespace);
Expand Down Expand Up @@ -202,6 +213,8 @@ const installAgentCmd = new Command({
'storage-class-name': storageClassName,
'set-value': setValue,
'set-file': setFile,
'agent-kube-namespace': agentKubeNamespace,
'agent-kube-context-name': agentKubeContextName,
verbose,
terminateProcess,
});
Expand Down
2 changes: 2 additions & 0 deletions lib/interface/cli/commands/hybrid/init.cmd.js
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,8 @@ const initCmd = new Command({
terminateProcess: false,
'set-value': setValue,
'set-file': setFile,
'agent-kube-context-name': kubeContextName,
'agent-kube-namespace': kubeNamespace,
};
const [runnerErr, runtimeName] = await to(installAgent.handler(agentInstallOptions));
await handleError(runnerErr, 'Runner installation failed', progressReporter, installationProgress.events.RUNNER_INSTALLED);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ async function newRuntimeName(kubeContextName, kubeNamespace) {
let suggestName;
// eslint-disable-next-line no-constant-condition
while (true) {
suggestName = `${defaultName.slice(0, maxRuntimeNameLength - 2)}_${i}`;
suggestName = `${defaultName.slice(0, maxRuntimeNameLength - 1 - i.toString().length)}_${i}`;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

la league

if (!reNames.has(suggestName)) {
break;
}
Expand Down Expand Up @@ -91,9 +91,6 @@ const installRuntimeCmd = new Command({
.option('attach-runtime', {
describe: 'if set to true, auto attach runtime to agent (need to provide ....)',
})
.option('agent-kube-namespace', {
describe: 'Agent\'s namespace',
})
.option('agent-kube-config-path', {
describe: 'Path to kubeconfig file for the agent (default is $HOME/.kube/config)',
})
Expand Down Expand Up @@ -150,6 +147,9 @@ const installRuntimeCmd = new Command({
if (!kubeNamespace) {
kubeNamespace = defaultNamespace;
}
if (attachRuntime && !agentKubeNamespace) {
throw new Error('agent-kube-namespace is a mandatory parameter');
}

// parse kubeNodeSelector in form key1=value1,key2=value2 to {key1: value1, key2: value2}
const kubeNodeSelectorObj = {};
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.64.2",
"version": "0.64.3",
"description": "Codefresh command line utility",
"main": "index.js",
"preferGlobal": true,
Expand Down