Skip to content

Commit c80d908

Browse files
author
Oleg Sucharevich
authored
Saas 6492 (#435)
* support creation of secret-store.kubernetes-runtime
1 parent 2632a4f commit c80d908

File tree

3 files changed

+69
-2
lines changed

3 files changed

+69
-2
lines changed
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
const debug = require('debug')('codefresh:cli:create:context:secret-store:kubernetes');
2+
const Command = require('../../../../../Command');
3+
const CFError = require('cf-errors');
4+
const cmd = require('../base.cmd');
5+
const { sdk } = require('../../../../../../../logic');
6+
7+
const command = new Command({
8+
command: 'kubernetes-runtime <name>',
9+
parent: cmd,
10+
description: 'Create a secret-store Kubernetes-Runtime context',
11+
usage: 'Create a secret store to use hybrid runtime to access K8S secret/configmap and use it as secret store',
12+
webDocs: {
13+
category: 'Create Secret-Store Context',
14+
subCategory: 'kubernetes-Runtime',
15+
title: 'kubernetes-runtime',
16+
weight: 10,
17+
},
18+
builder: (yargs) => {
19+
yargs
20+
.option('runtimes', {
21+
describe: 'Names of the runtime-environment to be used as secret store',
22+
type: 'array',
23+
default: ['*'],
24+
})
25+
.option('resource-type', {
26+
describe: 'Type of the resource in Kubernetes',
27+
required: true,
28+
choices: ['secret', 'configmap'],
29+
})
30+
.option('resource-name', {
31+
describe: 'Name of the resource in Kubernetes',
32+
required: true,
33+
});
34+
return yargs;
35+
},
36+
handler: async (argv) => {
37+
let runtimes = [];
38+
if (argv.runtime) {
39+
runtimes = argv.runtime;
40+
}
41+
const data = {
42+
apiVersion: 'v1',
43+
kind: 'context',
44+
metadata: {
45+
name: argv.name,
46+
},
47+
spec: {
48+
type: 'secret-store.kubernetes-runtime',
49+
data: {
50+
sharingPolicy: argv.sharingPolicy,
51+
resourceType: argv.resourceType,
52+
resourceName: argv.resourceName,
53+
runtimes,
54+
},
55+
},
56+
};
57+
58+
59+
if (!data.metadata.name || !data.spec.type) {
60+
throw new CFError('Name and type must be provided');
61+
}
62+
await sdk.contexts.create(data);
63+
console.log(`Context: ${data.metadata.name} created`);
64+
},
65+
});
66+
67+
module.exports = command;

lib/interface/cli/commands/context/get.cmd.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ const command = new Command({
2626
choices: [
2727
'config', 'git.bitbucket-server', 'git.bitbucket', 'git.github', 'git.gitlab',
2828
'git.stash', 'helm-repository', 'secret-yaml', 'secret', 'storage.gc', 'storage.s3', 'yaml',
29-
'secret-store.kubernetes',
29+
'secret-store.kubernetes', 'secret-store.kubernetes-runtime',
3030
],
3131
})
3232
.option('decrypt', {

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

0 commit comments

Comments
 (0)