Skip to content

Commit 6eb076c

Browse files
calculate default value to kube-context (#421)
1 parent 33cf848 commit 6eb076c

File tree

3 files changed

+16
-5
lines changed

3 files changed

+16
-5
lines changed

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

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ const Command = require('../../Command');
44
const { sdk } = require('../../../../logic');
55
const ProgressEvents = require('../../helpers/progressEvents');
66
const cliProgress = require('cli-progress');
7-
7+
const { getKubeContext } = require('../../helpers/kubernetes');
88

99
const attachAgentToRuntime = async (agent, name) => {
1010
const rt = await sdk.runtimeEnvs.get({ name });
@@ -72,16 +72,18 @@ const attachRuntimeCmd = new Command({
7272
'agent-name': agentName,
7373
'runtime-name': runtimeName,
7474
'agent-id': agentId,
75-
'runtime-kube-context-name': kubeContextName,
7675
'runtime-kube-namespace': kubeNamespace,
7776
'runtime-kube-config-path': kubeConfigPath,
78-
'agent-kube-context-name': agentKubeContextName,
7977
'agent-kube-namespace': agentKubeNamespace,
8078
'agent-kube-config-path': agentKubeConfigPath,
8179
'restart-agent': restartAgent,
8280
verbose,
8381

8482
} = argv;
83+
let {
84+
'runtime-kube-context-name': kubeContextName,
85+
'agent-kube-context-name': agentKubeContextName,
86+
} = argv;
8587
const { terminateProcess } = argv;
8688
let agent;
8789
if (_.isNull(runtimeName) || _.isUndefined(runtimeName) || runtimeName === '') {
@@ -100,6 +102,12 @@ const attachRuntimeCmd = new Command({
100102
if (!kubeNamespace) {
101103
throw new Error('runtime-kube-namespace is mandatory parameter');
102104
}
105+
if (!kubeContextName) {
106+
kubeContextName = getKubeContext(kubeConfigPath);
107+
}
108+
if (!agentKubeContextName) {
109+
agentKubeContextName = kubeContextName;
110+
}
103111

104112
await attachAgentToRuntime(agent, runtimeName);
105113

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,6 @@ const installRuntimeCmd = new Command({
9999
const {
100100
'storage-class-name': storageClassName,
101101
'agent-name': agentName,
102-
'runtime-kube-context-name': kubeContextName,
103102
'dry-run': dryRun,
104103
'runtime-kube-namespace': kubeNamespace,
105104
'in-cluster': inCluster,
@@ -112,6 +111,7 @@ const installRuntimeCmd = new Command({
112111
} = argv;
113112

114113
let {
114+
'runtime-kube-context-name': kubeContextName,
115115
'agent-kube-context-name': agentKubeContextName,
116116
'agent-kube-namespace': agentKubeNamespace,
117117
'agent-kube-config-path': agentKubeConfigPath,
@@ -123,6 +123,9 @@ const installRuntimeCmd = new Command({
123123
}
124124

125125
const apiHost = sdk.config.context.url;
126+
if (!kubeContextName) {
127+
kubeContextName = getKubeContext(kubeConfigPath);
128+
}
126129
const clusterName = kubeContextName || getKubeContext(kubeConfigPath);
127130
const runtimeName = `${clusterName}/${kubeNamespace}`;
128131

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

0 commit comments

Comments
 (0)