Skip to content

Commit

Permalink
fixed bug where I didn't check environment for nil pointer
Browse files Browse the repository at this point in the history
  • Loading branch information
NimbleArchitect committed Nov 16, 2022
1 parent 9dedba0 commit b95ea9b
Showing 1 changed file with 25 additions and 23 deletions.
48 changes: 25 additions & 23 deletions pkg/plugin/environment.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,29 +144,31 @@ func (s *environment) envBuildRow(info BuilderInformation, env v1.EnvVar, connec

envKey = env.Name
if len(env.Value) == 0 {
if env.ValueFrom.ConfigMapKeyRef != nil {
configName = env.ValueFrom.ConfigMapKeyRef.LocalObjectReference.Name
key = env.ValueFrom.ConfigMapKeyRef.Key
envValue = "CONFIGMAP:" + configName + " KEY:" + key
}

if env.ValueFrom.SecretKeyRef != nil {
configName = env.ValueFrom.SecretKeyRef.LocalObjectReference.Name
key = env.ValueFrom.SecretKeyRef.Key
envValue = "SECRETMAP:" + configName + " KEY:" + key
translate = false // never translate secrets
}

if env.ValueFrom.FieldRef != nil {
configName = env.ValueFrom.FieldRef.FieldPath
envValue = "FIELDREF:" + configName
translate = false // we cant translate FieldRef at the minute
}

if env.ValueFrom.ResourceFieldRef != nil {
configName = env.ValueFrom.ResourceFieldRef.Resource
envValue = "RESOURCE:" + configName
translate = false // we cant translate resourceFieldRef at the moment
if env.ValueFrom != nil {
if env.ValueFrom.ConfigMapKeyRef != nil {
configName = env.ValueFrom.ConfigMapKeyRef.LocalObjectReference.Name
key = env.ValueFrom.ConfigMapKeyRef.Key
envValue = "CONFIGMAP:" + configName + " KEY:" + key
}

if env.ValueFrom.SecretKeyRef != nil {
configName = env.ValueFrom.SecretKeyRef.LocalObjectReference.Name
key = env.ValueFrom.SecretKeyRef.Key
envValue = "SECRETMAP:" + configName + " KEY:" + key
translate = false // never translate secrets
}

if env.ValueFrom.FieldRef != nil {
configName = env.ValueFrom.FieldRef.FieldPath
envValue = "FIELDREF:" + configName
translate = false // we cant translate FieldRef at the minute
}

if env.ValueFrom.ResourceFieldRef != nil {
configName = env.ValueFrom.ResourceFieldRef.Resource
envValue = "RESOURCE:" + configName
translate = false // we cant translate resourceFieldRef at the moment
}
}

if translate {
Expand Down

0 comments on commit b95ea9b

Please sign in to comment.