diff --git a/go.mod b/go.mod index 2d7bfdb94..321d548a3 100644 --- a/go.mod +++ b/go.mod @@ -11,7 +11,7 @@ require ( k8s.io/code-generator v0.33.1 k8s.io/kube-openapi v0.0.0-20250318190949-c8a335a9a2ff knative.dev/hack v0.0.0-20250514121446-f525e187efdc - knative.dev/pkg v0.0.0-20250626040505-5e2512c7127f + knative.dev/pkg v0.0.0-20250627005806-7681e80bae5f ) require ( diff --git a/go.sum b/go.sum index 026c4b3b2..c8095f3ab 100644 --- a/go.sum +++ b/go.sum @@ -680,8 +680,8 @@ k8s.io/utils v0.0.0-20241210054802-24370beab758 h1:sdbE21q2nlQtFh65saZY+rRM6x6aJ k8s.io/utils v0.0.0-20241210054802-24370beab758/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0= knative.dev/hack v0.0.0-20250514121446-f525e187efdc h1:8HmclJlA0zNE/G1SkgdC3/IFSSyhaSz2iIhihU6YbEo= knative.dev/hack v0.0.0-20250514121446-f525e187efdc/go.mod h1:R0ritgYtjLDO9527h5vb5X6gfvt5LCrJ55BNbVDsWiY= -knative.dev/pkg v0.0.0-20250626040505-5e2512c7127f h1:V8/nxYaJ9A5oWS+qJ92xrfBoumZITLO5S8RU4L0uY+8= -knative.dev/pkg v0.0.0-20250626040505-5e2512c7127f/go.mod h1:0s7tF3WffhdCzvTzaTEE092KeB4P3OYuRvwFuh5c7kk= +knative.dev/pkg v0.0.0-20250627005806-7681e80bae5f h1:U2qhuJk5ezHFCkcKqh10lB2TckOoXNQAYj2qgFblXhA= +knative.dev/pkg v0.0.0-20250627005806-7681e80bae5f/go.mod h1:sZkXsfyjetJqzHRkR3/8fP6K6iQJsub2W2rtYKTu6FU= rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8= rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0= rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA= diff --git a/vendor/knative.dev/pkg/system/env.go b/vendor/knative.dev/pkg/system/env.go index ea1db0f0b..c82cef6b0 100644 --- a/vendor/knative.dev/pkg/system/env.go +++ b/vendor/knative.dev/pkg/system/env.go @@ -17,6 +17,7 @@ limitations under the License. package system import ( + "cmp" "fmt" "os" ) @@ -24,8 +25,10 @@ import ( const ( // NamespaceEnvKey is the environment variable that specifies the system namespace. NamespaceEnvKey = "SYSTEM_NAMESPACE" + // ResourceLabelEnvKey is the environment variable that specifies the system resource - // label. + // label. This label should be used to limit the number of configmaps that are watched + // in the system namespace. ResourceLabelEnvKey = "SYSTEM_RESOURCE_LABEL" ) @@ -60,3 +63,28 @@ import ( func ResourceLabel() string { return os.Getenv(ResourceLabelEnvKey) } + +// PodName will read various env vars to determine the name of the running +// pod before falling back +// +// First it will read 'POD_NAME' this is expected to be populated using the +// Kubernetes downward API. +// +// env: +// - name: MY_POD_NAME +// valueFrom: +// fieldRef: +// fieldPath: metadata.name +// +// As a fallback it will read HOSTNAME. This is undocumented +// Kubernetes behaviour that podman, cri-o and containerd have +// inherited from docker. +// +// If none of these env-vars is set PodName will return an +// empty string +func PodName() string { + return cmp.Or( + os.Getenv("POD_NAME"), + os.Getenv("HOSTNAME"), + ) +} diff --git a/vendor/modules.txt b/vendor/modules.txt index ff9309920..4e9a33e40 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -855,7 +855,7 @@ k8s.io/utils/trace # knative.dev/hack v0.0.0-20250514121446-f525e187efdc ## explicit; go 1.21 knative.dev/hack -# knative.dev/pkg v0.0.0-20250626040505-5e2512c7127f +# knative.dev/pkg v0.0.0-20250627005806-7681e80bae5f ## explicit; go 1.24.0 knative.dev/pkg/apis knative.dev/pkg/apis/duck