mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-25 12:43:23 +00:00
TracingConfiguration is now validated strictly
This commit is contained in:
parent
55b83c92b3
commit
a9c8061b1e
@ -27,7 +27,7 @@ import (
|
||||
"go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc"
|
||||
"go.opentelemetry.io/otel/metric/noop"
|
||||
"go.opentelemetry.io/otel/sdk/resource"
|
||||
"go.opentelemetry.io/otel/semconv/v1.12.0"
|
||||
semconv "go.opentelemetry.io/otel/semconv/v1.12.0"
|
||||
"google.golang.org/grpc"
|
||||
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
@ -47,7 +47,7 @@ const apiserverService = "apiserver"
|
||||
|
||||
var (
|
||||
cfgScheme = runtime.NewScheme()
|
||||
codecs = serializer.NewCodecFactory(cfgScheme)
|
||||
codecs = serializer.NewCodecFactory(cfgScheme, serializer.EnableStrict)
|
||||
)
|
||||
|
||||
func init() {
|
||||
|
@ -98,6 +98,32 @@ func TestReadTracingConfiguration(t *testing.T) {
|
||||
expectedResult: nil,
|
||||
expectedError: strptr("unable to read tracing configuration from \"test-tracing-config-absent\": open test-tracing-config-absent: no such file or directory"),
|
||||
},
|
||||
{
|
||||
name: "duplicate field error; strict validation",
|
||||
createFile: true,
|
||||
contents: `
|
||||
apiVersion: apiserver.config.k8s.io/v1alpha1
|
||||
kind: TracingConfiguration
|
||||
endpoint: localhost:4317
|
||||
endpoint: localhost:4318
|
||||
samplingRatePerMillion: 12345
|
||||
`,
|
||||
expectedResult: nil,
|
||||
expectedError: strptr("unable to decode tracing configuration data: strict decoding error"),
|
||||
},
|
||||
{
|
||||
name: "unknown field error; strict validation",
|
||||
createFile: true,
|
||||
contents: `
|
||||
apiVersion: apiserver.config.k8s.io/v1alpha1
|
||||
kind: TracingConfiguration
|
||||
foo: bar
|
||||
endpoint: localhost:4318
|
||||
samplingRatePerMillion: 12345
|
||||
`,
|
||||
expectedResult: nil,
|
||||
expectedError: strptr("unable to decode tracing configuration data: strict decoding error"),
|
||||
},
|
||||
{
|
||||
name: "v1alpha1",
|
||||
createFile: true,
|
||||
|
Loading…
Reference in New Issue
Block a user