@@ -21,8 +21,6 @@ func appUpdateSettingsCommand(commonFlags []cli.Flag, clientConfig *types.Client
2121 Subcommands : []* cli.Command {
2222 appUpdateStageWrite (commonFlags , clientConfig ),
2323 appUpdatePreviewWrite (commonFlags , clientConfig ),
24- appUpdateAuthnType (commonFlags , clientConfig ),
25- appUpdateGitAuth (commonFlags , clientConfig ),
2624 },
2725 }
2826}
@@ -151,123 +149,18 @@ The second required argument is <appPathGlob>. ` + PATH_SPEC_HELP + `
151149 }
152150}
153151
154- func appUpdateAuthnType (commonFlags []cli.Flag , clientConfig * types.ClientConfig ) * cli.Command {
155- flags := make ([]cli.Flag , 0 , len (commonFlags )+ 2 )
156- flags = append (flags , commonFlags ... )
157- flags = append (flags , dryRunFlag ())
158-
159- return & cli.Command {
160- Name : "auth" ,
161- Usage : "Update authentication mode for apps" ,
162- Flags : flags ,
163- Before : altsrc .InitInputSourceWithContext (flags , altsrc .NewTomlSourceFromFlagFunc (configFileFlagName )),
164- ArgsUsage : "<value:system|default|none|custom> <appPathGlob>" ,
165-
166- UsageText : `args: <value:default|none> <appPathGlob>
167-
168- The first required argument <value> is a string, system, default, none or OAuth entry name.
169- The second required argument is <appPathGlob>. ` + PATH_SPEC_HELP + `
170-
171- Examples:
172- Update all apps, across domains: openrun app update-settings auth default all
173- Update apps in the example.com domain: openrun app update-settings auth none "example.com:**"` ,
174-
175- Action : func (cCtx * cli.Context ) error {
176- if cCtx .NArg () != 2 {
177- return fmt .Errorf ("requires two arguments: <value> <appPathGlob>" )
178- }
179-
180- client := system .NewHttpClient (clientConfig .ServerUri , clientConfig .AdminUser , clientConfig .Client .AdminPassword , clientConfig .Client .SkipCertCheck )
181- values := url.Values {}
182- values .Add ("appPathGlob" , cCtx .Args ().Get (1 ))
183- values .Add (DRY_RUN_ARG , strconv .FormatBool (cCtx .Bool (DRY_RUN_FLAG )))
184-
185- body := types .CreateUpdateAppRequest ()
186- body .AuthnType = types .StringValue (cCtx .Args ().Get (0 ))
187-
188- var updateResponse types.AppUpdateSettingsResponse
189- if err := client .Post ("/_openrun/app_settings" , values , body , & updateResponse ); err != nil {
190- return err
191- }
192-
193- for _ , updateResult := range updateResponse .UpdateResults {
194- fmt .Printf ("Updating %s\n " , updateResult )
195- }
196- printStdout (cCtx , "%d app(s) updated.\n " , len (updateResponse .UpdateResults ))
197-
198- if updateResponse .DryRun {
199- fmt .Print (DRY_RUN_MESSAGE )
200- }
201-
202- return nil
203- },
204- }
205- }
206-
207- func appUpdateGitAuth (commonFlags []cli.Flag , clientConfig * types.ClientConfig ) * cli.Command {
208- flags := make ([]cli.Flag , 0 , len (commonFlags )+ 2 )
209- flags = append (flags , commonFlags ... )
210- flags = append (flags , dryRunFlag ())
211-
212- return & cli.Command {
213- Name : "git-auth" ,
214- Usage : "Update git-auth entry for apps" ,
215- Flags : flags ,
216- Before : altsrc .InitInputSourceWithContext (flags , altsrc .NewTomlSourceFromFlagFunc (configFileFlagName )),
217- ArgsUsage : "<entryName> <appPathGlob>" ,
218-
219- UsageText : `args: <entryName> <appPathGlob>
220-
221- The first required argument <entryName> is a string. Specify the git_auth entry key name as configured in the openrun.toml config.
222- Set to "-" to remove the git_auth entry.
223- The second required argument is <appPathGlob>. ` + PATH_SPEC_HELP + `
224-
225- Examples:
226- Update all apps, across domains: openrun app update-settings git-auth mygit all
227- Update apps in the example.com domain: openrun app git-auth gitentrykey "example.com:**"` ,
228-
229- Action : func (cCtx * cli.Context ) error {
230- if cCtx .NArg () != 2 {
231- return fmt .Errorf ("requires two arguments: <entryName> <appPathGlob>" )
232- }
233-
234- client := system .NewHttpClient (clientConfig .ServerUri , clientConfig .AdminUser , clientConfig .Client .AdminPassword , clientConfig .Client .SkipCertCheck )
235- values := url.Values {}
236- values .Add ("appPathGlob" , cCtx .Args ().Get (1 ))
237- values .Add (DRY_RUN_ARG , strconv .FormatBool (cCtx .Bool (DRY_RUN_FLAG )))
238-
239- body := types .CreateUpdateAppRequest ()
240- body .GitAuthName = types .StringValue (cCtx .Args ().Get (0 ))
241-
242- var updateResponse types.AppUpdateSettingsResponse
243- if err := client .Post ("/_openrun/app_settings" , values , body , & updateResponse ); err != nil {
244- return err
245- }
246-
247- for _ , updateResult := range updateResponse .UpdateResults {
248- fmt .Printf ("Updating %s\n " , updateResult )
249- }
250- printStdout (cCtx , "%d app(s) updated.\n " , len (updateResponse .UpdateResults ))
251-
252- if updateResponse .DryRun {
253- fmt .Print (DRY_RUN_MESSAGE )
254- }
255-
256- return nil
257- },
258- }
259- }
260-
261152func appUpdateMetadataCommand (commonFlags []cli.Flag , clientConfig * types.ClientConfig ) * cli.Command {
262153 return & cli.Command {
263- Name : "update-metadata " ,
154+ Name : "update" ,
264155 Usage : `Update OpenRun app metadata. Metadata updates are staged and have to be promoted to prod. Use "openrun param" to update app parameter metadata.` ,
265156 Subcommands : []* cli.Command {
266157 appUpdateAppSpec (commonFlags , clientConfig ),
267- appUpdateConfig (commonFlags , clientConfig , "container-option" , "copt" , types .AppMetadataContainerOptions ),
268- appUpdateConfig (commonFlags , clientConfig , "container-arg" , "carg" , types .AppMetadataContainerArgs ),
269- appUpdateConfig (commonFlags , clientConfig , "container-volumes" , "cvol" , types .AppMetadataContainerVolumes ),
270- appUpdateConfig (commonFlags , clientConfig , "app-config" , "conf" , types .AppMetadataAppConfig ),
158+ appUpdateConfig (commonFlags , clientConfig , "container-option" , "copt" , types .AppMetadataContainerOptions , "option" ),
159+ appUpdateConfig (commonFlags , clientConfig , "container-arg" , "carg" , types .AppMetadataContainerArgs , "arg" ),
160+ appUpdateConfig (commonFlags , clientConfig , "container-volumes" , "cvol" , types .AppMetadataContainerVolumes , "volume" ),
161+ appUpdateConfig (commonFlags , clientConfig , "app-config" , "conf" , types .AppMetadataAppConfig , "config" ),
162+ appUpdateConfig (commonFlags , clientConfig , "auth" , "" , types .AppMetadataAuthnType , "<auth_type>" ),
163+ appUpdateConfig (commonFlags , clientConfig , "git-auth" , "" , types .AppMetadataGitAuthName , "<git_auth>" ),
271164 },
272165 }
273166}
@@ -291,8 +184,8 @@ The first required argument <value> is a string, a valid app spec name or - (to
291184The last required argument is <appPathGlob>. ` + PATH_SPEC_HELP + `
292185
293186 Examples:
294- Update all apps, across domains: openrun app update-metadata spec - all
295- Update apps in the example.com domain: openrun app update-metadata spec proxy "example.com:**"` ,
187+ Update all apps, across domains: openrun app update spec - all
188+ Update apps in the example.com domain: openrun app update spec proxy "example.com:**"` ,
296189
297190 Action : func (cCtx * cli.Context ) error {
298191 if cCtx .NArg () != 2 {
@@ -340,27 +233,25 @@ The last required argument is <appPathGlob>. ` + PATH_SPEC_HELP + `
340233}
341234
342235// appUpdateConfig creates a command to update app metadata config
343- func appUpdateConfig (commonFlags []cli.Flag , clientConfig * types.ClientConfig , arg string , shortFlag string , configType types.AppMetadataConfigType ) * cli.Command {
236+ func appUpdateConfig (commonFlags []cli.Flag , clientConfig * types.ClientConfig , arg string , shortFlag string , configType types.AppMetadataConfigType , valName string ) * cli.Command {
344237 flags := make ([]cli.Flag , 0 , len (commonFlags )+ 2 )
345238 flags = append (flags , commonFlags ... )
346239 flags = append (flags , dryRunFlag ())
347240 flags = append (flags , newBoolFlag (PROMOTE_FLAG , "p" , "Promote the change from stage to prod" , false ))
348241
349- return & cli.Command {
242+ cmd := & cli.Command {
350243 Name : arg ,
351- Aliases : []string {shortFlag },
352244 Usage : fmt .Sprintf ("Update %s metadata for apps" , arg ),
353245 Flags : flags ,
354246 Before : altsrc .InitInputSourceWithContext (flags , altsrc .NewTomlSourceFromFlagFunc (configFileFlagName )),
355- ArgsUsage : "key=value <appPathGlob>" ,
247+ ArgsUsage : valName + " <appPathGlob>" ,
356248
357- UsageText : fmt .Sprintf (`args: key=value [key=value ...] <appPathGlob>
358- The initial arguments key=value are strings, the key to set and the value to use delimited by =. The value is optional for
359- container options. The last argument is <appPathGlob>. ` + PATH_SPEC_HELP + `
249+ UsageText : fmt .Sprintf (`args: ` + valName + ` <appPathGlob>
250+ The initial argument are strings. The last argument is <appPathGlob>. ` + PATH_SPEC_HELP + `
360251
361252 Examples:
362- Update all apps, across domains: openrun app update-metadata %s key=value all
363- Update apps in the example.com domain: openrun app update-metadata %s key=value "example.com:**"` , arg , arg ),
253+ Update all apps, across domains: openrun app update %s %s all
254+ Update apps in the example.com domain: openrun app update %s %s "example.com:**"` , arg , valName , arg , valName ),
364255
365256 Action : func (cCtx * cli.Context ) error {
366257 if cCtx .NArg () < 2 {
@@ -407,4 +298,8 @@ container options. The last argument is <appPathGlob>. `+PATH_SPEC_HELP+`
407298 return nil
408299 },
409300 }
301+ if shortFlag != "" {
302+ cmd .Aliases = []string {shortFlag }
303+ }
304+ return cmd
410305}
0 commit comments