Skip to content

Commit

Permalink
Add already exist check
Browse files Browse the repository at this point in the history
Signed-off-by: Kfir Toledo <[email protected]>
  • Loading branch information
kfirtoledo committed Mar 10, 2024
1 parent 09f3b06 commit 057683d
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions cmd/cl-adm/cmd/deploy/deploy_peer.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ func (o *PeerOptions) Run() error {
}

managerModified := strings.ReplaceAll(string(managerFile), ghImage, newImage)
err = decoder.DecodeEach(context.Background(), strings.NewReader(managerModified), decoder.CreateHandler(resource))
err = decoder.DecodeEach(context.Background(), strings.NewReader(managerModified), decoder.CreateIgnoreAlreadyExists(resource))
if err != nil {
return err
}
Expand All @@ -150,7 +150,7 @@ func (o *PeerOptions) Run() error {
err = decoder.DecodeEach(
context.Background(),
strings.NewReader(string(secretFile)),
decoder.CreateHandler(resource),
decoder.CreateIgnoreAlreadyExists(resource),
decoder.MutateNamespace(o.Namespace),
)
if err != nil {
Expand All @@ -177,7 +177,9 @@ func (o *PeerOptions) Run() error {
}

err = decoder.DecodeEach(context.Background(), strings.NewReader(string(instance)), decoder.CreateHandler(resource))
if err != nil {
if errors.IsAlreadyExists(err) {
fmt.Println("CRD instance for ClusterLink (\"cl-instance\") was already exist.")
} else if err != nil {
return err
}
} else {
Expand Down

0 comments on commit 057683d

Please sign in to comment.