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 @@ -11,7 +11,7 @@ require (
11
11
k8s.io/code-generator v0.33.1
12
12
k8s.io/kube-openapi v0.0.0-20250318190949-c8a335a9a2ff
13
13
knative.dev/hack v0.0.0-20250514121446-f525e187efdc
14
- knative.dev/pkg v0.0.0-20250626040505-5e2512c7127f
14
+ knative.dev/pkg v0.0.0-20250627005806-7681e80bae5f
15
15
)
16
16
17
17
require (
Original file line number Diff line number Diff line change @@ -680,8 +680,8 @@ k8s.io/utils v0.0.0-20241210054802-24370beab758 h1:sdbE21q2nlQtFh65saZY+rRM6x6aJ
680
680
k8s.io/utils v0.0.0-20241210054802-24370beab758 /go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0 =
681
681
knative.dev/hack v0.0.0-20250514121446-f525e187efdc h1:8HmclJlA0zNE/G1SkgdC3/IFSSyhaSz2iIhihU6YbEo =
682
682
knative.dev/hack v0.0.0-20250514121446-f525e187efdc /go.mod h1:R0ritgYtjLDO9527h5vb5X6gfvt5LCrJ55BNbVDsWiY =
683
- knative.dev/pkg v0.0.0-20250626040505-5e2512c7127f h1:V8/nxYaJ9A5oWS+qJ92xrfBoumZITLO5S8RU4L0uY+8 =
684
- knative.dev/pkg v0.0.0-20250626040505-5e2512c7127f /go.mod h1:0s7tF3WffhdCzvTzaTEE092KeB4P3OYuRvwFuh5c7kk =
683
+ knative.dev/pkg v0.0.0-20250627005806-7681e80bae5f h1:U2qhuJk5ezHFCkcKqh10lB2TckOoXNQAYj2qgFblXhA =
684
+ knative.dev/pkg v0.0.0-20250627005806-7681e80bae5f /go.mod h1:sZkXsfyjetJqzHRkR3/8fP6K6iQJsub2W2rtYKTu6FU =
685
685
rsc.io/binaryregexp v0.2.0 /go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8 =
686
686
rsc.io/quote/v3 v3.1.0 /go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0 =
687
687
rsc.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.
17
17
package system
18
18
19
19
import (
20
+ "cmp"
20
21
"fmt"
21
22
"os"
22
23
)
23
24
24
25
const (
25
26
// NamespaceEnvKey is the environment variable that specifies the system namespace.
26
27
NamespaceEnvKey = "SYSTEM_NAMESPACE"
28
+
27
29
// 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.
29
32
ResourceLabelEnvKey = "SYSTEM_RESOURCE_LABEL"
30
33
)
31
34
@@ -60,3 +63,28 @@ import (
60
63
func ResourceLabel () string {
61
64
return os .Getenv (ResourceLabelEnvKey )
62
65
}
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 @@ -855,7 +855,7 @@ k8s.io/utils/trace
855
855
# knative.dev/hack v0.0.0-20250514121446-f525e187efdc
856
856
## explicit; go 1.21
857
857
knative.dev/hack
858
- # knative.dev/pkg v0.0.0-20250626040505-5e2512c7127f
858
+ # knative.dev/pkg v0.0.0-20250627005806-7681e80bae5f
859
859
## explicit; go 1.24.0
860
860
knative.dev/pkg/apis
861
861
knative.dev/pkg/apis/duck
You can’t perform that action at this time.
0 commit comments