@@ -21,7 +21,9 @@ func initApplyCommand(commonFlags []cli.Flag, clientConfig *types.ClientConfig)
2121 flags = append (flags , newStringFlag ("commit" , "c" , "The commit SHA to checkout if using git source. This takes precedence over branch" , "" ))
2222 flags = append (flags , newStringFlag ("git-auth" , "g" , "The name of the git_auth entry in server config to use" , "" ))
2323 flags = append (flags , newBoolFlag ("approve" , "a" , "Approve the app permissions" , false ))
24- flags = append (flags , newBoolFlag ("reload" , "" , "Which apps to reload: none, updated, all (default)" , false ))
24+ flags = append (flags , newStringFlag ("reload" , "r" , "Which apps to reload: none, updated (default), all" , "updated" ))
25+ flags = append (flags , newBoolFlag ("promote" , "p" , "Promote changes from stage to prod" , false ))
26+ flags = append (flags , newBoolFlag ("force" , "f" , "Force update app config, removing non-declarative changes" , false ))
2527 flags = append (flags , dryRunFlag ())
2628
2729 return & cli.Command {
@@ -39,11 +41,16 @@ Examples:
3941 Apply app config for all apps: clace apply ./app.ace all
4042 Apply app config for all apps: clace apply ./app.ace all
4143 Apply app config for example.com domain apps: clace apply ./app.ace example.com:**
42- Apply app config from git for all apps: clace apply github.com/claceio/apps/apps.ace all
44+ Apply app config from git for all apps: clace apply --reload=updated --promote --approve github.com/claceio/apps/apps.ace all
45+ Apply app config from git for all apps, overwriting changes: clace apply --reload=updated --promote --force github.com/claceio/apps/apps.ace all
4346` ,
4447
4548 Action : func (cCtx * cli.Context ) error {
46- if cCtx .NArg () != 2 {
49+ if cCtx .NArg () < 2 {
50+ reload := cCtx .String ("reload" )
51+ if reload != "" && reload != "none" && reload != "updated" && reload != "all" {
52+ return fmt .Errorf ("invalid value for --reload, expected none/updated/all: %s" , reload )
53+ }
4754 return fmt .Errorf ("expected two arguments: <filePath> <appPathGlob>" )
4855 }
4956
@@ -58,6 +65,8 @@ Examples:
5865 values .Add ("commit" , cCtx .String ("commit" ))
5966 values .Add ("gitAuth" , cCtx .String ("git-auth" ))
6067 values .Add ("reload" , cCtx .String ("reload" ))
68+ values .Add ("promote" , strconv .FormatBool (cCtx .Bool ("promote" )))
69+ values .Add ("force" , strconv .FormatBool (cCtx .Bool ("force" )))
6170
6271 var applyResponse types.AppApplyResponse
6372 err := client .Post ("/_clace/apply" , values , nil , & applyResponse )
@@ -66,6 +75,70 @@ Examples:
6675 }
6776
6877 fmt .Printf ("Applied %#+v\n " , applyResponse )
78+
79+ if len (applyResponse .CreateResults ) > 0 {
80+ fmt .Fprintf (cCtx .App .Writer , "Created apps:\n " )
81+ for i , createResult := range applyResponse .CreateResults {
82+ if i > 0 {
83+ fmt .Fprintf (cCtx .App .Writer , ", " )
84+ }
85+ printCreateResult (cCtx , createResult )
86+ }
87+ }
88+
89+ if len (applyResponse .UpdateResults ) > 0 {
90+ fmt .Fprintf (cCtx .App .Writer , "Updated apps: " )
91+ for i , updateResult := range applyResponse .UpdateResults {
92+ if i > 0 {
93+ fmt .Fprintf (cCtx .App .Writer , ", " )
94+ }
95+ fmt .Fprintf (cCtx .App .Writer , "%s" , updateResult )
96+ }
97+ fmt .Fprintln (cCtx .App .Writer )
98+ }
99+
100+ if len (applyResponse .ReloadResults ) > 0 {
101+ fmt .Fprintf (cCtx .App .Writer , "Reloaded apps: " )
102+ for i , reloadResult := range applyResponse .ReloadResults {
103+ if i > 0 {
104+ fmt .Fprintf (cCtx .App .Writer , ", " )
105+ }
106+ fmt .Fprintf (cCtx .App .Writer , "%s" , reloadResult )
107+ }
108+ fmt .Fprintln (cCtx .App .Writer )
109+ }
110+
111+ if len (applyResponse .ApproveResults ) > 0 {
112+ fmt .Fprintf (cCtx .App .Writer , "Approved apps:\n " )
113+ for _ , approveResult := range applyResponse .ApproveResults {
114+ if ! approveResult .NeedsApproval {
115+ // Server does not return these for reload to reduce the noise
116+ fmt .Printf ("No approval required. %s - %s\n " , approveResult .AppPathDomain , approveResult .Id )
117+ } else {
118+ fmt .Printf ("App permissions have been approved %s - %s\n " , approveResult .AppPathDomain , approveResult .Id )
119+ printApproveResult (approveResult )
120+ }
121+ }
122+ }
123+
124+ if len (applyResponse .PromoteResults ) > 0 {
125+ fmt .Fprintf (cCtx .App .Writer , "Promoted apps: " )
126+ for i , promoteResult := range applyResponse .PromoteResults {
127+ if i > 0 {
128+ fmt .Fprintf (cCtx .App .Writer , ", " )
129+ }
130+ fmt .Fprintf (cCtx .App .Writer , "%s" , promoteResult )
131+ }
132+ fmt .Fprintln (cCtx .App .Writer )
133+ }
134+
135+ fmt .Fprintf (cCtx .App .Writer , "%d app(s) updated, %d app(s) reloaded, %d app(s) approved, %d app(s) promoted.\n " ,
136+ len (applyResponse .UpdateResults ), len (applyResponse .ReloadResults ), len (applyResponse .ApproveResults ), len (applyResponse .PromoteResults ))
137+
138+ if applyResponse .DryRun {
139+ fmt .Print (DRY_RUN_MESSAGE )
140+ }
141+
69142 return nil
70143 },
71144 }
0 commit comments