@@ -30,6 +30,13 @@ import (
30
30
)
31
31
32
32
type (
33
+ createContextOpts struct {
34
+ apiKey string
35
+ caCert string
36
+ name string
37
+ url string
38
+ }
39
+
33
40
updateGitOpsSettingsOpts struct {
34
41
gitProvider cfgit.ProviderType
35
42
gitApiURL string
@@ -74,10 +81,7 @@ commands, respectively:
74
81
}
75
82
76
83
func newConfigCreateContextCommand () * cobra.Command {
77
- var (
78
- apiKey string
79
- url string
80
- )
84
+ opts := & createContextOpts {}
81
85
82
86
cmd := & cobra.Command {
83
87
Use : "create-context NAME" ,
@@ -92,24 +96,26 @@ func newConfigCreateContextCommand() *cobra.Command {
92
96
return fmt .Errorf ("must provide context name to use" )
93
97
}
94
98
95
- return runConfigCreateContext (cmd .Context (), args [0 ], apiKey , url )
99
+ opts .name = args [0 ]
100
+ return runConfigCreateContext (cmd .Context (), opts )
96
101
},
97
102
}
98
103
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 " )
101
107
die (cmd .MarkFlagRequired ("api-key" ))
102
108
103
109
return cmd
104
110
}
105
111
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 {
108
114
return err
109
115
}
110
116
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 )
113
119
}
114
120
115
121
func newConfigGetContextsCommand () * cobra.Command {
0 commit comments