@@ -48,7 +48,7 @@ the current directory or from the directory specified with --path.
48
48
cmd .Flags ().StringP ("output" , "o" , "human" , "Output format (human|json) ($FUNC_OUTPUT)" )
49
49
50
50
configEnvsAddCmd := NewConfigEnvsAddCmd (loadSaver )
51
- configEnvsRemoveCmd := NewConfigEnvsRemoveCmd ()
51
+ configEnvsRemoveCmd := NewConfigEnvsRemoveCmd (loadSaver )
52
52
53
53
addPathFlag (cmd )
54
54
addPathFlag (configEnvsAddCmd )
@@ -139,8 +139,8 @@ set environment variable from a secret
139
139
return cmd
140
140
}
141
141
142
- func NewConfigEnvsRemoveCmd () * cobra.Command {
143
- return & cobra.Command {
142
+ func NewConfigEnvsRemoveCmd (loadSaver functionLoaderSaver ) * cobra.Command {
143
+ cmd := & cobra.Command {
144
144
Use : "remove" ,
145
145
Short : "Remove environment variable from the function configuration" ,
146
146
Long : `Remove environment variable from the function configuration
@@ -150,17 +150,40 @@ in the current directory or from the directory specified with --path.
150
150
` ,
151
151
Aliases : []string {"rm" },
152
152
SuggestFor : []string {"del" , "delete" , "rmeove" },
153
- PreRunE : bindEnv ("path" , "verbose" ),
153
+ PreRunE : bindEnv ("path" , "name" , " verbose" ),
154
154
RunE : func (cmd * cobra.Command , args []string ) (err error ) {
155
- function , err := initConfigCommand (defaultLoaderSaver )
155
+ function , err := initConfigCommand (loadSaver )
156
156
if err != nil {
157
157
return
158
158
}
159
159
160
+ var name string
161
+ if cmd .Flags ().Changed ("name" ) {
162
+ s , e := cmd .Flags ().GetString ("name" )
163
+ if e != nil {
164
+ return e
165
+ }
166
+ name = s
167
+ }
168
+
169
+ if name != "" {
170
+ envs := []fn.Env {}
171
+ for _ , v := range function .Run .Envs {
172
+ if * v .Name != name {
173
+ envs = append (envs , v )
174
+ }
175
+ }
176
+ function .Run .Envs = envs
177
+ return loadSaver .Save (function )
178
+ }
179
+
160
180
return runRemoveEnvsPrompt (function )
161
181
},
162
182
}
163
183
184
+ cmd .Flags ().StringP ("name" , "" , "" , "Name of the environment variable." )
185
+ return cmd
186
+
164
187
}
165
188
166
189
func listEnvs (f fn.Function , w io.Writer , outputFormat Format ) error {
0 commit comments