Skip to content
Open
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
25 changes: 24 additions & 1 deletion internal/operators/osc/manifest.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,19 @@ func Manifests() (map[string][]byte, []byte, error) {
return nil, nil, err
}

oscKataConfigManifest, err := getKataConfig(Namespace)
if err != nil {
return nil, nil, err
}


openshiftManifests := make(map[string][]byte)

openshiftManifests["50_openshift-osc_ns.yaml"] = oscNamespaceManifest
openshiftManifests["50_openshift-osc_operator_group.yaml"] = oscOperatorGroupManifest
openshiftManifests["50_openshift-osc_subscription.yaml"] = oscSubscriptionManifest

return openshiftManifests, nil, err
return openshiftManifests, oscKataConfigManifest, err
}

func executeTemplate(data map[string]string, contentName, content string) ([]byte, error) {
Expand Down Expand Up @@ -68,6 +74,13 @@ func getOperatorGroup(namespace string) ([]byte, error) {
return executeTemplate(data, "oscOperatorGroupManifest", oscOperatorGroupManifest)
}

func getKataConfig(namespace string) ([]byte, error) {
data := map[string]string{
"OPERATOR_NAMESPACE": namespace,
}
return executeTemplate(data, "oscKataConfigManifest", oscKataConfigManifest)
}

const oscNamespaceManifest = `
apiVersion: v1
kind: Namespace
Expand Down Expand Up @@ -98,3 +111,13 @@ spec:
name: {{.OPERATOR_SOURCE_NAME}}
installPlanApproval: Automatic
`

const oscKataConfigManifest = `
apiVersion: kataconfiguration.openshift.io/v1
kind: KataConfig
metadata:
name: cluster-kataconfig
spec:
enablePeerPods: false
logLevel: info
`
Comment on lines +115 to +123
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jhernand it looks like this operator needs this CRD first. I don't see any operator adding CRDs, would you recommend this path or do you know any other better way to achieve this?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this may not work. These manifests are created all together, so there is no guarantee that the operator (created as a result of the subscription) will be already available, and therefore the custom resource definitions will not be available yet. It would be better to create it as part of the "custom manifests". Those are the second return value of the Manifests function (currently nil):

return openshiftManifests, nil, err

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Following this suggestion. I updated this function and it works well now.