Skip to content

Commit

Permalink
Fix cd cancel and cd refresh
Browse files Browse the repository at this point in the history
  • Loading branch information
lionello committed Jan 15, 2025
1 parent c921c49 commit a2b14f7
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 11 deletions.
34 changes: 24 additions & 10 deletions src/cmd/cli/command/cd.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ var cdCmd = &cobra.Command{

var cdDestroyCmd = &cobra.Command{
Use: "destroy",
Annotations: authNeededAnnotation,
Args: cobra.NoArgs, // TODO: set MaximumNArgs(1),
Annotations: authNeededAnnotation, // need subscription
Args: cobra.NoArgs, // TODO: set MaximumNArgs(1),
Short: "Destroy the service stack",
RunE: func(cmd *cobra.Command, args []string) error {
loader := configureLoader(cmd)
Expand All @@ -44,8 +44,8 @@ var cdDestroyCmd = &cobra.Command{

var cdDownCmd = &cobra.Command{
Use: "down",
Annotations: authNeededAnnotation,
Args: cobra.NoArgs, // TODO: set MaximumNArgs(1),
Annotations: authNeededAnnotation, // need subscription
Args: cobra.NoArgs, // TODO: set MaximumNArgs(1),
Short: "Refresh and then destroy the service stack",
RunE: func(cmd *cobra.Command, args []string) error {
loader := configureLoader(cmd)
Expand All @@ -69,9 +69,10 @@ var cdDownCmd = &cobra.Command{
}

var cdRefreshCmd = &cobra.Command{
Use: "refresh",
Args: cobra.NoArgs, // TODO: set MaximumNArgs(1),
Short: "Refresh the service stack",
Use: "refresh",
Annotations: authNeededAnnotation, // need subscription
Args: cobra.NoArgs, // TODO: set MaximumNArgs(1),
Short: "Refresh the service stack",
RunE: func(cmd *cobra.Command, args []string) error {
loader := configureLoader(cmd)
provider, err := getProvider(cmd.Context(), loader)
Expand All @@ -83,14 +84,21 @@ var cdRefreshCmd = &cobra.Command{
if err != nil {
return err
}

err = canIUseProvider(cmd.Context(), provider, projectName)
if err != nil {
return err
}

return cli.BootstrapCommand(cmd.Context(), projectName, client, provider, "refresh")
},
}

var cdCancelCmd = &cobra.Command{
Use: "cancel",
Args: cobra.NoArgs, // TODO: set MaximumNArgs(1),
Short: "Cancel the current CD operation",
Use: "cancel",
Annotations: authNeededAnnotation, // need subscription
Args: cobra.NoArgs, // TODO: set MaximumNArgs(1),
Short: "Cancel the current CD operation",
RunE: func(cmd *cobra.Command, args []string) error {
loader := configureLoader(cmd)
provider, err := getProvider(cmd.Context(), loader)
Expand All @@ -102,6 +110,12 @@ var cdCancelCmd = &cobra.Command{
if err != nil {
return err
}

err = canIUseProvider(cmd.Context(), provider, projectName)
if err != nil {
return err
}

return cli.BootstrapCommand(cmd.Context(), projectName, client, provider, "cancel")
},
}
Expand Down
2 changes: 2 additions & 0 deletions src/pkg/cli/client/byoc/aws/byoc.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,8 @@ func (b *ByocAws) setUpCD(ctx context.Context) error {
return nil
}

term.Debugf("Using CD image: %q", b.CDImage)

cdTaskName := byoc.CdTaskPrefix
containers := []types.Container{
{
Expand Down
2 changes: 2 additions & 0 deletions src/pkg/cli/client/byoc/gcp/byoc.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,8 @@ func (b *ByocGcp) setUpCD(ctx context.Context) error {
}

// 5. Setup Cloud Run Job
term.Debugf("Using CD image: %q", b.CDImage)

serviceAccount := path.Base(b.cdServiceAccount)
if err := b.driver.SetupJob(ctx, "defang-cd", serviceAccount, []types.Container{
{
Expand Down
2 changes: 1 addition & 1 deletion src/pkg/clouds/do/appPlatform/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ func shellQuote(args ...string) string {
}

func getImageSourceSpec(cdImagePath string) (*godo.ImageSourceSpec, error) {
term.Debugf("Using CD image: %s", cdImagePath)
term.Debugf("Using CD image: %q", cdImagePath)
image, err := ParseImage(cdImagePath)
if err != nil {
return nil, err
Expand Down

0 comments on commit a2b14f7

Please sign in to comment.