Skip to content

Commit

Permalink
test yaml format ordering
Browse files Browse the repository at this point in the history
Signed-off-by: Thomas Jungblut <tjungblu@redhat.com>
  • Loading branch information
tjungblu committed Dec 20, 2024
1 parent ef12c12 commit f62cfc9
Showing 1 changed file with 14 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package cvo

import (
"fmt"
"k8s.io/apimachinery/pkg/util/sets"
"path"
"strings"

Expand Down Expand Up @@ -304,18 +305,23 @@ func preparePayloadScript(platformType hyperv1.PlatformType, oauthEnabled bool)
}

func cvoBootstrapScript(clusterID string) string {
filtered := make([]string, 0)
for _, capability := range configv1.KnownClusterVersionCapabilities {
if capability != configv1.ClusterVersionCapabilityImageRegistry {
filtered = append(filtered, string(capability))
enabledCaps := sets.New[configv1.ClusterVersionCapability](
configv1.ClusterVersionCapabilitySets[configv1.ClusterVersionCapabilitySetCurrent]...)
enabledCaps = enabledCaps.Delete(configv1.ClusterVersionCapabilityImageRegistry)

capabilities := strings.Builder{}
capList := enabledCaps.UnsortedList()
for i, capability := range capList {
capabilities.WriteString(string(capability))
if i != len(capList)-1 {
capabilities.WriteString(",")
}
}

capabilities := strings.Join(filtered, ", ")
payloadDir := volumeMounts.Path(cvoContainerBootstrap().Name, cvoVolumePayload().Name)
var scriptTemplate = `#!/bin/bash
set -euo pipefail
cat > /tmp/clusterversion.yaml <<EOF
cat > /tmp/clusterversion.yaml <<-EOF
apiVersion: config.openshift.io/v1
kind: ClusterVersion
metadata:
Expand All @@ -325,6 +331,7 @@ spec:
baselineCapabilitySet: 'None'
additionalEnabledCapabilities: [%s]
clusterID: %s
EOF
oc get ns openshift-config &> /dev/null || oc create ns openshift-config
oc get ns openshift-config-managed &> /dev/null || oc create ns openshift-config-managed
Expand All @@ -338,7 +345,7 @@ while true; do
done
oc get clusterversion/version &> /dev/null || oc create -f /tmp/clusterversion.yaml
`
return fmt.Sprintf(scriptTemplate, clusterID, capabilities, payloadDir)
return fmt.Sprintf(scriptTemplate, capabilities.String(), clusterID, payloadDir)
}

func buildCVOContainerMain(image, releaseImage, namespace string, updateService configv1.URL, enableCVOManagementClusterMetricsAccess bool) func(c *corev1.Container) {
Expand Down

0 comments on commit f62cfc9

Please sign in to comment.