// validateDatacenters validates the individual datacenter.cfg files referenced in datacenters.cfg.
547584
func validateDatacenters(c *validation.Context, datacenters map[string]*configPB.Datacenter) {
	// Datacenter, rack, and switch names must be unique.
	// Keep records of ones we've already seen.
	names := stringset.New(len(datacenters))
	racks := stringset.New(0)
	switches := stringset.New(0)
	kvms := stringset.New(0)

	for filename, dc := range datacenters {
		c.SetFile(filename)
		switch {
		case dc.Name == "":
			c.Errorf("datacenter names are required and must be non-empty")
		case !names.Add(dc.Name):
			c.Errorf("duplicate datacenter %q", dc.Name)
		}

		c.Enter("datacenter %q", dc.Name)
		for _, rack := range dc.Rack {
			switch {
			case rack.Name == "":
				c.Errorf("rack names are required and must be non-empty")
			case !racks.Add(rack.Name):
				c.Errorf("duplicate rack %q", rack.Name)
			}

			c.Enter("rack %q", rack.Name)
			for _, s := range rack.Switch {
				switch {
				case s.Name == "":
					c.Errorf("switch names are required and must be non-empty")
				case !switches.Add(s.Name):
					c.Errorf("duplicate switch %q", s.Name)
				}

				c.Enter("switch %q", s.Name)
				switch {
				case s.Ports < 1:
					c.Errorf("switches must have at least one port")
				case s.Ports > switchMaxPorts:
					c.Errorf("switches must have at most %d ports", switchMaxPorts)
				}
				c.Exit()
			}
			c.Exit()
		}
		for _, kvm := range dc.Kvm {
			switch {
			case kvm.Name == "":
				c.Errorf("KVM names are required and must be non-empty")
			case !kvms.Add(kvm.Name):
				c.Errorf("duplicate KVM %q", kvm.Name)
			}
			c.Enter("kvm %q", kvm.Name)
			if !racks.Has(kvm.Rack) {
				c.Errorf("rack %q does not exist", kvm.Rack)
			}
			_, err := common.ParseMAC48(kvm.MacAddress)
			if err != nil {
				c.Errorf("invalid MAC-48 address %q", kvm.MacAddress)
			}
			_, err = common.ParseIPv4(kvm.Ipv4)
			if err != nil {
				c.Errorf("invalid IPv4 address %q", kvm.Ipv4)
			}
			c.Exit()
		}
		for _, rack := range dc.Rack {
			if rack.Kvm != "" {
				c.Enter("rack %q", rack.Name)
				if !kvms.Has(rack.Kvm) {
					c.Errorf("KVM %q does not exist", rack.Kvm)
				}
				c.Exit()
			}
		}
		c.Exit()
	}
}
739738
func ValidateConfig(p storage.Provider, cfg *storage.Config) error {
	return p.ValidateConfig(cfg)
}
101504
func ValidateEndpoints(endpoints *api.Endpoints) field.ErrorList {
	allErrs := ValidateObjectMeta(&endpoints.ObjectMeta, true, ValidateEndpointsName, field.NewPath("metadata"))
	allErrs = append(allErrs, validateEndpointSubsets(endpoints.Subsets, field.NewPath("subsets"))...)
	return allErrs
}
384698
func ValidateCapabilities(caps []string) error {
	valids := GetAllCapabilities()
	for _, c := range caps {
		if !inSlice(valids, c) {
			return errdefs.InvalidParameter(fmt.Errorf("unknown capability: %q", c))
		}
	}
	return nil
}
1020996
func ValidateEndpoints(endpoints *core.Endpoints) field.ErrorList {
	allErrs := ValidateObjectMeta(&endpoints.ObjectMeta, true, ValidateEndpointsName, field.NewPath("metadata"))
	allErrs = append(allErrs, ValidateEndpointsSpecificAnnotations(endpoints.Annotations, field.NewPath("annotations"))...)
	allErrs = append(allErrs, validateEndpointSubsets(endpoints.Subsets, field.NewPath("subsets"))...)
	return allErrs
}
1124267
func (r Network_SecurityGroup) GetSupportedDataCenters() (resp []datatypes.Location, err error) {
	err = r.Session.DoRequest("SoftLayer_Network_SecurityGroup", "getSupportedDataCenters", nil, &r.Options, &resp)
	return
}
901168
func (p *Provider) ValidateDataSourceConfig(providers.ValidateDataSourceConfigRequest) providers.ValidateDataSourceConfigResponse {
	// FIXME: move the backend configuration validate call that's currently
	// inside the read method  into here so that we can catch provider configuration
	// errors in terraform validate as well as during terraform plan.
	var res providers.ValidateDataSourceConfigResponse
	return res
}
843373
func ValidateAPIServer(a *kubeadm.APIServer, fldPath *field.Path) field.ErrorList {
	allErrs := field.ErrorList{}
	allErrs = append(allErrs, ValidateCertSANs(a.CertSANs, fldPath.Child("certSANs"))...)
	return allErrs
}
40742
func (vr *validateRun) validateGenerated(ctx context.Context, path string) (*validateResult, error) {
	// -config-set flag must not be used in this mode, config sets are defined
	// on Starlark level.
	if vr.configSet != "" {
		return nil, base.NewCLIError("-config-set can't be used when validating Starlark-based configs")
	}

	meta := vr.DefaultMeta()
	output, err := base.GenerateConfigs(ctx, path, &meta, &vr.Meta)
	if err != nil {
		return nil, err
	}

	result := &validateResult{}

	if meta.ConfigDir != "-" {
		// Find files that are present on disk, but no longer in the output.
		tracked, err := lucicfg.FindTrackedFiles(meta.ConfigDir, meta.TrackedFiles)
		if err != nil {
			return result, err
		}
		for _, f := range tracked {
			if _, present := output.Data[f]; !present {
				result.Stale = append(result.Stale, f)
			}
		}
		// Find files that are newer in the output or do not exist on disk.
		changed, _ := output.Compare(meta.ConfigDir)
		result.Stale = append(result.Stale, changed...)
	}

	if len(result.Stale) != 0 {
		return result, fmt.Errorf(
			"following files on disk are out-of-date: %s.\n"+
				"  Run `lucicfg generate %q` to update them",
			strings.Join(result.Stale, ", "), path)
	}

	// Validate via LUCI Config RPC. This silently skips configs not belonging to
	// any config sets.
	result.Validation, err = base.ValidateOutput(
		ctx,
		output,
		vr.ConfigService,
		meta.ConfigServiceHost,
		meta.FailOnWarnings)
	return result, err
}
1084205
func (t *AvailService) DataCenters() (*AvailDataCentersResponse, error) {
	u := &url.Values{}
	v := AvailDataCentersResponse{}
	if err := t.client.do("avail.datacenters", u, &v.Response); err != nil {
		return nil, err
	}
	v.DataCenters = make([]DataCenter, 5)
	if err := json.Unmarshal(v.RawData, &v.DataCenters); err != nil {
		return nil, err
	}
	return &v, nil
}
293832
func (env *joyentEnviron) ConstraintsValidator(ctx context.ProviderCallContext) (constraints.Validator, error) {
	validator := constraints.NewValidator()
	validator.RegisterUnsupported(unsupportedConstraints)
	packages, err := env.compute.cloudapi.ListPackages(nil)
	if err != nil {
		return nil, err
	}
	instTypeNames := make([]string, len(packages))
	for i, pkg := range packages {
		instTypeNames[i] = pkg.Name
	}
	validator.RegisterVocabulary(constraints.InstanceType, instTypeNames)
	return validator, nil
}
1207872
func ValidateStorageProvider(providerType storage.ProviderType, attributes map[string]interface{}) error {
	switch providerType {
	case K8s_ProviderType:
	case provider.RootfsProviderType:
	case provider.TmpfsProviderType:
	default:
		return errors.NotValidf("storage provider type %q", providerType)
	}
	if attributes == nil {
		return nil
	}
	if mediumValue, ok := attributes[storageMedium]; ok {
		medium := core.StorageMedium(fmt.Sprintf("%v", mediumValue))
		if medium != core.StorageMediumMemory && medium != core.StorageMediumHugePages {
			return errors.NotValidf("storage medium %q", mediumValue)
		}
	}
	if providerType == K8s_ProviderType {
		if _, err := newStorageConfig(attributes); err != nil {
			return errors.Trace(err)
		}
	}
	return nil
}
387419
func validateBundledVersions(bundledVersions SupportedVersions, binDir string) error {
	for _, v := range bundledVersions {
		for _, binaryName := range []string{"etcd", "etcdctl"} {
			fn := filepath.Join(binDir, fmt.Sprintf("%s-%s", binaryName, v))
			if _, err := os.Stat(fn); err != nil {
				return fmt.Errorf("failed to validate '%s' binary exists for bundled-version '%s': %v", fn, v, err)
			}

		}
	}
	return nil
}
650936
func ValidateCertificateDates(cert *x509.Certificate) error {
	if cert == nil {
		return nil
	}
	if time.Now().UTC().Before(cert.NotBefore) {
		return errors.New("Certificate provided is not valid until later date")
	}

	if time.Now().UTC().After(cert.NotAfter) {
		return errors.New("Certificate provided has expired")
	}
	return nil
}
355094
func ValidateDBConfig(cfg DBConfig) error {
	err := vala.BeginValidation().Validate(
		vala.StringNotEmpty(cfg.DB, "db"),
		vala.StringNotEmpty(cfg.User, "user"),
		vala.StringNotEmpty(cfg.Host, "host"),
		vala.Not(vala.Equals(cfg.Port, 0, "port")),
		vala.StringNotEmpty(cfg.DBName, "dbname"),
		vala.StringNotEmpty(cfg.SSLMode, "sslmode"),
	).Check()
	if err != nil {
		return err
	}

	if cfg.DB != "postgres" && cfg.DB != "mysql" {
		return errors.New("not a valid driver name")
	}

	return nil
}
439391
func validateDefaults(ctx *validation.Context, title string, d *admin.ServiceAccountRuleDefaults) {
	ctx.Enter(title)
	defer ctx.Exit()
	validateScopes(ctx, "allowed_scope", d.AllowedScope)
	validateMaxGrantValidityDuration(ctx, d.MaxGrantValidityDuration)
}
409288
func ValidateConfig(ctx *validation.Context, cfg []*config.Settings_SourceAcls) {
	var ACLs ACLs
	ACLs.load(ctx, cfg)
}