From 03c45873125e4d73875407345fff26f543cad576 Mon Sep 17 00:00:00 2001 From: Karel Simon Date: Thu, 20 Jun 2024 08:38:18 +0200 Subject: [PATCH] revert: run go mod tidy && go mod vendor Signed-off-by: Karel Simon --- .../github.com/antlr4-go/antlr/v4/antlrdoc.go | 8 +- vendor/github.com/antlr4-go/antlr/v4/atn.go | 8 +- .../antlr4-go/antlr/v4/atn_config.go | 3 + .../antlr4-go/antlr/v4/input_stream.go | 2 +- .../github.com/antlr4-go/antlr/v4/jcollect.go | 5 +- vendor/github.com/antlr4-go/antlr/v4/lexer.go | 2 +- .../antlr4-go/antlr/v4/ll1_analyzer.go | 1 - vendor/github.com/antlr4-go/antlr/v4/mutex.go | 41 -- .../antlr4-go/antlr/v4/mutex_nomutex.go | 32 -- .../antlr/v4/parser_atn_simulator.go | 4 +- .../antlr4-go/antlr/v4/prediction_context.go | 60 +-- .../antlr4-go/antlr/v4/recognizer.go | 2 +- .../antlr4-go/antlr/v4/statistics.go | 3 +- vendor/github.com/antlr4-go/antlr/v4/token.go | 82 ++-- vendor/github.com/antlr4-go/antlr/v4/utils.go | 53 --- .../emicklei/go-restful/v3/CHANGES.md | 8 +- .../emicklei/go-restful/v3/curly.go | 48 +-- vendor/github.com/go-logr/logr/README.md | 1 - vendor/github.com/go-logr/logr/funcr/funcr.go | 169 ++++---- .../grpc-gateway/v2/runtime/context.go | 17 +- .../grpc-gateway/v2/runtime/errors.go | 10 +- .../grpc-gateway/v2/runtime/handler.go | 46 +- .../grpc-gateway/v2/runtime/marshal_json.go | 5 - .../grpc-gateway/v2/runtime/marshal_jsonpb.go | 15 +- .../v2/runtime/marshaler_registry.go | 2 +- .../grpc-gateway/v2/runtime/pattern.go | 18 +- .../apis/monitoring/v1/podmonitor_types.go | 4 +- .../pkg/apis/monitoring/v1/probe_types.go | 6 +- .../apis/monitoring/v1/prometheus_types.go | 72 +--- .../pkg/apis/monitoring/v1/types.go | 16 +- .../monitoring/v1/zz_generated.deepcopy.go | 140 +++--- .../pipeline/pkg/apis/config/feature_flags.go | 47 +-- .../pipeline/pkg/apis/config/metrics.go | 9 - .../apis/pipeline/v1/container_validation.go | 81 +--- .../pkg/apis/pipeline/v1/openapi_generated.go | 2 +- .../apis/pipeline/v1/pipeline_validation.go | 8 +- .../pipeline/v1/pipelineref_validation.go | 26 +- .../pkg/apis/pipeline/v1/result_types.go | 2 +- .../pkg/apis/pipeline/v1/swagger.json | 2 +- .../apis/pipeline/v1/taskref_validation.go | 32 +- .../v1alpha1/stepaction_conversion.go | 53 +-- .../pipeline/v1beta1/container_validation.go | 81 +--- .../pipeline/v1beta1/openapi_generated.go | 270 ------------ .../pipeline/v1beta1/pipeline_validation.go | 8 +- .../v1beta1/pipelineref_validation.go | 61 +-- .../pkg/apis/pipeline/v1beta1/register.go | 2 - .../pipeline/v1beta1/stepaction_conversion.go | 42 -- .../apis/pipeline/v1beta1/stepaction_types.go | 170 -------- .../pipeline/v1beta1/stepaction_validation.go | 209 --------- .../pkg/apis/pipeline/v1beta1/swagger.json | 139 ------ .../pipeline/v1beta1/taskref_validation.go | 56 +-- .../pipeline/v1beta1/zz_generated.deepcopy.go | 119 ------ .../v1beta1/resolution_request_types.go | 7 - .../v1beta1/fake/fake_pipeline_client.go | 4 - .../pipeline/v1beta1/fake/fake_stepaction.go | 129 ------ .../pipeline/v1beta1/generated_expansion.go | 2 - .../typed/pipeline/v1beta1/pipeline_client.go | 5 - .../typed/pipeline/v1beta1/stepaction.go | 178 -------- .../informers/externalversions/generic.go | 2 - .../pipeline/v1beta1/interface.go | 7 - .../pipeline/v1beta1/stepaction.go | 90 ---- .../stepaction/fake/fake.go | 4 +- .../stepaction/stepaction.go | 10 +- .../pipeline/v1beta1/expansion_generated.go | 8 - .../listers/pipeline/v1beta1/stepaction.go | 99 ----- .../pipeline/pkg/resolution/common/errors.go | 27 -- .../pkg/resolution/common/interface.go | 4 - .../tektoncd/pipeline/pkg/result/result.go | 8 +- .../tektoncd/pipeline/test/clients.go | 4 +- .../tektoncd/pipeline/test/controller.go | 8 +- .../diff/print.go} | 34 +- .../test/e2e-tests-kind-prow-alpha.env | 1 - .../test/e2e-tests-kind-prow-beta.env | 1 - .../tektoncd/pipeline/test/e2e-tests.sh | 14 - .../tektoncd/pipeline/test/featureflags.go | 18 +- .../tektoncd/pipeline/test/resolution.go | 178 ++++++++ vendor/golang.org/x/exp/slices/cmp.go | 44 -- vendor/golang.org/x/exp/slices/slices.go | 397 ++++-------------- vendor/golang.org/x/exp/slices/sort.go | 115 ++--- .../slices/{zsortanyfunc.go => zsortfunc.go} | 154 +++---- .../golang.org/x/exp/slices/zsortordered.go | 34 +- .../api/expr/v1alpha1/checked.pb.go | 2 +- .../googleapis/api/expr/v1alpha1/eval.pb.go | 2 +- .../api/expr/v1alpha1/explain.pb.go | 2 +- .../googleapis/api/expr/v1alpha1/syntax.pb.go | 2 +- .../googleapis/api/expr/v1alpha1/value.pb.go | 2 +- .../googleapis/api/httpbody/httpbody.pb.go | 4 +- .../googleapis/rpc/status/status.pb.go | 4 +- .../virtwrap/api/testdata/cpu_pinning.xml | 7 + .../api/testdata/domain_arm64.xml.tmpl | 78 ++++ .../api/testdata/domain_numa_topology.xml | 20 + .../api/testdata/domain_ppc64le.xml.tmpl | 78 ++++ .../api/testdata/domain_x86_64.xml.tmpl | 78 ++++ vendor/modules.txt | 53 ++- 94 files changed, 1192 insertions(+), 3028 deletions(-) delete mode 100644 vendor/github.com/antlr4-go/antlr/v4/mutex.go delete mode 100644 vendor/github.com/antlr4-go/antlr/v4/mutex_nomutex.go delete mode 100644 vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/stepaction_conversion.go delete mode 100644 vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/stepaction_types.go delete mode 100644 vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/stepaction_validation.go delete mode 100644 vendor/github.com/tektoncd/pipeline/pkg/client/clientset/versioned/typed/pipeline/v1beta1/fake/fake_stepaction.go delete mode 100644 vendor/github.com/tektoncd/pipeline/pkg/client/clientset/versioned/typed/pipeline/v1beta1/stepaction.go delete mode 100644 vendor/github.com/tektoncd/pipeline/pkg/client/informers/externalversions/pipeline/v1beta1/stepaction.go rename vendor/github.com/tektoncd/pipeline/pkg/client/injection/informers/pipeline/{v1beta1 => v1alpha1}/stepaction/fake/fake.go (93%) rename vendor/github.com/tektoncd/pipeline/pkg/client/injection/informers/pipeline/{v1beta1 => v1alpha1}/stepaction/stepaction.go (81%) delete mode 100644 vendor/github.com/tektoncd/pipeline/pkg/client/listers/pipeline/v1beta1/stepaction.go rename vendor/github.com/tektoncd/pipeline/{pkg/apis/pipeline/v1beta1/stepaction_defaults.go => test/diff/print.go} (51%) create mode 100644 vendor/github.com/tektoncd/pipeline/test/resolution.go delete mode 100644 vendor/golang.org/x/exp/slices/cmp.go rename vendor/golang.org/x/exp/slices/{zsortanyfunc.go => zsortfunc.go} (64%) create mode 100644 vendor/kubevirt.io/kubevirt/pkg/virt-launcher/virtwrap/api/testdata/cpu_pinning.xml create mode 100644 vendor/kubevirt.io/kubevirt/pkg/virt-launcher/virtwrap/api/testdata/domain_arm64.xml.tmpl create mode 100644 vendor/kubevirt.io/kubevirt/pkg/virt-launcher/virtwrap/api/testdata/domain_numa_topology.xml create mode 100644 vendor/kubevirt.io/kubevirt/pkg/virt-launcher/virtwrap/api/testdata/domain_ppc64le.xml.tmpl create mode 100644 vendor/kubevirt.io/kubevirt/pkg/virt-launcher/virtwrap/api/testdata/domain_x86_64.xml.tmpl diff --git a/vendor/github.com/antlr4-go/antlr/v4/antlrdoc.go b/vendor/github.com/antlr4-go/antlr/v4/antlrdoc.go index 48bd362bf..3bb4fd7c4 100644 --- a/vendor/github.com/antlr4-go/antlr/v4/antlrdoc.go +++ b/vendor/github.com/antlr4-go/antlr/v4/antlrdoc.go @@ -17,9 +17,9 @@ ANTLR4 that it is compatible with (I.E. uses the /v4 path). However, this was found to be problematic, as it meant that with the runtime embedded so far underneath the root of the repo, the `go get` and related commands could not properly resolve the location of the go runtime source code. This meant that the reference to the runtime in your `go.mod` file would refer to the correct source code, but would not -list the release tag such as @4.13.1 - this was confusing, to say the least. +list the release tag such as @4.12.0 - this was confusing, to say the least. -As of 4.13.0, the runtime is now available as a go module in its own repo, and can be imported as `github.com/antlr4-go/antlr` +As of 4.12.1, the runtime is now available as a go module in its own repo, and can be imported as `github.com/antlr4-go/antlr` (the go get command should also be used with this path). See the main documentation for the ANTLR4 project for more information, which is available at [ANTLR docs]. The documentation for using the Go runtime is available at [Go runtime docs]. @@ -49,7 +49,7 @@ Here is a general/recommended template for an ANTLR based recognizer in Go: . ├── parser │ ├── mygrammar.g4 - │ ├── antlr-4.13.1-complete.jar + │ ├── antlr-4.12.1-complete.jar │ ├── generate.go │ └── generate.sh ├── parsing - generated code goes here @@ -71,7 +71,7 @@ And the generate.sh file will look similar to this: #!/bin/sh - alias antlr4='java -Xmx500M -cp "./antlr4-4.13.1-complete.jar:$CLASSPATH" org.antlr.v4.Tool' + alias antlr4='java -Xmx500M -cp "./antlr4-4.12.1-complete.jar:$CLASSPATH" org.antlr.v4.Tool' antlr4 -Dlanguage=Go -no-visitor -package parsing *.g4 depending on whether you want visitors or listeners or any other ANTLR options. Not that another option here diff --git a/vendor/github.com/antlr4-go/antlr/v4/atn.go b/vendor/github.com/antlr4-go/antlr/v4/atn.go index e749ebd0c..cdeefed24 100644 --- a/vendor/github.com/antlr4-go/antlr/v4/atn.go +++ b/vendor/github.com/antlr4-go/antlr/v4/atn.go @@ -4,6 +4,8 @@ package antlr +import "sync" + // ATNInvalidAltNumber is used to represent an ALT number that has yet to be calculated or // which is invalid for a particular struct such as [*antlr.BaseRuleContext] var ATNInvalidAltNumber int @@ -54,9 +56,9 @@ type ATN struct { // states []ATNState - mu Mutex - stateMu RWMutex - edgeMu RWMutex + mu sync.Mutex + stateMu sync.RWMutex + edgeMu sync.RWMutex } // NewATN returns a new ATN struct representing the given grammarType and is used diff --git a/vendor/github.com/antlr4-go/antlr/v4/atn_config.go b/vendor/github.com/antlr4-go/antlr/v4/atn_config.go index 267308bb3..a83f25d34 100644 --- a/vendor/github.com/antlr4-go/antlr/v4/atn_config.go +++ b/vendor/github.com/antlr4-go/antlr/v4/atn_config.go @@ -73,6 +73,9 @@ func NewATNConfig1(c *ATNConfig, state ATNState, context *PredictionContext) *AT // NewATNConfig creates a new ATNConfig instance given an existing config, a state, a context and a semantic context, other 'constructors' // are just wrappers around this one. func NewATNConfig(c *ATNConfig, state ATNState, context *PredictionContext, semanticContext SemanticContext) *ATNConfig { + if semanticContext == nil { + panic("semanticContext cannot be nil") // TODO: Remove this - probably put here for some bug that is now fixed + } b := &ATNConfig{} b.InitATNConfig(c, state, c.GetAlt(), context, semanticContext) b.cType = parserConfig diff --git a/vendor/github.com/antlr4-go/antlr/v4/input_stream.go b/vendor/github.com/antlr4-go/antlr/v4/input_stream.go index ab4e96be5..b737fe85f 100644 --- a/vendor/github.com/antlr4-go/antlr/v4/input_stream.go +++ b/vendor/github.com/antlr4-go/antlr/v4/input_stream.go @@ -148,7 +148,7 @@ func (is *InputStream) GetTextFromInterval(i Interval) string { } func (*InputStream) GetSourceName() string { - return "Obtained from string" + return "" } // String returns the entire input stream as a string diff --git a/vendor/github.com/antlr4-go/antlr/v4/jcollect.go b/vendor/github.com/antlr4-go/antlr/v4/jcollect.go index 6d668f798..ceccd96d2 100644 --- a/vendor/github.com/antlr4-go/antlr/v4/jcollect.go +++ b/vendor/github.com/antlr4-go/antlr/v4/jcollect.go @@ -8,6 +8,7 @@ import ( "container/list" "runtime/debug" "sort" + "sync" ) // Collectable is an interface that a struct should implement if it is to be @@ -586,12 +587,12 @@ type VisitRecord struct { type VisitList struct { cache *list.List - lock RWMutex + lock sync.RWMutex } var visitListPool = VisitList{ cache: list.New(), - lock: RWMutex{}, + lock: sync.RWMutex{}, } // NewVisitRecord returns a new VisitRecord instance from the pool if available. diff --git a/vendor/github.com/antlr4-go/antlr/v4/lexer.go b/vendor/github.com/antlr4-go/antlr/v4/lexer.go index e5594b216..3c7896a91 100644 --- a/vendor/github.com/antlr4-go/antlr/v4/lexer.go +++ b/vendor/github.com/antlr4-go/antlr/v4/lexer.go @@ -207,7 +207,7 @@ func (b *BaseLexer) NextToken() Token { for { b.thetype = TokenInvalidType - ttype := b.safeMatch() // Defaults to LexerSkip + ttype := b.safeMatch() if b.input.LA(1) == TokenEOF { b.hitEOF = true diff --git a/vendor/github.com/antlr4-go/antlr/v4/ll1_analyzer.go b/vendor/github.com/antlr4-go/antlr/v4/ll1_analyzer.go index dfdff000b..4955ac876 100644 --- a/vendor/github.com/antlr4-go/antlr/v4/ll1_analyzer.go +++ b/vendor/github.com/antlr4-go/antlr/v4/ll1_analyzer.go @@ -40,7 +40,6 @@ func (la *LL1Analyzer) getDecisionLookahead(s ATNState) []*IntervalSet { for alt := 0; alt < count; alt++ { look[alt] = NewIntervalSet() - // TODO: This is one of the reasons that ATNConfigs are allocated and freed all the time - fix this tomorrow jim! lookBusy := NewJStore[*ATNConfig, Comparator[*ATNConfig]](aConfEqInst, ClosureBusyCollection, "LL1Analyzer.getDecisionLookahead for lookBusy") la.look1(s.GetTransitions()[alt].getTarget(), nil, BasePredictionContextEMPTY, look[alt], lookBusy, NewBitSet(), false, false) diff --git a/vendor/github.com/antlr4-go/antlr/v4/mutex.go b/vendor/github.com/antlr4-go/antlr/v4/mutex.go deleted file mode 100644 index 2b0cda474..000000000 --- a/vendor/github.com/antlr4-go/antlr/v4/mutex.go +++ /dev/null @@ -1,41 +0,0 @@ -//go:build !antlr.nomutex -// +build !antlr.nomutex - -package antlr - -import "sync" - -// Mutex is a simple mutex implementation which just delegates to sync.Mutex, it -// is used to provide a mutex implementation for the antlr package, which users -// can turn off with the build tag -tags antlr.nomutex -type Mutex struct { - mu sync.Mutex -} - -func (m *Mutex) Lock() { - m.mu.Lock() -} - -func (m *Mutex) Unlock() { - m.mu.Unlock() -} - -type RWMutex struct { - mu sync.RWMutex -} - -func (m *RWMutex) Lock() { - m.mu.Lock() -} - -func (m *RWMutex) Unlock() { - m.mu.Unlock() -} - -func (m *RWMutex) RLock() { - m.mu.RLock() -} - -func (m *RWMutex) RUnlock() { - m.mu.RUnlock() -} diff --git a/vendor/github.com/antlr4-go/antlr/v4/mutex_nomutex.go b/vendor/github.com/antlr4-go/antlr/v4/mutex_nomutex.go deleted file mode 100644 index 35ce4353e..000000000 --- a/vendor/github.com/antlr4-go/antlr/v4/mutex_nomutex.go +++ /dev/null @@ -1,32 +0,0 @@ -//go:build antlr.nomutex -// +build antlr.nomutex - -package antlr - -type Mutex struct{} - -func (m *Mutex) Lock() { - // No-op -} - -func (m *Mutex) Unlock() { - // No-op -} - -type RWMutex struct{} - -func (m *RWMutex) Lock() { - // No-op -} - -func (m *RWMutex) Unlock() { - // No-op -} - -func (m *RWMutex) RLock() { - // No-op -} - -func (m *RWMutex) RUnlock() { - // No-op -} diff --git a/vendor/github.com/antlr4-go/antlr/v4/parser_atn_simulator.go b/vendor/github.com/antlr4-go/antlr/v4/parser_atn_simulator.go index 724fa17a1..ae2869692 100644 --- a/vendor/github.com/antlr4-go/antlr/v4/parser_atn_simulator.go +++ b/vendor/github.com/antlr4-go/antlr/v4/parser_atn_simulator.go @@ -10,6 +10,8 @@ import ( "strings" ) +var () + // ClosureBusy is a store of ATNConfigs and is a tiny abstraction layer over // a standard JStore so that we can use Lazy instantiation of the JStore, mostly // to avoid polluting the stats module with a ton of JStore instances with nothing in them. @@ -881,7 +883,7 @@ func (p *ParserATNSimulator) getPredicatePredictions(ambigAlts *BitSet, altToPre // the ERROR state was reached, outerContext as the initial parser context from the paper // or the parser stack at the instant before prediction commences. // -// The func returns the value to return from [AdaptivePredict], or +// Teh func returns the value to return from [AdaptivePredict], or // [ATNInvalidAltNumber] if a suitable alternative was not // identified and [AdaptivePredict] should report an error instead. func (p *ParserATNSimulator) getSynValidOrSemInvalidAltThatFinishedDecisionEntryRule(configs *ATNConfigSet, outerContext ParserRuleContext) int { diff --git a/vendor/github.com/antlr4-go/antlr/v4/prediction_context.go b/vendor/github.com/antlr4-go/antlr/v4/prediction_context.go index a1d5186b8..c1b80cc1f 100644 --- a/vendor/github.com/antlr4-go/antlr/v4/prediction_context.go +++ b/vendor/github.com/antlr4-go/antlr/v4/prediction_context.go @@ -6,6 +6,7 @@ package antlr import ( "fmt" + "golang.org/x/exp/slices" "strconv" ) @@ -100,7 +101,7 @@ func NewArrayPredictionContext(parents []*PredictionContext, returnStates []int) hash = murmurUpdate(hash, returnState) } hash = murmurFinish(hash, len(parents)<<1) - + nec := &PredictionContext{} nec.cachedHash = hash nec.pcType = PredictionContextArray @@ -114,9 +115,6 @@ func (p *PredictionContext) Hash() int { } func (p *PredictionContext) Equals(other Collectable[*PredictionContext]) bool { - if p == other { - return true - } switch p.pcType { case PredictionContextEmpty: otherP := other.(*PredictionContext) @@ -140,11 +138,13 @@ func (p *PredictionContext) ArrayEquals(o Collectable[*PredictionContext]) bool if p.cachedHash != other.Hash() { return false // can't be same if hash is different } - + // Must compare the actual array elements and not just the array address // - return intSlicesEqual(p.returnStates, other.returnStates) && - pcSliceEqual(p.parents, other.parents) + return slices.Equal(p.returnStates, other.returnStates) && + slices.EqualFunc(p.parents, other.parents, func(x, y *PredictionContext) bool { + return x.Equals(y) + }) } func (p *PredictionContext) SingletonEquals(other Collectable[*PredictionContext]) bool { @@ -152,23 +152,23 @@ func (p *PredictionContext) SingletonEquals(other Collectable[*PredictionContext return false } otherP := other.(*PredictionContext) - if otherP == nil || otherP.pcType != PredictionContextSingleton { + if otherP == nil { return false } - + if p.cachedHash != otherP.Hash() { return false // Can't be same if hash is different } - + if p.returnState != otherP.getReturnState(0) { return false } - + // Both parents must be nil if one is if p.parentCtx == nil { return otherP.parentCtx == nil } - + return p.parentCtx.Equals(otherP.parentCtx) } @@ -225,27 +225,27 @@ func (p *PredictionContext) String() string { return "$" case PredictionContextSingleton: var up string - + if p.parentCtx == nil { up = "" } else { up = p.parentCtx.String() } - + if len(up) == 0 { if p.returnState == BasePredictionContextEmptyReturnState { return "$" } - + return strconv.Itoa(p.returnState) } - + return strconv.Itoa(p.returnState) + " " + up case PredictionContextArray: if p.isEmpty() { return "[]" } - + s := "[" for i := 0; i < len(p.returnStates); i++ { if i > 0 { @@ -263,7 +263,7 @@ func (p *PredictionContext) String() string { } } return s + "]" - + default: return "unknown" } @@ -309,18 +309,18 @@ func predictionContextFromRuleContext(a *ATN, outerContext RuleContext) *Predict parent := predictionContextFromRuleContext(a, outerContext.GetParent().(RuleContext)) state := a.states[outerContext.GetInvokingState()] transition := state.GetTransitions()[0] - + return SingletonBasePredictionContextCreate(parent, transition.(*RuleTransition).followState.GetStateNumber()) } func merge(a, b *PredictionContext, rootIsWildcard bool, mergeCache *JPCMap) *PredictionContext { - + // Share same graph if both same // if a == b || a.Equals(b) { return a } - + if a.pcType == PredictionContextSingleton && b.pcType == PredictionContextSingleton { return mergeSingletons(a, b, rootIsWildcard, mergeCache) } @@ -334,7 +334,7 @@ func merge(a, b *PredictionContext, rootIsWildcard bool, mergeCache *JPCMap) *Pr return b } } - + // Convert either Singleton or Empty to arrays, so that we can merge them // ara := convertToArray(a) @@ -395,7 +395,7 @@ func mergeSingletons(a, b *PredictionContext, rootIsWildcard bool, mergeCache *J return previous } } - + rootMerge := mergeRoot(a, b, rootIsWildcard) if rootMerge != nil { if mergeCache != nil { @@ -564,7 +564,7 @@ func mergeArrays(a, b *PredictionContext, rootIsWildcard bool, mergeCache *JPCMa i := 0 // walks a j := 0 // walks b k := 0 // walks target M array - + mergedReturnStates := make([]int, len(a.returnStates)+len(b.returnStates)) mergedParents := make([]*PredictionContext, len(a.returnStates)+len(b.returnStates)) // walk and merge to yield mergedParents, mergedReturnStates @@ -626,9 +626,9 @@ func mergeArrays(a, b *PredictionContext, rootIsWildcard bool, mergeCache *JPCMa mergedParents = mergedParents[0:k] mergedReturnStates = mergedReturnStates[0:k] } - + M := NewArrayPredictionContext(mergedParents, mergedReturnStates) - + // if we created same array as a or b, return that instead // TODO: JI track whether this is possible above during merge sort for speed and possibly avoid an allocation if M.Equals(a) { @@ -650,7 +650,7 @@ func mergeArrays(a, b *PredictionContext, rootIsWildcard bool, mergeCache *JPCMa return b } combineCommonParents(&mergedParents) - + if mergeCache != nil { mergeCache.Put(a, b, M) } @@ -666,7 +666,7 @@ func mergeArrays(a, b *PredictionContext, rootIsWildcard bool, mergeCache *JPCMa //goland:noinspection GoUnusedFunction func combineCommonParents(parents *[]*PredictionContext) { uniqueParents := NewJStore[*PredictionContext, Comparator[*PredictionContext]](pContextEqInst, PredictionContextCollection, "combineCommonParents for PredictionContext") - + for p := 0; p < len(*parents); p++ { parent := (*parents)[p] _, _ = uniqueParents.Put(parent) @@ -685,7 +685,7 @@ func getCachedBasePredictionContext(context *PredictionContext, contextCache *Pr if present { return existing } - + existing, present = contextCache.Get(context) if present { visited.Put(context, existing) @@ -722,6 +722,6 @@ func getCachedBasePredictionContext(context *PredictionContext, contextCache *Pr contextCache.add(updated) visited.Put(updated, updated) visited.Put(context, updated) - + return updated } diff --git a/vendor/github.com/antlr4-go/antlr/v4/recognizer.go b/vendor/github.com/antlr4-go/antlr/v4/recognizer.go index dcb8548cd..2e0b504fb 100644 --- a/vendor/github.com/antlr4-go/antlr/v4/recognizer.go +++ b/vendor/github.com/antlr4-go/antlr/v4/recognizer.go @@ -56,7 +56,7 @@ var tokenTypeMapCache = make(map[string]int) var ruleIndexMapCache = make(map[string]int) func (b *BaseRecognizer) checkVersion(toolVersion string) { - runtimeVersion := "4.13.1" + runtimeVersion := "4.12.0" if runtimeVersion != toolVersion { fmt.Println("ANTLR runtime and generated code versions disagree: " + runtimeVersion + "!=" + toolVersion) } diff --git a/vendor/github.com/antlr4-go/antlr/v4/statistics.go b/vendor/github.com/antlr4-go/antlr/v4/statistics.go index 8cb5f3ed6..70c0673a0 100644 --- a/vendor/github.com/antlr4-go/antlr/v4/statistics.go +++ b/vendor/github.com/antlr4-go/antlr/v4/statistics.go @@ -9,6 +9,7 @@ import ( "path/filepath" "sort" "strconv" + "sync" ) // This file allows the user to collect statistics about the runtime of the ANTLR runtime. It is not enabled by default @@ -29,7 +30,7 @@ type goRunStats struct { // within this package. // jStats []*JStatRec - jStatsLock RWMutex + jStatsLock sync.RWMutex topN int topNByMax []*JStatRec topNByUsed []*JStatRec diff --git a/vendor/github.com/antlr4-go/antlr/v4/token.go b/vendor/github.com/antlr4-go/antlr/v4/token.go index f5bc34229..9670efb82 100644 --- a/vendor/github.com/antlr4-go/antlr/v4/token.go +++ b/vendor/github.com/antlr4-go/antlr/v4/token.go @@ -104,25 +104,6 @@ func (b *BaseToken) GetSource() *TokenSourceCharStreamPair { return b.source } -func (b *BaseToken) GetText() string { - if b.text != "" { - return b.text - } - input := b.GetInputStream() - if input == nil { - return "" - } - n := input.Size() - if b.GetStart() < n && b.GetStop() < n { - return input.GetTextFromInterval(NewInterval(b.GetStart(), b.GetStop())) - } - return "" -} - -func (b *BaseToken) SetText(text string) { - b.text = text -} - func (b *BaseToken) GetTokenIndex() int { return b.tokenIndex } @@ -139,28 +120,6 @@ func (b *BaseToken) GetInputStream() CharStream { return b.source.charStream } -func (b *BaseToken) String() string { - txt := b.GetText() - if txt != "" { - txt = strings.Replace(txt, "\n", "\\n", -1) - txt = strings.Replace(txt, "\r", "\\r", -1) - txt = strings.Replace(txt, "\t", "\\t", -1) - } else { - txt = "" - } - - var ch string - if b.GetChannel() > 0 { - ch = ",channel=" + strconv.Itoa(b.GetChannel()) - } else { - ch = "" - } - - return "[@" + strconv.Itoa(b.GetTokenIndex()) + "," + strconv.Itoa(b.GetStart()) + ":" + strconv.Itoa(b.GetStop()) + "='" + - txt + "',<" + strconv.Itoa(b.GetTokenType()) + ">" + - ch + "," + strconv.Itoa(b.GetLine()) + ":" + strconv.Itoa(b.GetColumn()) + "]" -} - type CommonToken struct { BaseToken } @@ -211,3 +170,44 @@ func (c *CommonToken) clone() *CommonToken { t.text = c.GetText() return t } + +func (c *CommonToken) GetText() string { + if c.text != "" { + return c.text + } + input := c.GetInputStream() + if input == nil { + return "" + } + n := input.Size() + if c.start < n && c.stop < n { + return input.GetTextFromInterval(NewInterval(c.start, c.stop)) + } + return "" +} + +func (c *CommonToken) SetText(text string) { + c.text = text +} + +func (c *CommonToken) String() string { + txt := c.GetText() + if txt != "" { + txt = strings.Replace(txt, "\n", "\\n", -1) + txt = strings.Replace(txt, "\r", "\\r", -1) + txt = strings.Replace(txt, "\t", "\\t", -1) + } else { + txt = "" + } + + var ch string + if c.channel > 0 { + ch = ",channel=" + strconv.Itoa(c.channel) + } else { + ch = "" + } + + return "[@" + strconv.Itoa(c.tokenIndex) + "," + strconv.Itoa(c.start) + ":" + strconv.Itoa(c.stop) + "='" + + txt + "',<" + strconv.Itoa(c.tokenType) + ">" + + ch + "," + strconv.Itoa(c.line) + ":" + strconv.Itoa(c.column) + "]" +} diff --git a/vendor/github.com/antlr4-go/antlr/v4/utils.go b/vendor/github.com/antlr4-go/antlr/v4/utils.go index 36a37f247..733d7df9d 100644 --- a/vendor/github.com/antlr4-go/antlr/v4/utils.go +++ b/vendor/github.com/antlr4-go/antlr/v4/utils.go @@ -326,56 +326,3 @@ func isDirectory(dir string) (bool, error) { } return fileInfo.IsDir(), err } - -// intSlicesEqual returns true if the two slices of ints are equal, and is a little -// faster than slices.Equal. -func intSlicesEqual(s1, s2 []int) bool { - if s1 == nil && s2 == nil { - return true - } - if s1 == nil || s2 == nil { - return false - } - if len(s1) == 0 && len(s2) == 0 { - return true - } - - if len(s1) == 0 || len(s2) == 0 || len(s1) != len(s2) { - return false - } - // If the slices are using the same memory, then they are the same slice - if &s1[0] == &s2[0] { - return true - } - for i, v := range s1 { - if v != s2[i] { - return false - } - } - return true -} - -func pcSliceEqual(s1, s2 []*PredictionContext) bool { - if s1 == nil && s2 == nil { - return true - } - if s1 == nil || s2 == nil { - return false - } - if len(s1) == 0 && len(s2) == 0 { - return true - } - if len(s1) == 0 || len(s2) == 0 || len(s1) != len(s2) { - return false - } - // If the slices are using the same memory, then they are the same slice - if &s1[0] == &s2[0] { - return true - } - for i, v := range s1 { - if !v.Equals(s2[i]) { - return false - } - } - return true -} diff --git a/vendor/github.com/emicklei/go-restful/v3/CHANGES.md b/vendor/github.com/emicklei/go-restful/v3/CHANGES.md index 92b78048e..9e790390b 100644 --- a/vendor/github.com/emicklei/go-restful/v3/CHANGES.md +++ b/vendor/github.com/emicklei/go-restful/v3/CHANGES.md @@ -1,24 +1,18 @@ # Change history of go-restful -## [v3.12.1] - 2024-05-28 - -- fix misroute when dealing multiple webservice with regex (#549) (thanks Haitao Chen) - ## [v3.12.0] - 2024-03-11 - - add Flush method #529 (#538) - fix: Improper handling of empty POST requests (#543) ## [v3.11.3] - 2024-01-09 - - better not have 2 tags on one commit ## [v3.11.1, v3.11.2] - 2024-01-09 - fix by restoring custom JSON handler functions (Mike Beaumont #540) -## [v3.12.0] - 2023-08-19 +## [v3.11.0] - 2023-08-19 - restored behavior as <= v3.9.0 with option to change path strategy using TrimRightSlashEnabled. diff --git a/vendor/github.com/emicklei/go-restful/v3/curly.go b/vendor/github.com/emicklei/go-restful/v3/curly.go index 6fd2bcd5a..ba1fc5d5f 100644 --- a/vendor/github.com/emicklei/go-restful/v3/curly.go +++ b/vendor/github.com/emicklei/go-restful/v3/curly.go @@ -46,10 +46,10 @@ func (c CurlyRouter) SelectRoute( // selectRoutes return a collection of Route from a WebService that matches the path tokens from the request. func (c CurlyRouter) selectRoutes(ws *WebService, requestTokens []string) sortableCurlyRoutes { candidates := make(sortableCurlyRoutes, 0, 8) - for _, eachRoute := range ws.routes { - matches, paramCount, staticCount := c.matchesRouteByPathTokens(eachRoute.pathParts, requestTokens, eachRoute.hasCustomVerb) + for _, each := range ws.routes { + matches, paramCount, staticCount := c.matchesRouteByPathTokens(each.pathParts, requestTokens, each.hasCustomVerb) if matches { - candidates.add(curlyRoute{eachRoute, paramCount, staticCount}) // TODO make sure Routes() return pointers? + candidates.add(curlyRoute{each, paramCount, staticCount}) // TODO make sure Routes() return pointers? } } sort.Sort(candidates) @@ -72,7 +72,7 @@ func (c CurlyRouter) matchesRouteByPathTokens(routeTokens, requestTokens []strin return false, 0, 0 } requestToken := requestTokens[i] - if routeHasCustomVerb && hasCustomVerb(routeToken) { + if routeHasCustomVerb && hasCustomVerb(routeToken){ if !isMatchCustomVerb(routeToken, requestToken) { return false, 0, 0 } @@ -129,52 +129,44 @@ func (c CurlyRouter) detectRoute(candidateRoutes sortableCurlyRoutes, httpReques // detectWebService returns the best matching webService given the list of path tokens. // see also computeWebserviceScore func (c CurlyRouter) detectWebService(requestTokens []string, webServices []*WebService) *WebService { - var bestWs *WebService + var best *WebService score := -1 - for _, eachWS := range webServices { - matches, eachScore := c.computeWebserviceScore(requestTokens, eachWS.pathExpr.tokens) + for _, each := range webServices { + matches, eachScore := c.computeWebserviceScore(requestTokens, each.pathExpr.tokens) if matches && (eachScore > score) { - bestWs = eachWS + best = each score = eachScore } } - return bestWs + return best } // computeWebserviceScore returns whether tokens match and // the weighted score of the longest matching consecutive tokens from the beginning. -func (c CurlyRouter) computeWebserviceScore(requestTokens []string, routeTokens []string) (bool, int) { - if len(routeTokens) > len(requestTokens) { +func (c CurlyRouter) computeWebserviceScore(requestTokens []string, tokens []string) (bool, int) { + if len(tokens) > len(requestTokens) { return false, 0 } score := 0 - for i := 0; i < len(routeTokens); i++ { - eachRequestToken := requestTokens[i] - eachRouteToken := routeTokens[i] - if len(eachRequestToken) == 0 && len(eachRouteToken) == 0 { + for i := 0; i < len(tokens); i++ { + each := requestTokens[i] + other := tokens[i] + if len(each) == 0 && len(other) == 0 { score++ continue } - if len(eachRouteToken) > 0 && strings.HasPrefix(eachRouteToken, "{") { + if len(other) > 0 && strings.HasPrefix(other, "{") { // no empty match - if len(eachRequestToken) == 0 { + if len(each) == 0 { return false, score } - score++ - - if colon := strings.Index(eachRouteToken, ":"); colon != -1 { - // match by regex - matchesToken, _ := c.regularMatchesPathToken(eachRouteToken, colon, eachRequestToken) - if matchesToken { - score++ // extra score for regex match - } - } + score += 1 } else { // not a parameter - if eachRequestToken != eachRouteToken { + if each != other { return false, score } - score += (len(routeTokens) - i) * 10 //fuzzy + score += (len(tokens) - i) * 10 //fuzzy } } return true, score diff --git a/vendor/github.com/go-logr/logr/README.md b/vendor/github.com/go-logr/logr/README.md index 7c7f0c69c..8969526a6 100644 --- a/vendor/github.com/go-logr/logr/README.md +++ b/vendor/github.com/go-logr/logr/README.md @@ -1,7 +1,6 @@ # A minimal logging API for Go [![Go Reference](https://pkg.go.dev/badge/github.com/go-logr/logr.svg)](https://pkg.go.dev/github.com/go-logr/logr) -[![Go Report Card](https://goreportcard.com/badge/github.com/go-logr/logr)](https://goreportcard.com/report/github.com/go-logr/logr) [![OpenSSF Scorecard](https://api.securityscorecards.dev/projects/github.com/go-logr/logr/badge)](https://securityscorecards.dev/viewer/?platform=github.com&org=go-logr&repo=logr) logr offers an(other) opinion on how Go programs and libraries can do logging diff --git a/vendor/github.com/go-logr/logr/funcr/funcr.go b/vendor/github.com/go-logr/logr/funcr/funcr.go index 30568e768..fb2f866f4 100644 --- a/vendor/github.com/go-logr/logr/funcr/funcr.go +++ b/vendor/github.com/go-logr/logr/funcr/funcr.go @@ -236,14 +236,15 @@ func newFormatter(opts Options, outfmt outputFormat) Formatter { // implementation. It should be constructed with NewFormatter. Some of // its methods directly implement logr.LogSink. type Formatter struct { - outputFormat outputFormat - prefix string - values []any - valuesStr string - depth int - opts *Options - groupName string // for slog groups - groups []groupDef + outputFormat outputFormat + prefix string + values []any + valuesStr string + parentValuesStr string + depth int + opts *Options + group string // for slog groups + groupDepth int } // outputFormat indicates which outputFormat to use. @@ -256,13 +257,6 @@ const ( outputJSON ) -// groupDef represents a saved group. The values may be empty, but we don't -// know if we need to render the group until the final record is rendered. -type groupDef struct { - name string - values string -} - // PseudoStruct is a list of key-value pairs that gets logged as a struct. type PseudoStruct []any @@ -270,102 +264,76 @@ type PseudoStruct []any func (f Formatter) render(builtins, args []any) string { // Empirically bytes.Buffer is faster than strings.Builder for this. buf := bytes.NewBuffer(make([]byte, 0, 1024)) - if f.outputFormat == outputJSON { - buf.WriteByte('{') // for the whole record + buf.WriteByte('{') // for the whole line } - // Render builtins vals := builtins if hook := f.opts.RenderBuiltinsHook; hook != nil { vals = hook(f.sanitize(vals)) } - f.flatten(buf, vals, false) // keys are ours, no need to escape + f.flatten(buf, vals, false, false) // keys are ours, no need to escape continuing := len(builtins) > 0 - // Turn the inner-most group into a string - argsStr := func() string { - buf := bytes.NewBuffer(make([]byte, 0, 1024)) - - vals = args - if hook := f.opts.RenderArgsHook; hook != nil { - vals = hook(f.sanitize(vals)) + if f.parentValuesStr != "" { + if continuing { + buf.WriteByte(f.comma()) } - f.flatten(buf, vals, true) // escape user-provided keys - - return buf.String() - }() + buf.WriteString(f.parentValuesStr) + continuing = true + } - // Render the stack of groups from the inside out. - bodyStr := f.renderGroup(f.groupName, f.valuesStr, argsStr) - for i := len(f.groups) - 1; i >= 0; i-- { - grp := &f.groups[i] - if grp.values == "" && bodyStr == "" { - // no contents, so we must elide the whole group - continue + groupDepth := f.groupDepth + if f.group != "" { + if f.valuesStr != "" || len(args) != 0 { + if continuing { + buf.WriteByte(f.comma()) + } + buf.WriteString(f.quoted(f.group, true)) // escape user-provided keys + buf.WriteByte(f.colon()) + buf.WriteByte('{') // for the group + continuing = false + } else { + // The group was empty + groupDepth-- } - bodyStr = f.renderGroup(grp.name, grp.values, bodyStr) } - if bodyStr != "" { + if f.valuesStr != "" { if continuing { buf.WriteByte(f.comma()) } - buf.WriteString(bodyStr) - } - - if f.outputFormat == outputJSON { - buf.WriteByte('}') // for the whole record - } - - return buf.String() -} - -// renderGroup returns a string representation of the named group with rendered -// values and args. If the name is empty, this will return the values and args, -// joined. If the name is not empty, this will return a single key-value pair, -// where the value is a grouping of the values and args. If the values and -// args are both empty, this will return an empty string, even if the name was -// specified. -func (f Formatter) renderGroup(name string, values string, args string) string { - buf := bytes.NewBuffer(make([]byte, 0, 1024)) - - needClosingBrace := false - if name != "" && (values != "" || args != "") { - buf.WriteString(f.quoted(name, true)) // escape user-provided keys - buf.WriteByte(f.colon()) - buf.WriteByte('{') - needClosingBrace = true + buf.WriteString(f.valuesStr) + continuing = true } - continuing := false - if values != "" { - buf.WriteString(values) - continuing = true + vals = args + if hook := f.opts.RenderArgsHook; hook != nil { + vals = hook(f.sanitize(vals)) } + f.flatten(buf, vals, continuing, true) // escape user-provided keys - if args != "" { - if continuing { - buf.WriteByte(f.comma()) - } - buf.WriteString(args) + for i := 0; i < groupDepth; i++ { + buf.WriteByte('}') // for the groups } - if needClosingBrace { - buf.WriteByte('}') + if f.outputFormat == outputJSON { + buf.WriteByte('}') // for the whole line } return buf.String() } -// flatten renders a list of key-value pairs into a buffer. If escapeKeys is -// true, the keys are assumed to have non-JSON-compatible characters in them -// and must be evaluated for escapes. +// flatten renders a list of key-value pairs into a buffer. If continuing is +// true, it assumes that the buffer has previous values and will emit a +// separator (which depends on the output format) before the first pair it +// writes. If escapeKeys is true, the keys are assumed to have +// non-JSON-compatible characters in them and must be evaluated for escapes. // // This function returns a potentially modified version of kvList, which // ensures that there is a value for every key (adding a value if needed) and // that each key is a string (substituting a key if needed). -func (f Formatter) flatten(buf *bytes.Buffer, kvList []any, escapeKeys bool) []any { +func (f Formatter) flatten(buf *bytes.Buffer, kvList []any, continuing bool, escapeKeys bool) []any { // This logic overlaps with sanitize() but saves one type-cast per key, // which can be measurable. if len(kvList)%2 != 0 { @@ -386,7 +354,7 @@ func (f Formatter) flatten(buf *bytes.Buffer, kvList []any, escapeKeys bool) []a } v := kvList[i+1] - if i > 0 { + if i > 0 || continuing { if f.outputFormat == outputJSON { buf.WriteByte(f.comma()) } else { @@ -798,17 +766,46 @@ func (f Formatter) sanitize(kvList []any) []any { // startGroup opens a new group scope (basically a sub-struct), which locks all // the current saved values and starts them anew. This is needed to satisfy // slog. -func (f *Formatter) startGroup(name string) { +func (f *Formatter) startGroup(group string) { // Unnamed groups are just inlined. - if name == "" { + if group == "" { return } - n := len(f.groups) - f.groups = append(f.groups[:n:n], groupDef{f.groupName, f.valuesStr}) + // Any saved values can no longer be changed. + buf := bytes.NewBuffer(make([]byte, 0, 1024)) + continuing := false + + if f.parentValuesStr != "" { + buf.WriteString(f.parentValuesStr) + continuing = true + } + + if f.group != "" && f.valuesStr != "" { + if continuing { + buf.WriteByte(f.comma()) + } + buf.WriteString(f.quoted(f.group, true)) // escape user-provided keys + buf.WriteByte(f.colon()) + buf.WriteByte('{') // for the group + continuing = false + } + + if f.valuesStr != "" { + if continuing { + buf.WriteByte(f.comma()) + } + buf.WriteString(f.valuesStr) + } + + // NOTE: We don't close the scope here - that's done later, when a log line + // is actually rendered (because we have N scopes to close). + + f.parentValuesStr = buf.String() // Start collecting new values. - f.groupName = name + f.group = group + f.groupDepth++ f.valuesStr = "" f.values = nil } @@ -903,7 +900,7 @@ func (f *Formatter) AddValues(kvList []any) { // Pre-render values, so we don't have to do it on each Info/Error call. buf := bytes.NewBuffer(make([]byte, 0, 1024)) - f.flatten(buf, vals, true) // escape user-provided keys + f.flatten(buf, vals, false, true) // escape user-provided keys f.valuesStr = buf.String() } diff --git a/vendor/github.com/grpc-ecosystem/grpc-gateway/v2/runtime/context.go b/vendor/github.com/grpc-ecosystem/grpc-gateway/v2/runtime/context.go index 5dd4e4478..31553e784 100644 --- a/vendor/github.com/grpc-ecosystem/grpc-gateway/v2/runtime/context.go +++ b/vendor/github.com/grpc-ecosystem/grpc-gateway/v2/runtime/context.go @@ -148,12 +148,6 @@ func annotateContext(ctx context.Context, mux *ServeMux, req *http.Request, rpcM var pairs []string for key, vals := range req.Header { key = textproto.CanonicalMIMEHeaderKey(key) - switch key { - case xForwardedFor, xForwardedHost: - // Handled separately below - continue - } - for _, val := range vals { // For backwards-compatibility, pass through 'authorization' header with no prefix. if key == "Authorization" { @@ -187,17 +181,18 @@ func annotateContext(ctx context.Context, mux *ServeMux, req *http.Request, rpcM pairs = append(pairs, strings.ToLower(xForwardedHost), req.Host) } - xff := req.Header.Values(xForwardedFor) if addr := req.RemoteAddr; addr != "" { if remoteIP, _, err := net.SplitHostPort(addr); err == nil { - xff = append(xff, remoteIP) + if fwd := req.Header.Get(xForwardedFor); fwd == "" { + pairs = append(pairs, strings.ToLower(xForwardedFor), remoteIP) + } else { + pairs = append(pairs, strings.ToLower(xForwardedFor), fmt.Sprintf("%s, %s", fwd, remoteIP)) + } } } - if len(xff) > 0 { - pairs = append(pairs, strings.ToLower(xForwardedFor), strings.Join(xff, ", ")) - } if timeout != 0 { + //nolint:govet // The context outlives this function ctx, _ = context.WithTimeout(ctx, timeout) } if len(pairs) == 0 { diff --git a/vendor/github.com/grpc-ecosystem/grpc-gateway/v2/runtime/errors.go b/vendor/github.com/grpc-ecosystem/grpc-gateway/v2/runtime/errors.go index 568299869..230cac7b8 100644 --- a/vendor/github.com/grpc-ecosystem/grpc-gateway/v2/runtime/errors.go +++ b/vendor/github.com/grpc-ecosystem/grpc-gateway/v2/runtime/errors.go @@ -71,7 +71,7 @@ func HTTPStatusFromCode(code codes.Code) int { case codes.DataLoss: return http.StatusInternalServerError default: - grpclog.Warningf("Unknown gRPC error code: %v", code) + grpclog.Infof("Unknown gRPC error code: %v", code) return http.StatusInternalServerError } } @@ -114,17 +114,17 @@ func DefaultHTTPErrorHandler(ctx context.Context, mux *ServeMux, marshaler Marsh buf, merr := marshaler.Marshal(pb) if merr != nil { - grpclog.Errorf("Failed to marshal error message %q: %v", s, merr) + grpclog.Infof("Failed to marshal error message %q: %v", s, merr) w.WriteHeader(http.StatusInternalServerError) if _, err := io.WriteString(w, fallback); err != nil { - grpclog.Errorf("Failed to write response: %v", err) + grpclog.Infof("Failed to write response: %v", err) } return } md, ok := ServerMetadataFromContext(ctx) if !ok { - grpclog.Error("Failed to extract ServerMetadata from context") + grpclog.Infof("Failed to extract ServerMetadata from context") } handleForwardResponseServerMetadata(w, mux, md) @@ -148,7 +148,7 @@ func DefaultHTTPErrorHandler(ctx context.Context, mux *ServeMux, marshaler Marsh w.WriteHeader(st) if _, err := w.Write(buf); err != nil { - grpclog.Errorf("Failed to write response: %v", err) + grpclog.Infof("Failed to write response: %v", err) } if doForwardTrailers { diff --git a/vendor/github.com/grpc-ecosystem/grpc-gateway/v2/runtime/handler.go b/vendor/github.com/grpc-ecosystem/grpc-gateway/v2/runtime/handler.go index de1eef1f4..5e14cf8b0 100644 --- a/vendor/github.com/grpc-ecosystem/grpc-gateway/v2/runtime/handler.go +++ b/vendor/github.com/grpc-ecosystem/grpc-gateway/v2/runtime/handler.go @@ -6,7 +6,6 @@ import ( "io" "net/http" "net/textproto" - "strconv" "strings" "google.golang.org/genproto/googleapis/api/httpbody" @@ -18,10 +17,16 @@ import ( // ForwardResponseStream forwards the stream from gRPC server to REST client. func ForwardResponseStream(ctx context.Context, mux *ServeMux, marshaler Marshaler, w http.ResponseWriter, req *http.Request, recv func() (proto.Message, error), opts ...func(context.Context, http.ResponseWriter, proto.Message) error) { - rc := http.NewResponseController(w) + f, ok := w.(http.Flusher) + if !ok { + grpclog.Infof("Flush not supported in %T", w) + http.Error(w, "unexpected type of web server", http.StatusInternalServerError) + return + } + md, ok := ServerMetadataFromContext(ctx) if !ok { - grpclog.Error("Failed to extract ServerMetadata from context") + grpclog.Infof("Failed to extract ServerMetadata from context") http.Error(w, "unexpected error", http.StatusInternalServerError) return } @@ -76,29 +81,20 @@ func ForwardResponseStream(ctx context.Context, mux *ServeMux, marshaler Marshal } if err != nil { - grpclog.Errorf("Failed to marshal response chunk: %v", err) + grpclog.Infof("Failed to marshal response chunk: %v", err) handleForwardResponseStreamError(ctx, wroteHeader, marshaler, w, req, mux, err, delimiter) return } if _, err := w.Write(buf); err != nil { - grpclog.Errorf("Failed to send response chunk: %v", err) + grpclog.Infof("Failed to send response chunk: %v", err) return } wroteHeader = true if _, err := w.Write(delimiter); err != nil { - grpclog.Errorf("Failed to send delimiter chunk: %v", err) - return - } - err = rc.Flush() - if err != nil { - if errors.Is(err, http.ErrNotSupported) { - grpclog.Errorf("Flush not supported in %T", w) - http.Error(w, "unexpected type of web server", http.StatusInternalServerError) - return - } - grpclog.Errorf("Failed to flush response to client: %v", err) + grpclog.Infof("Failed to send delimiter chunk: %v", err) return } + f.Flush() } } @@ -140,7 +136,7 @@ type responseBody interface { func ForwardResponseMessage(ctx context.Context, mux *ServeMux, marshaler Marshaler, w http.ResponseWriter, req *http.Request, resp proto.Message, opts ...func(context.Context, http.ResponseWriter, proto.Message) error) { md, ok := ServerMetadataFromContext(ctx) if !ok { - grpclog.Error("Failed to extract ServerMetadata from context") + grpclog.Infof("Failed to extract ServerMetadata from context") } handleForwardResponseServerMetadata(w, mux, md) @@ -172,17 +168,13 @@ func ForwardResponseMessage(ctx context.Context, mux *ServeMux, marshaler Marsha buf, err = marshaler.Marshal(resp) } if err != nil { - grpclog.Errorf("Marshal error: %v", err) + grpclog.Infof("Marshal error: %v", err) HTTPError(ctx, mux, marshaler, w, req, err) return } - if !doForwardTrailers { - w.Header().Set("Content-Length", strconv.Itoa(len(buf))) - } - if _, err = w.Write(buf); err != nil { - grpclog.Errorf("Failed to write response: %v", err) + grpclog.Infof("Failed to write response: %v", err) } if doForwardTrailers { @@ -201,7 +193,7 @@ func handleForwardResponseOptions(ctx context.Context, w http.ResponseWriter, re } for _, opt := range opts { if err := opt(ctx, w, resp); err != nil { - grpclog.Errorf("Error handling ForwardResponseOptions: %v", err) + grpclog.Infof("Error handling ForwardResponseOptions: %v", err) return err } } @@ -217,15 +209,15 @@ func handleForwardResponseStreamError(ctx context.Context, wroteHeader bool, mar } buf, err := marshaler.Marshal(msg) if err != nil { - grpclog.Errorf("Failed to marshal an error: %v", err) + grpclog.Infof("Failed to marshal an error: %v", err) return } if _, err := w.Write(buf); err != nil { - grpclog.Errorf("Failed to notify error to client: %v", err) + grpclog.Infof("Failed to notify error to client: %v", err) return } if _, err := w.Write(delimiter); err != nil { - grpclog.Errorf("Failed to send delimiter chunk: %v", err) + grpclog.Infof("Failed to send delimiter chunk: %v", err) return } } diff --git a/vendor/github.com/grpc-ecosystem/grpc-gateway/v2/runtime/marshal_json.go b/vendor/github.com/grpc-ecosystem/grpc-gateway/v2/runtime/marshal_json.go index fe52081ab..d6aa82578 100644 --- a/vendor/github.com/grpc-ecosystem/grpc-gateway/v2/runtime/marshal_json.go +++ b/vendor/github.com/grpc-ecosystem/grpc-gateway/v2/runtime/marshal_json.go @@ -24,11 +24,6 @@ func (j *JSONBuiltin) Marshal(v interface{}) ([]byte, error) { return json.Marshal(v) } -// MarshalIndent is like Marshal but applies Indent to format the output -func (j *JSONBuiltin) MarshalIndent(v interface{}, prefix, indent string) ([]byte, error) { - return json.MarshalIndent(v, prefix, indent) -} - // Unmarshal unmarshals JSON data into "v". func (j *JSONBuiltin) Unmarshal(data []byte, v interface{}) error { return json.Unmarshal(data, v) diff --git a/vendor/github.com/grpc-ecosystem/grpc-gateway/v2/runtime/marshal_jsonpb.go b/vendor/github.com/grpc-ecosystem/grpc-gateway/v2/runtime/marshal_jsonpb.go index 8376d1e0e..51b8247da 100644 --- a/vendor/github.com/grpc-ecosystem/grpc-gateway/v2/runtime/marshal_jsonpb.go +++ b/vendor/github.com/grpc-ecosystem/grpc-gateway/v2/runtime/marshal_jsonpb.go @@ -30,6 +30,10 @@ func (*JSONPb) ContentType(_ interface{}) string { // Marshal marshals "v" into JSON. func (j *JSONPb) Marshal(v interface{}) ([]byte, error) { + if _, ok := v.(proto.Message); !ok { + return j.marshalNonProtoField(v) + } + var buf bytes.Buffer if err := j.marshalTo(&buf, v); err != nil { return nil, err @@ -44,17 +48,9 @@ func (j *JSONPb) marshalTo(w io.Writer, v interface{}) error { if err != nil { return err } - if j.Indent != "" { - b := &bytes.Buffer{} - if err := json.Indent(b, buf, "", j.Indent); err != nil { - return err - } - buf = b.Bytes() - } _, err = w.Write(buf) return err } - b, err := j.MarshalOptions.Marshal(p) if err != nil { return err @@ -154,6 +150,9 @@ func (j *JSONPb) marshalNonProtoField(v interface{}) ([]byte, error) { } m[fmt.Sprintf("%v", k.Interface())] = (*json.RawMessage)(&buf) } + if j.Indent != "" { + return json.MarshalIndent(m, "", j.Indent) + } return json.Marshal(m) } if enum, ok := rv.Interface().(protoEnum); ok && !j.UseEnumNumbers { diff --git a/vendor/github.com/grpc-ecosystem/grpc-gateway/v2/runtime/marshaler_registry.go b/vendor/github.com/grpc-ecosystem/grpc-gateway/v2/runtime/marshaler_registry.go index 0b051e6e8..a714de024 100644 --- a/vendor/github.com/grpc-ecosystem/grpc-gateway/v2/runtime/marshaler_registry.go +++ b/vendor/github.com/grpc-ecosystem/grpc-gateway/v2/runtime/marshaler_registry.go @@ -46,7 +46,7 @@ func MarshalerForRequest(mux *ServeMux, r *http.Request) (inbound Marshaler, out for _, contentTypeVal := range r.Header[contentTypeHeader] { contentType, _, err := mime.ParseMediaType(contentTypeVal) if err != nil { - grpclog.Errorf("Failed to parse Content-Type %s: %v", contentTypeVal, err) + grpclog.Infof("Failed to parse Content-Type %s: %v", contentTypeVal, err) continue } if m, ok := mux.marshalers.mimeMap[contentType]; ok { diff --git a/vendor/github.com/grpc-ecosystem/grpc-gateway/v2/runtime/pattern.go b/vendor/github.com/grpc-ecosystem/grpc-gateway/v2/runtime/pattern.go index e54507145..8f90d15a5 100644 --- a/vendor/github.com/grpc-ecosystem/grpc-gateway/v2/runtime/pattern.go +++ b/vendor/github.com/grpc-ecosystem/grpc-gateway/v2/runtime/pattern.go @@ -52,13 +52,13 @@ type Pattern struct { // It returns an error if the given definition is invalid. func NewPattern(version int, ops []int, pool []string, verb string) (Pattern, error) { if version != 1 { - grpclog.Errorf("unsupported version: %d", version) + grpclog.Infof("unsupported version: %d", version) return Pattern{}, ErrInvalidPattern } l := len(ops) if l%2 != 0 { - grpclog.Errorf("odd number of ops codes: %d", l) + grpclog.Infof("odd number of ops codes: %d", l) return Pattern{}, ErrInvalidPattern } @@ -81,14 +81,14 @@ func NewPattern(version int, ops []int, pool []string, verb string) (Pattern, er stack++ case utilities.OpPushM: if pushMSeen { - grpclog.Error("pushM appears twice") + grpclog.Infof("pushM appears twice") return Pattern{}, ErrInvalidPattern } pushMSeen = true stack++ case utilities.OpLitPush: if op.operand < 0 || len(pool) <= op.operand { - grpclog.Errorf("negative literal index: %d", op.operand) + grpclog.Infof("negative literal index: %d", op.operand) return Pattern{}, ErrInvalidPattern } if pushMSeen { @@ -97,18 +97,18 @@ func NewPattern(version int, ops []int, pool []string, verb string) (Pattern, er stack++ case utilities.OpConcatN: if op.operand <= 0 { - grpclog.Errorf("negative concat size: %d", op.operand) + grpclog.Infof("negative concat size: %d", op.operand) return Pattern{}, ErrInvalidPattern } stack -= op.operand if stack < 0 { - grpclog.Error("stack underflow") + grpclog.Info("stack underflow") return Pattern{}, ErrInvalidPattern } stack++ case utilities.OpCapture: if op.operand < 0 || len(pool) <= op.operand { - grpclog.Errorf("variable name index out of bound: %d", op.operand) + grpclog.Infof("variable name index out of bound: %d", op.operand) return Pattern{}, ErrInvalidPattern } v := pool[op.operand] @@ -116,11 +116,11 @@ func NewPattern(version int, ops []int, pool []string, verb string) (Pattern, er vars = append(vars, v) stack-- if stack < 0 { - grpclog.Error("stack underflow") + grpclog.Infof("stack underflow") return Pattern{}, ErrInvalidPattern } default: - grpclog.Errorf("invalid opcode: %d", op.code) + grpclog.Infof("invalid opcode: %d", op.code) return Pattern{}, ErrInvalidPattern } diff --git a/vendor/github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring/v1/podmonitor_types.go b/vendor/github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring/v1/podmonitor_types.go index aa0217501..c6a78fd09 100644 --- a/vendor/github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring/v1/podmonitor_types.go +++ b/vendor/github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring/v1/podmonitor_types.go @@ -269,7 +269,7 @@ type PodMetricsEndpoint struct { // samples before ingestion. // // +optional - MetricRelabelConfigs []RelabelConfig `json:"metricRelabelings,omitempty"` + MetricRelabelConfigs []*RelabelConfig `json:"metricRelabelings,omitempty"` // `relabelings` configures the relabeling rules to apply the target's // metadata labels. @@ -281,7 +281,7 @@ type PodMetricsEndpoint struct { // More info: https://prometheus.io/docs/prometheus/latest/configuration/configuration/#relabel_config // // +optional - RelabelConfigs []RelabelConfig `json:"relabelings,omitempty"` + RelabelConfigs []*RelabelConfig `json:"relabelings,omitempty"` // `proxyURL` configures the HTTP Proxy URL (e.g. // "http://proxyserver:2195") to go through when scraping the target. diff --git a/vendor/github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring/v1/probe_types.go b/vendor/github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring/v1/probe_types.go index 4e8427c6c..e740cee08 100644 --- a/vendor/github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring/v1/probe_types.go +++ b/vendor/github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring/v1/probe_types.go @@ -75,7 +75,7 @@ type ProbeSpec struct { // OAuth2 for the URL. Only valid in Prometheus versions 2.27.0 and newer. OAuth2 *OAuth2 `json:"oauth2,omitempty"` // MetricRelabelConfigs to apply to samples before ingestion. - MetricRelabelConfigs []RelabelConfig `json:"metricRelabelings,omitempty"` + MetricRelabelConfigs []*RelabelConfig `json:"metricRelabelings,omitempty"` // Authorization section for this endpoint Authorization *SafeAuthorization `json:"authorization,omitempty"` // SampleLimit defines per-scrape limit on number of scraped samples that will be accepted. @@ -166,7 +166,7 @@ type ProbeTargetStaticConfig struct { // RelabelConfigs to apply to the label set of the targets before it gets // scraped. // More info: https://prometheus.io/docs/prometheus/latest/configuration/configuration/#relabel_config - RelabelConfigs []RelabelConfig `json:"relabelingConfigs,omitempty"` + RelabelConfigs []*RelabelConfig `json:"relabelingConfigs,omitempty"` } // ProbeTargetIngress defines the set of Ingress objects considered for probing. @@ -184,7 +184,7 @@ type ProbeTargetIngress struct { // probed URL. // The original scrape job's name is available via the `__tmp_prometheus_job_name` label. // More info: https://prometheus.io/docs/prometheus/latest/configuration/configuration/#relabel_config - RelabelConfigs []RelabelConfig `json:"relabelingConfigs,omitempty"` + RelabelConfigs []*RelabelConfig `json:"relabelingConfigs,omitempty"` } // ProberSpec contains specification parameters for the Prober used for probing. diff --git a/vendor/github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring/v1/prometheus_types.go b/vendor/github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring/v1/prometheus_types.go index c8aed40be..4953225cb 100644 --- a/vendor/github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring/v1/prometheus_types.go +++ b/vendor/github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring/v1/prometheus_types.go @@ -88,9 +88,6 @@ type TopologySpreadConstraint struct { AdditionalLabelSelectors *AdditionalLabelSelectors `json:"additionalLabelSelectors,omitempty"` } -// +kubebuilder:validation:MinLength:=1 -type EnableFeature string - // CommonPrometheusFields are the options available to both the Prometheus server and agent. // +k8s:deepcopy-gen=true type CommonPrometheusFields struct { @@ -305,10 +302,7 @@ type CommonPrometheusFields struct { // that this behaviour may break at any time without notice. // // For more information see https://prometheus.io/docs/prometheus/latest/feature_flags/ - // - // +listType:=set - // +optional - EnableFeatures []EnableFeature `json:"enableFeatures,omitempty"` + EnableFeatures []string `json:"enableFeatures,omitempty"` // The external URL under which the Prometheus service is externally // available. This is necessary to generate correct URLs (for instance if @@ -356,14 +350,6 @@ type CommonPrometheusFields struct { // Prometheus Pods. ServiceAccountName string `json:"serviceAccountName,omitempty"` - // AutomountServiceAccountToken indicates whether a service account token should be automatically mounted in the pod. - // If the field isn't set, the operator mounts the service account token by default. - // - // **Warning:** be aware that by default, Prometheus requires the service account token for Kubernetes service discovery. - // It is possible to use strategic merge patch to project the service account token into the 'prometheus' container. - // +optional - AutomountServiceAccountToken *bool `json:"automountServiceAccountToken,omitempty"` - // Secrets is a list of Secrets in the same namespace as the Prometheus // object, which shall be mounted into the Prometheus Pods. // Each Secret is added to the StatefulSet definition as a volume named `secret-`. @@ -491,7 +477,7 @@ type CommonPrometheusFields struct { // object. IgnoreNamespaceSelectors bool `json:"ignoreNamespaceSelectors,omitempty"` - // When not empty, a label will be added to: + // When not empty, a label will be added to // // 1. All metrics scraped from `ServiceMonitor`, `PodMonitor`, `Probe` and `ScrapeConfig` objects. // 2. All metrics generated from recording rules defined in `PrometheusRule` objects. @@ -502,7 +488,7 @@ type CommonPrometheusFields struct { // // The label's name is this field's value. // The label's value is the namespace of the `ServiceMonitor`, - // `PodMonitor`, `Probe`, `PrometheusRule` or `ScrapeConfig` object. + // `PodMonitor`, `Probe` or `PrometheusRule` object. EnforcedNamespaceLabel string `json:"enforcedNamespaceLabel,omitempty"` // When defined, enforcedSampleLimit specifies a global limit on the number @@ -1382,23 +1368,16 @@ type AzureAD struct { // +optional Cloud *string `json:"cloud,omitempty"` // ManagedIdentity defines the Azure User-assigned Managed identity. - // Cannot be set at the same time as `oauth` or `sdk`. + // Cannot be set at the same time as `oauth`. // +optional ManagedIdentity *ManagedIdentity `json:"managedIdentity,omitempty"` // OAuth defines the oauth config that is being used to authenticate. - // Cannot be set at the same time as `managedIdentity` or `sdk`. + // Cannot be set at the same time as `managedIdentity`. // // It requires Prometheus >= v2.48.0. // // +optional OAuth *AzureOAuth `json:"oauth,omitempty"` - // SDK defines the Azure SDK config that is being used to authenticate. - // See https://learn.microsoft.com/en-us/azure/developer/go/azure-sdk-authentication - // Cannot be set at the same time as `oauth` or `managedIdentity`. - // - // It requires Prometheus >= 2.52.0. - // +optional - SDK *AzureSDK `json:"sdk,omitempty"` } // AzureOAuth defines the Azure OAuth settings. @@ -1411,7 +1390,7 @@ type AzureOAuth struct { // `clientSecret` specifies a key of a Secret containing the client secret of the Azure Active Directory application that is being used to authenticate. // +required ClientSecret v1.SecretKeySelector `json:"clientSecret"` - // `tenantId` is the tenant ID of the Azure Active Directory application that is being used to authenticate. + // `tenantID` is the tenant ID of the Azure Active Directory application that is being used to authenticate. // +required // +kubebuilder:validation:MinLength=1 // +kubebuilder:validation:Pattern:=^[0-9a-zA-Z-.]+$ @@ -1426,14 +1405,6 @@ type ManagedIdentity struct { ClientID string `json:"clientId"` } -// AzureSDK is used to store azure SDK config values. -type AzureSDK struct { - // `tenantId` is the tenant ID of the azure active directory application that is being used to authenticate. - // +optional - // +kubebuilder:validation:Pattern:=^[0-9a-zA-Z-.]+$ - TenantID *string `json:"tenantId,omitempty"` -} - // RemoteReadSpec defines the configuration for Prometheus to read back samples // from a remote endpoint. // +k8s:openapi-gen=true @@ -1559,9 +1530,7 @@ type RelabelConfig struct { // regular expression matches. // // Regex capture groups are available. - // - //+optional - Replacement *string `json:"replacement,omitempty"` + Replacement string `json:"replacement,omitempty"` // Action to perform based on the regex matching. // @@ -1686,17 +1655,6 @@ type AlertmanagerEndpoints struct { // // +optional EnableHttp2 *bool `json:"enableHttp2,omitempty"` - - // Relabel configuration applied to the discovered Alertmanagers. - // - // +optional - RelabelConfigs []RelabelConfig `json:"relabelings,omitempty"` - - // Relabeling configs applied before sending alerts to a specific Alertmanager. - // It requires Prometheus >= v2.51.0. - // - // +optional - AlertRelabelConfigs []RelabelConfig `json:"alertRelabelings,omitempty"` } // +k8s:openapi-gen=true @@ -1841,25 +1799,17 @@ func (e *AuthorizationValidationError) Error() string { type ScrapeClass struct { // Name of the scrape class. - // // +kubebuilder:validation:MinLength=1 // +required Name string `json:"name"` - // Default indicates that the scrape applies to all scrape objects that - // don't configure an explicit scrape class name. - // - // Only one scrape class can be set as the default. + // Default indicates that the scrape applies to all scrape objects that don't configure an explicit scrape class name. // + // Only one scrape class can be set as default. // +optional Default *bool `json:"default,omitempty"` - // TLSConfig defines the TLS settings to use for the scrape. When the - // scrape objects define their own CA, certificate and/or key, they take - // precedence over the corresponding scrape class fields. - // - // For now only the `caFile`, `certFile` and `keyFile` fields are supported. - // + // TLSConfig section for scrapes. // +optional TLSConfig *TLSConfig `json:"tlsConfig,omitempty"` @@ -1873,5 +1823,5 @@ type ScrapeClass struct { // More info: https://prometheus.io/docs/prometheus/latest/configuration/configuration/#relabel_config // // +optional - Relabelings []RelabelConfig `json:"relabelings,omitempty"` + Relabelings []*RelabelConfig `json:"relabelings,omitempty"` } diff --git a/vendor/github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring/v1/types.go b/vendor/github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring/v1/types.go index a49b87d66..901caa2a4 100644 --- a/vendor/github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring/v1/types.go +++ b/vendor/github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring/v1/types.go @@ -101,7 +101,7 @@ type ProxyConfig struct { // It requires Prometheus >= v2.43.0. // +optional // +mapType:=atomic - ProxyConnectHeader map[string][]v1.SecretKeySelector `json:"proxyConnectHeader,omitempty"` + ProxyConnectHeader map[string]v1.SecretKeySelector `json:"proxyConnectHeader,omitempty"` } // ObjectReference references a PodMonitor, ServiceMonitor, Probe or PrometheusRule object. @@ -497,7 +497,7 @@ type Endpoint struct { // samples before ingestion. // // +optional - MetricRelabelConfigs []RelabelConfig `json:"metricRelabelings,omitempty"` + MetricRelabelConfigs []*RelabelConfig `json:"metricRelabelings,omitempty"` // `relabelings` configures the relabeling rules to apply the target's // metadata labels. @@ -509,7 +509,7 @@ type Endpoint struct { // More info: https://prometheus.io/docs/prometheus/latest/configuration/configuration/#relabel_config // // +optional - RelabelConfigs []RelabelConfig `json:"relabelings,omitempty"` + RelabelConfigs []*RelabelConfig `json:"relabelings,omitempty"` // `proxyURL` configures the HTTP Proxy URL (e.g. // "http://proxyserver:2195") to go through when scraping the target. @@ -656,20 +656,14 @@ func (c *SecretOrConfigMap) String() string { type SafeTLSConfig struct { // Certificate authority used when verifying server certificates. CA SecretOrConfigMap `json:"ca,omitempty"` - // Client certificate to present when doing client-authentication. Cert SecretOrConfigMap `json:"cert,omitempty"` - // Secret containing the client key file for the targets. KeySecret *v1.SecretKeySelector `json:"keySecret,omitempty"` - // Used to verify the hostname for the targets. - //+optional - ServerName *string `json:"serverName,omitempty"` - + ServerName string `json:"serverName,omitempty"` // Disable target certificate validation. - //+optional - InsecureSkipVerify *bool `json:"insecureSkipVerify,omitempty"` + InsecureSkipVerify bool `json:"insecureSkipVerify,omitempty"` } // Validate semantically validates the given SafeTLSConfig. diff --git a/vendor/github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring/v1/zz_generated.deepcopy.go b/vendor/github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring/v1/zz_generated.deepcopy.go index b1e63c9ce..dc1e7a2a7 100644 --- a/vendor/github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring/v1/zz_generated.deepcopy.go +++ b/vendor/github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring/v1/zz_generated.deepcopy.go @@ -172,20 +172,6 @@ func (in *AlertmanagerEndpoints) DeepCopyInto(out *AlertmanagerEndpoints) { *out = new(bool) **out = **in } - if in.RelabelConfigs != nil { - in, out := &in.RelabelConfigs, &out.RelabelConfigs - *out = make([]RelabelConfig, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } - if in.AlertRelabelConfigs != nil { - in, out := &in.AlertRelabelConfigs, &out.AlertRelabelConfigs - *out = make([]RelabelConfig, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AlertmanagerEndpoints. @@ -577,11 +563,6 @@ func (in *AzureAD) DeepCopyInto(out *AzureAD) { *out = new(AzureOAuth) (*in).DeepCopyInto(*out) } - if in.SDK != nil { - in, out := &in.SDK, &out.SDK - *out = new(AzureSDK) - (*in).DeepCopyInto(*out) - } } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AzureAD. @@ -610,26 +591,6 @@ func (in *AzureOAuth) DeepCopy() *AzureOAuth { return out } -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *AzureSDK) DeepCopyInto(out *AzureSDK) { - *out = *in - if in.TenantID != nil { - in, out := &in.TenantID, &out.TenantID - *out = new(string) - **out = **in - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AzureSDK. -func (in *AzureSDK) DeepCopy() *AzureSDK { - if in == nil { - return nil - } - out := new(AzureSDK) - in.DeepCopyInto(out) - return out -} - // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *BasicAuth) DeepCopyInto(out *BasicAuth) { *out = *in @@ -739,7 +700,7 @@ func (in *CommonPrometheusFields) DeepCopyInto(out *CommonPrometheusFields) { } if in.EnableFeatures != nil { in, out := &in.EnableFeatures, &out.EnableFeatures - *out = make([]EnableFeature, len(*in)) + *out = make([]string, len(*in)) copy(*out, *in) } if in.Storage != nil { @@ -779,11 +740,6 @@ func (in *CommonPrometheusFields) DeepCopyInto(out *CommonPrometheusFields) { (*out)[key] = val } } - if in.AutomountServiceAccountToken != nil { - in, out := &in.AutomountServiceAccountToken, &out.AutomountServiceAccountToken - *out = new(bool) - **out = **in - } if in.Secrets != nil { in, out := &in.Secrets, &out.Secrets *out = make([]string, len(*in)) @@ -1146,16 +1102,24 @@ func (in *Endpoint) DeepCopyInto(out *Endpoint) { } if in.MetricRelabelConfigs != nil { in, out := &in.MetricRelabelConfigs, &out.MetricRelabelConfigs - *out = make([]RelabelConfig, len(*in)) + *out = make([]*RelabelConfig, len(*in)) for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) + if (*in)[i] != nil { + in, out := &(*in)[i], &(*out)[i] + *out = new(RelabelConfig) + (*in).DeepCopyInto(*out) + } } } if in.RelabelConfigs != nil { in, out := &in.RelabelConfigs, &out.RelabelConfigs - *out = make([]RelabelConfig, len(*in)) + *out = make([]*RelabelConfig, len(*in)) for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) + if (*in)[i] != nil { + in, out := &(*in)[i], &(*out)[i] + *out = new(RelabelConfig) + (*in).DeepCopyInto(*out) + } } } if in.ProxyURL != nil { @@ -1511,16 +1475,24 @@ func (in *PodMetricsEndpoint) DeepCopyInto(out *PodMetricsEndpoint) { } if in.MetricRelabelConfigs != nil { in, out := &in.MetricRelabelConfigs, &out.MetricRelabelConfigs - *out = make([]RelabelConfig, len(*in)) + *out = make([]*RelabelConfig, len(*in)) for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) + if (*in)[i] != nil { + in, out := &(*in)[i], &(*out)[i] + *out = new(RelabelConfig) + (*in).DeepCopyInto(*out) + } } } if in.RelabelConfigs != nil { in, out := &in.RelabelConfigs, &out.RelabelConfigs - *out = make([]RelabelConfig, len(*in)) + *out = make([]*RelabelConfig, len(*in)) for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) + if (*in)[i] != nil { + in, out := &(*in)[i], &(*out)[i] + *out = new(RelabelConfig) + (*in).DeepCopyInto(*out) + } } } if in.ProxyURL != nil { @@ -1749,9 +1721,13 @@ func (in *ProbeSpec) DeepCopyInto(out *ProbeSpec) { } if in.MetricRelabelConfigs != nil { in, out := &in.MetricRelabelConfigs, &out.MetricRelabelConfigs - *out = make([]RelabelConfig, len(*in)) + *out = make([]*RelabelConfig, len(*in)) for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) + if (*in)[i] != nil { + in, out := &(*in)[i], &(*out)[i] + *out = new(RelabelConfig) + (*in).DeepCopyInto(*out) + } } } if in.Authorization != nil { @@ -1818,9 +1794,13 @@ func (in *ProbeTargetIngress) DeepCopyInto(out *ProbeTargetIngress) { in.NamespaceSelector.DeepCopyInto(&out.NamespaceSelector) if in.RelabelConfigs != nil { in, out := &in.RelabelConfigs, &out.RelabelConfigs - *out = make([]RelabelConfig, len(*in)) + *out = make([]*RelabelConfig, len(*in)) for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) + if (*in)[i] != nil { + in, out := &(*in)[i], &(*out)[i] + *out = new(RelabelConfig) + (*in).DeepCopyInto(*out) + } } } } @@ -1852,9 +1832,13 @@ func (in *ProbeTargetStaticConfig) DeepCopyInto(out *ProbeTargetStaticConfig) { } if in.RelabelConfigs != nil { in, out := &in.RelabelConfigs, &out.RelabelConfigs - *out = make([]RelabelConfig, len(*in)) + *out = make([]*RelabelConfig, len(*in)) for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) + if (*in)[i] != nil { + in, out := &(*in)[i], &(*out)[i] + *out = new(RelabelConfig) + (*in).DeepCopyInto(*out) + } } } } @@ -2249,20 +2233,9 @@ func (in *ProxyConfig) DeepCopyInto(out *ProxyConfig) { } if in.ProxyConnectHeader != nil { in, out := &in.ProxyConnectHeader, &out.ProxyConnectHeader - *out = make(map[string][]corev1.SecretKeySelector, len(*in)) + *out = make(map[string]corev1.SecretKeySelector, len(*in)) for key, val := range *in { - var outVal []corev1.SecretKeySelector - if val == nil { - (*out)[key] = nil - } else { - inVal := (*in)[key] - in, out := &inVal, &outVal - *out = make([]corev1.SecretKeySelector, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } - (*out)[key] = outVal + (*out)[key] = *val.DeepCopy() } } } @@ -2360,11 +2333,6 @@ func (in *RelabelConfig) DeepCopyInto(out *RelabelConfig) { *out = new(string) **out = **in } - if in.Replacement != nil { - in, out := &in.Replacement, &out.Replacement - *out = new(string) - **out = **in - } } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RelabelConfig. @@ -2653,16 +2621,6 @@ func (in *SafeTLSConfig) DeepCopyInto(out *SafeTLSConfig) { *out = new(corev1.SecretKeySelector) (*in).DeepCopyInto(*out) } - if in.ServerName != nil { - in, out := &in.ServerName, &out.ServerName - *out = new(string) - **out = **in - } - if in.InsecureSkipVerify != nil { - in, out := &in.InsecureSkipVerify, &out.InsecureSkipVerify - *out = new(bool) - **out = **in - } } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SafeTLSConfig. @@ -2690,9 +2648,13 @@ func (in *ScrapeClass) DeepCopyInto(out *ScrapeClass) { } if in.Relabelings != nil { in, out := &in.Relabelings, &out.Relabelings - *out = make([]RelabelConfig, len(*in)) + *out = make([]*RelabelConfig, len(*in)) for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) + if (*in)[i] != nil { + in, out := &(*in)[i], &(*out)[i] + *out = new(RelabelConfig) + (*in).DeepCopyInto(*out) + } } } } diff --git a/vendor/github.com/tektoncd/pipeline/pkg/apis/config/feature_flags.go b/vendor/github.com/tektoncd/pipeline/pkg/apis/config/feature_flags.go index d9c65cc21..f8c057801 100644 --- a/vendor/github.com/tektoncd/pipeline/pkg/apis/config/feature_flags.go +++ b/vendor/github.com/tektoncd/pipeline/pkg/apis/config/feature_flags.go @@ -102,12 +102,12 @@ const ( EnableCELInWhenExpression = "enable-cel-in-whenexpression" // EnableStepActions is the flag to enable the use of StepActions in Steps EnableStepActions = "enable-step-actions" + // EnableArtifacts is the flag to enable the use of Artifacts in Steps EnableArtifacts = "enable-artifacts" + // EnableParamEnum is the flag to enabled enum in params EnableParamEnum = "enable-param-enum" - // EnableConciseResolverSyntax is the flag to enable concise resolver syntax - EnableConciseResolverSyntax = "enable-concise-resolver-syntax" // DisableInlineSpec is the flag to disable embedded spec // in Taskrun or Pipelinerun @@ -151,13 +151,13 @@ var ( // DefaultEnableStepActions is the default PerFeatureFlag value for EnableStepActions DefaultEnableStepActions = PerFeatureFlag{ Name: EnableStepActions, - Stability: BetaAPIFields, - Enabled: DefaultBetaFeatureEnabled, + Stability: AlphaAPIFields, + Enabled: DefaultAlphaFeatureEnabled, } - // DefaultEnableArtifacts is the default PerFeatureFlag value for EnableArtifacts + // DefaultEnableArtifacts is the default PerFeatureFlag value for EnableStepActions DefaultEnableArtifacts = PerFeatureFlag{ - Name: EnableArtifacts, + Name: EnableStepActions, Stability: AlphaAPIFields, Enabled: DefaultAlphaFeatureEnabled, } @@ -168,13 +168,6 @@ var ( Stability: AlphaAPIFields, Enabled: DefaultAlphaFeatureEnabled, } - - // DefaultEnableConciseResolverSyntax is the default PerFeatureFlag value for EnableConciseResolverSyntax - DefaultEnableConciseResolverSyntax = PerFeatureFlag{ - Name: EnableConciseResolverSyntax, - Stability: AlphaAPIFields, - Enabled: DefaultAlphaFeatureEnabled, - } ) // FeatureFlags holds the features configurations @@ -196,18 +189,17 @@ type FeatureFlags struct { // ignore: skip trusted resources verification when no matching verification policies found // warn: skip trusted resources verification when no matching verification policies found and log a warning // fail: fail the taskrun or pipelines run if no matching verification policies found - VerificationNoMatchPolicy string - EnableProvenanceInStatus bool - ResultExtractionMethod string - MaxResultSize int - SetSecurityContext bool - Coschedule string - EnableCELInWhenExpression bool - EnableStepActions bool - EnableParamEnum bool - EnableArtifacts bool - DisableInlineSpec string - EnableConciseResolverSyntax bool + VerificationNoMatchPolicy string + EnableProvenanceInStatus bool + ResultExtractionMethod string + MaxResultSize int + SetSecurityContext bool + Coschedule string + EnableCELInWhenExpression bool + EnableStepActions bool + EnableParamEnum bool + EnableArtifacts bool + DisableInlineSpec string } // GetFeatureFlagsConfigName returns the name of the configmap containing all @@ -302,15 +294,14 @@ func NewFeatureFlagsFromMap(cfgMap map[string]string) (*FeatureFlags, error) { if err := setPerFeatureFlag(EnableParamEnum, DefaultEnableParamEnum, &tc.EnableParamEnum); err != nil { return nil, err } + if err := setPerFeatureFlag(EnableArtifacts, DefaultEnableArtifacts, &tc.EnableArtifacts); err != nil { return nil, err } if err := setFeatureInlineSpec(cfgMap, DisableInlineSpec, DefaultDisableInlineSpec, &tc.DisableInlineSpec); err != nil { return nil, err } - if err := setPerFeatureFlag(EnableConciseResolverSyntax, DefaultEnableConciseResolverSyntax, &tc.EnableConciseResolverSyntax); err != nil { - return nil, err - } + // Given that they are alpha features, Tekton Bundles and Custom Tasks should be switched on if // enable-api-fields is "alpha". If enable-api-fields is not "alpha" then fall back to the value of // each feature's individual flag. diff --git a/vendor/github.com/tektoncd/pipeline/pkg/apis/config/metrics.go b/vendor/github.com/tektoncd/pipeline/pkg/apis/config/metrics.go index 0df91805d..2b18f6d0c 100644 --- a/vendor/github.com/tektoncd/pipeline/pkg/apis/config/metrics.go +++ b/vendor/github.com/tektoncd/pipeline/pkg/apis/config/metrics.go @@ -39,9 +39,6 @@ const ( // countWithReasonKey sets if the reason label should be included on count metrics countWithReasonKey = "metrics.count.enable-reason" - // throttledWithNamespaceKey sets if the namespace label should be included on the taskrun throttled metrics - throttledWithNamespaceKey = "metrics.taskrun.throttle.enable-namespace" - // DefaultTaskrunLevel determines to what level to aggregate metrics // when it isn't specified in configmap DefaultTaskrunLevel = TaskrunLevelAtTask @@ -99,7 +96,6 @@ type Metrics struct { DurationTaskrunType string DurationPipelinerunType string CountWithReason bool - ThrottleWithNamespace bool } // GetMetricsConfigName returns the name of the configmap containing all @@ -133,7 +129,6 @@ func newMetricsFromMap(cfgMap map[string]string) (*Metrics, error) { DurationTaskrunType: DefaultDurationTaskrunType, DurationPipelinerunType: DefaultDurationPipelinerunType, CountWithReason: false, - ThrottleWithNamespace: false, } if taskrunLevel, ok := cfgMap[metricsTaskrunLevelKey]; ok { @@ -154,10 +149,6 @@ func newMetricsFromMap(cfgMap map[string]string) (*Metrics, error) { tc.CountWithReason = true } - if throttleWithNamespace, ok := cfgMap[throttledWithNamespaceKey]; ok && throttleWithNamespace != "false" { - tc.ThrottleWithNamespace = true - } - return &tc, nil } diff --git a/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1/container_validation.go b/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1/container_validation.go index ec55189bc..bfee6884b 100644 --- a/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1/container_validation.go +++ b/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1/container_validation.go @@ -18,9 +18,6 @@ package v1 import ( "context" - "errors" - "fmt" - "regexp" "strings" "github.com/tektoncd/pipeline/pkg/apis/config" @@ -28,72 +25,38 @@ import ( "knative.dev/pkg/apis" ) -func validateRef(ctx context.Context, refName string, refResolver ResolverName, refParams Params) (errs *apis.FieldError) { +// Validate ensures that a supplied Ref field is populated +// correctly. No errors are returned for a nil Ref. +func (ref *Ref) Validate(ctx context.Context) (errs *apis.FieldError) { + if ref == nil { + return errs + } + switch { - case refResolver != "" || refParams != nil: - if refParams != nil { - errs = errs.Also(config.ValidateEnabledAPIFields(ctx, "resolver params", config.BetaAPIFields).ViaField("params")) - if refName != "" { - errs = errs.Also(apis.ErrMultipleOneOf("name", "params")) - } - if refResolver == "" { - errs = errs.Also(apis.ErrMissingField("resolver")) - } - errs = errs.Also(ValidateParameters(ctx, refParams)) - } - if refResolver != "" { + case ref.Resolver != "" || ref.Params != nil: + if ref.Resolver != "" { errs = errs.Also(config.ValidateEnabledAPIFields(ctx, "resolver", config.BetaAPIFields).ViaField("resolver")) - if refName != "" { - // make sure that the name is url-like. - err := RefNameLikeUrl(refName) - if err == nil && !config.FromContextOrDefaults(ctx).FeatureFlags.EnableConciseResolverSyntax { - // If name is url-like then concise resolver syntax must be enabled - errs = errs.Also(apis.ErrGeneric(fmt.Sprintf("feature flag %s should be set to true to use concise resolver syntax", config.EnableConciseResolverSyntax), "")) - } - if err != nil { - errs = errs.Also(apis.ErrInvalidValue(err, "name")) - } + if ref.Name != "" { + errs = errs.Also(apis.ErrMultipleOneOf("name", "resolver")) } } - case refName != "": - // ref name can be a Url-like format. - if err := RefNameLikeUrl(refName); err == nil { - // If name is url-like then concise resolver syntax must be enabled - if !config.FromContextOrDefaults(ctx).FeatureFlags.EnableConciseResolverSyntax { - errs = errs.Also(apis.ErrGeneric(fmt.Sprintf("feature flag %s should be set to true to use concise resolver syntax", config.EnableConciseResolverSyntax), "")) + if ref.Params != nil { + errs = errs.Also(config.ValidateEnabledAPIFields(ctx, "resolver params", config.BetaAPIFields).ViaField("params")) + if ref.Name != "" { + errs = errs.Also(apis.ErrMultipleOneOf("name", "params")) } - // In stage1 of concise remote resolvers syntax, this is a required field. - // TODO: remove this check when implementing stage 2 where this is optional. - if refResolver == "" { + if ref.Resolver == "" { errs = errs.Also(apis.ErrMissingField("resolver")) } - // Or, it must be a valid k8s name - } else { - // ref name must be a valid k8s name - if errSlice := validation.IsQualifiedName(refName); len(errSlice) != 0 { - errs = errs.Also(apis.ErrInvalidValue(strings.Join(errSlice, ","), "name")) - } + errs = errs.Also(ValidateParameters(ctx, ref.Params)) + } + case ref.Name != "": + // ref name must be a valid k8s name + if errSlice := validation.IsQualifiedName(ref.Name); len(errSlice) != 0 { + errs = errs.Also(apis.ErrInvalidValue(strings.Join(errSlice, ","), "name")) } default: errs = errs.Also(apis.ErrMissingField("name")) } return errs } - -// Validate ensures that a supplied Ref field is populated -// correctly. No errors are returned for a nil Ref. -func (ref *Ref) Validate(ctx context.Context) (errs *apis.FieldError) { - if ref == nil { - return errs - } - return validateRef(ctx, ref.Name, ref.Resolver, ref.Params) -} - -// RefNameLikeUrl checks if the name is url parsable and returns an error if it isn't. -func RefNameLikeUrl(name string) error { - schemeRegex := regexp.MustCompile(`[\w-]+:\/\/*`) - if !schemeRegex.MatchString(name) { - return errors.New("invalid URI for request") - } - return nil -} diff --git a/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1/openapi_generated.go b/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1/openapi_generated.go index a5b1eff40..f9380013f 100644 --- a/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1/openapi_generated.go +++ b/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1/openapi_generated.go @@ -3159,7 +3159,7 @@ func schema_pkg_apis_pipeline_v1_StepResult(ref common.ReferenceCallback) common return common.OpenAPIDefinition{ Schema: spec.Schema{ SchemaProps: spec.SchemaProps{ - Description: "StepResult used to describe the Results of a Step.\n\nThis is field is at an BETA stability level and gated by \"enable-step-actions\" feature flag.", + Description: "StepResult used to describe the Results of a Step.\n\nThis is field is at an ALPHA stability level and gated by \"enable-step-actions\" feature flag.", Type: []string{"object"}, Properties: map[string]spec.Schema{ "name": { diff --git a/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1/pipeline_validation.go b/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1/pipeline_validation.go index 43e56d102..a0b65f778 100644 --- a/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1/pipeline_validation.go +++ b/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1/pipeline_validation.go @@ -151,10 +151,10 @@ func (l PipelineTaskList) Validate(ctx context.Context, taskNames sets.String, p } // validateUsageOfDeclaredPipelineTaskParameters validates that all parameters referenced in the pipeline Task are declared by the pipeline Task. -func (l PipelineTaskList) validateUsageOfDeclaredPipelineTaskParameters(ctx context.Context, additionalParams []ParamSpec, path string) (errs *apis.FieldError) { +func (l PipelineTaskList) validateUsageOfDeclaredPipelineTaskParameters(ctx context.Context, path string) (errs *apis.FieldError) { for i, t := range l { if t.TaskSpec != nil { - errs = errs.Also(ValidateUsageOfDeclaredParameters(ctx, t.TaskSpec.Steps, append(t.TaskSpec.Params, additionalParams...)).ViaFieldIndex(path, i)) + errs = errs.Also(ValidateUsageOfDeclaredParameters(ctx, t.TaskSpec.Steps, t.TaskSpec.Params).ViaFieldIndex(path, i)) } } return errs @@ -385,8 +385,8 @@ func validatePipelineWorkspacesDeclarations(wss []PipelineWorkspaceDeclaration) // validatePipelineParameterUsage validates that parameters referenced in the Pipeline are declared by the Pipeline func (ps *PipelineSpec) validatePipelineParameterUsage(ctx context.Context) (errs *apis.FieldError) { - errs = errs.Also(PipelineTaskList(ps.Tasks).validateUsageOfDeclaredPipelineTaskParameters(ctx, ps.Params, "tasks")) - errs = errs.Also(PipelineTaskList(ps.Finally).validateUsageOfDeclaredPipelineTaskParameters(ctx, ps.Params, "finally")) + errs = errs.Also(PipelineTaskList(ps.Tasks).validateUsageOfDeclaredPipelineTaskParameters(ctx, "tasks")) + errs = errs.Also(PipelineTaskList(ps.Finally).validateUsageOfDeclaredPipelineTaskParameters(ctx, "finally")) errs = errs.Also(validatePipelineTaskParameterUsage(ps.Tasks, ps.Params).ViaField("tasks")) errs = errs.Also(validatePipelineTaskParameterUsage(ps.Finally, ps.Params).ViaField("finally")) return errs diff --git a/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1/pipelineref_validation.go b/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1/pipelineref_validation.go index c23db32a5..9fa7c9894 100644 --- a/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1/pipelineref_validation.go +++ b/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1/pipelineref_validation.go @@ -19,6 +19,7 @@ package v1 import ( "context" + "github.com/tektoncd/pipeline/pkg/apis/config" "knative.dev/pkg/apis" ) @@ -26,7 +27,28 @@ import ( // correctly. No errors are returned for a nil PipelineRef. func (ref *PipelineRef) Validate(ctx context.Context) (errs *apis.FieldError) { if ref == nil { - return errs + return } - return validateRef(ctx, ref.Name, ref.Resolver, ref.Params) + + if ref.Resolver != "" || ref.Params != nil { + if ref.Resolver != "" { + errs = errs.Also(config.ValidateEnabledAPIFields(ctx, "resolver", config.BetaAPIFields).ViaField("resolver")) + if ref.Name != "" { + errs = errs.Also(apis.ErrMultipleOneOf("name", "resolver")) + } + } + if ref.Params != nil { + errs = errs.Also(config.ValidateEnabledAPIFields(ctx, "resolver params", config.BetaAPIFields).ViaField("params")) + if ref.Name != "" { + errs = errs.Also(apis.ErrMultipleOneOf("name", "params")) + } + if ref.Resolver == "" { + errs = errs.Also(apis.ErrMissingField("resolver")) + } + errs = errs.Also(ValidateParameters(ctx, ref.Params)) + } + } else if ref.Name == "" { + errs = errs.Also(apis.ErrMissingField("name")) + } + return } diff --git a/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1/result_types.go b/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1/result_types.go index b36bf6fc6..6361d7a36 100644 --- a/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1/result_types.go +++ b/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1/result_types.go @@ -40,7 +40,7 @@ type TaskResult struct { // StepResult used to describe the Results of a Step. // -// This is field is at an BETA stability level and gated by "enable-step-actions" feature flag. +// This is field is at an ALPHA stability level and gated by "enable-step-actions" feature flag. type StepResult struct { // Name the given name Name string `json:"name"` diff --git a/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1/swagger.json b/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1/swagger.json index b44c5d356..8993af2ff 100644 --- a/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1/swagger.json +++ b/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1/swagger.json @@ -1611,7 +1611,7 @@ } }, "v1.StepResult": { - "description": "StepResult used to describe the Results of a Step.\n\nThis is field is at an BETA stability level and gated by \"enable-step-actions\" feature flag.", + "description": "StepResult used to describe the Results of a Step.\n\nThis is field is at an ALPHA stability level and gated by \"enable-step-actions\" feature flag.", "type": "object", "required": [ "name" diff --git a/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1/taskref_validation.go b/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1/taskref_validation.go index bbc5fbbfc..4f4e03303 100644 --- a/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1/taskref_validation.go +++ b/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1/taskref_validation.go @@ -18,7 +18,10 @@ package v1 import ( "context" + "strings" + "github.com/tektoncd/pipeline/pkg/apis/config" + "k8s.io/apimachinery/pkg/util/validation" "knative.dev/pkg/apis" ) @@ -28,5 +31,32 @@ func (ref *TaskRef) Validate(ctx context.Context) (errs *apis.FieldError) { if ref == nil { return errs } - return validateRef(ctx, ref.Name, ref.Resolver, ref.Params) + + switch { + case ref.Resolver != "" || ref.Params != nil: + if ref.Resolver != "" { + errs = errs.Also(config.ValidateEnabledAPIFields(ctx, "resolver", config.BetaAPIFields).ViaField("resolver")) + if ref.Name != "" { + errs = errs.Also(apis.ErrMultipleOneOf("name", "resolver")) + } + } + if ref.Params != nil { + errs = errs.Also(config.ValidateEnabledAPIFields(ctx, "resolver params", config.BetaAPIFields).ViaField("params")) + if ref.Name != "" { + errs = errs.Also(apis.ErrMultipleOneOf("name", "params")) + } + if ref.Resolver == "" { + errs = errs.Also(apis.ErrMissingField("resolver")) + } + errs = errs.Also(ValidateParameters(ctx, ref.Params)) + } + case ref.Name != "": + // TaskRef name must be a valid k8s name + if errSlice := validation.IsQualifiedName(ref.Name); len(errSlice) != 0 { + errs = errs.Also(apis.ErrInvalidValue(strings.Join(errSlice, ","), "name")) + } + default: + errs = errs.Also(apis.ErrMissingField("name")) + } + return errs } diff --git a/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1alpha1/stepaction_conversion.go b/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1alpha1/stepaction_conversion.go index b2896d0de..a02bf7609 100644 --- a/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1alpha1/stepaction_conversion.go +++ b/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1alpha1/stepaction_conversion.go @@ -15,9 +15,7 @@ package v1alpha1 import ( "context" - "fmt" - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" "knative.dev/pkg/apis" ) @@ -25,63 +23,20 @@ var _ apis.Convertible = (*StepAction)(nil) // ConvertTo implements apis.Convertible func (s *StepAction) ConvertTo(ctx context.Context, to apis.Convertible) error { - if apis.IsInDelete(ctx) { - return nil - } - switch sink := to.(type) { - case *v1beta1.StepAction: - sink.ObjectMeta = s.ObjectMeta - return s.Spec.ConvertTo(ctx, &sink.Spec) - default: - return fmt.Errorf("unknown version, got: %T", sink) - } + return nil } // ConvertTo implements apis.Convertible -func (ss *StepActionSpec) ConvertTo(ctx context.Context, sink *v1beta1.StepActionSpec) error { - sink.Description = ss.Description - sink.Image = ss.Image - sink.Command = ss.Command - sink.Args = ss.Args - sink.Env = ss.Env - sink.Script = ss.Script - sink.WorkingDir = ss.WorkingDir - sink.Params = ss.Params - sink.Results = ss.Results - sink.SecurityContext = ss.SecurityContext - sink.VolumeMounts = ss.VolumeMounts - +func (ss *StepActionSpec) ConvertTo(ctx context.Context, sink *StepActionSpec) error { return nil } // ConvertFrom implements apis.Convertible func (s *StepAction) ConvertFrom(ctx context.Context, from apis.Convertible) error { - if apis.IsInDelete(ctx) { - return nil - } - switch source := from.(type) { - case *v1beta1.StepAction: - s.ObjectMeta = source.ObjectMeta - return s.Spec.ConvertFrom(ctx, &source.Spec) - default: - return fmt.Errorf("unknown version, got: %T", source) - } + return nil } // ConvertFrom implements apis.Convertible -func (ss *StepActionSpec) ConvertFrom(ctx context.Context, source *v1beta1.StepActionSpec) error { - ss.Description = source.Description - ss.Image = source.Image - ss.Command = source.Command - ss.Args = source.Args - ss.Env = source.Env - ss.Script = source.Script - ss.WorkingDir = source.WorkingDir - - ss.Params = source.Params - ss.Results = source.Results - ss.SecurityContext = source.SecurityContext - ss.VolumeMounts = source.VolumeMounts - +func (ss *StepActionSpec) ConvertFrom(ctx context.Context, source *StepActionSpec) error { return nil } diff --git a/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/container_validation.go b/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/container_validation.go index dc1b60d15..bab6f8bc4 100644 --- a/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/container_validation.go +++ b/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/container_validation.go @@ -18,9 +18,6 @@ package v1beta1 import ( "context" - "errors" - "fmt" - "regexp" "strings" "github.com/tektoncd/pipeline/pkg/apis/config" @@ -28,72 +25,38 @@ import ( "knative.dev/pkg/apis" ) -func validateRef(ctx context.Context, refName string, refResolver ResolverName, refParams Params) (errs *apis.FieldError) { +// Validate ensures that a supplied Ref field is populated +// correctly. No errors are returned for a nil Ref. +func (ref *Ref) Validate(ctx context.Context) (errs *apis.FieldError) { + if ref == nil { + return errs + } + switch { - case refResolver != "" || refParams != nil: - if refParams != nil { - errs = errs.Also(config.ValidateEnabledAPIFields(ctx, "resolver params", config.BetaAPIFields).ViaField("params")) - if refName != "" { - errs = errs.Also(apis.ErrMultipleOneOf("name", "params")) - } - if refResolver == "" { - errs = errs.Also(apis.ErrMissingField("resolver")) - } - errs = errs.Also(ValidateParameters(ctx, refParams)) - } - if refResolver != "" { + case ref.Resolver != "" || ref.Params != nil: + if ref.Resolver != "" { errs = errs.Also(config.ValidateEnabledAPIFields(ctx, "resolver", config.BetaAPIFields).ViaField("resolver")) - if refName != "" { - // make sure that the name is url-like. - err := RefNameLikeUrl(refName) - if err == nil && !config.FromContextOrDefaults(ctx).FeatureFlags.EnableConciseResolverSyntax { - // If name is url-like then concise resolver syntax must be enabled - errs = errs.Also(apis.ErrGeneric(fmt.Sprintf("feature flag %s should be set to true to use concise resolver syntax", config.EnableConciseResolverSyntax), "")) - } - if err != nil { - errs = errs.Also(apis.ErrInvalidValue(err, "name")) - } + if ref.Name != "" { + errs = errs.Also(apis.ErrMultipleOneOf("name", "resolver")) } } - case refName != "": - // ref name can be a Url-like format. - if err := RefNameLikeUrl(refName); err == nil { - // If name is url-like then concise resolver syntax must be enabled - if !config.FromContextOrDefaults(ctx).FeatureFlags.EnableConciseResolverSyntax { - errs = errs.Also(apis.ErrGeneric(fmt.Sprintf("feature flag %s should be set to true to use concise resolver syntax", config.EnableConciseResolverSyntax), "")) + if ref.Params != nil { + errs = errs.Also(config.ValidateEnabledAPIFields(ctx, "resolver params", config.BetaAPIFields).ViaField("params")) + if ref.Name != "" { + errs = errs.Also(apis.ErrMultipleOneOf("name", "params")) } - // In stage1 of concise remote resolvers syntax, this is a required field. - // TODO: remove this check when implementing stage 2 where this is optional. - if refResolver == "" { + if ref.Resolver == "" { errs = errs.Also(apis.ErrMissingField("resolver")) } - // Or, it must be a valid k8s name - } else { - // ref name must be a valid k8s name - if errSlice := validation.IsQualifiedName(refName); len(errSlice) != 0 { - errs = errs.Also(apis.ErrInvalidValue(strings.Join(errSlice, ","), "name")) - } + errs = errs.Also(ValidateParameters(ctx, ref.Params)) + } + case ref.Name != "": + // Ref name must be a valid k8s name + if errSlice := validation.IsQualifiedName(ref.Name); len(errSlice) != 0 { + errs = errs.Also(apis.ErrInvalidValue(strings.Join(errSlice, ","), "name")) } default: errs = errs.Also(apis.ErrMissingField("name")) } return errs } - -// Validate ensures that a supplied Ref field is populated -// correctly. No errors are returned for a nil Ref. -func (ref *Ref) Validate(ctx context.Context) (errs *apis.FieldError) { - if ref == nil { - return errs - } - return validateRef(ctx, ref.Name, ref.Resolver, ref.Params) -} - -// RefNameLikeUrl checks if the name is url parsable and returns an error if it isn't. -func RefNameLikeUrl(name string) error { - schemeRegex := regexp.MustCompile(`[\w-]+:\/\/*`) - if !schemeRegex.MatchString(name) { - return errors.New("invalid URI for request") - } - return nil -} diff --git a/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/openapi_generated.go b/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/openapi_generated.go index 6a06a0867..d938565b8 100644 --- a/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/openapi_generated.go +++ b/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/openapi_generated.go @@ -87,9 +87,6 @@ func GetOpenAPIDefinitions(ref common.ReferenceCallback) map[string]common.OpenA "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.SidecarState": schema_pkg_apis_pipeline_v1beta1_SidecarState(ref), "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.SkippedTask": schema_pkg_apis_pipeline_v1beta1_SkippedTask(ref), "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.Step": schema_pkg_apis_pipeline_v1beta1_Step(ref), - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.StepAction": schema_pkg_apis_pipeline_v1beta1_StepAction(ref), - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.StepActionList": schema_pkg_apis_pipeline_v1beta1_StepActionList(ref), - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.StepActionSpec": schema_pkg_apis_pipeline_v1beta1_StepActionSpec(ref), "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.StepOutputConfig": schema_pkg_apis_pipeline_v1beta1_StepOutputConfig(ref), "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.StepState": schema_pkg_apis_pipeline_v1beta1_StepState(ref), "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.StepTemplate": schema_pkg_apis_pipeline_v1beta1_StepTemplate(ref), @@ -4091,266 +4088,6 @@ func schema_pkg_apis_pipeline_v1beta1_Step(ref common.ReferenceCallback) common. } } -func schema_pkg_apis_pipeline_v1beta1_StepAction(ref common.ReferenceCallback) common.OpenAPIDefinition { - return common.OpenAPIDefinition{ - Schema: spec.Schema{ - SchemaProps: spec.SchemaProps{ - Description: "StepAction represents the actionable components of Step. The Step can only reference it from the cluster or using remote resolution.", - Type: []string{"object"}, - Properties: map[string]spec.Schema{ - "kind": { - SchemaProps: spec.SchemaProps{ - Description: "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", - Type: []string{"string"}, - Format: "", - }, - }, - "apiVersion": { - SchemaProps: spec.SchemaProps{ - Description: "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", - Type: []string{"string"}, - Format: "", - }, - }, - "metadata": { - SchemaProps: spec.SchemaProps{ - Default: map[string]interface{}{}, - Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta"), - }, - }, - "spec": { - SchemaProps: spec.SchemaProps{ - Description: "Spec holds the desired state of the Step from the client", - Default: map[string]interface{}{}, - Ref: ref("github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.StepActionSpec"), - }, - }, - }, - }, - }, - Dependencies: []string{ - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.StepActionSpec", "k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta"}, - } -} - -func schema_pkg_apis_pipeline_v1beta1_StepActionList(ref common.ReferenceCallback) common.OpenAPIDefinition { - return common.OpenAPIDefinition{ - Schema: spec.Schema{ - SchemaProps: spec.SchemaProps{ - Description: "StepActionList contains a list of StepActions", - Type: []string{"object"}, - Properties: map[string]spec.Schema{ - "kind": { - SchemaProps: spec.SchemaProps{ - Description: "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", - Type: []string{"string"}, - Format: "", - }, - }, - "apiVersion": { - SchemaProps: spec.SchemaProps{ - Description: "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", - Type: []string{"string"}, - Format: "", - }, - }, - "metadata": { - SchemaProps: spec.SchemaProps{ - Default: map[string]interface{}{}, - Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.ListMeta"), - }, - }, - "items": { - SchemaProps: spec.SchemaProps{ - Type: []string{"array"}, - Items: &spec.SchemaOrArray{ - Schema: &spec.Schema{ - SchemaProps: spec.SchemaProps{ - Default: map[string]interface{}{}, - Ref: ref("github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.StepAction"), - }, - }, - }, - }, - }, - }, - Required: []string{"items"}, - }, - }, - Dependencies: []string{ - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1.StepAction", "k8s.io/apimachinery/pkg/apis/meta/v1.ListMeta"}, - } -} - -func schema_pkg_apis_pipeline_v1beta1_StepActionSpec(ref common.ReferenceCallback) common.OpenAPIDefinition { - return common.OpenAPIDefinition{ - Schema: spec.Schema{ - SchemaProps: spec.SchemaProps{ - Description: "StepActionSpec contains the actionable components of a step.", - Type: []string{"object"}, - Properties: map[string]spec.Schema{ - "description": { - SchemaProps: spec.SchemaProps{ - Description: "Description is a user-facing description of the stepaction that may be used to populate a UI.", - Type: []string{"string"}, - Format: "", - }, - }, - "image": { - SchemaProps: spec.SchemaProps{ - Description: "Image reference name to run for this StepAction. More info: https://kubernetes.io/docs/concepts/containers/images", - Type: []string{"string"}, - Format: "", - }, - }, - "command": { - VendorExtensible: spec.VendorExtensible{ - Extensions: spec.Extensions{ - "x-kubernetes-list-type": "atomic", - }, - }, - SchemaProps: spec.SchemaProps{ - Description: "Entrypoint array. Not executed within a shell. The image's ENTRYPOINT is used if this is not provided. Variable references $(VAR_NAME) are expanded using the container's environment. If a variable cannot be resolved, the reference in the input string will be unchanged. Double $$ are reduced to a single $, which allows for escaping the $(VAR_NAME) syntax: i.e. \"$$(VAR_NAME)\" will produce the string literal \"$(VAR_NAME)\". Escaped references will never be expanded, regardless of whether the variable exists or not. Cannot be updated. More info: https://kubernetes.io/docs/tasks/inject-data-application/define-command-argument-container/#running-a-command-in-a-shell", - Type: []string{"array"}, - Items: &spec.SchemaOrArray{ - Schema: &spec.Schema{ - SchemaProps: spec.SchemaProps{ - Default: "", - Type: []string{"string"}, - Format: "", - }, - }, - }, - }, - }, - "args": { - VendorExtensible: spec.VendorExtensible{ - Extensions: spec.Extensions{ - "x-kubernetes-list-type": "atomic", - }, - }, - SchemaProps: spec.SchemaProps{ - Description: "Arguments to the entrypoint. The image's CMD is used if this is not provided. Variable references $(VAR_NAME) are expanded using the container's environment. If a variable cannot be resolved, the reference in the input string will be unchanged. Double $$ are reduced to a single $, which allows for escaping the $(VAR_NAME) syntax: i.e. \"$$(VAR_NAME)\" will produce the string literal \"$(VAR_NAME)\". Escaped references will never be expanded, regardless of whether the variable exists or not. Cannot be updated. More info: https://kubernetes.io/docs/tasks/inject-data-application/define-command-argument-container/#running-a-command-in-a-shell", - Type: []string{"array"}, - Items: &spec.SchemaOrArray{ - Schema: &spec.Schema{ - SchemaProps: spec.SchemaProps{ - Default: "", - Type: []string{"string"}, - Format: "", - }, - }, - }, - }, - }, - "env": { - VendorExtensible: spec.VendorExtensible{ - Extensions: spec.Extensions{ - "x-kubernetes-list-type": "atomic", - "x-kubernetes-patch-merge-key": "name", - "x-kubernetes-patch-strategy": "merge", - }, - }, - SchemaProps: spec.SchemaProps{ - Description: "List of environment variables to set in the container. Cannot be updated.", - Type: []string{"array"}, - Items: &spec.SchemaOrArray{ - Schema: &spec.Schema{ - SchemaProps: spec.SchemaProps{ - Default: map[string]interface{}{}, - Ref: ref("k8s.io/api/core/v1.EnvVar"), - }, - }, - }, - }, - }, - "script": { - SchemaProps: spec.SchemaProps{ - Description: "Script is the contents of an executable file to execute.\n\nIf Script is not empty, the Step cannot have an Command and the Args will be passed to the Script.", - Type: []string{"string"}, - Format: "", - }, - }, - "workingDir": { - SchemaProps: spec.SchemaProps{ - Description: "Step's working directory. If not specified, the container runtime's default will be used, which might be configured in the container image. Cannot be updated.", - Type: []string{"string"}, - Format: "", - }, - }, - "params": { - VendorExtensible: spec.VendorExtensible{ - Extensions: spec.Extensions{ - "x-kubernetes-list-type": "atomic", - }, - }, - SchemaProps: spec.SchemaProps{ - Description: "Params is a list of input parameters required to run the stepAction. Params must be supplied as inputs in Steps unless they declare a defaultvalue.", - Type: []string{"array"}, - Items: &spec.SchemaOrArray{ - Schema: &spec.Schema{ - SchemaProps: spec.SchemaProps{ - Default: map[string]interface{}{}, - Ref: ref("github.com/tektoncd/pipeline/pkg/apis/pipeline/v1.ParamSpec"), - }, - }, - }, - }, - }, - "results": { - VendorExtensible: spec.VendorExtensible{ - Extensions: spec.Extensions{ - "x-kubernetes-list-type": "atomic", - }, - }, - SchemaProps: spec.SchemaProps{ - Description: "Results are values that this StepAction can output", - Type: []string{"array"}, - Items: &spec.SchemaOrArray{ - Schema: &spec.Schema{ - SchemaProps: spec.SchemaProps{ - Default: map[string]interface{}{}, - Ref: ref("github.com/tektoncd/pipeline/pkg/apis/pipeline/v1.StepResult"), - }, - }, - }, - }, - }, - "securityContext": { - SchemaProps: spec.SchemaProps{ - Description: "SecurityContext defines the security options the Step should be run with. If set, the fields of SecurityContext override the equivalent fields of PodSecurityContext. More info: https://kubernetes.io/docs/tasks/configure-pod-container/security-context/ The value set in StepAction will take precedence over the value from Task.", - Ref: ref("k8s.io/api/core/v1.SecurityContext"), - }, - }, - "volumeMounts": { - VendorExtensible: spec.VendorExtensible{ - Extensions: spec.Extensions{ - "x-kubernetes-list-type": "atomic", - "x-kubernetes-patch-merge-key": "mountPath", - "x-kubernetes-patch-strategy": "merge", - }, - }, - SchemaProps: spec.SchemaProps{ - Description: "Volumes to mount into the Step's filesystem. Cannot be updated.", - Type: []string{"array"}, - Items: &spec.SchemaOrArray{ - Schema: &spec.Schema{ - SchemaProps: spec.SchemaProps{ - Default: map[string]interface{}{}, - Ref: ref("k8s.io/api/core/v1.VolumeMount"), - }, - }, - }, - }, - }, - }, - }, - }, - Dependencies: []string{ - "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1.ParamSpec", "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1.StepResult", "k8s.io/api/core/v1.EnvVar", "k8s.io/api/core/v1.SecurityContext", "k8s.io/api/core/v1.VolumeMount"}, - } -} - func schema_pkg_apis_pipeline_v1beta1_StepOutputConfig(ref common.ReferenceCallback) common.OpenAPIDefinition { return common.OpenAPIDefinition{ Schema: spec.Schema{ @@ -6560,13 +6297,6 @@ func schema_pkg_apis_resolution_v1beta1_ResolutionRequestSpec(ref common.Referen }, }, }, - "url": { - SchemaProps: spec.SchemaProps{ - Description: "URL is the runtime url passed to the resolver to help it figure out how to resolver the resource being requested. This is currently at an ALPHA stability level and subject to alpha API compatibility policies.", - Type: []string{"string"}, - Format: "", - }, - }, }, }, }, diff --git a/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/pipeline_validation.go b/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/pipeline_validation.go index 0a5f2ec38..f1c34eee5 100644 --- a/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/pipeline_validation.go +++ b/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/pipeline_validation.go @@ -153,10 +153,10 @@ func (l PipelineTaskList) Validate(ctx context.Context, taskNames sets.String, p } // validateUsageOfDeclaredPipelineTaskParameters validates that all parameters referenced in the pipeline Task are declared by the pipeline Task. -func (l PipelineTaskList) validateUsageOfDeclaredPipelineTaskParameters(ctx context.Context, additionalParams []ParamSpec, path string) (errs *apis.FieldError) { +func (l PipelineTaskList) validateUsageOfDeclaredPipelineTaskParameters(ctx context.Context, path string) (errs *apis.FieldError) { for i, t := range l { if t.TaskSpec != nil { - errs = errs.Also(ValidateUsageOfDeclaredParameters(ctx, t.TaskSpec.Steps, append(t.TaskSpec.Params, additionalParams...)).ViaFieldIndex(path, i)) + errs = errs.Also(ValidateUsageOfDeclaredParameters(ctx, t.TaskSpec.Steps, t.TaskSpec.Params).ViaFieldIndex(path, i)) } } return errs @@ -403,8 +403,8 @@ func validatePipelineWorkspacesDeclarations(wss []PipelineWorkspaceDeclaration) // validatePipelineParameterUsage validates that parameters referenced in the Pipeline are declared by the Pipeline func (ps *PipelineSpec) validatePipelineParameterUsage(ctx context.Context) (errs *apis.FieldError) { - errs = errs.Also(PipelineTaskList(ps.Tasks).validateUsageOfDeclaredPipelineTaskParameters(ctx, ps.Params, "tasks")) - errs = errs.Also(PipelineTaskList(ps.Finally).validateUsageOfDeclaredPipelineTaskParameters(ctx, ps.Params, "finally")) + errs = errs.Also(PipelineTaskList(ps.Tasks).validateUsageOfDeclaredPipelineTaskParameters(ctx, "tasks")) + errs = errs.Also(PipelineTaskList(ps.Finally).validateUsageOfDeclaredPipelineTaskParameters(ctx, "finally")) errs = errs.Also(validatePipelineTaskParameterUsage(ps.Tasks, ps.Params).ViaField("tasks")) errs = errs.Also(validatePipelineTaskParameterUsage(ps.Finally, ps.Params).ViaField("finally")) return errs diff --git a/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/pipelineref_validation.go b/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/pipelineref_validation.go index b57801125..a0b7e02f1 100644 --- a/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/pipelineref_validation.go +++ b/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/pipelineref_validation.go @@ -19,11 +19,9 @@ package v1beta1 import ( "context" "fmt" - "strings" "github.com/google/go-containerregistry/pkg/name" "github.com/tektoncd/pipeline/pkg/apis/config" - "k8s.io/apimachinery/pkg/util/validation" "knative.dev/pkg/apis" ) @@ -33,8 +31,17 @@ func (ref *PipelineRef) Validate(ctx context.Context) (errs *apis.FieldError) { if ref == nil { return errs } - switch { - case ref.Resolver != "" || ref.Params != nil: + + if ref.Resolver != "" || ref.Params != nil { + if ref.Resolver != "" { + errs = errs.Also(config.ValidateEnabledAPIFields(ctx, "resolver", config.BetaAPIFields).ViaField("resolver")) + if ref.Name != "" { + errs = errs.Also(apis.ErrMultipleOneOf("name", "resolver")) + } + if ref.Bundle != "" { + errs = errs.Also(apis.ErrMultipleOneOf("bundle", "resolver")) + } + } if ref.Params != nil { errs = errs.Also(config.ValidateEnabledAPIFields(ctx, "resolver params", config.BetaAPIFields).ViaField("params")) if ref.Name != "" { @@ -48,52 +55,16 @@ func (ref *PipelineRef) Validate(ctx context.Context) (errs *apis.FieldError) { } errs = errs.Also(ValidateParameters(ctx, ref.Params)) } - if ref.Resolver != "" { - errs = errs.Also(config.ValidateEnabledAPIFields(ctx, "resolver", config.BetaAPIFields).ViaField("resolver")) - if ref.Name != "" { - // make sure that the name is url-like. - err := RefNameLikeUrl(ref.Name) - if err == nil && !config.FromContextOrDefaults(ctx).FeatureFlags.EnableConciseResolverSyntax { - // If name is url-like then concise resolver syntax must be enabled - errs = errs.Also(apis.ErrGeneric(fmt.Sprintf("feature flag %s should be set to true to use concise resolver syntax", config.EnableConciseResolverSyntax), "")) - } - if err != nil { - errs = errs.Also(apis.ErrInvalidValue(err, "name")) - } - } - if ref.Bundle != "" { - errs = errs.Also(apis.ErrMultipleOneOf("bundle", "resolver")) - } - } - case ref.Bundle != "": + } else { if ref.Name == "" { errs = errs.Also(apis.ErrMissingField("name")) } - errs = errs.Also(validateBundleFeatureFlag(ctx, "bundle", true).ViaField("bundle")) - if _, err := name.ParseReference(ref.Bundle); err != nil { - errs = errs.Also(apis.ErrInvalidValue("invalid bundle reference", "bundle", err.Error())) - } - case ref.Name != "": - // ref name can be a Url-like format. - if err := RefNameLikeUrl(ref.Name); err == nil { - // If name is url-like then concise resolver syntax must be enabled - if !config.FromContextOrDefaults(ctx).FeatureFlags.EnableConciseResolverSyntax { - errs = errs.Also(apis.ErrGeneric(fmt.Sprintf("feature flag %s should be set to true to use concise resolver syntax", config.EnableConciseResolverSyntax), "")) - } - // In stage1 of concise remote resolvers syntax, this is a required field. - // TODO: remove this check when implementing stage 2 where this is optional. - if ref.Resolver == "" { - errs = errs.Also(apis.ErrMissingField("resolver")) - } - // Or, it must be a valid k8s name - } else { - // ref name must be a valid k8s name - if errSlice := validation.IsQualifiedName(ref.Name); len(errSlice) != 0 { - errs = errs.Also(apis.ErrInvalidValue(strings.Join(errSlice, ","), "name")) + if ref.Bundle != "" { + errs = errs.Also(validateBundleFeatureFlag(ctx, "bundle", true).ViaField("bundle")) + if _, err := name.ParseReference(ref.Bundle); err != nil { + errs = errs.Also(apis.ErrInvalidValue("invalid bundle reference", "bundle", err.Error())) } } - default: - errs = errs.Also(apis.ErrMissingField("name")) } return //nolint:nakedret } diff --git a/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/register.go b/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/register.go index c33fa8a84..6154ae5da 100644 --- a/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/register.go +++ b/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/register.go @@ -58,8 +58,6 @@ func addKnownTypes(scheme *runtime.Scheme) error { &PipelineRunList{}, &CustomRun{}, &CustomRunList{}, - &StepAction{}, - &StepActionList{}, ) // &Condition{}, // &ConditionList{}, diff --git a/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/stepaction_conversion.go b/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/stepaction_conversion.go deleted file mode 100644 index 6d8afd26f..000000000 --- a/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/stepaction_conversion.go +++ /dev/null @@ -1,42 +0,0 @@ -/* -Copyright 2023 The Tekton 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 v1beta1 - -import ( - "context" - - "knative.dev/pkg/apis" -) - -var _ apis.Convertible = (*StepAction)(nil) - -// ConvertTo implements apis.Convertible -func (s *StepAction) ConvertTo(ctx context.Context, to apis.Convertible) error { - return nil -} - -// ConvertTo implements apis.Convertible -func (ss *StepActionSpec) ConvertTo(ctx context.Context, sink *StepActionSpec) error { - return nil -} - -// ConvertFrom implements apis.Convertible -func (s *StepAction) ConvertFrom(ctx context.Context, from apis.Convertible) error { - return nil -} - -// ConvertFrom implements apis.Convertible -func (ss *StepActionSpec) ConvertFrom(ctx context.Context, source *StepActionSpec) error { - return nil -} diff --git a/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/stepaction_types.go b/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/stepaction_types.go deleted file mode 100644 index 495c9ee01..000000000 --- a/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/stepaction_types.go +++ /dev/null @@ -1,170 +0,0 @@ -/* -Copyright 2023 The Tekton 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 v1beta1 - -import ( - v1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1" - corev1 "k8s.io/api/core/v1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/runtime/schema" - "knative.dev/pkg/apis" - "knative.dev/pkg/kmeta" -) - -// +genclient -// +genclient:noStatus -// +genreconciler:krshapedlogic=false -// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object - -// StepAction represents the actionable components of Step. -// The Step can only reference it from the cluster or using remote resolution. -// -// +k8s:openapi-gen=true -type StepAction struct { - metav1.TypeMeta `json:",inline"` - // +optional - metav1.ObjectMeta `json:"metadata"` - - // Spec holds the desired state of the Step from the client - // +optional - Spec StepActionSpec `json:"spec"` -} - -var _ kmeta.OwnerRefable = (*StepAction)(nil) - -// StepAction returns the step action's spec -func (s *StepAction) StepActionSpec() StepActionSpec { - return s.Spec -} - -// StepActionMetadata returns the step action's ObjectMeta -func (s *StepAction) StepActionMetadata() metav1.ObjectMeta { - return s.ObjectMeta -} - -// Copy returns a deep copy of the stepaction -func (s *StepAction) Copy() StepActionObject { - return s.DeepCopy() -} - -// GetGroupVersionKind implements kmeta.OwnerRefable. -func (*StepAction) GetGroupVersionKind() schema.GroupVersionKind { - return SchemeGroupVersion.WithKind("StepAction") -} - -// StepActionList contains a list of StepActions -// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object -type StepActionList struct { - metav1.TypeMeta `json:",inline"` - // +optional - metav1.ListMeta `json:"metadata,omitempty"` - Items []StepAction `json:"items"` -} - -// StepActionSpec contains the actionable components of a step. -type StepActionSpec struct { - // Description is a user-facing description of the stepaction that may be - // used to populate a UI. - // +optional - Description string `json:"description,omitempty"` - // Image reference name to run for this StepAction. - // More info: https://kubernetes.io/docs/concepts/containers/images - // +optional - Image string `json:"image,omitempty" protobuf:"bytes,2,opt,name=image"` - // Entrypoint array. Not executed within a shell. - // The image's ENTRYPOINT is used if this is not provided. - // Variable references $(VAR_NAME) are expanded using the container's environment. If a variable - // cannot be resolved, the reference in the input string will be unchanged. Double $$ are reduced - // to a single $, which allows for escaping the $(VAR_NAME) syntax: i.e. "$$(VAR_NAME)" will - // produce the string literal "$(VAR_NAME)". Escaped references will never be expanded, regardless - // of whether the variable exists or not. Cannot be updated. - // More info: https://kubernetes.io/docs/tasks/inject-data-application/define-command-argument-container/#running-a-command-in-a-shell - // +optional - // +listType=atomic - Command []string `json:"command,omitempty" protobuf:"bytes,3,rep,name=command"` - // Arguments to the entrypoint. - // The image's CMD is used if this is not provided. - // Variable references $(VAR_NAME) are expanded using the container's environment. If a variable - // cannot be resolved, the reference in the input string will be unchanged. Double $$ are reduced - // to a single $, which allows for escaping the $(VAR_NAME) syntax: i.e. "$$(VAR_NAME)" will - // produce the string literal "$(VAR_NAME)". Escaped references will never be expanded, regardless - // of whether the variable exists or not. Cannot be updated. - // More info: https://kubernetes.io/docs/tasks/inject-data-application/define-command-argument-container/#running-a-command-in-a-shell - // +optional - // +listType=atomic - Args []string `json:"args,omitempty" protobuf:"bytes,4,rep,name=args"` - // List of environment variables to set in the container. - // Cannot be updated. - // +optional - // +patchMergeKey=name - // +patchStrategy=merge - // +listType=atomic - Env []corev1.EnvVar `json:"env,omitempty" patchMergeKey:"name" patchStrategy:"merge" protobuf:"bytes,7,rep,name=env"` - // Script is the contents of an executable file to execute. - // - // If Script is not empty, the Step cannot have an Command and the Args will be passed to the Script. - // +optional - Script string `json:"script,omitempty"` - // Step's working directory. - // If not specified, the container runtime's default will be used, which - // might be configured in the container image. - // Cannot be updated. - // +optional - WorkingDir string `json:"workingDir,omitempty" protobuf:"bytes,5,opt,name=workingDir"` - // Params is a list of input parameters required to run the stepAction. - // Params must be supplied as inputs in Steps unless they declare a defaultvalue. - // +optional - // +listType=atomic - Params v1.ParamSpecs `json:"params,omitempty"` - // Results are values that this StepAction can output - // +optional - // +listType=atomic - Results []v1.StepResult `json:"results,omitempty"` - // SecurityContext defines the security options the Step should be run with. - // If set, the fields of SecurityContext override the equivalent fields of PodSecurityContext. - // More info: https://kubernetes.io/docs/tasks/configure-pod-container/security-context/ - // The value set in StepAction will take precedence over the value from Task. - // +optional - SecurityContext *corev1.SecurityContext `json:"securityContext,omitempty" protobuf:"bytes,15,opt,name=securityContext"` - // Volumes to mount into the Step's filesystem. - // Cannot be updated. - // +optional - // +patchMergeKey=mountPath - // +patchStrategy=merge - // +listType=atomic - VolumeMounts []corev1.VolumeMount `json:"volumeMounts,omitempty" patchMergeKey:"mountPath" patchStrategy:"merge" protobuf:"bytes,9,rep,name=volumeMounts"` -} - -// ToStep converts the StepActionSpec to a Step struct -func (ss *StepActionSpec) ToStep() *v1.Step { - return &v1.Step{ - Image: ss.Image, - Command: ss.Command, - Args: ss.Args, - WorkingDir: ss.WorkingDir, - Script: ss.Script, - Env: ss.Env, - VolumeMounts: ss.VolumeMounts, - SecurityContext: ss.SecurityContext, - Results: ss.Results, - } -} - -// StepActionObject is implemented by StepAction -type StepActionObject interface { - apis.Defaultable - StepActionMetadata() metav1.ObjectMeta - StepActionSpec() StepActionSpec - Copy() StepActionObject -} diff --git a/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/stepaction_validation.go b/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/stepaction_validation.go deleted file mode 100644 index 0955c7e4f..000000000 --- a/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/stepaction_validation.go +++ /dev/null @@ -1,209 +0,0 @@ -/* -Copyright 2023 The Tekton 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 v1beta1 - -import ( - "context" - "strings" - - "github.com/tektoncd/pipeline/pkg/apis/config" - v1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1" - "github.com/tektoncd/pipeline/pkg/apis/validate" - "github.com/tektoncd/pipeline/pkg/substitution" - admissionregistrationv1 "k8s.io/api/admissionregistration/v1" - corev1 "k8s.io/api/core/v1" - "k8s.io/apimachinery/pkg/util/sets" - "knative.dev/pkg/apis" - "knative.dev/pkg/webhook/resourcesemantics" -) - -var ( - _ apis.Validatable = (*StepAction)(nil) - _ resourcesemantics.VerbLimited = (*StepAction)(nil) -) - -// SupportedVerbs returns the operations that validation should be called for -func (s *StepAction) SupportedVerbs() []admissionregistrationv1.OperationType { - return []admissionregistrationv1.OperationType{admissionregistrationv1.Create, admissionregistrationv1.Update} -} - -// Validate implements apis.Validatable -func (s *StepAction) Validate(ctx context.Context) (errs *apis.FieldError) { - errs = validate.ObjectMetadata(s.GetObjectMeta()).ViaField("metadata") - errs = errs.Also(s.Spec.Validate(apis.WithinSpec(ctx)).ViaField("spec")) - return errs -} - -// Validate implements apis.Validatable -func (ss *StepActionSpec) Validate(ctx context.Context) (errs *apis.FieldError) { - if ss.Image == "" { - errs = errs.Also(apis.ErrMissingField("Image")) - } - - if ss.Script != "" { - if len(ss.Command) > 0 { - errs = errs.Also(&apis.FieldError{ - Message: "script cannot be used with command", - Paths: []string{"script"}, - }) - } - - cleaned := strings.TrimSpace(ss.Script) - if strings.HasPrefix(cleaned, "#!win") { - errs = errs.Also(config.ValidateEnabledAPIFields(ctx, "windows script support", config.AlphaAPIFields).ViaField("script")) - } - errs = errs.Also(validateNoParamSubstitutionsInScript(ss.Script)) - } - errs = errs.Also(validateUsageOfDeclaredParameters(ctx, *ss)) - errs = errs.Also(v1.ValidateParameterTypes(ctx, ss.Params).ViaField("params")) - errs = errs.Also(validateParameterVariables(ctx, *ss, ss.Params)) - errs = errs.Also(v1.ValidateStepResultsVariables(ctx, ss.Results, ss.Script)) - errs = errs.Also(v1.ValidateStepResults(ctx, ss.Results).ViaField("results")) - errs = errs.Also(validateVolumeMounts(ss.VolumeMounts, ss.Params).ViaField("volumeMounts")) - return errs -} - -// validateNoParamSubstitutionsInScript validates that param substitutions are not invoked in the script -func validateNoParamSubstitutionsInScript(script string) *apis.FieldError { - _, present, errString := substitution.ExtractVariablesFromString(script, "params") - if errString != "" || present { - return &apis.FieldError{ - Message: "param substitution in scripts is not allowed.", - Paths: []string{"script"}, - } - } - return nil -} - -// validateUsageOfDeclaredParameters validates that all parameters referenced in the Task are declared by the Task. -func validateUsageOfDeclaredParameters(ctx context.Context, sas StepActionSpec) *apis.FieldError { - params := sas.Params - var errs *apis.FieldError - _, _, objectParams := params.SortByType() - allParameterNames := sets.NewString(params.GetNames()...) - errs = errs.Also(validateStepActionVariables(ctx, sas, "params", allParameterNames)) - errs = errs.Also(ValidateObjectUsage(ctx, sas, objectParams)) - errs = errs.Also(v1.ValidateObjectParamsHaveProperties(ctx, params)) - return errs -} - -func validateVolumeMounts(volumeMounts []corev1.VolumeMount, params v1.ParamSpecs) (errs *apis.FieldError) { - if len(volumeMounts) == 0 { - return - } - paramNames := sets.String{} - for _, p := range params { - paramNames.Insert(p.Name) - } - for idx, v := range volumeMounts { - matches, _ := substitution.ExtractVariableExpressions(v.Name, "params") - if len(matches) != 1 { - errs = errs.Also(apis.ErrInvalidValue(v.Name, "name", "expect the Name to be a single param reference").ViaIndex(idx)) - return errs - } else if matches[0] != v.Name { - errs = errs.Also(apis.ErrInvalidValue(v.Name, "name", "expect the Name to be a single param reference").ViaIndex(idx)) - return errs - } - errs = errs.Also(substitution.ValidateNoReferencesToUnknownVariables(v.Name, "params", paramNames).ViaIndex(idx)) - } - return errs -} - -// validateParameterVariables validates all variables within a slice of ParamSpecs against a StepAction -func validateParameterVariables(ctx context.Context, sas StepActionSpec, params v1.ParamSpecs) *apis.FieldError { - var errs *apis.FieldError - errs = errs.Also(params.ValidateNoDuplicateNames()) - stringParams, arrayParams, objectParams := params.SortByType() - stringParameterNames := sets.NewString(stringParams.GetNames()...) - arrayParameterNames := sets.NewString(arrayParams.GetNames()...) - errs = errs.Also(v1.ValidateNameFormat(stringParameterNames.Insert(arrayParameterNames.List()...), objectParams)) - return errs.Also(validateStepActionArrayUsage(sas, "params", arrayParameterNames)) -} - -// ValidateObjectUsage validates the usage of individual attributes of an object param and the usage of the entire object -func ValidateObjectUsage(ctx context.Context, sas StepActionSpec, params v1.ParamSpecs) (errs *apis.FieldError) { - objectParameterNames := sets.NewString() - for _, p := range params { - // collect all names of object type params - objectParameterNames.Insert(p.Name) - - // collect all keys for this object param - objectKeys := sets.NewString() - for key := range p.Properties { - objectKeys.Insert(key) - } - - // check if the object's key names are referenced correctly i.e. param.objectParam.key1 - errs = errs.Also(validateStepActionVariables(ctx, sas, "params\\."+p.Name, objectKeys)) - } - - return errs.Also(validateStepActionObjectUsageAsWhole(sas, "params", objectParameterNames)) -} - -// validateStepActionObjectUsageAsWhole returns an error if the StepAction contains references to the entire input object params in fields where these references are prohibited -func validateStepActionObjectUsageAsWhole(sas StepActionSpec, prefix string, vars sets.String) *apis.FieldError { - errs := substitution.ValidateNoReferencesToEntireProhibitedVariables(sas.Image, prefix, vars).ViaField("image") - errs = errs.Also(substitution.ValidateNoReferencesToEntireProhibitedVariables(sas.Script, prefix, vars).ViaField("script")) - for i, cmd := range sas.Command { - errs = errs.Also(substitution.ValidateNoReferencesToEntireProhibitedVariables(cmd, prefix, vars).ViaFieldIndex("command", i)) - } - for i, arg := range sas.Args { - errs = errs.Also(substitution.ValidateNoReferencesToEntireProhibitedVariables(arg, prefix, vars).ViaFieldIndex("args", i)) - } - for _, env := range sas.Env { - errs = errs.Also(substitution.ValidateNoReferencesToEntireProhibitedVariables(env.Value, prefix, vars).ViaFieldKey("env", env.Name)) - } - for i, vm := range sas.VolumeMounts { - errs = errs.Also(substitution.ValidateNoReferencesToEntireProhibitedVariables(vm.Name, prefix, vars).ViaFieldIndex("volumeMounts", i)) - } - return errs -} - -// validateStepActionArrayUsage returns an error if the Step contains references to the input array params in fields where these references are prohibited -func validateStepActionArrayUsage(sas StepActionSpec, prefix string, arrayParamNames sets.String) *apis.FieldError { - errs := substitution.ValidateNoReferencesToProhibitedVariables(sas.Image, prefix, arrayParamNames).ViaField("image") - errs = errs.Also(substitution.ValidateNoReferencesToProhibitedVariables(sas.Script, prefix, arrayParamNames).ViaField("script")) - for i, cmd := range sas.Command { - errs = errs.Also(substitution.ValidateVariableReferenceIsIsolated(cmd, prefix, arrayParamNames).ViaFieldIndex("command", i)) - } - for i, arg := range sas.Args { - errs = errs.Also(substitution.ValidateVariableReferenceIsIsolated(arg, prefix, arrayParamNames).ViaFieldIndex("args", i)) - } - for _, env := range sas.Env { - errs = errs.Also(substitution.ValidateNoReferencesToProhibitedVariables(env.Value, prefix, arrayParamNames).ViaFieldKey("env", env.Name)) - } - for i, vm := range sas.VolumeMounts { - errs = errs.Also(substitution.ValidateNoReferencesToProhibitedVariables(vm.Name, prefix, arrayParamNames).ViaFieldIndex("volumeMounts", i)) - } - return errs -} - -// validateStepActionVariables returns an error if the StepAction contains references to any unknown variables -func validateStepActionVariables(ctx context.Context, sas StepActionSpec, prefix string, vars sets.String) *apis.FieldError { - errs := substitution.ValidateNoReferencesToUnknownVariables(sas.Image, prefix, vars).ViaField("image") - errs = errs.Also(substitution.ValidateNoReferencesToUnknownVariables(sas.Script, prefix, vars).ViaField("script")) - for i, cmd := range sas.Command { - errs = errs.Also(substitution.ValidateNoReferencesToUnknownVariables(cmd, prefix, vars).ViaFieldIndex("command", i)) - } - for i, arg := range sas.Args { - errs = errs.Also(substitution.ValidateNoReferencesToUnknownVariables(arg, prefix, vars).ViaFieldIndex("args", i)) - } - for _, env := range sas.Env { - errs = errs.Also(substitution.ValidateNoReferencesToUnknownVariables(env.Value, prefix, vars).ViaFieldKey("env", env.Name)) - } - for i, vm := range sas.VolumeMounts { - errs = errs.Also(substitution.ValidateNoReferencesToUnknownVariables(vm.Name, prefix, vars).ViaFieldIndex("volumeMounts", i)) - } - return errs -} diff --git a/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/swagger.json b/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/swagger.json index 91cf8fe17..622b1d680 100644 --- a/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/swagger.json +++ b/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/swagger.json @@ -1722,10 +1722,6 @@ "$ref": "#/definitions/v1.Param" }, "x-kubernetes-list-type": "atomic" - }, - "url": { - "description": "URL is the runtime url passed to the resolver to help it figure out how to resolver the resource being requested. This is currently at an ALPHA stability level and subject to alpha API compatibility policies.", - "type": "string" } } }, @@ -2259,141 +2255,6 @@ } } }, - "v1beta1.StepAction": { - "description": "StepAction represents the actionable components of Step. The Step can only reference it from the cluster or using remote resolution.", - "type": "object", - "properties": { - "apiVersion": { - "description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", - "type": "string" - }, - "kind": { - "description": "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", - "type": "string" - }, - "metadata": { - "default": {}, - "$ref": "#/definitions/v1.ObjectMeta" - }, - "spec": { - "description": "Spec holds the desired state of the Step from the client", - "default": {}, - "$ref": "#/definitions/v1beta1.StepActionSpec" - } - } - }, - "v1beta1.StepActionList": { - "description": "StepActionList contains a list of StepActions", - "type": "object", - "required": [ - "items" - ], - "properties": { - "apiVersion": { - "description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources", - "type": "string" - }, - "items": { - "type": "array", - "items": { - "default": {}, - "$ref": "#/definitions/v1beta1.StepAction" - } - }, - "kind": { - "description": "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds", - "type": "string" - }, - "metadata": { - "default": {}, - "$ref": "#/definitions/v1.ListMeta" - } - } - }, - "v1beta1.StepActionSpec": { - "description": "StepActionSpec contains the actionable components of a step.", - "type": "object", - "properties": { - "args": { - "description": "Arguments to the entrypoint. The image's CMD is used if this is not provided. Variable references $(VAR_NAME) are expanded using the container's environment. If a variable cannot be resolved, the reference in the input string will be unchanged. Double $$ are reduced to a single $, which allows for escaping the $(VAR_NAME) syntax: i.e. \"$$(VAR_NAME)\" will produce the string literal \"$(VAR_NAME)\". Escaped references will never be expanded, regardless of whether the variable exists or not. Cannot be updated. More info: https://kubernetes.io/docs/tasks/inject-data-application/define-command-argument-container/#running-a-command-in-a-shell", - "type": "array", - "items": { - "type": "string", - "default": "" - }, - "x-kubernetes-list-type": "atomic" - }, - "command": { - "description": "Entrypoint array. Not executed within a shell. The image's ENTRYPOINT is used if this is not provided. Variable references $(VAR_NAME) are expanded using the container's environment. If a variable cannot be resolved, the reference in the input string will be unchanged. Double $$ are reduced to a single $, which allows for escaping the $(VAR_NAME) syntax: i.e. \"$$(VAR_NAME)\" will produce the string literal \"$(VAR_NAME)\". Escaped references will never be expanded, regardless of whether the variable exists or not. Cannot be updated. More info: https://kubernetes.io/docs/tasks/inject-data-application/define-command-argument-container/#running-a-command-in-a-shell", - "type": "array", - "items": { - "type": "string", - "default": "" - }, - "x-kubernetes-list-type": "atomic" - }, - "description": { - "description": "Description is a user-facing description of the stepaction that may be used to populate a UI.", - "type": "string" - }, - "env": { - "description": "List of environment variables to set in the container. Cannot be updated.", - "type": "array", - "items": { - "default": {}, - "$ref": "#/definitions/v1.EnvVar" - }, - "x-kubernetes-list-type": "atomic", - "x-kubernetes-patch-merge-key": "name", - "x-kubernetes-patch-strategy": "merge" - }, - "image": { - "description": "Image reference name to run for this StepAction. More info: https://kubernetes.io/docs/concepts/containers/images", - "type": "string" - }, - "params": { - "description": "Params is a list of input parameters required to run the stepAction. Params must be supplied as inputs in Steps unless they declare a defaultvalue.", - "type": "array", - "items": { - "default": {}, - "$ref": "#/definitions/v1.ParamSpec" - }, - "x-kubernetes-list-type": "atomic" - }, - "results": { - "description": "Results are values that this StepAction can output", - "type": "array", - "items": { - "default": {}, - "$ref": "#/definitions/v1.StepResult" - }, - "x-kubernetes-list-type": "atomic" - }, - "script": { - "description": "Script is the contents of an executable file to execute.\n\nIf Script is not empty, the Step cannot have an Command and the Args will be passed to the Script.", - "type": "string" - }, - "securityContext": { - "description": "SecurityContext defines the security options the Step should be run with. If set, the fields of SecurityContext override the equivalent fields of PodSecurityContext. More info: https://kubernetes.io/docs/tasks/configure-pod-container/security-context/ The value set in StepAction will take precedence over the value from Task.", - "$ref": "#/definitions/v1.SecurityContext" - }, - "volumeMounts": { - "description": "Volumes to mount into the Step's filesystem. Cannot be updated.", - "type": "array", - "items": { - "default": {}, - "$ref": "#/definitions/v1.VolumeMount" - }, - "x-kubernetes-list-type": "atomic", - "x-kubernetes-patch-merge-key": "mountPath", - "x-kubernetes-patch-strategy": "merge" - }, - "workingDir": { - "description": "Step's working directory. If not specified, the container runtime's default will be used, which might be configured in the container image. Cannot be updated.", - "type": "string" - } - } - }, "v1beta1.StepOutputConfig": { "description": "StepOutputConfig stores configuration for a step output stream.", "type": "object", diff --git a/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/taskref_validation.go b/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/taskref_validation.go index 7db46c0d9..a3e2bb036 100644 --- a/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/taskref_validation.go +++ b/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/taskref_validation.go @@ -18,7 +18,6 @@ package v1beta1 import ( "context" - "fmt" "strings" "github.com/google/go-containerregistry/pkg/name" @@ -33,8 +32,18 @@ func (ref *TaskRef) Validate(ctx context.Context) (errs *apis.FieldError) { if ref == nil { return errs } + switch { case ref.Resolver != "" || ref.Params != nil: + if ref.Resolver != "" { + errs = errs.Also(config.ValidateEnabledAPIFields(ctx, "resolver", config.BetaAPIFields).ViaField("resolver")) + if ref.Name != "" { + errs = errs.Also(apis.ErrMultipleOneOf("name", "resolver")) + } + if ref.Bundle != "" { + errs = errs.Also(apis.ErrMultipleOneOf("bundle", "resolver")) + } + } if ref.Params != nil { errs = errs.Also(config.ValidateEnabledAPIFields(ctx, "resolver params", config.BetaAPIFields).ViaField("params")) if ref.Name != "" { @@ -48,23 +57,6 @@ func (ref *TaskRef) Validate(ctx context.Context) (errs *apis.FieldError) { } errs = errs.Also(ValidateParameters(ctx, ref.Params)) } - if ref.Resolver != "" { - errs = errs.Also(config.ValidateEnabledAPIFields(ctx, "resolver", config.BetaAPIFields).ViaField("resolver")) - if ref.Name != "" { - // make sure that the name is url-like. - err := RefNameLikeUrl(ref.Name) - if err == nil && !config.FromContextOrDefaults(ctx).FeatureFlags.EnableConciseResolverSyntax { - // If name is url-like then concise resolver syntax must be enabled - errs = errs.Also(apis.ErrGeneric(fmt.Sprintf("feature flag %s should be set to true to use concise resolver syntax", config.EnableConciseResolverSyntax), "")) - } - if err != nil { - errs = errs.Also(apis.ErrInvalidValue(err, "name")) - } - } - if ref.Bundle != "" { - errs = errs.Also(apis.ErrMultipleOneOf("bundle", "resolver")) - } - } case ref.Bundle != "": if ref.Name == "" { errs = errs.Also(apis.ErrMissingField("name")) @@ -73,27 +65,13 @@ func (ref *TaskRef) Validate(ctx context.Context) (errs *apis.FieldError) { if _, err := name.ParseReference(ref.Bundle); err != nil { errs = errs.Also(apis.ErrInvalidValue("invalid bundle reference", "bundle", err.Error())) } - case ref.Name != "": - // ref name can be a Url-like format. - if err := RefNameLikeUrl(ref.Name); err == nil { - // If name is url-like then concise resolver syntax must be enabled - if !config.FromContextOrDefaults(ctx).FeatureFlags.EnableConciseResolverSyntax { - errs = errs.Also(apis.ErrGeneric(fmt.Sprintf("feature flag %s should be set to true to use concise resolver syntax", config.EnableConciseResolverSyntax), "")) - } - // In stage1 of concise remote resolvers syntax, this is a required field. - // TODO: remove this check when implementing stage 2 where this is optional. - if ref.Resolver == "" { - errs = errs.Also(apis.ErrMissingField("resolver")) - } - // Or, it must be a valid k8s name - } else { - // ref name must be a valid k8s name - if errSlice := validation.IsQualifiedName(ref.Name); len(errSlice) != 0 { - errs = errs.Also(apis.ErrInvalidValue(strings.Join(errSlice, ","), "name")) - } - } default: - errs = errs.Also(apis.ErrMissingField("name")) + if ref.Name == "" { + errs = errs.Also(apis.ErrMissingField("name")) + } else if errSlice := validation.IsQualifiedName(ref.Name); len(errSlice) != 0 { + // TaskRef name must be a valid k8s name + errs = errs.Also(apis.ErrInvalidValue(strings.Join(errSlice, ","), "name")) + } } - return //nolint:nakedret + return errs } diff --git a/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/zz_generated.deepcopy.go b/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/zz_generated.deepcopy.go index 04d3a09ad..807595a19 100644 --- a/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/zz_generated.deepcopy.go +++ b/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/zz_generated.deepcopy.go @@ -1871,125 +1871,6 @@ func (in *Step) DeepCopy() *Step { return out } -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *StepAction) DeepCopyInto(out *StepAction) { - *out = *in - out.TypeMeta = in.TypeMeta - in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) - in.Spec.DeepCopyInto(&out.Spec) - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new StepAction. -func (in *StepAction) DeepCopy() *StepAction { - if in == nil { - return nil - } - out := new(StepAction) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *StepAction) DeepCopyObject() runtime.Object { - if c := in.DeepCopy(); c != nil { - return c - } - return nil -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *StepActionList) DeepCopyInto(out *StepActionList) { - *out = *in - out.TypeMeta = in.TypeMeta - in.ListMeta.DeepCopyInto(&out.ListMeta) - if in.Items != nil { - in, out := &in.Items, &out.Items - *out = make([]StepAction, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new StepActionList. -func (in *StepActionList) DeepCopy() *StepActionList { - if in == nil { - return nil - } - out := new(StepActionList) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *StepActionList) DeepCopyObject() runtime.Object { - if c := in.DeepCopy(); c != nil { - return c - } - return nil -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *StepActionSpec) DeepCopyInto(out *StepActionSpec) { - *out = *in - if in.Command != nil { - in, out := &in.Command, &out.Command - *out = make([]string, len(*in)) - copy(*out, *in) - } - if in.Args != nil { - in, out := &in.Args, &out.Args - *out = make([]string, len(*in)) - copy(*out, *in) - } - if in.Env != nil { - in, out := &in.Env, &out.Env - *out = make([]corev1.EnvVar, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } - if in.Params != nil { - in, out := &in.Params, &out.Params - *out = make(pipelinev1.ParamSpecs, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } - if in.Results != nil { - in, out := &in.Results, &out.Results - *out = make([]pipelinev1.StepResult, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } - if in.SecurityContext != nil { - in, out := &in.SecurityContext, &out.SecurityContext - *out = new(corev1.SecurityContext) - (*in).DeepCopyInto(*out) - } - if in.VolumeMounts != nil { - in, out := &in.VolumeMounts, &out.VolumeMounts - *out = make([]corev1.VolumeMount, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new StepActionSpec. -func (in *StepActionSpec) DeepCopy() *StepActionSpec { - if in == nil { - return nil - } - out := new(StepActionSpec) - in.DeepCopyInto(out) - return out -} - // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *StepOutputConfig) DeepCopyInto(out *StepOutputConfig) { *out = *in diff --git a/vendor/github.com/tektoncd/pipeline/pkg/apis/resolution/v1beta1/resolution_request_types.go b/vendor/github.com/tektoncd/pipeline/pkg/apis/resolution/v1beta1/resolution_request_types.go index f78a4a493..60b51fa04 100644 --- a/vendor/github.com/tektoncd/pipeline/pkg/apis/resolution/v1beta1/resolution_request_types.go +++ b/vendor/github.com/tektoncd/pipeline/pkg/apis/resolution/v1beta1/resolution_request_types.go @@ -64,13 +64,6 @@ type ResolutionRequestSpec struct { // +optional // +listType=atomic Params []pipelinev1.Param `json:"params,omitempty"` - // URL is the runtime url passed to the resolver - // to help it figure out how to resolver the resource being - // requested. - // This is currently at an ALPHA stability level and subject to - // alpha API compatibility policies. - // +optional - URL string `json:"url,omitempty"` } // ResolutionRequestStatus are all the fields in a ResolutionRequest's diff --git a/vendor/github.com/tektoncd/pipeline/pkg/client/clientset/versioned/typed/pipeline/v1beta1/fake/fake_pipeline_client.go b/vendor/github.com/tektoncd/pipeline/pkg/client/clientset/versioned/typed/pipeline/v1beta1/fake/fake_pipeline_client.go index 326e2fbb2..a142026b2 100644 --- a/vendor/github.com/tektoncd/pipeline/pkg/client/clientset/versioned/typed/pipeline/v1beta1/fake/fake_pipeline_client.go +++ b/vendor/github.com/tektoncd/pipeline/pkg/client/clientset/versioned/typed/pipeline/v1beta1/fake/fake_pipeline_client.go @@ -44,10 +44,6 @@ func (c *FakeTektonV1beta1) PipelineRuns(namespace string) v1beta1.PipelineRunIn return &FakePipelineRuns{c, namespace} } -func (c *FakeTektonV1beta1) StepActions(namespace string) v1beta1.StepActionInterface { - return &FakeStepActions{c, namespace} -} - func (c *FakeTektonV1beta1) Tasks(namespace string) v1beta1.TaskInterface { return &FakeTasks{c, namespace} } diff --git a/vendor/github.com/tektoncd/pipeline/pkg/client/clientset/versioned/typed/pipeline/v1beta1/fake/fake_stepaction.go b/vendor/github.com/tektoncd/pipeline/pkg/client/clientset/versioned/typed/pipeline/v1beta1/fake/fake_stepaction.go deleted file mode 100644 index 048c9e56c..000000000 --- a/vendor/github.com/tektoncd/pipeline/pkg/client/clientset/versioned/typed/pipeline/v1beta1/fake/fake_stepaction.go +++ /dev/null @@ -1,129 +0,0 @@ -/* -Copyright 2020 The Tekton 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. -*/ - -// Code generated by client-gen. DO NOT EDIT. - -package fake - -import ( - "context" - - v1beta1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" - v1 "k8s.io/apimachinery/pkg/apis/meta/v1" - labels "k8s.io/apimachinery/pkg/labels" - types "k8s.io/apimachinery/pkg/types" - watch "k8s.io/apimachinery/pkg/watch" - testing "k8s.io/client-go/testing" -) - -// FakeStepActions implements StepActionInterface -type FakeStepActions struct { - Fake *FakeTektonV1beta1 - ns string -} - -var stepactionsResource = v1beta1.SchemeGroupVersion.WithResource("stepactions") - -var stepactionsKind = v1beta1.SchemeGroupVersion.WithKind("StepAction") - -// Get takes name of the stepAction, and returns the corresponding stepAction object, and an error if there is any. -func (c *FakeStepActions) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1beta1.StepAction, err error) { - obj, err := c.Fake. - Invokes(testing.NewGetAction(stepactionsResource, c.ns, name), &v1beta1.StepAction{}) - - if obj == nil { - return nil, err - } - return obj.(*v1beta1.StepAction), err -} - -// List takes label and field selectors, and returns the list of StepActions that match those selectors. -func (c *FakeStepActions) List(ctx context.Context, opts v1.ListOptions) (result *v1beta1.StepActionList, err error) { - obj, err := c.Fake. - Invokes(testing.NewListAction(stepactionsResource, stepactionsKind, c.ns, opts), &v1beta1.StepActionList{}) - - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &v1beta1.StepActionList{ListMeta: obj.(*v1beta1.StepActionList).ListMeta} - for _, item := range obj.(*v1beta1.StepActionList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err -} - -// Watch returns a watch.Interface that watches the requested stepActions. -func (c *FakeStepActions) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { - return c.Fake. - InvokesWatch(testing.NewWatchAction(stepactionsResource, c.ns, opts)) - -} - -// Create takes the representation of a stepAction and creates it. Returns the server's representation of the stepAction, and an error, if there is any. -func (c *FakeStepActions) Create(ctx context.Context, stepAction *v1beta1.StepAction, opts v1.CreateOptions) (result *v1beta1.StepAction, err error) { - obj, err := c.Fake. - Invokes(testing.NewCreateAction(stepactionsResource, c.ns, stepAction), &v1beta1.StepAction{}) - - if obj == nil { - return nil, err - } - return obj.(*v1beta1.StepAction), err -} - -// Update takes the representation of a stepAction and updates it. Returns the server's representation of the stepAction, and an error, if there is any. -func (c *FakeStepActions) Update(ctx context.Context, stepAction *v1beta1.StepAction, opts v1.UpdateOptions) (result *v1beta1.StepAction, err error) { - obj, err := c.Fake. - Invokes(testing.NewUpdateAction(stepactionsResource, c.ns, stepAction), &v1beta1.StepAction{}) - - if obj == nil { - return nil, err - } - return obj.(*v1beta1.StepAction), err -} - -// Delete takes name of the stepAction and deletes it. Returns an error if one occurs. -func (c *FakeStepActions) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { - _, err := c.Fake. - Invokes(testing.NewDeleteActionWithOptions(stepactionsResource, c.ns, name, opts), &v1beta1.StepAction{}) - - return err -} - -// DeleteCollection deletes a collection of objects. -func (c *FakeStepActions) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { - action := testing.NewDeleteCollectionAction(stepactionsResource, c.ns, listOpts) - - _, err := c.Fake.Invokes(action, &v1beta1.StepActionList{}) - return err -} - -// Patch applies the patch and returns the patched stepAction. -func (c *FakeStepActions) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1beta1.StepAction, err error) { - obj, err := c.Fake. - Invokes(testing.NewPatchSubresourceAction(stepactionsResource, c.ns, name, pt, data, subresources...), &v1beta1.StepAction{}) - - if obj == nil { - return nil, err - } - return obj.(*v1beta1.StepAction), err -} diff --git a/vendor/github.com/tektoncd/pipeline/pkg/client/clientset/versioned/typed/pipeline/v1beta1/generated_expansion.go b/vendor/github.com/tektoncd/pipeline/pkg/client/clientset/versioned/typed/pipeline/v1beta1/generated_expansion.go index 87f277c5c..b9f3554be 100644 --- a/vendor/github.com/tektoncd/pipeline/pkg/client/clientset/versioned/typed/pipeline/v1beta1/generated_expansion.go +++ b/vendor/github.com/tektoncd/pipeline/pkg/client/clientset/versioned/typed/pipeline/v1beta1/generated_expansion.go @@ -26,8 +26,6 @@ type PipelineExpansion interface{} type PipelineRunExpansion interface{} -type StepActionExpansion interface{} - type TaskExpansion interface{} type TaskRunExpansion interface{} diff --git a/vendor/github.com/tektoncd/pipeline/pkg/client/clientset/versioned/typed/pipeline/v1beta1/pipeline_client.go b/vendor/github.com/tektoncd/pipeline/pkg/client/clientset/versioned/typed/pipeline/v1beta1/pipeline_client.go index fcd65e7ce..0974d3177 100644 --- a/vendor/github.com/tektoncd/pipeline/pkg/client/clientset/versioned/typed/pipeline/v1beta1/pipeline_client.go +++ b/vendor/github.com/tektoncd/pipeline/pkg/client/clientset/versioned/typed/pipeline/v1beta1/pipeline_client.go @@ -32,7 +32,6 @@ type TektonV1beta1Interface interface { CustomRunsGetter PipelinesGetter PipelineRunsGetter - StepActionsGetter TasksGetter TaskRunsGetter } @@ -58,10 +57,6 @@ func (c *TektonV1beta1Client) PipelineRuns(namespace string) PipelineRunInterfac return newPipelineRuns(c, namespace) } -func (c *TektonV1beta1Client) StepActions(namespace string) StepActionInterface { - return newStepActions(c, namespace) -} - func (c *TektonV1beta1Client) Tasks(namespace string) TaskInterface { return newTasks(c, namespace) } diff --git a/vendor/github.com/tektoncd/pipeline/pkg/client/clientset/versioned/typed/pipeline/v1beta1/stepaction.go b/vendor/github.com/tektoncd/pipeline/pkg/client/clientset/versioned/typed/pipeline/v1beta1/stepaction.go deleted file mode 100644 index 388f06295..000000000 --- a/vendor/github.com/tektoncd/pipeline/pkg/client/clientset/versioned/typed/pipeline/v1beta1/stepaction.go +++ /dev/null @@ -1,178 +0,0 @@ -/* -Copyright 2020 The Tekton 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. -*/ - -// Code generated by client-gen. DO NOT EDIT. - -package v1beta1 - -import ( - "context" - "time" - - v1beta1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" - scheme "github.com/tektoncd/pipeline/pkg/client/clientset/versioned/scheme" - v1 "k8s.io/apimachinery/pkg/apis/meta/v1" - types "k8s.io/apimachinery/pkg/types" - watch "k8s.io/apimachinery/pkg/watch" - rest "k8s.io/client-go/rest" -) - -// StepActionsGetter has a method to return a StepActionInterface. -// A group's client should implement this interface. -type StepActionsGetter interface { - StepActions(namespace string) StepActionInterface -} - -// StepActionInterface has methods to work with StepAction resources. -type StepActionInterface interface { - Create(ctx context.Context, stepAction *v1beta1.StepAction, opts v1.CreateOptions) (*v1beta1.StepAction, error) - Update(ctx context.Context, stepAction *v1beta1.StepAction, opts v1.UpdateOptions) (*v1beta1.StepAction, error) - Delete(ctx context.Context, name string, opts v1.DeleteOptions) error - DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error - Get(ctx context.Context, name string, opts v1.GetOptions) (*v1beta1.StepAction, error) - List(ctx context.Context, opts v1.ListOptions) (*v1beta1.StepActionList, error) - Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) - Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1beta1.StepAction, err error) - StepActionExpansion -} - -// stepActions implements StepActionInterface -type stepActions struct { - client rest.Interface - ns string -} - -// newStepActions returns a StepActions -func newStepActions(c *TektonV1beta1Client, namespace string) *stepActions { - return &stepActions{ - client: c.RESTClient(), - ns: namespace, - } -} - -// Get takes name of the stepAction, and returns the corresponding stepAction object, and an error if there is any. -func (c *stepActions) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1beta1.StepAction, err error) { - result = &v1beta1.StepAction{} - err = c.client.Get(). - Namespace(c.ns). - Resource("stepactions"). - Name(name). - VersionedParams(&options, scheme.ParameterCodec). - Do(ctx). - Into(result) - return -} - -// List takes label and field selectors, and returns the list of StepActions that match those selectors. -func (c *stepActions) List(ctx context.Context, opts v1.ListOptions) (result *v1beta1.StepActionList, err error) { - var timeout time.Duration - if opts.TimeoutSeconds != nil { - timeout = time.Duration(*opts.TimeoutSeconds) * time.Second - } - result = &v1beta1.StepActionList{} - err = c.client.Get(). - Namespace(c.ns). - Resource("stepactions"). - VersionedParams(&opts, scheme.ParameterCodec). - Timeout(timeout). - Do(ctx). - Into(result) - return -} - -// Watch returns a watch.Interface that watches the requested stepActions. -func (c *stepActions) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { - var timeout time.Duration - if opts.TimeoutSeconds != nil { - timeout = time.Duration(*opts.TimeoutSeconds) * time.Second - } - opts.Watch = true - return c.client.Get(). - Namespace(c.ns). - Resource("stepactions"). - VersionedParams(&opts, scheme.ParameterCodec). - Timeout(timeout). - Watch(ctx) -} - -// Create takes the representation of a stepAction and creates it. Returns the server's representation of the stepAction, and an error, if there is any. -func (c *stepActions) Create(ctx context.Context, stepAction *v1beta1.StepAction, opts v1.CreateOptions) (result *v1beta1.StepAction, err error) { - result = &v1beta1.StepAction{} - err = c.client.Post(). - Namespace(c.ns). - Resource("stepactions"). - VersionedParams(&opts, scheme.ParameterCodec). - Body(stepAction). - Do(ctx). - Into(result) - return -} - -// Update takes the representation of a stepAction and updates it. Returns the server's representation of the stepAction, and an error, if there is any. -func (c *stepActions) Update(ctx context.Context, stepAction *v1beta1.StepAction, opts v1.UpdateOptions) (result *v1beta1.StepAction, err error) { - result = &v1beta1.StepAction{} - err = c.client.Put(). - Namespace(c.ns). - Resource("stepactions"). - Name(stepAction.Name). - VersionedParams(&opts, scheme.ParameterCodec). - Body(stepAction). - Do(ctx). - Into(result) - return -} - -// Delete takes name of the stepAction and deletes it. Returns an error if one occurs. -func (c *stepActions) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { - return c.client.Delete(). - Namespace(c.ns). - Resource("stepactions"). - Name(name). - Body(&opts). - Do(ctx). - Error() -} - -// DeleteCollection deletes a collection of objects. -func (c *stepActions) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { - var timeout time.Duration - if listOpts.TimeoutSeconds != nil { - timeout = time.Duration(*listOpts.TimeoutSeconds) * time.Second - } - return c.client.Delete(). - Namespace(c.ns). - Resource("stepactions"). - VersionedParams(&listOpts, scheme.ParameterCodec). - Timeout(timeout). - Body(&opts). - Do(ctx). - Error() -} - -// Patch applies the patch and returns the patched stepAction. -func (c *stepActions) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1beta1.StepAction, err error) { - result = &v1beta1.StepAction{} - err = c.client.Patch(pt). - Namespace(c.ns). - Resource("stepactions"). - Name(name). - SubResource(subresources...). - VersionedParams(&opts, scheme.ParameterCodec). - Body(data). - Do(ctx). - Into(result) - return -} diff --git a/vendor/github.com/tektoncd/pipeline/pkg/client/informers/externalversions/generic.go b/vendor/github.com/tektoncd/pipeline/pkg/client/informers/externalversions/generic.go index fe44a25ab..cec37e053 100644 --- a/vendor/github.com/tektoncd/pipeline/pkg/client/informers/externalversions/generic.go +++ b/vendor/github.com/tektoncd/pipeline/pkg/client/informers/externalversions/generic.go @@ -81,8 +81,6 @@ func (f *sharedInformerFactory) ForResource(resource schema.GroupVersionResource return &genericInformer{resource: resource.GroupResource(), informer: f.Tekton().V1beta1().Pipelines().Informer()}, nil case v1beta1.SchemeGroupVersion.WithResource("pipelineruns"): return &genericInformer{resource: resource.GroupResource(), informer: f.Tekton().V1beta1().PipelineRuns().Informer()}, nil - case v1beta1.SchemeGroupVersion.WithResource("stepactions"): - return &genericInformer{resource: resource.GroupResource(), informer: f.Tekton().V1beta1().StepActions().Informer()}, nil case v1beta1.SchemeGroupVersion.WithResource("tasks"): return &genericInformer{resource: resource.GroupResource(), informer: f.Tekton().V1beta1().Tasks().Informer()}, nil case v1beta1.SchemeGroupVersion.WithResource("taskruns"): diff --git a/vendor/github.com/tektoncd/pipeline/pkg/client/informers/externalversions/pipeline/v1beta1/interface.go b/vendor/github.com/tektoncd/pipeline/pkg/client/informers/externalversions/pipeline/v1beta1/interface.go index 2821b942c..307843a80 100644 --- a/vendor/github.com/tektoncd/pipeline/pkg/client/informers/externalversions/pipeline/v1beta1/interface.go +++ b/vendor/github.com/tektoncd/pipeline/pkg/client/informers/externalversions/pipeline/v1beta1/interface.go @@ -32,8 +32,6 @@ type Interface interface { Pipelines() PipelineInformer // PipelineRuns returns a PipelineRunInformer. PipelineRuns() PipelineRunInformer - // StepActions returns a StepActionInformer. - StepActions() StepActionInformer // Tasks returns a TaskInformer. Tasks() TaskInformer // TaskRuns returns a TaskRunInformer. @@ -71,11 +69,6 @@ func (v *version) PipelineRuns() PipelineRunInformer { return &pipelineRunInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} } -// StepActions returns a StepActionInformer. -func (v *version) StepActions() StepActionInformer { - return &stepActionInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} -} - // Tasks returns a TaskInformer. func (v *version) Tasks() TaskInformer { return &taskInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} diff --git a/vendor/github.com/tektoncd/pipeline/pkg/client/informers/externalversions/pipeline/v1beta1/stepaction.go b/vendor/github.com/tektoncd/pipeline/pkg/client/informers/externalversions/pipeline/v1beta1/stepaction.go deleted file mode 100644 index 4ec857819..000000000 --- a/vendor/github.com/tektoncd/pipeline/pkg/client/informers/externalversions/pipeline/v1beta1/stepaction.go +++ /dev/null @@ -1,90 +0,0 @@ -/* -Copyright 2020 The Tekton 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. -*/ - -// Code generated by informer-gen. DO NOT EDIT. - -package v1beta1 - -import ( - "context" - time "time" - - pipelinev1beta1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" - versioned "github.com/tektoncd/pipeline/pkg/client/clientset/versioned" - internalinterfaces "github.com/tektoncd/pipeline/pkg/client/informers/externalversions/internalinterfaces" - v1beta1 "github.com/tektoncd/pipeline/pkg/client/listers/pipeline/v1beta1" - v1 "k8s.io/apimachinery/pkg/apis/meta/v1" - runtime "k8s.io/apimachinery/pkg/runtime" - watch "k8s.io/apimachinery/pkg/watch" - cache "k8s.io/client-go/tools/cache" -) - -// StepActionInformer provides access to a shared informer and lister for -// StepActions. -type StepActionInformer interface { - Informer() cache.SharedIndexInformer - Lister() v1beta1.StepActionLister -} - -type stepActionInformer struct { - factory internalinterfaces.SharedInformerFactory - tweakListOptions internalinterfaces.TweakListOptionsFunc - namespace string -} - -// NewStepActionInformer constructs a new informer for StepAction type. -// Always prefer using an informer factory to get a shared informer instead of getting an independent -// one. This reduces memory footprint and number of connections to the server. -func NewStepActionInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { - return NewFilteredStepActionInformer(client, namespace, resyncPeriod, indexers, nil) -} - -// NewFilteredStepActionInformer constructs a new informer for StepAction type. -// Always prefer using an informer factory to get a shared informer instead of getting an independent -// one. This reduces memory footprint and number of connections to the server. -func NewFilteredStepActionInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) cache.SharedIndexInformer { - return cache.NewSharedIndexInformer( - &cache.ListWatch{ - ListFunc: func(options v1.ListOptions) (runtime.Object, error) { - if tweakListOptions != nil { - tweakListOptions(&options) - } - return client.TektonV1beta1().StepActions(namespace).List(context.TODO(), options) - }, - WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { - if tweakListOptions != nil { - tweakListOptions(&options) - } - return client.TektonV1beta1().StepActions(namespace).Watch(context.TODO(), options) - }, - }, - &pipelinev1beta1.StepAction{}, - resyncPeriod, - indexers, - ) -} - -func (f *stepActionInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { - return NewFilteredStepActionInformer(client, f.namespace, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions) -} - -func (f *stepActionInformer) Informer() cache.SharedIndexInformer { - return f.factory.InformerFor(&pipelinev1beta1.StepAction{}, f.defaultInformer) -} - -func (f *stepActionInformer) Lister() v1beta1.StepActionLister { - return v1beta1.NewStepActionLister(f.Informer().GetIndexer()) -} diff --git a/vendor/github.com/tektoncd/pipeline/pkg/client/injection/informers/pipeline/v1beta1/stepaction/fake/fake.go b/vendor/github.com/tektoncd/pipeline/pkg/client/injection/informers/pipeline/v1alpha1/stepaction/fake/fake.go similarity index 93% rename from vendor/github.com/tektoncd/pipeline/pkg/client/injection/informers/pipeline/v1beta1/stepaction/fake/fake.go rename to vendor/github.com/tektoncd/pipeline/pkg/client/injection/informers/pipeline/v1alpha1/stepaction/fake/fake.go index 7372bf60d..c86846e86 100644 --- a/vendor/github.com/tektoncd/pipeline/pkg/client/injection/informers/pipeline/v1beta1/stepaction/fake/fake.go +++ b/vendor/github.com/tektoncd/pipeline/pkg/client/injection/informers/pipeline/v1alpha1/stepaction/fake/fake.go @@ -22,7 +22,7 @@ import ( context "context" fake "github.com/tektoncd/pipeline/pkg/client/injection/informers/factory/fake" - stepaction "github.com/tektoncd/pipeline/pkg/client/injection/informers/pipeline/v1beta1/stepaction" + stepaction "github.com/tektoncd/pipeline/pkg/client/injection/informers/pipeline/v1alpha1/stepaction" controller "knative.dev/pkg/controller" injection "knative.dev/pkg/injection" ) @@ -35,6 +35,6 @@ func init() { func withInformer(ctx context.Context) (context.Context, controller.Informer) { f := fake.Get(ctx) - inf := f.Tekton().V1beta1().StepActions() + inf := f.Tekton().V1alpha1().StepActions() return context.WithValue(ctx, stepaction.Key{}, inf), inf.Informer() } diff --git a/vendor/github.com/tektoncd/pipeline/pkg/client/injection/informers/pipeline/v1beta1/stepaction/stepaction.go b/vendor/github.com/tektoncd/pipeline/pkg/client/injection/informers/pipeline/v1alpha1/stepaction/stepaction.go similarity index 81% rename from vendor/github.com/tektoncd/pipeline/pkg/client/injection/informers/pipeline/v1beta1/stepaction/stepaction.go rename to vendor/github.com/tektoncd/pipeline/pkg/client/injection/informers/pipeline/v1alpha1/stepaction/stepaction.go index ffb873d19..f793675e7 100644 --- a/vendor/github.com/tektoncd/pipeline/pkg/client/injection/informers/pipeline/v1beta1/stepaction/stepaction.go +++ b/vendor/github.com/tektoncd/pipeline/pkg/client/injection/informers/pipeline/v1alpha1/stepaction/stepaction.go @@ -21,7 +21,7 @@ package stepaction import ( context "context" - v1beta1 "github.com/tektoncd/pipeline/pkg/client/informers/externalversions/pipeline/v1beta1" + v1alpha1 "github.com/tektoncd/pipeline/pkg/client/informers/externalversions/pipeline/v1alpha1" factory "github.com/tektoncd/pipeline/pkg/client/injection/informers/factory" controller "knative.dev/pkg/controller" injection "knative.dev/pkg/injection" @@ -37,16 +37,16 @@ type Key struct{} func withInformer(ctx context.Context) (context.Context, controller.Informer) { f := factory.Get(ctx) - inf := f.Tekton().V1beta1().StepActions() + inf := f.Tekton().V1alpha1().StepActions() return context.WithValue(ctx, Key{}, inf), inf.Informer() } // Get extracts the typed informer from the context. -func Get(ctx context.Context) v1beta1.StepActionInformer { +func Get(ctx context.Context) v1alpha1.StepActionInformer { untyped := ctx.Value(Key{}) if untyped == nil { logging.FromContext(ctx).Panic( - "Unable to fetch github.com/tektoncd/pipeline/pkg/client/informers/externalversions/pipeline/v1beta1.StepActionInformer from context.") + "Unable to fetch github.com/tektoncd/pipeline/pkg/client/informers/externalversions/pipeline/v1alpha1.StepActionInformer from context.") } - return untyped.(v1beta1.StepActionInformer) + return untyped.(v1alpha1.StepActionInformer) } diff --git a/vendor/github.com/tektoncd/pipeline/pkg/client/listers/pipeline/v1beta1/expansion_generated.go b/vendor/github.com/tektoncd/pipeline/pkg/client/listers/pipeline/v1beta1/expansion_generated.go index 0fe1994d1..db5d996e6 100644 --- a/vendor/github.com/tektoncd/pipeline/pkg/client/listers/pipeline/v1beta1/expansion_generated.go +++ b/vendor/github.com/tektoncd/pipeline/pkg/client/listers/pipeline/v1beta1/expansion_generated.go @@ -46,14 +46,6 @@ type PipelineRunListerExpansion interface{} // PipelineRunNamespaceLister. type PipelineRunNamespaceListerExpansion interface{} -// StepActionListerExpansion allows custom methods to be added to -// StepActionLister. -type StepActionListerExpansion interface{} - -// StepActionNamespaceListerExpansion allows custom methods to be added to -// StepActionNamespaceLister. -type StepActionNamespaceListerExpansion interface{} - // TaskListerExpansion allows custom methods to be added to // TaskLister. type TaskListerExpansion interface{} diff --git a/vendor/github.com/tektoncd/pipeline/pkg/client/listers/pipeline/v1beta1/stepaction.go b/vendor/github.com/tektoncd/pipeline/pkg/client/listers/pipeline/v1beta1/stepaction.go deleted file mode 100644 index 192573825..000000000 --- a/vendor/github.com/tektoncd/pipeline/pkg/client/listers/pipeline/v1beta1/stepaction.go +++ /dev/null @@ -1,99 +0,0 @@ -/* -Copyright 2020 The Tekton 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. -*/ - -// Code generated by lister-gen. DO NOT EDIT. - -package v1beta1 - -import ( - v1beta1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1" - "k8s.io/apimachinery/pkg/api/errors" - "k8s.io/apimachinery/pkg/labels" - "k8s.io/client-go/tools/cache" -) - -// StepActionLister helps list StepActions. -// All objects returned here must be treated as read-only. -type StepActionLister interface { - // List lists all StepActions in the indexer. - // Objects returned here must be treated as read-only. - List(selector labels.Selector) (ret []*v1beta1.StepAction, err error) - // StepActions returns an object that can list and get StepActions. - StepActions(namespace string) StepActionNamespaceLister - StepActionListerExpansion -} - -// stepActionLister implements the StepActionLister interface. -type stepActionLister struct { - indexer cache.Indexer -} - -// NewStepActionLister returns a new StepActionLister. -func NewStepActionLister(indexer cache.Indexer) StepActionLister { - return &stepActionLister{indexer: indexer} -} - -// List lists all StepActions in the indexer. -func (s *stepActionLister) List(selector labels.Selector) (ret []*v1beta1.StepAction, err error) { - err = cache.ListAll(s.indexer, selector, func(m interface{}) { - ret = append(ret, m.(*v1beta1.StepAction)) - }) - return ret, err -} - -// StepActions returns an object that can list and get StepActions. -func (s *stepActionLister) StepActions(namespace string) StepActionNamespaceLister { - return stepActionNamespaceLister{indexer: s.indexer, namespace: namespace} -} - -// StepActionNamespaceLister helps list and get StepActions. -// All objects returned here must be treated as read-only. -type StepActionNamespaceLister interface { - // List lists all StepActions in the indexer for a given namespace. - // Objects returned here must be treated as read-only. - List(selector labels.Selector) (ret []*v1beta1.StepAction, err error) - // Get retrieves the StepAction from the indexer for a given namespace and name. - // Objects returned here must be treated as read-only. - Get(name string) (*v1beta1.StepAction, error) - StepActionNamespaceListerExpansion -} - -// stepActionNamespaceLister implements the StepActionNamespaceLister -// interface. -type stepActionNamespaceLister struct { - indexer cache.Indexer - namespace string -} - -// List lists all StepActions in the indexer for a given namespace. -func (s stepActionNamespaceLister) List(selector labels.Selector) (ret []*v1beta1.StepAction, err error) { - err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) { - ret = append(ret, m.(*v1beta1.StepAction)) - }) - return ret, err -} - -// Get retrieves the StepAction from the indexer for a given namespace and name. -func (s stepActionNamespaceLister) Get(name string) (*v1beta1.StepAction, error) { - obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name) - if err != nil { - return nil, err - } - if !exists { - return nil, errors.NewNotFound(v1beta1.Resource("stepaction"), name) - } - return obj.(*v1beta1.StepAction), nil -} diff --git a/vendor/github.com/tektoncd/pipeline/pkg/resolution/common/errors.go b/vendor/github.com/tektoncd/pipeline/pkg/resolution/common/errors.go index d304989b8..bb680f7fb 100644 --- a/vendor/github.com/tektoncd/pipeline/pkg/resolution/common/errors.go +++ b/vendor/github.com/tektoncd/pipeline/pkg/resolution/common/errors.go @@ -17,21 +17,10 @@ limitations under the License. package common import ( - "context" "errors" "fmt" - "slices" - "strings" - - apierrors "k8s.io/apimachinery/pkg/api/errors" ) -// This error is defined in etcd at -// https://github.com/etcd-io/etcd/blob/5b226e0abf4100253c94bb71f47d6815877ed5a2/server/etcdserver/errors.go#L30 -// TODO: If/when https://github.com/kubernetes/kubernetes/issues/106491 is addressed, -// we should stop relying on a hardcoded string. -var errEtcdLeaderChange = "etcdserver: leader changed" - // Error embeds both a short machine-readable string reason for resolution // problems alongside the original error generated during the resolution flow. type Error struct { @@ -176,19 +165,3 @@ func ReasonError(err error) (string, error) { return reason, resolutionError } - -// IsErrTransient returns true if an error returned by GetTask/GetStepAction is retryable. -func IsErrTransient(err error) bool { - switch { - case apierrors.IsConflict(err): - return true - case apierrors.IsServerTimeout(err): - return true - case apierrors.IsTimeout(err): - return true - default: - return slices.ContainsFunc([]string{errEtcdLeaderChange, context.DeadlineExceeded.Error()}, func(s string) bool { - return strings.Contains(err.Error(), s) - }) - } -} diff --git a/vendor/github.com/tektoncd/pipeline/pkg/resolution/common/interface.go b/vendor/github.com/tektoncd/pipeline/pkg/resolution/common/interface.go index 82bfda685..3a1968f36 100644 --- a/vendor/github.com/tektoncd/pipeline/pkg/resolution/common/interface.go +++ b/vendor/github.com/tektoncd/pipeline/pkg/resolution/common/interface.go @@ -30,8 +30,6 @@ type ResolverName string // Requester is the interface implemented by a type that knows how to // submit requests for remote resources. -// -// Deprecated: Use [github.com/tektoncd/pipeline/pkg/remoteresolution/resource.Requester]. type Requester interface { // Submit accepts the name of a resolver to submit a request to // along with the request itself. @@ -43,8 +41,6 @@ type Requester interface { // type an opportunity to control properties such as whether the name of // a request has particular properties, whether the request should be made // to a specific namespace, and precisely which parameters should be included. -// -// Deprecated: Use [github.com/tektoncd/pipeline/pkg/remoteresolution/resource.Request]. type Request interface { Name() string Namespace() string diff --git a/vendor/github.com/tektoncd/pipeline/pkg/result/result.go b/vendor/github.com/tektoncd/pipeline/pkg/result/result.go index ab52c6c82..e3d66b596 100644 --- a/vendor/github.com/tektoncd/pipeline/pkg/result/result.go +++ b/vendor/github.com/tektoncd/pipeline/pkg/result/result.go @@ -36,8 +36,8 @@ const ( // StepResultType default step result value StepResultType ResultType = 4 - // StepArtifactsResultType default artifacts result value - StepArtifactsResultType ResultType = 5 + // ArtifactsResultType default artifacts result value + ArtifactsResultType ResultType = 5 ) // RunResult is used to write key/value pairs to TaskRun pod termination messages. @@ -91,8 +91,8 @@ func (r *ResultType) UnmarshalJSON(data []byte) error { *r = TaskRunResultType case "InternalTektonResult": *r = InternalTektonResultType - case "StepArtifactsResult": - *r = StepArtifactsResultType + case "ArtifactsResult": + *r = ArtifactsResultType default: *r = UnknownResultType } diff --git a/vendor/github.com/tektoncd/pipeline/test/clients.go b/vendor/github.com/tektoncd/pipeline/test/clients.go index dc0424a52..0a0a4f214 100644 --- a/vendor/github.com/tektoncd/pipeline/test/clients.go +++ b/vendor/github.com/tektoncd/pipeline/test/clients.go @@ -68,7 +68,7 @@ type clients struct { V1TaskClient v1.TaskInterface V1TaskRunClient v1.TaskRunInterface V1PipelineRunClient v1.PipelineRunInterface - V1beta1StepActionClient v1beta1.StepActionInterface + V1alpha1StepActionClient v1alpha1.StepActionInterface } // newClients instantiates and returns several clientsets required for making requests to the @@ -110,6 +110,6 @@ func newClients(t *testing.T, configPath, clusterName, namespace string) *client c.V1TaskClient = cs.TektonV1().Tasks(namespace) c.V1TaskRunClient = cs.TektonV1().TaskRuns(namespace) c.V1PipelineRunClient = cs.TektonV1().PipelineRuns(namespace) - c.V1beta1StepActionClient = cs.TektonV1beta1().StepActions(namespace) + c.V1alpha1StepActionClient = cs.TektonV1alpha1().StepActions(namespace) return c } diff --git a/vendor/github.com/tektoncd/pipeline/test/controller.go b/vendor/github.com/tektoncd/pipeline/test/controller.go index d4cc55061..93a3840ae 100644 --- a/vendor/github.com/tektoncd/pipeline/test/controller.go +++ b/vendor/github.com/tektoncd/pipeline/test/controller.go @@ -37,10 +37,10 @@ import ( fakepipelineruninformer "github.com/tektoncd/pipeline/pkg/client/injection/informers/pipeline/v1/pipelinerun/fake" faketaskinformer "github.com/tektoncd/pipeline/pkg/client/injection/informers/pipeline/v1/task/fake" faketaskruninformer "github.com/tektoncd/pipeline/pkg/client/injection/informers/pipeline/v1/taskrun/fake" + fakestepactioninformer "github.com/tektoncd/pipeline/pkg/client/injection/informers/pipeline/v1alpha1/stepaction/fake" fakeverificationpolicyinformer "github.com/tektoncd/pipeline/pkg/client/injection/informers/pipeline/v1alpha1/verificationpolicy/fake" fakeclustertaskinformer "github.com/tektoncd/pipeline/pkg/client/injection/informers/pipeline/v1beta1/clustertask/fake" fakecustomruninformer "github.com/tektoncd/pipeline/pkg/client/injection/informers/pipeline/v1beta1/customrun/fake" - fakestepactioninformer "github.com/tektoncd/pipeline/pkg/client/injection/informers/pipeline/v1beta1/stepaction/fake" fakeresolutionclientset "github.com/tektoncd/pipeline/pkg/client/resolution/clientset/versioned/fake" resolutioninformersv1alpha1 "github.com/tektoncd/pipeline/pkg/client/resolution/informers/externalversions/resolution/v1beta1" fakeresolutionrequestclient "github.com/tektoncd/pipeline/pkg/client/resolution/injection/client/fake" @@ -74,7 +74,7 @@ type Data struct { Pipelines []*v1.Pipeline TaskRuns []*v1.TaskRun Tasks []*v1.Task - StepActions []*v1beta1.StepAction + StepActions []*v1alpha1.StepAction ClusterTasks []*v1beta1.ClusterTask CustomRuns []*v1beta1.CustomRun Pods []*corev1.Pod @@ -104,7 +104,7 @@ type Informers struct { Run informersv1alpha1.RunInformer CustomRun informersv1beta1.CustomRunInformer Task informersv1.TaskInformer - StepAction informersv1beta1.StepActionInformer + StepAction informersv1alpha1.StepActionInformer ClusterTask informersv1beta1.ClusterTaskInformer Pod coreinformers.PodInformer ConfigMap coreinformers.ConfigMapInformer @@ -236,7 +236,7 @@ func SeedTestData(t *testing.T, ctx context.Context, d Data) (Clients, Informers c.Pipeline.PrependReactor("*", "stepactions", AddToInformer(t, i.StepAction.Informer().GetIndexer())) for _, sa := range d.StepActions { sa := sa.DeepCopy() // Avoid assumptions that the informer's copy is modified. - if _, err := c.Pipeline.TektonV1beta1().StepActions(sa.Namespace).Create(ctx, sa, metav1.CreateOptions{}); err != nil { + if _, err := c.Pipeline.TektonV1alpha1().StepActions(sa.Namespace).Create(ctx, sa, metav1.CreateOptions{}); err != nil { t.Fatal(err) } } diff --git a/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/stepaction_defaults.go b/vendor/github.com/tektoncd/pipeline/test/diff/print.go similarity index 51% rename from vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/stepaction_defaults.go rename to vendor/github.com/tektoncd/pipeline/test/diff/print.go index 0274a66bc..9c8a90f5f 100644 --- a/vendor/github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1/stepaction_defaults.go +++ b/vendor/github.com/tektoncd/pipeline/test/diff/print.go @@ -1,9 +1,12 @@ /* -Copyright 2023 The Tekton Authors +Copyright 2020 The Tekton 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. @@ -11,27 +14,12 @@ See the License for the specific language governing permissions and limitations under the License. */ -package v1beta1 - -import ( - "context" - - "knative.dev/pkg/apis" -) - -var _ apis.Defaultable = (*StepAction)(nil) - -// SetDefaults implements apis.Defaultable -func (s *StepAction) SetDefaults(ctx context.Context) { - s.Spec.SetDefaults(ctx) -} +package diff -// SetDefaults set any defaults for the StepAction spec -func (ss *StepActionSpec) SetDefaults(ctx context.Context) { - for i := range ss.Params { - ss.Params[i].SetDefaults(ctx) - } - for i := range ss.Results { - ss.Results[i].SetDefaults(ctx) - } +// PrintWantGot takes a diff string generated by cmp.Diff and returns it +// in a consistent format for reuse across all of our tests. This +// func assumes that the order of arguments passed to cmp.Diff was +// (want, got) or, in other words, the expectedResult then the actualResult. +func PrintWantGot(diff string) string { + return "(-want, +got): " + diff } diff --git a/vendor/github.com/tektoncd/pipeline/test/e2e-tests-kind-prow-alpha.env b/vendor/github.com/tektoncd/pipeline/test/e2e-tests-kind-prow-alpha.env index dfcc2e764..255bdf635 100644 --- a/vendor/github.com/tektoncd/pipeline/test/e2e-tests-kind-prow-alpha.env +++ b/vendor/github.com/tektoncd/pipeline/test/e2e-tests-kind-prow-alpha.env @@ -8,4 +8,3 @@ ENABLE_STEP_ACTIONS=true ENABLE_CEL_IN_WHENEXPRESSION=true ENABLE_PARAM_ENUM=true ENABLE_ARTIFACTS=true -ENABLE_CONCISE_RESOLVER_SYNTAX=true diff --git a/vendor/github.com/tektoncd/pipeline/test/e2e-tests-kind-prow-beta.env b/vendor/github.com/tektoncd/pipeline/test/e2e-tests-kind-prow-beta.env index 516f46759..8dae8c618 100644 --- a/vendor/github.com/tektoncd/pipeline/test/e2e-tests-kind-prow-beta.env +++ b/vendor/github.com/tektoncd/pipeline/test/e2e-tests-kind-prow-beta.env @@ -2,6 +2,5 @@ SKIP_INITIALIZE=true PIPELINE_FEATURE_GATE=beta EMBEDDED_STATUS_GATE=minimal RUN_YAML_TESTS=true -ENABLE_STEP_ACTIONS=true KO_DOCKER_REPO=registry.local:5000 E2E_GO_TEST_TIMEOUT=40m diff --git a/vendor/github.com/tektoncd/pipeline/test/e2e-tests.sh b/vendor/github.com/tektoncd/pipeline/test/e2e-tests.sh index 8a8b63a48..a291f27e4 100644 --- a/vendor/github.com/tektoncd/pipeline/test/e2e-tests.sh +++ b/vendor/github.com/tektoncd/pipeline/test/e2e-tests.sh @@ -32,7 +32,6 @@ ENABLE_STEP_ACTIONS=${ENABLE_STEP_ACTIONS:="false"} ENABLE_CEL_IN_WHENEXPRESSION=${ENABLE_CEL_IN_WHENEXPRESSION:="false"} ENABLE_PARAM_ENUM=${ENABLE_PARAM_ENUM:="false"} ENABLE_ARTIFACTS=${ENABLE_ARTIFACTS:="false"} -ENABLE_CONCISE_RESOLVER_SYNTAX=${ENABLE_CONCISE_RESOLVER_SYNTAX:="false"} failed=0 # Script entry point. @@ -131,18 +130,6 @@ function set_enable_artifacts() { kubectl patch configmap feature-flags -n tekton-pipelines -p "$jsonpatch" } -function set_enable_concise_resolver_syntax() { - local method="$1" - if [ "$method" != "false" ] && [ "$method" != "true" ]; then - printf "Invalid value for enable-concise-resolver-syntax %s\n" ${method} - exit 255 - fi - printf "Setting enable-concise-resolver-syntax to %s\n", ${method} - jsonpatch=$(printf "{\"data\": {\"enable-concise-resolver-syntax\": \"%s\"}}" $1) - echo "feature-flags ConfigMap patch: ${jsonpatch}" - kubectl patch configmap feature-flags -n tekton-pipelines -p "$jsonpatch" -} - function run_e2e() { # Run the integration tests header "Running Go e2e tests" @@ -170,7 +157,6 @@ set_enable_step_actions "$ENABLE_STEP_ACTIONS" set_cel_in_whenexpression "$ENABLE_CEL_IN_WHENEXPRESSION" set_enable_param_enum "$ENABLE_PARAM_ENUM" set_enable_artifacts "$ENABLE_ARTIFACTS" -set_enable_concise_resolver_syntax "$ENABLE_CONCISE_RESOLVER_SYNTAX" run_e2e (( failed )) && fail_test diff --git a/vendor/github.com/tektoncd/pipeline/test/featureflags.go b/vendor/github.com/tektoncd/pipeline/test/featureflags.go index 0f5cd810f..673d82cb7 100644 --- a/vendor/github.com/tektoncd/pipeline/test/featureflags.go +++ b/vendor/github.com/tektoncd/pipeline/test/featureflags.go @@ -111,21 +111,19 @@ func requireAllGates(gates map[string]string) func(context.Context, *testing.T, func getFeatureFlagsBaseOnAPIFlag(t *testing.T) *config.FeatureFlags { t.Helper() alphaFeatureFlags, err := config.NewFeatureFlagsFromMap(map[string]string{ - "enable-api-fields": "alpha", - "results-from": "sidecar-logs", - "enable-tekton-oci-bundles": "true", - "enable-step-actions": "true", - "enable-cel-in-whenexpression": "true", - "enable-param-enum": "true", - "enable-artifacts": "true", - "enable-concise-resolver-syntax": "true", + "enable-api-fields": "alpha", + "results-from": "sidecar-logs", + "enable-tekton-oci-bundles": "true", + "enable-step-actions": "true", + "enable-cel-in-whenexpression": "true", + "enable-param-enum": "true", + "enable-artifacts": "true", }) if err != nil { t.Fatalf("error creating alpha feature flags configmap: %v", err) } betaFeatureFlags, err := config.NewFeatureFlagsFromMap(map[string]string{ - "enable-api-fields": "beta", - "enable-step-actions": "true", + "enable-api-fields": "beta", }) if err != nil { t.Fatalf("error creating beta feature flags configmap: %v", err) diff --git a/vendor/github.com/tektoncd/pipeline/test/resolution.go b/vendor/github.com/tektoncd/pipeline/test/resolution.go new file mode 100644 index 000000000..514988427 --- /dev/null +++ b/vendor/github.com/tektoncd/pipeline/test/resolution.go @@ -0,0 +1,178 @@ +/* +Copyright 2023 The Tekton 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 test + +import ( + "context" + "errors" + "fmt" + "strings" + + "github.com/google/go-cmp/cmp" + pipelinev1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1" + resolution "github.com/tektoncd/pipeline/pkg/resolution/common" + "github.com/tektoncd/pipeline/test/diff" +) + +var _ resolution.Requester = &Requester{} +var _ resolution.ResolvedResource = &ResolvedResource{} + +// NewRequester creates a mock requester that resolves to the given +// resource or returns the given error on Submit(). +func NewRequester(resource resolution.ResolvedResource, err error) *Requester { + return &Requester{ + ResolvedResource: resource, + SubmitErr: err, + } +} + +// NewResolvedResource creates a mock resolved resource that is +// populated with the given data and annotations or returns the given +// error from its Data() method. +func NewResolvedResource(data []byte, annotations map[string]string, source *pipelinev1.RefSource, dataErr error) *ResolvedResource { + return &ResolvedResource{ + ResolvedData: data, + ResolvedAnnotations: annotations, + ResolvedRefSource: source, + DataErr: dataErr, + } +} + +// Requester implements resolution.Requester and makes it easier +// to mock the outcome of a remote pipelineRef or taskRef resolution. +type Requester struct { + // The resolved resource object to return when a request is + // submitted. + ResolvedResource resolution.ResolvedResource + // An error to return when a request is submitted. + SubmitErr error + // Params that should match those on the request in order to return the resolved resource + Params []pipelinev1.Param +} + +// Submit implements resolution.Requester, accepting the name of a +// resolver and a request for a specific remote file, and then returns +// whatever mock data was provided on initialization. +func (r *Requester) Submit(ctx context.Context, resolverName resolution.ResolverName, req resolution.Request) (resolution.ResolvedResource, error) { + if len(r.Params) == 0 { + return r.ResolvedResource, r.SubmitErr + } + reqParams := make(map[string]pipelinev1.ParamValue) + for _, p := range req.Params() { + reqParams[p.Name] = p.Value + } + + var wrongParams []string + for _, p := range r.Params { + if reqValue, ok := reqParams[p.Name]; !ok { + wrongParams = append(wrongParams, fmt.Sprintf("expected %s param to be %#v, but was %#v", p.Name, p.Value, reqValue)) + } else if d := cmp.Diff(p.Value, reqValue); d != "" { + wrongParams = append(wrongParams, fmt.Sprintf("%s param did not match: %s", p.Name, diff.PrintWantGot(d))) + } + } + if len(wrongParams) > 0 { + return nil, errors.New(strings.Join(wrongParams, "; ")) + } + + return r.ResolvedResource, r.SubmitErr +} + +// ResolvedResource implements resolution.ResolvedResource and makes +// it easier to mock the resolved content of a fetched pipeline or task. +type ResolvedResource struct { + // The resolved bytes to return when resolution is complete. + ResolvedData []byte + // An error to return instead of the resolved bytes after + // resolution completes. + DataErr error + // Annotations to return when resolution is complete. + ResolvedAnnotations map[string]string + // ResolvedRefSource to return the source reference of the remote data + ResolvedRefSource *pipelinev1.RefSource +} + +// Data implements resolution.ResolvedResource and returns the mock +// data and/or error given to it on initialization. +func (r *ResolvedResource) Data() ([]byte, error) { + return r.ResolvedData, r.DataErr +} + +// Annotations implements resolution.ResolvedResource and returns +// the mock annotations given to it on initialization. +func (r *ResolvedResource) Annotations() map[string]string { + return r.ResolvedAnnotations +} + +// RefSource is the source reference of the remote data that records where the remote +// file came from including the url, digest and the entrypoint. +func (r *ResolvedResource) RefSource() *pipelinev1.RefSource { + return r.ResolvedRefSource +} + +// RawRequest stores the raw request data +type RawRequest struct { + // the request name + Name string + // the request namespace + Namespace string + // the params for the request + Params []pipelinev1.Param +} + +// Request returns a Request interface based on the RawRequest. +func (r *RawRequest) Request() resolution.Request { + if r == nil { + r = &RawRequest{} + } + return &Request{ + RawRequest: *r, + } +} + +// Request implements resolution.Request and makes it easier to mock input for submit +// Using inline structs is to avoid conflicts between field names and method names. +type Request struct { + RawRequest +} + +var _ resolution.Request = &Request{} + +// NewRequest creates a mock request that is populated with the given name namespace and params +func NewRequest(name, namespace string, params []pipelinev1.Param) *Request { + return &Request{ + RawRequest: RawRequest{ + Name: name, + Namespace: namespace, + Params: params, + }, + } +} + +// Name implements resolution.Request and returns the mock name given to it on initialization. +func (r *Request) Name() string { + return r.RawRequest.Name +} + +// Namespace implements resolution.Request and returns the mock namespace given to it on initialization. +func (r *Request) Namespace() string { + return r.RawRequest.Namespace +} + +// Params implements resolution.Request and returns the mock params given to it on initialization. +func (r *Request) Params() pipelinev1.Params { + return r.RawRequest.Params +} diff --git a/vendor/golang.org/x/exp/slices/cmp.go b/vendor/golang.org/x/exp/slices/cmp.go deleted file mode 100644 index fbf1934a0..000000000 --- a/vendor/golang.org/x/exp/slices/cmp.go +++ /dev/null @@ -1,44 +0,0 @@ -// Copyright 2023 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package slices - -import "golang.org/x/exp/constraints" - -// min is a version of the predeclared function from the Go 1.21 release. -func min[T constraints.Ordered](a, b T) T { - if a < b || isNaN(a) { - return a - } - return b -} - -// max is a version of the predeclared function from the Go 1.21 release. -func max[T constraints.Ordered](a, b T) T { - if a > b || isNaN(a) { - return a - } - return b -} - -// cmpLess is a copy of cmp.Less from the Go 1.21 release. -func cmpLess[T constraints.Ordered](x, y T) bool { - return (isNaN(x) && !isNaN(y)) || x < y -} - -// cmpCompare is a copy of cmp.Compare from the Go 1.21 release. -func cmpCompare[T constraints.Ordered](x, y T) int { - xNaN := isNaN(x) - yNaN := isNaN(y) - if xNaN && yNaN { - return 0 - } - if xNaN || x < y { - return -1 - } - if yNaN || x > y { - return +1 - } - return 0 -} diff --git a/vendor/golang.org/x/exp/slices/slices.go b/vendor/golang.org/x/exp/slices/slices.go index 46ceac343..8a7cf20db 100644 --- a/vendor/golang.org/x/exp/slices/slices.go +++ b/vendor/golang.org/x/exp/slices/slices.go @@ -3,20 +3,23 @@ // license that can be found in the LICENSE file. // Package slices defines various functions useful with slices of any type. +// Unless otherwise specified, these functions all apply to the elements +// of a slice at index 0 <= i < len(s). +// +// Note that the less function in IsSortedFunc, SortFunc, SortStableFunc requires a +// strict weak ordering (https://en.wikipedia.org/wiki/Weak_ordering#Strict_weak_orderings), +// or the sorting may fail to sort correctly. A common case is when sorting slices of +// floating-point numbers containing NaN values. package slices -import ( - "unsafe" - - "golang.org/x/exp/constraints" -) +import "golang.org/x/exp/constraints" // Equal reports whether two slices are equal: the same length and all // elements equal. If the lengths are different, Equal returns false. // Otherwise, the elements are compared in increasing index order, and the // comparison stops at the first unequal pair. // Floating point NaNs are not considered equal. -func Equal[S ~[]E, E comparable](s1, s2 S) bool { +func Equal[E comparable](s1, s2 []E) bool { if len(s1) != len(s2) { return false } @@ -28,12 +31,12 @@ func Equal[S ~[]E, E comparable](s1, s2 S) bool { return true } -// EqualFunc reports whether two slices are equal using an equality +// EqualFunc reports whether two slices are equal using a comparison // function on each pair of elements. If the lengths are different, // EqualFunc returns false. Otherwise, the elements are compared in // increasing index order, and the comparison stops at the first index // for which eq returns false. -func EqualFunc[S1 ~[]E1, S2 ~[]E2, E1, E2 any](s1 S1, s2 S2, eq func(E1, E2) bool) bool { +func EqualFunc[E1, E2 any](s1 []E1, s2 []E2, eq func(E1, E2) bool) bool { if len(s1) != len(s2) { return false } @@ -46,37 +49,45 @@ func EqualFunc[S1 ~[]E1, S2 ~[]E2, E1, E2 any](s1 S1, s2 S2, eq func(E1, E2) boo return true } -// Compare compares the elements of s1 and s2, using [cmp.Compare] on each pair -// of elements. The elements are compared sequentially, starting at index 0, +// Compare compares the elements of s1 and s2. +// The elements are compared sequentially, starting at index 0, // until one element is not equal to the other. // The result of comparing the first non-matching elements is returned. // If both slices are equal until one of them ends, the shorter slice is // considered less than the longer one. // The result is 0 if s1 == s2, -1 if s1 < s2, and +1 if s1 > s2. -func Compare[S ~[]E, E constraints.Ordered](s1, s2 S) int { +// Comparisons involving floating point NaNs are ignored. +func Compare[E constraints.Ordered](s1, s2 []E) int { + s2len := len(s2) for i, v1 := range s1 { - if i >= len(s2) { + if i >= s2len { return +1 } v2 := s2[i] - if c := cmpCompare(v1, v2); c != 0 { - return c + switch { + case v1 < v2: + return -1 + case v1 > v2: + return +1 } } - if len(s1) < len(s2) { + if len(s1) < s2len { return -1 } return 0 } -// CompareFunc is like [Compare] but uses a custom comparison function on each -// pair of elements. +// CompareFunc is like Compare but uses a comparison function +// on each pair of elements. The elements are compared in increasing +// index order, and the comparisons stop after the first time cmp +// returns non-zero. // The result is the first non-zero result of cmp; if cmp always // returns 0 the result is 0 if len(s1) == len(s2), -1 if len(s1) < len(s2), // and +1 if len(s1) > len(s2). -func CompareFunc[S1 ~[]E1, S2 ~[]E2, E1, E2 any](s1 S1, s2 S2, cmp func(E1, E2) int) int { +func CompareFunc[E1, E2 any](s1 []E1, s2 []E2, cmp func(E1, E2) int) int { + s2len := len(s2) for i, v1 := range s1 { - if i >= len(s2) { + if i >= s2len { return +1 } v2 := s2[i] @@ -84,7 +95,7 @@ func CompareFunc[S1 ~[]E1, S2 ~[]E2, E1, E2 any](s1 S1, s2 S2, cmp func(E1, E2) return c } } - if len(s1) < len(s2) { + if len(s1) < s2len { return -1 } return 0 @@ -92,7 +103,7 @@ func CompareFunc[S1 ~[]E1, S2 ~[]E2, E1, E2 any](s1 S1, s2 S2, cmp func(E1, E2) // Index returns the index of the first occurrence of v in s, // or -1 if not present. -func Index[S ~[]E, E comparable](s S, v E) int { +func Index[E comparable](s []E, v E) int { for i := range s { if v == s[i] { return i @@ -103,7 +114,7 @@ func Index[S ~[]E, E comparable](s S, v E) int { // IndexFunc returns the first index i satisfying f(s[i]), // or -1 if none do. -func IndexFunc[S ~[]E, E any](s S, f func(E) bool) int { +func IndexFunc[E any](s []E, f func(E) bool) int { for i := range s { if f(s[i]) { return i @@ -113,237 +124,90 @@ func IndexFunc[S ~[]E, E any](s S, f func(E) bool) int { } // Contains reports whether v is present in s. -func Contains[S ~[]E, E comparable](s S, v E) bool { +func Contains[E comparable](s []E, v E) bool { return Index(s, v) >= 0 } // ContainsFunc reports whether at least one // element e of s satisfies f(e). -func ContainsFunc[S ~[]E, E any](s S, f func(E) bool) bool { +func ContainsFunc[E any](s []E, f func(E) bool) bool { return IndexFunc(s, f) >= 0 } // Insert inserts the values v... into s at index i, // returning the modified slice. -// The elements at s[i:] are shifted up to make room. -// In the returned slice r, r[i] == v[0], -// and r[i+len(v)] == value originally at r[i]. +// In the returned slice r, r[i] == v[0]. // Insert panics if i is out of range. // This function is O(len(s) + len(v)). func Insert[S ~[]E, E any](s S, i int, v ...E) S { - m := len(v) - if m == 0 { - return s - } - n := len(s) - if i == n { - return append(s, v...) - } - if n+m > cap(s) { - // Use append rather than make so that we bump the size of - // the slice up to the next storage class. - // This is what Grow does but we don't call Grow because - // that might copy the values twice. - s2 := append(s[:i], make(S, n+m-i)...) + tot := len(s) + len(v) + if tot <= cap(s) { + s2 := s[:tot] + copy(s2[i+len(v):], s[i:]) copy(s2[i:], v) - copy(s2[i+m:], s[i:]) return s2 } - s = s[:n+m] - - // before: - // s: aaaaaaaabbbbccccccccdddd - // ^ ^ ^ ^ - // i i+m n n+m - // after: - // s: aaaaaaaavvvvbbbbcccccccc - // ^ ^ ^ ^ - // i i+m n n+m - // - // a are the values that don't move in s. - // v are the values copied in from v. - // b and c are the values from s that are shifted up in index. - // d are the values that get overwritten, never to be seen again. - - if !overlaps(v, s[i+m:]) { - // Easy case - v does not overlap either the c or d regions. - // (It might be in some of a or b, or elsewhere entirely.) - // The data we copy up doesn't write to v at all, so just do it. - - copy(s[i+m:], s[i:]) - - // Now we have - // s: aaaaaaaabbbbbbbbcccccccc - // ^ ^ ^ ^ - // i i+m n n+m - // Note the b values are duplicated. - - copy(s[i:], v) - - // Now we have - // s: aaaaaaaavvvvbbbbcccccccc - // ^ ^ ^ ^ - // i i+m n n+m - // That's the result we want. - return s - } - - // The hard case - v overlaps c or d. We can't just shift up - // the data because we'd move or clobber the values we're trying - // to insert. - // So instead, write v on top of d, then rotate. - copy(s[n:], v) - - // Now we have - // s: aaaaaaaabbbbccccccccvvvv - // ^ ^ ^ ^ - // i i+m n n+m - - rotateRight(s[i:], m) - - // Now we have - // s: aaaaaaaavvvvbbbbcccccccc - // ^ ^ ^ ^ - // i i+m n n+m - // That's the result we want. - return s -} - -// clearSlice sets all elements up to the length of s to the zero value of E. -// We may use the builtin clear func instead, and remove clearSlice, when upgrading -// to Go 1.21+. -func clearSlice[S ~[]E, E any](s S) { - var zero E - for i := range s { - s[i] = zero - } + s2 := make(S, tot) + copy(s2, s[:i]) + copy(s2[i:], v) + copy(s2[i+len(v):], s[i:]) + return s2 } // Delete removes the elements s[i:j] from s, returning the modified slice. -// Delete panics if j > len(s) or s[i:j] is not a valid slice of s. -// Delete is O(len(s)-i), so if many items must be deleted, it is better to +// Delete panics if s[i:j] is not a valid slice of s. +// Delete modifies the contents of the slice s; it does not create a new slice. +// Delete is O(len(s)-j), so if many items must be deleted, it is better to // make a single call deleting them all together than to delete one at a time. -// Delete zeroes the elements s[len(s)-(j-i):len(s)]. +// Delete might not modify the elements s[len(s)-(j-i):len(s)]. If those +// elements contain pointers you might consider zeroing those elements so that +// objects they reference can be garbage collected. func Delete[S ~[]E, E any](s S, i, j int) S { - _ = s[i:j:len(s)] // bounds check - - if i == j { - return s - } + _ = s[i:j] // bounds check - oldlen := len(s) - s = append(s[:i], s[j:]...) - clearSlice(s[len(s):oldlen]) // zero/nil out the obsolete elements, for GC - return s + return append(s[:i], s[j:]...) } // DeleteFunc removes any elements from s for which del returns true, // returning the modified slice. -// DeleteFunc zeroes the elements between the new length and the original length. +// When DeleteFunc removes m elements, it might not modify the elements +// s[len(s)-m:len(s)]. If those elements contain pointers you might consider +// zeroing those elements so that objects they reference can be garbage +// collected. func DeleteFunc[S ~[]E, E any](s S, del func(E) bool) S { - i := IndexFunc(s, del) - if i == -1 { - return s - } // Don't start copying elements until we find one to delete. - for j := i + 1; j < len(s); j++ { - if v := s[j]; !del(v) { - s[i] = v - i++ + for i, v := range s { + if del(v) { + j := i + for i++; i < len(s); i++ { + v = s[i] + if !del(v) { + s[j] = v + j++ + } + } + return s[:j] } } - clearSlice(s[i:]) // zero/nil out the obsolete elements, for GC - return s[:i] + return s } // Replace replaces the elements s[i:j] by the given v, and returns the // modified slice. Replace panics if s[i:j] is not a valid slice of s. -// When len(v) < (j-i), Replace zeroes the elements between the new length and the original length. func Replace[S ~[]E, E any](s S, i, j int, v ...E) S { _ = s[i:j] // verify that i:j is a valid subslice - - if i == j { - return Insert(s, i, v...) - } - if j == len(s) { - return append(s[:i], v...) - } - tot := len(s[:i]) + len(v) + len(s[j:]) - if tot > cap(s) { - // Too big to fit, allocate and copy over. - s2 := append(s[:i], make(S, tot-i)...) // See Insert - copy(s2[i:], v) + if tot <= cap(s) { + s2 := s[:tot] copy(s2[i+len(v):], s[j:]) + copy(s2[i:], v) return s2 } - - r := s[:tot] - - if i+len(v) <= j { - // Easy, as v fits in the deleted portion. - copy(r[i:], v) - if i+len(v) != j { - copy(r[i+len(v):], s[j:]) - } - clearSlice(s[tot:]) // zero/nil out the obsolete elements, for GC - return r - } - - // We are expanding (v is bigger than j-i). - // The situation is something like this: - // (example has i=4,j=8,len(s)=16,len(v)=6) - // s: aaaaxxxxbbbbbbbbyy - // ^ ^ ^ ^ - // i j len(s) tot - // a: prefix of s - // x: deleted range - // b: more of s - // y: area to expand into - - if !overlaps(r[i+len(v):], v) { - // Easy, as v is not clobbered by the first copy. - copy(r[i+len(v):], s[j:]) - copy(r[i:], v) - return r - } - - // This is a situation where we don't have a single place to which - // we can copy v. Parts of it need to go to two different places. - // We want to copy the prefix of v into y and the suffix into x, then - // rotate |y| spots to the right. - // - // v[2:] v[:2] - // | | - // s: aaaavvvvbbbbbbbbvv - // ^ ^ ^ ^ - // i j len(s) tot - // - // If either of those two destinations don't alias v, then we're good. - y := len(v) - (j - i) // length of y portion - - if !overlaps(r[i:j], v) { - copy(r[i:j], v[y:]) - copy(r[len(s):], v[:y]) - rotateRight(r[i:], y) - return r - } - if !overlaps(r[len(s):], v) { - copy(r[len(s):], v[:y]) - copy(r[i:j], v[y:]) - rotateRight(r[i:], y) - return r - } - - // Now we know that v overlaps both x and y. - // That means that the entirety of b is *inside* v. - // So we don't need to preserve b at all; instead we - // can copy v first, then copy the b part of v out of - // v to the right destination. - k := startIdx(v, s[j:]) - copy(r[i:], v) - copy(r[i+len(v):], r[i+k:]) - return r + s2 := make(S, tot) + copy(s2, s[:i]) + copy(s2[i:], v) + copy(s2[i+len(v):], s[j:]) + return s2 } // Clone returns a copy of the slice. @@ -358,9 +222,10 @@ func Clone[S ~[]E, E any](s S) S { // Compact replaces consecutive runs of equal elements with a single copy. // This is like the uniq command found on Unix. -// Compact modifies the contents of the slice s and returns the modified slice, -// which may have a smaller length. -// Compact zeroes the elements between the new length and the original length. +// Compact modifies the contents of the slice s; it does not create a new slice. +// When Compact discards m elements in total, it might not modify the elements +// s[len(s)-m:len(s)]. If those elements contain pointers you might consider +// zeroing those elements so that objects they reference can be garbage collected. func Compact[S ~[]E, E comparable](s S) S { if len(s) < 2 { return s @@ -374,13 +239,10 @@ func Compact[S ~[]E, E comparable](s S) S { i++ } } - clearSlice(s[i:]) // zero/nil out the obsolete elements, for GC return s[:i] } -// CompactFunc is like [Compact] but uses an equality function to compare elements. -// For runs of elements that compare equal, CompactFunc keeps the first one. -// CompactFunc zeroes the elements between the new length and the original length. +// CompactFunc is like Compact but uses a comparison function. func CompactFunc[S ~[]E, E any](s S, eq func(E, E) bool) S { if len(s) < 2 { return s @@ -394,7 +256,6 @@ func CompactFunc[S ~[]E, E any](s S, eq func(E, E) bool) S { i++ } } - clearSlice(s[i:]) // zero/nil out the obsolete elements, for GC return s[:i] } @@ -419,97 +280,3 @@ func Grow[S ~[]E, E any](s S, n int) S { func Clip[S ~[]E, E any](s S) S { return s[:len(s):len(s)] } - -// Rotation algorithm explanation: -// -// rotate left by 2 -// start with -// 0123456789 -// split up like this -// 01 234567 89 -// swap first 2 and last 2 -// 89 234567 01 -// join first parts -// 89234567 01 -// recursively rotate first left part by 2 -// 23456789 01 -// join at the end -// 2345678901 -// -// rotate left by 8 -// start with -// 0123456789 -// split up like this -// 01 234567 89 -// swap first 2 and last 2 -// 89 234567 01 -// join last parts -// 89 23456701 -// recursively rotate second part left by 6 -// 89 01234567 -// join at the end -// 8901234567 - -// TODO: There are other rotate algorithms. -// This algorithm has the desirable property that it moves each element exactly twice. -// The triple-reverse algorithm is simpler and more cache friendly, but takes more writes. -// The follow-cycles algorithm can be 1-write but it is not very cache friendly. - -// rotateLeft rotates b left by n spaces. -// s_final[i] = s_orig[i+r], wrapping around. -func rotateLeft[E any](s []E, r int) { - for r != 0 && r != len(s) { - if r*2 <= len(s) { - swap(s[:r], s[len(s)-r:]) - s = s[:len(s)-r] - } else { - swap(s[:len(s)-r], s[r:]) - s, r = s[len(s)-r:], r*2-len(s) - } - } -} -func rotateRight[E any](s []E, r int) { - rotateLeft(s, len(s)-r) -} - -// swap swaps the contents of x and y. x and y must be equal length and disjoint. -func swap[E any](x, y []E) { - for i := 0; i < len(x); i++ { - x[i], y[i] = y[i], x[i] - } -} - -// overlaps reports whether the memory ranges a[0:len(a)] and b[0:len(b)] overlap. -func overlaps[E any](a, b []E) bool { - if len(a) == 0 || len(b) == 0 { - return false - } - elemSize := unsafe.Sizeof(a[0]) - if elemSize == 0 { - return false - } - // TODO: use a runtime/unsafe facility once one becomes available. See issue 12445. - // Also see crypto/internal/alias/alias.go:AnyOverlap - return uintptr(unsafe.Pointer(&a[0])) <= uintptr(unsafe.Pointer(&b[len(b)-1]))+(elemSize-1) && - uintptr(unsafe.Pointer(&b[0])) <= uintptr(unsafe.Pointer(&a[len(a)-1]))+(elemSize-1) -} - -// startIdx returns the index in haystack where the needle starts. -// prerequisite: the needle must be aliased entirely inside the haystack. -func startIdx[E any](haystack, needle []E) int { - p := &needle[0] - for i := range haystack { - if p == &haystack[i] { - return i - } - } - // TODO: what if the overlap is by a non-integral number of Es? - panic("needle not found") -} - -// Reverse reverses the elements of the slice in place. -func Reverse[S ~[]E, E any](s S) { - for i, j := 0, len(s)-1; i < j; i, j = i+1, j-1 { - s[i], s[j] = s[j], s[i] - } -} diff --git a/vendor/golang.org/x/exp/slices/sort.go b/vendor/golang.org/x/exp/slices/sort.go index b67897f76..231b6448a 100644 --- a/vendor/golang.org/x/exp/slices/sort.go +++ b/vendor/golang.org/x/exp/slices/sort.go @@ -2,8 +2,6 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -//go:generate go run $GOROOT/src/sort/gen_sort_variants.go -exp - package slices import ( @@ -13,116 +11,57 @@ import ( ) // Sort sorts a slice of any ordered type in ascending order. -// When sorting floating-point numbers, NaNs are ordered before other values. -func Sort[S ~[]E, E constraints.Ordered](x S) { +// Sort may fail to sort correctly when sorting slices of floating-point +// numbers containing Not-a-number (NaN) values. +// Use slices.SortFunc(x, func(a, b float64) bool {return a < b || (math.IsNaN(a) && !math.IsNaN(b))}) +// instead if the input may contain NaNs. +func Sort[E constraints.Ordered](x []E) { n := len(x) pdqsortOrdered(x, 0, n, bits.Len(uint(n))) } -// SortFunc sorts the slice x in ascending order as determined by the cmp -// function. This sort is not guaranteed to be stable. -// cmp(a, b) should return a negative number when a < b, a positive number when -// a > b and zero when a == b. +// SortFunc sorts the slice x in ascending order as determined by the less function. +// This sort is not guaranteed to be stable. // -// SortFunc requires that cmp is a strict weak ordering. +// SortFunc requires that less is a strict weak ordering. // See https://en.wikipedia.org/wiki/Weak_ordering#Strict_weak_orderings. -func SortFunc[S ~[]E, E any](x S, cmp func(a, b E) int) { +func SortFunc[E any](x []E, less func(a, b E) bool) { n := len(x) - pdqsortCmpFunc(x, 0, n, bits.Len(uint(n)), cmp) + pdqsortLessFunc(x, 0, n, bits.Len(uint(n)), less) } // SortStableFunc sorts the slice x while keeping the original order of equal -// elements, using cmp to compare elements in the same way as [SortFunc]. -func SortStableFunc[S ~[]E, E any](x S, cmp func(a, b E) int) { - stableCmpFunc(x, len(x), cmp) +// elements, using less to compare elements. +func SortStableFunc[E any](x []E, less func(a, b E) bool) { + stableLessFunc(x, len(x), less) } // IsSorted reports whether x is sorted in ascending order. -func IsSorted[S ~[]E, E constraints.Ordered](x S) bool { +func IsSorted[E constraints.Ordered](x []E) bool { for i := len(x) - 1; i > 0; i-- { - if cmpLess(x[i], x[i-1]) { + if x[i] < x[i-1] { return false } } return true } -// IsSortedFunc reports whether x is sorted in ascending order, with cmp as the -// comparison function as defined by [SortFunc]. -func IsSortedFunc[S ~[]E, E any](x S, cmp func(a, b E) int) bool { +// IsSortedFunc reports whether x is sorted in ascending order, with less as the +// comparison function. +func IsSortedFunc[E any](x []E, less func(a, b E) bool) bool { for i := len(x) - 1; i > 0; i-- { - if cmp(x[i], x[i-1]) < 0 { + if less(x[i], x[i-1]) { return false } } return true } -// Min returns the minimal value in x. It panics if x is empty. -// For floating-point numbers, Min propagates NaNs (any NaN value in x -// forces the output to be NaN). -func Min[S ~[]E, E constraints.Ordered](x S) E { - if len(x) < 1 { - panic("slices.Min: empty list") - } - m := x[0] - for i := 1; i < len(x); i++ { - m = min(m, x[i]) - } - return m -} - -// MinFunc returns the minimal value in x, using cmp to compare elements. -// It panics if x is empty. If there is more than one minimal element -// according to the cmp function, MinFunc returns the first one. -func MinFunc[S ~[]E, E any](x S, cmp func(a, b E) int) E { - if len(x) < 1 { - panic("slices.MinFunc: empty list") - } - m := x[0] - for i := 1; i < len(x); i++ { - if cmp(x[i], m) < 0 { - m = x[i] - } - } - return m -} - -// Max returns the maximal value in x. It panics if x is empty. -// For floating-point E, Max propagates NaNs (any NaN value in x -// forces the output to be NaN). -func Max[S ~[]E, E constraints.Ordered](x S) E { - if len(x) < 1 { - panic("slices.Max: empty list") - } - m := x[0] - for i := 1; i < len(x); i++ { - m = max(m, x[i]) - } - return m -} - -// MaxFunc returns the maximal value in x, using cmp to compare elements. -// It panics if x is empty. If there is more than one maximal element -// according to the cmp function, MaxFunc returns the first one. -func MaxFunc[S ~[]E, E any](x S, cmp func(a, b E) int) E { - if len(x) < 1 { - panic("slices.MaxFunc: empty list") - } - m := x[0] - for i := 1; i < len(x); i++ { - if cmp(x[i], m) > 0 { - m = x[i] - } - } - return m -} - // BinarySearch searches for target in a sorted slice and returns the position // where target is found, or the position where target would appear in the // sort order; it also returns a bool saying whether the target is really found // in the slice. The slice must be sorted in increasing order. -func BinarySearch[S ~[]E, E constraints.Ordered](x S, target E) (int, bool) { +func BinarySearch[E constraints.Ordered](x []E, target E) (int, bool) { // Inlining is faster than calling BinarySearchFunc with a lambda. n := len(x) // Define x[-1] < target and x[n] >= target. @@ -131,24 +70,24 @@ func BinarySearch[S ~[]E, E constraints.Ordered](x S, target E) (int, bool) { for i < j { h := int(uint(i+j) >> 1) // avoid overflow when computing h // i ≤ h < j - if cmpLess(x[h], target) { + if x[h] < target { i = h + 1 // preserves x[i-1] < target } else { j = h // preserves x[j] >= target } } // i == j, x[i-1] < target, and x[j] (= x[i]) >= target => answer is i. - return i, i < n && (x[i] == target || (isNaN(x[i]) && isNaN(target))) + return i, i < n && x[i] == target } -// BinarySearchFunc works like [BinarySearch], but uses a custom comparison +// BinarySearchFunc works like BinarySearch, but uses a custom comparison // function. The slice must be sorted in increasing order, where "increasing" // is defined by cmp. cmp should return 0 if the slice element matches // the target, a negative number if the slice element precedes the target, // or a positive number if the slice element follows the target. // cmp must implement the same ordering as the slice, such that if // cmp(a, t) < 0 and cmp(b, t) >= 0, then a must precede b in the slice. -func BinarySearchFunc[S ~[]E, E, T any](x S, target T, cmp func(E, T) int) (int, bool) { +func BinarySearchFunc[E, T any](x []E, target T, cmp func(E, T) int) (int, bool) { n := len(x) // Define cmp(x[-1], target) < 0 and cmp(x[n], target) >= 0 . // Invariant: cmp(x[i - 1], target) < 0, cmp(x[j], target) >= 0. @@ -187,9 +126,3 @@ func (r *xorshift) Next() uint64 { func nextPowerOfTwo(length int) uint { return 1 << bits.Len(uint(length)) } - -// isNaN reports whether x is a NaN without requiring the math package. -// This will always return false if T is not floating-point. -func isNaN[T constraints.Ordered](x T) bool { - return x != x -} diff --git a/vendor/golang.org/x/exp/slices/zsortanyfunc.go b/vendor/golang.org/x/exp/slices/zsortfunc.go similarity index 64% rename from vendor/golang.org/x/exp/slices/zsortanyfunc.go rename to vendor/golang.org/x/exp/slices/zsortfunc.go index 06f2c7a24..2a632476c 100644 --- a/vendor/golang.org/x/exp/slices/zsortanyfunc.go +++ b/vendor/golang.org/x/exp/slices/zsortfunc.go @@ -6,28 +6,28 @@ package slices -// insertionSortCmpFunc sorts data[a:b] using insertion sort. -func insertionSortCmpFunc[E any](data []E, a, b int, cmp func(a, b E) int) { +// insertionSortLessFunc sorts data[a:b] using insertion sort. +func insertionSortLessFunc[E any](data []E, a, b int, less func(a, b E) bool) { for i := a + 1; i < b; i++ { - for j := i; j > a && (cmp(data[j], data[j-1]) < 0); j-- { + for j := i; j > a && less(data[j], data[j-1]); j-- { data[j], data[j-1] = data[j-1], data[j] } } } -// siftDownCmpFunc implements the heap property on data[lo:hi]. +// siftDownLessFunc implements the heap property on data[lo:hi]. // first is an offset into the array where the root of the heap lies. -func siftDownCmpFunc[E any](data []E, lo, hi, first int, cmp func(a, b E) int) { +func siftDownLessFunc[E any](data []E, lo, hi, first int, less func(a, b E) bool) { root := lo for { child := 2*root + 1 if child >= hi { break } - if child+1 < hi && (cmp(data[first+child], data[first+child+1]) < 0) { + if child+1 < hi && less(data[first+child], data[first+child+1]) { child++ } - if !(cmp(data[first+root], data[first+child]) < 0) { + if !less(data[first+root], data[first+child]) { return } data[first+root], data[first+child] = data[first+child], data[first+root] @@ -35,30 +35,30 @@ func siftDownCmpFunc[E any](data []E, lo, hi, first int, cmp func(a, b E) int) { } } -func heapSortCmpFunc[E any](data []E, a, b int, cmp func(a, b E) int) { +func heapSortLessFunc[E any](data []E, a, b int, less func(a, b E) bool) { first := a lo := 0 hi := b - a // Build heap with greatest element at top. for i := (hi - 1) / 2; i >= 0; i-- { - siftDownCmpFunc(data, i, hi, first, cmp) + siftDownLessFunc(data, i, hi, first, less) } // Pop elements, largest first, into end of data. for i := hi - 1; i >= 0; i-- { data[first], data[first+i] = data[first+i], data[first] - siftDownCmpFunc(data, lo, i, first, cmp) + siftDownLessFunc(data, lo, i, first, less) } } -// pdqsortCmpFunc sorts data[a:b]. +// pdqsortLessFunc sorts data[a:b]. // The algorithm based on pattern-defeating quicksort(pdqsort), but without the optimizations from BlockQuicksort. // pdqsort paper: https://arxiv.org/pdf/2106.05123.pdf // C++ implementation: https://github.com/orlp/pdqsort // Rust implementation: https://docs.rs/pdqsort/latest/pdqsort/ // limit is the number of allowed bad (very unbalanced) pivots before falling back to heapsort. -func pdqsortCmpFunc[E any](data []E, a, b, limit int, cmp func(a, b E) int) { +func pdqsortLessFunc[E any](data []E, a, b, limit int, less func(a, b E) bool) { const maxInsertion = 12 var ( @@ -70,25 +70,25 @@ func pdqsortCmpFunc[E any](data []E, a, b, limit int, cmp func(a, b E) int) { length := b - a if length <= maxInsertion { - insertionSortCmpFunc(data, a, b, cmp) + insertionSortLessFunc(data, a, b, less) return } // Fall back to heapsort if too many bad choices were made. if limit == 0 { - heapSortCmpFunc(data, a, b, cmp) + heapSortLessFunc(data, a, b, less) return } // If the last partitioning was imbalanced, we need to breaking patterns. if !wasBalanced { - breakPatternsCmpFunc(data, a, b, cmp) + breakPatternsLessFunc(data, a, b, less) limit-- } - pivot, hint := choosePivotCmpFunc(data, a, b, cmp) + pivot, hint := choosePivotLessFunc(data, a, b, less) if hint == decreasingHint { - reverseRangeCmpFunc(data, a, b, cmp) + reverseRangeLessFunc(data, a, b, less) // The chosen pivot was pivot-a elements after the start of the array. // After reversing it is pivot-a elements before the end of the array. // The idea came from Rust's implementation. @@ -98,48 +98,48 @@ func pdqsortCmpFunc[E any](data []E, a, b, limit int, cmp func(a, b E) int) { // The slice is likely already sorted. if wasBalanced && wasPartitioned && hint == increasingHint { - if partialInsertionSortCmpFunc(data, a, b, cmp) { + if partialInsertionSortLessFunc(data, a, b, less) { return } } // Probably the slice contains many duplicate elements, partition the slice into // elements equal to and elements greater than the pivot. - if a > 0 && !(cmp(data[a-1], data[pivot]) < 0) { - mid := partitionEqualCmpFunc(data, a, b, pivot, cmp) + if a > 0 && !less(data[a-1], data[pivot]) { + mid := partitionEqualLessFunc(data, a, b, pivot, less) a = mid continue } - mid, alreadyPartitioned := partitionCmpFunc(data, a, b, pivot, cmp) + mid, alreadyPartitioned := partitionLessFunc(data, a, b, pivot, less) wasPartitioned = alreadyPartitioned leftLen, rightLen := mid-a, b-mid balanceThreshold := length / 8 if leftLen < rightLen { wasBalanced = leftLen >= balanceThreshold - pdqsortCmpFunc(data, a, mid, limit, cmp) + pdqsortLessFunc(data, a, mid, limit, less) a = mid + 1 } else { wasBalanced = rightLen >= balanceThreshold - pdqsortCmpFunc(data, mid+1, b, limit, cmp) + pdqsortLessFunc(data, mid+1, b, limit, less) b = mid } } } -// partitionCmpFunc does one quicksort partition. +// partitionLessFunc does one quicksort partition. // Let p = data[pivot] // Moves elements in data[a:b] around, so that data[i]

=p for inewpivot. // On return, data[newpivot] = p -func partitionCmpFunc[E any](data []E, a, b, pivot int, cmp func(a, b E) int) (newpivot int, alreadyPartitioned bool) { +func partitionLessFunc[E any](data []E, a, b, pivot int, less func(a, b E) bool) (newpivot int, alreadyPartitioned bool) { data[a], data[pivot] = data[pivot], data[a] i, j := a+1, b-1 // i and j are inclusive of the elements remaining to be partitioned - for i <= j && (cmp(data[i], data[a]) < 0) { + for i <= j && less(data[i], data[a]) { i++ } - for i <= j && !(cmp(data[j], data[a]) < 0) { + for i <= j && !less(data[j], data[a]) { j-- } if i > j { @@ -151,10 +151,10 @@ func partitionCmpFunc[E any](data []E, a, b, pivot int, cmp func(a, b E) int) (n j-- for { - for i <= j && (cmp(data[i], data[a]) < 0) { + for i <= j && less(data[i], data[a]) { i++ } - for i <= j && !(cmp(data[j], data[a]) < 0) { + for i <= j && !less(data[j], data[a]) { j-- } if i > j { @@ -168,17 +168,17 @@ func partitionCmpFunc[E any](data []E, a, b, pivot int, cmp func(a, b E) int) (n return j, false } -// partitionEqualCmpFunc partitions data[a:b] into elements equal to data[pivot] followed by elements greater than data[pivot]. +// partitionEqualLessFunc partitions data[a:b] into elements equal to data[pivot] followed by elements greater than data[pivot]. // It assumed that data[a:b] does not contain elements smaller than the data[pivot]. -func partitionEqualCmpFunc[E any](data []E, a, b, pivot int, cmp func(a, b E) int) (newpivot int) { +func partitionEqualLessFunc[E any](data []E, a, b, pivot int, less func(a, b E) bool) (newpivot int) { data[a], data[pivot] = data[pivot], data[a] i, j := a+1, b-1 // i and j are inclusive of the elements remaining to be partitioned for { - for i <= j && !(cmp(data[a], data[i]) < 0) { + for i <= j && !less(data[a], data[i]) { i++ } - for i <= j && (cmp(data[a], data[j]) < 0) { + for i <= j && less(data[a], data[j]) { j-- } if i > j { @@ -191,15 +191,15 @@ func partitionEqualCmpFunc[E any](data []E, a, b, pivot int, cmp func(a, b E) in return i } -// partialInsertionSortCmpFunc partially sorts a slice, returns true if the slice is sorted at the end. -func partialInsertionSortCmpFunc[E any](data []E, a, b int, cmp func(a, b E) int) bool { +// partialInsertionSortLessFunc partially sorts a slice, returns true if the slice is sorted at the end. +func partialInsertionSortLessFunc[E any](data []E, a, b int, less func(a, b E) bool) bool { const ( maxSteps = 5 // maximum number of adjacent out-of-order pairs that will get shifted shortestShifting = 50 // don't shift any elements on short arrays ) i := a + 1 for j := 0; j < maxSteps; j++ { - for i < b && !(cmp(data[i], data[i-1]) < 0) { + for i < b && !less(data[i], data[i-1]) { i++ } @@ -216,7 +216,7 @@ func partialInsertionSortCmpFunc[E any](data []E, a, b int, cmp func(a, b E) int // Shift the smaller one to the left. if i-a >= 2 { for j := i - 1; j >= 1; j-- { - if !(cmp(data[j], data[j-1]) < 0) { + if !less(data[j], data[j-1]) { break } data[j], data[j-1] = data[j-1], data[j] @@ -225,7 +225,7 @@ func partialInsertionSortCmpFunc[E any](data []E, a, b int, cmp func(a, b E) int // Shift the greater one to the right. if b-i >= 2 { for j := i + 1; j < b; j++ { - if !(cmp(data[j], data[j-1]) < 0) { + if !less(data[j], data[j-1]) { break } data[j], data[j-1] = data[j-1], data[j] @@ -235,9 +235,9 @@ func partialInsertionSortCmpFunc[E any](data []E, a, b int, cmp func(a, b E) int return false } -// breakPatternsCmpFunc scatters some elements around in an attempt to break some patterns +// breakPatternsLessFunc scatters some elements around in an attempt to break some patterns // that might cause imbalanced partitions in quicksort. -func breakPatternsCmpFunc[E any](data []E, a, b int, cmp func(a, b E) int) { +func breakPatternsLessFunc[E any](data []E, a, b int, less func(a, b E) bool) { length := b - a if length >= 8 { random := xorshift(length) @@ -253,12 +253,12 @@ func breakPatternsCmpFunc[E any](data []E, a, b int, cmp func(a, b E) int) { } } -// choosePivotCmpFunc chooses a pivot in data[a:b]. +// choosePivotLessFunc chooses a pivot in data[a:b]. // // [0,8): chooses a static pivot. // [8,shortestNinther): uses the simple median-of-three method. // [shortestNinther,∞): uses the Tukey ninther method. -func choosePivotCmpFunc[E any](data []E, a, b int, cmp func(a, b E) int) (pivot int, hint sortedHint) { +func choosePivotLessFunc[E any](data []E, a, b int, less func(a, b E) bool) (pivot int, hint sortedHint) { const ( shortestNinther = 50 maxSwaps = 4 * 3 @@ -276,12 +276,12 @@ func choosePivotCmpFunc[E any](data []E, a, b int, cmp func(a, b E) int) (pivot if l >= 8 { if l >= shortestNinther { // Tukey ninther method, the idea came from Rust's implementation. - i = medianAdjacentCmpFunc(data, i, &swaps, cmp) - j = medianAdjacentCmpFunc(data, j, &swaps, cmp) - k = medianAdjacentCmpFunc(data, k, &swaps, cmp) + i = medianAdjacentLessFunc(data, i, &swaps, less) + j = medianAdjacentLessFunc(data, j, &swaps, less) + k = medianAdjacentLessFunc(data, k, &swaps, less) } // Find the median among i, j, k and stores it into j. - j = medianCmpFunc(data, i, j, k, &swaps, cmp) + j = medianLessFunc(data, i, j, k, &swaps, less) } switch swaps { @@ -294,29 +294,29 @@ func choosePivotCmpFunc[E any](data []E, a, b int, cmp func(a, b E) int) (pivot } } -// order2CmpFunc returns x,y where data[x] <= data[y], where x,y=a,b or x,y=b,a. -func order2CmpFunc[E any](data []E, a, b int, swaps *int, cmp func(a, b E) int) (int, int) { - if cmp(data[b], data[a]) < 0 { +// order2LessFunc returns x,y where data[x] <= data[y], where x,y=a,b or x,y=b,a. +func order2LessFunc[E any](data []E, a, b int, swaps *int, less func(a, b E) bool) (int, int) { + if less(data[b], data[a]) { *swaps++ return b, a } return a, b } -// medianCmpFunc returns x where data[x] is the median of data[a],data[b],data[c], where x is a, b, or c. -func medianCmpFunc[E any](data []E, a, b, c int, swaps *int, cmp func(a, b E) int) int { - a, b = order2CmpFunc(data, a, b, swaps, cmp) - b, c = order2CmpFunc(data, b, c, swaps, cmp) - a, b = order2CmpFunc(data, a, b, swaps, cmp) +// medianLessFunc returns x where data[x] is the median of data[a],data[b],data[c], where x is a, b, or c. +func medianLessFunc[E any](data []E, a, b, c int, swaps *int, less func(a, b E) bool) int { + a, b = order2LessFunc(data, a, b, swaps, less) + b, c = order2LessFunc(data, b, c, swaps, less) + a, b = order2LessFunc(data, a, b, swaps, less) return b } -// medianAdjacentCmpFunc finds the median of data[a - 1], data[a], data[a + 1] and stores the index into a. -func medianAdjacentCmpFunc[E any](data []E, a int, swaps *int, cmp func(a, b E) int) int { - return medianCmpFunc(data, a-1, a, a+1, swaps, cmp) +// medianAdjacentLessFunc finds the median of data[a - 1], data[a], data[a + 1] and stores the index into a. +func medianAdjacentLessFunc[E any](data []E, a int, swaps *int, less func(a, b E) bool) int { + return medianLessFunc(data, a-1, a, a+1, swaps, less) } -func reverseRangeCmpFunc[E any](data []E, a, b int, cmp func(a, b E) int) { +func reverseRangeLessFunc[E any](data []E, a, b int, less func(a, b E) bool) { i := a j := b - 1 for i < j { @@ -326,37 +326,37 @@ func reverseRangeCmpFunc[E any](data []E, a, b int, cmp func(a, b E) int) { } } -func swapRangeCmpFunc[E any](data []E, a, b, n int, cmp func(a, b E) int) { +func swapRangeLessFunc[E any](data []E, a, b, n int, less func(a, b E) bool) { for i := 0; i < n; i++ { data[a+i], data[b+i] = data[b+i], data[a+i] } } -func stableCmpFunc[E any](data []E, n int, cmp func(a, b E) int) { +func stableLessFunc[E any](data []E, n int, less func(a, b E) bool) { blockSize := 20 // must be > 0 a, b := 0, blockSize for b <= n { - insertionSortCmpFunc(data, a, b, cmp) + insertionSortLessFunc(data, a, b, less) a = b b += blockSize } - insertionSortCmpFunc(data, a, n, cmp) + insertionSortLessFunc(data, a, n, less) for blockSize < n { a, b = 0, 2*blockSize for b <= n { - symMergeCmpFunc(data, a, a+blockSize, b, cmp) + symMergeLessFunc(data, a, a+blockSize, b, less) a = b b += 2 * blockSize } if m := a + blockSize; m < n { - symMergeCmpFunc(data, a, m, n, cmp) + symMergeLessFunc(data, a, m, n, less) } blockSize *= 2 } } -// symMergeCmpFunc merges the two sorted subsequences data[a:m] and data[m:b] using +// symMergeLessFunc merges the two sorted subsequences data[a:m] and data[m:b] using // the SymMerge algorithm from Pok-Son Kim and Arne Kutzner, "Stable Minimum // Storage Merging by Symmetric Comparisons", in Susanne Albers and Tomasz // Radzik, editors, Algorithms - ESA 2004, volume 3221 of Lecture Notes in @@ -375,7 +375,7 @@ func stableCmpFunc[E any](data []E, n int, cmp func(a, b E) int) { // symMerge assumes non-degenerate arguments: a < m && m < b. // Having the caller check this condition eliminates many leaf recursion calls, // which improves performance. -func symMergeCmpFunc[E any](data []E, a, m, b int, cmp func(a, b E) int) { +func symMergeLessFunc[E any](data []E, a, m, b int, less func(a, b E) bool) { // Avoid unnecessary recursions of symMerge // by direct insertion of data[a] into data[m:b] // if data[a:m] only contains one element. @@ -387,7 +387,7 @@ func symMergeCmpFunc[E any](data []E, a, m, b int, cmp func(a, b E) int) { j := b for i < j { h := int(uint(i+j) >> 1) - if cmp(data[h], data[a]) < 0 { + if less(data[h], data[a]) { i = h + 1 } else { j = h @@ -411,7 +411,7 @@ func symMergeCmpFunc[E any](data []E, a, m, b int, cmp func(a, b E) int) { j := m for i < j { h := int(uint(i+j) >> 1) - if !(cmp(data[m], data[h]) < 0) { + if !less(data[m], data[h]) { i = h + 1 } else { j = h @@ -438,7 +438,7 @@ func symMergeCmpFunc[E any](data []E, a, m, b int, cmp func(a, b E) int) { for start < r { c := int(uint(start+r) >> 1) - if !(cmp(data[p-c], data[c]) < 0) { + if !less(data[p-c], data[c]) { start = c + 1 } else { r = c @@ -447,33 +447,33 @@ func symMergeCmpFunc[E any](data []E, a, m, b int, cmp func(a, b E) int) { end := n - start if start < m && m < end { - rotateCmpFunc(data, start, m, end, cmp) + rotateLessFunc(data, start, m, end, less) } if a < start && start < mid { - symMergeCmpFunc(data, a, start, mid, cmp) + symMergeLessFunc(data, a, start, mid, less) } if mid < end && end < b { - symMergeCmpFunc(data, mid, end, b, cmp) + symMergeLessFunc(data, mid, end, b, less) } } -// rotateCmpFunc rotates two consecutive blocks u = data[a:m] and v = data[m:b] in data: +// rotateLessFunc rotates two consecutive blocks u = data[a:m] and v = data[m:b] in data: // Data of the form 'x u v y' is changed to 'x v u y'. // rotate performs at most b-a many calls to data.Swap, // and it assumes non-degenerate arguments: a < m && m < b. -func rotateCmpFunc[E any](data []E, a, m, b int, cmp func(a, b E) int) { +func rotateLessFunc[E any](data []E, a, m, b int, less func(a, b E) bool) { i := m - a j := b - m for i != j { if i > j { - swapRangeCmpFunc(data, m-i, m, j, cmp) + swapRangeLessFunc(data, m-i, m, j, less) i -= j } else { - swapRangeCmpFunc(data, m-i, m+j-i, i, cmp) + swapRangeLessFunc(data, m-i, m+j-i, i, less) j -= i } } // i == j - swapRangeCmpFunc(data, m-i, m, i, cmp) + swapRangeLessFunc(data, m-i, m, i, less) } diff --git a/vendor/golang.org/x/exp/slices/zsortordered.go b/vendor/golang.org/x/exp/slices/zsortordered.go index 99b47c398..efaa1c8b7 100644 --- a/vendor/golang.org/x/exp/slices/zsortordered.go +++ b/vendor/golang.org/x/exp/slices/zsortordered.go @@ -11,7 +11,7 @@ import "golang.org/x/exp/constraints" // insertionSortOrdered sorts data[a:b] using insertion sort. func insertionSortOrdered[E constraints.Ordered](data []E, a, b int) { for i := a + 1; i < b; i++ { - for j := i; j > a && cmpLess(data[j], data[j-1]); j-- { + for j := i; j > a && (data[j] < data[j-1]); j-- { data[j], data[j-1] = data[j-1], data[j] } } @@ -26,10 +26,10 @@ func siftDownOrdered[E constraints.Ordered](data []E, lo, hi, first int) { if child >= hi { break } - if child+1 < hi && cmpLess(data[first+child], data[first+child+1]) { + if child+1 < hi && (data[first+child] < data[first+child+1]) { child++ } - if !cmpLess(data[first+root], data[first+child]) { + if !(data[first+root] < data[first+child]) { return } data[first+root], data[first+child] = data[first+child], data[first+root] @@ -107,7 +107,7 @@ func pdqsortOrdered[E constraints.Ordered](data []E, a, b, limit int) { // Probably the slice contains many duplicate elements, partition the slice into // elements equal to and elements greater than the pivot. - if a > 0 && !cmpLess(data[a-1], data[pivot]) { + if a > 0 && !(data[a-1] < data[pivot]) { mid := partitionEqualOrdered(data, a, b, pivot) a = mid continue @@ -138,10 +138,10 @@ func partitionOrdered[E constraints.Ordered](data []E, a, b, pivot int) (newpivo data[a], data[pivot] = data[pivot], data[a] i, j := a+1, b-1 // i and j are inclusive of the elements remaining to be partitioned - for i <= j && cmpLess(data[i], data[a]) { + for i <= j && (data[i] < data[a]) { i++ } - for i <= j && !cmpLess(data[j], data[a]) { + for i <= j && !(data[j] < data[a]) { j-- } if i > j { @@ -153,10 +153,10 @@ func partitionOrdered[E constraints.Ordered](data []E, a, b, pivot int) (newpivo j-- for { - for i <= j && cmpLess(data[i], data[a]) { + for i <= j && (data[i] < data[a]) { i++ } - for i <= j && !cmpLess(data[j], data[a]) { + for i <= j && !(data[j] < data[a]) { j-- } if i > j { @@ -177,10 +177,10 @@ func partitionEqualOrdered[E constraints.Ordered](data []E, a, b, pivot int) (ne i, j := a+1, b-1 // i and j are inclusive of the elements remaining to be partitioned for { - for i <= j && !cmpLess(data[a], data[i]) { + for i <= j && !(data[a] < data[i]) { i++ } - for i <= j && cmpLess(data[a], data[j]) { + for i <= j && (data[a] < data[j]) { j-- } if i > j { @@ -201,7 +201,7 @@ func partialInsertionSortOrdered[E constraints.Ordered](data []E, a, b int) bool ) i := a + 1 for j := 0; j < maxSteps; j++ { - for i < b && !cmpLess(data[i], data[i-1]) { + for i < b && !(data[i] < data[i-1]) { i++ } @@ -218,7 +218,7 @@ func partialInsertionSortOrdered[E constraints.Ordered](data []E, a, b int) bool // Shift the smaller one to the left. if i-a >= 2 { for j := i - 1; j >= 1; j-- { - if !cmpLess(data[j], data[j-1]) { + if !(data[j] < data[j-1]) { break } data[j], data[j-1] = data[j-1], data[j] @@ -227,7 +227,7 @@ func partialInsertionSortOrdered[E constraints.Ordered](data []E, a, b int) bool // Shift the greater one to the right. if b-i >= 2 { for j := i + 1; j < b; j++ { - if !cmpLess(data[j], data[j-1]) { + if !(data[j] < data[j-1]) { break } data[j], data[j-1] = data[j-1], data[j] @@ -298,7 +298,7 @@ func choosePivotOrdered[E constraints.Ordered](data []E, a, b int) (pivot int, h // order2Ordered returns x,y where data[x] <= data[y], where x,y=a,b or x,y=b,a. func order2Ordered[E constraints.Ordered](data []E, a, b int, swaps *int) (int, int) { - if cmpLess(data[b], data[a]) { + if data[b] < data[a] { *swaps++ return b, a } @@ -389,7 +389,7 @@ func symMergeOrdered[E constraints.Ordered](data []E, a, m, b int) { j := b for i < j { h := int(uint(i+j) >> 1) - if cmpLess(data[h], data[a]) { + if data[h] < data[a] { i = h + 1 } else { j = h @@ -413,7 +413,7 @@ func symMergeOrdered[E constraints.Ordered](data []E, a, m, b int) { j := m for i < j { h := int(uint(i+j) >> 1) - if !cmpLess(data[m], data[h]) { + if !(data[m] < data[h]) { i = h + 1 } else { j = h @@ -440,7 +440,7 @@ func symMergeOrdered[E constraints.Ordered](data []E, a, m, b int) { for start < r { c := int(uint(start+r) >> 1) - if !cmpLess(data[p-c], data[c]) { + if !(data[p-c] < data[c]) { start = c + 1 } else { r = c diff --git a/vendor/google.golang.org/genproto/googleapis/api/expr/v1alpha1/checked.pb.go b/vendor/google.golang.org/genproto/googleapis/api/expr/v1alpha1/checked.pb.go index 9f81dbcd8..137ff5b1e 100644 --- a/vendor/google.golang.org/genproto/googleapis/api/expr/v1alpha1/checked.pb.go +++ b/vendor/google.golang.org/genproto/googleapis/api/expr/v1alpha1/checked.pb.go @@ -1,4 +1,4 @@ -// Copyright 2024 Google LLC +// Copyright 2023 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/vendor/google.golang.org/genproto/googleapis/api/expr/v1alpha1/eval.pb.go b/vendor/google.golang.org/genproto/googleapis/api/expr/v1alpha1/eval.pb.go index 0a2ffb595..ca4415956 100644 --- a/vendor/google.golang.org/genproto/googleapis/api/expr/v1alpha1/eval.pb.go +++ b/vendor/google.golang.org/genproto/googleapis/api/expr/v1alpha1/eval.pb.go @@ -1,4 +1,4 @@ -// Copyright 2024 Google LLC +// Copyright 2023 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/vendor/google.golang.org/genproto/googleapis/api/expr/v1alpha1/explain.pb.go b/vendor/google.golang.org/genproto/googleapis/api/expr/v1alpha1/explain.pb.go index 57aaa2c9f..3f994b4e3 100644 --- a/vendor/google.golang.org/genproto/googleapis/api/expr/v1alpha1/explain.pb.go +++ b/vendor/google.golang.org/genproto/googleapis/api/expr/v1alpha1/explain.pb.go @@ -1,4 +1,4 @@ -// Copyright 2024 Google LLC +// Copyright 2023 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/vendor/google.golang.org/genproto/googleapis/api/expr/v1alpha1/syntax.pb.go b/vendor/google.golang.org/genproto/googleapis/api/expr/v1alpha1/syntax.pb.go index 6b867a46e..0d718fc36 100644 --- a/vendor/google.golang.org/genproto/googleapis/api/expr/v1alpha1/syntax.pb.go +++ b/vendor/google.golang.org/genproto/googleapis/api/expr/v1alpha1/syntax.pb.go @@ -1,4 +1,4 @@ -// Copyright 2024 Google LLC +// Copyright 2023 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/vendor/google.golang.org/genproto/googleapis/api/expr/v1alpha1/value.pb.go b/vendor/google.golang.org/genproto/googleapis/api/expr/v1alpha1/value.pb.go index 0a5ca6a1b..033f23868 100644 --- a/vendor/google.golang.org/genproto/googleapis/api/expr/v1alpha1/value.pb.go +++ b/vendor/google.golang.org/genproto/googleapis/api/expr/v1alpha1/value.pb.go @@ -1,4 +1,4 @@ -// Copyright 2024 Google LLC +// Copyright 2023 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/vendor/google.golang.org/genproto/googleapis/api/httpbody/httpbody.pb.go b/vendor/google.golang.org/genproto/googleapis/api/httpbody/httpbody.pb.go index e7d3805e3..3543268f8 100644 --- a/vendor/google.golang.org/genproto/googleapis/api/httpbody/httpbody.pb.go +++ b/vendor/google.golang.org/genproto/googleapis/api/httpbody/httpbody.pb.go @@ -1,4 +1,4 @@ -// Copyright 2024 Google LLC +// Copyright 2023 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -15,7 +15,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.26.0 -// protoc v4.24.4 +// protoc v3.21.9 // source: google/api/httpbody.proto package httpbody diff --git a/vendor/google.golang.org/genproto/googleapis/rpc/status/status.pb.go b/vendor/google.golang.org/genproto/googleapis/rpc/status/status.pb.go index 6ad1b1c1d..a6b508188 100644 --- a/vendor/google.golang.org/genproto/googleapis/rpc/status/status.pb.go +++ b/vendor/google.golang.org/genproto/googleapis/rpc/status/status.pb.go @@ -1,4 +1,4 @@ -// Copyright 2024 Google LLC +// Copyright 2022 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -15,7 +15,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.26.0 -// protoc v4.24.4 +// protoc v3.21.9 // source: google/rpc/status.proto package status diff --git a/vendor/kubevirt.io/kubevirt/pkg/virt-launcher/virtwrap/api/testdata/cpu_pinning.xml b/vendor/kubevirt.io/kubevirt/pkg/virt-launcher/virtwrap/api/testdata/cpu_pinning.xml new file mode 100644 index 000000000..05d02e72e --- /dev/null +++ b/vendor/kubevirt.io/kubevirt/pkg/virt-launcher/virtwrap/api/testdata/cpu_pinning.xml @@ -0,0 +1,7 @@ + + + + + + +` diff --git a/vendor/kubevirt.io/kubevirt/pkg/virt-launcher/virtwrap/api/testdata/domain_arm64.xml.tmpl b/vendor/kubevirt.io/kubevirt/pkg/virt-launcher/virtwrap/api/testdata/domain_arm64.xml.tmpl new file mode 100644 index 000000000..eb7b11bd9 --- /dev/null +++ b/vendor/kubevirt.io/kubevirt/pkg/virt-launcher/virtwrap/api/testdata/domain_arm64.xml.tmpl @@ -0,0 +1,78 @@ + + mynamespace_testvmi + 9 + + hvm + + + + e4686d2c-6e8d-4335-b8fd-81bee22f4814 + + + + + + + + + {{ . }} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + /dev/urandom + + + + + f4686d2c-6e8d-4335-b8fd-81bee22f4814 + + 5 + + + + + + + + + + + + + + + Conroe + + + + + 2 + 2 + diff --git a/vendor/kubevirt.io/kubevirt/pkg/virt-launcher/virtwrap/api/testdata/domain_numa_topology.xml b/vendor/kubevirt.io/kubevirt/pkg/virt-launcher/virtwrap/api/testdata/domain_numa_topology.xml new file mode 100644 index 000000000..8c6dba7bc --- /dev/null +++ b/vendor/kubevirt.io/kubevirt/pkg/virt-launcher/virtwrap/api/testdata/domain_numa_topology.xml @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + + + + +` diff --git a/vendor/kubevirt.io/kubevirt/pkg/virt-launcher/virtwrap/api/testdata/domain_ppc64le.xml.tmpl b/vendor/kubevirt.io/kubevirt/pkg/virt-launcher/virtwrap/api/testdata/domain_ppc64le.xml.tmpl new file mode 100644 index 000000000..3cee91b2c --- /dev/null +++ b/vendor/kubevirt.io/kubevirt/pkg/virt-launcher/virtwrap/api/testdata/domain_ppc64le.xml.tmpl @@ -0,0 +1,78 @@ + + mynamespace_testvmi + 9 + + hvm + + + + e4686d2c-6e8d-4335-b8fd-81bee22f4814 + + + + + + + + + {{ . }} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + /dev/urandom + + + + + f4686d2c-6e8d-4335-b8fd-81bee22f4814 + + 5 + + + + + + + + + + + + + + + Conroe + + + + + 2 + 2 + diff --git a/vendor/kubevirt.io/kubevirt/pkg/virt-launcher/virtwrap/api/testdata/domain_x86_64.xml.tmpl b/vendor/kubevirt.io/kubevirt/pkg/virt-launcher/virtwrap/api/testdata/domain_x86_64.xml.tmpl new file mode 100644 index 000000000..1786a1517 --- /dev/null +++ b/vendor/kubevirt.io/kubevirt/pkg/virt-launcher/virtwrap/api/testdata/domain_x86_64.xml.tmpl @@ -0,0 +1,78 @@ + + mynamespace_testvmi + 9 + + hvm + + + + e4686d2c-6e8d-4335-b8fd-81bee22f4814 + + + + + + + + + {{ . }} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + /dev/urandom + + + + + f4686d2c-6e8d-4335-b8fd-81bee22f4814 + + 5 + + + + + + + + + + + + + + + Conroe + + + + + 2 + 2 + diff --git a/vendor/modules.txt b/vendor/modules.txt index 4bd40d832..0477850e5 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -1,5 +1,3 @@ -# cloud.google.com/go/iam v1.1.8 -## explicit; go 1.19 # contrib.go.opencensus.io/exporter/ocagent v0.7.1-0.20200907061046-05415f1de66d ## explicit; go 1.13 contrib.go.opencensus.io/exporter/ocagent @@ -18,8 +16,8 @@ github.com/alexflint/go-arg # github.com/alexflint/go-scalar v1.2.0 ## explicit; go 1.15 github.com/alexflint/go-scalar -# github.com/antlr4-go/antlr/v4 v4.13.1 -## explicit; go 1.22 +# github.com/antlr4-go/antlr/v4 v4.13.0 +## explicit; go 1.20 github.com/antlr4-go/antlr/v4 # github.com/beorn7/perks v1.0.1 ## explicit; go 1.11 @@ -61,7 +59,7 @@ github.com/containerd/stargz-snapshotter/estargz/errorutil # github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc ## explicit github.com/davecgh/go-spew/spew -# github.com/docker/cli v26.1.3+incompatible +# github.com/docker/cli v26.1.2+incompatible ## explicit github.com/docker/cli/cli/config github.com/docker/cli/cli/config/configfile @@ -70,14 +68,14 @@ github.com/docker/cli/cli/config/types # github.com/docker/distribution v2.8.3+incompatible ## explicit github.com/docker/distribution/registry/client/auth/challenge -# github.com/docker/docker v26.1.3+incompatible +# github.com/docker/docker v26.1.2+incompatible ## explicit github.com/docker/docker/pkg/homedir -# github.com/docker/docker-credential-helpers v0.8.2 +# github.com/docker/docker-credential-helpers v0.8.1 ## explicit; go 1.19 github.com/docker/docker-credential-helpers/client github.com/docker/docker-credential-helpers/credentials -# github.com/emicklei/go-restful/v3 v3.12.1 +# github.com/emicklei/go-restful/v3 v3.12.0 ## explicit; go 1.13 github.com/emicklei/go-restful/v3 github.com/emicklei/go-restful/v3/log @@ -101,7 +99,7 @@ github.com/go-kit/log/level # github.com/go-logfmt/logfmt v0.6.0 ## explicit; go 1.17 github.com/go-logfmt/logfmt -# github.com/go-logr/logr v1.4.2 +# github.com/go-logr/logr v1.4.1 ## explicit; go 1.18 github.com/go-logr/logr github.com/go-logr/logr/funcr @@ -219,8 +217,8 @@ github.com/google/uuid # github.com/gorilla/websocket v1.5.1 ## explicit; go 1.20 github.com/gorilla/websocket -# github.com/grpc-ecosystem/grpc-gateway/v2 v2.20.0 -## explicit; go 1.20 +# github.com/grpc-ecosystem/grpc-gateway/v2 v2.19.1 +## explicit; go 1.19 github.com/grpc-ecosystem/grpc-gateway/v2/internal/httprule github.com/grpc-ecosystem/grpc-gateway/v2/runtime github.com/grpc-ecosystem/grpc-gateway/v2/utilities @@ -370,7 +368,7 @@ github.com/pkg/errors # github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 ## explicit github.com/pmezard/go-difflib/difflib -# github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring v0.74.0 +# github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring v0.73.2 ## explicit; go 1.21 github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring/v1 @@ -400,8 +398,8 @@ github.com/prometheus/statsd_exporter/pkg/mapper/fsm # github.com/secure-systems-lab/go-securesystemslib v0.8.0 ## explicit; go 1.20 github.com/secure-systems-lab/go-securesystemslib/encrypted -# github.com/sigstore/sigstore v1.8.4 -## explicit; go 1.21 +# github.com/sigstore/sigstore v1.8.3 +## explicit; go 1.20 github.com/sigstore/sigstore/pkg/cryptoutils github.com/sigstore/sigstore/pkg/signature github.com/sigstore/sigstore/pkg/signature/options @@ -422,7 +420,7 @@ github.com/stoewer/go-strcase ## explicit; go 1.17 github.com/stretchr/testify/assert github.com/stretchr/testify/require -# github.com/tektoncd/pipeline v0.60.1 +# github.com/tektoncd/pipeline v0.59.0 ## explicit; go 1.21 github.com/tektoncd/pipeline/internal/artifactref github.com/tektoncd/pipeline/pkg/apis/config @@ -469,14 +467,14 @@ github.com/tektoncd/pipeline/pkg/client/injection/informers/pipeline/v1/task github.com/tektoncd/pipeline/pkg/client/injection/informers/pipeline/v1/task/fake github.com/tektoncd/pipeline/pkg/client/injection/informers/pipeline/v1/taskrun github.com/tektoncd/pipeline/pkg/client/injection/informers/pipeline/v1/taskrun/fake +github.com/tektoncd/pipeline/pkg/client/injection/informers/pipeline/v1alpha1/stepaction +github.com/tektoncd/pipeline/pkg/client/injection/informers/pipeline/v1alpha1/stepaction/fake github.com/tektoncd/pipeline/pkg/client/injection/informers/pipeline/v1alpha1/verificationpolicy github.com/tektoncd/pipeline/pkg/client/injection/informers/pipeline/v1alpha1/verificationpolicy/fake github.com/tektoncd/pipeline/pkg/client/injection/informers/pipeline/v1beta1/clustertask github.com/tektoncd/pipeline/pkg/client/injection/informers/pipeline/v1beta1/clustertask/fake github.com/tektoncd/pipeline/pkg/client/injection/informers/pipeline/v1beta1/customrun github.com/tektoncd/pipeline/pkg/client/injection/informers/pipeline/v1beta1/customrun/fake -github.com/tektoncd/pipeline/pkg/client/injection/informers/pipeline/v1beta1/stepaction -github.com/tektoncd/pipeline/pkg/client/injection/informers/pipeline/v1beta1/stepaction/fake github.com/tektoncd/pipeline/pkg/client/listers/pipeline/v1 github.com/tektoncd/pipeline/pkg/client/listers/pipeline/v1alpha1 github.com/tektoncd/pipeline/pkg/client/listers/pipeline/v1beta1 @@ -513,6 +511,7 @@ github.com/tektoncd/pipeline/pkg/result github.com/tektoncd/pipeline/pkg/spire/config github.com/tektoncd/pipeline/pkg/substitution github.com/tektoncd/pipeline/test +github.com/tektoncd/pipeline/test/diff # github.com/titanous/rocacheck v0.0.0-20171023193734-afe73141d399 ## explicit github.com/titanous/rocacheck @@ -576,7 +575,7 @@ golang.org/x/crypto/pbkdf2 golang.org/x/crypto/salsa20/salsa golang.org/x/crypto/scrypt golang.org/x/crypto/sha3 -# golang.org/x/exp v0.0.0-20240506185415-9bf2ced13842 +# golang.org/x/exp v0.0.0-20230713183714-613f0c0eb8a1 ## explicit; go 1.20 golang.org/x/exp/constraints golang.org/x/exp/maps @@ -646,17 +645,15 @@ golang.org/x/tools/go/ast/inspector # gomodules.xyz/jsonpatch/v2 v2.4.0 ## explicit; go 1.20 gomodules.xyz/jsonpatch/v2 -# google.golang.org/api v0.182.0 -## explicit; go 1.20 +# google.golang.org/api v0.180.0 +## explicit; go 1.19 google.golang.org/api/support/bundler -# google.golang.org/genproto v0.0.0-20240401170217-c3f982113cda +# google.golang.org/genproto/googleapis/api v0.0.0-20240318140521-94a12d6c2237 ## explicit; go 1.19 -# google.golang.org/genproto/googleapis/api v0.0.0-20240520151616-dc85e6b867a5 -## explicit; go 1.20 google.golang.org/genproto/googleapis/api/expr/v1alpha1 google.golang.org/genproto/googleapis/api/httpbody -# google.golang.org/genproto/googleapis/rpc v0.0.0-20240521202816-d264139d666e -## explicit; go 1.20 +# google.golang.org/genproto/googleapis/rpc v0.0.0-20240429193739-8cf5692501f6 +## explicit; go 1.19 google.golang.org/genproto/googleapis/rpc/status # google.golang.org/grpc v1.64.0 ## explicit; go 1.19 @@ -770,7 +767,7 @@ gopkg.in/yaml.v2 # gopkg.in/yaml.v3 v3.0.1 ## explicit gopkg.in/yaml.v3 -# k8s.io/api v0.29.5 => k8s.io/api v0.26.11 +# k8s.io/api v0.29.3 => k8s.io/api v0.26.11 ## explicit; go 1.19 k8s.io/api/admissionregistration/v1 k8s.io/api/admissionregistration/v1alpha1 @@ -823,7 +820,7 @@ k8s.io/api/scheduling/v1beta1 k8s.io/api/storage/v1 k8s.io/api/storage/v1alpha1 k8s.io/api/storage/v1beta1 -# k8s.io/apiextensions-apiserver v0.29.5 => k8s.io/apiextensions-apiserver v0.26.11 +# k8s.io/apiextensions-apiserver v0.29.3 => k8s.io/apiextensions-apiserver v0.26.11 ## explicit; go 1.19 k8s.io/apiextensions-apiserver/pkg/apis/apiextensions k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1 @@ -832,7 +829,7 @@ k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset/scheme k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset/typed/apiextensions/v1 k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset/typed/apiextensions/v1beta1 -# k8s.io/apimachinery v0.29.5 => k8s.io/apimachinery v0.26.11 +# k8s.io/apimachinery v0.29.3 => k8s.io/apimachinery v0.26.11 ## explicit; go 1.19 k8s.io/apimachinery/pkg/api/equality k8s.io/apimachinery/pkg/api/errors