Skip to content

Commit

Permalink
feat: add approbation request on stack restore cmd (#591)
Browse files Browse the repository at this point in the history
Co-authored-by: David Ragot <[email protected]>
  • Loading branch information
Dav-14 and David Ragot committed Nov 2, 2023
1 parent f98942b commit e20b628
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions components/fctl/cmd/stack/restore.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,23 @@ func (c *StackRestoreController) Run(cmd *cobra.Command, args []string) (fctl.Re
return nil, err
}

var stack *membershipclient.Stack
if len(args) == 1 {
rsp, _, err := apiClient.DefaultApi.GetStack(cmd.Context(), organization, args[0]).Execute()
if err != nil {
return nil, err
}
stack = rsp.Data
}

if stack == nil {
return nil, errors.New("Stack not found")
}

if !fctl.CheckStackApprobation(cmd, stack, "You are about to restore stack '%s'", stack.Name) {
return nil, fctl.ErrMissingApproval
}

response, _, err := apiClient.DefaultApi.
RestoreStack(cmd.Context(), organization, args[0]).
Execute()
Expand Down

0 comments on commit e20b628

Please sign in to comment.