Skip to content

Remove more Restart stuff #748

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

Merged
merged 1 commit into from
Oct 11, 2024
Merged
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
7 changes: 1 addition & 6 deletions src/cmd/cli/command/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -821,12 +821,7 @@ var restartCmd = &cobra.Command{
Args: cobra.MinimumNArgs(1),
Short: "Restart one or more services",
RunE: func(cmd *cobra.Command, args []string) error {
etag, err := cli.Restart(cmd.Context(), client, args...)
if err != nil {
return err
}
term.Info("Restarted service", args, "with deployment ID", etag)
return nil
return errors.New("Command 'restart' is deprecated, use 'up' instead")
},
}

Expand Down
6 changes: 3 additions & 3 deletions src/cmd/cli/command/compose.go
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ func makeComposeStartCmd() *cobra.Command {
Args: cobra.NoArgs, // TODO: takes optional list of service names
Short: "Reads a Compose file and deploys services to the cluster",
RunE: func(cmd *cobra.Command, args []string) error {
return fmt.Errorf("Command 'start' is deprecated, use 'up' instead")
return errors.New("Command 'start' is deprecated, use 'up' instead")
},
}
composeStartCmd.Flags().Bool("force", false, "force a build of the image even if nothing has changed")
Expand All @@ -216,7 +216,7 @@ func makeComposeRestartCmd() *cobra.Command {
Args: cobra.NoArgs, // TODO: takes optional list of service names
Short: "Reads a Compose file and restarts its services",
RunE: func(cmd *cobra.Command, args []string) error {
return fmt.Errorf("Command 'restart' is deprecated, use 'up' instead")
return errors.New("Command 'restart' is deprecated, use 'up' instead")
},
}
}
Expand All @@ -228,7 +228,7 @@ func makeComposeStopCmd() *cobra.Command {
Args: cobra.NoArgs, // TODO: takes optional list of service names
Short: "Reads a Compose file and stops its services",
RunE: func(cmd *cobra.Command, args []string) error {
return fmt.Errorf("Command 'stop' is deprecated, use 'down' instead")
return errors.New("Command 'stop' is deprecated, use 'down' instead")
},
}
}
Expand Down
4 changes: 0 additions & 4 deletions src/pkg/cli/client/byoc/aws/byoc.go
Original file line number Diff line number Diff line change
Expand Up @@ -689,10 +689,6 @@ func (b *ByocAws) DeleteConfig(ctx context.Context, secrets *defangv1.Secrets) e
return nil
}

func (b *ByocAws) Restart(ctx context.Context, names ...string) (types.ETag, error) {
return "", client.ErrNotImplemented("not yet implemented for BYOC; please use the AWS ECS dashboard") // FIXME: implement this for BYOC
}

func (b *ByocAws) BootstrapList(ctx context.Context) ([]string, error) {
bucketName := b.bucketName()
if bucketName == "" {
Expand Down
11 changes: 0 additions & 11 deletions src/pkg/cli/client/byoc/do/byoc.go
Original file line number Diff line number Diff line change
Expand Up @@ -299,17 +299,6 @@ func (b *ByocDo) PutConfig(ctx context.Context, config *defangv1.PutConfigReques
return err
}

func (b *ByocDo) Restart(ctx context.Context, names ...string) (types.ETag, error) {
app, err := b.getAppByName(ctx, b.ProjectName)
if err != nil {
return "", err
}

_, _, err = b.client.Apps.Update(ctx, app.ID, &godo.AppUpdateRequest{Spec: app.Spec})

return pkg.RandomID(), err
}

func (b *ByocDo) ServiceDNS(name string) string {
return "localhost"
}
Expand Down
1 change: 0 additions & 1 deletion src/pkg/cli/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ type Client interface {
GetServices(context.Context) (*defangv1.ListServicesResponse, error)
ListConfig(context.Context) (*defangv1.Secrets, error)
PutConfig(context.Context, *defangv1.PutConfigRequest) error
Restart(context.Context, ...string) (types.ETag, error)
ServiceDNS(name string) string
Subscribe(context.Context, *defangv1.SubscribeRequest) (ServerStream[defangv1.SubscribeResponse], error)
Follow(context.Context, *defangv1.TailRequest) (ServerStream[defangv1.TailResponse], error)
Expand Down
28 changes: 0 additions & 28 deletions src/pkg/cli/client/playground.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package client
import (
"context"
"errors"
"fmt"

"github.com/DefangLabs/defang/src/pkg/term"
"github.com/DefangLabs/defang/src/pkg/types"
Expand Down Expand Up @@ -105,33 +104,6 @@ func (g *PlaygroundClient) BootstrapList(context.Context) ([]string, error) {
return nil, errors.New("this command is not valid for the Defang playground; did you forget --provider?")
}

func (g *PlaygroundClient) Restart(ctx context.Context, names ...string) (types.ETag, error) {
// For now, we'll just get the service info and pass it back to Deploy as-is.
resp, err := g.GetServices(ctx)
if err != nil {
return "", err
}
existingServices := make(map[string]*defangv1.Service)
for _, serviceInfo := range resp.Services {
existingServices[serviceInfo.Service.Name] = serviceInfo.Service
}

servicesToUpdate := make([]*defangv1.Service, 0, len(names))
for _, name := range names {
service, ok := existingServices[name]
if !ok {
return "", fmt.Errorf("service %s not found", name)
}
servicesToUpdate = append(servicesToUpdate, service)
}

dr, err := g.Deploy(ctx, &defangv1.DeployRequest{Project: resp.Project, Services: servicesToUpdate})
if err != nil {
return "", err
}
return dr.Etag, nil
}

func (g PlaygroundClient) ServiceDNS(name string) string {
return string(g.TenantID) + "-" + name
}
Expand Down
20 changes: 0 additions & 20 deletions src/pkg/cli/restart.go

This file was deleted.

Loading