-
Notifications
You must be signed in to change notification settings - Fork 82
/
options.go
47 lines (40 loc) · 1.25 KB
/
options.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package framework
import (
"flag"
"k8s.io/client-go/tools/clientcmd"
)
func init() {
globalOptions.BindFlags()
flag.Parse()
if err := globalOptions.Validate(); err != nil {
panic(err)
}
}
var globalOptions Options
type Options struct {
KubeConfig string
ClusterName string
AWSRegion string
AWSVPCID string
}
func (options *Options) BindFlags() {
flag.StringVar(&options.KubeConfig, clientcmd.RecommendedConfigPathFlag, "", "Path to kubeconfig containing embedded authinfo (required)")
flag.StringVar(&options.ClusterName, "cluster-name", "", `Kubernetes cluster name (required)`)
flag.StringVar(&options.AWSRegion, "aws-region", "", `AWS Region for the kubernetes cluster`)
flag.StringVar(&options.AWSVPCID, "aws-vpc-id", "", `AWS VPC ID for the kubernetes cluster`)
}
func (options *Options) Validate() error {
// if len(options.KubeConfig) == 0 {
// return fmt.Errorf("%s must be set!", clientcmd.RecommendedConfigPathFlag)
// }
// if len(options.ClusterName) == 0 {
// return fmt.Errorf("%s must be set!", "cluster-name")
// }
// if len(options.AWSRegion) == 0 {
// return fmt.Errorf("%s must be set!", "aws-region")
// }
// if len(options.AWSVPCID) == 0 {
// return errors.Errorf("%s must be set!", "aws-vpc-id")
// }
return nil
}