@@ -30,6 +30,13 @@ import (
3030)
3131
3232type (
33+ createContextOpts struct {
34+ apiKey string
35+ caCert string
36+ name string
37+ url string
38+ }
39+
3340 updateGitOpsSettingsOpts struct {
3441 gitProvider cfgit.ProviderType
3542 gitApiURL string
@@ -74,10 +81,7 @@ commands, respectively:
7481}
7582
7683func newConfigCreateContextCommand () * cobra.Command {
77- var (
78- apiKey string
79- url string
80- )
84+ opts := & createContextOpts {}
8185
8286 cmd := & cobra.Command {
8387 Use : "create-context NAME" ,
@@ -92,24 +96,26 @@ func newConfigCreateContextCommand() *cobra.Command {
9296 return fmt .Errorf ("must provide context name to use" )
9397 }
9498
95- return runConfigCreateContext (cmd .Context (), args [0 ], apiKey , url )
99+ opts .name = args [0 ]
100+ return runConfigCreateContext (cmd .Context (), opts )
96101 },
97102 }
98103
99- cmd .Flags ().StringVar (& apiKey , "api-key" , "" , "API key" )
100- cmd .Flags ().StringVar (& url , "url" , store .Get ().DefaultAPI , "Codefresh system custom url " )
104+ cmd .Flags ().StringVar (& opts .apiKey , "api-key" , "" , "API key" )
105+ cmd .Flags ().StringVar (& opts .caCert , "ca-cert" , "" , "Codefresh Platform certificate file (for on-prem)" )
106+ cmd .Flags ().StringVar (& opts .url , "url" , store .Get ().DefaultAPI , "Codefresh system custom url " )
101107 die (cmd .MarkFlagRequired ("api-key" ))
102108
103109 return cmd
104110}
105111
106- func runConfigCreateContext (ctx context.Context , context , apiKey , url string ) error {
107- if err := cfConfig .CreateContext (ctx , context , apiKey , url ); err != nil {
112+ func runConfigCreateContext (ctx context.Context , opts * createContextOpts ) error {
113+ if err := cfConfig .CreateContext (ctx , opts . name , opts . apiKey , opts . url , opts . caCert ); err != nil {
108114 return err
109115 }
110116
111- log .G ().Infof ("New context created: \" %s\" " , context )
112- return runConfigUseContext (ctx , context )
117+ log .G ().Infof ("New context created: \" %s\" " , opts . name )
118+ return runConfigUseContext (ctx , opts . name )
113119}
114120
115121func newConfigGetContextsCommand () * cobra.Command {
0 commit comments