Skip to content

Commit d507fdd

Browse files
committed
less code
Signed-off-by: Alex Jones <[email protected]>
1 parent 02401ad commit d507fdd

File tree

5 files changed

+105
-31
lines changed

5 files changed

+105
-31
lines changed

apis/core/v1alpha1/featureflagconfiguration_types.go

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,7 @@ type FeatureFlagConfigurationSpec struct {
4444

4545
type FlagDSpec struct {
4646
// +optional
47-
Envs []FlagDEnvVar `json:"envs"`
48-
}
49-
50-
type FlagDEnvVar struct {
51-
Name string `json:"name"`
52-
Value string `json:"value,omitempty"`
47+
Envs []corev1.EnvVar `json:"envs"`
5348
}
5449

5550
type FeatureFlagSyncProvider struct {

apis/core/v1alpha1/zz_generated.deepcopy.go

Lines changed: 4 additions & 17 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config/crd/bases/core.openfeature.dev_featureflagconfigurations.yaml

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,109 @@ spec:
4646
properties:
4747
envs:
4848
items:
49+
description: EnvVar represents an environment variable present
50+
in a Container.
4951
properties:
5052
name:
53+
description: Name of the environment variable. Must be a
54+
C_IDENTIFIER.
5155
type: string
5256
value:
57+
description: 'Variable references $(VAR_NAME) are expanded
58+
using the previously defined environment variables in
59+
the container and any service environment variables. If
60+
a variable cannot be resolved, the reference in the input
61+
string will be unchanged. Double $$ are reduced to a single
62+
$, which allows for escaping the $(VAR_NAME) syntax: i.e.
63+
"$$(VAR_NAME)" will produce the string literal "$(VAR_NAME)".
64+
Escaped references will never be expanded, regardless
65+
of whether the variable exists or not. Defaults to "".'
5366
type: string
67+
valueFrom:
68+
description: Source for the environment variable's value.
69+
Cannot be used if value is not empty.
70+
properties:
71+
configMapKeyRef:
72+
description: Selects a key of a ConfigMap.
73+
properties:
74+
key:
75+
description: The key to select.
76+
type: string
77+
name:
78+
description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
79+
TODO: Add other useful fields. apiVersion, kind,
80+
uid?'
81+
type: string
82+
optional:
83+
description: Specify whether the ConfigMap or its
84+
key must be defined
85+
type: boolean
86+
required:
87+
- key
88+
type: object
89+
fieldRef:
90+
description: 'Selects a field of the pod: supports metadata.name,
91+
metadata.namespace, `metadata.labels[''<KEY>'']`,
92+
`metadata.annotations[''<KEY>'']`, spec.nodeName,
93+
spec.serviceAccountName, status.hostIP, status.podIP,
94+
status.podIPs.'
95+
properties:
96+
apiVersion:
97+
description: Version of the schema the FieldPath
98+
is written in terms of, defaults to "v1".
99+
type: string
100+
fieldPath:
101+
description: Path of the field to select in the
102+
specified API version.
103+
type: string
104+
required:
105+
- fieldPath
106+
type: object
107+
resourceFieldRef:
108+
description: 'Selects a resource of the container: only
109+
resources limits and requests (limits.cpu, limits.memory,
110+
limits.ephemeral-storage, requests.cpu, requests.memory
111+
and requests.ephemeral-storage) are currently supported.'
112+
properties:
113+
containerName:
114+
description: 'Container name: required for volumes,
115+
optional for env vars'
116+
type: string
117+
divisor:
118+
anyOf:
119+
- type: integer
120+
- type: string
121+
description: Specifies the output format of the
122+
exposed resources, defaults to "1"
123+
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
124+
x-kubernetes-int-or-string: true
125+
resource:
126+
description: 'Required: resource to select'
127+
type: string
128+
required:
129+
- resource
130+
type: object
131+
secretKeyRef:
132+
description: Selects a key of a secret in the pod's
133+
namespace
134+
properties:
135+
key:
136+
description: The key of the secret to select from. Must
137+
be a valid secret key.
138+
type: string
139+
name:
140+
description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
141+
TODO: Add other useful fields. apiVersion, kind,
142+
uid?'
143+
type: string
144+
optional:
145+
description: Specify whether the Secret or its key
146+
must be defined
147+
type: boolean
148+
required:
149+
- key
150+
type: object
151+
type: object
54152
required:
55153
- name
56154
type: object

config/manager/manager.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ spec:
3636
name: manager
3737
env:
3838
- name: FLAGD_VERSION
39-
value: INPUT_FLAGD_VERSION
39+
value: v0.0.7
4040
securityContext:
4141
allowPrivilegeEscalation: false
4242
livenessProbe:

webhooks/pod_webhook.go

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -173,12 +173,6 @@ func (m *PodMutator) injectSidecar(pod *corev1.Pod, configMap string, featureFla
173173
FlagDTag = os.Getenv("FLAGD_VERSION")
174174
}
175175

176-
var envs []corev1.EnvVar
177-
178-
for _, envPair := range featureFlag.Spec.FlagDSpec.Envs {
179-
envs = append(envs, corev1.EnvVar{Name: envPair.Name, Value: envPair.Value})
180-
}
181-
182176
pod.Spec.Containers = append(pod.Spec.Containers, corev1.Container{
183177
Name: "flagd",
184178
Image: "ghcr.io/open-feature/flagd:" + FlagDTag,
@@ -190,7 +184,7 @@ func (m *PodMutator) injectSidecar(pod *corev1.Pod, configMap string, featureFla
190184
MountPath: "/etc/flagd",
191185
},
192186
},
193-
Env: envs,
187+
Env: featureFlag.Spec.FlagDSpec.Envs,
194188
})
195189
return json.Marshal(pod)
196190
}

0 commit comments

Comments
 (0)