Skip to content

Commit

Permalink
allowed portable to run without mounting kube config file.
Browse files Browse the repository at this point in the history
  • Loading branch information
rubenhak committed Aug 4, 2020
1 parent 2962cda commit 059b0d9
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 9 deletions.
13 changes: 13 additions & 0 deletions run-dev-docker-mac-min.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash
MY_PATH="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/$(basename "${BASH_SOURCE[0]}")"
MY_DIR="$(dirname $MY_PATH)"
cd $MY_DIR

docker run --rm -it \
-p 5001:5001 \
-e NODE_ENV=development \
-v ~/.kube/config:/root/.kube/config:ro \
kubevious/portable:dev

# -v ~/.kube/config:/root/.kube/config:ro \

17 changes: 8 additions & 9 deletions src/lib/cluster/engine.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,16 @@ class ClusterEngine
init()
{
var configFilePath = process.env.KUBECONFIG || '~/.kube/config';
return this._setConfig(this._loadConfigFile(configFilePath))

return this._loadConfigFile(configFilePath)
.then(data => {
return this._setConfig(data)
});
}

_setConfig(configData)
_setConfig(config)
{
return configData
.then(config => {
return Promise.resolve()
.then(() => {
config = config || {};
config.contexts = config.contexts || [];
config.clusters = config.clusters || [];
Expand Down Expand Up @@ -133,16 +135,13 @@ class ClusterEngine
this.logger.error('Failed to load %s. Details: ', fileName, reason);
console.log('Make sure that ~/.kube/config file is properly mounted.')
console.log('Visit https://github.com/kubevious/portable for details')
process.exit(1);

return null;
});
}

createConfig(data)
{
const configData = Promise.resolve(yaml.safeLoad(data.config))

const configData = yaml.safeLoad(data.config);
return this._setConfig(configData)
.then(() => ({ clusters: this._clustersList, success: true }))
}
Expand Down

0 comments on commit 059b0d9

Please sign in to comment.