Skip to content

Commit af11cf7

Browse files
Merge pull request #104 from codefresh-io/CR-15884
fix cli not functional after deleting current-context
2 parents 71e82f1 + 91058b8 commit af11cf7

2 files changed

Lines changed: 9 additions & 3 deletions

File tree

lib/Config.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ class Config {
4040
url,
4141
context: contextName,
4242
configPath = process.env[defaults.CF_CONFIG_ENV] || defaults.CF_CONFIG_PATH,
43+
allowNoContext,
4344
} = options;
4445

4546
debug('trying to load from file:', configPath);
@@ -66,8 +67,10 @@ class Config {
6667
if (!context) {
6768
debug(`using current context: '${manager.currentContextName}'`);
6869
context = manager.getCurrentContext();
69-
if (!context) {
70-
const message = 'Failed to create context from file - no current context';
70+
if (!context && !allowNoContext) {
71+
const message = 'Failed to create context from file - '
72+
+ `Current context "${manager.currentContextName}" does not exist.`
73+
+ ' You must select another context using \'auth use-context <context>\'';
7174
debug(message);
7275
throw new CFError(message);
7376
}
@@ -215,6 +218,9 @@ class Config {
215218
static async _initializeConfig(context, options = {}) {
216219
debug('_initializeConfig');
217220
if (!context) {
221+
if (options.allowNoContext) {
222+
return new Config({ context, options });
223+
}
218224
const message = 'Context is not provided';
219225
debug(message);
220226
throw new CFError(message);

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "codefresh-sdk",
3-
"version": "1.11.1",
3+
"version": "1.11.2",
44
"description": "Codefresh_api_swagger_3_0_specification",
55
"main": "index.js",
66
"author": {

0 commit comments

Comments
 (0)