diff --git a/pkg/apiserver/authentication/oauth/options.go b/pkg/apiserver/authentication/oauth/options.go index 4e6b72d4f..826dc448b 100644 --- a/pkg/apiserver/authentication/oauth/options.go +++ b/pkg/apiserver/authentication/oauth/options.go @@ -63,10 +63,10 @@ type Options struct { Issuer string `json:"issuer,omitempty" yaml:"issuer,omitempty"` // RSA private key file used to sign the id token - SignKey string `json:"signKey,omitempty" yaml:"signKey"` + SignKey string `json:"signKey,omitempty" yaml:"signKey,omitempty"` // Raw RSA private key. Base64 encoded PEM file - SignKeyData string `json:"-,omitempty" yaml:"signKeyData"` + SignKeyData string `json:"-,omitempty" yaml:"signKeyData,omitempty"` // Register identity providers. IdentityProviders []IdentityProviderOptions `json:"identityProviders,omitempty" yaml:"identityProviders,omitempty"` @@ -191,7 +191,7 @@ type Token struct { type Client struct { // The name of the OAuth client is used as the client_id parameter when making requests to /oauth/authorize // and /oauth/token. - Name string `json:"name" yaml:"name,omitempty"` + Name string `json:"name,omitempty" yaml:"name,omitempty"` // Secret is the unique secret associated with a client Secret string `json:"-" yaml:"secret,omitempty"` diff --git a/pkg/apiserver/authorization/options.go b/pkg/apiserver/authorization/options.go index 628674142..e2062fd46 100644 --- a/pkg/apiserver/authorization/options.go +++ b/pkg/apiserver/authorization/options.go @@ -28,7 +28,7 @@ import ( ) type Options struct { - Mode string `json:"mode" yaml:"mode"` + Mode string `json:"mode" yaml:"mode"` } func NewOptions() *Options { diff --git a/pkg/apiserver/config/config_test.go b/pkg/apiserver/config/config_test.go index 24d61039c..cbe1983af 100644 --- a/pkg/apiserver/config/config_test.go +++ b/pkg/apiserver/config/config_test.go @@ -19,26 +19,24 @@ package config import ( "fmt" "io/ioutil" - "os" "testing" "time" - "kubesphere.io/kubesphere/pkg/apiserver/authentication" - "kubesphere.io/kubesphere/pkg/apiserver/authorization" - "github.com/google/go-cmp/cmp" "gopkg.in/yaml.v2" networkv1alpha1 "kubesphere.io/api/network/v1alpha1" + "kubesphere.io/kubesphere/pkg/apiserver/authentication" "kubesphere.io/kubesphere/pkg/apiserver/authentication/oauth" + "kubesphere.io/kubesphere/pkg/apiserver/authorization" "kubesphere.io/kubesphere/pkg/models/terminal" "kubesphere.io/kubesphere/pkg/simple/client/alerting" "kubesphere.io/kubesphere/pkg/simple/client/auditing" "kubesphere.io/kubesphere/pkg/simple/client/cache" "kubesphere.io/kubesphere/pkg/simple/client/devops/jenkins" - edgeruntime "kubesphere.io/kubesphere/pkg/simple/client/edgeruntime" + "kubesphere.io/kubesphere/pkg/simple/client/edgeruntime" "kubesphere.io/kubesphere/pkg/simple/client/events" "kubesphere.io/kubesphere/pkg/simple/client/gateway" "kubesphere.io/kubesphere/pkg/simple/client/gpu" @@ -58,7 +56,6 @@ import ( ) func newTestConfig() (*Config, error) { - var conf = &Config{ DevopsOptions: &jenkins.Options{ Host: "http://ks-devops.kubesphere-devops-system.svc", @@ -87,6 +84,9 @@ func newTestConfig() (*Config, error) { ManagerPassword: "P@88w0rd", UserSearchBase: "ou=Users,dc=example,dc=org", GroupSearchBase: "ou=Groups,dc=example,dc=org", + InitialCap: 10, + MaxCap: 100, + PoolName: "ldap", }, RedisOptions: &cache.Options{ Host: "localhost", @@ -96,7 +96,7 @@ func newTestConfig() (*Config, error) { }, S3Options: &s3.Options{ Endpoint: "http://minio.openpitrix-system.svc", - Region: "", + Region: "us-east-1", DisableSSL: false, ForcePathStyle: false, AccessKeyID: "ABCDEFGHIJKLMN", @@ -167,9 +167,7 @@ func newTestConfig() (*Config, error) { AccessTokenInactivityTimeout: 0, }, }, - MultiClusterOptions: &multicluster.Options{ - Enable: false, - }, + MultiClusterOptions: multicluster.NewOptions(), EventsOptions: &events.Options{ Host: "http://elasticsearch-logging-data.kubesphere-logging-system.svc:9200", IndexPrefix: "ks-logstash-events", diff --git a/pkg/models/terminal/options.go b/pkg/models/terminal/options.go index c574c1159..860f10d7c 100644 --- a/pkg/models/terminal/options.go +++ b/pkg/models/terminal/options.go @@ -3,8 +3,8 @@ package terminal import "github.com/spf13/pflag" type Options struct { - Image string `json:"image,omitempty" yaml:"image"` - Timeout int `json:"timeout,omitempty" yaml:"timeout"` + Image string `json:"image,omitempty" yaml:"image,omitempty"` + Timeout int `json:"timeout,omitempty" yaml:"timeout,omitempty"` } func NewTerminalOptions() *Options { diff --git a/pkg/simple/client/auditing/options.go b/pkg/simple/client/auditing/options.go index 4a2094f58..fca9ca2bf 100644 --- a/pkg/simple/client/auditing/options.go +++ b/pkg/simple/client/auditing/options.go @@ -37,7 +37,7 @@ type Options struct { BasicAuth bool `json:"basicAuth" yaml:"basicAuth"` Username string `json:"username" yaml:"username"` Password string `json:"password" yaml:"password"` - IndexPrefix string `json:"indexPrefix,omitempty" yaml:"indexPrefix"` + IndexPrefix string `json:"indexPrefix,omitempty" yaml:"indexPrefix,omitempty"` Version string `json:"version" yaml:"version"` } diff --git a/pkg/simple/client/cache/options.go b/pkg/simple/client/cache/options.go index a9f0bb50d..eb6c6f942 100644 --- a/pkg/simple/client/cache/options.go +++ b/pkg/simple/client/cache/options.go @@ -23,10 +23,10 @@ import ( ) type Options struct { - Host string `json:"host"` - Port int `json:"port"` - Password string `json:"password"` - DB int `json:"db"` + Host string `json:"host" yaml:"host"` + Port int `json:"port" yaml:"port"` + Password string `json:"password" yaml:"password"` + DB int `json:"db" yaml:"db"` } // NewRedisOptions returns options points to nowhere, diff --git a/pkg/simple/client/devops/jenkins/options.go b/pkg/simple/client/devops/jenkins/options.go index 8532961c2..b5606042a 100644 --- a/pkg/simple/client/devops/jenkins/options.go +++ b/pkg/simple/client/devops/jenkins/options.go @@ -25,11 +25,11 @@ import ( ) type Options struct { - Host string `json:",omitempty" yaml:"host" description:"Jenkins service host address"` - Username string `json:",omitempty" yaml:"username" description:"Jenkins admin username"` - Password string `json:",omitempty" yaml:"password" description:"Jenkins admin password"` - MaxConnections int `json:"maxConnections,omitempty" yaml:"maxConnections" description:"Maximum connections allowed to connect to Jenkins"` - Endpoint string `json:"endpoint,omitempty" yaml:"endpoint" description:"The endpoint of the ks-devops apiserver"` + Host string `json:",omitempty" yaml:"host,omitempty" description:"Jenkins service host address"` + Username string `json:",omitempty" yaml:"username,omitempty" description:"Jenkins admin username"` + Password string `json:",omitempty" yaml:"password,omitempty" description:"Jenkins admin password"` + MaxConnections int `json:"maxConnections,omitempty" yaml:"maxConnections,omitempty" description:"Maximum connections allowed to connect to Jenkins"` + Endpoint string `json:"endpoint,omitempty" yaml:"endpoint,omitempty" description:"The endpoint of the ks-devops apiserver"` } // NewDevopsOptions returns a `zero` instance diff --git a/pkg/simple/client/events/options.go b/pkg/simple/client/events/options.go index 7126f2c3f..982bafa18 100644 --- a/pkg/simple/client/events/options.go +++ b/pkg/simple/client/events/options.go @@ -27,7 +27,7 @@ type Options struct { BasicAuth bool `json:"basicAuth" yaml:"basicAuth"` Username string `json:"username" yaml:"username"` Password string `json:"password" yaml:"password"` - IndexPrefix string `json:"indexPrefix,omitempty" yaml:"indexPrefix"` + IndexPrefix string `json:"indexPrefix,omitempty" yaml:"indexPrefix,omitempty"` Version string `json:"version" yaml:"version"` } diff --git a/pkg/simple/client/gateway/options.go b/pkg/simple/client/gateway/options.go index 57d70c48e..d998173fd 100644 --- a/pkg/simple/client/gateway/options.go +++ b/pkg/simple/client/gateway/options.go @@ -24,17 +24,17 @@ import ( // Options contains configuration of the default Gateway type Options struct { - WatchesPath string `json:"watchesPath,omitempty" yaml:"watchesPath"` - Namespace string `json:"namespace,omitempty" yaml:"namespace"` - Repository string `json:"repository,omitempty" yaml:"repository"` - Tag string `json:"tag,omitempty" yaml:"tag"` + WatchesPath string `json:"watchesPath,omitempty" yaml:"watchesPath,omitempty"` + Namespace string `json:"namespace,omitempty" yaml:"namespace,omitempty"` + Repository string `json:"repository,omitempty" yaml:"repository,omitempty"` + Tag string `json:"tag,omitempty" yaml:"tag,omitempty"` } // NewGatewayOptions creates a default Gateway Option func NewGatewayOptions() *Options { return &Options{ WatchesPath: "", - Namespace: "", //constants.KubeSphereControlNamespace + Namespace: "", // constants.KubeSphereControlNamespace Repository: "", Tag: "", } diff --git a/pkg/simple/client/gpu/options.go b/pkg/simple/client/gpu/options.go index 472d0351a..f850046da 100644 --- a/pkg/simple/client/gpu/options.go +++ b/pkg/simple/client/gpu/options.go @@ -3,13 +3,13 @@ package gpu import "github.com/spf13/pflag" type GPUKind struct { - ResourceName string `json:"resourceName,omitempty" yaml:"resourceName"` - ResourceType string `json:"resourceType,omitempty" yaml:"resourceType"` - Default bool `json:"default,omitempty" yaml:"default"` + ResourceName string `json:"resourceName,omitempty" yaml:"resourceName,omitempty"` + ResourceType string `json:"resourceType,omitempty" yaml:"resourceType,omitempty"` + Default bool `json:"default,omitempty" yaml:"default,omitempty"` } type Options struct { - Kinds []GPUKind `json:"kinds,omitempty" yaml:"kinds"` + Kinds []GPUKind `json:"kinds,omitempty" yaml:"kinds,omitempty"` } func NewGPUOptions() *Options { diff --git a/pkg/simple/client/k8s/options.go b/pkg/simple/client/k8s/options.go index f4d97bd43..c1e104dc6 100644 --- a/pkg/simple/client/k8s/options.go +++ b/pkg/simple/client/k8s/options.go @@ -36,15 +36,15 @@ type KubernetesOptions struct { // kubernetes apiserver public address, used to generate kubeconfig // for downloading, default to host defined in kubeconfig // +optional - Master string `json:"master,omitempty" yaml:"master"` + Master string `json:"master,omitempty" yaml:"master,omitempty"` // kubernetes clientset qps // +optional - QPS float32 `json:"qps,omitempty" yaml:"qps"` + QPS float32 `json:"qps,omitempty" yaml:"qps,omitempty"` // kubernetes clientset burst // +optional - Burst int `json:"burst,omitempty" yaml:"burst"` + Burst int `json:"burst,omitempty" yaml:"burst,omitempty"` } // NewKubernetesOptions returns a `zero` instance diff --git a/pkg/simple/client/ldap/options.go b/pkg/simple/client/ldap/options.go index b10e56308..0641426e4 100644 --- a/pkg/simple/client/ldap/options.go +++ b/pkg/simple/client/ldap/options.go @@ -23,14 +23,14 @@ import ( ) type Options struct { - Host string `json:"host,omitempty" yaml:"host"` - ManagerDN string `json:"managerDN,omitempty" yaml:"managerDN"` - ManagerPassword string `json:"managerPassword,omitempty" yaml:"managerPassword"` - UserSearchBase string `json:"userSearchBase,omitempty" yaml:"userSearchBase"` - GroupSearchBase string `json:"groupSearchBase,omitempty" yaml:"groupSearchBase"` - InitialCap int `json:"initialCap,omitempty" yaml:"initialCap"` - MaxCap int `json:"maxCap,omitempty" yaml:"maxCap"` - PoolName string `json:"poolName,omitempty" yaml:"poolName"` + Host string `json:"host,omitempty" yaml:"host,omitempty"` + ManagerDN string `json:"managerDN,omitempty" yaml:"managerDN,omitempty"` + ManagerPassword string `json:"managerPassword,omitempty" yaml:"managerPassword,omitempty"` + UserSearchBase string `json:"userSearchBase,omitempty" yaml:"userSearchBase,omitempty"` + GroupSearchBase string `json:"groupSearchBase,omitempty" yaml:"groupSearchBase,omitempty"` + InitialCap int `json:"initialCap,omitempty" yaml:"initialCap,omitempty"` + MaxCap int `json:"maxCap,omitempty" yaml:"maxCap,omitempty"` + PoolName string `json:"poolName,omitempty" yaml:"poolName,omitempty"` } // NewOptions return a default option diff --git a/pkg/simple/client/logging/options.go b/pkg/simple/client/logging/options.go index 814ce47fd..7cd5bb605 100644 --- a/pkg/simple/client/logging/options.go +++ b/pkg/simple/client/logging/options.go @@ -27,7 +27,7 @@ type Options struct { BasicAuth bool `json:"basicAuth" yaml:"basicAuth"` Username string `json:"username" yaml:"username"` Password string `json:"password" yaml:"password"` - IndexPrefix string `json:"indexPrefix,omitempty" yaml:"indexPrefix"` + IndexPrefix string `json:"indexPrefix,omitempty" yaml:"indexPrefix,omitempty"` Version string `json:"version" yaml:"version"` } diff --git a/pkg/simple/client/monitoring/prometheus/prometheus_options.go b/pkg/simple/client/monitoring/prometheus/prometheus_options.go index cebb9e5f4..83e464cfb 100644 --- a/pkg/simple/client/monitoring/prometheus/prometheus_options.go +++ b/pkg/simple/client/monitoring/prometheus/prometheus_options.go @@ -21,7 +21,7 @@ import ( ) type Options struct { - Endpoint string `json:"endpoint,omitempty" yaml:"endpoint"` + Endpoint string `json:"endpoint,omitempty" yaml:"endpoint,omitempty"` } func NewPrometheusOptions() *Options { diff --git a/pkg/simple/client/multicluster/options.go b/pkg/simple/client/multicluster/options.go index 30b2b9a80..7f9ede5fe 100644 --- a/pkg/simple/client/multicluster/options.go +++ b/pkg/simple/client/multicluster/options.go @@ -31,28 +31,28 @@ const ( type Options struct { // Enable - Enable bool `json:"enable"` - EnableFederation bool `json:"enableFederation,omitempty"` + Enable bool `json:"enable" yaml:"enable"` + EnableFederation bool `json:"enableFederation,omitempty" yaml:"enableFederation,omitempty"` // ProxyPublishService is the service name of multicluster component tower. // If this field provided, apiserver going to use the ingress.ip of this service. // This field will be used when generating agent deployment yaml for joining clusters. - ProxyPublishService string `json:"proxyPublishService,omitempty"` + ProxyPublishService string `json:"proxyPublishService,omitempty" yaml:"proxyPublishService,omitempty"` // ProxyPublishAddress is the public address of tower for all cluster agents. // This field takes precedence over field ProxyPublishService. // If both field ProxyPublishService and ProxyPublishAddress are empty, apiserver will // return 404 Not Found for all cluster agent yaml requests. - ProxyPublishAddress string `json:"proxyPublishAddress,omitempty"` + ProxyPublishAddress string `json:"proxyPublishAddress,omitempty" yaml:"proxyPublishAddress,omitempty"` // AgentImage is the image used when generating deployment for all cluster agents. - AgentImage string `json:"agentImage,omitempty"` + AgentImage string `json:"agentImage,omitempty" yaml:"agentImage,omitempty"` // ClusterControllerResyncPeriod is the resync period used by cluster controller. - ClusterControllerResyncPeriod time.Duration `json:"clusterControllerResyncPeriod,omitempty" yaml:"clusterControllerResyncPeriod"` + ClusterControllerResyncPeriod time.Duration `json:"clusterControllerResyncPeriod,omitempty" yaml:"clusterControllerResyncPeriod,omitempty"` // HostClusterName is the name of the control plane cluster, default set to host. - HostClusterName string `json:"hostClusterName,omitempty" yaml:"hostClusterName"` + HostClusterName string `json:"hostClusterName,omitempty" yaml:"hostClusterName,omitempty"` } // NewOptions returns a default nil options diff --git a/pkg/simple/client/network/options.go b/pkg/simple/client/network/options.go index 04ff10dc4..2e646db9c 100644 --- a/pkg/simple/client/network/options.go +++ b/pkg/simple/client/network/options.go @@ -27,7 +27,7 @@ type NSNPOptions struct { } type Options struct { - EnableNetworkPolicy bool `json:"enableNetworkPolicy,omitempty" yaml:"enableNetworkPolicy"` + EnableNetworkPolicy bool `json:"enableNetworkPolicy,omitempty" yaml:"enableNetworkPolicy,omitempty"` NSNPOptions NSNPOptions `json:"nsnpOptions,omitempty" yaml:"nsnpOptions,omitempty"` WeaveScopeHost string `json:"weaveScopeHost,omitempty" yaml:"weaveScopeHost,omitempty"` IPPoolType string `json:"ippoolType,omitempty" yaml:"ippoolType,omitempty"` diff --git a/pkg/simple/client/notification/options.go b/pkg/simple/client/notification/options.go index 7bff28689..1db9794ef 100644 --- a/pkg/simple/client/notification/options.go +++ b/pkg/simple/client/notification/options.go @@ -17,7 +17,7 @@ limitations under the License. package notification type Options struct { - Endpoint string + Endpoint string `json:"endpoint,omitempty" yaml:"endpoint,omitempty"` } func NewNotificationOptions() *Options { diff --git a/pkg/simple/client/s3/options.go b/pkg/simple/client/s3/options.go index 42488f222..8350b98a0 100644 --- a/pkg/simple/client/s3/options.go +++ b/pkg/simple/client/s3/options.go @@ -24,14 +24,14 @@ import ( // Options contains configuration to access a s3 service type Options struct { - Endpoint string `json:"endpoint,omitempty" yaml:"endpoint"` - Region string `json:"region,omitempty" yaml:"region"` + Endpoint string `json:"endpoint,omitempty" yaml:"endpoint,omitempty"` + Region string `json:"region,omitempty" yaml:"region,omitempty"` DisableSSL bool `json:"disableSSL" yaml:"disableSSL"` ForcePathStyle bool `json:"forcePathStyle" yaml:"forcePathStyle"` - AccessKeyID string `json:"accessKeyID,omitempty" yaml:"accessKeyID"` - SecretAccessKey string `json:"secretAccessKey,omitempty" yaml:"secretAccessKey"` - SessionToken string `json:"sessionToken,omitempty" yaml:"sessionToken"` - Bucket string `json:"bucket,omitempty" yaml:"bucket"` + AccessKeyID string `json:"accessKeyID,omitempty" yaml:"accessKeyID,omitempty"` + SecretAccessKey string `json:"secretAccessKey,omitempty" yaml:"secretAccessKey,omitempty"` + SessionToken string `json:"sessionToken,omitempty" yaml:"sessionToken,omitempty"` + Bucket string `json:"bucket,omitempty" yaml:"bucket,omitempty"` } // NewS3Options creates a default disabled Options(empty endpoint) diff --git a/pkg/simple/client/servicemesh/options.go b/pkg/simple/client/servicemesh/options.go index 96d26b1d9..099cbd06e 100644 --- a/pkg/simple/client/servicemesh/options.go +++ b/pkg/simple/client/servicemesh/options.go @@ -21,16 +21,16 @@ import "github.com/spf13/pflag" type Options struct { // istio pilot discovery service url - IstioPilotHost string `json:"istioPilotHost,omitempty" yaml:"istioPilotHost"` + IstioPilotHost string `json:"istioPilotHost,omitempty" yaml:"istioPilotHost,omitempty"` // jaeger query service url - JaegerQueryHost string `json:"jaegerQueryHost,omitempty" yaml:"jaegerQueryHost"` + JaegerQueryHost string `json:"jaegerQueryHost,omitempty" yaml:"jaegerQueryHost,omitempty"` // kiali query service url - KialiQueryHost string `json:"kialiQueryHost,omitempty" yaml:"kialiQueryHost"` + KialiQueryHost string `json:"kialiQueryHost,omitempty" yaml:"kialiQueryHost,omitempty"` // prometheus service url for servicemesh metrics - ServicemeshPrometheusHost string `json:"servicemeshPrometheusHost,omitempty" yaml:"servicemeshPrometheusHost"` + ServicemeshPrometheusHost string `json:"servicemeshPrometheusHost,omitempty" yaml:"servicemeshPrometheusHost,omitempty"` } // NewServiceMeshOptions returns a `zero` instance diff --git a/pkg/simple/client/sonarqube/options.go b/pkg/simple/client/sonarqube/options.go index ec264aeb9..94d5183b7 100644 --- a/pkg/simple/client/sonarqube/options.go +++ b/pkg/simple/client/sonarqube/options.go @@ -21,8 +21,8 @@ import ( ) type Options struct { - Host string `json:",omitempty" yaml:"host" description:"SonarQube service host address"` - Token string `json:",omitempty" yaml:"token" description:"SonarQube service token"` + Host string `json:",omitempty" yaml:"host,omitempty" description:"SonarQube service host address"` + Token string `json:",omitempty" yaml:"token,omitempty" description:"SonarQube service token"` } func NewSonarQubeOptions() *Options {