diff --git a/go.mod b/go.mod index 52df005e95..d27efa9c9d 100644 --- a/go.mod +++ b/go.mod @@ -4,8 +4,8 @@ go 1.21 require ( github.com/google/go-cmp v0.6.0 - github.com/hashicorp/golang-lru v1.0.2 - github.com/hashicorp/hcl v1.0.0 + github.com/hashicorp/golang-lru v1.0.2 // indirect + github.com/hashicorp/hcl v1.0.0 // indirect github.com/mitchellh/go-homedir v1.1.0 github.com/spf13/afero v1.9.5 // indirect github.com/spf13/cobra v1.7.0 @@ -20,12 +20,12 @@ require ( k8s.io/cli-runtime v0.29.2 k8s.io/client-go v0.29.2 k8s.io/code-generator v0.29.2 - knative.dev/client-pkg v0.0.0-20240313113642-ca457df5ea78 - knative.dev/eventing v0.40.1-0.20240318205837-63068bd53ae6 - knative.dev/hack v0.0.0-20240318013248-424e75ed769a - knative.dev/networking v0.0.0-20240318132715-69566347ab2a - knative.dev/pkg v0.0.0-20240318073042-db6f3b074e8c - knative.dev/serving v0.40.1-0.20240319121315-da63b4a570fe + knative.dev/client-pkg v0.0.0-20240327121233-6984d81a90ec + knative.dev/eventing v0.40.1-0.20240327131403-47543259ceba + knative.dev/hack v0.0.0-20240327150553-47368d631660 + knative.dev/networking v0.0.0-20240327140628-ae039896b125 + knative.dev/pkg v0.0.0-20240327140624-1ca1f09c329e + knative.dev/serving v0.40.1-0.20240327150557-17df21964e1d sigs.k8s.io/yaml v1.4.0 ) @@ -87,7 +87,7 @@ require ( github.com/pkg/errors v0.9.1 // indirect github.com/prometheus/client_golang v1.19.0 // indirect github.com/prometheus/client_model v0.6.0 // indirect - github.com/prometheus/common v0.50.0 // indirect + github.com/prometheus/common v0.51.1 // indirect github.com/prometheus/procfs v0.12.0 // indirect github.com/prometheus/statsd_exporter v0.22.8 // indirect github.com/rickb777/date v1.20.0 // indirect @@ -112,10 +112,10 @@ require ( golang.org/x/time v0.5.0 // indirect golang.org/x/tools v0.19.0 // indirect gomodules.xyz/jsonpatch/v2 v2.4.0 // indirect - google.golang.org/api v0.170.0 // indirect + google.golang.org/api v0.171.0 // indirect google.golang.org/appengine v1.6.8 // indirect - google.golang.org/genproto/googleapis/api v0.0.0-20240304161311-37d4d3c04a78 // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20240311132316-a219d84964c2 // indirect + google.golang.org/genproto/googleapis/api v0.0.0-20240311132316-a219d84964c2 // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20240314234333-6e1732d8331c // indirect google.golang.org/grpc v1.62.1 // indirect google.golang.org/protobuf v1.33.0 // indirect gopkg.in/inf.v0 v0.9.1 // indirect diff --git a/go.sum b/go.sum index f81e080b30..2e5d331c6d 100644 --- a/go.sum +++ b/go.sum @@ -337,8 +337,8 @@ github.com/prometheus/common v0.26.0/go.mod h1:M7rCNAaPfAosfx8veZJCuw84e35h3Cfd9 github.com/prometheus/common v0.32.1/go.mod h1:vu+V0TpY+O6vW9J44gczi3Ap/oXXR10b+M/gUGO4Hls= github.com/prometheus/common v0.35.0/go.mod h1:phzohg0JFMnBEFGxTDbfu3QyL5GI8gTQJFhYO5B3mfA= github.com/prometheus/common v0.37.0/go.mod h1:phzohg0JFMnBEFGxTDbfu3QyL5GI8gTQJFhYO5B3mfA= -github.com/prometheus/common v0.50.0 h1:YSZE6aa9+luNa2da6/Tik0q0A5AbR+U003TItK57CPQ= -github.com/prometheus/common v0.50.0/go.mod h1:wHFBCEVWVmHMUpg7pYcOm2QUR/ocQdYSJVQJKnHc3xQ= +github.com/prometheus/common v0.51.1 h1:eIjN50Bwglz6a/c3hAgSMcofL3nD+nFQkV6Dd4DsQCw= +github.com/prometheus/common v0.51.1/go.mod h1:lrWtQx+iDfn2mbH5GUzlH9TSHyfZpHkSiG1W7y3sF2Q= github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= github.com/prometheus/procfs v0.1.3/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4OA4YeYWdaU= @@ -698,8 +698,8 @@ google.golang.org/api v0.30.0/go.mod h1:QGmEvQ87FHZNiUVJkT14jQNYJ4ZJjdRF23ZXz513 google.golang.org/api v0.35.0/go.mod h1:/XrVsuzM0rZmrsbjJutiuftIzeuTQcEeaYcSk/mQ1dg= google.golang.org/api v0.36.0/go.mod h1:+z5ficQTmoYpPn8LCUNVpK5I7hwkpjbcgqA7I34qYtE= google.golang.org/api v0.40.0/go.mod h1:fYKFpnQN0DsDSKRVRcQSDQNtqWPfM9i+zNPxepjRCQ8= -google.golang.org/api v0.170.0 h1:zMaruDePM88zxZBG+NG8+reALO2rfLhe/JShitLyT48= -google.golang.org/api v0.170.0/go.mod h1:/xql9M2btF85xac/VAm4PsLMTLVGUOpq4BE9R8jyNy8= +google.golang.org/api v0.171.0 h1:w174hnBPqut76FzW5Qaupt7zY8Kql6fiVjgys4f58sU= +google.golang.org/api v0.171.0/go.mod h1:Hnq5AHm4OTMt2BUVjael2CWZFD6vksJdWCWiUAmjC9o= google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= google.golang.org/appengine v1.5.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= @@ -747,10 +747,10 @@ google.golang.org/genproto v0.0.0-20201210142538-e3217bee35cc/go.mod h1:FWY/as6D google.golang.org/genproto v0.0.0-20201214200347-8c77b98c765d/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20210108203827-ffc7fda8c3d7/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20210226172003-ab064af71705/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto/googleapis/api v0.0.0-20240304161311-37d4d3c04a78 h1:SzXBGiWM1LNVYLCRP3e0/Gsze804l4jGoJ5lYysEO5I= -google.golang.org/genproto/googleapis/api v0.0.0-20240304161311-37d4d3c04a78/go.mod h1:O1cOfN1Cy6QEYr7VxtjOyP5AdAuR0aJ/MYZaaof623Y= -google.golang.org/genproto/googleapis/rpc v0.0.0-20240311132316-a219d84964c2 h1:9IZDv+/GcI6u+a4jRFRLxQs0RUCfavGfoOgEW6jpkI0= -google.golang.org/genproto/googleapis/rpc v0.0.0-20240311132316-a219d84964c2/go.mod h1:UCOku4NytXMJuLQE5VuqA5lX3PcHCBo8pxNyvkf4xBs= +google.golang.org/genproto/googleapis/api v0.0.0-20240311132316-a219d84964c2 h1:rIo7ocm2roD9DcFIX67Ym8icoGCKSARAiPljFhh5suQ= +google.golang.org/genproto/googleapis/api v0.0.0-20240311132316-a219d84964c2/go.mod h1:O1cOfN1Cy6QEYr7VxtjOyP5AdAuR0aJ/MYZaaof623Y= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240314234333-6e1732d8331c h1:lfpJ/2rWPa/kJgxyyXM8PrNnfCzcmxJ265mADgwmvLI= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240314234333-6e1732d8331c/go.mod h1:WtryC6hu0hhx87FDGxWCDptyssuo68sk10vYjF+T9fY= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38= google.golang.org/grpc v1.21.1/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM= @@ -839,18 +839,18 @@ k8s.io/kube-openapi v0.0.0-20231010175941-2dd684a91f00 h1:aVUu9fTY98ivBPKR9Y5w/A k8s.io/kube-openapi v0.0.0-20231010175941-2dd684a91f00/go.mod h1:AsvuZPBlUDVuCdzJ87iajxtXuR9oktsTctW/R9wwouA= k8s.io/utils v0.0.0-20240102154912-e7106e64919e h1:eQ/4ljkx21sObifjzXwlPKpdGLrCfRziVtos3ofG/sQ= k8s.io/utils v0.0.0-20240102154912-e7106e64919e/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0= -knative.dev/client-pkg v0.0.0-20240313113642-ca457df5ea78 h1:Dyk9poFb3XsKle6bgI3+XoyBZRpKkPXNuZmaw6BcWfE= -knative.dev/client-pkg v0.0.0-20240313113642-ca457df5ea78/go.mod h1:CODwMfQexBzzgB2fv9hYF1+FZfrYc9TF3B26GxW69zQ= -knative.dev/eventing v0.40.1-0.20240318205837-63068bd53ae6 h1:4EK1UKlX1dFJQEJnKYEZv2xXnDnI7CrSBmny0KneCEs= -knative.dev/eventing v0.40.1-0.20240318205837-63068bd53ae6/go.mod h1:/QONbc1yAStWdNFV59rJ7js7Mc/87izlFTWkbzORZeo= -knative.dev/hack v0.0.0-20240318013248-424e75ed769a h1:E5aUF562P5BXHsBYx7S4Oa4KKXSH8SkKFG5CqZOTypg= -knative.dev/hack v0.0.0-20240318013248-424e75ed769a/go.mod h1:yk2OjGDsbEnQjfxdm0/HJKS2WqTLEFg/N6nUs6Rqx3Q= -knative.dev/networking v0.0.0-20240318132715-69566347ab2a h1:mWpzptq5CInluhMyGerLrHSyH64sdi/hCtHeHyTOplg= -knative.dev/networking v0.0.0-20240318132715-69566347ab2a/go.mod h1:GgOyc+O4ZctaOgIDXVvC4tf++AHc/pMiiwCzZz67os4= -knative.dev/pkg v0.0.0-20240318073042-db6f3b074e8c h1:d8GmDhObjnH/iKrazsNjgLuuEnxLiFE/QSaeFY337cw= -knative.dev/pkg v0.0.0-20240318073042-db6f3b074e8c/go.mod h1:RfDXq7Rf7UmGCEdAiJZPpBRuh7dX73T8clniFt2zEAA= -knative.dev/serving v0.40.1-0.20240319121315-da63b4a570fe h1:SfsPuu5rZuL88DXQwuBCWW0ERBk1HWJKSGmLCX40OBE= -knative.dev/serving v0.40.1-0.20240319121315-da63b4a570fe/go.mod h1:mkfPllWec0aSHe7Rmcsu9MlyO1RLWQunbT+HGy99ntQ= +knative.dev/client-pkg v0.0.0-20240327121233-6984d81a90ec h1:gG8AzUJDHrYONInTv0wm1gSPzWp3n8tooewl+yGpe/I= +knative.dev/client-pkg v0.0.0-20240327121233-6984d81a90ec/go.mod h1:PYodo1bmKTrxnNCfLJa6a8wdg3QQH0XTOPlZJwrY64A= +knative.dev/eventing v0.40.1-0.20240327131403-47543259ceba h1:uX9UsYNHJQDpqVSMVijhSljmCSLZm5ocPdQJ4jrkyig= +knative.dev/eventing v0.40.1-0.20240327131403-47543259ceba/go.mod h1:19sfPiy4dK2jBIHgszOTk43qOvfCXz1GTIncRY3trB8= +knative.dev/hack v0.0.0-20240327150553-47368d631660 h1:tW6NgyjMnSXBS75+k+Xh5uNiLhJ9TFswS9hrkC3OQOc= +knative.dev/hack v0.0.0-20240327150553-47368d631660/go.mod h1:yk2OjGDsbEnQjfxdm0/HJKS2WqTLEFg/N6nUs6Rqx3Q= +knative.dev/networking v0.0.0-20240327140628-ae039896b125 h1:w9XY50H8EmPj0C3QGeScCcCqt8Y3vjPEujf/LeH7RLY= +knative.dev/networking v0.0.0-20240327140628-ae039896b125/go.mod h1:YlLpTHRi0i/5XVD3QoqEfFhSmAfRj9sZR2NQEOF9dVc= +knative.dev/pkg v0.0.0-20240327140624-1ca1f09c329e h1:Cg28hbL35g5Qd3tC0PKSX2FMMD8IZnTYxRr4VLIUgd8= +knative.dev/pkg v0.0.0-20240327140624-1ca1f09c329e/go.mod h1:uYSh5G3A/pFmzgowpvKeyphLbXVkY4x7zEhReKwsVeU= +knative.dev/serving v0.40.1-0.20240327150557-17df21964e1d h1:FM13mIUEX2ruEBl2Y9yMnSKIMfIliaq88PmdPkOUGsU= +knative.dev/serving v0.40.1-0.20240327150557-17df21964e1d/go.mod h1:Ai1kjddNp76rlrHL5wbctNifAk4wu5ASdJ/WR0nmgfk= 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/pkg/kn/plugin/context_sharing.go b/pkg/kn/plugin/context_sharing.go index 35ea0a1666..b9751417c3 100644 --- a/pkg/kn/plugin/context_sharing.go +++ b/pkg/kn/plugin/context_sharing.go @@ -23,7 +23,7 @@ import ( "path/filepath" "strings" - "knative.dev/client/pkg/kn/config" + "knative.dev/client/pkg/config" ) //--TYPES-- diff --git a/pkg/kn/plugin/manager.go b/pkg/kn/plugin/manager.go index d244ebcb96..de26bbf498 100644 --- a/pkg/kn/plugin/manager.go +++ b/pkg/kn/plugin/manager.go @@ -25,7 +25,7 @@ import ( "strings" "text/template" - pkgplugin "knative.dev/client-pkg/pkg/kn/plugin" + pkgplugin "knative.dev/client-pkg/pkg/plugin" homedir "github.com/mitchellh/go-homedir" "github.com/spf13/cobra" diff --git a/third_party/VENDOR-LICENSE/knative.dev/client-pkg/pkg/kn/plugin/LICENSE b/third_party/VENDOR-LICENSE/knative.dev/client-pkg/pkg/plugin/LICENSE similarity index 100% rename from third_party/VENDOR-LICENSE/knative.dev/client-pkg/pkg/kn/plugin/LICENSE rename to third_party/VENDOR-LICENSE/knative.dev/client-pkg/pkg/plugin/LICENSE diff --git a/vendor/github.com/prometheus/common/expfmt/expfmt.go b/vendor/github.com/prometheus/common/expfmt/expfmt.go index 6fc9555e3f..051b38cd17 100644 --- a/vendor/github.com/prometheus/common/expfmt/expfmt.go +++ b/vendor/github.com/prometheus/common/expfmt/expfmt.go @@ -15,6 +15,7 @@ package expfmt import ( + "fmt" "strings" "github.com/prometheus/common/model" @@ -63,7 +64,7 @@ const ( type FormatType int const ( - TypeUnknown = iota + TypeUnknown FormatType = iota TypeProtoCompact TypeProtoDelim TypeProtoText @@ -73,7 +74,8 @@ const ( // NewFormat generates a new Format from the type provided. Mostly used for // tests, most Formats should be generated as part of content negotiation in -// encode.go. +// encode.go. If a type has more than one version, the latest version will be +// returned. func NewFormat(t FormatType) Format { switch t { case TypeProtoCompact: @@ -91,13 +93,21 @@ func NewFormat(t FormatType) Format { } } +// NewOpenMetricsFormat generates a new OpenMetrics format matching the +// specified version number. +func NewOpenMetricsFormat(version string) (Format, error) { + if version == OpenMetricsVersion_0_0_1 { + return fmtOpenMetrics_0_0_1, nil + } + if version == OpenMetricsVersion_1_0_0 { + return fmtOpenMetrics_1_0_0, nil + } + return fmtUnknown, fmt.Errorf("unknown open metrics version string") +} + // FormatType deduces an overall FormatType for the given format. func (f Format) FormatType() FormatType { toks := strings.Split(string(f), ";") - if len(toks) < 2 { - return TypeUnknown - } - params := make(map[string]string) for i, t := range toks { if i == 0 { diff --git a/vendor/github.com/prometheus/common/expfmt/openmetrics_create.go b/vendor/github.com/prometheus/common/expfmt/openmetrics_create.go index 432843da33..353c5e93f9 100644 --- a/vendor/github.com/prometheus/common/expfmt/openmetrics_create.go +++ b/vendor/github.com/prometheus/common/expfmt/openmetrics_create.go @@ -248,12 +248,12 @@ func MetricFamilyToOpenMetrics(out io.Writer, in *dto.MetricFamily, options ...E var createdTsBytesWritten int // Finally the samples, one line for each. + if metricType == dto.MetricType_COUNTER && strings.HasSuffix(name, "_total") { + compliantName = compliantName + "_total" + } for _, metric := range in.Metric { switch metricType { case dto.MetricType_COUNTER: - if strings.HasSuffix(name, "_total") { - compliantName = compliantName + "_total" - } if metric.Counter == nil { return written, fmt.Errorf( "expected counter in metric %s %s", compliantName, metric, diff --git a/vendor/knative.dev/client-pkg/pkg/kn/plugin/types.go b/vendor/knative.dev/client-pkg/pkg/kn/plugin/types.go deleted file mode 100644 index 1d740b9a54..0000000000 --- a/vendor/knative.dev/client-pkg/pkg/kn/plugin/types.go +++ /dev/null @@ -1,30 +0,0 @@ -package plugin - -// Allow plugins to register to this slice for inlining -var InternalPlugins PluginList - -// Interface describing a plugin -type Plugin interface { - // Get the name of the plugin (the file name without extensions) - Name() string - - // Execute the plugin with the given arguments - Execute(args []string) error - - // Return a description of the plugin (if support by the plugin binary) - Description() (string, error) - - // The command path leading to this plugin. - // Eg. for a plugin "kn source github" this will be [ "source", "github" ] - CommandParts() []string - - // Location of the plugin where it is stored in the filesystem - Path() string -} - -// Used for sorting a list of plugins -type PluginList []Plugin - -func (p PluginList) Len() int { return len(p) } -func (p PluginList) Less(i, j int) bool { return p[i].Name() < p[j].Name() } -func (p PluginList) Swap(i, j int) { p[i], p[j] = p[j], p[i] } diff --git a/vendor/knative.dev/client-pkg/pkg/plugin/context_sharing_types.go b/vendor/knative.dev/client-pkg/pkg/plugin/context_sharing_types.go new file mode 100644 index 0000000000..f36fa6e314 --- /dev/null +++ b/vendor/knative.dev/client-pkg/pkg/plugin/context_sharing_types.go @@ -0,0 +1,54 @@ +// Copyright © 2023 The Knative Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package plugin + +// Manifest represents plugin metadata +type Manifest struct { + // Path to external plugin binary. Always empty for inlined plugins. + Path string `json:"path,omitempty"` + + // Plugin declares its own manifest to be included in Context Sharing feature + HasManifest bool `json:"hasManifest"` + + // ProducesContextDataKeys is a list of keys for the ContextData that + // a plugin can produce. Nil or an empty list declares that this + // plugin is not ContextDataProducer + ProducesContextDataKeys []string `json:"producesKeys,omitempty"` + + // ConsumesContextDataKeys is a list of keys from a ContextData that a + // plugin is interested in to consume. Nil or an empty list declares + // that this plugin is not a ContextDataConsumer + ConsumesContextDataKeys []string `json:"consumesKeys,omitempty"` +} + +// PluginWithManifest represents extended plugin support for Manifest and Context Sharing feature +type PluginWithManifest interface { + // Plugin original interface wrapper + Plugin + + // GetManifest returns a metadata descriptor of plugin + GetManifest() *Manifest + + // GetContextData returns a map structure that is used to share common context data from plugin + GetContextData() map[string]string + + // ExecuteWithContextData an extended version of plugin.Execute command to allow injection and use of ContextData. + // This is a map[string]string structure to share common value service name between kn and plugins. + ExecuteWithContextData(ctx map[string]string, args []string) error + // Alternative impl: use of native context.Context as a data structure. + // We decided to use plain map, because Context can't be extended to external plugins anyway. + // Another encode to JSON is required to pass it. We might reconsider that in future development iterations. + +} diff --git a/vendor/knative.dev/client-pkg/pkg/plugin/manager.go b/vendor/knative.dev/client-pkg/pkg/plugin/manager.go new file mode 100644 index 0000000000..007404ca8c --- /dev/null +++ b/vendor/knative.dev/client-pkg/pkg/plugin/manager.go @@ -0,0 +1,514 @@ +// Copyright © 2020 The Knative Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package plugin + +import ( + "errors" + "fmt" + "os" + "os/exec" + "path/filepath" + "runtime" + "sort" + "strings" + "text/template" + + homedir "github.com/mitchellh/go-homedir" + "github.com/spf13/cobra" +) + +// Allow plugins to register to this slice for inlining +var InternalPlugins PluginList + +// Interface describing a plugin +type Plugin interface { + // Get the name of the plugin (the file name without extensions) + Name() string + + // Execute the plugin with the given arguments + Execute(args []string) error + + // Return a description of the plugin (if support by the plugin binary) + Description() (string, error) + + // The command path leading to this plugin. + // Eg. for a plugin "kn source github" this will be [ "source", "github" ] + CommandParts() []string + + // Location of the plugin where it is stored in the filesystem + Path() string +} + +type ContextData map[string]string + +type PluginManifest struct { + // ProducesContextDataKeys is a list of keys for the ContextData that + // a plugin can produce. Nil or an empty list declares that this + // plugin is not ContextDataProducer + ProducesContextDataKeys []string + + // ConsumesContextDataKeys is a list of keys from a ContextData that a + // plugin is interested in to consume. Nil or an empty list declares + // that this plugin is not a ContextDataConsumer + ConsumesContextDataKeys []string +} + +type ContextDataConsumer interface { + // ExecuteWithContextData executes the plugin with the given args much like + // Execute() but with an additional argument that holds the ContextData + ExecuteWithContextData(args []string, data ContextData) error +} + +type Manager struct { + // Dedicated plugin directory as configured + pluginsDir string + + // Whether to check the OS path or not + lookupInPath bool +} + +type plugin struct { + // Path to the plugin to execute + path string + + // Name of the plugin + name string + + // Commands leading to the execution of this plugin (e.g. "service","log" for a plugin kn-service-log) + commandParts []string +} + +// All extensions that are supposed to be windows executable +var windowsExecExtensions = []string{".bat", ".cmd", ".com", ".exe", ".ps1"} + +// Used for sorting a list of plugins +type PluginList []Plugin + +func (p PluginList) Len() int { return len(p) } +func (p PluginList) Less(i, j int) bool { return p[i].Name() < p[j].Name() } +func (p PluginList) Swap(i, j int) { p[i], p[j] = p[j], p[i] } + +// === PluginManager ======================================================================= + +// NewManager creates a new manager for looking up plugins on the file system +func NewManager(pluginDir string, lookupInPath bool) *Manager { + return &Manager{ + pluginsDir: pluginDir, + lookupInPath: lookupInPath, + } +} + +// FindPlugin checks if a plugin for the given parts exist and return it. +// The args given must not contain any options and contain only +// the commands (like in [ "source", "github" ] for a plugin called 'kn-source-github' +// The plugin with the most specific (longest) name is returned or nil if non is found. +// An error is returned if the lookup fails for some reason like an io error +func (manager *Manager) FindPlugin(parts []string) (Plugin, error) { + if len(parts) == 0 { + // No command given + return nil, nil + } + + // Try to find internal plugin fist + plugin := lookupInternalPlugin(parts) + if plugin != nil { + return plugin, nil + } + + // Try to find plugin in pluginsDir + pluginDir, err := homedir.Expand(manager.pluginsDir) + if err != nil { + return nil, err + } + + return findMostSpecificPluginInPath(pluginDir, parts, manager.lookupInPath) +} + +// ListPlugins lists all plugins that can be found in the plugin directory or in the path (if configured) +func (manager *Manager) ListPlugins() (PluginList, error) { + return manager.ListPluginsForCommandGroup(nil) +} + +// ListPluginsForCommandGroup lists all plugins that can be found in the plugin directory or in the path (if configured), +// and which fits to a command group +func (manager *Manager) ListPluginsForCommandGroup(commandGroupParts []string) (PluginList, error) { + + // Initialize with list of internal plugins + var plugins = append([]Plugin{}, filterPluginsByCommandGroup(InternalPlugins, commandGroupParts)...) + + dirs, err := manager.pluginLookupDirectories() + if err != nil { + return nil, err + } + + // Examine all files in possible plugin directories + hasSeen := make(map[string]bool) + for _, pl := range plugins { + hasSeen[pl.Name()] = true + } + for _, dir := range dirs { + files, err := os.ReadDir(dir) + + // Ignore non-existing directories + if os.IsNotExist(err) { + continue + } + + // Check for plugins within given directory + for _, f := range files { + name := f.Name() + if f.IsDir() { + continue + } + if !strings.HasPrefix(name, "kn-") { + continue + } + + // Check if plugin matches a command group + if !isPluginFileNamePartOfCommandGroup(commandGroupParts, f.Name()) { + continue + } + + // Ignore all plugins that are shadowed + if seen, ok := hasSeen[name]; !ok || !seen { + plugins = append(plugins, &plugin{ + path: filepath.Join(dir, f.Name()), + name: stripWindowsExecExtensions(f.Name()), + commandParts: extractPluginCommandFromFileName(f.Name()), + }) + hasSeen[name] = true + } + } + } + + // Sort according to name + sort.Sort(PluginList(plugins)) + return plugins, nil +} + +func filterPluginsByCommandGroup(plugins PluginList, commandGroupParts []string) PluginList { + ret := PluginList{} + for _, pl := range plugins { + if isPartOfCommandGroup(commandGroupParts, pl.CommandParts()) { + ret = append(ret, pl) + } + } + return ret +} + +func isPartOfCommandGroup(commandGroupParts []string, commandParts []string) bool { + if len(commandParts) != len(commandGroupParts)+1 { + return false + } + for i := range commandGroupParts { + if commandParts[i] != commandGroupParts[i] { + return false + } + } + return true +} + +func isPluginFileNamePartOfCommandGroup(commandGroupParts []string, pluginFileName string) bool { + if commandGroupParts == nil { + return true + } + + commandParts := extractPluginCommandFromFileName(pluginFileName) + if len(commandParts) != len(commandGroupParts)+1 { + return false + } + for i := range commandGroupParts { + if commandParts[i] != commandGroupParts[i] { + return false + } + } + return true +} + +// PluginsDir returns the configured directory holding plugins +func (manager *Manager) PluginsDir() string { + return manager.pluginsDir +} + +// LookupInPath returns true if plugins should be also looked up within the path +func (manager *Manager) LookupInPath() bool { + return manager.lookupInPath +} + +// === Plugin ============================================================================== + +// Execute the plugin with the given arguments +func (plugin *plugin) Execute(args []string) error { + //nolint:gosec // Passing the arguments through is expected, the plugins are trusted. + cmd := exec.Command(plugin.path, args...) + cmd.Stdout = os.Stdout + cmd.Stderr = os.Stderr + cmd.Stdin = os.Stdin + cmd.Env = os.Environ() + return cmd.Run() +} + +// Return a description of the plugin (if support by the plugin binary) +func (plugin *plugin) Description() (string, error) { + // TODO: Call out to the plugin to find a description. + // For now just use the path to the plugin + return plugin.path, nil + // return strings.Join(plugin.commandParts, "-"), nil +} + +// The the command path leading to this plugin. +// Eg. for a plugin "kn source github" this will be [ "source", "github" ] +func (plugin *plugin) CommandParts() []string { + return plugin.commandParts +} + +// Return the path to the plugin +func (plugin *plugin) Path() string { + return plugin.path +} + +// Name of the plugin +func (plugin *plugin) Name() string { + return plugin.name +} + +// ========================================================================================= + +// Find out all directories that might hold a plugin +func (manager *Manager) pluginLookupDirectories() ([]string, error) { + pluginPath, err := homedir.Expand(manager.pluginsDir) + if err != nil { + return nil, err + } + dirs := []string{pluginPath} + if manager.lookupInPath { + dirs = append(dirs, filepath.SplitList(os.Getenv("PATH"))...) + } + dirs = uniquePathsList(dirs) + return dirs, nil +} + +// HelpTemplateFuncs returns a function map which can be used in templates for resolving +// plugin related help messages +func (manager *Manager) HelpTemplateFuncs() *template.FuncMap { + ret := template.FuncMap{ + "listPlugins": manager.listPluginsHelpMessage(), + } + + return &ret +} + +// listPluginsHelpMessage returns a function which returns all plugins that are directly below the given +// command as a properly formatted string +func (manager *Manager) listPluginsHelpMessage() func(cmd *cobra.Command) string { + return func(cmd *cobra.Command) string { + if !cmd.HasSubCommands() { + return "" + } + list, err := manager.ListPluginsForCommandGroup(extractCommandGroup(cmd, []string{})) + if err != nil || len(list) == 0 { + // We don't show plugins if there is an error + return "" + } + var plugins []string + for _, pl := range list { + t := fmt.Sprintf(" %%-%ds %%s", cmd.NamePadding()) + desc, _ := pl.Description() + command := (pl.CommandParts())[len(pl.CommandParts())-1] + help := fmt.Sprintf(t, command, desc) + plugins = append(plugins, help) + } + return strings.Join(plugins, "\n") + } +} + +// extractCommandGroup constructs the command path as array of strings +func extractCommandGroup(cmd *cobra.Command, parts []string) []string { + if cmd.HasParent() { + parts = extractCommandGroup(cmd.Parent(), parts) + parts = append(parts, cmd.Name()) + } + return parts +} + +// uniquePathsList deduplicates a given slice of strings without +// sorting or otherwise altering its order in any way. +func uniquePathsList(paths []string) []string { + seen := map[string]bool{} + newPaths := make([]string, 0, len(paths)) + for _, p := range paths { + if seen[p] { + continue + } + seen[p] = true + newPaths = append(newPaths, p) + } + return newPaths +} + +// Split up a command name, discard the initial prefix ("kn-") and convert +// parts to command syntax (i.e. replace _ with -) +func extractPluginCommandFromFileName(name string) []string { + // Remove extension on windows + name = stripWindowsExecExtensions(name) + parts := strings.Split(name, "-") + if len(parts) < 1 { + return []string{} + } + ret := make([]string, 0, len(parts)-1) + for _, p := range parts[1:] { + ret = append(ret, convertUnderscoreToDash(p)) + } + return ret +} + +// Strip any extension that indicates an EXE on Windows +func stripWindowsExecExtensions(name string) string { + if runtime.GOOS == "windows" { + ext := filepath.Ext(name) + if len(ext) > 0 { + for _, e := range windowsExecExtensions { + if ext == e { + name = name[:len(name)-len(ext)] + break + } + } + } + } + return name +} + +// Return the path and the parts building the most specific plugin in the given directory +// If lookupInPath is true, then also the OS PATH is checked. +// An error returned if any IO operation fails +func findMostSpecificPluginInPath(dir string, parts []string, lookupInPath bool) (Plugin, error) { + for i := len(parts); i > 0; i-- { + + // Construct plugin name to lookup + var nameParts []string + var commandParts []string + for _, p := range parts[0:i] { + // for arguments that contain the path separator, + // stop the loop once the separator appears + if strings.Contains(p, string(os.PathSeparator)) { + break + } + // Subcommands with "-" are translated to "_" + // (e.g. a command "kn log-all" is translated to a plugin "kn-log_all") + nameParts = append(nameParts, convertDashToUnderscore(p)) + commandParts = append(commandParts, p) + } + name := fmt.Sprintf("kn-%s", strings.Join(nameParts, "-")) + + // Check for the name in plugin directory and PATH (if requested) + path, err := findInDirOrPath(name, dir, lookupInPath) + if err != nil { + return nil, fmt.Errorf("cannot lookup plugin %s in directory %s (lookup in path: %t): %w", name, dir, lookupInPath, err) + } + + // Found, return it + if path != "" { + return &plugin{ + path: path, + commandParts: commandParts, + name: name, + }, nil + } + } + + // Nothing found + return nil, nil +} + +// convertDashToUnderscore converts from the command name to the file name +func convertDashToUnderscore(p string) string { + return strings.Replace(p, "-", "_", -1) +} + +// convertUnderscoreToDash converts from the filename to the command name +func convertUnderscoreToDash(p string) string { + return strings.Replace(p, "_", "-", -1) +} + +// Find a command with name in the given directory or on the execution PATH (if lookupInPath is true) +// On Windows, also check well known extensions for executables +// Return the full path found or "" if none has found +// Return an error on any IO error. +func findInDirOrPath(name string, dir string, lookupInPath bool) (string, error) { + + exts := []string{""} + if runtime.GOOS == "windows" { + // Add also well known extensions for windows + exts = append(exts, windowsExecExtensions...) + } + + for _, ext := range exts { + nameExt := name + ext + + // Check plugin dir first + path := filepath.Join(dir, nameExt) + _, err := os.Stat(path) + if err == nil { + // Found in dir + return path, nil + } + if !os.IsNotExist(err) { + return "", fmt.Errorf("i/o error while reading %s: %w", path, err) + } + + // Check in PATH if requested + if lookupInPath { + path, err = exec.LookPath(name) + if err == nil { + // Found in path + return path, nil + } + if !errors.Is(err, exec.ErrNotFound) { + return "", fmt.Errorf("error for looking up %s in path: %w", name, err) + } + } + } + + // Not found + return "", nil +} + +// lookupInternalPlugin looks up internally registered plugins. Return nil if none is found. +// Start with longest argument path first to find the most specific match +func lookupInternalPlugin(parts []string) Plugin { + for i := len(parts); i > 0; i-- { + checkParts := parts[0:i] + for _, plugin := range InternalPlugins { + if equalsSlice(plugin.CommandParts(), checkParts) { + return plugin + } + } + } + return nil +} + +// equalsSlice return true if two string slices contain the same elements +func equalsSlice(a, b []string) bool { + if len(a) != len(b) || len(a) == 0 { + return false + } + + for i := range a { + if a[i] != b[i] { + return false + } + } + return true +} diff --git a/vendor/knative.dev/client-pkg/pkg/plugin/stat.go b/vendor/knative.dev/client-pkg/pkg/plugin/stat.go new file mode 100644 index 0000000000..d7cd7a1949 --- /dev/null +++ b/vendor/knative.dev/client-pkg/pkg/plugin/stat.go @@ -0,0 +1,36 @@ +// Copyright © 2019 The Knative Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +//go:build !windows +// +build !windows + +package plugin + +// This file doesn't compile for Windows platform, therefor a second stat_windows.go is +// added with a no-op + +import ( + "fmt" + "os" + "syscall" +) + +func statFileOwner(fileInfo os.FileInfo) (uint32, uint32, error) { + var sys *syscall.Stat_t + var ok bool + if sys, ok = fileInfo.Sys().(*syscall.Stat_t); !ok { + return 0, 0, fmt.Errorf("cannot check owner/group of file %s", fileInfo.Name()) + } + return sys.Uid, sys.Gid, nil +} diff --git a/vendor/knative.dev/client-pkg/pkg/plugin/stat_windows.go b/vendor/knative.dev/client-pkg/pkg/plugin/stat_windows.go new file mode 100644 index 0000000000..8a0af80f94 --- /dev/null +++ b/vendor/knative.dev/client-pkg/pkg/plugin/stat_windows.go @@ -0,0 +1,24 @@ +// Copyright © 2019 The Knative Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package plugin + +import ( + "os" +) + +// statFileOwner is a no-op on windows +func statFileOwner(fileInfo os.FileInfo) (uint32, uint32, error) { + return 0, 0, nil +} diff --git a/vendor/knative.dev/client-pkg/pkg/plugin/verify.go b/vendor/knative.dev/client-pkg/pkg/plugin/verify.go new file mode 100644 index 0000000000..5f5a03cea7 --- /dev/null +++ b/vendor/knative.dev/client-pkg/pkg/plugin/verify.go @@ -0,0 +1,256 @@ +// Copyright © 2019 The Knative Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package plugin + +import ( + "errors" + "fmt" + "io" + "os" + "path/filepath" + "runtime" + "strings" +) + +// Collection of errors and warning collected during verifications +type VerificationErrorsAndWarnings struct { + Errors []string + Warnings []string +} + +// permission bits for execute +const ( + UserExecute = 1 << 6 + GroupExecute = 1 << 3 + OtherExecute = 1 << 0 +) + +// Verification of a ll plugins. This method returns all errors and warnings +// for the verification. The following criteria are verified (for each plugin): +// * If the plugin is executable +// * If the plugin is overshadowed by a previous plugin +func (manager *Manager) Verify() VerificationErrorsAndWarnings { + eaw := VerificationErrorsAndWarnings{} + + dirs, err := manager.pluginLookupDirectories() + if err != nil { + return eaw.AddError("cannot lookup plugin directories: %v", err) + } + + // Examine all files in possible plugin directories + + seenPlugins := make(map[string]string) + for _, dir := range dirs { + files, err := os.ReadDir(dir) + + // Ignore non-existing directories + if os.IsNotExist(err) { + continue + } + + if err != nil { + eaw.AddError("unable to read directory '%s' from your plugin path: %v", dir, err) + continue + } + + for _, f := range files { + if f.IsDir() { + continue + } + if !strings.HasPrefix(f.Name(), "kn-") { + continue + } + eaw = verifyPath(filepath.Join(dir, f.Name()), seenPlugins, eaw) + } + } + return eaw +} + +func verifyPath(path string, seenPlugins map[string]string, eaw VerificationErrorsAndWarnings) VerificationErrorsAndWarnings { + + // Verify that plugin actually exists + fileInfo, err := os.Stat(path) + if err != nil { + if errors.Is(err, os.ErrNotExist) { + return eaw.AddError("cannot find plugin in %s", path) + } + return eaw.AddError("cannot stat %s: %v", path, err) + } + + eaw = addWarningIfNotExecutable(eaw, path, fileInfo) + eaw = addWarningIfAlreadySeen(eaw, seenPlugins, path) + + // Remember each verified plugin for duplicate check + seenPlugins[filepath.Base(path)] = path + + return eaw +} + +func addWarningIfNotExecutable(eaw VerificationErrorsAndWarnings, path string, fileInfo os.FileInfo) VerificationErrorsAndWarnings { + if runtime.GOOS == "windows" { + return checkForWindowsExecutable(eaw, fileInfo, path) + } + + mode := fileInfo.Mode() + if !mode.IsRegular() && !isSymlink(mode) { + return eaw.AddWarning("%s is not a file", path) + } + perms := uint32(mode.Perm()) + + uid, gid, err := statFileOwner(fileInfo) + if err != nil { + return eaw.AddWarning("%s", err.Error()) + } + isOwner := checkIfUserIsFileOwner(uid) + isInGroup, err := checkIfUserInGroup(gid) + if err != nil { + return eaw.AddError("cannot get group ids for checking executable status of file %s", path) + } + + // User is owner and owner can execute + if canOwnerExecute(perms, isOwner) { + return eaw + } + + // User is in group which can execute, but user is not file owner + if canGroupExecute(perms, isOwner, isInGroup) { + return eaw + } + + // All can execute, and the user is not file owner and not in the file's perm group + if canOtherExecute(perms, isOwner, isInGroup) { + return eaw + } + + return eaw.AddWarning("%s is not executable by current user", path) +} + +func addWarningIfAlreadySeen(eaw VerificationErrorsAndWarnings, seenPlugins map[string]string, path string) VerificationErrorsAndWarnings { + fileName := filepath.Base(path) + if existingPath, ok := seenPlugins[fileName]; ok { + return eaw.AddWarning("%s is ignored because it is shadowed by an equally named plugin: %s", path, existingPath) + } + return eaw +} + +func checkForWindowsExecutable(eaw VerificationErrorsAndWarnings, fileInfo os.FileInfo, path string) VerificationErrorsAndWarnings { + name := fileInfo.Name() + nameWithoutExecExtension := stripWindowsExecExtensions(name) + + if name == nameWithoutExecExtension { + return eaw.AddWarning("%s is not executable as it does not have a Windows exec extension (one of %s)", path, strings.Join(windowsExecExtensions, ", ")) + } + return eaw +} + +func checkIfUserInGroup(gid uint32) (bool, error) { + groups, err := os.Getgroups() + if err != nil { + return false, err + } + for _, g := range groups { + if int(gid) == g { + return true, nil + } + } + return false, nil +} + +func checkIfUserIsFileOwner(uid uint32) bool { + return int(uid) == os.Getuid() +} + +// Check if all can execute, and the user is not file owner and not in the file's perm group +func canOtherExecute(perms uint32, isOwner bool, isInGroup bool) bool { + if perms&OtherExecute != 0 { + if os.Getuid() == 0 { + return true + } + if !isOwner && !isInGroup { + return true + } + } + return false +} + +// Check if user is owner and owner can execute +func canOwnerExecute(perms uint32, isOwner bool) bool { + if perms&UserExecute != 0 { + if os.Getuid() == 0 { + return true + } + if isOwner { + return true + } + } + return false +} + +// Check if user is in group which can execute, but user is not file owner +func canGroupExecute(perms uint32, isOwner bool, isInGroup bool) bool { + if perms&GroupExecute != 0 { + if os.Getuid() == 0 { + return true + } + if !isOwner && isInGroup { + return true + } + } + return false +} + +func (eaw *VerificationErrorsAndWarnings) AddError(format string, args ...interface{}) VerificationErrorsAndWarnings { + eaw.Errors = append(eaw.Errors, fmt.Sprintf(format, args...)) + return *eaw +} + +func (eaw *VerificationErrorsAndWarnings) AddWarning(format string, args ...interface{}) VerificationErrorsAndWarnings { + eaw.Warnings = append(eaw.Warnings, fmt.Sprintf(format, args...)) + return *eaw +} + +func (eaw *VerificationErrorsAndWarnings) PrintWarningsAndErrors(out io.Writer) { + printSection(out, "ERROR", eaw.Errors) + printSection(out, "WARNING", eaw.Warnings) +} + +func (eaw *VerificationErrorsAndWarnings) HasErrors() bool { + return len(eaw.Errors) > 0 +} + +func (eaw *VerificationErrorsAndWarnings) IsEmpty() bool { + return len(eaw.Errors)+len(eaw.Warnings) == 0 +} + +func printSection(out io.Writer, label string, values []string) { + if len(values) > 0 { + printLabelWithConditionalPluralS(out, label, len(values)) + for _, value := range values { + fmt.Fprintf(out, " - %s\n", value) + } + } +} + +func printLabelWithConditionalPluralS(out io.Writer, label string, nr int) { + if nr == 1 { + fmt.Fprintf(out, "%s:\n", label) + } else { + fmt.Fprintf(out, "%ss:\n", label) + } +} + +func isSymlink(mode os.FileMode) bool { + return mode&os.ModeSymlink != 0 +} diff --git a/vendor/knative.dev/eventing/pkg/apis/eventing/v1/trigger_types.go b/vendor/knative.dev/eventing/pkg/apis/eventing/v1/trigger_types.go index b88ddcac9c..b20f651a29 100644 --- a/vendor/knative.dev/eventing/pkg/apis/eventing/v1/trigger_types.go +++ b/vendor/knative.dev/eventing/pkg/apis/eventing/v1/trigger_types.go @@ -76,6 +76,8 @@ var ( type TriggerSpec struct { // Broker is the broker that this trigger receives events from. Broker string `json:"broker,omitempty"` + // BrokerNamespace is the namespace of the broker that the trigger receives events from. + BrokerNamespace string `json:"brokerNamespace,omitempty"` // Filter is the filter to apply against all events from the Broker. Only events that pass this // filter will be sent to the Subscriber. If not specified, will default to allowing all events. diff --git a/vendor/knative.dev/hack/README.md b/vendor/knative.dev/hack/README.md index 8799e0b591..fd9c4d99b4 100644 --- a/vendor/knative.dev/hack/README.md +++ b/vendor/knative.dev/hack/README.md @@ -3,6 +3,11 @@ `hack` is a collection of scripts used to bootstrap CI processes and other vital entrypoint functionality. +## Contributing + +If you are interested in contributing to Knative, take a look at [CLOTRIBUTOR](https://clotributor.dev/search?project=knative&page=1) +for a list of help wanted issues across the project. + ## Using the `presubmit-tests.sh` helper script This is a helper script to run the presubmit tests. To use it: diff --git a/vendor/knative.dev/hack/SECURITY.md b/vendor/knative.dev/hack/SECURITY.md new file mode 100644 index 0000000000..52ec3c9f24 --- /dev/null +++ b/vendor/knative.dev/hack/SECURITY.md @@ -0,0 +1,7 @@ +# Knative Security Policy + +We're extremely grateful for security researchers and users that report vulnerabilities to the Knative Open Source Community. All reports are thoroughly investigated by a set of community volunteers. + +To make a report, please email the private security@knative.team list with the security details and the details expected for all Knative bug reports. + +See [Knative Security and Disclosure Information](https://knative.dev/docs/reference/security/) for more details. diff --git a/vendor/knative.dev/hack/go.work.sum b/vendor/knative.dev/hack/go.work.sum new file mode 100644 index 0000000000..1cc0cde937 --- /dev/null +++ b/vendor/knative.dev/hack/go.work.sum @@ -0,0 +1,61 @@ +cloud.google.com/go v0.26.0 h1:e0WKqKTd5BnrG8aKH3J3h+QvEIQtSUcf2n5UZ5ZgLtQ= +github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ= +github.com/NYTimes/gziphandler v0.0.0-20170623195520-56545f4a5d46 h1:lsxEuwrXEAokXB9qhlbKWPpo3KMLZQ5WB5WLQRW1uq0= +github.com/PuerkitoBio/purell v1.0.0 h1:0GoNN3taZV6QI81IXgCbxMyEaJDXMSIjArYBCYzVVvs= +github.com/PuerkitoBio/urlesc v0.0.0-20160726150825-5bd2802263f2 h1:JCHLVE3B+kJde7bIEo5N4J+ZbLhp0J1Fs+ulyRws4gE= +github.com/census-instrumentation/opencensus-proto v0.2.1 h1:glEXhBS5PSLLv4IXzLA5yPRVX4bilULVyxxbrfOtDAk= +github.com/client9/misspell v0.3.4 h1:ta993UF76GwbvJcIo3Y68y/M3WxlpEHPWIGDkJYwzJI= +github.com/cpuguy83/go-md2man/v2 v2.0.2 h1:p1EgwI/C7NhT0JmVkwCD2ZBK8j4aeHQX2pMHHBfMQ6w= +github.com/creack/pty v1.1.9 h1:uDmaGzcdjhF4i/plgjmEsriH11Y0o7RKapEf/LDaM3w= +github.com/docker/spdystream v0.0.0-20160310174837-449fdfce4d96 h1:cenwrSVm+Z7QLSV/BsnenAOcDXdX4cMv4wP0B/5QbPg= +github.com/docopt/docopt-go v0.0.0-20180111231733-ee0de3bc6815 h1:bWDMxwH3px2JBh6AyO7hdCn/PkvCZXii8TGj7sbtEbQ= +github.com/elazarl/goproxy v0.0.0-20180725130230-947c36da3153 h1:yUdfgN0XgIJw7foRItutHYUIhlcKzcSf5vDpdhQAKTc= +github.com/emicklei/go-restful v0.0.0-20170410110728-ff4f55a20633 h1:H2pdYOb3KQ1/YsqVWoWNLQO+fusocsw354rqGTZtAgw= +github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473 h1:4cmBvAEBNJaGARUEs3/suWRyfyBfhf7I60WBZq+bv2w= +github.com/envoyproxy/protoc-gen-validate v0.1.0 h1:EQciDnbrYxy13PgWoY8AqoxGiPrpgBZ1R8UNe3ddc+A= +github.com/evanphx/json-patch v4.9.0+incompatible h1:kLcOMZeuLAJvL2BPWLMIj5oaZQobrkAqrL+WFZwQses= +github.com/fsnotify/fsnotify v1.4.9 h1:hsms1Qyu0jgnwNXIxa+/V/PDsU6CfLf6CNO8H7IWoS4= +github.com/ghodss/yaml v0.0.0-20150909031657-73d445a93680 h1:ZktWZesgun21uEDrwW7iEV1zPCGQldM2atlJZ3TdvVM= +github.com/go-openapi/jsonpointer v0.0.0-20160704185906-46af16f9f7b1 h1:wSt/4CYxs70xbATrGXhokKF1i0tZjENLOo1ioIO13zk= +github.com/go-openapi/jsonreference v0.0.0-20160704190145-13c6e3589ad9 h1:tF+augKRWlWx0J0B7ZyyKSiTyV6E1zZe+7b3qQlcEf8= +github.com/go-openapi/spec v0.0.0-20160808142527-6aced65f8501 h1:C1JKChikHGpXwT5UQDFaryIpDtyyGL/CR6C2kB7F1oc= +github.com/go-openapi/swag v0.0.0-20160704191624-1d0bd113de87 h1:zP3nY8Tk2E6RTkqGYrarZXuzh+ffyLDljLxCy1iJw80= +github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b h1:VKtxabqXZkF25pY9ekfRL6a582T4P37/31XEstQ5p58= +github.com/golang/groupcache v0.0.0-20191227052852-215e87163ea7 h1:5ZkaAPbicIKTF2I64qf5Fh8Aa83Q/dnOafMYV0OMwjA= +github.com/golang/mock v1.1.1 h1:G5FRp8JnTd7RQH5kemVNlMeyXQAztQ3mOWV95KxsXH8= +github.com/golang/protobuf v1.4.2 h1:+Z5KGCizgyZCbGh1KZqA0fcLLkwbsjIzS4aV2v7wJX0= +github.com/google/uuid v1.1.1 h1:Gkbcsh/GbpXz7lPftLA3P6TYMwjCLYm83jiFQZF/3gY= +github.com/googleapis/gnostic v0.4.1 h1:DLJCy1n/vrD4HPjOvYcT8aYQXpPIzoRZONaYwyycI+I= +github.com/hashicorp/golang-lru v0.5.1 h1:0hERBMJE1eitiLkihrMvRVBYAkpHzc/J3QdDN+dAcgU= +github.com/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI= +github.com/kisielk/errcheck v1.2.0 h1:reN85Pxc5larApoH1keMBiu2GWtPqXQ1nc9gx+jOU+E= +github.com/kisielk/gotool v1.0.0 h1:AV2c/EiW3KqPNT9ZKl07ehoAGi4C5/01Cfbblndcapg= +github.com/kr/pretty v0.2.0 h1:s5hAObm+yFO5uHYt5dYjxi2rXrsnmRpJx4OYvIWUaQs= +github.com/kr/pty v1.1.1 h1:VkoXIwSboBpnk99O/KFauAEILuNHv5DVFKZMBN/gUgw= +github.com/mailru/easyjson v0.0.0-20160728113105-d5b7844b561a h1:TpvdAwDAt1K4ANVOfcihouRdvP+MgAfDWwBuct4l6ZY= +github.com/munnerz/goautoneg v0.0.0-20120707110453-a547fc61f48d h1:7PxY7LVfSZm7PEeBTyK1rj1gABdCO2mbri6GKO1cMDs= +github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f h1:y5//uYreIhSUg3J1GEMiLbxo1LJaP8RfCpH6pymGZus= +github.com/onsi/ginkgo v1.11.0 h1:JAKSXpt1YjtLA7YpPiqO9ss6sNXEsPfSGdwN0UHqzrw= +github.com/onsi/gomega v1.7.0 h1:XPnZz8VVBHjVsy1vzJmRwIcSwiUO+JFfrv/xGiigmME= +github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= +github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4 h1:gQz4mCbXsO+nc9n1hCxHcGA3Zx3Eo+UHZoInFGUIXNM= +github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk= +github.com/stretchr/objx v0.5.0 h1:1zr/of2m5FGMsad5YfcqgdqdWrIhu+EBEJRhR1U7z/c= +golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9 h1:psW17arqaxU48Z5kZ0CQnkZWQJsqcURM6tKiBApRjXI= +golang.org/x/exp v0.0.0-20190121172915-509febef88a4 h1:c2HOrn5iMezYjSlGPncknSEr/8x5LELb/ilJbXi9DEA= +golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3 h1:XQyxROzUlZH+WIQwySDgnISgOivlhjIEwaQaJEJrrN0= +golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be h1:vEDujvNQGv4jgYKudGeI/+DAX4Jffq6hpD55MmoEvKs= +golang.org/x/sync v0.0.0-20190423024810-112230192c58 h1:8gQV6CLnAEikrhgkHFbMAEhagSSnXWGV915qUMm9mrU= +golang.org/x/sys v0.0.0-20201112073958-5cba982894dd h1:5CtCZbICpIOFdgO940moixOPjc0178IU44m4EjOO5IY= +golang.org/x/tools v0.1.12 h1:VveCTK38A2rkS8ZqFY25HIDFscX5X9OoEhJd3quQmXU= +golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= +golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4= +google.golang.org/appengine v1.4.0 h1:/wp5JvzpHIxhs/dumFmF7BXTf3Z+dd4uXta4kVyO508= +google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013 h1:+kGHl1aib/qcwaRi1CbqBZ1rk19r85MNUf8HaBghugY= +google.golang.org/grpc v1.27.0 h1:rRYRFMVgRv6E0D70Skyfsr28tDXIuuPZyWGMPdMcnXg= +google.golang.org/protobuf v1.24.0 h1:UhZDfRO8JRQru4/+LlLE0BRKGF8L+PICnvYZmx/fEGA= +gopkg.in/fsnotify.v1 v1.4.7 h1:xOHLXZwVvI9hhs+cLKq5+I5onOuwQLhQwiu63xxlHs4= +gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ= +honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc h1:/hemPrYIhOhy8zYrNj+069zDB68us2sMGsfkFJO0iZs= +k8s.io/gengo v0.0.0-20200413195148-3a45101e95ac h1:sAvhNk5RRuc6FNYGqe7Ygz3PSo/2wGWbulskmzRX8Vs= +k8s.io/kube-openapi v0.0.0-20200805222855-6aeccd4b50c6 h1:+WnxoVtG8TMiudHBSEtrVL1egv36TkkJm+bA8AxicmQ= diff --git a/vendor/knative.dev/hack/library.sh b/vendor/knative.dev/hack/library.sh index ca67e68480..e5d21b70e6 100644 --- a/vendor/knative.dev/hack/library.sh +++ b/vendor/knative.dev/hack/library.sh @@ -753,6 +753,8 @@ function __go_update_deps_for_module() { if [[ "${FORCE_VENDOR:-false}" == "true" ]] || [ -d vendor ]; then group "Go mod vendor" go mod vendor 2>&1 | grep -v "ignoring symlink" || true + else + go mod download -x fi eval "$orig_pipefail_opt" @@ -770,8 +772,8 @@ function __go_update_deps_for_module() { remove_broken_symlinks ./vendor fi - group "Updating licenses" - update_licenses third_party/VENDOR-LICENSE "./..." + group "Checking licenses" + check_licenses ) } @@ -807,18 +809,6 @@ function run_kntest() { go_run knative.dev/test-infra/tools/kntest/cmd/kntest@latest "$@" } -# Run go-licenses to update licenses. -# Parameters: $1 - output file, relative to repo root dir. -# $2 - directory to inspect. -function update_licenses() { - local dst=$1 - local dir=$2 - shift - go_run github.com/google/go-licenses@v1.6.0 \ - save "${dir}" --save_path="${dst}" --force || \ - { echo "--- FAIL: go-licenses failed to update licenses"; return 1; } -} - # Run go-licenses to check for forbidden licenses. function check_licenses() { # Check that we don't have any forbidden licenses. diff --git a/vendor/knative.dev/networking/pkg/http/header/header.go b/vendor/knative.dev/networking/pkg/http/header/header.go index 158fb06200..143f8bedb2 100644 --- a/vendor/knative.dev/networking/pkg/http/header/header.go +++ b/vendor/knative.dev/networking/pkg/http/header/header.go @@ -55,9 +55,14 @@ const ( // at the Queue proxy level back to be a host header. OriginalHostKey = "K-Original-Host" - // KubeletProbeKey is the name of the header supplied by kubelet - // probes. Istio with mTLS rewrites probes, but their probes pass a - // different user-agent. So we augment the probes with this header. + // KubeletProbeKey is the name of the header supplied by kubelet probes. + // Prior to this deprecation, Istio with mTLS rewrote probes and their probes passed a + // different user-agent. Therefore, this header was added to augment the probes. + // + // Deprecated: this custom request header is no longer necessary since Istio now propagates the + // original request header `User-Agent` sent by the kubelet (e.g., User-Agent: kube-probe/1.29). + // For updated usage, please utilize knative.dev/networking/pkg/http/header.UserAgentKey and + // knative.dev/networking/pkg/http/header.KubeProbeUAPrefix KubeletProbeKey = "K-Kubelet-Probe" // RouteTagKey is the name of the header entry which has a tag name as value. diff --git a/vendor/knative.dev/serving/pkg/apis/serving/v1/revision_lifecycle.go b/vendor/knative.dev/serving/pkg/apis/serving/v1/revision_lifecycle.go index 9c92c01a3c..f0e54da9d8 100644 --- a/vendor/knative.dev/serving/pkg/apis/serving/v1/revision_lifecycle.go +++ b/vendor/knative.dev/serving/pkg/apis/serving/v1/revision_lifecycle.go @@ -170,7 +170,7 @@ func (rs *RevisionStatus) PropagateDeploymentStatus(original *appsv1.DeploymentS // PropagateAutoscalerStatus propagates autoscaler's status to the revision's status. func (rs *RevisionStatus) PropagateAutoscalerStatus(ps *autoscalingv1alpha1.PodAutoscalerStatus) { - resUnavailable := rs.GetCondition(RevisionConditionResourcesAvailable).IsFalse() + resUnavailable := rs.GetCondition(RevisionConditionResourcesAvailable).IsFalse() || rs.GetCondition(RevisionConditionContainerHealthy).IsFalse() // Reflect the PA status in our own. cond := ps.GetCondition(autoscalingv1alpha1.PodAutoscalerConditionReady) diff --git a/vendor/modules.txt b/vendor/modules.txt index fe30791fc3..7f8f072e64 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -240,7 +240,7 @@ github.com/prometheus/client_golang/prometheus/promhttp # github.com/prometheus/client_model v0.6.0 ## explicit; go 1.19 github.com/prometheus/client_model/go -# github.com/prometheus/common v0.50.0 +# github.com/prometheus/common v0.51.1 ## explicit; go 1.21 github.com/prometheus/common/expfmt github.com/prometheus/common/internal/bitbucket.org/ww/goautoneg @@ -410,7 +410,7 @@ golang.org/x/tools/internal/imports # gomodules.xyz/jsonpatch/v2 v2.4.0 ## explicit; go 1.20 gomodules.xyz/jsonpatch/v2 -# google.golang.org/api v0.170.0 +# google.golang.org/api v0.171.0 ## explicit; go 1.19 google.golang.org/api/support/bundler # google.golang.org/appengine v1.6.8 @@ -422,10 +422,10 @@ google.golang.org/appengine/internal/log google.golang.org/appengine/internal/remote_api google.golang.org/appengine/internal/urlfetch google.golang.org/appengine/urlfetch -# google.golang.org/genproto/googleapis/api v0.0.0-20240304161311-37d4d3c04a78 +# google.golang.org/genproto/googleapis/api v0.0.0-20240311132316-a219d84964c2 ## explicit; go 1.19 google.golang.org/genproto/googleapis/api/httpbody -# google.golang.org/genproto/googleapis/rpc v0.0.0-20240311132316-a219d84964c2 +# google.golang.org/genproto/googleapis/rpc v0.0.0-20240314234333-6e1732d8331c ## explicit; go 1.19 google.golang.org/genproto/googleapis/rpc/status # google.golang.org/grpc v1.62.1 @@ -960,10 +960,10 @@ k8s.io/utils/pointer k8s.io/utils/ptr k8s.io/utils/strings/slices k8s.io/utils/trace -# knative.dev/client-pkg v0.0.0-20240313113642-ca457df5ea78 +# knative.dev/client-pkg v0.0.0-20240327121233-6984d81a90ec ## explicit; go 1.21 -knative.dev/client-pkg/pkg/kn/plugin -# knative.dev/eventing v0.40.1-0.20240318205837-63068bd53ae6 +knative.dev/client-pkg/pkg/plugin +# knative.dev/eventing v0.40.1-0.20240327131403-47543259ceba ## explicit; go 1.21 knative.dev/eventing/pkg/apis/config knative.dev/eventing/pkg/apis/duck @@ -994,10 +994,10 @@ knative.dev/eventing/pkg/client/clientset/versioned/typed/sources/v1/fake knative.dev/eventing/pkg/client/clientset/versioned/typed/sources/v1beta2 knative.dev/eventing/pkg/client/clientset/versioned/typed/sources/v1beta2/fake knative.dev/eventing/pkg/eventingtls -# knative.dev/hack v0.0.0-20240318013248-424e75ed769a +# knative.dev/hack v0.0.0-20240327150553-47368d631660 ## explicit; go 1.18 knative.dev/hack -# knative.dev/networking v0.0.0-20240318132715-69566347ab2a +# knative.dev/networking v0.0.0-20240327140628-ae039896b125 ## explicit; go 1.21 knative.dev/networking/pkg knative.dev/networking/pkg/apis/networking @@ -1013,7 +1013,7 @@ knative.dev/networking/pkg/http/proxy knative.dev/networking/pkg/http/stats knative.dev/networking/pkg/ingress knative.dev/networking/pkg/k8s -# knative.dev/pkg v0.0.0-20240318073042-db6f3b074e8c +# knative.dev/pkg v0.0.0-20240327140624-1ca1f09c329e ## explicit; go 1.21 knative.dev/pkg/apis knative.dev/pkg/apis/duck @@ -1063,7 +1063,7 @@ knative.dev/pkg/tracing/config knative.dev/pkg/tracing/propagation knative.dev/pkg/tracing/propagation/tracecontextb3 knative.dev/pkg/tracker -# knative.dev/serving v0.40.1-0.20240319121315-da63b4a570fe +# knative.dev/serving v0.40.1-0.20240327150557-17df21964e1d ## explicit; go 1.21 knative.dev/serving/pkg/apis/autoscaling knative.dev/serving/pkg/apis/autoscaling/v1alpha1