@@ -11,6 +11,7 @@ import (
11
11
12
12
func (r * RootCmd ) update () * serpent.Command {
13
13
var (
14
+ force bool
14
15
parameterFlags workspaceParameterFlags
15
16
bflags buildFlags
16
17
)
@@ -29,6 +30,19 @@ func (r *RootCmd) update() *serpent.Command {
29
30
if err != nil {
30
31
return err
31
32
}
33
+
34
+ // update command with --force flag is used as an alias for restart.
35
+ // It can be used to update the workspace parameters for an already up-to-date workspace.
36
+ if force {
37
+ _ , _ = fmt .Fprintf (inv .Stdout , "Restarting %s to update the workspace parameters.\n " , workspace .Name )
38
+ return r .restart ().Handler (inv )
39
+ }
40
+
41
+ if ! workspace .Outdated && len (parameterFlags .richParameters ) != 0 {
42
+ _ , _ = fmt .Fprintf (inv .Stdout , "Workspace is up-to-date. Please add --force to update the workspace parameters.\n " )
43
+ return nil
44
+ }
45
+
32
46
if ! workspace .Outdated && ! parameterFlags .promptRichParameters && ! parameterFlags .promptEphemeralParameters && len (parameterFlags .ephemeralParameters ) == 0 {
33
47
_ , _ = fmt .Fprintf (inv .Stdout , "Workspace is up-to-date.\n " )
34
48
return nil
@@ -57,5 +71,11 @@ func (r *RootCmd) update() *serpent.Command {
57
71
58
72
cmd .Options = append (cmd .Options , parameterFlags .allOptions ()... )
59
73
cmd .Options = append (cmd .Options , bflags .cliOptions ()... )
74
+
75
+ cmd .Options = append (cmd .Options , serpent.Option {
76
+ Flag : "force" ,
77
+ Description : "Force the update of the workspace even if it is up-to-date." ,
78
+ Value : serpent .BoolOf (& force ),
79
+ })
60
80
return cmd
61
81
}
0 commit comments