diff --git a/Gopkg.lock b/Gopkg.lock index 1d1fdf4b..7aff0ba9 100644 --- a/Gopkg.lock +++ b/Gopkg.lock @@ -966,7 +966,7 @@ [[projects]] branch = "master" - digest = "1:087752cbad644085941d5dbe2a04ef0c285fed9205006a5a3d3816256ac0fecd" + digest = "1:5e0b4baaab070168841e509efe16651d72eae440ffbd4cf23344e6ff8ae722a3" name = "knative.dev/pkg" packages = [ "apis", @@ -986,7 +986,7 @@ "reconciler", ] pruneopts = "T" - revision = "1893541a0fac5885032c8ec170fd81234de13f4a" + revision = "7cbd0bcc1a30e5205033b35a60149063abeda8e3" [[projects]] branch = "master" @@ -997,7 +997,7 @@ "tools/dep-collector", ] pruneopts = "UT" - revision = "3f96c9e98f31595fe33eaa2d95f5e2170522acd7" + revision = "71f886c808ce483867a28ca2b47e843916a72b44" [[projects]] digest = "1:8730e0150dfb2b7e173890c8b9868e7a273082ef8e39f4940e3506a481cf895c" diff --git a/vendor/knative.dev/pkg/Gopkg.lock b/vendor/knative.dev/pkg/Gopkg.lock index 4e52e3b5..fa7353dc 100644 --- a/vendor/knative.dev/pkg/Gopkg.lock +++ b/vendor/knative.dev/pkg/Gopkg.lock @@ -410,6 +410,14 @@ pruneopts = "NUT" revision = "95032a82bc518f77982ea72343cc1ade730072f0" +[[projects]] + digest = "1:08c58ac78a8c1f61e9a96350066d30fe194b8779799bd932a79932a5166a173f" + name = "github.com/kelseyhightower/envconfig" + packages = ["."] + pruneopts = "NUT" + revision = "0b417c4ec4a8a82eecc22a1459a504aa55163d61" + version = "v1.4.0" + [[projects]] digest = "1:58999a98719fddbac6303cb17e8d85b945f60b72f48e3a2df6b950b97fa926f1" name = "github.com/konsorten/go-windows-terminal-sequences" @@ -1342,14 +1350,14 @@ [[projects]] branch = "master" - digest = "1:3d0c703375017dde28d1ee030d7f82ea838ab023841890ead18e91c8c9aded80" + digest = "1:e5bd21467544cbd14cb25553c5c78eb2e0e93baf9288a3c2ebaf1cf1fdb0c95f" name = "knative.dev/test-infra" packages = [ "scripts", "tools/dep-collector", ] pruneopts = "UT" - revision = "7a8eea898f66fc7cd5fec6bb7c0fa2a80eeb702e" + revision = "3f96c9e98f31595fe33eaa2d95f5e2170522acd7" [[projects]] digest = "1:8730e0150dfb2b7e173890c8b9868e7a273082ef8e39f4940e3506a481cf895c" @@ -1390,6 +1398,7 @@ "github.com/google/uuid", "github.com/gorilla/websocket", "github.com/kballard/go-shellquote", + "github.com/kelseyhightower/envconfig", "github.com/markbates/inflect", "github.com/openzipkin/zipkin-go", "github.com/openzipkin/zipkin-go/model", diff --git a/vendor/knative.dev/pkg/test/prow/env.go b/vendor/knative.dev/pkg/test/prow/env.go new file mode 100644 index 00000000..a36b7a1d --- /dev/null +++ b/vendor/knative.dev/pkg/test/prow/env.go @@ -0,0 +1,59 @@ +/* +Copyright 2020 The Knative Authors + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// env.go provides a central point to read all environment variables defined by Prow. + +package prow + +import ( + "errors" + "fmt" + + "github.com/kelseyhightower/envconfig" +) + +// EnvConfig consists of all the environment variables that can be set in a Prow job, +// check https://github.com/kubernetes/test-infra/blob/master/prow/jobs.md#job-environment-variables +// for more information. +type EnvConfig struct { + CI bool + Artifacts string + JobName string `split_words:"true"` + JobType string `split_words:"true"` + JobSpec string `split_words:"true"` + BuildID string `envconfig:"BUILD_ID"` + ProwJobID string `envconfig:"PROW_JOB_ID"` + RepoOwner string `split_words:"true"` + RepoName string `split_words:"true"` + PullBaseRef string `split_words:"true"` + PullBaseSha string `split_words:"true"` + PullRefs string `split_words:"true"` + PullNumber uint `split_words:"true"` + PullPullSha string `split_words:"true"` +} + +// GetEnvConfig returns values of all the environment variables that can be possibly set in a Prow job. +func GetEnvConfig() (*EnvConfig, error) { + var ec EnvConfig + if err := envconfig.Process("", &ec); err != nil { + return nil, fmt.Errorf("failed getting environment variables for Prow: %w", err) + } + + if !ec.CI { + return nil, errors.New("this function is not expected to be called from a non-CI environment") + } + return &ec, nil +} diff --git a/vendor/knative.dev/pkg/test/prow/prow.go b/vendor/knative.dev/pkg/test/prow/prow.go index 957ed52a..5d31ce81 100644 --- a/vendor/knative.dev/pkg/test/prow/prow.go +++ b/vendor/knative.dev/pkg/test/prow/prow.go @@ -108,6 +108,11 @@ type Finished struct { // Metadata contains metadata in finished.json type Metadata map[string]interface{} +// IsCI returns whether the current environment is a CI environment. +func IsCI() bool { + return strings.EqualFold(os.Getenv("CI"), "true") +} + /* Local logics */ // GetLocalArtifactsDir gets the artifacts directory where prow looks for artifacts. diff --git a/vendor/knative.dev/pkg/test/zipkin/util.go b/vendor/knative.dev/pkg/test/zipkin/util.go index f02f4370..cb168113 100644 --- a/vendor/knative.dev/pkg/test/zipkin/util.go +++ b/vendor/knative.dev/pkg/test/zipkin/util.go @@ -130,9 +130,17 @@ func CleanupZipkinTracingSetup(logf logging.FormatLogger) { // JSONTrace returns a trace for the given traceID. It will continually try to get the trace. If the // trace it gets has the expected number of spans, then it will be returned. If not, it will try // again. If it reaches timeout, then it returns everything it has so far with an error. -func JSONTrace(traceID string, expected int, timeout time.Duration) (trace []model.SpanModel, err error) { +func JSONTrace(traceID string, expected int, timeout time.Duration) ([]model.SpanModel, error) { + return JSONTracePred(traceID, timeout, func(trace []model.SpanModel) bool { return len(trace) == expected }) +} + +// JSONTracePred returns a trace for the given traceID. It will +// continually try to get the trace until the trace spans satisfy the +// predicate. If the timeout is reached then the last fetched trace +// tree if available is returned along with an error. +func JSONTracePred(traceID string, timeout time.Duration, pred func([]model.SpanModel) bool) (trace []model.SpanModel, err error) { t := time.After(timeout) - for len(trace) != expected { + for !pred(trace) { select { case <-t: return trace, &TimeoutError{