MCPcopy Create free account
hub / github.com/cloudnative-pg/cloudnative-pg / CreateConfigMap

Function CreateConfigMap

tests/utils/operator/upgrade.go:48–84  ·  view source on GitHub ↗

CreateConfigMap creates the operator namespace and enables/disable the online upgrade for the instance manager

(
	ctx context.Context,
	crudClient client.Client,
	pgOperatorNamespace, configName string,
	isOnline bool,
)

Source from the content-addressed store, hash-verified

46// CreateConfigMap creates the operator namespace and enables/disable the online upgrade for
47// the instance manager
48func CreateConfigMap(
49 ctx context.Context,
50 crudClient client.Client,
51 pgOperatorNamespace, configName string,
52 isOnline bool,
53) {
54 By("creating operator namespace", func() {
55 // Create a upgradeNamespace for all the resources
56 namespacedName := types.NamespacedName{
57 Name: pgOperatorNamespace,
58 }
59 namespaceResource := &corev1.Namespace{}
60 err := crudClient.Get(ctx, namespacedName, namespaceResource)
61 if apierrors.IsNotFound(err) {
62 err = namespaces.CreateNamespace(ctx, crudClient, pgOperatorNamespace)
63 Expect(err).ToNot(HaveOccurred())
64 } else if err != nil {
65 Expect(err).ToNot(HaveOccurred())
66 }
67 })
68
69 By(fmt.Sprintf("ensuring 'ENABLE_INSTANCE_MANAGER_INPLACE_UPDATES' is set to %v", isOnline), func() {
70 enable := "false"
71 if isOnline {
72 enable = "true"
73 }
74 configMap := &corev1.ConfigMap{
75 ObjectMeta: metav1.ObjectMeta{
76 Namespace: pgOperatorNamespace,
77 Name: configName,
78 },
79 Data: map[string]string{"ENABLE_INSTANCE_MANAGER_INPLACE_UPDATES": enable},
80 }
81 _, err := objects.Create(ctx, crudClient, configMap)
82 Expect(err).NotTo(HaveOccurred())
83 })
84}
85
86// operatorServiceAccount is the operator's ServiceAccount, used to probe the
87// admission path that the operator itself exercises while bootstrapping a cluster.

Callers 1

upgrade_test.goFile · 0.92

Calls 3

CreateNamespaceFunction · 0.92
CreateFunction · 0.92
GetMethod · 0.45

Tested by

no test coverage detected