K-EXPLORER: support --insecure-skip-tls-verify like kubectl

This commit is contained in:
niusmallnan 2022-07-22 15:39:00 +08:00
parent 62d6de019d
commit e56abbdc81

View File

@ -14,11 +14,12 @@ import (
) )
type Config struct { type Config struct {
KubeConfig string KubeConfig string
Context string Context string
HTTPSListenPort int HTTPSListenPort int
HTTPListenPort int HTTPListenPort int
UIPath string UIPath string
InsecureSkipTLSVerify bool
WebhookConfig authcli.WebhookConfig WebhookConfig authcli.WebhookConfig
} }
@ -42,6 +43,13 @@ func (c *Config) ToServer(ctx context.Context) (*server.Server, error) {
} }
restConfig.RateLimiter = ratelimit.None restConfig.RateLimiter = ratelimit.None
// K-EXPLORER
restConfig.Insecure = c.InsecureSkipTLSVerify
if restConfig.Insecure {
restConfig.CAData = nil
restConfig.CAFile = ""
}
if c.WebhookConfig.WebhookAuthentication { if c.WebhookConfig.WebhookAuthentication {
auth, err = c.WebhookConfig.WebhookMiddleware() auth, err = c.WebhookConfig.WebhookMiddleware()
if err != nil { if err != nil {
@ -84,6 +92,10 @@ func Flags(config *Config) []cli.Flag {
Value: 9080, Value: 9080,
Destination: &config.HTTPListenPort, Destination: &config.HTTPListenPort,
}, },
cli.BoolFlag{
Name: "insecure-skip-tls-verify",
Destination: &config.InsecureSkipTLSVerify,
},
} }
return append(flags, authcli.Flags(&config.WebhookConfig)...) return append(flags, authcli.Flags(&config.WebhookConfig)...)