Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix cd cancel and cd refresh #956

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading