Skip to content

Commit

Permalink
fix tag delete following resource create
Browse files Browse the repository at this point in the history
  • Loading branch information
nojnhuh committed Feb 17, 2023
1 parent b188333 commit 7c92038
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
11 changes: 6 additions & 5 deletions azure/services/tags/tags.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,13 +105,14 @@ func (s *Service) Reconcile(ctx context.Context) error {
return errors.Wrap(err, "cannot update tags")
}
}

// We also need to update the annotation if anything changed.
if err := s.Scope.UpdateAnnotationJSON(tagsSpec.Annotation, newAnnotation); err != nil {
return err
}
log.V(2).Info("successfully updated tags")
}

// We also need to update the annotation even if nothing changed to
// ensure it's set immediately following resource creation.
if err := s.Scope.UpdateAnnotationJSON(tagsSpec.Annotation, newAnnotation); err != nil {
return err
}
}
return nil
}
Expand Down
1 change: 1 addition & 0 deletions azure/services/tags/tags_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,7 @@ func TestReconcileTags(t *testing.T) {
},
}}, nil)
s.AnnotationJSON("my-annotation").Return(map[string]interface{}{"key": "value"}, nil)
s.UpdateAnnotationJSON("my-annotation", map[string]interface{}{"key": "value"})
},
},
}
Expand Down

0 comments on commit 7c92038

Please sign in to comment.