// CheckGlobalVarFlags checks if the global flags are valid
353232
func CheckGlobalVarFlags() []error {
	fmt.Fprint(os.Stdout, "   ↳ checking flags from global vars\n")
	errors := []error{}
	pflag.CommandLine.VisitAll(func(f *pflag.Flag) {
		errors = append(errors, fmt.Errorf("flag %q is invalid, please don't register any flag under the global variable \"CommandLine\"", f.Name))
	})
	return errors
}
1019747
func registerFlags(c *cli.Config, f *flag.FlagSet) {
	f.StringVar(&c.CertFile, "cert", "", "Client certificate that contains the public key")
	f.StringVar(&c.Domain, "domain", "", "remote server domain name")
	f.StringVar(&c.Serial, "serial", "", "certificate serial number")
	f.StringVar(&c.AKI, "aki", "", "certificate issuer (authority) key identifier")
	f.StringVar(&c.DBConfigFile, "db-config", "", "certificate db configuration file")
}
850077
func (a App) HasFlags() bool {
	return a.Flags != nil && len(a.Flags) > 0
}
907352
func (cmd *connectCmd) validateFlags(c context.Context) error {
	switch {
	case cmd.dir == "":
		return errors.New("-dir is required")
	// TODO(crbug/945063): Remove -server.
	case cmd.provider == "" && cmd.server == "":
		return errors.New("-provider or -server is required")
	case cmd.user == "":
		return errors.New("-user is required")
	}
	return nil
}
784477
func GetFlags() []pcli.Flag {
	boshdefaults := boshinit.GetVSphereDefaults()

	boshFlags := boshinit.BoshFlags(boshdefaults)
	vsphereFlags := []pcli.Flag{
		// vsphere specific flags
		pcli.CreateStringFlag("vsphere-address", "IP of the vCenter"),
		pcli.CreateStringFlag("vsphere-user", "vSphere user"),
		pcli.CreateStringFlag("vsphere-password", "vSphere user's password"),
		pcli.CreateStringFlag("vsphere-datacenter-name", "name of the datacenter the Director will use for VM creation"),
		pcli.CreateStringFlag("vsphere-vm-folder", "name of the folder created to hold VMs"),
		pcli.CreateStringFlag("vsphere-template-folder", "the name of the folder created to hold stemcells"),
		pcli.CreateStringFlag("vsphere-datastore", "name of the datastore the Director will use for storing VMs"),
		pcli.CreateStringFlag("vsphere-disk-path", "name of the VMs folder, disk folder will be automatically created in the chosen datastore."),
		pcli.CreateStringSliceFlag("vsphere-clusters", "one or more vSphere datacenter cluster names"),
		pcli.CreateStringSliceFlag("vsphere-resource-pool", "Name of resource pool for vsphere cluster"),
		// vsphere subnet1 flags
		pcli.CreateStringFlag("vsphere-subnet1-name", "name of the vSphere network for subnet1"),
		pcli.CreateStringFlag("vsphere-subnet1-range", "CIDR range for subnet1"),
		pcli.CreateStringFlag("vsphere-subnet1-gateway", "IP of the default gateway for subnet1"),
		pcli.CreateStringSliceFlag("vsphere-subnet1-dns", "IP of the DNS server(s) for subnet1"),
	}
	for _, flag := range vsphereFlags {
		boshFlags = append(boshFlags, flag)
	}
	return boshFlags
}
305676
func FindGlobal(key string) *Global {
	collections.globalMutex.Lock()
	defer collections.globalMutex.Unlock()

	obj := collections.globals[key]
	if obj == nil {
		return nil
	}

	return obj
}
16650
func (c *Context) GlobalUint(name string) uint {
	if fs := lookupGlobalFlagSet(name, c); fs != nil {
		return lookupUint(name, fs)
	}
	return 0
}
908307
func (o *DebuggingOptions) AddFlags(fs *pflag.FlagSet) {
	if o == nil {
		return
	}

	fs.BoolVar(&o.EnableProfiling, "profiling", o.EnableProfiling,
		"Enable profiling via web interface host:port/debug/pprof/")
	fs.BoolVar(&o.EnableContentionProfiling, "contention-profiling", o.EnableContentionProfiling,
		"Enable lock contention profiling, if profiling is enabled")
}
308739
func (c *Context) GlobalBoolT(name string) bool {
	if fs := lookupGlobalFlagSet(name, c); fs != nil {
		return lookupBoolT(name, fs)
	}
	return false
}
1328721
func (c *Context) GlobalBool(name string) bool {
	if fs := lookupGlobalFlagSet(name, c); fs != nil {
		return lookupBool(name, fs)
	}
	return false
}
955392
func (s *Plugin) GetFlags() []pcli.Flag {

	flags := cloudconfigs.CreateAZFlags()
	flags = cloudconfigs.CreateNetworkFlags(flags, networkFlags)
	flags = append(flags, pcli.CreateStringSliceFlag("aws-availablity-zone", "aws availablility zone"))
	return flags
}
912809
func (c *RFCCommand) VisitAllFlags(fn func(*flag.Flag)) {
	c.flags.VisitAll(fn)
}
697439
func ValidateGlobal(obj *Global) error {
	collections.globalMutex.Lock()
	defer collections.globalMutex.Unlock()

	// Validate key is correct
	keyStr := obj.Name
	if obj.Key != keyStr {
		log.Errorf("Expecting Global Key: %s. Got: %s", keyStr, obj.Key)
		return errors.New("Invalid Key")
	}

	// Validate each field

	if len(obj.ArpMode) > 64 {
		return errors.New("arpMode string too long")
	}

	arpModeMatch := regexp.MustCompile("^(proxy|flood)?$")
	if arpModeMatch.MatchString(obj.ArpMode) == false {
		return errors.New("arpMode string invalid format")
	}

	if len(obj.FwdMode) > 64 {
		return errors.New("fwdMode string too long")
	}

	fwdModeMatch := regexp.MustCompile("^(bridge|routing)?$")
	if fwdModeMatch.MatchString(obj.FwdMode) == false {
		return errors.New("fwdMode string invalid format")
	}

	if len(obj.Name) > 64 {
		return errors.New("name string too long")
	}

	nameMatch := regexp.MustCompile("^(global)$")
	if nameMatch.MatchString(obj.Name) == false {
		return errors.New("name string invalid format")
	}

	if len(obj.NetworkInfraType) > 64 {
		return errors.New("networkInfraType string too long")
	}

	networkInfraTypeMatch := regexp.MustCompile("^(aci|aci-opflex|default)?$")
	if networkInfraTypeMatch.MatchString(obj.NetworkInfraType) == false {
		return errors.New("networkInfraType string invalid format")
	}

	pvtSubnetMatch := regexp.MustCompile("^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])(\\.(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])){3})/16$")
	if pvtSubnetMatch.MatchString(obj.PvtSubnet) == false {
		return errors.New("pvtSubnet string invalid format")
	}

	vlansMatch := regexp.MustCompile("^([0-9]{1,4}?-[0-9]{1,4}?)$")
	if vlansMatch.MatchString(obj.Vlans) == false {
		return errors.New("vlans string invalid format")
	}

	vxlansMatch := regexp.MustCompile("^([0-9]{1,8}?-[0-9]{1,8}?)$")
	if vxlansMatch.MatchString(obj.Vxlans) == false {
		return errors.New("vxlans string invalid format")
	}

	return nil
}
1060206
func cflags(p *Package, def bool) (cppflags, cflags, cxxflags, ldflags []string) {
	var defaults string
	if def {
		defaults = "-g -O2"
	}

	cppflags = stringList(envList("CGO_CPPFLAGS", ""), p.CgoCPPFLAGS)
	cflags = stringList(envList("CGO_CFLAGS", defaults), p.CgoCFLAGS)
	cxxflags = stringList(envList("CGO_CXXFLAGS", defaults), p.CgoCXXFLAGS)
	ldflags = stringList(envList("CGO_LDFLAGS", defaults), p.CgoLDFLAGS)
	return
}
1260514
func (c *Context) GlobalStringSlice(name string) []string {
	if fs := lookupGlobalFlagSet(name, c); fs != nil {
		return lookupStringSlice(name, fs)
	}
	return nil
}
1100491
func newFlagSetWithGlobals() *pflag.FlagSet {
	fs := pflag.NewFlagSet("", pflag.ExitOnError)
	// set the normalize func, similar to k8s.io/component-base/cli//flags.go:InitFlags
	fs.SetNormalizeFunc(cliflag.WordSepNormalizeFunc)
	// explicitly add flags from libs that register global flags
	options.AddGlobalFlags(fs)
	return fs
}
814013
func isGlobalArg(arg string) bool {
	prefixes := []string{
		"--endpoint=",
		"--etcd-key-prefix=",
		"--etcd-keyfile=",
		"--etcd-certfile=",
		"--etcd-cafile=",
		// "--experimental-api=",
		"--known-hosts-file=",
		"--request-timeout=",
		"--ssh-timeout=",
		"--strict-host-key-checking=",
		"--tunnel=",
	}
	for _, p := range prefixes {
		if strings.HasPrefix(arg, p) {
			return true
		}
	}
	return false
}