codefresh 0.84.10 → 0.86.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Dockerfile +12 -6
- package/Dockerfile-debian +15 -6
- package/Dockerfile-debian-rootless +15 -7
- package/Dockerfile-rootless +13 -7
- package/__mocks__/codefresh.yml +40 -0
- package/docs/index.js +19 -18
- package/lib/interface/cli/commands/agent/install.cmd.js +191 -113
- package/lib/interface/cli/commands/root/root.sdk.spec.js +1 -1
- package/lib/interface/cli/commands/runtimeEnvironments/attach.cmd.js +105 -84
- package/lib/interface/cli/commands/runtimeEnvironments/install.cmd.js +216 -188
- package/lib/interface/cli/completion/tree.json +1 -1
- package/package.json +3 -3
- package/codefresh-arm.yml +0 -253
- package/codefresh-release.yml +0 -482
- package/codefresh.yml +0 -373
package/Dockerfile
CHANGED
|
@@ -10,20 +10,26 @@ ENV PATH="/pyinstaller:$PATH"
|
|
|
10
10
|
RUN pip install yq==${YQ_VERSION}
|
|
11
11
|
RUN pyinstaller --noconfirm --onefile --log-level DEBUG --clean --distpath /tmp/ $(which yq)
|
|
12
12
|
|
|
13
|
+
# kubectl binary
|
|
14
|
+
FROM bitnami/kubectl:1.27.4 as kubectl
|
|
15
|
+
|
|
13
16
|
# Main
|
|
14
|
-
FROM node:18.17.1-alpine3.
|
|
17
|
+
FROM node:18.17.1-alpine3.18
|
|
15
18
|
|
|
16
|
-
RUN apk --update add --no-cache
|
|
19
|
+
RUN apk --update add --no-cache \
|
|
20
|
+
bash \
|
|
21
|
+
ca-certificates \
|
|
22
|
+
curl \
|
|
23
|
+
git \
|
|
24
|
+
jq
|
|
17
25
|
|
|
18
26
|
COPY --from=go /go/bin/hub /usr/local/bin/hub
|
|
19
27
|
COPY --from=yq /tmp/yq /usr/local/bin/yq
|
|
28
|
+
COPY --from=kubectl /opt/bitnami/kubectl/bin/kubectl /usr/local/bin/
|
|
20
29
|
|
|
21
30
|
WORKDIR /cf-cli
|
|
22
31
|
|
|
23
|
-
COPY package.json /cf-cli
|
|
24
|
-
COPY yarn.lock /cf-cli
|
|
25
|
-
COPY check-version.js /cf-cli
|
|
26
|
-
COPY run-check-version.js /cf-cli
|
|
32
|
+
COPY package.json yarn.lock check-version.js run-check-version.js /cf-cli/
|
|
27
33
|
|
|
28
34
|
RUN yarn install --prod --frozen-lockfile && \
|
|
29
35
|
yarn cache clean
|
package/Dockerfile-debian
CHANGED
|
@@ -10,21 +10,30 @@ ENV PATH="/pyinstaller:$PATH"
|
|
|
10
10
|
RUN pip install yq==${YQ_VERSION}
|
|
11
11
|
RUN pyinstaller --noconfirm --onefile --log-level DEBUG --clean --distpath /tmp/ $(which yq)
|
|
12
12
|
|
|
13
|
+
# kubectl binary
|
|
14
|
+
FROM bitnami/kubectl:1.27.4 as kubectl
|
|
15
|
+
|
|
13
16
|
# Main
|
|
14
17
|
FROM node:18.17.1-bullseye-slim
|
|
15
18
|
|
|
16
|
-
RUN apt update
|
|
17
|
-
|
|
19
|
+
RUN apt update \
|
|
20
|
+
&& apt -y install \
|
|
21
|
+
apt-transport-https \
|
|
22
|
+
bash \
|
|
23
|
+
busybox \
|
|
24
|
+
ca-certificates \
|
|
25
|
+
curl \
|
|
26
|
+
git \
|
|
27
|
+
jq \
|
|
28
|
+
&& ln -s /bin/busybox /usr/bin/[[
|
|
18
29
|
|
|
19
30
|
COPY --from=go /go/bin/hub /usr/local/bin/hub
|
|
20
31
|
COPY --from=yq /tmp/yq /usr/local/bin/yq
|
|
32
|
+
COPY --from=kubectl /opt/bitnami/kubectl/bin/kubectl /usr/local/bin/
|
|
21
33
|
|
|
22
34
|
WORKDIR /cf-cli
|
|
23
35
|
|
|
24
|
-
COPY package.json /cf-cli
|
|
25
|
-
COPY yarn.lock /cf-cli
|
|
26
|
-
COPY check-version.js /cf-cli
|
|
27
|
-
COPY run-check-version.js /cf-cli
|
|
36
|
+
COPY package.json yarn.lock check-version.js run-check-version.js /cf-cli/
|
|
28
37
|
|
|
29
38
|
RUN yarn install --prod --frozen-lockfile && \
|
|
30
39
|
yarn cache clean
|
|
@@ -10,21 +10,29 @@ ENV PATH="/pyinstaller:$PATH"
|
|
|
10
10
|
RUN pip install yq==${YQ_VERSION}
|
|
11
11
|
RUN pyinstaller --noconfirm --onefile --log-level DEBUG --clean --distpath /tmp/ $(which yq)
|
|
12
12
|
|
|
13
|
+
# kubectl binary
|
|
14
|
+
FROM bitnami/kubectl:1.27.4 as kubectl
|
|
15
|
+
|
|
13
16
|
# Main
|
|
14
17
|
FROM node:18.17.1-bullseye-slim
|
|
15
18
|
|
|
16
|
-
RUN apt update
|
|
17
|
-
|
|
19
|
+
RUN apt update \
|
|
20
|
+
&& apt -y install \
|
|
21
|
+
bash \
|
|
22
|
+
busybox \
|
|
23
|
+
ca-certificates \
|
|
24
|
+
curl \
|
|
25
|
+
git \
|
|
26
|
+
jq \
|
|
27
|
+
&& ln -s /bin/busybox /usr/bin/[[
|
|
18
28
|
|
|
19
29
|
COPY --from=go /go/bin/hub /usr/local/bin/hub
|
|
20
30
|
COPY --from=yq /tmp/yq /usr/local/bin/yq
|
|
31
|
+
COPY --from=kubectl /opt/bitnami/kubectl/bin/kubectl /usr/local/bin/
|
|
21
32
|
|
|
22
33
|
WORKDIR /cf-cli
|
|
23
34
|
|
|
24
|
-
COPY package.json /cf-cli
|
|
25
|
-
COPY yarn.lock /cf-cli
|
|
26
|
-
COPY check-version.js /cf-cli
|
|
27
|
-
COPY run-check-version.js /cf-cli
|
|
35
|
+
COPY package.json yarn.lock check-version.js run-check-version.js /cf-cli/
|
|
28
36
|
|
|
29
37
|
RUN yarn install --prod --frozen-lockfile && \
|
|
30
38
|
yarn cache clean
|
|
@@ -38,7 +46,7 @@ RUN ln -s $(pwd)/lib/interface/cli/codefresh /usr/local/bin/codefresh
|
|
|
38
46
|
RUN codefresh components update --location components
|
|
39
47
|
|
|
40
48
|
# we keep /root as home directory because cli by default looks for $HOME/.cfconfig
|
|
41
|
-
# and we do not want to break user automation if
|
|
49
|
+
# and we do not want to break user automation if they used to bind their .cfconfig
|
|
42
50
|
# to the /root/.cfconfig
|
|
43
51
|
RUN useradd -m -d /root -s /bin/sh cfu \
|
|
44
52
|
&& chown -R $(id -g cfu) /root /cf-cli \
|
package/Dockerfile-rootless
CHANGED
|
@@ -10,20 +10,26 @@ ENV PATH="/pyinstaller:$PATH"
|
|
|
10
10
|
RUN pip install yq==${YQ_VERSION}
|
|
11
11
|
RUN pyinstaller --noconfirm --onefile --log-level DEBUG --clean --distpath /tmp/ $(which yq)
|
|
12
12
|
|
|
13
|
+
# kubectl binary
|
|
14
|
+
FROM bitnami/kubectl:1.27.4 as kubectl
|
|
15
|
+
|
|
13
16
|
# Main
|
|
14
|
-
FROM node:18.17.1-alpine3.
|
|
17
|
+
FROM node:18.17.1-alpine3.18
|
|
15
18
|
|
|
16
|
-
RUN apk --update add --no-cache
|
|
19
|
+
RUN apk --update add --no-cache \
|
|
20
|
+
bash \
|
|
21
|
+
ca-certificates \
|
|
22
|
+
curl \
|
|
23
|
+
git \
|
|
24
|
+
jq
|
|
17
25
|
|
|
18
26
|
COPY --from=go /go/bin/hub /usr/local/bin/hub
|
|
19
27
|
COPY --from=yq /tmp/yq /usr/local/bin/yq
|
|
28
|
+
COPY --from=kubectl /opt/bitnami/kubectl/bin/kubectl /usr/local/bin/
|
|
20
29
|
|
|
21
30
|
WORKDIR /cf-cli
|
|
22
31
|
|
|
23
|
-
COPY package.json /cf-cli
|
|
24
|
-
COPY yarn.lock /cf-cli
|
|
25
|
-
COPY check-version.js /cf-cli
|
|
26
|
-
COPY run-check-version.js /cf-cli
|
|
32
|
+
COPY package.json yarn.lock check-version.js run-check-version.js /cf-cli/
|
|
27
33
|
|
|
28
34
|
RUN yarn install --prod --frozen-lockfile && \
|
|
29
35
|
yarn cache clean
|
|
@@ -37,7 +43,7 @@ RUN ln -s $(pwd)/lib/interface/cli/codefresh /usr/local/bin/codefresh
|
|
|
37
43
|
RUN codefresh components update --location components
|
|
38
44
|
|
|
39
45
|
# we keep /root as home directory because cli by default looks for $HOME/.cfconfig
|
|
40
|
-
# and we do not want to break user automation if
|
|
46
|
+
# and we do not want to break user automation if they used to bind their .cfconfig
|
|
41
47
|
# to the /root/.cfconfig
|
|
42
48
|
RUN adduser -D -h /root -s /bin/sh cfu \
|
|
43
49
|
&& chown -R $(id -g cfu) /root /cf-cli \
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# More examples of Codefresh YAML can be found at
|
|
2
|
+
# https://codefresh.io/docs/docs/yaml-examples/examples/
|
|
3
|
+
|
|
4
|
+
version: "1.0"
|
|
5
|
+
# Stages can help you organize your steps in stages
|
|
6
|
+
stages:
|
|
7
|
+
- "clone"
|
|
8
|
+
- "build"
|
|
9
|
+
- "test"
|
|
10
|
+
|
|
11
|
+
steps:
|
|
12
|
+
clone:
|
|
13
|
+
title: "Cloning repository"
|
|
14
|
+
type: "git-clone"
|
|
15
|
+
repo: "https://github.com/codefresh-io/cli/"
|
|
16
|
+
# Clone the master branch. Or, use ${{CF_BRANCH}} to get branch name from trigger
|
|
17
|
+
# Learn more at https://codefresh.io/docs/docs/codefresh-yaml/variables/
|
|
18
|
+
revision: "master"
|
|
19
|
+
stage: "clone"
|
|
20
|
+
|
|
21
|
+
build:
|
|
22
|
+
title: "Building Docker image"
|
|
23
|
+
type: "build"
|
|
24
|
+
image_name: "codefresh-io/cli"
|
|
25
|
+
working_directory: "${{clone}}"
|
|
26
|
+
# Set 'latest' tag on the image. Or, use built-in variables
|
|
27
|
+
# like ${{CF_BRANCH_TAG_NORMALIZED}} to use the current branch name/tag.
|
|
28
|
+
tag: "latest"
|
|
29
|
+
dockerfile: "Dockerfile"
|
|
30
|
+
stage: "build"
|
|
31
|
+
|
|
32
|
+
test:
|
|
33
|
+
title: "Running test"
|
|
34
|
+
type: "freestyle" # Run any command
|
|
35
|
+
image: "ubuntu:latest" # The image in which command will be executed
|
|
36
|
+
working_directory: "${{clone}}" # Running command where code cloned
|
|
37
|
+
commands:
|
|
38
|
+
- "ls"
|
|
39
|
+
stage: "test"
|
|
40
|
+
|
package/docs/index.js
CHANGED
|
@@ -16,21 +16,21 @@ const ALLOW_BETA_COMMANDS = process.env.ALLOW_BETA_COMMANDS;
|
|
|
16
16
|
const categoriesOrder = {
|
|
17
17
|
completion: 30,
|
|
18
18
|
authentication: 31,
|
|
19
|
-
'operate on resources'
|
|
20
|
-
pipelines
|
|
21
|
-
'pipelines v2 (beta)'
|
|
22
|
-
projects
|
|
19
|
+
'operate on resources': 32,
|
|
20
|
+
pipelines: 40,
|
|
21
|
+
'pipelines v2 (beta)': 42,
|
|
22
|
+
projects: 45,
|
|
23
23
|
builds: 50,
|
|
24
|
-
contexts
|
|
25
|
-
images
|
|
26
|
-
triggers
|
|
27
|
-
environments
|
|
28
|
-
compositions
|
|
29
|
-
'helm repos'
|
|
24
|
+
contexts: 70,
|
|
25
|
+
images: 80,
|
|
26
|
+
triggers: 90,
|
|
27
|
+
environments: 100,
|
|
28
|
+
compositions: 110,
|
|
29
|
+
'helm repos': 111,
|
|
30
30
|
'predefined pipelines': 120,
|
|
31
31
|
'cli config': 121,
|
|
32
32
|
teams: 130,
|
|
33
|
-
more
|
|
33
|
+
more: 150,
|
|
34
34
|
};
|
|
35
35
|
|
|
36
36
|
|
|
@@ -115,7 +115,7 @@ const getWeight = async (command) => {
|
|
|
115
115
|
}
|
|
116
116
|
};
|
|
117
117
|
|
|
118
|
-
const createCommandFile = async (nestedCategory,command) => {
|
|
118
|
+
const createCommandFile = async (nestedCategory, command) => {
|
|
119
119
|
const docs = command.prepareDocs();
|
|
120
120
|
const dir = path.resolve(baseDir, `${(nestedCategory || 'undefined').toLowerCase()}`);
|
|
121
121
|
|
|
@@ -216,7 +216,7 @@ const createCategoryFile = async (content, category) => {
|
|
|
216
216
|
* updates the category main file with a specific command
|
|
217
217
|
* possible extensions are: HEADER, COMMANDS
|
|
218
218
|
*/
|
|
219
|
-
const updateCategoryFileArray = async (nestedCategory,command, existingContent) => {
|
|
219
|
+
const updateCategoryFileArray = async (nestedCategory, command, existingContent) => {
|
|
220
220
|
const docs = command.prepareDocs();
|
|
221
221
|
const { category } = docs;
|
|
222
222
|
const finalCategoryArr = existingContent || {};
|
|
@@ -253,7 +253,7 @@ const updateCategoryFileArray = async (nestedCategory,command, existingContent)
|
|
|
253
253
|
finalCategoryArr.category = category;
|
|
254
254
|
newCmd.weight = await getWeight(command);
|
|
255
255
|
newCmd.content = commandString;
|
|
256
|
-
if (!finalCategoryArr.commands){
|
|
256
|
+
if (!finalCategoryArr.commands) {
|
|
257
257
|
finalCategoryArr.commands = [];
|
|
258
258
|
|
|
259
259
|
}
|
|
@@ -318,16 +318,16 @@ const createAutomatedDocs = async () => {
|
|
|
318
318
|
|
|
319
319
|
// document only in case category field exists and there are no sub commands under it
|
|
320
320
|
const docs = command.prepareDocs();
|
|
321
|
-
const {category} = docs;
|
|
321
|
+
const { category } = docs;
|
|
322
322
|
if (!category || await hasSubCommands(command)) {
|
|
323
323
|
continue;
|
|
324
324
|
}
|
|
325
325
|
|
|
326
326
|
nestedCategories[category] = await getNestedCategories(command);
|
|
327
327
|
const nestedCategory = nestedCategories[category];
|
|
328
|
-
categories[category] = await updateCategoryFileArray(nestedCategory,command, categories[category]);
|
|
328
|
+
categories[category] = await updateCategoryFileArray(nestedCategory, command, categories[category]);
|
|
329
329
|
await upsertCategoryFolder(nestedCategory);
|
|
330
|
-
await createCommandFile(nestedCategory,command);
|
|
330
|
+
await createCommandFile(nestedCategory, command);
|
|
331
331
|
}
|
|
332
332
|
|
|
333
333
|
let categoriesFinalContent = {};
|
|
@@ -356,7 +356,7 @@ const createDownloadPage = async () => {
|
|
|
356
356
|
links.push(asset.browser_download_url);
|
|
357
357
|
}));
|
|
358
358
|
const commandFilePath = path.resolve(baseDir, './installation/download.md');
|
|
359
|
-
const finalContent=
|
|
359
|
+
const finalContent =
|
|
360
360
|
'+++\n' +
|
|
361
361
|
'title = "Download"\n' +
|
|
362
362
|
'description = "asd"\n' +
|
|
@@ -372,6 +372,7 @@ const createDownloadPage = async () => {
|
|
|
372
372
|
' <li><a href=' + links[1] + ' target="_blank">Linux-x64</a></li>\n' +
|
|
373
373
|
' <li><a href=' + links[2] + ' target="_blank">Macos-x64</a></li>\n' +
|
|
374
374
|
' <li><a href=' + links[3] + ' target="_blank">Windows-x64</a></li>\n' +
|
|
375
|
+
' <li><a href=' + links[4] + ' target="_blank">Alpine-arm64</a></li>\n' +
|
|
375
376
|
'</ul> \n' +
|
|
376
377
|
'\n' +
|
|
377
378
|
'After downloading the binary, untar or unzip it and your are good to go.<br>\n' +
|
|
@@ -1,17 +1,160 @@
|
|
|
1
1
|
/* eslint-disable max-len */
|
|
2
|
+
const cliProgress = require('cli-progress');
|
|
3
|
+
const colors = require('colors');
|
|
2
4
|
const Command = require('../../Command');
|
|
3
5
|
const installRoot = require('../root/install.cmd');
|
|
4
6
|
const { sdk } = require('../../../../logic');
|
|
5
7
|
const installRuntimeCmd = require('../runtimeEnvironments/install.cmd');
|
|
6
8
|
const { getKubeContext } = require('../../helpers/kubernetes');
|
|
7
9
|
const ProgressEvents = require('../../helpers/progressEvents');
|
|
8
|
-
const cliProgress = require('cli-progress');
|
|
9
|
-
const colors = require('colors');
|
|
10
10
|
const { getNewAgentName } = require('./helper');
|
|
11
|
-
const { DefaultLogFormatter } = require('
|
|
11
|
+
const { DefaultLogFormatter } = require('../hybrid/helper');
|
|
12
|
+
const Output = require('../../../../output/Output');
|
|
12
13
|
|
|
13
14
|
const defaultNamespace = 'codefresh';
|
|
14
15
|
|
|
16
|
+
async function createAgent(argv) {
|
|
17
|
+
const {
|
|
18
|
+
name,
|
|
19
|
+
kubeConfigPath,
|
|
20
|
+
kubeContextName = getKubeContext(kubeConfigPath),
|
|
21
|
+
kubeNamespace = defaultNamespace,
|
|
22
|
+
} = argv;
|
|
23
|
+
const finalName = name || await getNewAgentName(kubeContextName, kubeNamespace);
|
|
24
|
+
try {
|
|
25
|
+
const { token } = await sdk.agents.create({ name: finalName });
|
|
26
|
+
console.log(`A Codefresh Runner with the name: ${colors.cyan(finalName)} has been created.`);
|
|
27
|
+
return token;
|
|
28
|
+
} catch (err) {
|
|
29
|
+
const msg = Output._extractErrorMessage(err);
|
|
30
|
+
if (msg.includes('Agent name duplication')) {
|
|
31
|
+
throw new Error(`A Codefresh Runner with the name "${colors.cyan(finalName)}" already exists. Please choose a different name, or delete the current agent from the platform.`);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
throw err;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
async function getAgentNameByToken(token) {
|
|
39
|
+
const [apiKey] = token.split('.');
|
|
40
|
+
const agentData = await sdk.tokens.getById({ id: apiKey });
|
|
41
|
+
if (!agentData) {
|
|
42
|
+
throw new Error('token is not valid');
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const {
|
|
46
|
+
subject: {
|
|
47
|
+
type,
|
|
48
|
+
ref,
|
|
49
|
+
},
|
|
50
|
+
} = agentData;
|
|
51
|
+
|
|
52
|
+
if (type !== 'agent') {
|
|
53
|
+
throw new Error('token is not assosicated with a runner');
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
const { name } = await sdk.agents.get({ agentId: ref });
|
|
57
|
+
return name;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
async function installAgentInCluster(argv, token, agentName) {
|
|
61
|
+
const {
|
|
62
|
+
kubeNodeSelector,
|
|
63
|
+
dryRun,
|
|
64
|
+
inCluster,
|
|
65
|
+
tolerations,
|
|
66
|
+
dockerRegistry,
|
|
67
|
+
skipVersionCheck,
|
|
68
|
+
kubeConfigPath,
|
|
69
|
+
kubeContextName = getKubeContext(kubeConfigPath),
|
|
70
|
+
kubeNamespace = defaultNamespace,
|
|
71
|
+
envVars,
|
|
72
|
+
verbose,
|
|
73
|
+
terminateProcess,
|
|
74
|
+
} = argv;
|
|
75
|
+
|
|
76
|
+
const apiHost = sdk.config.context.url;
|
|
77
|
+
const events = new ProgressEvents();
|
|
78
|
+
const format = 'downloading [{bar}] {percentage}% | {value}/{total}';
|
|
79
|
+
const progressBar = new cliProgress.SingleBar({ stopOnComplete: true, format }, cliProgress.Presets.shades_classic);
|
|
80
|
+
let totalSize;
|
|
81
|
+
events.onStart((size) => {
|
|
82
|
+
console.log('Downloading Codefresh Runner installer \n');
|
|
83
|
+
progressBar.start(size, 0);
|
|
84
|
+
totalSize = size;
|
|
85
|
+
});
|
|
86
|
+
events.onProgress((progress) => {
|
|
87
|
+
progressBar.update(progress);
|
|
88
|
+
if (progress >= totalSize) {
|
|
89
|
+
console.log('\n');
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
const agentInstallStatusCode = await sdk.agents.install({
|
|
93
|
+
agentId: agentName,
|
|
94
|
+
apiHost,
|
|
95
|
+
token,
|
|
96
|
+
kubeConfigPath,
|
|
97
|
+
kubeContextName,
|
|
98
|
+
kubeNamespace,
|
|
99
|
+
kubeNodeSelector,
|
|
100
|
+
inCluster,
|
|
101
|
+
dockerRegistry,
|
|
102
|
+
tolerations,
|
|
103
|
+
skipVersionCheck,
|
|
104
|
+
envVars,
|
|
105
|
+
events,
|
|
106
|
+
dryRun,
|
|
107
|
+
verbose,
|
|
108
|
+
terminateProcess,
|
|
109
|
+
logFormatting: DefaultLogFormatter,
|
|
110
|
+
});
|
|
111
|
+
if (agentInstallStatusCode !== 0) {
|
|
112
|
+
throw new Error(`\nRunner installation failed with code ${agentInstallStatusCode}`);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
async function installRuntimeFunc(argv, agentName) {
|
|
117
|
+
const {
|
|
118
|
+
runtimeName,
|
|
119
|
+
skipReCreation,
|
|
120
|
+
buildNodeSelector,
|
|
121
|
+
storageClassName,
|
|
122
|
+
setValue,
|
|
123
|
+
setFile,
|
|
124
|
+
agentKubeContextName,
|
|
125
|
+
agentKubeNamespace,
|
|
126
|
+
kubeConfigPath,
|
|
127
|
+
kubeContextName,
|
|
128
|
+
kubeNamespace,
|
|
129
|
+
skipClusterCreation,
|
|
130
|
+
makeDefaultRuntime,
|
|
131
|
+
platformOnly,
|
|
132
|
+
verbose,
|
|
133
|
+
terminateProcess,
|
|
134
|
+
} = argv;
|
|
135
|
+
await installRuntimeCmd.handler({
|
|
136
|
+
runtimeName,
|
|
137
|
+
skipReCreation,
|
|
138
|
+
skipClusterCreation,
|
|
139
|
+
runtimeKubeConfigPath: kubeConfigPath,
|
|
140
|
+
runtimeKubeContextName: kubeContextName,
|
|
141
|
+
runtimeKubeNamespace: kubeNamespace,
|
|
142
|
+
kubeNodeSelector: buildNodeSelector,
|
|
143
|
+
storageClassName,
|
|
144
|
+
setValue,
|
|
145
|
+
setFile,
|
|
146
|
+
makeDefaultRuntime,
|
|
147
|
+
attachRuntime: true,
|
|
148
|
+
agentName,
|
|
149
|
+
agentKubeContextName,
|
|
150
|
+
agentKubeNamespace,
|
|
151
|
+
restartAgent: true,
|
|
152
|
+
platformOnly,
|
|
153
|
+
verbose,
|
|
154
|
+
terminateProcess,
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
|
|
15
158
|
const installAgentCmd = new Command({
|
|
16
159
|
root: false,
|
|
17
160
|
parent: installRoot,
|
|
@@ -22,7 +165,7 @@ const installAgentCmd = new Command({
|
|
|
22
165
|
title: 'Install',
|
|
23
166
|
weight: 100,
|
|
24
167
|
},
|
|
25
|
-
builder: yargs => yargs
|
|
168
|
+
builder: (yargs) => yargs
|
|
26
169
|
.env('CF_ARG_') // this means that every process.env.CF_ARG_* will be passed to argv
|
|
27
170
|
.option('name', {
|
|
28
171
|
describe: 'Agent\'s name to be created if token is not provided',
|
|
@@ -57,6 +200,24 @@ const installAgentCmd = new Command({
|
|
|
57
200
|
.option('install-runtime', {
|
|
58
201
|
describe: 'Install and attach runtime on the same namespace as the agent (default is false)',
|
|
59
202
|
})
|
|
203
|
+
.option('runtime-name', {
|
|
204
|
+
describe: 'The name of the runtime to install',
|
|
205
|
+
})
|
|
206
|
+
.option('build-node-selector', {
|
|
207
|
+
describe: 'The kubernetes node selector "key=value" to be used by runner build resources (default is no node selector) (string)',
|
|
208
|
+
})
|
|
209
|
+
.option('skip-re-creation', {
|
|
210
|
+
description: 'If set to true, will skip runtime creation in the platform',
|
|
211
|
+
})
|
|
212
|
+
.option('set-value', {
|
|
213
|
+
describe: 'Set values for templates, example: --set-value LocalVolumesDir=/mnt/disks/ssd0/codefresh-volumes',
|
|
214
|
+
})
|
|
215
|
+
.option('set-file', {
|
|
216
|
+
describe: 'Set values for templates from file, example: --set-file Storage.GoogleServiceAccount=/path/to/service-account.json',
|
|
217
|
+
})
|
|
218
|
+
.option('skip-cluster-creation', {
|
|
219
|
+
description: 'If set to true, will skip cluster integration creation for this runtime',
|
|
220
|
+
})
|
|
60
221
|
.option('make-default-runtime', {
|
|
61
222
|
describe: 'should all pipelines run on the hybrid runtime (default is false)',
|
|
62
223
|
})
|
|
@@ -73,132 +234,49 @@ const installAgentCmd = new Command({
|
|
|
73
234
|
describe: 'The prefix for the container registry that will be used for pulling the required components images. Example: --docker-registry="docker.io"',
|
|
74
235
|
type: 'string',
|
|
75
236
|
})
|
|
237
|
+
.option('platform-only', {
|
|
238
|
+
describe: 'Set to true to create runtime on the platform side only',
|
|
239
|
+
})
|
|
76
240
|
.option('verbose', {
|
|
77
241
|
describe: 'Print logs',
|
|
78
242
|
}),
|
|
79
243
|
handler: async (argv) => {
|
|
80
|
-
let {
|
|
81
|
-
name, token,
|
|
82
|
-
} = argv;
|
|
83
244
|
const {
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
'build-node-selector': buildNodeSelector,
|
|
88
|
-
'dry-run': dryRun,
|
|
89
|
-
'in-cluster': inCluster,
|
|
90
|
-
tolerations,
|
|
91
|
-
'kube-config-path': kubeConfigPath,
|
|
92
|
-
'skip-version-check': skipVersionCheck,
|
|
93
|
-
'install-runtime': installRuntime,
|
|
94
|
-
'make-default-runtime': shouldMakeDefaultRe,
|
|
95
|
-
'storage-class-name': storageClassName,
|
|
96
|
-
verbose,
|
|
97
|
-
terminateProcess,
|
|
98
|
-
'set-value': setValue,
|
|
99
|
-
'set-file': setFile,
|
|
100
|
-
'agent-kube-context-name': agentKubeContextName,
|
|
101
|
-
'agent-kube-namespace': agentKubeNamespace,
|
|
102
|
-
'docker-registry': dockerRegistry,
|
|
103
|
-
envVars,
|
|
245
|
+
agentKubeNamespace,
|
|
246
|
+
installRuntime,
|
|
247
|
+
platformOnly,
|
|
104
248
|
} = argv;
|
|
105
|
-
let agent;
|
|
106
249
|
let {
|
|
107
|
-
|
|
108
|
-
|
|
250
|
+
name,
|
|
251
|
+
token,
|
|
109
252
|
} = argv;
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
}
|
|
113
|
-
if (!kubeNamespace) {
|
|
114
|
-
kubeNamespace = defaultNamespace;
|
|
115
|
-
}
|
|
116
|
-
if (installRuntime && !agentKubeNamespace) {
|
|
253
|
+
|
|
254
|
+
if (installRuntimeFunc && !agentKubeNamespace) {
|
|
117
255
|
throw new Error('agent-kube-namespace is a mandatory parameter when installing runtime');
|
|
118
256
|
}
|
|
119
257
|
|
|
120
|
-
if (!token) {
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
// eslint-disable-next-line prefer-destructuring
|
|
124
|
-
token = agent.token;
|
|
125
|
-
console.log(`A Codefresh Runner with the name: ${colors.cyan(name)} has been created.`);
|
|
258
|
+
if (!token) {
|
|
259
|
+
// Create an agent if not provided
|
|
260
|
+
token = await createAgent(argv);
|
|
126
261
|
} else {
|
|
127
|
-
// take the agent
|
|
128
|
-
const
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
262
|
+
// take the agent name from the token
|
|
263
|
+
const nameFromToken = await getAgentNameByToken(token);
|
|
264
|
+
if (!name) {
|
|
265
|
+
name = nameFromToken;
|
|
266
|
+
} else if (name !== nameFromToken) {
|
|
267
|
+
throw new Error(`token is assosicated with agent ${nameFromToken}, different from supplied '--name ${name}'`);
|
|
132
268
|
}
|
|
133
|
-
const { subject } = agentData;
|
|
134
|
-
|
|
135
|
-
if (subject.type !== 'agent') {
|
|
136
|
-
throw new Error('token is not assosicated with a runner');
|
|
137
|
-
}
|
|
138
|
-
const agentId = agentData.subject.ref;
|
|
139
|
-
const data = await sdk.agents.get({ agentId });
|
|
140
|
-
// eslint-disable-next-line prefer-destructuring
|
|
141
|
-
name = data.name;
|
|
142
269
|
}
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
const progressBar = new cliProgress.SingleBar({ stopOnComplete: true, format }, cliProgress.Presets.shades_classic);
|
|
147
|
-
let totalSize;
|
|
148
|
-
events.onStart((size) => {
|
|
149
|
-
console.log('Downloading Codefresh Runner installer \n');
|
|
150
|
-
progressBar.start(size, 0);
|
|
151
|
-
totalSize = size;
|
|
152
|
-
});
|
|
153
|
-
events.onProgress((progress) => {
|
|
154
|
-
progressBar.update(progress);
|
|
155
|
-
if (progress >= totalSize) {
|
|
156
|
-
console.log('\n');
|
|
157
|
-
}
|
|
158
|
-
});
|
|
159
|
-
const agentInstallStatusCode = await sdk.agents.install({
|
|
160
|
-
apiHost,
|
|
161
|
-
kubeContextName,
|
|
162
|
-
kubeNamespace,
|
|
163
|
-
token,
|
|
164
|
-
dryRun,
|
|
165
|
-
inCluster,
|
|
166
|
-
kubeNodeSelector,
|
|
167
|
-
dockerRegistry,
|
|
168
|
-
tolerations,
|
|
169
|
-
kubeConfigPath,
|
|
170
|
-
skipVersionCheck,
|
|
171
|
-
verbose,
|
|
172
|
-
agentId: name,
|
|
173
|
-
terminateProcess,
|
|
174
|
-
events,
|
|
175
|
-
logFormatting: DefaultLogFormatter,
|
|
176
|
-
envVars,
|
|
177
|
-
});
|
|
178
|
-
if (agentInstallStatusCode !== 0) {
|
|
179
|
-
throw new Error(`\nRunner installation failed with code ${agentInstallStatusCode}`);
|
|
270
|
+
|
|
271
|
+
if (!platformOnly) {
|
|
272
|
+
await installAgentInCluster(argv, token, name);
|
|
180
273
|
}
|
|
274
|
+
|
|
181
275
|
if (installRuntime) {
|
|
182
|
-
|
|
183
|
-
'runtime-name': reName,
|
|
184
|
-
'skip-re-creation': skipRuntimeCreation,
|
|
185
|
-
'runtime-kube-context-name': kubeContextName,
|
|
186
|
-
'runtime-kube-namespace': kubeNamespace,
|
|
187
|
-
'agent-name': name,
|
|
188
|
-
'runtime-kube-config-path': kubeConfigPath,
|
|
189
|
-
'attach-runtime': true,
|
|
190
|
-
'restart-agent': true,
|
|
191
|
-
'make-default-runtime': shouldMakeDefaultRe,
|
|
192
|
-
'kube-node-selector': buildNodeSelector,
|
|
193
|
-
'storage-class-name': storageClassName,
|
|
194
|
-
'set-value': setValue,
|
|
195
|
-
'set-file': setFile,
|
|
196
|
-
'agent-kube-namespace': agentKubeNamespace,
|
|
197
|
-
'agent-kube-context-name': agentKubeContextName,
|
|
198
|
-
verbose,
|
|
199
|
-
terminateProcess,
|
|
200
|
-
});
|
|
276
|
+
await installRuntimeFunc(argv, name);
|
|
201
277
|
}
|
|
278
|
+
|
|
279
|
+
console.log(token);
|
|
202
280
|
},
|
|
203
281
|
});
|
|
204
282
|
|
|
@@ -140,7 +140,7 @@ describe('root commands', () => {
|
|
|
140
140
|
describe('Not valid yaml ', async () => {
|
|
141
141
|
it('should throw error for not valid file', async () => {
|
|
142
142
|
const argv = {
|
|
143
|
-
filenames: ['./codefresh.yml'],
|
|
143
|
+
filenames: ['./__mocks__/codefresh.yml'],
|
|
144
144
|
};
|
|
145
145
|
const result = await validateCmd.handler(argv)
|
|
146
146
|
.catch(err => err);
|