Skip to content

Commit ca31665

Browse files
Saas 7627 - run in cluster mode (#515)
1 parent 12a9431 commit ca31665

File tree

3 files changed

+26
-19
lines changed

3 files changed

+26
-19
lines changed

codefresh.yml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,16 @@ steps:
3434
image-name: codefresh/cli
3535
tag: ${{CF_BRANCH_TAG_NORMALIZED}}
3636

37-
push_to_registry_revision:
38-
title: "Pushing image tagged with revision to registry"
37+
push_step:
3938
type: push
39+
tag: '${{CF_SHORT_REVISION}}'
4040
candidate: ${{build_step}}
41-
tag: ${{CF_SHORT_REVISION}}
41+
scale:
42+
push_to_dockerhub:
43+
registry: dockerhub
44+
title: "push to dockerhub"
45+
push_to_gcr:
46+
title: "push to gcr"
4247

4348
execute_release_pipeline:
4449
title: "Execute release pipeline in case version was changed"

lib/interface/cli/helpers/kubernetes.js

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,28 @@
11
const path = require('path');
2+
const fs = require('fs');
23
const { KubeConfig, Client } = require('kubernetes-client');
34
const Request = require('kubernetes-client/backends/request');
45
const _ = require('lodash');
6+
const { homedir } = require('os');
7+
8+
const _getKubeConfig = (kubeconfigPath) => {
9+
const kc = new KubeConfig();
10+
const kubePath = kubeconfigPath || process.env.KUBECONFIG || path.join(homedir(), '.kube', 'config');
11+
if (fs.existsSync(kubePath)) {
12+
kc.loadFromFile(kubePath);
13+
} else {
14+
kc.loadFromCluster();
15+
}
16+
17+
return kc;
18+
}
519

620
const getKubeContext = (kubeconfigPath) => {
7-
// eslint-disable-next-line global-require
8-
const homedir = require('os').homedir();
9-
const kubePath = kubeconfigPath || process.env.KUBECONFIG || path.join(homedir, '.kube', 'config');
10-
const kubeconfig = new KubeConfig();
11-
kubeconfig.loadFromFile(kubePath);
21+
const kubeconfig = _getKubeConfig(kubeconfigPath);
1222
return kubeconfig.currentContext;
1323
};
1424
const getAllKubeContexts = (kubeconfigPath) => {
15-
// eslint-disable-next-line global-require
16-
const homedir = require('os').homedir();
17-
const kubePath = kubeconfigPath || process.env.KUBECONFIG || path.join(homedir, '.kube', 'config');
18-
const kubeconfig = new KubeConfig();
19-
kubeconfig.loadFromFile(kubePath);
25+
const kubeconfig = _getKubeConfig(kubeconfigPath);
2026
const { contexts } = kubeconfig;
2127
if (contexts) {
2228
return contexts.reduce((acc, curr) => {
@@ -26,11 +32,7 @@ const getAllKubeContexts = (kubeconfigPath) => {
2632
}
2733
};
2834
const getAllNamespaces = async (kubeconfigPath, kubeContextName) => {
29-
// eslint-disable-next-line global-require
30-
const homedir = require('os').homedir();
31-
const kubePath = kubeconfigPath || process.env.KUBECONFIG || path.join(homedir, '.kube', 'config');
32-
const kubeconfig = new KubeConfig();
33-
kubeconfig.loadFromFile(kubePath);
35+
const kubeconfig = _getKubeConfig(kubeconfigPath);
3436
kubeconfig.setCurrentContext(kubeContextName);
3537
const backend = new Request({ kubeconfig });
3638
const client = new Client({ backend, version: 1.13 });

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

0 commit comments

Comments
 (0)