CreateSubscription creates a subscription object inside openshift with a fixed name
( ctx context.Context, crudClient client.Client, channel string, )
| 131 | |
| 132 | // CreateSubscription creates a subscription object inside openshift with a fixed name |
| 133 | func CreateSubscription( |
| 134 | ctx context.Context, |
| 135 | crudClient client.Client, |
| 136 | channel string, |
| 137 | ) error { |
| 138 | u := &unstructured.Unstructured{} |
| 139 | u.SetName("cloudnative-pg") |
| 140 | u.SetNamespace("openshift-operators") |
| 141 | u.SetGroupVersionKind(schema.GroupVersionKind{ |
| 142 | Group: "operators.coreos.com", |
| 143 | Version: "v1alpha1", |
| 144 | Kind: "Subscription", |
| 145 | }) |
| 146 | |
| 147 | spec := map[string]string{ |
| 148 | "channel": channel, |
| 149 | "installPlanApproval": "Automatic", |
| 150 | "name": "cloudnative-pg", |
| 151 | "source": "cloudnative-pg-manifests", |
| 152 | "sourceNamespace": "openshift-marketplace", |
| 153 | } |
| 154 | |
| 155 | err := unstructured.SetNestedStringMap(u.Object, spec, "spec") |
| 156 | if err != nil { |
| 157 | return err |
| 158 | } |
| 159 | |
| 160 | _, err = objects.Create(ctx, crudClient, u) |
| 161 | return err |
| 162 | } |
| 163 | |
| 164 | // DeleteSubscription deletes the operator's subscription object |
| 165 | func DeleteSubscription( |