Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ var certVolumeConfigs = []certVolumeConfig{
// BundleCSVDeploymentGenerator generates all deployments defined in rv1's cluster service version (CSV). The generated
// resource aim to have parity with OLMv0 generated Deployment resources:
// - olm.targetNamespaces annotation is set with the opts.TargetNamespace value
// - olm.operatorNamespace annotation is set with the opts.InstallNamespace value
// - the deployment spec's revision history limit is set to 1
Comment thread
Kajot-dev marked this conversation as resolved.
// - merges csv annotations to the deployment template's annotations
func BundleCSVDeploymentGenerator(rv1 *bundle.RegistryV1, opts render.Options) ([]client.Object, error) {
Expand All @@ -78,10 +79,13 @@ func BundleCSVDeploymentGenerator(rv1 *bundle.RegistryV1, opts render.Options) (
// See https://github.com/operator-framework/operator-lifecycle-manager/blob/dfd0b2bea85038d3c0d65348bc812d297f16b8d2/pkg/controller/install/deployment.go#L142
annotations := util.MergeMaps(rv1.CSV.Annotations, depSpec.Spec.Template.Annotations)

// In OLMv0 CSVs are annotated with the OperatorGroup's .spec.targetNamespaces
// In OLMv0, CSVs are annotated with OperatorGroup information:
// - olm.targetNamespaces: the OperatorGroup's .spec.targetNamespaces
// - olm.operatorNamespace: the namespace where the OperatorGroup is defined (operator's install namespace)
// See https://github.com/operator-framework/operator-lifecycle-manager/blob/dfd0b2bea85038d3c0d65348bc812d297f16b8d2/pkg/controller/operators/olm/operatorgroup.go#L279
// When the CSVs annotations are copied to the deployment template's annotations, they bring with it this annotation
// When the CSVs annotations are copied to the deployment template's annotations, they bring with it these annotations
Comment thread
Kajot-dev marked this conversation as resolved.
annotations["olm.targetNamespaces"] = strings.Join(opts.TargetNamespaces, ",")
annotations["olm.operatorNamespace"] = opts.InstallNamespace
depSpec.Spec.Template.Annotations = annotations

// Hardcode the deployment with RevisionHistoryLimit=1 to maintain parity with OLMv0 behaviour.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,10 @@ func Test_BundleCSVDeploymentGenerator_Succeeds(t *testing.T) {
Template: corev1.PodTemplateSpec{
ObjectMeta: metav1.ObjectMeta{
Annotations: map[string]string{
"csv": "annotation",
"olm.targetNamespaces": "watch-namespace-one,watch-namespace-two",
"pod": "annotation",
"csv": "annotation",
"olm.targetNamespaces": "watch-namespace-one,watch-namespace-two",
"olm.operatorNamespace": "install-namespace",
"pod": "annotation",
},
},
Spec: corev1.PodSpec{
Expand All @@ -148,8 +149,9 @@ func Test_BundleCSVDeploymentGenerator_Succeeds(t *testing.T) {
Template: corev1.PodTemplateSpec{
ObjectMeta: metav1.ObjectMeta{
Annotations: map[string]string{
"csv": "annotation",
"olm.targetNamespaces": "watch-namespace-one,watch-namespace-two",
"csv": "annotation",
"olm.targetNamespaces": "watch-namespace-one,watch-namespace-two",
"olm.operatorNamespace": "install-namespace",
},
},
},
Expand Down