diff --git a/go.mod b/go.mod index cae4f8b6..b9e71c40 100644 --- a/go.mod +++ b/go.mod @@ -16,8 +16,8 @@ require ( k8s.io/client-go v11.0.1-0.20190805182717-6502b5e7b1b5+incompatible k8s.io/code-generator v0.18.0 k8s.io/kube-openapi v0.0.0-20191107075043-30be4d16710a - knative.dev/pkg v0.0.0-20200514052058-c75d324f8b8b - knative.dev/test-infra v0.0.0-20200513224158-2b7ecf0da961 + knative.dev/pkg v0.0.0-20200515002500-16d7b963416f + knative.dev/test-infra v0.0.0-20200514223200-ef4fd3ad398f ) replace ( diff --git a/go.sum b/go.sum index 7733faf6..c288084b 100644 --- a/go.sum +++ b/go.sum @@ -1373,13 +1373,15 @@ knative.dev/pkg v0.0.0-20200505191044-3da93ebb24c2 h1:Qu2NlOHb9p3g+CSL/ok9+FySow knative.dev/pkg v0.0.0-20200505191044-3da93ebb24c2/go.mod h1:Q6sL35DdGs8hIQZKdaCXJGgY8f90BmNBKSb8z6d/BTM= knative.dev/pkg v0.0.0-20200514052058-c75d324f8b8b h1:lM0uwBgNcS9S4cWLqIS6Fvjt3kR/6oAPXgbXfEzBJwU= knative.dev/pkg v0.0.0-20200514052058-c75d324f8b8b/go.mod h1:tMOHGbxtRz8zYFGEGpV/bpoTEM1o89MwYFC4YJXl3GY= +knative.dev/pkg v0.0.0-20200515002500-16d7b963416f h1:kcpAMvYUqftHMA69wZ7g83zEW4y8cdnqfdJsSPOlrJQ= +knative.dev/pkg v0.0.0-20200515002500-16d7b963416f/go.mod h1:tMOHGbxtRz8zYFGEGpV/bpoTEM1o89MwYFC4YJXl3GY= knative.dev/test-infra v0.0.0-20200407185800-1b88cb3b45a5/go.mod h1:xcdUkMJrLlBswIZqL5zCuBFOC22WIPMQoVX1L35i0vQ= knative.dev/test-infra v0.0.0-20200505052144-5ea2f705bb55 h1:Ajn44+eHHjPQL/BQicj8LMy8VTD2ypMCfHJuZVGEtew= knative.dev/test-infra v0.0.0-20200505052144-5ea2f705bb55/go.mod h1:WqF1Azka+FxPZ20keR2zCNtiQA1MP9ZB4BH4HuI+SIU= knative.dev/test-infra v0.0.0-20200513011557-d03429a76034 h1:JxqONCZVS7or+Fv3ebVQoipuIBH7Ig3Qbx170hgIF+A= knative.dev/test-infra v0.0.0-20200513011557-d03429a76034/go.mod h1:aMif0KXL4g19YCYwsy4Ocjjz5xgPlseYV+B95Oo4JGE= -knative.dev/test-infra v0.0.0-20200513224158-2b7ecf0da961 h1:idvJyBTh6J2owRgJgwuC0Y8BBEiCJf02IfK6+Vk0U7c= -knative.dev/test-infra v0.0.0-20200513224158-2b7ecf0da961/go.mod h1:aMif0KXL4g19YCYwsy4Ocjjz5xgPlseYV+B95Oo4JGE= +knative.dev/test-infra v0.0.0-20200514223200-ef4fd3ad398f h1:2j9xK15xMRz5h+yXIHt19iBAhWoEzRlZjSNurXzp4Nc= +knative.dev/test-infra v0.0.0-20200514223200-ef4fd3ad398f/go.mod h1:+uml4upluwrnWHRSezi4WVcKJ0OJHynF16Ot7fu0ky4= modernc.org/cc v1.0.0/go.mod h1:1Sk4//wdnYJiUIxnW8ddKpaOJCF37yAdqYnkxUpaYxw= modernc.org/golex v1.0.0/go.mod h1:b/QX9oBD/LhixY6NDh+IdGv17hgB+51fET1i2kPSmvk= modernc.org/mathutil v1.0.0/go.mod h1:wU0vUrJsVWBZ4P6e7xtFJEhFSNsfRLJ8H458uRjg03k= diff --git a/vendor/knative.dev/pkg/apis/duck/v1/kresource_type.go b/vendor/knative.dev/pkg/apis/duck/v1/kresource_type.go index 80558428..78d8ece6 100644 --- a/vendor/knative.dev/pkg/apis/duck/v1/kresource_type.go +++ b/vendor/knative.dev/pkg/apis/duck/v1/kresource_type.go @@ -22,15 +22,15 @@ import ( corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/runtime/schema" "knative.dev/pkg/apis" ) // KRShaped is an interface for retrieving the duck elements of an arbitrary resource. type KRShaped interface { - metav1.ObjectMetaAccessor - - GetTypeMeta() *metav1.TypeMeta + metav1.Object + schema.ObjectKind GetStatus() *Status @@ -81,11 +81,6 @@ type KResourceList struct { Items []KResource `json:"items"` } -// GetTypeMeta retrieves the ObjectMeta of the KResource. Implements the KRShaped interface. -func (t *KResource) GetTypeMeta() *metav1.TypeMeta { - return &t.TypeMeta -} - // GetStatus retrieves the status of the KResource. Implements the KRShaped interface. func (t *KResource) GetStatus() *Status { return &t.Status diff --git a/vendor/knative.dev/pkg/configmap/parse.go b/vendor/knative.dev/pkg/configmap/parse.go new file mode 100644 index 00000000..097b38f9 --- /dev/null +++ b/vendor/knative.dev/pkg/configmap/parse.go @@ -0,0 +1,112 @@ +/* +Copyright 2020 The Knative Authors + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package configmap + +import ( + "strconv" + "strings" + "time" +) + +// ParseFunc is a function taking ConfigMap data and applying a parse operation to it. +type ParseFunc func(map[string]string) error + +// AsString passes the value at key through into the target, if it exists. +func AsString(key string, target *string) ParseFunc { + return func(data map[string]string) error { + if raw, ok := data[key]; ok { + *target = raw + } + return nil + } +} + +// AsBool parses the value at key as a boolean into the target, if it exists. +func AsBool(key string, target *bool) ParseFunc { + return func(data map[string]string) error { + if raw, ok := data[key]; ok { + *target = strings.EqualFold(raw, "true") + } + return nil + } +} + +// AsInt32 parses the value at key as an int32 into the target, if it exists. +func AsInt32(key string, target *int32) ParseFunc { + return func(data map[string]string) error { + if raw, ok := data[key]; ok { + val, err := strconv.ParseInt(raw, 10, 32) + if err != nil { + return err + } + *target = int32(val) + } + return nil + } +} + +// AsInt64 parses the value at key as an int64 into the target, if it exists. +func AsInt64(key string, target *int64) ParseFunc { + return func(data map[string]string) error { + if raw, ok := data[key]; ok { + val, err := strconv.ParseInt(raw, 10, 64) + if err != nil { + return err + } + *target = val + } + return nil + } +} + +// AsFloat64 parses the value at key as a float64 into the target, if it exists. +func AsFloat64(key string, target *float64) ParseFunc { + return func(data map[string]string) error { + if raw, ok := data[key]; ok { + val, err := strconv.ParseFloat(raw, 64) + if err != nil { + return err + } + *target = val + } + return nil + } +} + +// AsDuration parses the value at key as a time.Duration into the target, if it exists. +func AsDuration(key string, target *time.Duration) ParseFunc { + return func(data map[string]string) error { + if raw, ok := data[key]; ok { + val, err := time.ParseDuration(raw) + if err != nil { + return err + } + *target = val + } + return nil + } +} + +// Parse parses the given map using the parser functions passed in. +func Parse(data map[string]string, parsers ...ParseFunc) error { + for _, parse := range parsers { + if err := parse(data); err != nil { + return err + } + } + return nil +} diff --git a/vendor/knative.dev/pkg/metrics/config.go b/vendor/knative.dev/pkg/metrics/config.go index a752e8d3..c7426e34 100644 --- a/vendor/knative.dev/pkg/metrics/config.go +++ b/vendor/knative.dev/pkg/metrics/config.go @@ -26,6 +26,7 @@ import ( "path" "strconv" "strings" + "sync" "time" "go.opencensus.io/stats" @@ -34,10 +35,6 @@ import ( "knative.dev/pkg/metrics/metricskey" ) -const ( - DomainEnv = "METRICS_DOMAIN" -) - // metricsBackend specifies the backend to use for metrics type metricsBackend string @@ -55,6 +52,8 @@ const ( StackdriverClusterNameKey = "metrics.stackdriver-cluster-name" StackdriverUseSecretKey = "metrics.stackdriver-use-secret" + DomainEnv = "METRICS_DOMAIN" + // Stackdriver is used for Stackdriver backend Stackdriver metricsBackend = "stackdriver" // Prometheus is used for Prometheus backend @@ -120,6 +119,8 @@ type metricsConfig struct { stackdriverClientConfig StackdriverClientConfig } +var logOnce sync.Once + // StackdriverClientConfig encapsulates the metadata required to configure a Stackdriver client. type StackdriverClientConfig struct { // ProjectID is the stackdriver project ID to which data is uploaded. @@ -155,14 +156,15 @@ func NewStackdriverClientConfigFromMap(config map[string]string) *StackdriverCli // measurements in the metricsConfig's designated backend. func (mc *metricsConfig) record(ctx context.Context, mss []stats.Measurement, ros ...stats.Options) error { if mc == nil { - log.Println(`The metricsConfig has not been initialized yet. - + logOnce.Do(func() { + log.Println(`The metricsConfig has not been initialized yet. If this is a Go unit test consuming metric.Record(...) or metric.RecordBatch(...) then it should add the following import: - import ( _ "knative.dev/pkg/metrics/testing" )`) + }) + // Don't record data points if the metric config is not initialized yet. // At this point, it's unclear whether should record or not. return nil diff --git a/vendor/knative.dev/pkg/reconciler/reconcile_common.go b/vendor/knative.dev/pkg/reconciler/reconcile_common.go index 38e3bbe3..8af08f61 100644 --- a/vendor/knative.dev/pkg/reconciler/reconcile_common.go +++ b/vendor/knative.dev/pkg/reconciler/reconcile_common.go @@ -29,7 +29,7 @@ const failedGenerationBump = "NewObservedGenFailure" func PreProcessReconcile(ctx context.Context, resource duckv1.KRShaped) { newStatus := resource.GetStatus() - if newStatus.ObservedGeneration != resource.GetObjectMeta().GetGeneration() { + if newStatus.ObservedGeneration != resource.GetGeneration() { condSet := resource.GetConditionSet() manager := condSet.Manage(newStatus) @@ -46,7 +46,7 @@ func PostProcessReconcile(ctx context.Context, resource duckv1.KRShaped) { // Bump observed generation to denote that we have processed this // generation regardless of success or failure. - newStatus.ObservedGeneration = resource.GetObjectMeta().GetGeneration() + newStatus.ObservedGeneration = resource.GetGeneration() rc := mgr.GetTopLevelCondition() if rc.Reason == failedGenerationBump { diff --git a/vendor/knative.dev/test-infra/scripts/library.sh b/vendor/knative.dev/test-infra/scripts/library.sh index 0b392741..092f3981 100644 --- a/vendor/knative.dev/test-infra/scripts/library.sh +++ b/vendor/knative.dev/test-infra/scripts/library.sh @@ -544,7 +544,8 @@ function update_licenses() { local dst=$1 local dir=$2 shift - run_go_tool github.com/google/go-licenses go-licenses save "${dir}" --save_path="${dst}" --force || return 1 + run_go_tool github.com/google/go-licenses go-licenses save "${dir}" --save_path="${dst}" --force || \ + { echo "--- FAIL: go-licenses failed to update licenses"; return 1; } # Hack to make sure directories retain write permissions after save. This # can happen if the directory being copied is a Go module. # See https://github.com/google/go-licenses/issues/11 @@ -554,7 +555,8 @@ function update_licenses() { # Run go-licenses to check for forbidden licenses. function check_licenses() { # Check that we don't have any forbidden licenses. - run_go_tool github.com/google/go-licenses go-licenses check "${REPO_ROOT_DIR}/..." || return 1 + run_go_tool github.com/google/go-licenses go-licenses check "${REPO_ROOT_DIR}/..." || \ + { echo "--- FAIL: go-licenses failed the license check"; return 1; } } # Run the given linter on the given files, checking it exists first. diff --git a/vendor/knative.dev/test-infra/scripts/shellcheck-presubmit.sh b/vendor/knative.dev/test-infra/scripts/shellcheck-presubmit.sh index ce1515bd..d9c48129 100644 --- a/vendor/knative.dev/test-infra/scripts/shellcheck-presubmit.sh +++ b/vendor/knative.dev/test-infra/scripts/shellcheck-presubmit.sh @@ -1,5 +1,19 @@ #!/usr/bin/env bash +# 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. + set -e source "$(dirname "${BASH_SOURCE[0]}")/library.sh" diff --git a/vendor/modules.txt b/vendor/modules.txt index c6573d19..988e367f 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -656,7 +656,7 @@ k8s.io/kube-openapi/pkg/util/sets k8s.io/utils/buffer k8s.io/utils/integer k8s.io/utils/trace -# knative.dev/pkg v0.0.0-20200514052058-c75d324f8b8b +# knative.dev/pkg v0.0.0-20200515002500-16d7b963416f knative.dev/pkg/apis knative.dev/pkg/apis/duck knative.dev/pkg/apis/duck/v1 @@ -676,7 +676,7 @@ knative.dev/pkg/metrics knative.dev/pkg/metrics/metricskey knative.dev/pkg/reconciler knative.dev/pkg/tracker -# knative.dev/test-infra v0.0.0-20200513224158-2b7ecf0da961 +# knative.dev/test-infra v0.0.0-20200514223200-ef4fd3ad398f knative.dev/test-infra/scripts knative.dev/test-infra/tools/dep-collector # sigs.k8s.io/yaml v1.1.0