Skip to content

Commit

Permalink
Saas 7627 - run in cluster mode (#515)
Browse files Browse the repository at this point in the history
  • Loading branch information
roi-codefresh authored Jun 25, 2020
1 parent 12a9431 commit ca31665
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 19 deletions.
11 changes: 8 additions & 3 deletions codefresh.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,16 @@ steps:
image-name: codefresh/cli
tag: ${{CF_BRANCH_TAG_NORMALIZED}}

push_to_registry_revision:
title: "Pushing image tagged with revision to registry"
push_step:
type: push
tag: '${{CF_SHORT_REVISION}}'
candidate: ${{build_step}}
tag: ${{CF_SHORT_REVISION}}
scale:
push_to_dockerhub:
registry: dockerhub
title: "push to dockerhub"
push_to_gcr:
title: "push to gcr"

execute_release_pipeline:
title: "Execute release pipeline in case version was changed"
Expand Down
32 changes: 17 additions & 15 deletions lib/interface/cli/helpers/kubernetes.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,28 @@
const path = require('path');
const fs = require('fs');
const { KubeConfig, Client } = require('kubernetes-client');
const Request = require('kubernetes-client/backends/request');
const _ = require('lodash');
const { homedir } = require('os');

const _getKubeConfig = (kubeconfigPath) => {
const kc = new KubeConfig();
const kubePath = kubeconfigPath || process.env.KUBECONFIG || path.join(homedir(), '.kube', 'config');
if (fs.existsSync(kubePath)) {
kc.loadFromFile(kubePath);
} else {
kc.loadFromCluster();
}

return kc;
}

const getKubeContext = (kubeconfigPath) => {
// eslint-disable-next-line global-require
const homedir = require('os').homedir();
const kubePath = kubeconfigPath || process.env.KUBECONFIG || path.join(homedir, '.kube', 'config');
const kubeconfig = new KubeConfig();
kubeconfig.loadFromFile(kubePath);
const kubeconfig = _getKubeConfig(kubeconfigPath);
return kubeconfig.currentContext;
};
const getAllKubeContexts = (kubeconfigPath) => {
// eslint-disable-next-line global-require
const homedir = require('os').homedir();
const kubePath = kubeconfigPath || process.env.KUBECONFIG || path.join(homedir, '.kube', 'config');
const kubeconfig = new KubeConfig();
kubeconfig.loadFromFile(kubePath);
const kubeconfig = _getKubeConfig(kubeconfigPath);
const { contexts } = kubeconfig;
if (contexts) {
return contexts.reduce((acc, curr) => {
Expand All @@ -26,11 +32,7 @@ const getAllKubeContexts = (kubeconfigPath) => {
}
};
const getAllNamespaces = async (kubeconfigPath, kubeContextName) => {
// eslint-disable-next-line global-require
const homedir = require('os').homedir();
const kubePath = kubeconfigPath || process.env.KUBECONFIG || path.join(homedir, '.kube', 'config');
const kubeconfig = new KubeConfig();
kubeconfig.loadFromFile(kubePath);
const kubeconfig = _getKubeConfig(kubeconfigPath);
kubeconfig.setCurrentContext(kubeContextName);
const backend = new Request({ kubeconfig });
const client = new Client({ backend, version: 1.13 });
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.69.0",
"version": "0.69.2",
"description": "Codefresh command line utility",
"main": "index.js",
"preferGlobal": true,
Expand Down

0 comments on commit ca31665

Please sign in to comment.