// Validate a netprofile object
765829
func ValidateNetprofile(obj *Netprofile) error {
	collections.netprofileMutex.Lock()
	defer collections.netprofileMutex.Unlock()

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

	// Validate each field

	if obj.DSCP == 0 {
		obj.DSCP = 0
	}

	if obj.DSCP > 63 {
		return errors.New("DSCP Value Out of bound")
	}

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

	bandwidthMatch := regexp.MustCompile("^([1-9][0-9]* (([kmgKMG{1}]bps)|[kmgKMG{1}]|(kb|Kb|Gb|gb|Mb|mb)))?$|^([1-9][0-9]*(((k|m|g|K|G|M)bps)|(k|m|g|K|M|G)|(kb|Kb|Gb|gb|Mb|mb)))?$")
	if bandwidthMatch.MatchString(obj.Bandwidth) == false {
		return errors.New("bandwidth string invalid format")
	}

	if obj.Burst > 10486 {
		return errors.New("burst Value Out of bound")
	}

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

	return nil
}
317445
func httpGetNetprofile(w http.ResponseWriter, r *http.Request, vars map[string]string) (interface{}, error) {
	log.Debugf("Received httpGetNetprofile: %+v", vars)

	key := vars["key"]

	collections.netprofileMutex.Lock()
	defer collections.netprofileMutex.Unlock()
	obj := collections.netprofiles[key]
	if obj == nil {
		log.Infof("netprofile %s not found", key)
		return nil, errors.New("netprofile not found")
	}

	// Return the obj
	return obj, nil
}
559402
func (config Config) Validate() error {
	if config.Agent == nil {
		return errors.NotValidf("nil Agent")
	}
	if config.Facade == nil {
		return errors.NotValidf("nil Facade")
	}
	if config.Guard == nil {
		return errors.NotValidf("nil Guard")
	}
	if config.APIOpen == nil {
		return errors.NotValidf("nil APIOpen")
	}
	if config.ValidateMigration == nil {
		return errors.NotValidf("nil ValidateMigration")
	}
	return nil
}
1179776
func (m *GrpcService_GoogleGrpc_CallCredentials_MetadataCredentialsFromPlugin) Validate() error {
	if m == nil {
		return nil
	}

	// no validation rules for Name

	switch m.ConfigType.(type) {

	case *GrpcService_GoogleGrpc_CallCredentials_MetadataCredentialsFromPlugin_Config:

		{
			tmp := m.GetConfig()

			if v, ok := interface{}(tmp).(interface{ Validate() error }); ok {

				if err := v.Validate(); err != nil {
					return GrpcService_GoogleGrpc_CallCredentials_MetadataCredentialsFromPluginValidationError{
						field:  "Config",
						reason: "embedded message failed validation",
						cause:  err,
					}
				}
			}
		}

	case *GrpcService_GoogleGrpc_CallCredentials_MetadataCredentialsFromPlugin_TypedConfig:

		{
			tmp := m.GetTypedConfig()

			if v, ok := interface{}(tmp).(interface{ Validate() error }); ok {

				if err := v.Validate(); err != nil {
					return GrpcService_GoogleGrpc_CallCredentials_MetadataCredentialsFromPluginValidationError{
						field:  "TypedConfig",
						reason: "embedded message failed validation",
						cause:  err,
					}
				}
			}
		}

	}

	return nil
}
727169
func (c *Config) Validate() error {
	var result *multierror.Error

	if c.PoolName == "" {
		result = multierror.Append(result, fmt.Errorf("pool_name is required"))
	}

	if c.RootPath == "" {
		result = multierror.Append(result, fmt.Errorf("root_path is required"))
	}

	if c.BaseImageSize == "" {
		result = multierror.Append(result, fmt.Errorf("base_image_size is required"))
	}

	return result.ErrorOrNil()
}
715209
func httpCreateNetprofile(w http.ResponseWriter, r *http.Request, vars map[string]string) (interface{}, error) {
	log.Debugf("Received httpGetNetprofile: %+v", vars)

	var obj Netprofile
	key := vars["key"]

	// Get object from the request
	err := json.NewDecoder(r.Body).Decode(&obj)
	if err != nil {
		log.Errorf("Error decoding netprofile create request. Err %v", err)
		return nil, err
	}

	// set the key
	obj.Key = key

	// Create the object
	err = CreateNetprofile(&obj)
	if err != nil {
		log.Errorf("CreateNetprofile error for: %+v. Err: %v", obj, err)
		return nil, err
	}

	// Return the obj
	return obj, nil
}
1033670
func ValidateNetworkPolicy(np *networking.NetworkPolicy) field.ErrorList {
	allErrs := apivalidation.ValidateObjectMeta(&np.ObjectMeta, true, ValidateNetworkPolicyName, field.NewPath("metadata"))
	allErrs = append(allErrs, ValidateNetworkPolicySpec(&np.Spec, field.NewPath("spec"))...)
	return allErrs
}
225934
func (config Config) Validate() error {
	if config.ModelWatcher == nil {
		return errors.NotValidf("nil ModelWatcher")
	}
	if config.ModelGetter == nil {
		return errors.NotValidf("nil ModelGetter")
	}
	if config.NewModelWorker == nil {
		return errors.NotValidf("nil NewModelWorker")
	}
	if config.ErrorDelay <= 0 {
		return errors.NotValidf("non-positive ErrorDelay")
	}
	return nil
}
904339
func (s profileService) DefineProfile(request *Profile) (*ProfileResponse, error) {
	var response ProfileResponse
	req, err := s.client.NewRequest("POST", defineProfilePath, request)
	if err != nil {
		return nil, err
	}
	err = s.client.Do(req, &response)
	if err != nil {
		return nil, err
	}
	return &response, nil
}
553933
func ValidateNetworkOptions(binary string, ctx *cli.Context) (*NetworkConfigs, error) {
	// 1. validate and set plugin mode
	pluginMode := strings.ToLower(ctx.String("mode"))
	switch pluginMode {
	case core.Docker, core.Kubernetes, core.SwarmMode, core.Test:
		logrus.Infof("Using %s mode: %v", binary, pluginMode)
	case "":
		return nil, fmt.Errorf("%s mode is not set", binary)
	default:
		return nil, fmt.Errorf("unknown %s mode: %v", binary, pluginMode)
	}

	// 2. validate and set network mode
	networkMode := strings.ToLower(ctx.String("netmode"))
	switch networkMode {
	case "vlan", "vxlan":
		logrus.Infof("Using %s network mode: %v", binary, networkMode)
	case "":
		return nil, fmt.Errorf("%s network mode is not set", binary)
	default:
		return nil, fmt.Errorf("unknown %s network mode: %v", binary, networkMode)
	}

	// 3. validate forwarding mode
	forwardMode := strings.ToLower(ctx.String("fwdmode"))
	if forwardMode == "" {
		return nil, fmt.Errorf("unknown %s forwarding mode: %v", binary, forwardMode)
	} else if forwardMode != "bridge" && forwardMode != "routing" {
		return nil, fmt.Errorf("%s forwarding mode is not set", binary)
	} else if networkMode == "vxlan" && forwardMode == "bridge" {
		return nil, fmt.Errorf("invalid %s forwarding mode: %q (network mode: %q)", binary, forwardMode, networkMode)
	}
	// vxlan/vlan+routing, vlan+bridge are valid combinations
	logrus.Infof("Using %s forwarding mode: %v", binary, forwardMode)
	return &NetworkConfigs{
		Mode:        pluginMode,
		NetworkMode: networkMode,
		ForwardMode: forwardMode,
	}, nil
}
1017003
func (sdnStrategy) Validate(ctx context.Context, obj runtime.Object) field.ErrorList {
	return validation.ValidateNetNamespace(obj.(*networkapi.NetNamespace))
}
507242
func FindNetprofile(key string) *Netprofile {
	collections.netprofileMutex.Lock()
	defer collections.netprofileMutex.Unlock()

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

	return obj
}
642856
func (o *Enterprise) NetconfProfiles(info *bambou.FetchingInfo) (NetconfProfilesList, *bambou.Error) {

	var list NetconfProfilesList
	err := bambou.CurrentSession().FetchChildren(o, NetconfProfileIdentity, &list, info)
	return list, err
}
749663
func ValidateAppProfile(obj *AppProfile) error {
	collections.appProfileMutex.Lock()
	defer collections.appProfileMutex.Unlock()

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

	// Validate each field

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

	appProfileNameMatch := regexp.MustCompile("^(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\\-]*[a-zA-Z0-9])\\.)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9\\-]*[A-Za-z0-9])$")
	if appProfileNameMatch.MatchString(obj.AppProfileName) == false {
		return errors.New("appProfileName string invalid format")
	}

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

	tenantNameMatch := regexp.MustCompile("^(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\\-]*[a-zA-Z0-9])\\.)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9\\-]*[A-Za-z0-9])$")
	if tenantNameMatch.MatchString(obj.TenantName) == false {
		return errors.New("tenantName string invalid format")
	}

	return nil
}
1054540
func (config Config) Validate() error {
	if config.Facade == nil {
		return errors.NotValidf("nil Facade")
	}
	if config.GateUnlocker == nil {
		return errors.NotValidf("nil GateUnlocker")
	}
	if config.ControllerTag == (names.ControllerTag{}) {
		return errors.NotValidf("empty ControllerTag")
	}
	if config.ModelTag == (names.ModelTag{}) {
		return errors.NotValidf("empty ModelTag")
	}
	if config.CredentialAPI == nil {
		return errors.NotValidf("nil CredentialAPI")
	}
	return nil
}
992758
func (m *LabelConfigurationSpec) Validate(formats strfmt.Registry) error {
	var res []error

	if err := m.validateUser(formats); err != nil {
		res = append(res, err)
	}

	if len(res) > 0 {
		return errors.CompositeValidationError(res...)
	}
	return nil
}
100843
func (config Config) Validate() error {
	if config.Facade == nil {
		return errors.NotValidf("nil Facade")
	}
	if config.GateUnlocker == nil {
		return errors.NotValidf("nil GateUnlocker")
	}
	if config.ModelTag == (names.ModelTag{}) {
		return errors.NotValidf("empty ModelTag")
	}
	return nil
}