From a7d582c42bc2838d6043adc46bf7b0aef51d61a4 Mon Sep 17 00:00:00 2001 From: Yun Long Date: Mon, 13 Nov 2023 21:21:26 +0800 Subject: [PATCH 1/6] Fix misuse of omitempty in jsonschema --- pkg/cluster/customdata/customdata.go | 4 +- pkg/filters/builder/builder.go | 6 +- pkg/filters/builder/databuilder.go | 3 +- pkg/filters/builder/requestadaptor.go | 20 ++--- pkg/filters/builder/requestbuilder.go | 4 +- pkg/filters/builder/responseadaptor.go | 8 +- pkg/filters/builder/responsebuilder.go | 4 +- pkg/filters/connectcontrol/connectcontrol.go | 16 ++-- pkg/filters/corsadaptor/corsadaptor.go | 12 +-- pkg/filters/fallback/fallback.go | 4 +- pkg/filters/headerlookup/headerlookup.go | 6 +- pkg/filters/kafkabackend/spec.go | 4 +- pkg/filters/meshadaptor/meshadaptor.go | 4 +- pkg/filters/mock/mock.go | 14 ++-- pkg/filters/mqttclientauth/mqttauth.go | 2 +- pkg/filters/proxies/grpcproxy/pool.go | 23 +++-- pkg/filters/proxies/grpcproxy/proxy.go | 15 ++-- pkg/filters/proxies/grpcproxy/requestmatch.go | 2 +- pkg/filters/proxies/healthcheck.go | 10 +-- pkg/filters/proxies/httpproxy/pool.go | 16 ++-- pkg/filters/proxies/httpproxy/proxy.go | 23 ++--- pkg/filters/proxies/httpproxy/requestmatch.go | 4 +- .../proxies/httpproxy/simplehttpproxy.go | 12 +-- pkg/filters/proxies/httpproxy/wspool.go | 10 +-- pkg/filters/proxies/loadbalance.go | 10 +-- pkg/filters/proxies/requestmatch.go | 10 +-- pkg/filters/proxies/server.go | 6 +- pkg/filters/proxies/serverpool.go | 10 +-- pkg/filters/proxies/stickysession.go | 6 +- pkg/filters/ratelimiter/ratelimiter.go | 8 +- pkg/filters/redirector/redirector.go | 4 +- pkg/filters/remotefilter/remotefilter.go | 2 +- pkg/filters/validator/basicauth.go | 26 +++--- pkg/filters/validator/jwt.go | 4 +- pkg/filters/validator/oauth2.go | 12 +-- pkg/filters/validator/validator.go | 10 +-- pkg/filters/wasmhost/wasmhost.go | 2 +- pkg/object/autocertmanager/autocertmanager.go | 8 +- .../consulserviceregistry.go | 9 +- pkg/object/function/spec/function.go | 22 ++--- .../gatewaycontroller/gatewaycontroller.go | 7 +- pkg/object/globalfilter/globalfilter.go | 8 +- pkg/object/grpcserver/spec.go | 50 +++++------ pkg/object/httpserver/routers/spec.go | 42 +++++----- pkg/object/httpserver/spec.go | 38 ++++----- .../ingresscontroller/ingresscontroller.go | 8 +- pkg/object/meshcontroller/spec/spec.go | 84 +++++++++---------- pkg/object/mqttproxy/mock_test.go | 6 +- pkg/object/mqttproxy/spec.go | 30 +++---- .../nacosserviceregistry.go | 14 ++-- pkg/object/pipeline/pipeline.go | 12 +-- .../httpprot/httpheader/httpheader.go | 6 +- .../httpprot/httpheader/validator.go | 4 +- pkg/protocols/httpprot/request.go | 14 ++-- pkg/protocols/httpprot/response.go | 6 +- pkg/resilience/circuitbreaker.go | 18 ++-- pkg/resilience/retry.go | 8 +- pkg/supervisor/spec.go | 2 +- pkg/tracing/tracing.go | 60 ++++++------- pkg/util/ipfilter/ipfilter.go | 6 +- pkg/util/pathadaptor/pathadaptor.go | 8 +- pkg/util/signer/signer.go | 8 +- pkg/util/signer/spec.go | 16 ++-- pkg/util/stringtool/stringtool.go | 8 +- pkg/util/urlrule/urlrule.go | 4 +- pkg/v/validaterecorder_test.go | 10 +-- 66 files changed, 423 insertions(+), 429 deletions(-) diff --git a/pkg/cluster/customdata/customdata.go b/pkg/cluster/customdata/customdata.go index 473d23a338..d7197c8358 100644 --- a/pkg/cluster/customdata/customdata.go +++ b/pkg/cluster/customdata/customdata.go @@ -39,9 +39,9 @@ type Kind struct { Name string `json:"name" jsonschema:"required"` // IDField is a field name of custom data of this kind, this field is the ID // of the data, that's unique among the same kind, the default value is 'name'. - IDField string `json:"idField" jsonschema:"omitempty"` + IDField string `json:"idField,omitempty"` // JSONSchema is JSON schema to validate a custom data of this kind - JSONSchema dynamicobject.DynamicObject `json:"jsonSchema" jsonschema:"omitempty"` + JSONSchema dynamicobject.DynamicObject `json:"jsonSchema,omitempty"` } // KindWithLen defines the spec of a custom data kind with length diff --git a/pkg/filters/builder/builder.go b/pkg/filters/builder/builder.go index d675283f79..2e0430f31d 100644 --- a/pkg/filters/builder/builder.go +++ b/pkg/filters/builder/builder.go @@ -39,9 +39,9 @@ type ( // Spec is the spec of Builder. Spec struct { - LeftDelim string `json:"leftDelim,omitempty" jsonschema:"omitempty"` - RightDelim string `json:"rightDelim,omitempty" jsonschema:"omitempty"` - Template string `json:"template,omitempty" jsonschema:"omitempty"` + LeftDelim string `json:"leftDelim,omitempty"` + RightDelim string `json:"rightDelim,omitempty"` + Template string `json:"template,omitempty"` } ) diff --git a/pkg/filters/builder/databuilder.go b/pkg/filters/builder/databuilder.go index a9b5efd116..951bfaf208 100644 --- a/pkg/filters/builder/databuilder.go +++ b/pkg/filters/builder/databuilder.go @@ -57,7 +57,7 @@ type ( DataBuilderSpec struct { filters.BaseSpec `json:",inline"` Spec `json:",inline"` - DataKey string `json:"dataKey" jsonschema:"omitempty"` + DataKey string `json:"dataKey,omitempty"` } ) @@ -106,7 +106,6 @@ func (db *DataBuilder) reload() { // Handle builds request. func (db *DataBuilder) Handle(ctx *context.Context) (result string) { data, err := prepareBuilderData(ctx) - if err != nil { logger.Warnf("prepareBuilderData failed: %v", err) return resultBuildErr diff --git a/pkg/filters/builder/requestadaptor.go b/pkg/filters/builder/requestadaptor.go index a74d1f0d8c..7833c6d7a7 100644 --- a/pkg/filters/builder/requestadaptor.go +++ b/pkg/filters/builder/requestadaptor.go @@ -145,25 +145,25 @@ type ( Spec `json:",inline"` RequestAdaptorTemplate `json:",inline"` - Compress string `json:"compress,omitempty" jsonschema:"omitempty"` - Decompress string `json:"decompress,omitempty" jsonschema:"omitempty"` - Sign *SignerSpec `json:"sign,omitempty" jsonschema:"omitempty"` + Compress string `json:"compress,omitempty"` + Decompress string `json:"decompress,omitempty"` + Sign *SignerSpec `json:"sign,omitempty"` } // RequestAdaptorTemplate is the template of the request adaptor. RequestAdaptorTemplate struct { - Host string `json:"host,omitempty" jsonschema:"omitempty"` - Method string `json:"method,omitempty" jsonschema:"omitempty,format=httpmethod"` - Path *pathadaptor.Spec `json:"path,omitempty" jsonschema:"omitempty"` - Header *httpheader.AdaptSpec `json:"header,omitempty" jsonschema:"omitempty"` - Body string `json:"body,omitempty" jsonschema:"omitempty"` + Host string `json:"host,omitempty"` + Method string `json:"method,omitempty" jsonschema:"format=httpmethod"` + Path *pathadaptor.Spec `json:"path,omitempty"` + Header *httpheader.AdaptSpec `json:"header,omitempty"` + Body string `json:"body,omitempty"` } // SignerSpec is the spec of the request signer. SignerSpec struct { signer.Spec `json:",inline"` - APIProvider string `json:"apiProvider" jsonschema:"omitempty,enum=,enum=aws4"` - Scopes []string `json:"scopes" jsonschema:"omitempty"` + APIProvider string `json:"apiProvider,omitempty" jsonschema:"enum=,enum=aws4"` + Scopes []string `json:"scopes,omitempty"` } signerConfig struct { diff --git a/pkg/filters/builder/requestbuilder.go b/pkg/filters/builder/requestbuilder.go index 780d513f45..c6d31b9e7e 100644 --- a/pkg/filters/builder/requestbuilder.go +++ b/pkg/filters/builder/requestbuilder.go @@ -58,8 +58,8 @@ type ( RequestBuilderSpec struct { filters.BaseSpec `json:",inline"` Spec `json:",inline"` - SourceNamespace string `json:"sourceNamespace" jsonschema:"omitempty"` - Protocol string `json:"protocol" jsonschema:"omitempty"` + SourceNamespace string `json:"sourceNamespace,omitempty"` + Protocol string `json:"protocol,omitempty"` } ) diff --git a/pkg/filters/builder/responseadaptor.go b/pkg/filters/builder/responseadaptor.go index c7420c8456..6bc1809555 100644 --- a/pkg/filters/builder/responseadaptor.go +++ b/pkg/filters/builder/responseadaptor.go @@ -70,14 +70,14 @@ type ( Spec `json:",inline"` ResponseAdaptorTemplate `json:",inline"` - Compress string `json:"compress" jsonschema:"omitempty"` - Decompress string `json:"decompress" jsonschema:"omitempty"` + Compress string `json:"compress,omitempty"` + Decompress string `json:"decompress,omitempty"` } // ResponseAdaptorTemplate is the template of ResponseAdaptor. ResponseAdaptorTemplate struct { - Header *httpheader.AdaptSpec `json:"header" jsonschema:"omitempty"` - Body string `json:"body" jsonschema:"omitempty"` + Header *httpheader.AdaptSpec `json:"header,omitempty"` + Body string `json:"body,omitempty"` } ) diff --git a/pkg/filters/builder/responsebuilder.go b/pkg/filters/builder/responsebuilder.go index 1a12f0a01d..25ca35e769 100644 --- a/pkg/filters/builder/responsebuilder.go +++ b/pkg/filters/builder/responsebuilder.go @@ -58,8 +58,8 @@ type ( ResponseBuilderSpec struct { filters.BaseSpec `json:",inline"` Spec `json:",inline"` - SourceNamespace string `json:"sourceNamespace" jsonschema:"omitempty"` - Protocol string `json:"protocol" jsonschema:"omitempty"` + SourceNamespace string `json:"sourceNamespace,omitempty"` + Protocol string `json:"protocol,omitempty"` } ) diff --git a/pkg/filters/connectcontrol/connectcontrol.go b/pkg/filters/connectcontrol/connectcontrol.go index 2ddc63382f..24f8058b32 100644 --- a/pkg/filters/connectcontrol/connectcontrol.go +++ b/pkg/filters/connectcontrol/connectcontrol.go @@ -68,18 +68,18 @@ type ( Spec struct { filters.BaseSpec `json:",inline"` - BannedClientRe string `json:"bannedClientRe" jsonschema:"omitempty"` - BannedClients []string `json:"bannedClients" jsonschema:"omitempty"` - BannedTopicRe string `json:"bannedTopicRe" jsonschema:"omitempty"` - BannedTopics []string `json:"bannedTopics" jsonschema:"omitempty"` + BannedClientRe string `json:"bannedClientRe,omitempty"` + BannedClients []string `json:"bannedClients,omitempty"` + BannedTopicRe string `json:"bannedTopicRe,omitempty"` + BannedTopics []string `json:"bannedTopics,omitempty"` } // Status is ConnectControl filter status Status struct { - BannedClientRe string `json:"bannedClientRe" jsonschema:"omitempty"` - BannedClientNum int `json:"bannedClientNum" jsonschema:"omitempty"` - BannedTopicRe string `json:"bannedTopicRe" jsonschema:"omitempty"` - BannedTopicNum int `json:"bannedTopicNum" jsonschema:"omitempty"` + BannedClientRe string `json:"bannedClientRe,omitempty"` + BannedClientNum int `json:"bannedClientNum,omitempty"` + BannedTopicRe string `json:"bannedTopicRe,omitempty"` + BannedTopicNum int `json:"bannedTopicNum,omitempty"` } ) diff --git a/pkg/filters/corsadaptor/corsadaptor.go b/pkg/filters/corsadaptor/corsadaptor.go index 2c666fe168..8a695643ee 100644 --- a/pkg/filters/corsadaptor/corsadaptor.go +++ b/pkg/filters/corsadaptor/corsadaptor.go @@ -64,12 +64,12 @@ type ( Spec struct { filters.BaseSpec `json:",inline"` - AllowedOrigins []string `json:"allowedOrigins" jsonschema:"omitempty"` - AllowedMethods []string `json:"allowedMethods" jsonschema:"omitempty,uniqueItems=true,format=httpmethod-array"` - AllowedHeaders []string `json:"allowedHeaders" jsonschema:"omitempty"` - AllowCredentials bool `json:"allowCredentials" jsonschema:"omitempty"` - ExposedHeaders []string `json:"exposedHeaders" jsonschema:"omitempty"` - MaxAge int `json:"maxAge" jsonschema:"omitempty"` + AllowedOrigins []string `json:"allowedOrigins,omitempty"` + AllowedMethods []string `json:"allowedMethods,omitempty" jsonschema:"uniqueItems=true,format=httpmethod-array"` + AllowedHeaders []string `json:"allowedHeaders,omitempty"` + AllowCredentials bool `json:"allowCredentials,omitempty"` + ExposedHeaders []string `json:"exposedHeaders,omitempty"` + MaxAge int `json:"maxAge,omitempty"` } ) diff --git a/pkg/filters/fallback/fallback.go b/pkg/filters/fallback/fallback.go index 918eb2c928..b14949f18a 100644 --- a/pkg/filters/fallback/fallback.go +++ b/pkg/filters/fallback/fallback.go @@ -64,8 +64,8 @@ type ( filters.BaseSpec `json:",inline"` MockCode int `json:"mockCode" jsonschema:"required,format=httpcode"` - MockHeaders map[string]string `json:"mockHeaders" jsonschema:"omitempty"` - MockBody string `json:"mockBody" jsonschema:"omitempty"` + MockHeaders map[string]string `json:"mockHeaders,omitempty"` + MockBody string `json:"mockBody,omitempty"` } ) diff --git a/pkg/filters/headerlookup/headerlookup.go b/pkg/filters/headerlookup/headerlookup.go index 9a890ed08e..23f096501e 100644 --- a/pkg/filters/headerlookup/headerlookup.go +++ b/pkg/filters/headerlookup/headerlookup.go @@ -78,8 +78,8 @@ type ( // HeaderSetterSpec defines etcd source key and request destination header. HeaderSetterSpec struct { - EtcdKey string `json:"etcdKey,omitempty" jsonschema:"omitempty"` - HeaderKey string `json:"headerKey,omitempty" jsonschema:"omitempty"` + EtcdKey string `json:"etcdKey,omitempty"` + HeaderKey string `json:"headerKey,omitempty"` } // Spec defines header key and etcd prefix that form etcd key like /custom-data/{etcdPrefix}/{headerKey's value}. @@ -95,7 +95,7 @@ type ( HeaderKey string `json:"headerKey" jsonschema:"required"` EtcdPrefix string `json:"etcdPrefix" jsonschema:"required"` - PathRegExp string `json:"pathRegExp" jsonschema:"omitempty"` + PathRegExp string `json:"pathRegExp,omitempty"` HeaderSetters []*HeaderSetterSpec `json:"headerSetters" jsonschema:"required"` } ) diff --git a/pkg/filters/kafkabackend/spec.go b/pkg/filters/kafkabackend/spec.go index ccce67d07f..7611b9da6f 100644 --- a/pkg/filters/kafkabackend/spec.go +++ b/pkg/filters/kafkabackend/spec.go @@ -31,11 +31,11 @@ type ( // Topic defined ways to get Kafka topic Topic struct { Default string `json:"default" jsonschema:"required"` - Dynamic *Dynamic `json:"dynamic" jsonschema:"omitempty"` + Dynamic *Dynamic `json:"dynamic,omitempty"` } // Dynamic defines dynamic ways to get Kafka topic from http request Dynamic struct { - Header string `json:"header" jsonschema:"omitempty"` + Header string `json:"header,omitempty"` } ) diff --git a/pkg/filters/meshadaptor/meshadaptor.go b/pkg/filters/meshadaptor/meshadaptor.go index 0113fdd571..d59bb077e4 100644 --- a/pkg/filters/meshadaptor/meshadaptor.go +++ b/pkg/filters/meshadaptor/meshadaptor.go @@ -56,12 +56,12 @@ type ( // Spec is HTTPAdaptor Spec. Spec struct { filters.BaseSpec `json:",inline"` - ServiceCanaries []*ServiceCanaryAdaptor `json:"serviceCanaries" jsonschema:"omitempty"` + ServiceCanaries []*ServiceCanaryAdaptor `json:"serviceCanaries,omitempty"` } // ServiceCanaryAdaptor is the service canary adaptor. ServiceCanaryAdaptor struct { - Header *httpheader.AdaptSpec `json:"header,omitempty" jsonschema:"required"` + Header *httpheader.AdaptSpec `json:"header" jsonschema:"required"` Filter *proxy.RequestMatcherSpec `json:"filter" jsonschema:"required"` filter proxy.RequestMatcher diff --git a/pkg/filters/mock/mock.go b/pkg/filters/mock/mock.go index e2cf7c1736..6588c57169 100644 --- a/pkg/filters/mock/mock.go +++ b/pkg/filters/mock/mock.go @@ -69,19 +69,19 @@ type ( Rule struct { Match MatchRule `json:"match" jsonschema:"required"` Code int `json:"code" jsonschema:"required,format=httpcode"` - Headers map[string]string `json:"headers" jsonschema:"omitempty"` - Body string `json:"body" jsonschema:"omitempty"` - Delay string `json:"delay" jsonschema:"omitempty,format=duration"` + Headers map[string]string `json:"headers,omitempty"` + Body string `json:"body,omitempty"` + Delay string `json:"delay,omitempty" jsonschema:"format=duration"` delay time.Duration } // MatchRule is the rule to match a request MatchRule struct { - Path string `json:"path,omitempty" jsonschema:"omitempty,pattern=^/"` - PathPrefix string `json:"pathPrefix,omitempty" jsonschema:"omitempty,pattern=^/"` - Headers map[string]*stringtool.StringMatcher `json:"headers" jsonschema:"omitempty"` - MatchAllHeaders bool `json:"matchAllHeaders" jsonschema:"omitempty"` + Path string `json:"path,omitempty" jsonschema:"pattern=^/"` + PathPrefix string `json:"pathPrefix,omitempty" jsonschema:"pattern=^/"` + Headers map[string]*stringtool.StringMatcher `json:"headers,omitempty"` + MatchAllHeaders bool `json:"matchAllHeaders,omitempty"` } ) diff --git a/pkg/filters/mqttclientauth/mqttauth.go b/pkg/filters/mqttclientauth/mqttauth.go index 1c475895d2..6372d5e6d8 100644 --- a/pkg/filters/mqttclientauth/mqttauth.go +++ b/pkg/filters/mqttclientauth/mqttauth.go @@ -66,7 +66,7 @@ type ( Spec struct { filters.BaseSpec `json:",inline"` - Salt string `json:"salt" jsonschema:"omitempty"` + Salt string `json:"salt,omitempty"` Auth []*Auth `json:"auth" jsonschema:"required"` } diff --git a/pkg/filters/proxies/grpcproxy/pool.go b/pkg/filters/proxies/grpcproxy/pool.go index 1802e63c95..d44a9f4735 100644 --- a/pkg/filters/proxies/grpcproxy/pool.go +++ b/pkg/filters/proxies/grpcproxy/pool.go @@ -111,15 +111,13 @@ type serverPoolContext struct { resp *grpcprot.Response } -var ( - desc = &grpc.StreamDesc{ - // we assume that client side and server side both use stream calls. - // in test, only one or neither of the client and the server use streaming calls, - // gRPC server works well too - ClientStreams: true, - ServerStreams: true, - } -) +var desc = &grpc.StreamDesc{ + // we assume that client side and server side both use stream calls. + // in test, only one or neither of the client and the server use streaming calls, + // gRPC server works well too + ClientStreams: true, + ServerStreams: true, +} // ServerPool defines a server pool. type ServerPool struct { @@ -136,9 +134,9 @@ type ServerPool struct { type ServerPoolSpec struct { BaseServerPoolSpec `json:",inline"` - SpanName string `json:"spanName" jsonschema:"omitempty"` - Filter *RequestMatcherSpec `json:"filter" jsonschema:"omitempty"` - CircuitBreakerPolicy string `json:"circuitBreakerPolicy" jsonschema:"omitempty"` + SpanName string `json:"spanName,omitempty"` + Filter *RequestMatcherSpec `json:"filter,omitempty"` + CircuitBreakerPolicy string `json:"circuitBreakerPolicy,omitempty"` } // Validate validates ServerPoolSpec. @@ -373,7 +371,6 @@ func (sp *ServerPool) biTransport(ctx *serverPoolContext, proxyAsClientStream gr return nil } } - } func (sp *ServerPool) buildOutputResponse(spCtx *serverPoolContext, s *status.Status) { diff --git a/pkg/filters/proxies/grpcproxy/proxy.go b/pkg/filters/proxies/grpcproxy/proxy.go index 25d3f3d73a..dc992be0e3 100644 --- a/pkg/filters/proxies/grpcproxy/proxy.go +++ b/pkg/filters/proxies/grpcproxy/proxy.go @@ -75,8 +75,10 @@ var ( } ) -var _ filters.Filter = (*Proxy)(nil) -var _ filters.Resiliencer = (*Proxy)(nil) +var ( + _ filters.Filter = (*Proxy)(nil) + _ filters.Resiliencer = (*Proxy)(nil) +) func init() { filters.Register(kind) @@ -102,10 +104,10 @@ type ( filters.BaseSpec `json:",inline"` Pools []*ServerPoolSpec `json:"pools" jsonschema:"required"` // Timeout could be specified in unary calls case, and in stream calls case, it should not be specified - Timeout string `json:"timeout" jsonschema:"omitempty,format=duration"` - BorrowTimeout string `json:"borrowTimeout" jsonschema:"omitempty,format=duration"` - ConnectTimeout string `json:"connectTimeout" jsonschema:"omitempty,format=duration"` - MaxIdleConnsPerHost int `json:"maxIdleConnsPerHost" jsonschema:"omitempty"` + Timeout string `json:"timeout,omitempty" jsonschema:"format=duration"` + BorrowTimeout string `json:"borrowTimeout,omitempty" jsonschema:"format=duration"` + ConnectTimeout string `json:"connectTimeout,omitempty" jsonschema:"format=duration"` + MaxIdleConnsPerHost int `json:"maxIdleConnsPerHost,omitempty"` } // Server is the backend server. @@ -255,7 +257,6 @@ func (p *Proxy) Close() { for _, v := range p.candidatePools { v.Close() } - } // Handle handles GRPCContext. diff --git a/pkg/filters/proxies/grpcproxy/requestmatch.go b/pkg/filters/proxies/grpcproxy/requestmatch.go index 2bf4cedaad..90111bfa0b 100644 --- a/pkg/filters/proxies/grpcproxy/requestmatch.go +++ b/pkg/filters/proxies/grpcproxy/requestmatch.go @@ -27,7 +27,7 @@ import ( // RequestMatcherSpec describe RequestMatcher type RequestMatcherSpec struct { proxies.RequestMatcherBaseSpec `json:",inline"` - Methods []*stringtool.StringMatcher `json:"methods" jsonschema:"omitempty"` + Methods []*stringtool.StringMatcher `json:"methods"` } // Validate validates the RequestMatcherSpec. diff --git a/pkg/filters/proxies/healthcheck.go b/pkg/filters/proxies/healthcheck.go index d1ab47a261..1bc281d7e1 100644 --- a/pkg/filters/proxies/healthcheck.go +++ b/pkg/filters/proxies/healthcheck.go @@ -25,15 +25,15 @@ import ( // HealthCheckSpec is the spec for health check. type HealthCheckSpec struct { // Interval is the interval duration for health check. - Interval string `json:"interval" jsonschema:"omitempty,format=duration"` + Interval string `json:"interval,omitempty" jsonschema:"format=duration"` // Path is the health check path for server - Path string `json:"path" jsonschema:"omitempty"` + Path string `json:"path,omitempty"` // Timeout is the timeout duration for health check, default is 3. - Timeout string `json:"timeout" jsonschema:"omitempty,format=duration"` + Timeout string `json:"timeout,omitempty" jsonschema:"format=duration"` // Fails is the consecutive fails count for assert fail, default is 1. - Fails int `json:"fails" jsonschema:"omitempty,minimum=1"` + Fails int `json:"fails,omitempty" jsonschema:"minimum=1"` // Passes is the consecutive passes count for assert pass, default is 1. - Passes int `json:"passes" jsonschema:"omitempty,minimum=1"` + Passes int `json:"passes,omitempty" jsonschema:"minimum=1"` } // HealthChecker checks whether a server is healthy or not. diff --git a/pkg/filters/proxies/httpproxy/pool.go b/pkg/filters/proxies/httpproxy/pool.go index 15390505d1..1a293c8926 100644 --- a/pkg/filters/proxies/httpproxy/pool.go +++ b/pkg/filters/proxies/httpproxy/pool.go @@ -181,16 +181,16 @@ type ServerPool struct { type ServerPoolSpec struct { BaseServerPoolSpec `json:",inline"` - Filter *RequestMatcherSpec `json:"filter,omitempty" jsonschema:"omitempty"` - SpanName string `json:"spanName,omitempty" jsonschema:"omitempty"` - ServerMaxBodySize int64 `json:"serverMaxBodySize,omitempty" jsonschema:"omitempty"` - Timeout string `json:"timeout,omitempty" jsonschema:"omitempty,format=duration"` - RetryPolicy string `json:"retryPolicy,omitempty" jsonschema:"omitempty"` - CircuitBreakerPolicy string `json:"circuitBreakerPolicy,omitempty" jsonschema:"omitempty"` - MemoryCache *MemoryCacheSpec `json:"memoryCache,omitempty" jsonschema:"omitempty"` + Filter *RequestMatcherSpec `json:"filter,omitempty"` + SpanName string `json:"spanName,omitempty"` + ServerMaxBodySize int64 `json:"serverMaxBodySize,omitempty"` + Timeout string `json:"timeout,omitempty" jsonschema:"format=duration"` + RetryPolicy string `json:"retryPolicy,omitempty"` + CircuitBreakerPolicy string `json:"circuitBreakerPolicy,omitempty"` + MemoryCache *MemoryCacheSpec `json:"memoryCache,omitempty"` // FailureCodes would be 5xx if it isn't assigned any value. - FailureCodes []int `json:"failureCodes,omitempty" jsonschema:"omitempty,uniqueItems=true"` + FailureCodes []int `json:"failureCodes,omitempty" jsonschema:"uniqueItems=true"` } // ServerPoolStatus is the status of Pool. diff --git a/pkg/filters/proxies/httpproxy/proxy.go b/pkg/filters/proxies/httpproxy/proxy.go index 834ee2a0de..52f149cb94 100644 --- a/pkg/filters/proxies/httpproxy/proxy.go +++ b/pkg/filters/proxies/httpproxy/proxy.go @@ -76,8 +76,10 @@ var kind = &filters.Kind{ }, } -var _ filters.Filter = (*Proxy)(nil) -var _ filters.Resiliencer = (*Proxy)(nil) +var ( + _ filters.Filter = (*Proxy)(nil) + _ filters.Resiliencer = (*Proxy)(nil) +) func init() { filters.Register(kind) @@ -107,13 +109,13 @@ type ( filters.BaseSpec `json:",inline"` Pools []*ServerPoolSpec `json:"pools" jsonschema:"required"` - MirrorPool *ServerPoolSpec `json:"mirrorPool,omitempty" jsonschema:"omitempty"` - Compression *CompressionSpec `json:"compression,omitempty" jsonschema:"omitempty"` - MTLS *MTLS `json:"mtls,omitempty" jsonschema:"omitempty"` - MaxIdleConns int `json:"maxIdleConns,omitempty" jsonschema:"omitempty"` - MaxIdleConnsPerHost int `json:"maxIdleConnsPerHost,omitempty" jsonschema:"omitempty"` - MaxRedirection int `json:"maxRedirection,omitempty" jsonschema:"omitempty"` - ServerMaxBodySize int64 `json:"serverMaxBodySize,omitempty" jsonschema:"omitempty"` + MirrorPool *ServerPoolSpec `json:"mirrorPool,omitempty"` + Compression *CompressionSpec `json:"compression,omitempty"` + MTLS *MTLS `json:"mtls,omitempty"` + MaxIdleConns int `json:"maxIdleConns,omitempty"` + MaxIdleConnsPerHost int `json:"maxIdleConnsPerHost,omitempty"` + MaxRedirection int `json:"maxRedirection,omitempty"` + ServerMaxBodySize int64 `json:"serverMaxBodySize,omitempty"` } // Status is the status of Proxy. @@ -128,7 +130,7 @@ type ( CertBase64 string `json:"certBase64" jsonschema:"required,format=base64"` KeyBase64 string `json:"keyBase64" jsonschema:"required,format=base64"` RootCertBase64 string `json:"rootCertBase64" jsonschema:"required,format=base64"` - InsecureSkipVerify bool `json:"insecureSkipVerify" jsonschema:"omitempty"` + InsecureSkipVerify bool `json:"insecureSkipVerify,omitempty"` } // HTTPClientSpec is the spec of HTTPClient. @@ -181,7 +183,6 @@ func (s *Spec) Validate() error { } func HTTPClient(tlsCfg *tls.Config, spec *HTTPClientSpec, timeout time.Duration) *http.Client { - dialFunc := func(ctx stdctx.Context, network, addr string) (net.Conn, error) { return (&net.Dialer{ Timeout: 30 * time.Second, diff --git a/pkg/filters/proxies/httpproxy/requestmatch.go b/pkg/filters/proxies/httpproxy/requestmatch.go index 2126107235..0679f6ff7e 100644 --- a/pkg/filters/proxies/httpproxy/requestmatch.go +++ b/pkg/filters/proxies/httpproxy/requestmatch.go @@ -27,7 +27,7 @@ import ( // RequestMatcherSpec describe RequestMatcher type RequestMatcherSpec struct { proxies.RequestMatcherBaseSpec `json:",inline"` - URLs []*MethodAndURLMatcher `json:"urls" jsonschema:"omitempty"` + URLs []*MethodAndURLMatcher `json:"urls,omitempty"` } // Validate validates the RequestMatcherSpec. @@ -150,7 +150,7 @@ func (gm *generalMatcher) matchURL(req *httpprot.Request) bool { // MethodAndURLMatcher defines the match rule of a http request type MethodAndURLMatcher struct { - Methods []string `json:"methods" jsonschema:"omitempty,uniqueItems=true,format=httpmethod-array"` + Methods []string `json:"methods,omitempty" jsonschema:"uniqueItems=true,format=httpmethod-array"` URL *stringtool.StringMatcher `json:"url" jsonschema:"required"` } diff --git a/pkg/filters/proxies/httpproxy/simplehttpproxy.go b/pkg/filters/proxies/httpproxy/simplehttpproxy.go index 02bf9a985a..97e20bb0ba 100644 --- a/pkg/filters/proxies/httpproxy/simplehttpproxy.go +++ b/pkg/filters/proxies/httpproxy/simplehttpproxy.go @@ -82,12 +82,12 @@ type ( SimpleHTTPProxySpec struct { filters.BaseSpec `json:",inline"` - Compression *CompressionSpec `json:"compression,omitempty" jsonschema:"omitempty"` - MaxIdleConns int `json:"maxIdleConns" jsonschema:"omitempty"` - MaxIdleConnsPerHost int `json:"maxIdleConnsPerHost" jsonschema:"omitempty"` - ServerMaxBodySize int64 `json:"serverMaxBodySize" jsonschema:"omitempty"` - Timeout string `json:"timeout" jsonschema:"omitempty,format=duration"` - RetryPolicy string `json:"retryPolicy" jsonschema:"omitempty"` + Compression *CompressionSpec `json:"compression,omitempty"` + MaxIdleConns int `json:"maxIdleConns"` + MaxIdleConnsPerHost int `json:"maxIdleConnsPerHost"` + ServerMaxBodySize int64 `json:"serverMaxBodySize"` + Timeout string `json:"timeout" jsonschema:"format=duration"` + RetryPolicy string `json:"retryPolicy"` } ) diff --git a/pkg/filters/proxies/httpproxy/wspool.go b/pkg/filters/proxies/httpproxy/wspool.go index d645f0991c..883d0a8449 100644 --- a/pkg/filters/proxies/httpproxy/wspool.go +++ b/pkg/filters/proxies/httpproxy/wspool.go @@ -47,11 +47,11 @@ type WebSocketServerPool struct { // WebSocketServerPoolSpec is the spec for a server pool. type WebSocketServerPoolSpec struct { BaseServerPoolSpec `json:",inline"` - ClientMaxMsgSize int64 `json:"clientMaxMsgSize,omitempty" jsonschema:"omitempty"` - ServerMaxMsgSize int64 `json:"serverMaxMsgSize,omitempty" jsonschema:"omitempty"` - Filter *RequestMatcherSpec `json:"filter,omitempty" jsonschema:"omitempty"` - InsecureSkipVerify bool `json:"insecureSkipVerify,omitempty" jsonschema:"omitempty"` - OriginPatterns []string `json:"originPatterns,omitempty" jsonschema:"omitempty"` + ClientMaxMsgSize int64 `json:"clientMaxMsgSize,omitempty"` + ServerMaxMsgSize int64 `json:"serverMaxMsgSize,omitempty"` + Filter *RequestMatcherSpec `json:"filter,omitempty"` + InsecureSkipVerify bool `json:"insecureSkipVerify,omitempty"` + OriginPatterns []string `json:"originPatterns,omitempty"` } // NewWebSocketServerPool creates a new server pool according to spec. diff --git a/pkg/filters/proxies/loadbalance.go b/pkg/filters/proxies/loadbalance.go index 829cc723c6..f85d7f6a07 100644 --- a/pkg/filters/proxies/loadbalance.go +++ b/pkg/filters/proxies/loadbalance.go @@ -57,11 +57,11 @@ type LoadBalancer interface { // this is not good as new policies could be added in the future, we should // convert it to a map later. type LoadBalanceSpec struct { - Policy string `json:"policy,omitempty" jsonschema:"omitempty"` - HeaderHashKey string `json:"headerHashKey,omitempty" jsonschema:"omitempty"` - ForwardKey string `json:"forwardKey,omitempty" jsonschema:"omitempty"` - StickySession *StickySessionSpec `json:"stickySession,omitempty" jsonschema:"omitempty"` - HealthCheck *HealthCheckSpec `json:"healthCheck,omitempty" jsonschema:"omitempty"` + Policy string `json:"policy,omitempty"` + HeaderHashKey string `json:"headerHashKey,omitempty"` + ForwardKey string `json:"forwardKey,omitempty"` + StickySession *StickySessionSpec `json:"stickySession,omitempty"` + HealthCheck *HealthCheckSpec `json:"healthCheck,omitempty"` } // LoadBalancePolicy is the interface of a load balance policy. diff --git a/pkg/filters/proxies/requestmatch.go b/pkg/filters/proxies/requestmatch.go index 89be0b9da1..d8c5713425 100644 --- a/pkg/filters/proxies/requestmatch.go +++ b/pkg/filters/proxies/requestmatch.go @@ -34,11 +34,11 @@ type RequestMatcher interface { // RequestMatcherBaseSpec describe RequestMatcher type RequestMatcherBaseSpec struct { - Policy string `json:"policy" jsonschema:"omitempty,enum=,enum=general,enum=ipHash,enum=headerHash,enum=random"` - MatchAllHeaders bool `json:"matchAllHeaders" jsonschema:"omitempty"` - Headers map[string]*stringtool.StringMatcher `json:"headers" jsonschema:"omitempty"` - Permil uint32 `json:"permil" jsonschema:"omitempty,minimum=0,maximum=1000"` - HeaderHashKey string `json:"headerHashKey" jsonschema:"omitempty"` + Policy string `json:"policy,omitempty" jsonschema:"enum=,enum=general,enum=ipHash,enum=headerHash,enum=random"` + MatchAllHeaders bool `json:"matchAllHeaders,omitempty"` + Headers map[string]*stringtool.StringMatcher `json:"headers,omitempty"` + Permil uint32 `json:"permil,omitempty" jsonschema:"minimum=0,maximum=1000"` + HeaderHashKey string `json:"headerHashKey,omitempty"` } // Validate validates the RequestMatcherBaseSpec. diff --git a/pkg/filters/proxies/server.go b/pkg/filters/proxies/server.go index 76bfd44493..82520b111f 100644 --- a/pkg/filters/proxies/server.go +++ b/pkg/filters/proxies/server.go @@ -27,9 +27,9 @@ import ( // Server is a backend proxy server. type Server struct { URL string `json:"url" jsonschema:"required,format=url"` - Tags []string `json:"tags,omitempty" jsonschema:"omitempty,uniqueItems=true"` - Weight int `json:"weight,omitempty" jsonschema:"omitempty,minimum=0,maximum=100"` - KeepHost bool `json:"keepHost,omitempty" jsonschema:"omitempty,default=false"` + Tags []string `json:"tags,omitempty" jsonschema:"uniqueItems=true"` + Weight int `json:"weight,omitempty" jsonschema:"minimum=0,maximum=100"` + KeepHost bool `json:"keepHost,omitempty" jsonschema:"default=false"` AddrIsHostName bool `json:"-"` Unhealth bool `json:"-"` // HealthCounter is used to count the number of successive health checks diff --git a/pkg/filters/proxies/serverpool.go b/pkg/filters/proxies/serverpool.go index c0d152f137..3e05cc5263 100644 --- a/pkg/filters/proxies/serverpool.go +++ b/pkg/filters/proxies/serverpool.go @@ -45,11 +45,11 @@ type ServerPoolBase struct { // ServerPoolBaseSpec is the spec for a base server pool. type ServerPoolBaseSpec struct { - ServerTags []string `json:"serverTags,omitempty" jsonschema:"omitempty,uniqueItems=true"` - Servers []*Server `json:"servers,omitempty" jsonschema:"omitempty"` - ServiceRegistry string `json:"serviceRegistry,omitempty" jsonschema:"omitempty"` - ServiceName string `json:"serviceName,omitempty" jsonschema:"omitempty"` - LoadBalance *LoadBalanceSpec `json:"loadBalance,omitempty" jsonschema:"omitempty"` + ServerTags []string `json:"serverTags,omitempty" jsonschema:"uniqueItems=true"` + Servers []*Server `json:"servers,omitempty"` + ServiceRegistry string `json:"serviceRegistry,omitempty"` + ServiceName string `json:"serviceName,omitempty"` + LoadBalance *LoadBalanceSpec `json:"loadBalance,omitempty"` } // Validate validates ServerPoolSpec. diff --git a/pkg/filters/proxies/stickysession.go b/pkg/filters/proxies/stickysession.go index 38f1fed93d..fa31519076 100644 --- a/pkg/filters/proxies/stickysession.go +++ b/pkg/filters/proxies/stickysession.go @@ -52,11 +52,11 @@ const ( type StickySessionSpec struct { Mode string `json:"mode" jsonschema:"required,enum=CookieConsistentHash,enum=DurationBased,enum=ApplicationBased"` // AppCookieName is the user-defined cookie name in CookieConsistentHash and ApplicationBased mode. - AppCookieName string `json:"appCookieName" jsonschema:"omitempty"` + AppCookieName string `json:"appCookieName,omitempty"` // LBCookieName is the generated cookie name in DurationBased and ApplicationBased mode. - LBCookieName string `json:"lbCookieName" jsonschema:"omitempty"` + LBCookieName string `json:"lbCookieName,omitempty"` // LBCookieExpire is the expire seconds of generated cookie in DurationBased and ApplicationBased mode. - LBCookieExpire string `json:"lbCookieExpire" jsonschema:"omitempty,format=duration"` + LBCookieExpire string `json:"lbCookieExpire,omitempty" jsonschema:"format=duration"` } // SessionSticker is the interface for session stickiness. diff --git a/pkg/filters/ratelimiter/ratelimiter.go b/pkg/filters/ratelimiter/ratelimiter.go index e379e2c0fa..2350fe1bb9 100644 --- a/pkg/filters/ratelimiter/ratelimiter.go +++ b/pkg/filters/ratelimiter/ratelimiter.go @@ -58,9 +58,9 @@ type ( // Policy defines the policy of a rate limiter Policy struct { Name string `json:"name" jsonschema:"required"` - TimeoutDuration string `json:"timeoutDuration" jsonschema:"omitempty,format=duration"` - LimitRefreshPeriod string `json:"limitRefreshPeriod" jsonschema:"omitempty,format=duration"` - LimitForPeriod int `json:"limitForPeriod" jsonschema:"omitempty,minimum=1"` + TimeoutDuration string `json:"timeoutDuration,omitempty" jsonschema:"format=duration"` + LimitRefreshPeriod string `json:"limitRefreshPeriod,omitempty" jsonschema:"format=duration"` + LimitForPeriod int `json:"limitForPeriod,omitempty" jsonschema:"minimum=1"` } // URLRule defines the rate limiter rule for a URL pattern @@ -79,7 +79,7 @@ type ( // Rule is the detailed config of RateLimiter. Rule struct { Policies []*Policy `json:"policies" jsonschema:"required"` - DefaultPolicyRef string `json:"defaultPolicyRef" jsonschema:"omitempty"` + DefaultPolicyRef string `json:"defaultPolicyRef,omitempty"` URLs []*URLRule `json:"urls" jsonschema:"required"` } diff --git a/pkg/filters/redirector/redirector.go b/pkg/filters/redirector/redirector.go index 74371197b9..247bccd5fa 100644 --- a/pkg/filters/redirector/redirector.go +++ b/pkg/filters/redirector/redirector.go @@ -82,9 +82,9 @@ type ( filters.BaseSpec `json:",inline"` Match string `json:"match" jsonschema:"required"` - MatchPart string `json:"matchPart,omitempty" jsonschema:"omitempty,enum=uri,enum=path,enum=full"` // default uri + MatchPart string `json:"matchPart,omitempty" jsonschema:"enum=uri,enum=path,enum=full"` // default uri Replacement string `json:"replacement" jsonschema:"required"` - StatusCode int `json:"statusCode,omitempty" jsonschema:"omitempty"` // default 301 + StatusCode int `json:"statusCode,omitempty"` // default 301 } ) diff --git a/pkg/filters/remotefilter/remotefilter.go b/pkg/filters/remotefilter/remotefilter.go index 6304407422..bef087ca47 100644 --- a/pkg/filters/remotefilter/remotefilter.go +++ b/pkg/filters/remotefilter/remotefilter.go @@ -119,7 +119,7 @@ type ( filters.BaseSpec `json:",inline"` URL string `json:"url" jsonschema:"required,format=uri"` - Timeout string `json:"timeout" jsonschema:"omitempty,format=duration"` + Timeout string `json:"timeout,omitempty" jsonschema:"format=duration"` timeout time.Duration } diff --git a/pkg/filters/validator/basicauth.go b/pkg/filters/validator/basicauth.go index c737013608..f38e635c1c 100644 --- a/pkg/filters/validator/basicauth.go +++ b/pkg/filters/validator/basicauth.go @@ -44,12 +44,12 @@ type ( // BasicAuthValidatorSpec defines the configuration of Basic Auth validator. // There are 'file' and 'etcd' modes. BasicAuthValidatorSpec struct { - Mode string `json:"mode" jsonschema:"omitempty,enum=FILE,enum=ETCD,enum=LDAP"` + Mode string `json:"mode,omitempty" jsonschema:"enum=FILE,enum=ETCD,enum=LDAP"` // Required for 'FILE' mode. // UserFile is path to file containing encrypted user credentials in apache2-utils/htpasswd format. // To add user `userY`, use `sudo htpasswd /etc/apache2/.htpasswd userY` // Reference: https://manpages.debian.org/testing/apache2-utils/htpasswd.1.en.html#EXAMPLES - UserFile string `json:"userFile" jsonschema:"omitempty"` + UserFile string `json:"userFile,omitempty"` // Required for 'ETCD' mode. // When EtcdPrefix is specified, verify user credentials from etcd. Etcd should store them: // key: /custom-data/{etcdPrefix}/{$key} @@ -59,7 +59,7 @@ type ( // password: "$password" // Username and password are used for Basic Authentication. If "username" is empty, the value of "key" // entry is used as username for Basic Auth. - EtcdPrefix string `json:"etcdPrefix" jsonschema:"omitempty"` + EtcdPrefix string `json:"etcdPrefix,omitempty"` // Required for 'LDAP' mode. LDAP *ldapSpec `json:"ldap,omitempty" jsonshema:"omitempty"` } @@ -100,12 +100,12 @@ type ( Port int `json:"port" jsonschema:"required"` BaseDN string `json:"baseDN" jsonschema:"required"` UID string `json:"uid" jsonschema:"required"` - UseSSL bool `json:"useSSL" jsonschema:"omitempty"` - SkipTLS bool `json:"skipTLS" jsonschema:"omitempty"` - Insecure bool `json:"insecure" jsonschema:"omitempty"` - ServerName string `json:"serverName" jsonschema:"omitempty"` - CertBase64 string `json:"certBase64" jsonschema:"omitempty,format=base64"` - KeyBase64 string `json:"keyBase64" jsonschema:"omitempty,format=base64"` + UseSSL bool `json:"useSSL,omitempty"` + SkipTLS bool `json:"skipTLS,omitempty"` + Insecure bool `json:"insecure,omitempty"` + ServerName string `json:"serverName,omitempty"` + CertBase64 string `json:"certBase64,omitempty" jsonschema:"format=base64"` + KeyBase64 string `json:"keyBase64,omitempty" jsonschema:"format=base64"` certificates []tls.Certificate } @@ -117,8 +117,8 @@ type ( // etcdCredentials defines the format for credentials in etcd etcdCredentials struct { - Key string `json:"key" jsonschema:"omitempty"` - User string `json:"username" jsonschema:"omitempty"` + Key string `json:"key,omitempty"` + User string `json:"username,omitempty"` Pass string `json:"password" jsonschema:"required"` } ) @@ -357,7 +357,8 @@ func newLDAPUserCache(spec *ldapSpec) *ldapUserCache { } return &ldapUserCache{ spec: spec, - client: client} + client: client, + } } // make it mockable @@ -381,7 +382,6 @@ func (luc *ldapUserCache) Match(username, password string) bool { } func (luc *ldapUserCache) WatchChanges() { - } func (luc *ldapUserCache) Close() { diff --git a/pkg/filters/validator/jwt.go b/pkg/filters/validator/jwt.go index 3cfc55f319..15e8e4b3c6 100644 --- a/pkg/filters/validator/jwt.go +++ b/pkg/filters/validator/jwt.go @@ -32,14 +32,14 @@ import ( // JWTValidatorSpec defines the configuration of JWT validator type JWTValidatorSpec struct { Algorithm string `json:"algorithm" jsonschema:"enum=HS256,enum=HS384,enum=HS512,enum=RS256,enum=RS384,enum=RS512,enum=ES256,enum=ES384,enum=ES512,enum=EdDSA"` - //PublicKey is in hex encoding + // PublicKey is in hex encoding PublicKey string `json:"publicKey" jsonschema:"pattern=^$|^[A-Fa-f0-9]+$"` // Secret is in hex encoding Secret string `json:"secret" jsonschema:"pattern=^$|^[A-Fa-f0-9]+$"` // CookieName specifies the name of a cookie, if not empty, and the cookie with // this name both exists and has a non-empty value, its value is used as token // string, the Authorization header is used to get the token string otherwise. - CookieName string `json:"cookieName" jsonschema:"omitempty"` + CookieName string `json:"cookieName,omitempty"` } // NewJWTValidator creates a new JWT validator diff --git a/pkg/filters/validator/oauth2.go b/pkg/filters/validator/oauth2.go index 467031e4d0..d883e9dc7d 100644 --- a/pkg/filters/validator/oauth2.go +++ b/pkg/filters/validator/oauth2.go @@ -35,10 +35,10 @@ type ( // OAuth2TokenIntrospect defines the validator configuration for OAuth2 token introspection OAuth2TokenIntrospect struct { EndPoint string `json:"endPoint" jsonschema:"required"` - BasicAuth string `json:"basicAuth" jsonschema:"omitempty"` - ClientID string `json:"clientId" jsonschema:"omitempty"` - ClientSecret string `json:"clientSecret" jsonschema:"omitempty"` - InsecureTLS bool `json:"insecureTls"` + BasicAuth string `json:"basicAuth,omitempty"` + ClientID string `json:"clientId,omitempty"` + ClientSecret string `json:"clientSecret,omitempty"` + InsecureTLS bool `json:"insecureTls,omitempty"` } // OAuth2JWT defines the validator configuration for OAuth2 self encoded access token @@ -51,8 +51,8 @@ type ( // OAuth2ValidatorSpec defines the configuration of OAuth2 validator OAuth2ValidatorSpec struct { - TokenIntrospect *OAuth2TokenIntrospect `json:"tokenIntrospect" jsonschema:"omitempty"` - JWT *OAuth2JWT `json:"jwt" jsonschema:"omitempty"` + TokenIntrospect *OAuth2TokenIntrospect `json:"tokenIntrospect,omitempty"` + JWT *OAuth2JWT `json:"jwt,omitempty"` } // OAuth2Validator defines the OAuth2 validator diff --git a/pkg/filters/validator/validator.go b/pkg/filters/validator/validator.go index 54cdb173a6..27d3596b81 100644 --- a/pkg/filters/validator/validator.go +++ b/pkg/filters/validator/validator.go @@ -70,11 +70,11 @@ type ( Spec struct { filters.BaseSpec `json:",inline"` - Headers *httpheader.ValidatorSpec `json:"headers,omitempty" jsonschema:"omitempty"` - JWT *JWTValidatorSpec `json:"jwt,omitempty" jsonschema:"omitempty"` - Signature *signer.Spec `json:"signature,omitempty" jsonschema:"omitempty"` - OAuth2 *OAuth2ValidatorSpec `json:"oauth2,omitempty" jsonschema:"omitempty"` - BasicAuth *BasicAuthValidatorSpec `json:"basicAuth,omitempty" jsonschema:"omitempty"` + Headers *httpheader.ValidatorSpec `json:"headers,omitempty"` + JWT *JWTValidatorSpec `json:"jwt,omitempty"` + Signature *signer.Spec `json:"signature,omitempty"` + OAuth2 *OAuth2ValidatorSpec `json:"oauth2,omitempty"` + BasicAuth *BasicAuthValidatorSpec `json:"basicAuth,omitempty"` } ) diff --git a/pkg/filters/wasmhost/wasmhost.go b/pkg/filters/wasmhost/wasmhost.go index 7b4f771863..3efe5e74e4 100644 --- a/pkg/filters/wasmhost/wasmhost.go +++ b/pkg/filters/wasmhost/wasmhost.go @@ -91,7 +91,7 @@ type ( MaxConcurrency int32 `json:"maxConcurrency" jsonschema:"required,minimum=1"` Code string `json:"code" jsonschema:"required"` Timeout string `json:"timeout" jsonschema:"required,format=duration"` - Parameters map[string]string `json:"parameters" jsonschema:"omitempty"` + Parameters map[string]string `json:"parameters,omitempty"` timeout time.Duration } diff --git a/pkg/object/autocertmanager/autocertmanager.go b/pkg/object/autocertmanager/autocertmanager.go index 98fb0860bd..524e9b90ea 100644 --- a/pkg/object/autocertmanager/autocertmanager.go +++ b/pkg/object/autocertmanager/autocertmanager.go @@ -62,7 +62,7 @@ func init() { } type ( - //AutoCertManager is the controller for Automated Certificate Management. + // AutoCertManager is the controller for Automated Certificate Management. AutoCertManager struct { super *supervisor.Supervisor superSpec *supervisor.Spec @@ -91,7 +91,7 @@ type ( // DomainSpec is the automated certificate management spec for a domain. DomainSpec struct { Name string `json:"name" jsonschema:"required"` - DNSProvider map[string]string `json:"dnsProvider" jsonschema:"omitempty"` + DNSProvider map[string]string `json:"dnsProvider,omitempty"` } // CertificateStatus is the certificate status of a domain. @@ -106,9 +106,7 @@ type ( } ) -var ( - globalACM atomic.Value -) +var globalACM atomic.Value // Validate validates the spec of AutoCertManager. func (spec *Spec) Validate() error { diff --git a/pkg/object/consulserviceregistry/consulserviceregistry.go b/pkg/object/consulserviceregistry/consulserviceregistry.go index 9fed3876ad..b367d79191 100644 --- a/pkg/object/consulserviceregistry/consulserviceregistry.go +++ b/pkg/object/consulserviceregistry/consulserviceregistry.go @@ -80,11 +80,11 @@ type ( Spec struct { Address string `json:"address" jsonschema:"required"` Scheme string `json:"scheme" jsonschema:"required,enum=http,enum=https"` - Datacenter string `json:"datacenter" jsonschema:"omitempty"` - Token string `json:"token" jsonschema:"omitempty"` - Namespace string `json:"namespace" jsonschema:"omitempty"` + Datacenter string `json:"datacenter,omitempty"` + Token string `json:"token,omitempty"` + Namespace string `json:"namespace,omitempty"` SyncInterval string `json:"syncInterval" jsonschema:"required,format=duration"` - ServiceTags []string `json:"serviceTags" jsonschema:"omitempty"` + ServiceTags []string `json:"serviceTags,omitempty"` } // Status is the status of ConsulServiceRegistry. @@ -394,7 +394,6 @@ func (c *ConsulServiceRegistry) ListServiceInstances(serviceName string) (map[st } catalogServices, err := client.ListServiceInstances(serviceName) - if err != nil { return nil, err } diff --git a/pkg/object/function/spec/function.go b/pkg/object/function/spec/function.go index eadef7d76a..1132dc57d9 100644 --- a/pkg/object/function/spec/function.go +++ b/pkg/object/function/spec/function.go @@ -59,22 +59,22 @@ type ( Function struct { Spec *Spec `json:"spec" jsonschema:"required"` Status *Status `json:"status" jsonschema:"required"` - Fsm *FSM `json:"fsm" jsonschema:"omitempty"` + Fsm *FSM `json:"fsm,omitempty"` } // Spec is the spec of FaaSFunction. Spec struct { Name string `json:"name" jsonschema:"required"` Image string `json:"image" jsonschema:"required"` - Port int `json:"port" jsonschema:"omitempty"` + Port int `json:"port,omitempty"` AutoScaleType string `json:"autoScaleType" jsonschema:"required"` AutoScaleValue string `json:"autoScaleValue" jsonschema:"required"` - MinReplica int `json:"minReplica" jsonschema:"omitempty"` - MaxReplica int `json:"maxReplica" jsonschema:"omitempty"` - LimitCPU string `json:"limitCPU" jsonschema:"omitempty"` - LimitMemory string `json:"limitMemory" jsonschema:"omitempty"` - RequestCPU string `json:"requestCPU" jsonschema:"omitempty"` - RequestMemory string `json:"requestMemory" jsonschema:"omitempty"` + MinReplica int `json:"minReplica,omitempty"` + MaxReplica int `json:"maxReplica,omitempty"` + LimitCPU string `json:"limitCPU,omitempty"` + LimitMemory string `json:"limitMemory,omitempty"` + RequestCPU string `json:"requestCPU,omitempty"` + RequestMemory string `json:"requestMemory,omitempty"` RequestAdaptor *builder.RequestAdaptorSpec `json:"requestAdaptor" jsonschema:"required"` } @@ -84,7 +84,7 @@ type ( Name string `json:"name" jsonschema:"required"` State State `json:"state" jsonschema:"required"` Event Event `json:"event" jsonschema:"required"` - ExtData map[string]string `json:"extData" jsonschema:"omitempty"` + ExtData map[string]string `json:"extData,omitempty"` } // Knative is the faas provider Knative. @@ -92,8 +92,8 @@ type ( HostSuffix string `json:"hostSuffix" jsonschema:"required"` NetworkLayerURL string `json:"networkLayerURL" jsonschema:"required,format=uri"` - Namespace string `json:"namespace" jsonschema:"omitempty"` - Timeout string `json:"timeout" jsonschema:"omitempty,format=duration"` + Namespace string `json:"namespace,omitempty"` + Timeout string `json:"timeout,omitempty" jsonschema:"format=duration"` } ) diff --git a/pkg/object/gatewaycontroller/gatewaycontroller.go b/pkg/object/gatewaycontroller/gatewaycontroller.go index 8ad752b8f8..a434a7ab99 100644 --- a/pkg/object/gatewaycontroller/gatewaycontroller.go +++ b/pkg/object/gatewaycontroller/gatewaycontroller.go @@ -55,9 +55,9 @@ type ( // Spec is the ingress controller spec Spec struct { - KubeConfig string `json:"kubeConfig" jsonschema:"omitempty"` - MasterURL string `json:"masterURL" jsonschema:"omitempty"` - Namespaces []string `json:"namespaces" jsonschema:"omitempty"` + KubeConfig string `json:"kubeConfig,omitempty"` + MasterURL string `json:"masterURL,omitempty"` + Namespaces []string `json:"namespaces,omitempty"` } ) @@ -86,7 +86,6 @@ func (gc *GatewayController) Init(superSpec *supervisor.Spec) { gc.spec = superSpec.ObjectSpec().(*Spec) gc.super = superSpec.Super() gc.reload() - } // Inherit inherits previous generation of GatewayController. diff --git a/pkg/object/globalfilter/globalfilter.go b/pkg/object/globalfilter/globalfilter.go index 33776c0289..72ae3db944 100644 --- a/pkg/object/globalfilter/globalfilter.go +++ b/pkg/object/globalfilter/globalfilter.go @@ -63,14 +63,14 @@ type ( // Spec describes the GlobalFilter. Spec struct { - BeforePipeline *pipeline.Spec `json:"beforePipeline" jsonschema:"omitempty"` - AfterPipeline *pipeline.Spec `json:"afterPipeline" jsonschema:"omitempty"` + BeforePipeline *pipeline.Spec `json:"beforePipeline,omitempty"` + AfterPipeline *pipeline.Spec `json:"afterPipeline,omitempty"` } // pipelineSpec defines pipeline spec to create an pipeline entity. pipelineSpec struct { - Kind string `json:"kind" jsonschema:"omitempty"` - Name string `json:"name" jsonschema:"omitempty"` + Kind string `json:"kind,omitempty"` + Name string `json:"name,omitempty"` *pipeline.Spec `json:",inline"` } ) diff --git a/pkg/object/grpcserver/spec.go b/pkg/object/grpcserver/spec.go index 0dfcf8c09d..e3e832e625 100644 --- a/pkg/object/grpcserver/spec.go +++ b/pkg/object/grpcserver/spec.go @@ -28,28 +28,28 @@ type ( // Spec describe gRPC server Spec struct { Port uint16 `json:"port" jsonschema:"required,minimum=1025"` - MaxConnections uint32 `json:"maxConnections" jsonschema:"omitempty,minimum=1"` + MaxConnections uint32 `json:"maxConnections,omitempty" jsonschema:"minimum=1"` // MinTime see keepalive.EnforcementPolicy - MinTime string `json:"minTimeClientSendPing" jsonschema:"omitempty,format=duration"` + MinTime string `json:"minTimeClientSendPing,omitempty" jsonschema:"format=duration"` // PermitWithoutStream see keepalive.EnforcementPolicy, false by default. - PermitWithoutStream bool `json:"permitClintSendPingWithoutStream" jsonschema:"omitempty,format=duration"` + PermitWithoutStream bool `json:"permitClintSendPingWithoutStream,omitempty" jsonschema:"format=duration"` // MaxConnectionIdle see keepalive.ServerParameters - MaxConnectionIdle string `json:"maxConnectionIdle" jsonschema:"omitempty,format=duration"` + MaxConnectionIdle string `json:"maxConnectionIdle,omitempty" jsonschema:"format=duration"` // MaxConnectionAge see keepalive.ServerParameters - MaxConnectionAge string `json:"maxConnectionAge" jsonschema:"omitempty,format=duration"` + MaxConnectionAge string `json:"maxConnectionAge,omitempty" jsonschema:"format=duration"` // MaxConnectionAgeGrace see keepalive.ServerParameters - MaxConnectionAgeGrace string `json:"maxConnectionAgeGrace" jsonschema:"omitempty,format=duration"` + MaxConnectionAgeGrace string `json:"maxConnectionAgeGrace,omitempty" jsonschema:"format=duration"` // Time see keepalive.ServerParameters - Time string `json:"keepaliveTime" jsonschema:"omitempty,format=duration"` + Time string `json:"keepaliveTime,omitempty" jsonschema:"format=duration"` // Timeout see keepalive.ServerParameters - Timeout string `json:"keepaliveTimeout" jsonschema:"omitempty,format=duration"` - IPFilter *ipfilter.Spec `json:"ipFilter,omitempty" jsonschema:"omitempty"` - Rules []*Rule `json:"rules" jsonschema:"omitempty"` - CacheSize uint32 `json:"cacheSize" jsonschema:"omitempty"` - GlobalFilter string `json:"globalFilter,omitempty" jsonschema:"omitempty"` - XForwardedFor bool `json:"xForwardedFor" jsonschema:"omitempty"` + Timeout string `json:"keepaliveTimeout,omitempty" jsonschema:"format=duration"` + IPFilter *ipfilter.Spec `json:"ipFilter,omitempty"` + Rules []*Rule `json:"rules,omitempty"` + CacheSize uint32 `json:"cacheSize,omitempty"` + GlobalFilter string `json:"globalFilter,omitempty"` + XForwardedFor bool `json:"xForwardedFor,omitempty"` } // Rule is first level entry of router. @@ -61,21 +61,21 @@ type ( // Reference: https://github.com/alecthomas/jsonschema/issues/30 // In the future if we have the scenario where we need marshal the field, but omitempty // in the schema, we are suppose to support multiple types on our own. - IPFilter *ipfilter.Spec `json:"ipFilter,omitempty" jsonschema:"omitempty"` - Host string `json:"host" jsonschema:"omitempty"` - HostRegexp string `json:"hostRegexp" jsonschema:"omitempty,format=regexp"` - Methods []*Method `json:"methods" jsonschema:"omitempty"` + IPFilter *ipfilter.Spec `json:"ipFilter,omitempty"` + Host string `json:"host,omitempty"` + HostRegexp string `json:"hostRegexp,omitempty" jsonschema:"format=regexp"` + Methods []*Method `json:"methods,omitempty"` } // Method is second level entry of router. Method struct { - IPFilter *ipfilter.Spec `json:"ipFilter,omitempty" jsonschema:"omitempty"` - Method string `json:"method,omitempty" jsonschema:"omitempty,pattern=^/"` - MethodPrefix string `json:"methodPrefix,omitempty" jsonschema:"omitempty,pattern=^/"` - MethodRegexp string `json:"methodRegexp,omitempty" jsonschema:"omitempty,format=regexp"` + IPFilter *ipfilter.Spec `json:"ipFilter,omitempty"` + Method string `json:"method,omitempty" jsonschema:"pattern=^/"` + MethodPrefix string `json:"methodPrefix,omitempty" jsonschema:"pattern=^/"` + MethodRegexp string `json:"methodRegexp,omitempty" jsonschema:"format=regexp"` Backend string `json:"backend" jsonschema:"required"` - Headers []*Header `json:"headers" jsonschema:"omitempty"` - MatchAllHeader bool `json:"matchAllHeader" jsonschema:"omitempty"` + Headers []*Header `json:"headers,omitempty"` + MatchAllHeader bool `json:"matchAllHeader,omitempty"` } // Header is the third level entry of router. A header entry is always under a specific path entry, that is to mean @@ -83,8 +83,8 @@ type ( // than the path entry itself. Header struct { Key string `json:"key" jsonschema:"required"` - Values []string `json:"values,omitempty" jsonschema:"omitempty,uniqueItems=true"` - Regexp string `json:"regexp,omitempty" jsonschema:"omitempty,format=regexp"` + Values []string `json:"values,omitempty" jsonschema:"uniqueItems=true"` + Regexp string `json:"regexp,omitempty" jsonschema:"format=regexp"` headerRE *regexp.Regexp } diff --git a/pkg/object/httpserver/routers/spec.go b/pkg/object/httpserver/routers/spec.go index 0156b4d93e..222010ef87 100644 --- a/pkg/object/httpserver/routers/spec.go +++ b/pkg/object/httpserver/routers/spec.go @@ -37,7 +37,7 @@ type Paths []*Path // Host defines the host match rule. type Host struct { - IsRegexp bool `json:"isRegexp" jsonschema:"omitempty"` + IsRegexp bool `json:"isRegexp,omitempty"` Value string `json:"value" jsonschema:"required"` prefix string `json:"-"` suffix string `json:"-"` @@ -53,29 +53,29 @@ type Rule struct { // Reference: https://github.com/alecthomas/jsonschema/issues/30 // In the future if we have the scenario where we need marshal the field, but omitempty // in the schema, we are suppose to support multiple types on our own. - IPFilterSpec *ipfilter.Spec `json:"ipFilter,omitempty" jsonschema:"omitempty"` - Host string `json:"host" jsonschema:"omitempty"` - HostRegexp string `json:"hostRegexp" jsonschema:"omitempty,format=regexp"` - Hosts []Host `json:"hosts" jsonschema:"omitempty"` - Paths Paths `json:"paths" jsonschema:"omitempty"` + IPFilterSpec *ipfilter.Spec `json:"ipFilter,omitempty"` + Host string `json:"host,omitempty"` + HostRegexp string `json:"hostRegexp,omitempty" jsonschema:"format=regexp"` + Hosts []Host `json:"hosts,omitempty"` + Paths Paths `json:"paths,omitempty"` ipFilter *ipfilter.IPFilter } // Path is second level entry of router. type Path struct { - IPFilterSpec *ipfilter.Spec `json:"ipFilter,omitempty" jsonschema:"omitempty"` - Path string `json:"path,omitempty" jsonschema:"omitempty,pattern=^/"` - PathPrefix string `json:"pathPrefix,omitempty" jsonschema:"omitempty,pattern=^/"` - PathRegexp string `json:"pathRegexp,omitempty" jsonschema:"omitempty,format=regexp"` - RewriteTarget string `json:"rewriteTarget" jsonschema:"omitempty"` - Methods []string `json:"methods,omitempty" jsonschema:"omitempty,uniqueItems=true,format=httpmethod-array"` + IPFilterSpec *ipfilter.Spec `json:"ipFilter,omitempty"` + Path string `json:"path,omitempty" jsonschema:"pattern=^/"` + PathPrefix string `json:"pathPrefix,omitempty" jsonschema:"pattern=^/"` + PathRegexp string `json:"pathRegexp,omitempty" jsonschema:"format=regexp"` + RewriteTarget string `json:"rewriteTarget,omitempty"` + Methods []string `json:"methods,omitempty" jsonschema:"uniqueItems=true,format=httpmethod-array"` Backend string `json:"backend" jsonschema:"required"` - ClientMaxBodySize int64 `json:"clientMaxBodySize" jsonschema:"omitempty"` - Headers Headers `json:"headers" jsonschema:"omitempty"` - Queries Queries `json:"queries,omitempty" jsonschema:"omitempty"` - MatchAllHeader bool `json:"matchAllHeader" jsonschema:"omitempty"` - MatchAllQuery bool `json:"matchAllQuery" jsonschema:"omitempty"` + ClientMaxBodySize int64 `json:"clientMaxBodySize,omitempty"` + Headers Headers `json:"headers,omitempty"` + Queries Queries `json:"queries,omitempty"` + MatchAllHeader bool `json:"matchAllHeader,omitempty"` + MatchAllQuery bool `json:"matchAllQuery,omitempty"` ipFilter *ipfilter.IPFilter method MethodType @@ -93,8 +93,8 @@ type Queries []*Query // than the path entry itself. type Header struct { Key string `json:"key" jsonschema:"required"` - Values []string `json:"values,omitempty" jsonschema:"omitempty,uniqueItems=true"` - Regexp string `json:"regexp,omitempty" jsonschema:"omitempty,format=regexp"` + Values []string `json:"values,omitempty" jsonschema:"uniqueItems=true"` + Regexp string `json:"regexp,omitempty" jsonschema:"format=regexp"` re *regexp.Regexp } @@ -102,8 +102,8 @@ type Header struct { // Query is the third level entry. type Query struct { Key string `json:"key" jsonschema:"required"` - Values []string `json:"values,omitempty" jsonschema:"omitempty,uniqueItems=true"` - Regexp string `json:"regexp,omitempty" jsonschema:"omitempty,format=regexp"` + Values []string `json:"values,omitempty" jsonschema:"uniqueItems=true"` + Regexp string `json:"regexp,omitempty" jsonschema:"format=regexp"` re *regexp.Regexp } diff --git a/pkg/object/httpserver/spec.go b/pkg/object/httpserver/spec.go index c79c6ce79b..03d11635ce 100644 --- a/pkg/object/httpserver/spec.go +++ b/pkg/object/httpserver/spec.go @@ -32,38 +32,38 @@ import ( type ( // Spec describes the HTTPServer. Spec struct { - HTTP3 bool `json:"http3" jsonschema:"omitempty"` + HTTP3 bool `json:"http3,omitempty"` KeepAlive bool `json:"keepAlive" jsonschema:"required"` HTTPS bool `json:"https" jsonschema:"required"` - AutoCert bool `json:"autoCert" jsonschema:"omitempty"` - XForwardedFor bool `json:"xForwardedFor" jsonschema:"omitempty"` - Address string `json:"address" jsonschema:"omitempty"` + AutoCert bool `json:"autoCert,omitempty"` + XForwardedFor bool `json:"xForwardedFor,omitempty"` + Address string `json:"address,omitempty"` Port uint16 `json:"port" jsonschema:"required,minimum=1"` - ClientMaxBodySize int64 `json:"clientMaxBodySize" jsonschema:"omitempty"` - KeepAliveTimeout string `json:"keepAliveTimeout" jsonschema:"omitempty,format=duration"` - MaxConnections uint32 `json:"maxConnections" jsonschema:"omitempty,minimum=1"` - CacheSize uint32 `json:"cacheSize" jsonschema:"omitempty"` - Tracing *tracing.Spec `json:"tracing,omitempty" jsonschema:"omitempty"` - CaCertBase64 string `json:"caCertBase64" jsonschema:"omitempty,format=base64"` + ClientMaxBodySize int64 `json:"clientMaxBodySize,omitempty"` + KeepAliveTimeout string `json:"keepAliveTimeout,omitempty" jsonschema:"format=duration"` + MaxConnections uint32 `json:"maxConnections,omitempty" jsonschema:"minimum=1"` + CacheSize uint32 `json:"cacheSize,omitempty"` + Tracing *tracing.Spec `json:"tracing,omitempty"` + CaCertBase64 string `json:"caCertBase64,omitempty" jsonschema:"format=base64"` // Support multiple certs, preserve the certbase64 and keybase64 // for backward compatibility - CertBase64 string `json:"certBase64" jsonschema:"omitempty,format=base64"` - KeyBase64 string `json:"keyBase64" jsonschema:"omitempty,format=base64"` + CertBase64 string `json:"certBase64,omitempty" jsonschema:"format=base64"` + KeyBase64 string `json:"keyBase64,omitempty" jsonschema:"format=base64"` // Certs saved as map, key is domain name, value is cert - Certs map[string]string `json:"certs" jsonschema:"omitempty"` + Certs map[string]string `json:"certs,omitempty"` // Keys saved as map, key is domain name, value is secret - Keys map[string]string `json:"keys" jsonschema:"omitempty"` + Keys map[string]string `json:"keys,omitempty"` - RouterKind string `json:"routerKind,omitempty" jsonschema:"omitempty,enum=,enum=Ordered,enum=RadixTree"` + RouterKind string `json:"routerKind,omitempty" jsonschema:"enum=,enum=Ordered,enum=RadixTree"` - IPFilter *ipfilter.Spec `json:"ipFilter,omitempty" jsonschema:"omitempty"` - Rules routers.Rules `json:"rules" jsonschema:"omitempty"` + IPFilter *ipfilter.Spec `json:"ipFilter,omitempty"` + Rules routers.Rules `json:"rules,omitempty"` - GlobalFilter string `json:"globalFilter,omitempty" jsonschema:"omitempty"` + GlobalFilter string `json:"globalFilter,omitempty"` - AccessLogFormat string `json:"accessLogFormat" jsonshema:"omitempty"` + AccessLogFormat string `json:"accessLogFormat,omitempty" jsonshema:"omitempty"` } ) diff --git a/pkg/object/ingresscontroller/ingresscontroller.go b/pkg/object/ingresscontroller/ingresscontroller.go index 14518099f2..993cd75cd7 100644 --- a/pkg/object/ingresscontroller/ingresscontroller.go +++ b/pkg/object/ingresscontroller/ingresscontroller.go @@ -69,10 +69,10 @@ type ( // Spec is the ingress controller spec Spec struct { HTTPServer *httpserver.Spec `json:"httpServer" jsonschema:"required"` - KubeConfig string `json:"kubeConfig" jsonschema:"omitempty"` - MasterURL string `json:"masterURL" jsonschema:"omitempty"` - Namespaces []string `json:"namespaces" jsonschema:"omitempty"` - IngressClass string `json:"ingressClass" jsonschema:"omitempty"` + KubeConfig string `json:"kubeConfig,omitempty"` + MasterURL string `json:"masterURL,omitempty"` + Namespaces []string `json:"namespaces,omitempty"` + IngressClass string `json:"ingressClass,omitempty"` } ) diff --git a/pkg/object/meshcontroller/spec/spec.go b/pkg/object/meshcontroller/spec/spec.go index dad53e2940..cace758565 100644 --- a/pkg/object/meshcontroller/spec/spec.go +++ b/pkg/object/meshcontroller/spec/spec.go @@ -117,39 +117,39 @@ type ( // IngressPort is the port for http server in mesh ingress IngressPort int `json:"ingressPort" jsonschema:"required"` - ExternalServiceRegistry string `json:"externalServiceRegistry" jsonschema:"omitempty"` + ExternalServiceRegistry string `json:"externalServiceRegistry,omitempty"` - CleanExternalRegistry bool `json:"cleanExternalRegistry"` + CleanExternalRegistry bool `json:"cleanExternalRegistry,omitempty"` - Security *Security `json:"security,omitempty" jsonschema:"omitempty"` + Security *Security `json:"security,omitempty"` // Sidecar injection relevant config. - ImageRegistryURL string `json:"imageRegistryURL" jsonschema:"omitempty"` - ImagePullPolicy string `json:"imagePullPolicy" jsonschema:"omitempty"` - SidecarImageName string `json:"sidecarImageName" jsonschema:"omitempty"` - AgentInitializerImageName string `json:"agentInitializerImageName" jsonschema:"omitempty"` - Log4jConfigName string `json:"log4jConfigName" jsonschema:"omitempty"` + ImageRegistryURL string `json:"imageRegistryURL,omitempty"` + ImagePullPolicy string `json:"imagePullPolicy,omitempty"` + SidecarImageName string `json:"sidecarImageName,omitempty"` + AgentInitializerImageName string `json:"agentInitializerImageName,omitempty"` + Log4jConfigName string `json:"log4jConfigName,omitempty"` - MonitorMTLS *MonitorMTLS `json:"monitorMTLS,omitempty" jsonschema:"omitempty"` - WorkerSpec WorkerSpec `json:"workerSpec" jsonschema:"omitempty"` + MonitorMTLS *MonitorMTLS `json:"monitorMTLS,omitempty"` + WorkerSpec WorkerSpec `json:"workerSpec,omitempty"` } // WorkerSpec is the spec of worker WorkerSpec struct { - Ingress IngressServerSpec `json:"ingress" jsonschema:"omitempty"` - Egress EgressServerSpec `json:"egress" jsonschema:"omitempty"` + Ingress IngressServerSpec `json:"ingress,omitempty"` + Egress EgressServerSpec `json:"egress,omitempty"` } // IngressServerSpec is the spec of ingress httpserver in worker IngressServerSpec struct { - KeepAlive bool `json:"keepAlive" jsonschema:"omitempty"` - KeepAliveTimeout string `json:"keepAliveTimeout" jsonschema:"omitempty,format=duration"` + KeepAlive bool `json:"keepAlive,omitempty"` + KeepAliveTimeout string `json:"keepAliveTimeout,omitempty" jsonschema:"format=duration"` } // EgressServerSpec is the spec of egress httpserver in worker EgressServerSpec struct { - KeepAlive bool `json:"keepAlive" jsonschema:"omitempty"` - KeepAliveTimeout string `json:"keepAliveTimeout" jsonschema:"omitempty,format=duration"` + KeepAlive bool `json:"keepAlive,omitempty"` + KeepAliveTimeout string `json:"keepAliveTimeout,omitempty" jsonschema:"format=duration"` } // MonitorMTLS is the spec of mTLS specification of monitor. @@ -159,7 +159,7 @@ type ( Username string `json:"username" jsonschema:"required"` Password string `json:"password" jsonschema:"required"` - ReporterAppendType string `json:"reporterAppendType"` + ReporterAppendType string `json:"reporterAppendType,omitempty"` CaCertBase64 string `json:"caCertBase64" jsonschema:"required,format=base64"` Certs []*MonitorCert `json:"certs" jsonschema:"required"` } @@ -183,15 +183,15 @@ type ( // Service contains the information of service. Service struct { // Empty means mesh registry itself. - RegistryName string `json:"registryName" jsonschema:"omitempty"` + RegistryName string `json:"registryName,omitempty"` Name string `json:"name" jsonschema:"required"` RegisterTenant string `json:"registerTenant" jsonschema:"required"` Sidecar *Sidecar `json:"sidecar" jsonschema:"required"` - Mock *Mock `json:"mock,omitempty" jsonschema:"omitempty"` - Resilience *Resilience `json:"resilience,omitempty" jsonschema:"omitempty"` - LoadBalance *LoadBalance `json:"loadBalance,omitempty" jsonschema:"omitempty"` - Observability *Observability `json:"observability,omitempty" jsonschema:"omitempty"` + Mock *Mock `json:"mock,omitempty"` + Resilience *Resilience `json:"resilience,omitempty"` + LoadBalance *LoadBalance `json:"loadBalance,omitempty"` + Observability *Observability `json:"observability,omitempty"` } // ServiceDeployment contains the information of service deployment. @@ -200,10 +200,10 @@ type ( App interface{} `json:"app" jsonschema:"required"` // All specs of ConfigMaps in volumes of the spec. - ConfigMaps []*v1.ConfigMap `json:"configMaps" jsonschema:"omitempty"` + ConfigMaps []*v1.ConfigMap `json:"configMaps,omitempty"` // All specs of Secrets in volumes of the spec. - Secrets []*v1.Secret `json:"secrets" jsonschema:"omitempty"` + Secrets []*v1.Secret `json:"secrets,omitempty"` } // Mock is the spec of configured and static API responses for this service. @@ -212,16 +212,16 @@ type ( Enabled bool `json:"enabled" jsonschema:"required"` // Rules are the mocking matching and responding configurations. - Rules []*mock.Rule `json:"rules" jsonschema:"omitempty"` + Rules []*mock.Rule `json:"rules,omitempty"` } // Resilience is the spec of service resilience. Resilience struct { - RateLimiter *ratelimiter.Rule `json:"rateLimiter,omitempty" jsonschema:"omitempty"` - CircuitBreaker *resilience.CircuitBreakerRule `json:"circuitBreaker,omitempty" jsonschema:"omitempty"` - Retry *resilience.RetryRule `json:"retry,omitempty" jsonschema:"omitempty"` - TimeLimiter *TimeLimiterRule `json:"timeLimiter,omitempty" jsonschema:"omitempty"` - FailureCodes []int `json:"failureCodes,omitempty" jsonschema:"omitempty,uniqueItems=true"` + RateLimiter *ratelimiter.Rule `json:"rateLimiter,omitempty"` + CircuitBreaker *resilience.CircuitBreakerRule `json:"circuitBreaker,omitempty"` + Retry *resilience.RetryRule `json:"retry,omitempty"` + TimeLimiter *TimeLimiterRule `json:"timeLimiter,omitempty"` + FailureCodes []int `json:"failureCodes,omitempty" jsonschema:"uniqueItems=true"` } // TimeLimiterRule is the spec of TimeLimiter. @@ -242,7 +242,7 @@ type ( // Priority must be [1, 9], the default is 5 if user does not set it. // The smaller number get higher priority. // The order is sorted by name alphabetically in the same priority. - Priority int `json:"priority" jsonschema:"omitempty"` + Priority int `json:"priority"` Selector *ServiceSelector `json:"selector" jsonschema:"required"` TrafficRules *TrafficRules `json:"trafficRules" jsonschema:"required"` } @@ -267,9 +267,9 @@ type ( // Observability is the spec of service observability. Observability struct { - OutputServer *ObservabilityOutputServer `json:"outputServer,omitempty" jsonschema:"omitempty"` - Tracings *ObservabilityTracings `json:"tracings,omitempty" jsonschema:"omitempty"` - Metrics *ObservabilityMetrics `json:"metrics,omitempty" jsonschema:"omitempty"` + OutputServer *ObservabilityOutputServer `json:"outputServer,omitempty"` + Tracings *ObservabilityTracings `json:"tracings,omitempty"` + Metrics *ObservabilityMetrics `json:"metrics,omitempty"` } // ObservabilityOutputServer is the output server of observability. @@ -335,10 +335,10 @@ type ( Tenant struct { Name string `json:"name"` - Services []string `json:"services,omitempty" jsonschema:"omitempty"` + Services []string `json:"services,omitempty"` // Format: RFC3339 - CreatedAt string `json:"createdAt" jsonschema:"omitempty"` - Description string `json:"description"` + CreatedAt string `json:"createdAt"` + Description string `json:"description,omitempty"` } // Certificate is one cert for mesh service instance or root CA. @@ -363,23 +363,23 @@ type ( InstanceID string `json:"instanceID" jsonschema:"required"` IP string `json:"ip" jsonschema:"required"` Port uint32 `json:"port" jsonschema:"required"` - RegistryTime string `json:"registryTime" jsonschema:"omitempty"` - Labels map[string]string `json:"labels" jsonschema:"omitempty"` + RegistryTime string `json:"registryTime"` + Labels map[string]string `json:"labels"` // Set by heartbeat timer event or API - Status string `json:"status" jsonschema:"omitempty"` + Status string `json:"status"` } // IngressPath is the path for a mesh ingress rule IngressPath struct { Path string `json:"path" jsonschema:"required,pattern=^/"` - RewriteTarget string `json:"rewriteTarget" jsonschema:"omitempty"` + RewriteTarget string `json:"rewriteTarget"` Backend string `json:"backend" jsonschema:"required"` } // IngressRule is the rule for mesh ingress IngressRule struct { - Host string `json:"host" jsonschema:"omitempty"` + Host string `json:"host"` Paths []*IngressPath `json:"paths" jsonschema:"required"` } diff --git a/pkg/object/mqttproxy/mock_test.go b/pkg/object/mqttproxy/mock_test.go index 7d1ed1de8b..3d2b93d7d6 100644 --- a/pkg/object/mqttproxy/mock_test.go +++ b/pkg/object/mqttproxy/mock_test.go @@ -279,9 +279,9 @@ type MockMQTTSpec struct { Password string `json:"password" jsonschema:"required"` Port uint16 `json:"port" jsonschema:"required"` BackendType string `json:"backendType" jsonschema:"required"` - EarlyStop bool `json:"earlyStop" jsonschema:"omitempty"` - KeysToStore []string `json:"keysToStore" jsonschema:"omitempty"` - ConnectKey string `json:"connectKey" jsonschema:"omitempty"` + EarlyStop bool `json:"earlyStop"` + KeysToStore []string `json:"keysToStore"` + ConnectKey string `json:"connectKey"` } // MockMQTTStatus is status of MockMQTTFilter diff --git a/pkg/object/mqttproxy/spec.go b/pkg/object/mqttproxy/spec.go index f370f46648..28466017ad 100644 --- a/pkg/object/mqttproxy/spec.go +++ b/pkg/object/mqttproxy/spec.go @@ -64,27 +64,27 @@ type ( EGName string `json:"-"` Name string `json:"-"` Port uint16 `json:"port" jsonschema:"required"` - UseTLS bool `json:"useTLS" jsonschema:"omitempty"` - Certificate []Certificate `json:"certificate" jsonschema:"omitempty"` - TopicCacheSize int `json:"topicCacheSize" jsonschema:"omitempty"` - MaxAllowedConnection int `json:"maxAllowedConnection" jsonschema:"omitempty"` - ConnectionLimit *RateLimit `json:"connectionLimit" jsonschema:"omitempty"` - ClientPublishLimit *RateLimit `json:"clientPublishLimit" jsonschema:"omitempty"` - Rules []*Rule `json:"rules" jsonschema:"omitempty"` - BrokerMode bool `json:"brokerMode" jsonschema:"omitempty"` + UseTLS bool `json:"useTLS,omitempty"` + Certificate []Certificate `json:"certificate,omitempty"` + TopicCacheSize int `json:"topicCacheSize,omitempty"` + MaxAllowedConnection int `json:"maxAllowedConnection,omitempty"` + ConnectionLimit *RateLimit `json:"connectionLimit,omitempty"` + ClientPublishLimit *RateLimit `json:"clientPublishLimit,omitempty"` + Rules []*Rule `json:"rules,omitempty"` + BrokerMode bool `json:"brokerMode,omitempty"` // unit is second, default is 30s - RetryInterval int `yaml:"retryInterval" jsonschema:"omitempty"` + RetryInterval int `yaml:"retryInterval,omitempty"` } // Rule used to route MQTT packets to different pipelines Rule struct { - When *When `json:"when" jsonschema:"omitempty"` - Pipeline string `json:"pipeline" jsonschema:"omitempty"` + When *When `json:"when,omitempty"` + Pipeline string `json:"pipeline,omitempty"` } // When is used to check if MQTT packet match this pipeline When struct { - PacketType PacketType `json:"packetType" jsonschema:"omitempty"` + PacketType PacketType `json:"packetType,omitempty"` } // RateLimit describes rate limit for connection or publish. @@ -92,9 +92,9 @@ type ( // timePeriod: max allowed bytes in time period // timePeriod: time of seconds to count requestRate and bytesRate, default 1 second RateLimit struct { - RequestRate int `json:"requestRate" jsonschema:"omitempty"` - BytesRate int `json:"bytesRate" jsonschema:"omitempty"` - TimePeriod int `json:"timePeriod" jsonschema:"omitempty"` + RequestRate int `json:"requestRate,omitempty"` + BytesRate int `json:"bytesRate,omitempty"` + TimePeriod int `json:"timePeriod,omitempty"` } // Certificate describes TLS certifications. diff --git a/pkg/object/nacosserviceregistry/nacosserviceregistry.go b/pkg/object/nacosserviceregistry/nacosserviceregistry.go index f2fade88b2..b5b66b5062 100644 --- a/pkg/object/nacosserviceregistry/nacosserviceregistry.go +++ b/pkg/object/nacosserviceregistry/nacosserviceregistry.go @@ -85,17 +85,17 @@ type ( Spec struct { Servers []*ServerSpec `json:"servers" jsonschema:"required"` SyncInterval string `json:"syncInterval" jsonschema:"required,format=duration"` - Namespace string `json:"namespace" jsonschema:"omitempty"` - Username string `json:"username" jsonschema:"omitempty"` - Password string `json:"password" jsonschema:"omitempty"` + Namespace string `json:"namespace,omitempty"` + Username string `json:"username,omitempty"` + Password string `json:"password,omitempty"` } // ServerSpec is the server config of Nacos. ServerSpec struct { - Scheme string `json:"scheme" jsonschema:"omitempty,enum=http,enum=https"` - ContextPath string `json:"contextPath" jsonschema:"omitempty"` - IPAddr string `json:"ipAddr" jsonschema:"required"` - Port uint16 `json:"port" jsonschema:"required"` + Scheme string `json:"scheme,omitempty" jsonschema:"enum=http,enum=https"` + ContextPath string `json:"contextPath,omitempty"` + IPAddr string `json:"ipAddr,omitempty" jsonschema:"required"` + Port uint16 `json:"port,omitempty" jsonschema:"required"` } // Status is the status of NacosServiceRegistry. diff --git a/pkg/object/pipeline/pipeline.go b/pkg/object/pipeline/pipeline.go index bf5b34b902..b689456e59 100644 --- a/pkg/object/pipeline/pipeline.go +++ b/pkg/object/pipeline/pipeline.go @@ -70,18 +70,18 @@ type ( // Spec describes the Pipeline. Spec struct { - Flow []FlowNode `json:"flow" jsonschema:"omitempty"` + Flow []FlowNode `json:"flow"` Filters []map[string]interface{} `json:"filters" jsonschema:"required"` - Resilience []map[string]interface{} `json:"resilience" jsonschema:"omitempty"` - Data map[string]interface{} `json:"data" jsonschema:"omitempty"` + Resilience []map[string]interface{} `json:"resilience"` + Data map[string]interface{} `json:"data"` } // FlowNode describes one node of the pipeline flow. FlowNode struct { FilterName string `json:"filter" jsonschema:"required,format=urlname"` - FilterAlias string `json:"alias" jsonschema:"omitempty"` - Namespace string `json:"namespace" jsonschema:"omitempty"` - JumpIf map[string]string `json:"jumpIf" jsonschema:"omitempty"` + FilterAlias string `json:"alias"` + Namespace string `json:"namespace"` + JumpIf map[string]string `json:"jumpIf"` filter filters.Filter } diff --git a/pkg/protocols/httpprot/httpheader/httpheader.go b/pkg/protocols/httpprot/httpheader/httpheader.go index 755ad10745..72c7b47be5 100644 --- a/pkg/protocols/httpprot/httpheader/httpheader.go +++ b/pkg/protocols/httpprot/httpheader/httpheader.go @@ -31,11 +31,11 @@ type ( // AdaptSpec describes rules for adapting. AdaptSpec struct { - Del []string `json:"del,omitempty" jsonschema:"omitempty,uniqueItems=true"` + Del []string `json:"del,omitempty" jsonschema:"uniqueItems=true"` // NOTE: Set and Add allow empty value. - Set map[string]string `json:"set,omitempty" jsonschema:"omitempty"` - Add map[string]string `json:"add,omitempty" jsonschema:"omitempty"` + Set map[string]string `json:"set,omitempty"` + Add map[string]string `json:"add,omitempty"` } ) diff --git a/pkg/protocols/httpprot/httpheader/validator.go b/pkg/protocols/httpprot/httpheader/validator.go index 82df807d97..201154f561 100644 --- a/pkg/protocols/httpprot/httpheader/validator.go +++ b/pkg/protocols/httpprot/httpheader/validator.go @@ -32,8 +32,8 @@ type ( // ValueValidator is the entity to validate value. ValueValidator struct { // NOTE: It allows empty value. - Values []string `json:"values" jsonschema:"omitempty,uniqueItems=true"` - Regexp string `json:"regexp" jsonschema:"omitempty,format=regexp"` + Values []string `json:"values,omitempty" jsonschema:"uniqueItems=true"` + Regexp string `json:"regexp,omitempty" jsonschema:"format=regexp"` re *regexp.Regexp } diff --git a/pkg/protocols/httpprot/request.go b/pkg/protocols/httpprot/request.go index c014e55a27..480351d1cd 100644 --- a/pkg/protocols/httpprot/request.go +++ b/pkg/protocols/httpprot/request.go @@ -409,17 +409,17 @@ func (r *builderRequest) YAMLBody() (interface{}, error) { // filter, so it is a `YAML in YAML` or `YAML in JSON` case. To make it // explicit, we use both json & yaml tags in its fields. type requestInfo struct { - Method string `json:"method" yaml:"method" jsonschema:"omitempty"` - URL string `json:"url" yaml:"url" jsonschema:"omitempty"` - Headers map[string][]string `json:"headers" yaml:"headers" jsonschema:"omitempty"` - Body string `json:"body" yaml:"body" jsonschema:"omitempty"` - FormData map[string]field `json:"formData" yaml:"formData" jsonschema:"omitempty"` + Method string `json:"method,omitempty"` + URL string `json:"url,omitempty"` + Headers map[string][]string `json:"headers,omitempty"` + Body string `json:"body,omitempty"` + FormData map[string]field `json:"formData,omitempty"` } // field stores the information of a form field. type field struct { - FileName string `json:"fileName" yaml:"fileName" jsonschema:"omitempty"` - Value string `json:"value" yaml:"value" jsonschema:"omitempty"` + FileName string `json:"fileName,omitempty"` + Value string `json:"value,omitempty"` } // NewRequestInfo returns a new requestInfo. diff --git a/pkg/protocols/httpprot/response.go b/pkg/protocols/httpprot/response.go index fb02a9ed01..15245d75ac 100644 --- a/pkg/protocols/httpprot/response.go +++ b/pkg/protocols/httpprot/response.go @@ -335,9 +335,9 @@ func (r *builderResponse) YAMLBody() (interface{}, error) { // responseInfo stores the information of a response. type responseInfo struct { - StatusCode int `json:"statusCode" jsonschema:"omitempty"` - Headers map[string][]string `json:"headers" jsonschema:"omitempty"` - Body string `json:"body" jsonschema:"omitempty"` + StatusCode int `json:"statusCode,omitempty"` + Headers map[string][]string `json:"headers,omitempty"` + Body string `json:"body,omitempty"` } // NewResponseInfo returns a new responseInfo. diff --git a/pkg/resilience/circuitbreaker.go b/pkg/resilience/circuitbreaker.go index e48553cc74..225c2995e5 100644 --- a/pkg/resilience/circuitbreaker.go +++ b/pkg/resilience/circuitbreaker.go @@ -61,15 +61,15 @@ type ( // CircuitBreakerRule is the detailed config of circuit breaker. CircuitBreakerRule struct { - SlidingWindowType string `json:"slidingWindowType" jsonschema:"omitempty,enum=COUNT_BASED,enum=TIME_BASED"` - FailureRateThreshold uint8 `json:"failureRateThreshold" jsonschema:"omitempty,minimum=1,maximum=100"` - SlowCallRateThreshold uint8 `json:"slowCallRateThreshold" jsonschema:"omitempty,minimum=1,maximum=100"` - SlidingWindowSize uint32 `json:"slidingWindowSize" jsonschema:"omitempty,minimum=1"` - PermittedNumberOfCallsInHalfOpen uint32 `json:"permittedNumberOfCallsInHalfOpenState" jsonschema:"omitempty"` - MinimumNumberOfCalls uint32 `json:"minimumNumberOfCalls" jsonschema:"omitempty"` - SlowCallDurationThreshold string `json:"slowCallDurationThreshold" jsonschema:"omitempty,format=duration"` - MaxWaitDurationInHalfOpen string `json:"maxWaitDurationInHalfOpenState" jsonschema:"omitempty,format=duration"` - WaitDurationInOpen string `json:"waitDurationInOpenState" jsonschema:"omitempty,format=duration"` + SlidingWindowType string `json:"slidingWindowType,omitempty" jsonschema:"enum=COUNT_BASED,enum=TIME_BASED"` + FailureRateThreshold uint8 `json:"failureRateThreshold,omitempty" jsonschema:"minimum=1,maximum=100"` + SlowCallRateThreshold uint8 `json:"slowCallRateThreshold,omitempty" jsonschema:"minimum=1,maximum=100"` + SlidingWindowSize uint32 `json:"slidingWindowSize,omitempty" jsonschema:"minimum=1"` + PermittedNumberOfCallsInHalfOpen uint32 `json:"permittedNumberOfCallsInHalfOpenState,omitempty"` + MinimumNumberOfCalls uint32 `json:"minimumNumberOfCalls,omitempty"` + SlowCallDurationThreshold string `json:"slowCallDurationThreshold,omitempty" jsonschema:"format=duration"` + MaxWaitDurationInHalfOpen string `json:"maxWaitDurationInHalfOpenState,omitempty" jsonschema:"format=duration"` + WaitDurationInOpen string `json:"waitDurationInOpenState,omitempty" jsonschema:"format=duration"` } ) diff --git a/pkg/resilience/retry.go b/pkg/resilience/retry.go index fd7a599c8a..35dc11ef8e 100644 --- a/pkg/resilience/retry.go +++ b/pkg/resilience/retry.go @@ -49,11 +49,11 @@ type ( // RetryRule is the detailed config of retry RetryRule struct { - MaxAttempts int `json:"maxAttempts" jsonschema:"omitempty,minimum=1"` - WaitDuration string `json:"waitDuration" jsonschema:"omitempty,format=duration"` + MaxAttempts int `json:"maxAttempts,omitempty" jsonschema:"minimum=1"` + WaitDuration string `json:"waitDuration,omitempty" jsonschema:"format=duration"` waitDuration time.Duration - BackOffPolicy string `json:"backOffPolicy" jsonschema:"omitempty,enum=random,enum=exponential"` - RandomizationFactor float64 `json:"randomizationFactor" jsonschema:"omitempty,minimum=0,maximum=1"` + BackOffPolicy string `json:"backOffPolicy,omitempty" jsonschema:"enum=random,enum=exponential"` + RandomizationFactor float64 `json:"randomizationFactor,omitempty" jsonschema:"minimum=0,maximum=1"` } ) diff --git a/pkg/supervisor/spec.go b/pkg/supervisor/spec.go index 0bed2ae20d..82bf99d927 100644 --- a/pkg/supervisor/spec.go +++ b/pkg/supervisor/spec.go @@ -47,7 +47,7 @@ type ( Version string `json:"version" jsonschema:"required"` // RFC3339 format - CreatedAt string `json:"createdAt,omitempty" jsonschema:"omitempty"` + CreatedAt string `json:"createdAt,omitempty"` } ) diff --git a/pkg/tracing/tracing.go b/pkg/tracing/tracing.go index f33f673e0f..bf62ec2085 100644 --- a/pkg/tracing/tracing.go +++ b/pkg/tracing/tracing.go @@ -45,14 +45,14 @@ type ( // Spec describes Tracer. Spec struct { ServiceName string `json:"serviceName" jsonschema:"required,minLength=1"` - Tags map[string]string `json:"tags" jsonschema:"omitempty"` - Attributes map[string]string `json:"attributes" jsonschema:"omitempty"` - SpanLimits *SpanLimitsSpec `json:"spanLimits" jsonschema:"omitempty"` - SampleRate float64 `json:"sampleRate" jsonschema:"omitempty,minimum=0,maximum=1,default=1"` - BatchLimits *BatchLimitsSpec `json:"batchLimits" jsonschema:"omitempty"` - Exporter *ExporterSpec `json:"exporter" jsonschema:"omitempty"` - Zipkin *ZipkinDeprecatedSpec `json:"zipkin" jsonschema:"omitempty"` - HeaderFormat headerFormat `json:"headerFormat" jsonschema:"omitempty,default=trace-context,enum=trace-context,enum=b3"` + Tags map[string]string `json:"tags,omitempty"` + Attributes map[string]string `json:"attributes,omitempty"` + SpanLimits *SpanLimitsSpec `json:"spanLimits,omitempty"` + SampleRate float64 `json:"sampleRate,omitempty" jsonschema:"minimum=0,maximum=1,default=1"` + BatchLimits *BatchLimitsSpec `json:"batchLimits,omitempty"` + Exporter *ExporterSpec `json:"exporter,omitempty"` + Zipkin *ZipkinDeprecatedSpec `json:"zipkin,omitempty"` + HeaderFormat headerFormat `json:"headerFormat,omitempty" jsonschema:"default=trace-context,enum=trace-context,enum=b3"` } // SpanLimitsSpec represents the limits of a span. @@ -63,7 +63,7 @@ type ( // Any string longer than this value will be truncated to this length. // // Setting this to a negative value means no limit is applied. - AttributeValueLengthLimit int `json:"attributeValueLengthLimit" jsonschema:"default=-1,omitempty"` + AttributeValueLengthLimit int `json:"attributeValueLengthLimit,omitempty" jsonschema:"default=-1"` // AttributeCountLimit is the maximum allowed span attribute count. Any // attribute added to a span once this limit is reached will be dropped. @@ -71,7 +71,7 @@ type ( // Setting this to zero means no attributes will be recorded. // // Setting this to a negative value means no limit is applied. - AttributeCountLimit int `json:"attributeCountLimit" jsonschema:"default=128,omitempty"` + AttributeCountLimit int `json:"attributeCountLimit,omitempty" jsonschema:"default=128"` // EventCountLimit is the maximum allowed span event count. Any event // added to a span once this limit is reached means it will be added but @@ -80,7 +80,7 @@ type ( // Setting this to zero means no events we be recorded. // // Setting this to a negative value means no limit is applied. - EventCountLimit int `json:"eventCountLimit" jsonschema:"default=128,omitempty"` + EventCountLimit int `json:"eventCountLimit,omitempty" jsonschema:"default=128"` // LinkCountLimit is the maximum allowed span link count. Any link added // to a span once this limit is reached means it will be added but the @@ -89,7 +89,7 @@ type ( // Setting this to zero means no links we be recorded. // // Setting this to a negative value means no limit is applied. - LinkCountLimit int `json:"linkCountLimit" jsonschema:"default=128,omitempty"` + LinkCountLimit int `json:"linkCountLimit,omitempty" jsonschema:"default=128"` // AttributePerEventCountLimit is the maximum number of attributes allowed // per span event. Any attribute added after this limit reached will be @@ -98,7 +98,7 @@ type ( // Setting this to zero means no attributes will be recorded for events. // // Setting this to a negative value means no limit is applied. - AttributePerEventCountLimit int `json:"attributePerEventCountLimit" jsonschema:"default=128,omitempty"` + AttributePerEventCountLimit int `json:"attributePerEventCountLimit,omitempty" jsonschema:"default=128"` // AttributePerLinkCountLimit is the maximum number of attributes allowed // per span link. Any attribute added after this limit reached will be @@ -107,7 +107,7 @@ type ( // Setting this to zero means no attributes will be recorded for links. // // Setting this to a negative value means no limit is applied. - AttributePerLinkCountLimit int `json:"attributePerLinkCountLimit" jsonschema:"default=128,omitempty"` + AttributePerLinkCountLimit int `json:"attributePerLinkCountLimit,omitempty" jsonschema:"default=128"` } // BatchLimitsSpec describes BatchSpanProcessorOptions. @@ -115,30 +115,30 @@ type ( // MaxQueueSize is the maximum queue size to buffer spans for delayed processing. If the // queue gets full it drops the spans. Use BlockOnQueueFull to change this behavior. // The default value of MaxQueueSize is 2048. - MaxQueueSize int `json:"maxQueueSize" jsonschema:"default=2048,omitempty"` + MaxQueueSize int `json:"maxQueueSize,omitempty" jsonschema:"default=2048"` // BatchTimeout is the maximum duration for constructing a batch. Processor // forcefully sends available spans when timeout is reached. // The default value of BatchTimeout is 5000 msec. - BatchTimeout int64 `json:"batchTimeout" jsonschema:"default=5000,omitempty"` + BatchTimeout int64 `json:"batchTimeout,omitempty" jsonschema:"default=5000"` // ExportTimeout specifies the maximum duration for exporting spans. If the timeout // is reached, the export will be cancelled. // The default value of ExportTimeout is 30000 msec. - ExportTimeout int64 `json:"exportTimeout" jsonschema:"default=30000,omitempty"` + ExportTimeout int64 `json:"exportTimeout,omitempty" jsonschema:"default=30000"` // MaxExportBatchSize is the maximum number of spans to process in a single batch. // If there are more than one batch worth of spans then it processes multiple batches // of spans one batch after the other without any delay. // The default value of MaxExportBatchSize is 512. - MaxExportBatchSize int `json:"maxExportBatchSize" jsonschema:"default=512,omitempty"` + MaxExportBatchSize int `json:"maxExportBatchSize,omitempty" jsonschema:"default=512"` } // ExporterSpec describes exporter. ExporterSpec struct { - Jaeger *JaegerSpec `json:"jaeger" jsonschema:"omitempty"` - Zipkin *ZipkinSpec `json:"zipkin" jsonschema:"omitempty"` - OTLP *OTLPSpec `json:"otlp" jsonschema:"omitempty"` + Jaeger *JaegerSpec `json:"jaeger,omitempty"` + Zipkin *ZipkinSpec `json:"zipkin,omitempty"` + OTLP *OTLPSpec `json:"otlp,omitempty"` } jaegerMode string @@ -146,9 +146,9 @@ type ( // JaegerSpec describes Jaeger. JaegerSpec struct { Mode jaegerMode `json:"mode" jsonschema:"required,enum=agent,enum=collector"` - Endpoint string `json:"endpoint" jsonschema:"omitempty"` - Username string `json:"username" jsonschema:"omitempty"` - Password string `json:"password" jsonschema:"omitempty"` + Endpoint string `json:"endpoint,omitempty"` + Username string `json:"username,omitempty"` + Password string `json:"password,omitempty"` } // ZipkinSpec describes Zipkin. @@ -161,20 +161,20 @@ type ( OTLPSpec struct { Protocol otlpProtocol `json:"protocol" jsonschema:"required,,enum=http,enum=grpc"` Endpoint string `json:"endpoint" jsonschema:"required"` - Insecure bool `json:"insecure" jsonschema:"omitempty"` - Compression string `json:"compression" jsonschema:"omitempty,enum=,enum=gzip"` + Insecure bool `json:"insecure,omitempty"` + Compression string `json:"compression,omitempty" jsonschema:"enum=,enum=gzip"` } // ZipkinDeprecatedSpec describes Zipkin. // Deprecated: This option will be kept until the next major version // incremented release. ZipkinDeprecatedSpec struct { - Hostport string `json:"hostport" jsonschema:"omitempty"` + Hostport string `json:"hostport,omitempty"` ServerURL string `json:"serverURL" jsonschema:"required,format=url"` - DisableReport bool `json:"disableReport" jsonschema:"omitempty"` + DisableReport bool `json:"disableReport,omitempty"` SampleRate float64 `json:"sampleRate" jsonschema:"required,minimum=0,maximum=1"` - SameSpan bool `json:"sameSpan" jsonschema:"omitempty"` - ID128Bit bool `json:"id128Bit" jsonschema:"omitempty"` + SameSpan bool `json:"sameSpan,omitempty"` + ID128Bit bool `json:"id128Bit,omitempty"` } // Tracer is the tracer. diff --git a/pkg/util/ipfilter/ipfilter.go b/pkg/util/ipfilter/ipfilter.go index 4032221463..ac14190719 100644 --- a/pkg/util/ipfilter/ipfilter.go +++ b/pkg/util/ipfilter/ipfilter.go @@ -35,10 +35,10 @@ var ( type ( // Spec describes IPFilter. Spec struct { - BlockByDefault bool `json:"blockByDefault" jsonschema:"omitempty"` + BlockByDefault bool `json:"blockByDefault,omitempty"` - AllowIPs []string `json:"allowIPs" jsonschema:"omitempty,uniqueItems=true,format=ipcidr-array"` - BlockIPs []string `json:"blockIPs" jsonschema:"omitempty,uniqueItems=true,format=ipcidr-array"` + AllowIPs []string `json:"allowIP,omitemptys" jsonschema:"uniqueItems=true,format=ipcidr-array"` + BlockIPs []string `json:"blockIPs,omitempty" jsonschema:"uniqueItems=true,format=ipcidr-array"` } // IPFilter is the IP filter. diff --git a/pkg/util/pathadaptor/pathadaptor.go b/pkg/util/pathadaptor/pathadaptor.go index 12827eb256..862be13f61 100644 --- a/pkg/util/pathadaptor/pathadaptor.go +++ b/pkg/util/pathadaptor/pathadaptor.go @@ -28,10 +28,10 @@ import ( type ( // Spec describes rules for PathAdaptor. Spec struct { - Replace string `json:"replace,omitempty" jsonschema:"omitempty"` - AddPrefix string `json:"addPrefix,omitempty" jsonschema:"omitempty,pattern=^/"` - TrimPrefix string `json:"trimPrefix,omitempty" jsonschema:"omitempty,pattern=^/"` - RegexpReplace *RegexpReplace `json:"regexpReplace,omitempty" jsonschema:"omitempty"` + Replace string `json:"replace,omitempty"` + AddPrefix string `json:"addPrefix,omitempty" jsonschema:"pattern=^/"` + TrimPrefix string `json:"trimPrefix,omitempty" jsonschema:"pattern=^/"` + RegexpReplace *RegexpReplace `json:"regexpReplace,omitempty"` } // RegexpReplace use regexp-replace pair to rewrite path. diff --git a/pkg/util/signer/signer.go b/pkg/util/signer/signer.go index 360ffd0a6f..3ab30670de 100644 --- a/pkg/util/signer/signer.go +++ b/pkg/util/signer/signer.go @@ -86,7 +86,7 @@ type ( // SigningKeyPrefix is prepend to access key secret when derive the signing key // Default: ME - SigningKeyPrefix string `json:"signingKeyPrefix" jsonschema:"omitempty"` + SigningKeyPrefix string `json:"signingKeyPrefix,omitempty"` } // HeaderHoisting defines which headers are allowed to be moved from header to query @@ -94,9 +94,9 @@ type ( // disallowed prefixes and doesn't match any of disallowed names are allowed to be // hoisted HeaderHoisting struct { - AllowedPrefix []string `json:"allowedPrefix" jsonschema:"omitempty,uniqueItems=true"` - DisallowedPrefix []string `json:"disallowedPrefix" jsonschema:"omitempty,uniqueItems=true"` - Disallowed []string `json:"disallowed" jsonschema:"omitempty,uniqueItems=true"` + AllowedPrefix []string `json:"allowedPrefix,omitempty" jsonschema:"uniqueItems=true"` + DisallowedPrefix []string `json:"disallowedPrefix,omitempty" jsonschema:"uniqueItems=true"` + Disallowed []string `json:"disallowed,omitempty" jsonschema:"uniqueItems=true"` disallowed map[string]bool } diff --git a/pkg/util/signer/spec.go b/pkg/util/signer/spec.go index 3553f18c6e..6399230ecb 100644 --- a/pkg/util/signer/spec.go +++ b/pkg/util/signer/spec.go @@ -21,14 +21,14 @@ import "time" // Spec defines the configuration of a Signer type Spec struct { - Literal *Literal `json:"literal,omitempty" jsonschema:"omitempty"` - HeaderHoisting *HeaderHoisting `json:"headerHoisting,omitempty" jsonschema:"omitempty"` - IgnoredHeaders []string `json:"ignoredHeaders" jsonschema:"omitempty,uniqueItems=true"` - ExcludeBody bool `json:"excludeBody" jsonschema:"omitempty"` - TTL string `json:"ttl" jsonschema:"omitempty,format=duration"` - AccessKeyID string `json:"accessKeyId" jsonschema:"omitempty"` - AccessKeySecret string `json:"accessKeySecret" jsonschema:"omitempty"` - AccessKeys map[string]string `json:"accessKeys" jsonschema:"omitempty"` + Literal *Literal `json:"literal,omitempty"` + HeaderHoisting *HeaderHoisting `json:"headerHoisting,omitempty"` + IgnoredHeaders []string `json:"ignoredHeaders,omitempty" jsonschema:"uniqueItems=true"` + ExcludeBody bool `json:"excludeBody,omitempty"` + TTL string `json:"ttl,omitempty" jsonschema:"format=duration"` + AccessKeyID string `json:"accessKeyId,omitempty"` + AccessKeySecret string `json:"accessKeySecret,omitempty"` + AccessKeys map[string]string `json:"accessKeys,omitempty"` // TODO: AccessKeys is used as an internal access key store, but an external store is also needed } diff --git a/pkg/util/stringtool/stringtool.go b/pkg/util/stringtool/stringtool.go index e0ec90b332..6fddb6943a 100644 --- a/pkg/util/stringtool/stringtool.go +++ b/pkg/util/stringtool/stringtool.go @@ -97,10 +97,10 @@ func IsAnyEmpty(strs ...string) bool { // StringMatcher defines the match rule of a string type StringMatcher struct { - Exact string `json:"exact" jsonschema:"omitempty"` - Prefix string `json:"prefix" jsonschema:"omitempty"` - RegEx string `json:"regex" jsonschema:"omitempty,format=regexp"` - Empty bool `json:"empty" jsonschema:"omitempty"` + Exact string `json:"exact,omitempty"` + Prefix string `json:"prefix,omitempty"` + RegEx string `json:"regex,omitempty" jsonschema:"format=regexp"` + Empty bool `json:"empty,omitempty"` re *regexp.Regexp } diff --git a/pkg/util/urlrule/urlrule.go b/pkg/util/urlrule/urlrule.go index e5f40ceecd..5417d386c5 100644 --- a/pkg/util/urlrule/urlrule.go +++ b/pkg/util/urlrule/urlrule.go @@ -28,9 +28,9 @@ type ( // URLRule defines the match rule of a http request URLRule struct { id string - Methods []string `json:"methods" jsonschema:"omitempty,uniqueItems=true,format=httpmethod-array"` + Methods []string `json:"methods,omitempty" jsonschema:"uniqueItems=true,format=httpmethod-array"` URL stringtool.StringMatcher `json:"url" jsonschema:"required"` - PolicyRef string `json:"policyRef" jsonschema:"omitempty"` + PolicyRef string `json:"policyRef,omitempty"` } ) diff --git a/pkg/v/validaterecorder_test.go b/pkg/v/validaterecorder_test.go index 5223c3f0d3..d09bf07cdd 100644 --- a/pkg/v/validaterecorder_test.go +++ b/pkg/v/validaterecorder_test.go @@ -52,9 +52,9 @@ func TestRequiredFromField(t *testing.T) { assert := assert.New(t) type User struct { - ID int `json:"id" jsonschema:"omitempty"` - Name string `json:"name" jsonschema:"-"` - Addr string `json:"address" jsonschema:"required"` + ID int `json:"id,omitempty"` + Name string `json:"name,omitempty" jsonschema:"-"` + Addr string `json:"address,omitempty" jsonschema:"required"` } u := User{ @@ -79,10 +79,10 @@ func TestValidateRecorder(t *testing.T) { assert := assert.New(t) type TestStruct struct { - ID int `json:"id" jsonschema:"omitempty"` + ID int `json:"id"` Name string `json:"name" jsonschema:"-"` Addr string `json:"address" jsonschema:"required"` - Method string `json:"method" jsonschema:"omitempty,format=httpmethod"` + Method string `json:"method" jsonschema:"format=httpmethod"` } u := TestStruct{ From 9361200db8e7c9c4580a513fa3174513d85b46cc Mon Sep 17 00:00:00 2001 From: Yun Long Date: Mon, 13 Nov 2023 23:50:46 +0800 Subject: [PATCH 2/6] Use active json schema vendor --- go.mod | 6 ++++-- go.sum | 14 ++++++++------ pkg/object/pipeline/pipeline.go | 12 ++++++------ pkg/supervisor/spec.go | 2 +- pkg/v/v.go | 21 +++++++++++---------- pkg/v/validaterecorder.go | 32 ++++++++++++-------------------- pkg/v/validaterecorder_test.go | 6 +++--- 7 files changed, 45 insertions(+), 48 deletions(-) diff --git a/go.mod b/go.mod index 400bf03690..31332fd426 100644 --- a/go.mod +++ b/go.mod @@ -22,6 +22,7 @@ require ( github.com/google/uuid v1.4.0 github.com/hashicorp/consul/api v1.26.1 github.com/hashicorp/golang-lru v1.0.2 + github.com/invopop/jsonschema v0.12.0 github.com/invopop/yaml v0.2.0 github.com/jtblin/go-ldap-client v0.0.0-20170223121919-b73f66626b33 github.com/libdns/alidns v1.0.3 @@ -36,7 +37,6 @@ require ( github.com/libdns/vultr v1.0.0 github.com/megaease/easemesh-api v1.4.4 github.com/megaease/grace v1.0.0 - github.com/megaease/jsonschema v0.5.1 github.com/megaease/yaml v0.0.0-20220804061446-4f18d6510aed github.com/mitchellh/mapstructure v1.5.0 github.com/nacos-group/nacos-sdk-go v1.1.4 @@ -50,6 +50,7 @@ require ( github.com/quic-go/quic-go v0.40.0 github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 github.com/rs/cors v1.10.1 + github.com/santhosh-tekuri/jsonschema/v5 v5.3.1 github.com/spf13/cobra v1.7.0 github.com/spf13/pflag v1.0.5 github.com/spf13/viper v1.17.0 @@ -94,6 +95,7 @@ require ( github.com/Masterminds/semver v1.5.0 // indirect github.com/agnivade/levenshtein v1.1.1 // indirect github.com/aws/aws-sdk-go-v2/service/ssooidc v1.19.0 // indirect + github.com/bahlo/generic-list-go v0.2.0 // indirect github.com/cenkalti/backoff/v4 v4.2.1 // indirect github.com/emicklei/go-restful/v3 v3.11.0 // indirect github.com/facebookgo/ensure v0.0.0-20200202191622-63f1cf65ac4c // indirect @@ -125,6 +127,7 @@ require ( github.com/stretchr/objx v0.5.1 // indirect github.com/tchap/go-patricia/v2 v2.3.1 // indirect github.com/vultr/govultr/v3 v3.3.4 // indirect + github.com/wk8/go-ordered-map/v2 v2.1.8 // indirect go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.19.0 // indirect go.opentelemetry.io/otel/metric v1.19.0 // indirect go.uber.org/mock v0.3.0 // indirect @@ -207,7 +210,6 @@ require ( github.com/hashicorp/go-uuid v1.0.3 // indirect github.com/hashicorp/hcl v1.0.0 // indirect github.com/hashicorp/serf v0.10.1 // indirect - github.com/iancoleman/orderedmap v0.3.0 // indirect github.com/imdario/mergo v0.3.16 // indirect github.com/inconshreveable/mousetrap v1.1.0 // indirect github.com/jcmturner/aescts/v2 v2.0.0 // indirect diff --git a/go.sum b/go.sum index a87fe79a27..620e529b5a 100644 --- a/go.sum +++ b/go.sum @@ -134,6 +134,8 @@ github.com/aws/aws-sdk-go-v2/service/sts v1.25.0/go.mod h1:S/LOQUeYDfJeJpFCIJDMj github.com/aws/smithy-go v1.13.5/go.mod h1:Tg+OJXh4MB2R/uN61Ko2f6hTZwB/ZYGOtib8J3gBHzA= github.com/aws/smithy-go v1.16.0 h1:gJZEH/Fqh+RsvlJ1Zt4tVAtV6bKkp3cC+R6FCZMNzik= github.com/aws/smithy-go v1.16.0/go.mod h1:NukqUGpCZIILqqiV0NIjeFh24kd/FAa4beRb6nbIUPE= +github.com/bahlo/generic-list-go v0.2.0 h1:5sz/EEAK+ls5wF+NeqDpk5+iNdMDXrh3z3nPnH1Wvgk= +github.com/bahlo/generic-list-go v0.2.0/go.mod h1:2KvAjgMlE5NNynlg/5iLrrCCZ2+5xWbdbCW3pNTGyYg= github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8= @@ -459,15 +461,14 @@ github.com/hashicorp/serf v0.10.1 h1:Z1H2J60yRKvfDYAOZLd2MU0ND4AH/WDz7xYHDWQsIPY github.com/hashicorp/serf v0.10.1/go.mod h1:yL2t6BqATOLGc5HF7qbFkTfXoPIY0WZdWHfEvMqbG+4= github.com/huandu/xstrings v1.4.0 h1:D17IlohoQq4UcpqD7fDk80P7l+lwAmlFaBHgOipl2FU= github.com/huandu/xstrings v1.4.0/go.mod h1:y5/lhBue+AyNmUVz9RLU9xbLR0o4KIIExikq4ovT0aE= -github.com/iancoleman/orderedmap v0.0.0-20190318233801-ac98e3ecb4b0/go.mod h1:N0Wam8K1arqPXNWjMo21EXnBPOPp36vB07FNRdD2geA= -github.com/iancoleman/orderedmap v0.3.0 h1:5cbR2grmZR/DiVt+VJopEhtVs9YGInGIxAoMJn+Ichc= -github.com/iancoleman/orderedmap v0.3.0/go.mod h1:XuLcCUkdL5owUCQeF2Ue9uuw1EptkJDkXXS7VoV7XGE= github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= github.com/imdario/mergo v0.3.16 h1:wwQJbIsHYGMUyLSPrEq1CT16AhnhNJQ51+4fdHUnCl4= github.com/imdario/mergo v0.3.16/go.mod h1:WBLT9ZmE3lPoWsEzCh9LPo3TiwVN+ZKEjmz+hD27ysY= github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8= github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw= +github.com/invopop/jsonschema v0.12.0 h1:6ovsNSuvn9wEQVOyc72aycBMVQFKz7cPdMJn10CvzRI= +github.com/invopop/jsonschema v0.12.0/go.mod h1:ffZ5Km5SWWRAIN6wbDXItl95euhFz2uON45H2qjYt+0= github.com/invopop/yaml v0.2.0 h1:7zky/qH+O0DwAyoobXUqvVBwgBFRxKoQ/3FjcVpjTMY= github.com/invopop/yaml v0.2.0/go.mod h1:2XuRLgs/ouIrW3XNzuNj7J3Nvu/Dig5MXvbCEdiBN3Q= github.com/jcmturner/aescts/v2 v2.0.0 h1:9YKLH6ey7H4eDBXW8khjYslgyqG2xZikXP0EQFKrle8= @@ -581,8 +582,6 @@ github.com/megaease/easemesh-api v1.4.4 h1:E18mtLfj8ffuPTeN7MqZeakJgT/tJ92JNIZsY github.com/megaease/easemesh-api v1.4.4/go.mod h1:GuAE5DwqK6lI/ovoRKjyPxBCSoMhj0NLp9PRejj0Hnw= github.com/megaease/grace v1.0.0 h1:b44R3j6e/iaN62F4ZUnru9nzL1VaIcxxUZjSPVtTVzI= github.com/megaease/grace v1.0.0/go.mod h1:mOR6MVYQ6zGyuz9Y2or/VJ6QWueTL3erxWfIwyCmiIg= -github.com/megaease/jsonschema v0.5.1 h1:uTzdFo0YbRasSr/FW4pW4mjjzUkKuPHsj8Do4fGwycs= -github.com/megaease/jsonschema v0.5.1/go.mod h1:yZf5f6xi1re5otY+sx2liXGTzEK72UGDKe3Rg5O4cVE= github.com/megaease/yaml v0.0.0-20220804061446-4f18d6510aed h1:e7bvqcldNRNTYg5rvnUkNZXt8/93wvdDVtDiyU+4YIY= github.com/megaease/yaml v0.0.0-20220804061446-4f18d6510aed/go.mod h1:N67rkx57qPgnZ9Rvi5nf3SOLUe77vWiixhVbe2QdK+o= github.com/miekg/dns v1.1.26/go.mod h1:bPDLeHnStXmXAq1m/Ch/hvfNHr14JKNPMBo3VZKjuso= @@ -717,6 +716,8 @@ github.com/sagikazarmark/locafero v0.3.0 h1:zT7VEGWC2DTflmccN/5T1etyKvxSxpHsjb9c github.com/sagikazarmark/locafero v0.3.0/go.mod h1:w+v7UsPNFwzF1cHuOajOOzoq4U7v/ig1mpRjqV+Bu1U= github.com/sagikazarmark/slog-shim v0.1.0 h1:diDBnUNK9N/354PgrxMywXnAwEr1QZcOr6gto+ugjYE= github.com/sagikazarmark/slog-shim v0.1.0/go.mod h1:SrcSrq8aKtyuqEI1uvTDTK1arOWRIczQRv+GVI1AkeQ= +github.com/santhosh-tekuri/jsonschema/v5 v5.3.1 h1:lZUw3E0/J3roVtGQ+SCrUrg3ON6NgVqpn3+iol9aGu4= +github.com/santhosh-tekuri/jsonschema/v5 v5.3.1/go.mod h1:uToXkOrWAZ6/Oc07xWQrPOhJotwFIyu2bBVN41fcDUY= github.com/sclevine/spec v1.4.0 h1:z/Q9idDcay5m5irkZ28M7PtQM4aOISzOpj4bUPkDee8= github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529 h1:nn5Wsu0esKSJiIVhscUtVbo7ada43DJhG55ua/hjS5I= github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc= @@ -753,7 +754,6 @@ github.com/stretchr/objx v0.5.1 h1:4VhoImhV/Bm0ToFkXFi8hXNXwpDRZ/ynw3amt82mzq0= github.com/stretchr/objx v0.5.1/go.mod h1:/iHQpkQwBD6DLUmQ4pE+s1TXdob1mORJ4/UFdrifcy0= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= -github.com/stretchr/testify v1.3.1-0.20190311161405-34c6fa2dc709/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= @@ -786,6 +786,8 @@ github.com/uber/jaeger-lib v2.4.1+incompatible/go.mod h1:ComeNDZlWwrWnDv8aPp0Ba6 github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw= github.com/vultr/govultr/v3 v3.3.4 h1:aj1eX0sRPVgEjNH/LzQwpuC5dA277kMLeGNw2GeJmoM= github.com/vultr/govultr/v3 v3.3.4/go.mod h1:7NjuHeQv5vgUWR2H1sPc9D+xffrT5ql+kNi6R3yuwzo= +github.com/wk8/go-ordered-map/v2 v2.1.8 h1:5h/BUHu93oj4gIdvHHHGsScSTMijfx5PeYkE/fJgbpc= +github.com/wk8/go-ordered-map/v2 v2.1.8/go.mod h1:5nJHM5DyteebpVlHnWMV0rPz6Zp7+xBAnxjb1X5vnTw= github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f/go.mod h1:N2zxlSyiKSe5eX1tZViRH5QA0qijqEDrYZiPEAiq3wU= github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb h1:zGWFAtiMcyryUHoUjUJX0/lt1H2+i2Ka2n+D3DImSNo= github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb/go.mod h1:N2zxlSyiKSe5eX1tZViRH5QA0qijqEDrYZiPEAiq3wU= diff --git a/pkg/object/pipeline/pipeline.go b/pkg/object/pipeline/pipeline.go index b689456e59..e8faaa505a 100644 --- a/pkg/object/pipeline/pipeline.go +++ b/pkg/object/pipeline/pipeline.go @@ -70,18 +70,18 @@ type ( // Spec describes the Pipeline. Spec struct { - Flow []FlowNode `json:"flow"` + Flow []FlowNode `json:"flow,omitempty"` Filters []map[string]interface{} `json:"filters" jsonschema:"required"` - Resilience []map[string]interface{} `json:"resilience"` - Data map[string]interface{} `json:"data"` + Resilience []map[string]interface{} `json:"resilience,omitempty"` + Data map[string]interface{} `json:"data,omitempty"` } // FlowNode describes one node of the pipeline flow. FlowNode struct { FilterName string `json:"filter" jsonschema:"required,format=urlname"` - FilterAlias string `json:"alias"` - Namespace string `json:"namespace"` - JumpIf map[string]string `json:"jumpIf"` + FilterAlias string `json:"alias,omitempty"` + Namespace string `json:"namespace,omitempty"` + JumpIf map[string]string `json:"jumpIf,omitempty"` filter filters.Filter } diff --git a/pkg/supervisor/spec.go b/pkg/supervisor/spec.go index 82bf99d927..2a5a6b984b 100644 --- a/pkg/supervisor/spec.go +++ b/pkg/supervisor/spec.go @@ -44,7 +44,7 @@ type ( MetaSpec struct { Name string `json:"name" jsonschema:"required,format=urlname"` Kind string `json:"kind" jsonschema:"required"` - Version string `json:"version" jsonschema:"required"` + Version string `json:"version,omitempty"` // RFC3339 format CreatedAt string `json:"createdAt,omitempty"` diff --git a/pkg/v/v.go b/pkg/v/v.go index 0dc679ee3b..f340cc6ae2 100644 --- a/pkg/v/v.go +++ b/pkg/v/v.go @@ -23,10 +23,9 @@ import ( "reflect" "sync" - genjs "github.com/megaease/jsonschema" - loadjs "github.com/xeipuuv/gojsonschema" + genjs "github.com/invopop/jsonschema" + loadjs "github.com/santhosh-tekuri/jsonschema/v5" - "github.com/megaease/easegress/v2/pkg/logger" "github.com/megaease/easegress/v2/pkg/util/codectool" ) @@ -75,6 +74,12 @@ func Validate(v interface{}) *ValidateRecorder { vr.recordSystem(fmt.Errorf("marshal %#v to json failed: %v", v, err)) return vr } + var rawValue interface{} + err = codectool.Unmarshal(jsonBuff, &rawValue) + if err != nil { + vr.recordSystem(fmt.Errorf("unmarshal json %s failed: %v", jsonBuff, err)) + return vr + } sm, err := getSchemaMeta(reflect.TypeOf(v)) if err != nil { @@ -82,12 +87,8 @@ func Validate(v interface{}) *ValidateRecorder { return vr } - docLoader := loadjs.NewBytesLoader(jsonBuff) - result, err := sm.loadSchema.Validate(docLoader) - if err != nil { - logger.Errorf("BUG: invalid schema: %v", err) - } - vr.recordJSONSchema(result) + err = sm.loadSchema.Validate(rawValue) + vr.recordJSONSchema(err) val := reflect.ValueOf(v) traverseGo(&val, nil, vr.record) @@ -122,7 +123,7 @@ func getSchemaMeta(t reflect.Type) (*schemaMeta, error) { return nil, fmt.Errorf("marshal %#v to json failed: %v", sm.loadSchema, err) } - sm.loadSchema, err = loadjs.NewSchema(loadjs.NewBytesLoader(sm.jsonFormat)) + sm.loadSchema, err = loadjs.CompileString(loadjs.Draft2020.String(), string(sm.jsonFormat)) if err != nil { return nil, fmt.Errorf("new schema from %s failed: %v", sm.jsonFormat, err) } diff --git a/pkg/v/validaterecorder.go b/pkg/v/validaterecorder.go index 156dbdf866..7f4e6259ca 100644 --- a/pkg/v/validaterecorder.go +++ b/pkg/v/validaterecorder.go @@ -24,8 +24,6 @@ import ( "runtime/debug" "strings" - loadjs "github.com/xeipuuv/gojsonschema" - "github.com/megaease/easegress/v2/pkg/logger" "github.com/megaease/easegress/v2/pkg/util/codectool" ) @@ -76,9 +74,9 @@ type ( } ) -func (vr *ValidateRecorder) recordJSONSchema(result *loadjs.Result) { - for _, err := range result.Errors() { - vr.JSONSchemaErrs = append(vr.JSONSchemaErrs, err.String()) +func (vr *ValidateRecorder) recordJSONSchema(err error) { + if err != nil { + vr.JSONSchemaErrs = append(vr.JSONSchemaErrs, err.Error()) } } @@ -93,22 +91,16 @@ func getFieldJSONName(field *reflect.StructField) string { return fieldName } -func requiredFromField(field *reflect.StructField) bool { - tags := strings.Split(field.Tag.Get("jsonschema"), ",") - switch { - case len(tags) == 0: - return false - case tags[0] == "-": - return false - default: - for _, tag := range tags { - if tag == "omitempty" { - return false - } +func IsOmitemptyField(field *reflect.StructField) bool { + tags := strings.Split(field.Tag.Get("json"), ",") + + for _, tag := range tags { + if tag == "omitempty" { + return true } - // NOTICE: Required by default. - return true } + + return false } func (vr *ValidateRecorder) record(val *reflect.Value, field *reflect.StructField) { @@ -121,7 +113,7 @@ func (vr *ValidateRecorder) recordFormat(val *reflect.Value, field *reflect.Stru return } - if !requiredFromField(field) && val.IsZero() { + if IsOmitemptyField(field) { return } diff --git a/pkg/v/validaterecorder_test.go b/pkg/v/validaterecorder_test.go index d09bf07cdd..90b4746ca6 100644 --- a/pkg/v/validaterecorder_test.go +++ b/pkg/v/validaterecorder_test.go @@ -66,13 +66,13 @@ func TestRequiredFromField(t *testing.T) { typeOfT := val.Type() idField, _ := typeOfT.FieldByName("ID") - assert.False(requiredFromField(&idField)) + assert.True(IsOmitemptyField(&idField)) nameField, _ := typeOfT.FieldByName("Name") - assert.False(requiredFromField(&nameField)) + assert.True(IsOmitemptyField(&nameField)) addrField, _ := typeOfT.FieldByName("Addr") - assert.True(requiredFromField(&addrField)) + assert.True(IsOmitemptyField(&addrField)) } func TestValidateRecorder(t *testing.T) { From c7f514203d01bacd5afba371a444ca4bcd279c82 Mon Sep 17 00:00:00 2001 From: Yun Long Date: Tue, 14 Nov 2023 00:19:42 +0800 Subject: [PATCH 3/6] Fix broken unit tests --- pkg/filters/proxies/grpcproxy/proxy_test.go | 3 ++- pkg/filters/proxies/grpcproxy/requestmatch.go | 2 +- pkg/filters/proxies/httpproxy/simplehttpproxy.go | 10 +++++----- pkg/object/meshcontroller/spec/spec.go | 14 +++++++------- pkg/object/mqttproxy/mock_test.go | 7 ++++--- pkg/util/ipfilter/ipfilter.go | 2 +- pkg/v/validaterecorder.go | 2 +- 7 files changed, 21 insertions(+), 19 deletions(-) diff --git a/pkg/filters/proxies/grpcproxy/proxy_test.go b/pkg/filters/proxies/grpcproxy/proxy_test.go index 7d4455553a..ed37fcf9aa 100644 --- a/pkg/filters/proxies/grpcproxy/proxy_test.go +++ b/pkg/filters/proxies/grpcproxy/proxy_test.go @@ -153,7 +153,8 @@ name: grpcforwardproxy _ = yaml.Unmarshal([]byte(s), &rawSpec) _ = codectool.Unmarshal([]byte(s), &rawSpec) - spec, _ := filters.NewSpec(nil, "", rawSpec) + spec, err := filters.NewSpec(nil, "", rawSpec) + assertions.Nil(err) p.spec = spec.(*Spec) p.reload() assertions.True(oldPool == p.connectionPool) diff --git a/pkg/filters/proxies/grpcproxy/requestmatch.go b/pkg/filters/proxies/grpcproxy/requestmatch.go index 90111bfa0b..fe50d60d9b 100644 --- a/pkg/filters/proxies/grpcproxy/requestmatch.go +++ b/pkg/filters/proxies/grpcproxy/requestmatch.go @@ -27,7 +27,7 @@ import ( // RequestMatcherSpec describe RequestMatcher type RequestMatcherSpec struct { proxies.RequestMatcherBaseSpec `json:",inline"` - Methods []*stringtool.StringMatcher `json:"methods"` + Methods []*stringtool.StringMatcher `json:"methods,omitempty"` } // Validate validates the RequestMatcherSpec. diff --git a/pkg/filters/proxies/httpproxy/simplehttpproxy.go b/pkg/filters/proxies/httpproxy/simplehttpproxy.go index 97e20bb0ba..8755a3f25e 100644 --- a/pkg/filters/proxies/httpproxy/simplehttpproxy.go +++ b/pkg/filters/proxies/httpproxy/simplehttpproxy.go @@ -83,11 +83,11 @@ type ( filters.BaseSpec `json:",inline"` Compression *CompressionSpec `json:"compression,omitempty"` - MaxIdleConns int `json:"maxIdleConns"` - MaxIdleConnsPerHost int `json:"maxIdleConnsPerHost"` - ServerMaxBodySize int64 `json:"serverMaxBodySize"` - Timeout string `json:"timeout" jsonschema:"format=duration"` - RetryPolicy string `json:"retryPolicy"` + MaxIdleConns int `json:"maxIdleConns,omitempty"` + MaxIdleConnsPerHost int `json:"maxIdleConnsPerHost,omitempty"` + ServerMaxBodySize int64 `json:"serverMaxBodySize,omitempty"` + Timeout string `json:"timeout,omitempty" jsonschema:"format=duration"` + RetryPolicy string `json:"retryPolicy,omitempty"` } ) diff --git a/pkg/object/meshcontroller/spec/spec.go b/pkg/object/meshcontroller/spec/spec.go index cace758565..cee6701d94 100644 --- a/pkg/object/meshcontroller/spec/spec.go +++ b/pkg/object/meshcontroller/spec/spec.go @@ -143,13 +143,13 @@ type ( // IngressServerSpec is the spec of ingress httpserver in worker IngressServerSpec struct { KeepAlive bool `json:"keepAlive,omitempty"` - KeepAliveTimeout string `json:"keepAliveTimeout,omitempty" jsonschema:"format=duration"` + KeepAliveTimeout string `json:"keepAliveTimeout,omitempty" jsonschema:"omitempty,format=duration"` } // EgressServerSpec is the spec of egress httpserver in worker EgressServerSpec struct { KeepAlive bool `json:"keepAlive,omitempty"` - KeepAliveTimeout string `json:"keepAliveTimeout,omitempty" jsonschema:"format=duration"` + KeepAliveTimeout string `json:"keepAliveTimeout,omitempty" jsonschema:"omitempty,format=duration"` } // MonitorMTLS is the spec of mTLS specification of monitor. @@ -221,7 +221,7 @@ type ( CircuitBreaker *resilience.CircuitBreakerRule `json:"circuitBreaker,omitempty"` Retry *resilience.RetryRule `json:"retry,omitempty"` TimeLimiter *TimeLimiterRule `json:"timeLimiter,omitempty"` - FailureCodes []int `json:"failureCodes,omitempty" jsonschema:"uniqueItems=true"` + FailureCodes []int `json:"failureCodes,omitempty" jsonschema:"omitempty,uniqueItems=true"` } // TimeLimiterRule is the spec of TimeLimiter. @@ -363,8 +363,8 @@ type ( InstanceID string `json:"instanceID" jsonschema:"required"` IP string `json:"ip" jsonschema:"required"` Port uint32 `json:"port" jsonschema:"required"` - RegistryTime string `json:"registryTime"` - Labels map[string]string `json:"labels"` + RegistryTime string `json:"registryTime,omitempty"` + Labels map[string]string `json:"labels,omitempty"` // Set by heartbeat timer event or API Status string `json:"status"` @@ -373,13 +373,13 @@ type ( // IngressPath is the path for a mesh ingress rule IngressPath struct { Path string `json:"path" jsonschema:"required,pattern=^/"` - RewriteTarget string `json:"rewriteTarget"` + RewriteTarget string `json:"rewriteTarget,omitempty"` Backend string `json:"backend" jsonschema:"required"` } // IngressRule is the rule for mesh ingress IngressRule struct { - Host string `json:"host"` + Host string `json:"host,omitempty"` Paths []*IngressPath `json:"paths" jsonschema:"required"` } diff --git a/pkg/object/mqttproxy/mock_test.go b/pkg/object/mqttproxy/mock_test.go index 3d2b93d7d6..2734f84efb 100644 --- a/pkg/object/mqttproxy/mock_test.go +++ b/pkg/object/mqttproxy/mock_test.go @@ -96,6 +96,7 @@ func (w *mockWatcher) WatchRaw(key string) (<-chan *clientv3.Event, error) func (w *mockWatcher) WatchRawPrefix(prefix string) (<-chan map[string]*clientv3.Event, error) { return nil, nil } + func (w *mockWatcher) WatchWithOp(key string, ops ...cluster.ClientOp) (<-chan map[string]*string, error) { return w.delCh, nil } @@ -279,9 +280,9 @@ type MockMQTTSpec struct { Password string `json:"password" jsonschema:"required"` Port uint16 `json:"port" jsonschema:"required"` BackendType string `json:"backendType" jsonschema:"required"` - EarlyStop bool `json:"earlyStop"` - KeysToStore []string `json:"keysToStore"` - ConnectKey string `json:"connectKey"` + EarlyStop bool `json:"earlyStop,omitempty"` + KeysToStore []string `json:"keysToStore,omitempty"` + ConnectKey string `json:"connectKey,omitempty"` } // MockMQTTStatus is status of MockMQTTFilter diff --git a/pkg/util/ipfilter/ipfilter.go b/pkg/util/ipfilter/ipfilter.go index ac14190719..3fad5e1558 100644 --- a/pkg/util/ipfilter/ipfilter.go +++ b/pkg/util/ipfilter/ipfilter.go @@ -37,7 +37,7 @@ type ( Spec struct { BlockByDefault bool `json:"blockByDefault,omitempty"` - AllowIPs []string `json:"allowIP,omitemptys" jsonschema:"uniqueItems=true,format=ipcidr-array"` + AllowIPs []string `json:"allowIPs,omitempty" jsonschema:"uniqueItems=true,format=ipcidr-array"` BlockIPs []string `json:"blockIPs,omitempty" jsonschema:"uniqueItems=true,format=ipcidr-array"` } diff --git a/pkg/v/validaterecorder.go b/pkg/v/validaterecorder.go index 7f4e6259ca..e4da7207db 100644 --- a/pkg/v/validaterecorder.go +++ b/pkg/v/validaterecorder.go @@ -113,7 +113,7 @@ func (vr *ValidateRecorder) recordFormat(val *reflect.Value, field *reflect.Stru return } - if IsOmitemptyField(field) { + if IsOmitemptyField(field) && val.IsZero() { return } From 7b35fb79b843778bc2d41d5eeafb8f1f2899453f Mon Sep 17 00:00:00 2001 From: Yun Long Date: Wed, 15 Nov 2023 11:01:29 +0800 Subject: [PATCH 4/6] Update pkg/object/nacosserviceregistry/nacosserviceregistry.go Co-authored-by: su chen --- pkg/object/nacosserviceregistry/nacosserviceregistry.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/object/nacosserviceregistry/nacosserviceregistry.go b/pkg/object/nacosserviceregistry/nacosserviceregistry.go index b5b66b5062..174c3fabef 100644 --- a/pkg/object/nacosserviceregistry/nacosserviceregistry.go +++ b/pkg/object/nacosserviceregistry/nacosserviceregistry.go @@ -94,8 +94,8 @@ type ( ServerSpec struct { Scheme string `json:"scheme,omitempty" jsonschema:"enum=http,enum=https"` ContextPath string `json:"contextPath,omitempty"` - IPAddr string `json:"ipAddr,omitempty" jsonschema:"required"` - Port uint16 `json:"port,omitempty" jsonschema:"required"` + IPAddr string `json:"ipAddr" jsonschema:"required"` + Port uint16 `json:"port" jsonschema:"required"` } // Status is the status of NacosServiceRegistry. From 901b78c917736f02640a7e524251091ce319b113 Mon Sep 17 00:00:00 2001 From: Yun Long Date: Wed, 15 Nov 2023 11:01:59 +0800 Subject: [PATCH 5/6] Update pkg/object/httpserver/spec.go Co-authored-by: su chen --- pkg/object/httpserver/spec.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/object/httpserver/spec.go b/pkg/object/httpserver/spec.go index 03d11635ce..860122a0f3 100644 --- a/pkg/object/httpserver/spec.go +++ b/pkg/object/httpserver/spec.go @@ -63,7 +63,7 @@ type ( GlobalFilter string `json:"globalFilter,omitempty"` - AccessLogFormat string `json:"accessLogFormat,omitempty" jsonshema:"omitempty"` + AccessLogFormat string `json:"accessLogFormat,omitempty"` } ) From ade9ffaa28bd7d9cde5b0586aa13a7a549ce460d Mon Sep 17 00:00:00 2001 From: Yun Long Date: Wed, 15 Nov 2023 11:04:42 +0800 Subject: [PATCH 6/6] Eliminate more omitempty jsonschema --- pkg/object/meshcontroller/spec/spec.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pkg/object/meshcontroller/spec/spec.go b/pkg/object/meshcontroller/spec/spec.go index cee6701d94..1ab4fe977d 100644 --- a/pkg/object/meshcontroller/spec/spec.go +++ b/pkg/object/meshcontroller/spec/spec.go @@ -143,13 +143,13 @@ type ( // IngressServerSpec is the spec of ingress httpserver in worker IngressServerSpec struct { KeepAlive bool `json:"keepAlive,omitempty"` - KeepAliveTimeout string `json:"keepAliveTimeout,omitempty" jsonschema:"omitempty,format=duration"` + KeepAliveTimeout string `json:"keepAliveTimeout,omitempty" jsonschema:"format=duration"` } // EgressServerSpec is the spec of egress httpserver in worker EgressServerSpec struct { KeepAlive bool `json:"keepAlive,omitempty"` - KeepAliveTimeout string `json:"keepAliveTimeout,omitempty" jsonschema:"omitempty,format=duration"` + KeepAliveTimeout string `json:"keepAliveTimeout,omitempty" jsonschema:"format=duration"` } // MonitorMTLS is the spec of mTLS specification of monitor. @@ -221,7 +221,7 @@ type ( CircuitBreaker *resilience.CircuitBreakerRule `json:"circuitBreaker,omitempty"` Retry *resilience.RetryRule `json:"retry,omitempty"` TimeLimiter *TimeLimiterRule `json:"timeLimiter,omitempty"` - FailureCodes []int `json:"failureCodes,omitempty" jsonschema:"omitempty,uniqueItems=true"` + FailureCodes []int `json:"failureCodes,omitempty" jsonschema:"uniqueItems=true"` } // TimeLimiterRule is the spec of TimeLimiter.