File tree Expand file tree Collapse file tree 4 files changed +33
-5
lines changed
Expand file tree Collapse file tree 4 files changed +33
-5
lines changed Original file line number Diff line number Diff line change @@ -17,7 +17,7 @@ require (
1717 k8s.io/code-generator v0.33.1
1818 k8s.io/utils v0.0.0-20241210054802-24370beab758
1919 knative.dev/hack v0.0.0-20250514121446-f525e187efdc
20- knative.dev/pkg v0.0.0-20250626040505-5e2512c7127f
20+ knative.dev/pkg v0.0.0-20250627014006-8481e7eef7f6
2121 sigs.k8s.io/yaml v1.5.0
2222)
2323
Original file line number Diff line number Diff line change @@ -687,8 +687,8 @@ k8s.io/utils v0.0.0-20241210054802-24370beab758 h1:sdbE21q2nlQtFh65saZY+rRM6x6aJ
687687k8s.io/utils v0.0.0-20241210054802-24370beab758 /go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0 =
688688knative.dev/hack v0.0.0-20250514121446-f525e187efdc h1:8HmclJlA0zNE/G1SkgdC3/IFSSyhaSz2iIhihU6YbEo =
689689knative.dev/hack v0.0.0-20250514121446-f525e187efdc /go.mod h1:R0ritgYtjLDO9527h5vb5X6gfvt5LCrJ55BNbVDsWiY =
690- knative.dev/pkg v0.0.0-20250626040505-5e2512c7127f h1:V8/nxYaJ9A5oWS+qJ92xrfBoumZITLO5S8RU4L0uY+8 =
691- knative.dev/pkg v0.0.0-20250626040505-5e2512c7127f /go.mod h1:0s7tF3WffhdCzvTzaTEE092KeB4P3OYuRvwFuh5c7kk =
690+ knative.dev/pkg v0.0.0-20250627014006-8481e7eef7f6 h1:nmlU5tsFhfOZzTLlW7gZXN7KhqnF8XtR9myQ6ysRr9U =
691+ knative.dev/pkg v0.0.0-20250627014006-8481e7eef7f6 /go.mod h1:sZkXsfyjetJqzHRkR3/8fP6K6iQJsub2W2rtYKTu6FU =
692692rsc.io/binaryregexp v0.2.0 /go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8 =
693693rsc.io/quote/v3 v3.1.0 /go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0 =
694694rsc.io/sampler v1.3.0 /go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA =
Original file line number Diff line number Diff line change @@ -17,15 +17,18 @@ limitations under the License.
1717package system
1818
1919import (
20+ "cmp"
2021 "fmt"
2122 "os"
2223)
2324
2425const (
2526 // NamespaceEnvKey is the environment variable that specifies the system namespace.
2627 NamespaceEnvKey = "SYSTEM_NAMESPACE"
28+
2729 // ResourceLabelEnvKey is the environment variable that specifies the system resource
28- // label.
30+ // label. This label should be used to limit the number of configmaps that are watched
31+ // in the system namespace.
2932 ResourceLabelEnvKey = "SYSTEM_RESOURCE_LABEL"
3033)
3134
@@ -60,3 +63,28 @@ import (
6063func ResourceLabel () string {
6164 return os .Getenv (ResourceLabelEnvKey )
6265}
66+
67+ // PodName will read various env vars to determine the name of the running
68+ // pod before falling back
69+ //
70+ // First it will read 'POD_NAME' this is expected to be populated using the
71+ // Kubernetes downward API.
72+ //
73+ // env:
74+ // - name: MY_POD_NAME
75+ // valueFrom:
76+ // fieldRef:
77+ // fieldPath: metadata.name
78+ //
79+ // As a fallback it will read HOSTNAME. This is undocumented
80+ // Kubernetes behaviour that podman, cri-o and containerd have
81+ // inherited from docker.
82+ //
83+ // If none of these env-vars is set PodName will return an
84+ // empty string
85+ func PodName () string {
86+ return cmp .Or (
87+ os .Getenv ("POD_NAME" ),
88+ os .Getenv ("HOSTNAME" ),
89+ )
90+ }
Original file line number Diff line number Diff line change @@ -875,7 +875,7 @@ k8s.io/utils/trace
875875# knative.dev/hack v0.0.0-20250514121446-f525e187efdc
876876## explicit; go 1.21
877877knative.dev/hack
878- # knative.dev/pkg v0.0.0-20250626040505-5e2512c7127f
878+ # knative.dev/pkg v0.0.0-20250627014006-8481e7eef7f6
879879## explicit; go 1.24.0
880880knative.dev/pkg/apis
881881knative.dev/pkg/apis/duck
You can’t perform that action at this time.
0 commit comments