Skip to content

Commit

Permalink
fix(patch): fixed assignment for nil annotation (#728)
Browse files Browse the repository at this point in the history
  • Loading branch information
powerfooI authored Jan 14, 2025
1 parent e2148bf commit 9acaff2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
3 changes: 3 additions & 0 deletions internal/dashboard/business/oceanbase/obcluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -852,6 +852,9 @@ func PatchOBCluster(ctx context.Context, nn *param.K8sObjectIdentity, param *par

if param.AddDeletionProtection && !alreadyIgnoredDeletion {
// Update deletion protection if specified
if obcluster.Annotations == nil {
obcluster.Annotations = make(map[string]string)
}
obcluster.Annotations[oceanbaseconst.AnnotationsIgnoreDeletion] = "true"
} else if param.RemoveDeletionProtection && alreadyIgnoredDeletion {
delete(obcluster.Annotations, oceanbaseconst.AnnotationsIgnoreDeletion)
Expand Down
3 changes: 3 additions & 0 deletions internal/dashboard/business/oceanbase/obtenant.go
Original file line number Diff line number Diff line change
Expand Up @@ -639,6 +639,9 @@ func PatchTenant(ctx context.Context, nn types.NamespacedName, p *param.PatchTen
if alreadyIgnoreDeletion && p.RemoveDeletionProtection {
delete(tenant.Annotations, oceanbaseconst.AnnotationsIgnoreDeletion)
} else if !alreadyIgnoreDeletion && p.AddDeletionProtection {
if tenant.Annotations == nil {
tenant.Annotations = make(map[string]string)
}
tenant.Annotations[oceanbaseconst.AnnotationsIgnoreDeletion] = "true"
}
if len(p.Variables) > 0 {
Expand Down

0 comments on commit 9acaff2

Please sign in to comment.