Skip to content

Commit

Permalink
Merge pull request #481 from FabianKramm/service-account
Browse files Browse the repository at this point in the history
fix: fix init manifests panic
  • Loading branch information
FabianKramm authored May 13, 2022
2 parents 9aba801 + 405964d commit a95fb14
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions pkg/controllers/manifests/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,14 @@ func (r *InitManifestsConfigMapReconciler) Reconcile(ctx context.Context, req ct
// make array stable or otherwise order is random
sort.Strings(cmData)
manifests := strings.Join(cmData, "\n---\n")
lastAppliedManifests := cm.ObjectMeta.Annotations[LastAppliedManifestKey]
if lastAppliedManifests != "" {
lastAppliedManifests, err = compress.Uncompress(lastAppliedManifests)
if err != nil {
r.Log.Errorf("error decompressing manifests: %v", err)
lastAppliedManifests := ""
if cm.ObjectMeta.Annotations != nil {
lastAppliedManifests = cm.ObjectMeta.Annotations[LastAppliedManifestKey]
if lastAppliedManifests != "" {
lastAppliedManifests, err = compress.Uncompress(lastAppliedManifests)
if err != nil {
r.Log.Errorf("error decompressing manifests: %v", err)
}
}
}

Expand All @@ -80,6 +83,9 @@ func (r *InitManifestsConfigMapReconciler) Reconcile(ctx context.Context, req ct
}

// update annotation
if cm.ObjectMeta.Annotations == nil {
cm.ObjectMeta.Annotations = map[string]string{}
}
cm.ObjectMeta.Annotations[LastAppliedManifestKey] = compressedManifests
err = r.LocalClient.Update(ctx, cm, &client.UpdateOptions{})
if err != nil {
Expand Down

0 comments on commit a95fb14

Please sign in to comment.