@@ -48,7 +48,7 @@ the current directory or from the directory specified with --path.
4848 cmd .Flags ().StringP ("output" , "o" , "human" , "Output format (human|json) ($FUNC_OUTPUT)" )
4949
5050 configEnvsAddCmd := NewConfigEnvsAddCmd (loadSaver )
51- configEnvsRemoveCmd := NewConfigEnvsRemoveCmd ()
51+ configEnvsRemoveCmd := NewConfigEnvsRemoveCmd (loadSaver )
5252
5353 addPathFlag (cmd )
5454 addPathFlag (configEnvsAddCmd )
@@ -139,8 +139,8 @@ set environment variable from a secret
139139 return cmd
140140}
141141
142- func NewConfigEnvsRemoveCmd () * cobra.Command {
143- return & cobra.Command {
142+ func NewConfigEnvsRemoveCmd (loadSaver functionLoaderSaver ) * cobra.Command {
143+ cmd := & cobra.Command {
144144 Use : "remove" ,
145145 Short : "Remove environment variable from the function configuration" ,
146146 Long : `Remove environment variable from the function configuration
@@ -150,17 +150,40 @@ in the current directory or from the directory specified with --path.
150150` ,
151151 Aliases : []string {"rm" },
152152 SuggestFor : []string {"del" , "delete" , "rmeove" },
153- PreRunE : bindEnv ("path" , "verbose" ),
153+ PreRunE : bindEnv ("path" , "name" , " verbose" ),
154154 RunE : func (cmd * cobra.Command , args []string ) (err error ) {
155- function , err := initConfigCommand (defaultLoaderSaver )
155+ function , err := initConfigCommand (loadSaver )
156156 if err != nil {
157157 return
158158 }
159159
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+
160180 return runRemoveEnvsPrompt (function )
161181 },
162182 }
163183
184+ cmd .Flags ().StringP ("name" , "" , "" , "Name of the environment variable." )
185+ return cmd
186+
164187}
165188
166189func listEnvs (f fn.Function , w io.Writer , outputFormat Format ) error {
0 commit comments