github.com/kubearmor/cilium@v1.6.12/api/v1/models/label_configuration.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  	strfmt "github.com/go-openapi/strfmt"
    10  
    11  	"github.com/go-openapi/errors"
    12  	"github.com/go-openapi/swag"
    13  )
    14  
    15  // LabelConfiguration Label configuration of an endpoint
    16  // swagger:model LabelConfiguration
    17  type LabelConfiguration struct {
    18  
    19  	// The user provided desired configuration
    20  	Spec *LabelConfigurationSpec `json:"spec,omitempty"`
    21  
    22  	// The current configuration
    23  	Status *LabelConfigurationStatus `json:"status,omitempty"`
    24  }
    25  
    26  // Validate validates this label configuration
    27  func (m *LabelConfiguration) Validate(formats strfmt.Registry) error {
    28  	var res []error
    29  
    30  	if err := m.validateSpec(formats); err != nil {
    31  		res = append(res, err)
    32  	}
    33  
    34  	if err := m.validateStatus(formats); err != nil {
    35  		res = append(res, err)
    36  	}
    37  
    38  	if len(res) > 0 {
    39  		return errors.CompositeValidationError(res...)
    40  	}
    41  	return nil
    42  }
    43  
    44  func (m *LabelConfiguration) validateSpec(formats strfmt.Registry) error {
    45  
    46  	if swag.IsZero(m.Spec) { // not required
    47  		return nil
    48  	}
    49  
    50  	if m.Spec != nil {
    51  		if err := m.Spec.Validate(formats); err != nil {
    52  			if ve, ok := err.(*errors.Validation); ok {
    53  				return ve.ValidateName("spec")
    54  			}
    55  			return err
    56  		}
    57  	}
    58  
    59  	return nil
    60  }
    61  
    62  func (m *LabelConfiguration) validateStatus(formats strfmt.Registry) error {
    63  
    64  	if swag.IsZero(m.Status) { // not required
    65  		return nil
    66  	}
    67  
    68  	if m.Status != nil {
    69  		if err := m.Status.Validate(formats); err != nil {
    70  			if ve, ok := err.(*errors.Validation); ok {
    71  				return ve.ValidateName("status")
    72  			}
    73  			return err
    74  		}
    75  	}
    76  
    77  	return nil
    78  }
    79  
    80  // MarshalBinary interface implementation
    81  func (m *LabelConfiguration) MarshalBinary() ([]byte, error) {
    82  	if m == nil {
    83  		return nil, nil
    84  	}
    85  	return swag.WriteJSON(m)
    86  }
    87  
    88  // UnmarshalBinary interface implementation
    89  func (m *LabelConfiguration) UnmarshalBinary(b []byte) error {
    90  	var res LabelConfiguration
    91  	if err := swag.ReadJSON(b, &res); err != nil {
    92  		return err
    93  	}
    94  	*m = res
    95  	return nil
    96  }