Skip to content

Commit

Permalink
chore: delete needless annotations
Browse files Browse the repository at this point in the history
  • Loading branch information
Rory-Z committed Jun 16, 2023
1 parent d0327dd commit 89ea845
Showing 1 changed file with 14 additions and 44 deletions.
58 changes: 14 additions & 44 deletions apis/apps/v1beta4/emqxbroker_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,8 @@ func defaultLabelsAndAnnotations(r Emqx) {
template := r.GetSpec().GetTemplate()
template.Labels = mergeMap(template.Labels, labels)
template.Annotations = mergeMap(template.Annotations, r.GetAnnotations())
delete(template.Annotations, "kubectl.kubernetes.io/last-applied-configuration")

r.GetSpec().SetTemplate(template)
}

Expand Down Expand Up @@ -171,29 +173,13 @@ func defaultEmqxConfig(r Emqx) {
func defaultServiceTemplate(r Emqx) {
s := r.GetSpec().GetServiceTemplate()

s.ObjectMeta.Namespace = r.GetNamespace()
if s.ObjectMeta.Name == "" {
s.ObjectMeta.Name = r.GetName()
}
if s.ObjectMeta.Labels == nil {
s.ObjectMeta.Labels = make(map[string]string)
}
for key, value := range r.GetLabels() {
if _, ok := s.ObjectMeta.Labels[key]; !ok {
s.ObjectMeta.Labels[key] = value
}
}
if s.ObjectMeta.Annotations == nil {
s.ObjectMeta.Annotations = map[string]string{}
}
for key, value := range r.GetAnnotations() {
if key == "kubectl.kubernetes.io/last-applied-configuration" {
continue
}
if _, ok := s.ObjectMeta.Annotations[key]; !ok {
s.ObjectMeta.Annotations[key] = value
}
if s.Name == "" {
s.Name = r.GetName()
}
s.Namespace = r.GetNamespace()
s.Labels = mergeMap(s.Labels, r.GetLabels())
s.Annotations = mergeMap(s.ObjectMeta.Annotations, r.GetAnnotations())
delete(s.Annotations, "kubectl.kubernetes.io/last-applied-configuration")

s.Spec.Selector = r.GetLabels()
s.Spec.Ports = MergeServicePorts(
Expand All @@ -217,30 +203,14 @@ func defaultPersistent(r Emqx) {
return
}

p.ObjectMeta.Namespace = r.GetNamespace()
if p.ObjectMeta.Name == "" {
if p.Name == "" {
names := Names{Object: r}
p.ObjectMeta.Name = names.Data()
}
if p.ObjectMeta.Labels == nil {
p.ObjectMeta.Labels = make(map[string]string)
}
for key, value := range r.GetLabels() {
if _, ok := p.ObjectMeta.Labels[key]; !ok {
p.ObjectMeta.Labels[key] = value
}
}
if p.ObjectMeta.Annotations == nil {
p.ObjectMeta.Annotations = map[string]string{}
}
for key, value := range r.GetAnnotations() {
if key == "kubectl.kubernetep.io/last-applied-configuration" {
continue
}
if _, ok := p.ObjectMeta.Annotations[key]; !ok {
p.ObjectMeta.Annotations[key] = value
}
p.Name = names.Data()
}
p.Namespace = r.GetNamespace()
p.Labels = mergeMap(p.Labels, r.GetLabels())
p.Annotations = mergeMap(p.Annotations, r.GetAnnotations())
delete(p.Annotations, "kubectl.kubernetes.io/last-applied-configuration")
}

func defaultSecurityContext(r Emqx) {
Expand Down

0 comments on commit 89ea845

Please sign in to comment.