diff --git a/Gopkg.lock b/Gopkg.lock index 9f2c00fe9c..d2209bd1d6 100644 --- a/Gopkg.lock +++ b/Gopkg.lock @@ -266,11 +266,11 @@ version = "v0.3.0" [[projects]] - digest = "1:10aa62acd56f635de190110a836aa261b3774e697b2b6a7af27d8263cf856d47" + digest = "1:ecc8bd577aaaa8ce2c3ad060e61e1daeadbab1d14a0934f019ad2995c3a666b0" name = "github.com/google/go-containerregistry" packages = ["pkg/name"] pruneopts = "NUT" - revision = "b02d448a3705facf11018efff34f1d2830be5724" + revision = "955bf358a3d8d1ebfa6204338ef3fe364255cd85" [[projects]] digest = "1:3ec6c8e4b700377066dbb5ab3155c55f97109ab6147fee9423a68506d79bbafa" @@ -1345,7 +1345,7 @@ [[projects]] branch = "release-0.13" - digest = "1:f4dcb79e9b01236fe9fb89e7740af183af737c0a7c62ebd68d9ee9d33904abd5" + digest = "1:8c79753b03a6656d3fb3bd585334b7e2b11a77f780e38e0d1eb24492771b7ddf" name = "knative.dev/eventing" packages = [ "pkg/apis/config", @@ -1428,11 +1428,11 @@ "test/test_images/transformevents", ] pruneopts = "UT" - revision = "200ea1aebdbf9a71068f3fd59205f3bf07ba65e6" + revision = "133ec838f2706b18dab87c7f1b2cb6cccd9409f1" [[projects]] branch = "release-0.13" - digest = "1:77db7d7e7364e6acb7fe627ddb377f94e5199b020be96aa0e8654cd864db2d7a" + digest = "1:333539485c96ddf9d1ac20c5141a27044890c7d5b7f5de85f28a9267120acb4c" name = "knative.dev/pkg" packages = [ "apis", @@ -1509,7 +1509,7 @@ "webhook/resourcesemantics/validation", ] pruneopts = "T" - revision = "2006e107e39eb0e661e4437ba76b16465162689e" + revision = "a56a6ea3fa56b9c9c2482a5bda0005dd2364d183" [[projects]] branch = "release-0.13" @@ -1562,18 +1562,18 @@ "pkg/client/listers/serving/v1beta1", ] pruneopts = "NUT" - revision = "804b3bb854ea94a17f4348f8afca48c8b413c566" + revision = "aa470a6af2da383a5cc81483dfd476d41bbd1830" [[projects]] branch = "master" - digest = "1:e7ea104eff9c91ce48f1730ab8b4098faa1ea519162ccbbbca68c205428f0e21" + digest = "1:2987a1db00b983af9e5d5281639a754fb6449eef01e6a375894829eaec17cb2a" name = "knative.dev/test-infra" packages = [ "scripts", "tools/dep-collector", ] pruneopts = "UT" - revision = "83fb33bf8fcfe5c0e021eb6c9bb8733a5b8423c0" + revision = "d878fef854182d0cb2ab2190c66a785b8f05e3e2" [[projects]] digest = "1:8730e0150dfb2b7e173890c8b9868e7a273082ef8e39f4940e3506a481cf895c" diff --git a/vendor/github.com/google/go-containerregistry/pkg/name/digest.go b/vendor/github.com/google/go-containerregistry/pkg/name/digest.go index 2dc0f7f371..120dd216ab 100644 --- a/vendor/github.com/google/go-containerregistry/pkg/name/digest.go +++ b/vendor/github.com/google/go-containerregistry/pkg/name/digest.go @@ -28,7 +28,8 @@ const ( // Digest stores a digest name in a structured form. type Digest struct { Repository - digest string + digest string + original string } // Ensure Digest implements Reference @@ -54,8 +55,9 @@ func (d Digest) Name() string { return d.Repository.Name() + digestDelim + d.DigestStr() } +// String returns the original input string. func (d Digest) String() string { - return d.Name() + return d.original } func checkDigest(name string) error { @@ -86,5 +88,9 @@ func NewDigest(name string, opts ...Option) (Digest, error) { if err != nil { return Digest{}, err } - return Digest{repo, digest}, nil + return Digest{ + Repository: repo, + digest: digest, + original: name, + }, nil } diff --git a/vendor/github.com/google/go-containerregistry/pkg/name/ref.go b/vendor/github.com/google/go-containerregistry/pkg/name/ref.go index c02d82e5df..f9388253f1 100644 --- a/vendor/github.com/google/go-containerregistry/pkg/name/ref.go +++ b/vendor/github.com/google/go-containerregistry/pkg/name/ref.go @@ -44,6 +44,6 @@ func ParseReference(s string, opts ...Option) (Reference, error) { if d, err := NewDigest(s, opts...); err == nil { return d, nil } - // TODO: Combine above errors into something more useful? - return nil, NewErrBadName("could not parse reference") + return nil, NewErrBadName("could not parse reference: " + s) + } diff --git a/vendor/github.com/google/go-containerregistry/pkg/name/repository.go b/vendor/github.com/google/go-containerregistry/pkg/name/repository.go index 5eeb8ace97..54367a15cd 100644 --- a/vendor/github.com/google/go-containerregistry/pkg/name/repository.go +++ b/vendor/github.com/google/go-containerregistry/pkg/name/repository.go @@ -99,3 +99,23 @@ func NewRepository(name string, opts ...Option) (Repository, error) { } return Repository{reg, repo}, nil } + +// Tag returns a Tag in this Repository. +func (r Repository) Tag(identifier string) Tag { + t := Tag{ + tag: identifier, + Repository: r, + } + t.original = t.Name() + return t +} + +// Digest returns a Digest in this Repository. +func (r Repository) Digest(identifier string) Digest { + d := Digest{ + digest: identifier, + Repository: r, + } + d.original = d.Name() + return d +} diff --git a/vendor/github.com/google/go-containerregistry/pkg/name/tag.go b/vendor/github.com/google/go-containerregistry/pkg/name/tag.go index e6cce34dbd..eac9ad1480 100644 --- a/vendor/github.com/google/go-containerregistry/pkg/name/tag.go +++ b/vendor/github.com/google/go-containerregistry/pkg/name/tag.go @@ -28,7 +28,8 @@ const ( // Tag stores a docker tag name in a structured form. type Tag struct { Repository - tag string + tag string + original string } // Ensure Tag implements Reference @@ -57,8 +58,9 @@ func (t Tag) Name() string { return t.Repository.Name() + tagDelim + t.TagStr() } +// String returns the original input string. func (t Tag) String() string { - return t.Name() + return t.original } // Scope returns the scope required to perform the given action on the tag. @@ -98,5 +100,9 @@ func NewTag(name string, opts ...Option) (Tag, error) { if err != nil { return Tag{}, err } - return Tag{repo, tag}, nil + return Tag{ + Repository: repo, + tag: tag, + original: name, + }, nil } diff --git a/vendor/knative.dev/eventing/pkg/apis/eventing/v1alpha1/trigger_conversion.go b/vendor/knative.dev/eventing/pkg/apis/eventing/v1alpha1/trigger_conversion.go index fb9c063180..aa6adea0fa 100644 --- a/vendor/knative.dev/eventing/pkg/apis/eventing/v1alpha1/trigger_conversion.go +++ b/vendor/knative.dev/eventing/pkg/apis/eventing/v1alpha1/trigger_conversion.go @@ -34,14 +34,19 @@ func (source *Trigger) ConvertTo(ctx context.Context, obj apis.Convertible) erro sink.Spec.Subscriber = source.Spec.Subscriber if source.Spec.Filter != nil { sink.Spec.Filter = &v1beta1.TriggerFilter{ - Attributes: make(v1beta1.TriggerFilterAttributes, 0), } if source.Spec.Filter.Attributes != nil { + sink.Spec.Filter = &v1beta1.TriggerFilter{ + Attributes: make(v1beta1.TriggerFilterAttributes, len(*source.Spec.Filter.Attributes)), + } for k, v := range *source.Spec.Filter.Attributes { sink.Spec.Filter.Attributes[k] = v } } if source.Spec.Filter.DeprecatedSourceAndType != nil { + sink.Spec.Filter = &v1beta1.TriggerFilter{ + Attributes: make(v1beta1.TriggerFilterAttributes, 2), + } sink.Spec.Filter.Attributes["source"] = source.Spec.Filter.DeprecatedSourceAndType.Source sink.Spec.Filter.Attributes["type"] = source.Spec.Filter.DeprecatedSourceAndType.Type } @@ -63,7 +68,7 @@ func (sink *Trigger) ConvertFrom(ctx context.Context, obj apis.Convertible) erro sink.ObjectMeta = source.ObjectMeta sink.Spec.Broker = source.Spec.Broker sink.Spec.Subscriber = source.Spec.Subscriber - if source.Spec.Filter != nil { + if source.Spec.Filter != nil && source.Spec.Filter.Attributes != nil { attributes := TriggerFilterAttributes{} for k, v := range source.Spec.Filter.Attributes { attributes[k] = v diff --git a/vendor/knative.dev/eventing/test/lib/resources/eventing.go b/vendor/knative.dev/eventing/test/lib/resources/eventing.go index 6e213f34cf..81f987fdb8 100644 --- a/vendor/knative.dev/eventing/test/lib/resources/eventing.go +++ b/vendor/knative.dev/eventing/test/lib/resources/eventing.go @@ -294,8 +294,8 @@ func WithAttributesTriggerFilterV1Beta1(eventSource, eventType string, extension } } -// WithDependencyAnnotaionTrigger returns an option that adds a dependency annotation to the given Trigger. -func WithDependencyAnnotaionTrigger(dependencyAnnotation string) TriggerOption { +// WithDependencyAnnotationTrigger returns an option that adds a dependency annotation to the given Trigger. +func WithDependencyAnnotationTrigger(dependencyAnnotation string) TriggerOption { return func(t *eventingv1alpha1.Trigger) { if t.Annotations == nil { t.Annotations = make(map[string]string) @@ -304,6 +304,16 @@ func WithDependencyAnnotaionTrigger(dependencyAnnotation string) TriggerOption { } } +// WithDependencyAnnotationTrigger returns an option that adds a dependency annotation to the given Trigger. +func WithDependencyAnnotationTriggerV1Beta1(dependencyAnnotation string) TriggerOptionV1Beta1 { + return func(t *eventingv1beta1.Trigger) { + if t.Annotations == nil { + t.Annotations = make(map[string]string) + } + t.Annotations[eventingv1beta1.DependencyAnnotation] = dependencyAnnotation + } +} + // WithBroker returns an option that adds a Broker for the given Trigger. func WithBroker(brokerName string) TriggerOption { return func(t *eventingv1alpha1.Trigger) { diff --git a/vendor/knative.dev/pkg/injection/sharedmain/main.go b/vendor/knative.dev/pkg/injection/sharedmain/main.go index cbf6e82ffb..a7b078cee4 100644 --- a/vendor/knative.dev/pkg/injection/sharedmain/main.go +++ b/vendor/knative.dev/pkg/injection/sharedmain/main.go @@ -106,7 +106,7 @@ func GetLeaderElectionConfig(ctx context.Context) (*kle.Config, error) { leaderElectionConfigMap, err := kubeclient.Get(ctx).CoreV1().ConfigMaps(system.Namespace()).Get(kle.ConfigMapName(), metav1.GetOptions{}) if err != nil { if apierrors.IsNotFound(err) { - return kle.NewConfigFromMap(nil) + return kle.NewConfigFromConfigMap(nil) } return nil, err diff --git a/vendor/knative.dev/pkg/metrics/exporter.go b/vendor/knative.dev/pkg/metrics/exporter.go index b34c60a9d1..0ba542b1b4 100644 --- a/vendor/knative.dev/pkg/metrics/exporter.go +++ b/vendor/knative.dev/pkg/metrics/exporter.go @@ -16,6 +16,7 @@ package metrics import ( "errors" "fmt" + "strings" "sync" "go.opencensus.io/stats/view" @@ -74,7 +75,7 @@ func UpdateExporterFromConfigMap(component string, logger *zap.SugaredLogger) fu return func(configMap *corev1.ConfigMap) { UpdateExporter(ExporterOptions{ Domain: domain, - Component: component, + Component: strings.ReplaceAll(component, "-", "_"), ConfigMap: configMap.Data, }, logger) } diff --git a/vendor/knative.dev/test-infra/scripts/README.md b/vendor/knative.dev/test-infra/scripts/README.md index ca673fb135..32e17ac1ff 100644 --- a/vendor/knative.dev/test-infra/scripts/README.md +++ b/vendor/knative.dev/test-infra/scripts/README.md @@ -70,10 +70,11 @@ integration tests). Use the flags `--build-tests`, `--unit-tests` and `--integration-tests` to run a specific set of tests. -To run a specific program as a test, use the `--run-test` flag, and provide the +To run specific programs as a test, use the `--run-test` flag, and provide the program as the argument. If arguments are required for the program, pass everything as a single quotes argument. For example, -`./presubmit-tests.sh --run-test "test/my/test data"`. +`./presubmit-tests.sh --run-test "test/my/test data"`. This flag can be used +repeatedly, and each one will be ran in sequential order. The script will automatically skip all presubmit tests for PRs where all changed files are exempt of tests (e.g., a PR changing only the `OWNERS` file). diff --git a/vendor/knative.dev/test-infra/scripts/library.sh b/vendor/knative.dev/test-infra/scripts/library.sh index d2715650cd..434deda253 100755 --- a/vendor/knative.dev/test-infra/scripts/library.sh +++ b/vendor/knative.dev/test-infra/scripts/library.sh @@ -327,6 +327,13 @@ function capture_output() { return ${failed} } +# Print failed step, which could be highlighted by spyglass. +# Parameters: $1...n - description of step that failed +function step_failed() { + local spyglass_token="Step failed:" + echo "${spyglass_token} $@" +} + # Create a temporary file with the given extension in a way that works on both Linux and macOS. # Parameters: $1 - file name without extension (e.g. 'myfile_XXXX') # $2 - file extension (e.g. 'xml') @@ -475,7 +482,19 @@ function run_go_tool() { if [[ -z "$(which ${tool})" ]]; then local action=get [[ $1 =~ ^[\./].* ]] && action=install - go ${action} $1 + # Avoid running `go get` from root dir of the repository, as it can change go.sum and go.mod files. + # See discussions in https://github.com/golang/go/issues/27643. + if [[ ${action} == "get" && $(pwd) == "${REPO_ROOT_DIR}" ]]; then + local temp_dir="$(mktemp -d)" + local install_failed=0 + # Swallow the output as we are returning the stdout in the end. + pushd "${temp_dir}" > /dev/null 2>&1 + go ${action} $1 || install_failed=1 + popd > /dev/null 2>&1 + (( install_failed )) && return ${install_failed} + else + go ${action} $1 + fi fi shift 2 ${tool} "$@" diff --git a/vendor/knative.dev/test-infra/scripts/markdown-link-check-config.rc b/vendor/knative.dev/test-infra/scripts/markdown-link-check-config.rc index 9d802a0d48..49b042e827 100644 --- a/vendor/knative.dev/test-infra/scripts/markdown-link-check-config.rc +++ b/vendor/knative.dev/test-infra/scripts/markdown-link-check-config.rc @@ -1,5 +1,5 @@ # For help, see # https://github.com/raviqqe/liche/blob/master/README.md -# Don't check localhost links --x "^https?://localhost($|[:/].*)" +# Don't check localhost links and don't check templated links +-x "(^https?://localhost($|[:/].*))|(^https://.*{{.*$)" diff --git a/vendor/knative.dev/test-infra/scripts/presubmit-tests.sh b/vendor/knative.dev/test-infra/scripts/presubmit-tests.sh index c14f251712..11b09a6841 100755 --- a/vendor/knative.dev/test-infra/scripts/presubmit-tests.sh +++ b/vendor/knative.dev/test-infra/scripts/presubmit-tests.sh @@ -93,19 +93,19 @@ function run_build_tests() { local failed=0 # Run pre-build tests, if any if function_exists pre_build_tests; then - pre_build_tests || failed=1 + pre_build_tests || { failed=1; step_failed "pre_build_tests"; } fi # Don't run build tests if pre-build tests failed if (( ! failed )); then if function_exists build_tests; then - build_tests || failed=1 + build_tests || { failed=1; step_failed "build_tests"; } else - default_build_test_runner || failed=1 + default_build_test_runner || { failed=1; step_failed "default_build_test_runner"; } fi fi # Don't run post-build tests if pre/build tests failed if (( ! failed )) && function_exists post_build_tests; then - post_build_tests || failed=1 + post_build_tests || { failed=1; step_failed "post_build_tests"; } fi results_banner "Build" ${failed} return ${failed} @@ -147,14 +147,20 @@ function markdown_build_tests() { # Default build test runner that: # * check markdown files -# * `go build` on the entire repo # * run `/hack/verify-codegen.sh` (if it exists) +# * `go build` on the entire repo # * check licenses in all go packages function default_build_test_runner() { local failed=0 - # Perform markdown build checks first + # Perform markdown build checks markdown_build_tests || failed=1 - # For documentation PRs, just check the md files + # Run verify-codegen check + if [[ -f ./hack/verify-codegen.sh ]]; then + subheader "Checking autogenerated code is up-to-date" + report_build_test Verify_CodeGen ./hack/verify-codegen.sh || failed=1 + fi + # For documentation PRs, just check the md files and run + # verify-codegen (as md files can be auto-generated in some repos). (( IS_DOCUMENTATION_PR )) && return ${failed} # Don't merge these two lines, or return code will always be 0. local go_pkg_dirs @@ -186,13 +192,9 @@ function default_build_test_runner() { # Remove unused generated binary, if any. rm -f e2e.test done - + local errors_go="$(echo -e "${errors_go1}\n${errors_go2}" | uniq)" create_junit_xml _build_tests Build_Go "${errors_go}" - if [[ -f ./hack/verify-codegen.sh ]]; then - subheader "Checking autogenerated code is up-to-date" - report_build_test Verify_CodeGen ./hack/verify-codegen.sh || failed=1 - fi # Check that we don't have any forbidden licenses in our images. subheader "Checking for forbidden licenses" report_build_test Check_Licenses check_licenses ${go_pkg_dirs} || failed=1 @@ -211,19 +213,19 @@ function run_unit_tests() { local failed=0 # Run pre-unit tests, if any if function_exists pre_unit_tests; then - pre_unit_tests || failed=1 + pre_unit_tests || { failed=1; step_failed "pre_unit_tests"; } fi # Don't run unit tests if pre-unit tests failed if (( ! failed )); then if function_exists unit_tests; then - unit_tests || failed=1 + unit_tests || { failed=1; step_failed "unit_tests"; } else - default_unit_test_runner || failed=1 + default_unit_test_runner || { failed=1; step_failed "default_unit_test_runner"; } fi fi # Don't run post-unit tests if pre/unit tests failed if (( ! failed )) && function_exists post_unit_tests; then - post_unit_tests || failed=1 + post_unit_tests || { failed=1; step_failed "post_unit_tests"; } fi results_banner "Unit" ${failed} return ${failed} @@ -247,19 +249,19 @@ function run_integration_tests() { local failed=0 # Run pre-integration tests, if any if function_exists pre_integration_tests; then - pre_integration_tests || failed=1 + pre_integration_tests || { failed=1; step_failed "pre_integration_tests"; } fi # Don't run integration tests if pre-integration tests failed if (( ! failed )); then if function_exists integration_tests; then - integration_tests || failed=1 + integration_tests || { failed=1; step_failed "integration_tests"; } else - default_integration_test_runner || failed=1 + default_integration_test_runner || { failed=1; step_failed "default_integration_test_runner"; } fi fi # Don't run integration tests if pre/integration tests failed if (( ! failed )) && function_exists post_integration_tests; then - post_integration_tests || failed=1 + post_integration_tests || { failed=1; step_failed "post_integration_tests"; } fi results_banner "Integration" ${failed} return ${failed} @@ -273,6 +275,7 @@ function default_integration_test_runner() { echo "Running integration test ${e2e_test}" if ! ${e2e_test} ${options}; then failed=1 + step_failed "${e2e_test} ${options}" fi done return ${failed} @@ -325,7 +328,7 @@ function main() { [[ -z $1 ]] && set -- "--all-tests" - local TEST_TO_RUN="" + local TESTS_TO_RUN=() while [[ $# -ne 0 ]]; do local parameter=$1 @@ -341,7 +344,7 @@ function main() { --run-test) shift [[ $# -ge 1 ]] || abort "missing executable after --run-test" - TEST_TO_RUN="$1" + TESTS_TO_RUN+=("$1") ;; *) abort "error: unknown option ${parameter}" ;; esac @@ -351,7 +354,7 @@ function main() { readonly RUN_BUILD_TESTS readonly RUN_UNIT_TESTS readonly RUN_INTEGRATION_TESTS - readonly TEST_TO_RUN + readonly TESTS_TO_RUN cd ${REPO_ROOT_DIR} @@ -359,7 +362,7 @@ function main() { local failed=0 - if [[ -n "${TEST_TO_RUN}" ]]; then + if [[ ${#TESTS_TO_RUN[@]} > 0 ]]; then if (( RUN_BUILD_TESTS || RUN_UNIT_TESTS || RUN_INTEGRATION_TESTS )); then abort "--run-test must be used alone" fi @@ -368,17 +371,19 @@ function main() { header "Documentation only PR, skipping running custom test" exit 0 fi - ${TEST_TO_RUN} || failed=1 + for test_to_run in "${TESTS_TO_RUN[@]}"; do + ${test_to_run} || { failed=1; step_failed "${test_to_run}"; } + done fi - run_build_tests || failed=1 + run_build_tests || { failed=1; step_failed "run_build_tests"; } # If PRESUBMIT_TEST_FAIL_FAST is set to true, don't run unit tests if build tests failed if (( ! PRESUBMIT_TEST_FAIL_FAST )) || (( ! failed )); then - run_unit_tests || failed=1 + run_unit_tests || { failed=1; step_failed "run_unit_tests"; } fi # If PRESUBMIT_TEST_FAIL_FAST is set to true, don't run integration tests if build/unit tests failed if (( ! PRESUBMIT_TEST_FAIL_FAST )) || (( ! failed )); then - run_integration_tests || failed=1 + run_integration_tests || { failed=1; step_failed "run_integration_tests"; } fi exit ${failed} diff --git a/vendor/knative.dev/test-infra/scripts/release.sh b/vendor/knative.dev/test-infra/scripts/release.sh index 915fc97f62..d23c4c33b5 100755 --- a/vendor/knative.dev/test-infra/scripts/release.sh +++ b/vendor/knative.dev/test-infra/scripts/release.sh @@ -498,9 +498,30 @@ function publish_artifacts() { # Entry point for a release script. function main() { + parse_flags "$@" + + # Checkout specific branch, if necessary + local current_branch + current_branch="$(git rev-parse --abbrev-ref HEAD)" + if [[ -n "${RELEASE_BRANCH}" && -z "${FROM_NIGHTLY_RELEASE}" && "${current_branch}" != "${RELEASE_BRANCH}" ]]; then + setup_upstream + setup_branch + # When it runs in Prow, the origin is identical with upstream, and previous + # fetch already fetched release-* branches, so no need to `checkout -b` + if (( IS_PROW )); then + git checkout "${RELEASE_BRANCH}" || abort "cannot checkout branch ${RELEASE_BRANCH}" + else + git checkout -b "${RELEASE_BRANCH}" upstream/"${RELEASE_BRANCH}" || abort "cannot checkout branch ${RELEASE_BRANCH}" + fi + # HACK HACK HACK + # Rerun the release script from the release branch. Fixes https://github.com/knative/test-infra/issues/1262 + ./hack/release.sh "$@" + exit "$?" + fi + function_exists build_release || abort "function 'build_release()' not defined" [[ -x ${VALIDATION_TESTS} ]] || abort "test script '${VALIDATION_TESTS}' doesn't exist" - parse_flags "$@" + # Log what will be done and where. banner "Release configuration" if which gcloud &>/dev/null ; then @@ -533,13 +554,6 @@ function main() { fi [[ -n "${RELEASE_NOTES}" ]] && echo "- Release notes are generated from '${RELEASE_NOTES}'" - # Checkout specific branch, if necessary - if [[ -n "${RELEASE_BRANCH}" && -z "${FROM_NIGHTLY_RELEASE}" ]]; then - setup_upstream - setup_branch - git checkout upstream/${RELEASE_BRANCH} || abort "cannot checkout branch ${RELEASE_BRANCH}" - fi - if [[ -n "${FROM_NIGHTLY_RELEASE}" ]]; then build_from_nightly_release else