github.com/kubearmor/cilium@v1.6.12/api/v1/models/daemon_configuration_spec.go (about)

     1  // Code generated by go-swagger; DO NOT EDIT.
     2  
     3  package models
     4  
     5  // This file was generated by the swagger tool.
     6  // Editing this file might prove futile when you re-run the swagger generate command
     7  
     8  import (
     9  	"encoding/json"
    10  
    11  	strfmt "github.com/go-openapi/strfmt"
    12  
    13  	"github.com/go-openapi/errors"
    14  	"github.com/go-openapi/swag"
    15  	"github.com/go-openapi/validate"
    16  )
    17  
    18  // DaemonConfigurationSpec The controllable configuration of the daemon.
    19  // swagger:model DaemonConfigurationSpec
    20  type DaemonConfigurationSpec struct {
    21  
    22  	// Changeable configuration
    23  	Options ConfigurationMap `json:"options,omitempty"`
    24  
    25  	// The policy-enforcement mode
    26  	// Enum: [default always never]
    27  	PolicyEnforcement string `json:"policy-enforcement,omitempty"`
    28  }
    29  
    30  // Validate validates this daemon configuration spec
    31  func (m *DaemonConfigurationSpec) Validate(formats strfmt.Registry) error {
    32  	var res []error
    33  
    34  	if err := m.validateOptions(formats); err != nil {
    35  		res = append(res, err)
    36  	}
    37  
    38  	if err := m.validatePolicyEnforcement(formats); err != nil {
    39  		res = append(res, err)
    40  	}
    41  
    42  	if len(res) > 0 {
    43  		return errors.CompositeValidationError(res...)
    44  	}
    45  	return nil
    46  }
    47  
    48  func (m *DaemonConfigurationSpec) validateOptions(formats strfmt.Registry) error {
    49  
    50  	if swag.IsZero(m.Options) { // not required
    51  		return nil
    52  	}
    53  
    54  	if err := m.Options.Validate(formats); err != nil {
    55  		if ve, ok := err.(*errors.Validation); ok {
    56  			return ve.ValidateName("options")
    57  		}
    58  		return err
    59  	}
    60  
    61  	return nil
    62  }
    63  
    64  var daemonConfigurationSpecTypePolicyEnforcementPropEnum []interface{}
    65  
    66  func init() {
    67  	var res []string
    68  	if err := json.Unmarshal([]byte(`["default","always","never"]`), &res); err != nil {
    69  		panic(err)
    70  	}
    71  	for _, v := range res {
    72  		daemonConfigurationSpecTypePolicyEnforcementPropEnum = append(daemonConfigurationSpecTypePolicyEnforcementPropEnum, v)
    73  	}
    74  }
    75  
    76  const (
    77  
    78  	// DaemonConfigurationSpecPolicyEnforcementDefault captures enum value "default"
    79  	DaemonConfigurationSpecPolicyEnforcementDefault string = "default"
    80  
    81  	// DaemonConfigurationSpecPolicyEnforcementAlways captures enum value "always"
    82  	DaemonConfigurationSpecPolicyEnforcementAlways string = "always"
    83  
    84  	// DaemonConfigurationSpecPolicyEnforcementNever captures enum value "never"
    85  	DaemonConfigurationSpecPolicyEnforcementNever string = "never"
    86  )
    87  
    88  // prop value enum
    89  func (m *DaemonConfigurationSpec) validatePolicyEnforcementEnum(path, location string, value string) error {
    90  	if err := validate.Enum(path, location, value, daemonConfigurationSpecTypePolicyEnforcementPropEnum); err != nil {
    91  		return err
    92  	}
    93  	return nil
    94  }
    95  
    96  func (m *DaemonConfigurationSpec) validatePolicyEnforcement(formats strfmt.Registry) error {
    97  
    98  	if swag.IsZero(m.PolicyEnforcement) { // not required
    99  		return nil
   100  	}
   101  
   102  	// value enum
   103  	if err := m.validatePolicyEnforcementEnum("policy-enforcement", "body", m.PolicyEnforcement); err != nil {
   104  		return err
   105  	}
   106  
   107  	return nil
   108  }
   109  
   110  // MarshalBinary interface implementation
   111  func (m *DaemonConfigurationSpec) MarshalBinary() ([]byte, error) {
   112  	if m == nil {
   113  		return nil, nil
   114  	}
   115  	return swag.WriteJSON(m)
   116  }
   117  
   118  // UnmarshalBinary interface implementation
   119  func (m *DaemonConfigurationSpec) UnmarshalBinary(b []byte) error {
   120  	var res DaemonConfigurationSpec
   121  	if err := swag.ReadJSON(b, &res); err != nil {
   122  		return err
   123  	}
   124  	*m = res
   125  	return nil
   126  }