Skip to content
Open
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
25 changes: 21 additions & 4 deletions internal/cmd/deploy/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,27 @@ func runDeploy(f *cmdutil.Factory, opts *Options) error {
return err
}
} else {
// create a new service
service, err = f.ApiClient.CreateEmptyService(context.Background(), projectID, opts.name)
if err != nil {
return err
// check if a service with the same name already exists
if opts.name != "" {
existingServices, err := f.ApiClient.ListAllServices(context.Background(), projectID)
if err != nil {
return fmt.Errorf("listing services: %w", err)
}
for _, s := range existingServices {
if s.Name == opts.name {
service = s
f.Log.Infof("Found existing service '%s', redeploying...", opts.name)
break
}
}
}

// create a new service if no existing one was found
if service == nil {
service, err = f.ApiClient.CreateEmptyService(context.Background(), projectID, opts.name)
if err != nil {
return err
}
}
}

Expand Down