Skip to content

Commit 54e22e9

Browse files
authored
flag pinning (#55)
Signed-off-by: Alex Jones <[email protected]>
1 parent 2a7d8b1 commit 54e22e9

File tree

3 files changed

+16
-3
lines changed

3 files changed

+16
-3
lines changed

Makefile

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
# Image URL to use all building/pushing image targets
33
IMG ?= controller:latest
44
# ENVTEST_K8S_VERSION refers to the version of kubebuilder assets to be downloaded by envtest binary.
5+
FLAGD_VERSION=v0.0.3
56
ENVTEST_K8S_VERSION = 1.23
67

78
# Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set)
@@ -45,6 +46,7 @@ manifests: controller-gen ## Generate WebhookConfiguration, ClusterRole and Cust
4546

4647
.PHONY: generate
4748
generate: controller-gen ## Generate code containing DeepCopy, DeepCopyInto, and DeepCopyObject method implementations.
49+
sed -i '' -e 's/INPUT_FLAGD_VERSION/${FLAGD_VERSION}/g' config/manager/manager.yaml
4850
cp schemas/json-schema/flagd-definitions.json pkg/utils/flagd-definitions.json
4951
$(CONTROLLER_GEN) object:headerFile="hack/boilerplate.go.txt" paths="./..."
5052

@@ -98,12 +100,12 @@ release-manifests: manifests kustomize
98100
$(KUSTOMIZE) build config/default > config/rendered/release.yaml
99101

100102
.PHONY: deploy
101-
deploy: manifests kustomize ## Deploy controller to the K8s cluster specified in ~/.kube/config.
103+
deploy: generate manifests kustomize ## Deploy controller to the K8s cluster specified in ~/.kube/config.
102104
cd config/manager && $(KUSTOMIZE) edit set image controller=${IMG}
103105
$(KUSTOMIZE) build config/default | kubectl apply -f -
104106

105107
.PHONY: undeploy
106-
undeploy: ## Undeploy controller from the K8s cluster specified in ~/.kube/config. Call with ignore-not-found=true to ignore resource not found errors during deletion.
108+
undeploy: generate ## Undeploy controller from the K8s cluster specified in ~/.kube/config. Call with ignore-not-found=true to ignore resource not found errors during deletion.
107109
$(KUSTOMIZE) build config/default | kubectl delete --ignore-not-found=$(ignore-not-found) -f -
108110

109111
CONTROLLER_GEN = $(shell pwd)/bin/controller-gen

config/manager/manager.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ spec:
3434
imagePullPolicy: Always
3535
image: controller:main
3636
name: manager
37+
env:
38+
- name: FLAGD_VERSION
39+
value: INPUT_FLAGD_VERSION
3740
securityContext:
3841
allowPrivilegeEscalation: false
3942
livenessProbe:

webhooks/pod_webhook.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"encoding/json"
66
"fmt"
77
"net/http"
8+
"os"
89

910
corev1alpha1 "github.com/open-feature/open-feature-operator/apis/core/v1alpha1"
1011

@@ -19,10 +20,13 @@ import (
1920

2021
// we likely want these to be configurable, eventually
2122
const (
22-
FlagDTag = "main"
2323
FlagDImagePullPolicy = "Always"
2424
)
2525

26+
var (
27+
FlagDTag = "main"
28+
)
29+
2630
// NOTE: RBAC not needed here.
2731
//+kubebuilder:rbac:groups="",resources=pods,verbs=get;list;watch;create;update;patch;delete
2832
//+kubebuilder:rbac:groups="",resources=configmaps,verbs=get;list;watch;create;update;patch;delete
@@ -166,6 +170,10 @@ func (m *PodMutator) injectSidecar(pod *corev1.Pod, configMap string, featureFla
166170
commandSequence = append(commandSequence, featureFlag.Spec.SyncProvider.Name)
167171
}
168172

173+
if os.Getenv("FLAGD_VERSION") != "" {
174+
FlagDTag = os.Getenv("FLAGD_VERSION")
175+
}
176+
169177
pod.Spec.Containers = append(pod.Spec.Containers, corev1.Container{
170178
Name: "flagd",
171179
Image: "ghcr.io/open-feature/flagd:" + FlagDTag,

0 commit comments

Comments
 (0)