Skip to content

Commit

Permalink
improve tctl -f command
Browse files Browse the repository at this point in the history
  • Loading branch information
marcoandredinis committed Oct 3, 2023
1 parent b1c24ef commit 24dde14
Showing 1 changed file with 4 additions and 13 deletions.
17 changes: 4 additions & 13 deletions tool/tctl/common/resource_command.go
Original file line number Diff line number Diff line change
Expand Up @@ -989,21 +989,12 @@ func (rc *ResourceCommand) createDiscoveryConfig(ctx context.Context, client aut

remote := client.DiscoveryConfigClient()

_, err = remote.GetDiscoveryConfig(ctx, discoveryConfig.GetName())
if err != nil && !trace.IsNotFound(err) {
return trace.Wrap(err)
}
exists := (err == nil)

if exists {
if !rc.force {
return trace.AlreadyExists("DiscoveryConfig %q already exists", discoveryConfig.GetName())
}

if _, err := remote.UpdateDiscoveryConfig(ctx, discoveryConfig); err != nil {
if rc.force {
if _, err := remote.UpsertDiscoveryConfig(ctx, discoveryConfig); err != nil {
return trace.Wrap(err)
}
fmt.Printf("DiscoveryConfig %q has been updated\n", discoveryConfig.GetName())

fmt.Printf("DiscoveryConfig %q has been written\n", discoveryConfig.GetName())
return nil
}

Expand Down

0 comments on commit 24dde14

Please sign in to comment.