Skip to content
This repository has been archived by the owner on Oct 9, 2023. It is now read-only.

Commit

Permalink
Merge branch 'master' into node-execution-checkpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
hamersaw authored Oct 5, 2022
2 parents 4e71330 + 66eaf12 commit dd86a60
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
6 changes: 6 additions & 0 deletions pkg/webhook/k8s_secrets_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import (
)

func TestK8sSecretInjector_Inject(t *testing.T) {
optional := true

inputPod := corev1.Pod{
Spec: corev1.PodSpec{
Containers: []corev1.Container{
Expand All @@ -36,6 +38,7 @@ func TestK8sSecretInjector_Inject(t *testing.T) {
LocalObjectReference: corev1.LocalObjectReference{
Name: "grOUP",
},
Optional: &optional,
},
},
},
Expand Down Expand Up @@ -63,6 +66,7 @@ func TestK8sSecretInjector_Inject(t *testing.T) {
Path: "hello",
},
},
Optional: &optional,
},
},
},
Expand Down Expand Up @@ -110,6 +114,7 @@ func TestK8sSecretInjector_Inject(t *testing.T) {
Path: "world",
},
},
Optional: &optional,
},
},
},
Expand Down Expand Up @@ -147,6 +152,7 @@ func TestK8sSecretInjector_Inject(t *testing.T) {
VolumeSource: corev1.VolumeSource{
Secret: &corev1.SecretVolumeSource{
SecretName: "hello",
Optional: &optional,
},
},
},
Expand Down
6 changes: 5 additions & 1 deletion pkg/webhook/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,23 @@ func hasEnvVar(envVars []corev1.EnvVar, envVarKey string) bool {
}

func CreateEnvVarForSecret(secret *core.Secret) corev1.EnvVar {
optional := true
return corev1.EnvVar{
Name: strings.ToUpper(K8sDefaultEnvVarPrefix + secret.Group + EnvVarGroupKeySeparator + secret.Key),
ValueFrom: &corev1.EnvVarSource{
SecretKeyRef: &corev1.SecretKeySelector{
LocalObjectReference: corev1.LocalObjectReference{
Name: secret.Group,
},
Key: secret.Key,
Key: secret.Key,
Optional: &optional,
},
},
}
}

func CreateVolumeForSecret(secret *core.Secret) corev1.Volume {
optional := true
return corev1.Volume{
// we don't want to create different volume for the same secret group
Name: encoding.Base32Encoder.EncodeToString([]byte(secret.Group + EnvVarGroupKeySeparator + secret.GroupVersion)),
Expand All @@ -51,6 +54,7 @@ func CreateVolumeForSecret(secret *core.Secret) corev1.Volume {
Path: strings.ToLower(secret.Key),
},
},
Optional: &optional,
},
},
}
Expand Down

0 comments on commit dd86a60

Please sign in to comment.