diff --git a/go.mod b/go.mod index c1a0b249..dbc1200b 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-20200517014302-3c29a1ce8906 - knative.dev/test-infra v0.0.0-20200515184601-7a28f47cdbcb + knative.dev/pkg v0.0.0-20200518174206-60f4ae1dbe6f + knative.dev/test-infra v0.0.0-20200519015156-82551620b0a9 ) replace ( diff --git a/go.sum b/go.sum index 9663f3f8..41dcfbc8 100644 --- a/go.sum +++ b/go.sum @@ -1375,8 +1375,8 @@ knative.dev/pkg v0.0.0-20200514052058-c75d324f8b8b h1:lM0uwBgNcS9S4cWLqIS6Fvjt3k 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/pkg v0.0.0-20200517014302-3c29a1ce8906 h1:Xo/FFyVEZic+75UZJ0MJMuXgdfh+99YixIMAd3nCVys= -knative.dev/pkg v0.0.0-20200517014302-3c29a1ce8906/go.mod h1:GinFtW8LEi9rzCkzCMHAIlAnZjP1RzauxwhRAI3rimI= +knative.dev/pkg v0.0.0-20200518174206-60f4ae1dbe6f h1:f2eK5+z0/l2S431UCezMG9W4FzktuNbD0OB1gezSoMs= +knative.dev/pkg v0.0.0-20200518174206-60f4ae1dbe6f/go.mod h1:GinFtW8LEi9rzCkzCMHAIlAnZjP1RzauxwhRAI3rimI= 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= @@ -1384,8 +1384,8 @@ knative.dev/test-infra v0.0.0-20200513011557-d03429a76034 h1:JxqONCZVS7or+Fv3ebV knative.dev/test-infra v0.0.0-20200513011557-d03429a76034/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= -knative.dev/test-infra v0.0.0-20200515184601-7a28f47cdbcb h1:g1NE1OdGOh8vgLaKhi6O/fXFhlewq7wnL2EQNLKe+bE= -knative.dev/test-infra v0.0.0-20200515184601-7a28f47cdbcb/go.mod h1:A5b2OAXTOeHT3hHhVQm3dmtbuWvIDP7qzgtqxA3/2pE= +knative.dev/test-infra v0.0.0-20200519015156-82551620b0a9 h1:kKfV3QWsxugwXsqgjFd72MjZeAHJ381dWqAxH2KMknc= +knative.dev/test-infra v0.0.0-20200519015156-82551620b0a9/go.mod h1:A5b2OAXTOeHT3hHhVQm3dmtbuWvIDP7qzgtqxA3/2pE= 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/configmap/parse.go b/vendor/knative.dev/pkg/configmap/parse.go index 097b38f9..6479598b 100644 --- a/vendor/knative.dev/pkg/configmap/parse.go +++ b/vendor/knative.dev/pkg/configmap/parse.go @@ -17,9 +17,12 @@ limitations under the License. package configmap import ( + "fmt" "strconv" "strings" "time" + + "k8s.io/apimachinery/pkg/util/sets" ) // ParseFunc is a function taking ConfigMap data and applying a parse operation to it. @@ -51,7 +54,7 @@ func AsInt32(key string, target *int32) ParseFunc { if raw, ok := data[key]; ok { val, err := strconv.ParseInt(raw, 10, 32) if err != nil { - return err + return fmt.Errorf("failed to parse %q: %w", key, err) } *target = int32(val) } @@ -65,7 +68,7 @@ func AsInt64(key string, target *int64) ParseFunc { if raw, ok := data[key]; ok { val, err := strconv.ParseInt(raw, 10, 64) if err != nil { - return err + return fmt.Errorf("failed to parse %q: %w", key, err) } *target = val } @@ -79,7 +82,7 @@ func AsFloat64(key string, target *float64) ParseFunc { if raw, ok := data[key]; ok { val, err := strconv.ParseFloat(raw, 64) if err != nil { - return err + return fmt.Errorf("failed to parse %q: %w", key, err) } *target = val } @@ -93,7 +96,7 @@ func AsDuration(key string, target *time.Duration) ParseFunc { if raw, ok := data[key]; ok { val, err := time.ParseDuration(raw) if err != nil { - return err + return fmt.Errorf("failed to parse %q: %w", key, err) } *target = val } @@ -101,6 +104,16 @@ func AsDuration(key string, target *time.Duration) ParseFunc { } } +// AsStringSet parses the value at key as a sets.String (split by ',') into the target, if it exists. +func AsStringSet(key string, target *sets.String) ParseFunc { + return func(data map[string]string) error { + if raw, ok := data[key]; ok { + *target = sets.NewString(strings.Split(raw, ",")...) + } + 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 { diff --git a/vendor/knative.dev/pkg/metrics/config_observability.go b/vendor/knative.dev/pkg/metrics/config_observability.go index e40cb2fb..e4560ede 100644 --- a/vendor/knative.dev/pkg/metrics/config_observability.go +++ b/vendor/knative.dev/pkg/metrics/config_observability.go @@ -18,10 +18,10 @@ package metrics import ( "os" - "strings" texttemplate "text/template" corev1 "k8s.io/api/core/v1" + cm "knative.dev/pkg/configmap" ) const ( @@ -71,32 +71,23 @@ func defaultConfig() *ObservabilityConfig { // NewObservabilityConfigFromConfigMap creates a ObservabilityConfig from the supplied ConfigMap func NewObservabilityConfigFromConfigMap(configMap *corev1.ConfigMap) (*ObservabilityConfig, error) { oc := defaultConfig() - if evlc, ok := configMap.Data["logging.enable-var-log-collection"]; ok { - oc.EnableVarLogCollection = strings.EqualFold(evlc, "true") + + if err := cm.Parse(configMap.Data, + cm.AsBool("logging.enable-var-log-collection", &oc.EnableVarLogCollection), + cm.AsString("logging.revision-url-template", &oc.LoggingURLTemplate), + cm.AsString("logging.request-log-template", &oc.RequestLogTemplate), + cm.AsBool("logging.enable-probe-request-log", &oc.EnableProbeRequestLog), + cm.AsString("metrics.request-metrics-backend-destination", &oc.RequestMetricsBackend), + cm.AsBool("profiling.enable", &oc.EnableProfiling), + ); err != nil { + return nil, err } - if rut, ok := configMap.Data["logging.revision-url-template"]; ok { - oc.LoggingURLTemplate = rut - } - - if rlt, ok := configMap.Data["logging.request-log-template"]; ok { + if oc.RequestLogTemplate != "" { // Verify that we get valid templates. - if _, err := texttemplate.New("requestLog").Parse(rlt); err != nil { + if _, err := texttemplate.New("requestLog").Parse(oc.RequestLogTemplate); err != nil { return nil, err } - oc.RequestLogTemplate = rlt - } - - if eprl, ok := configMap.Data["logging.enable-probe-request-log"]; ok { - oc.EnableProbeRequestLog = strings.EqualFold(eprl, "true") - } - - if mb, ok := configMap.Data["metrics.request-metrics-backend-destination"]; ok { - oc.RequestMetricsBackend = mb - } - - if prof, ok := configMap.Data["profiling.enable"]; ok { - oc.EnableProfiling = strings.EqualFold(prof, "true") } return oc, nil diff --git a/vendor/modules.txt b/vendor/modules.txt index c8be56ee..850e3adc 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-20200517014302-3c29a1ce8906 +# knative.dev/pkg v0.0.0-20200518174206-60f4ae1dbe6f 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-20200515184601-7a28f47cdbcb +# knative.dev/test-infra v0.0.0-20200519015156-82551620b0a9 knative.dev/test-infra/scripts knative.dev/test-infra/tools/dep-collector # sigs.k8s.io/yaml v1.1.0