Skip to content

Commit

Permalink
Merge pull request #467 from DefangLabs/edw-restart-proj-name
Browse files Browse the repository at this point in the history
Fix restart command with project support
  • Loading branch information
lionello committed Jun 13, 2024
2 parents 99a7106 + ea719de commit dd44de9
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
22 changes: 16 additions & 6 deletions src/pkg/cli/client/playground.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package client
import (
"context"
"errors"
"fmt"

"github.com/DefangLabs/defang/src/pkg/types"
defangv1 "github.com/DefangLabs/defang/src/protos/io/defang/v1"
Expand Down Expand Up @@ -95,16 +96,25 @@ func (g *PlaygroundClient) BootstrapList(context.Context) ([]string, error) {

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.
services := make([]*defangv1.Service, 0, len(names))
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 {
serviceInfo, err := g.GetService(ctx, &defangv1.ServiceID{Name: name})
if err != nil {
return "", err
service, ok := existingServices[name]
if !ok {
return "", fmt.Errorf("service %s not found", name)
}
services = append(services, serviceInfo.Service)
servicesToUpdate = append(servicesToUpdate, service)
}

dr, err := g.Deploy(ctx, &defangv1.DeployRequest{Services: services})
dr, err := g.Deploy(ctx, &defangv1.DeployRequest{Project: resp.Project, Services: servicesToUpdate})
if err != nil {
return "", err
}
Expand Down
2 changes: 1 addition & 1 deletion src/pkg/term/colorizer.go
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ func (t *Term) Warnf(format string, v ...any) (int, error) {
}

func (t *Term) Error(v ...any) (int, error) {
return output(t.stderr, ErrorColor, ensureNewline(fmt.Sprint(v...)))
return output(t.stderr, ErrorColor, fmt.Sprintln(v...))
}

func (t *Term) Errorf(format string, v ...any) (int, error) {
Expand Down

0 comments on commit dd44de9

Please sign in to comment.