Skip to content

Commit

Permalink
Merge pull request #344 from karelyatin/downward_api
Browse files Browse the repository at this point in the history
Reuse env.DownwardAPI from lib-common
  • Loading branch information
openshift-merge-bot[bot] authored Aug 21, 2024
2 parents 9459682 + de0fc05 commit 6a2f34f
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 18 deletions.
2 changes: 1 addition & 1 deletion pkg/ovncontroller/configjob.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ func ConfigJob(
envVars["OVNAvailabilityZones"] = env.SetValue(strings.Join(instance.Spec.ExternalIDS.OvnAvailabilityZones, ":"))
envVars["EnableChassisAsGateway"] = env.SetValue(fmt.Sprintf("%t", *instance.Spec.ExternalIDS.EnableChassisAsGateway))
envVars["PhysicalNetworks"] = env.SetValue(getPhysicalNetworks(instance))
envVars["OVNHostName"] = EnvDownwardAPI("spec.nodeName")
envVars["OVNHostName"] = env.DownwardAPI("spec.nodeName")

for _, ovnPod := range ovnPods.Items {
jobs = append(
Expand Down
17 changes: 0 additions & 17 deletions pkg/ovncontroller/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import (
"sort"
"strings"

"github.com/openstack-k8s-operators/lib-common/modules/common/env"
ovnv1 "github.com/openstack-k8s-operators/ovn-operator/api/v1beta1"
"golang.org/x/exp/maps"
corev1 "k8s.io/api/core/v1"
Expand Down Expand Up @@ -59,19 +58,3 @@ func getOVNControllerPods(

return podList, nil
}

// EnvDownwardAPI - set env from FieldRef->FieldPath, e.g. status.podIP
func EnvDownwardAPI(field string) env.Setter {
return func(env *corev1.EnvVar) {
if env.ValueFrom == nil {
env.ValueFrom = &corev1.EnvVarSource{}
}
env.Value = ""

if env.ValueFrom.FieldRef == nil {
env.ValueFrom.FieldRef = &corev1.ObjectFieldSelector{}
}

env.ValueFrom.FieldRef.FieldPath = field
}
}

0 comments on commit 6a2f34f

Please sign in to comment.