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

Commit

Permalink
Merge pull request #400 from wwitzel3/fix-configmap-queryer
Browse files Browse the repository at this point in the history
fix bug with ConfigMapsForPod
  • Loading branch information
Sam Foo authored Nov 1, 2019
2 parents f9ac3af + e777eea commit ab4f547
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
19 changes: 12 additions & 7 deletions internal/queryer/queryer.go
Original file line number Diff line number Diff line change
Expand Up @@ -740,18 +740,23 @@ func (osq *ObjectStoreQueryer) ConfigMapsForPod(ctx context.Context, pod *corev1
return nil, errors.Wrap(err, "copying object metadata")
}

for _, c := range pod.Spec.Containers {
for ci := range pod.Spec.Containers {
c := &pod.Spec.Containers[ci]
for _, e := range c.Env {
ref := e.ValueFrom.ConfigMapKeyRef
if ref.Name == configMap.Name {
configMaps = append(configMaps, configMap)
if e.ValueFrom != nil && e.ValueFrom.ConfigMapKeyRef != nil {
ref := e.ValueFrom.ConfigMapKeyRef
if ref.Name == configMap.Name {
configMaps = append(configMaps, configMap)
}
}
}

for _, e := range c.EnvFrom {
ref := e.ConfigMapRef
if ref.Name == configMap.Name {
configMaps = append(configMaps, configMap)
if e.ConfigMapRef != nil {
ref := e.ConfigMapRef
if ref.Name == configMap.Name {
configMaps = append(configMaps, configMap)
}
}
}
}
Expand Down
4 changes: 4 additions & 0 deletions internal/queryer/queryer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -910,6 +910,10 @@ func TestObjectStoreQueryer_ConfigMapsForPod(t *testing.T) {
},
},
Env: []corev1.EnvVar{
{
Name: "configmap3",
Value: "configmap3_value",
},
{
ValueFrom: &corev1.EnvVarSource{
ConfigMapKeyRef: &corev1.ConfigMapKeySelector{
Expand Down

0 comments on commit ab4f547

Please sign in to comment.