Skip to content

Commit

Permalink
fix: resource update when conflict
Browse files Browse the repository at this point in the history
Signed-off-by: asingh51 <[email protected]>
  • Loading branch information
asingh51 authored and ashutosh16 committed Jan 30, 2025
1 parent 43f83fa commit e9025ca
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
6 changes: 4 additions & 2 deletions cmd/argocd/commands/admin/backup.go
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ func NewImportCommand() *cobra.Command {

errors.CheckError(err)
for _, bakObj := range backupObjects {
if len(skipResourcesWithLabels) != 0 && isLabelMatches(bakObj, skipResourcesWithLabels) {
if isLabelMatches(bakObj, skipResourcesWithLabels) {
fmt.Printf("Skipping %s/%s %s in namespace %s\n", bakObj.GroupVersionKind().Group, bakObj.GroupVersionKind().Kind, bakObj.GetName(), bakObj.GetNamespace())
continue
}
Expand Down Expand Up @@ -512,9 +512,11 @@ func updateTracking(bak, live *unstructured.Unstructured) {

// skip resource if any of the specified label exists.
func isLabelMatches(bak *unstructured.Unstructured, skipResourcesWithLabels []string) bool {

Check failure on line 514 in cmd/argocd/commands/admin/backup.go

View workflow job for this annotation

GitHub Actions / Lint Go code

unnecessary leading newline (whitespace)
if bak == nil {

Check failure on line 515 in cmd/argocd/commands/admin/backup.go

View workflow job for this annotation

GitHub Actions / Lint Go code

File is not properly formatted (gofumpt)
if len(skipResourcesWithLabels) == 0 {
return false
}

Check failure on line 519 in cmd/argocd/commands/admin/backup.go

View workflow job for this annotation

GitHub Actions / Lint Go code

File is not properly formatted (gofumpt)
labels := bak.GetLabels()
for _, key := range skipResourcesWithLabels {
if _, exists := labels[key]; exists {
Expand Down
6 changes: 0 additions & 6 deletions cmd/argocd/commands/admin/backup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,12 +93,6 @@ func TestIsLabelMatches(t *testing.T) {
skipLabels []string
expected bool
}{
{
name: "Nil object",
obj: nil,
skipLabels: []string{"test-label"},
expected: false,
},
{
name: "Label matches",
obj: &unstructured.Unstructured{
Expand Down

0 comments on commit e9025ca

Please sign in to comment.