github.com/oam-dev/cluster-gateway@v1.9.0/pkg/config/args_clusterproxy.go (about) 1 package config 2 3 import ( 4 "github.com/pkg/errors" 5 "github.com/spf13/pflag" 6 ) 7 8 var ClusterProxyHost string 9 var ClusterProxyPort int 10 var ClusterProxyCAFile string 11 var ClusterProxyCertFile string 12 var ClusterProxyKeyFile string 13 14 func ValidateClusterProxy() error { 15 if len(ClusterProxyHost) == 0 { 16 return nil 17 } 18 if ClusterProxyPort == 0 { 19 return errors.New("--proxy-port must be greater than 0") 20 } 21 if len(ClusterProxyCAFile) == 0 { 22 return errors.New("--proxy-ca-cert must be specified") 23 } 24 if len(ClusterProxyCertFile) == 0 { 25 return errors.New("--proxy-cert must be specified") 26 } 27 if len(ClusterProxyKeyFile) == 0 { 28 return errors.New("--proxy-key must be specified") 29 } 30 return nil 31 } 32 33 func AddClusterProxyFlags(set *pflag.FlagSet) { 34 set.StringVarP(&ClusterProxyHost, "proxy-host", "", "", 35 "the host of the cluster proxy endpoint") 36 set.IntVarP(&ClusterProxyPort, "proxy-port", "", 8090, 37 "the port of the cluster proxy endpoint") 38 set.StringVarP(&ClusterProxyCAFile, "proxy-ca-cert", "", "", 39 "the path to ca file for connecting cluster proxy") 40 set.StringVarP(&ClusterProxyCertFile, "proxy-cert", "", "", 41 "the path to tls cert for connecting cluster proxy") 42 set.StringVarP(&ClusterProxyKeyFile, "proxy-key", "", "", 43 "the path to tls key for connecting cluster proxy") 44 }