Skip to content

Commit

Permalink
rollouts: fix panic when template type is empty (#3876)
Browse files Browse the repository at this point in the history
  • Loading branch information
natasha41575 committed Mar 12, 2023
1 parent 70bdf1c commit 09d5dee
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion rollouts/controllers/rollout_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -719,6 +719,11 @@ func newRemoteSync(rollout *gitopsv1alpha1.Rollout, target *clusterPackagePair)
clusterRef := gitopsv1alpha1.ClusterRef{Name: target.cluster.Name}
clusterName := clusterRef.Name[strings.LastIndex(clusterRef.Name, "/")+1:]

templateType := gitopsv1alpha1.TemplateTypeRootSync
if rollout != nil && rollout.Spec.SyncTemplate != nil {
templateType = rollout.Spec.SyncTemplate.Type
}

// The RemoteSync object is created in the same namespace as the Rollout
// object. The RemoteSync will create either a RepoSync in the same namespace,
// or a RootSync in the config-management-system namespace.
Expand All @@ -741,7 +746,7 @@ func newRemoteSync(rollout *gitopsv1alpha1.Rollout, target *clusterPackagePair)
},

Spec: gitopsv1alpha1.RemoteSyncSpec{
Type: rollout.Spec.SyncTemplate.Type,
Type: templateType,
ClusterRef: clusterRef,
Template: &gitopsv1alpha1.Template{
Spec: toSyncSpec(target.packageRef),
Expand Down

0 comments on commit 09d5dee

Please sign in to comment.