@@ -26,14 +26,12 @@ import (
2626const (
2727 configurationFlag = "configuration"
2828 albNameFlag = "name"
29- poolNameFlag = "pool"
3029)
3130
3231type inputModel struct {
3332 * globalflags.GlobalFlagModel
3433 Configuration * string
3534 AlbName * string
36- Poolname * string
3735}
3836
3937func NewCmd (p * print.Printer ) * cobra.Command {
@@ -44,8 +42,8 @@ func NewCmd(p *print.Printer) *cobra.Command {
4442 Args : args .NoArgs ,
4543 Example : examples .Build (
4644 examples .NewExample (
47- `Update an application target pool from a configuration file` ,
48- "$ stackit beta alb update --configuration my-target pool.json" ),
45+ `Update an application target pool from a configuration file (the name of the pool is read from the file) ` ,
46+ "$ stackit beta alb update --configuration my-target- pool.json --name my-load-balancer " ),
4947 ),
5048 RunE : func (cmd * cobra.Command , _ []string ) error {
5149 ctx := context .Background ()
@@ -94,8 +92,7 @@ func NewCmd(p *print.Printer) *cobra.Command {
9492func configureFlags (cmd * cobra.Command ) {
9593 cmd .Flags ().StringP (configurationFlag , "c" , "" , "filename of the input configuration file" )
9694 cmd .Flags ().StringP (albNameFlag , "n" , "" , "name of the target pool name to update" )
97- cmd .Flags ().StringP (poolNameFlag , "t" , "" , "name of the target pool to update" )
98- err := flags .MarkFlagsRequired (cmd , configurationFlag , albNameFlag , poolNameFlag )
95+ err := flags .MarkFlagsRequired (cmd , configurationFlag , albNameFlag )
9996 cobra .CheckErr (err )
10097}
10198
@@ -109,7 +106,6 @@ func parseInput(p *print.Printer, cmd *cobra.Command) (*inputModel, error) {
109106 GlobalFlagModel : globalFlags ,
110107 Configuration : flags .FlagToStringPointer (p , cmd , configurationFlag ),
111108 AlbName : flags .FlagToStringPointer (p , cmd , albNameFlag ),
112- Poolname : flags .FlagToStringPointer (p , cmd , poolNameFlag ),
113109 }
114110
115111 if p .IsVerbosityDebug () {
@@ -129,7 +125,10 @@ func buildRequest(ctx context.Context, model *inputModel, apiClient *alb.APIClie
129125 if err != nil {
130126 return req , err
131127 }
132- req = apiClient .UpdateTargetPool (ctx , model .ProjectId , model .Region , * model .AlbName , * model .Poolname )
128+ if payload .Name == nil {
129+ return req , fmt .Errorf ("update target pool: no poolname provided" )
130+ }
131+ req = apiClient .UpdateTargetPool (ctx , model .ProjectId , model .Region , * model .AlbName , * payload .Name )
133132 return req .UpdateTargetPoolPayload (payload ), nil
134133}
135134
0 commit comments