File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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 ) ;
Original file line number Diff line number Diff line change 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" : {
You can’t perform that action at this time.
0 commit comments