diff --git a/codefresh.yml b/codefresh.yml index 1c9845f9f..13fa02510 100644 --- a/codefresh.yml +++ b/codefresh.yml @@ -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" diff --git a/lib/interface/cli/helpers/kubernetes.js b/lib/interface/cli/helpers/kubernetes.js index cf1ab0459..71aa0afd4 100644 --- a/lib/interface/cli/helpers/kubernetes.js +++ b/lib/interface/cli/helpers/kubernetes.js @@ -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) => { @@ -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 }); diff --git a/package.json b/package.json index 020af4e34..a63256b69 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "codefresh", - "version": "0.69.0", + "version": "0.69.2", "description": "Codefresh command line utility", "main": "index.js", "preferGlobal": true,