Skip to content

Commit

Permalink
remove needs for normalized name map
Browse files Browse the repository at this point in the history
update after merge

update service state name
  • Loading branch information
nullfunc committed Jun 27, 2024
1 parent 84743a0 commit 2d9f4a3
Show file tree
Hide file tree
Showing 5 changed files with 164 additions and 175 deletions.
3 changes: 2 additions & 1 deletion src/cmd/cli/command/servicemonitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@ import (
"context"

"github.com/DefangLabs/defang/src/pkg/cli"
"github.com/DefangLabs/defang/src/pkg/cli/compose"
"github.com/DefangLabs/defang/src/pkg/term"
defangv1 "github.com/DefangLabs/defang/src/protos/io/defang/v1"
)

func waitServiceStatus(ctx context.Context, targetStatus cli.ServiceStatus, serviceInfos []*defangv1.ServiceInfo) error {
serviceList := []string{}
for _, serviceInfo := range serviceInfos {
serviceList = append(serviceList, serviceInfo.Service.Name)
serviceList = append(serviceList, compose.NormalizeServiceName(serviceInfo.Service.Name))
}

// set up service status subscription (non-blocking)
Expand Down
2 changes: 1 addition & 1 deletion src/pkg/cli/compose/convert.go
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ func convertServiceState(state string) defangv1.ServiceState {
default:
return defangv1.ServiceState_UNKNOWN
case "building_pending":
return defangv1.ServiceState_BUILDING_PENDING
return defangv1.ServiceState_BUILD_PENDING
case "building":
return defangv1.ServiceState_BUILDING
case "created":
Expand Down
17 changes: 2 additions & 15 deletions src/pkg/cli/subscribe.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"fmt"

"github.com/DefangLabs/defang/src/pkg/cli/client"
"github.com/DefangLabs/defang/src/pkg/cli/compose"
"github.com/DefangLabs/defang/src/pkg/term"
defangv1 "github.com/DefangLabs/defang/src/protos/io/defang/v1"
)
Expand All @@ -21,13 +20,6 @@ func Subscribe(ctx context.Context, client client.Client, services []string) (<-
return nil, fmt.Errorf("no services specified")
}

normalizedServiceNameToServiceName := make(map[string]string, len(services))

for i, service := range services {
services[i] = compose.NormalizeServiceName(service)
normalizedServiceNameToServiceName[services[i]] = service
}

statusChan := make(chan SubscribeServiceStatus, len(services))
if DoDryRun {
defer close(statusChan)
Expand Down Expand Up @@ -67,18 +59,13 @@ func Subscribe(ctx context.Context, client client.Client, services []string) (<-
continue
}

serviceName, ok := normalizedServiceNameToServiceName[servInfo.Service.Name]
if !ok {
term.Debugf("Unknown service %s in subscribe response\n", servInfo.Service.Name)
continue
}
status := SubscribeServiceStatus{
Name: serviceName,
Name: servInfo.Service.Name,
Status: servInfo.Status,
}

statusChan <- status
term.Debugf("service %s with status %s\n", serviceName, servInfo.Status)
term.Debugf("service %s with status %s\n", servInfo.Service.Name, servInfo.Status)
}
}()

Expand Down
Loading

0 comments on commit 2d9f4a3

Please sign in to comment.