github.com/cilium/cilium@v1.16.2/api/v1/models/endpoint_configuration_spec.go (about)

     1  // Code generated by go-swagger; DO NOT EDIT.
     2  
     3  // Copyright Authors of Cilium
     4  // SPDX-License-Identifier: Apache-2.0
     5  
     6  package models
     7  
     8  // This file was generated by the swagger tool.
     9  // Editing this file might prove futile when you re-run the swagger generate command
    10  
    11  import (
    12  	"context"
    13  
    14  	"github.com/go-openapi/errors"
    15  	"github.com/go-openapi/strfmt"
    16  	"github.com/go-openapi/swag"
    17  )
    18  
    19  // EndpointConfigurationSpec An endpoint's configuration
    20  //
    21  // swagger:model EndpointConfigurationSpec
    22  type EndpointConfigurationSpec struct {
    23  
    24  	// the endpoint's labels
    25  	LabelConfiguration *LabelConfigurationSpec `json:"label-configuration,omitempty"`
    26  
    27  	// Changeable configuration
    28  	Options ConfigurationMap `json:"options,omitempty"`
    29  }
    30  
    31  // Validate validates this endpoint configuration spec
    32  func (m *EndpointConfigurationSpec) Validate(formats strfmt.Registry) error {
    33  	var res []error
    34  
    35  	if err := m.validateLabelConfiguration(formats); err != nil {
    36  		res = append(res, err)
    37  	}
    38  
    39  	if err := m.validateOptions(formats); err != nil {
    40  		res = append(res, err)
    41  	}
    42  
    43  	if len(res) > 0 {
    44  		return errors.CompositeValidationError(res...)
    45  	}
    46  	return nil
    47  }
    48  
    49  func (m *EndpointConfigurationSpec) validateLabelConfiguration(formats strfmt.Registry) error {
    50  	if swag.IsZero(m.LabelConfiguration) { // not required
    51  		return nil
    52  	}
    53  
    54  	if m.LabelConfiguration != nil {
    55  		if err := m.LabelConfiguration.Validate(formats); err != nil {
    56  			if ve, ok := err.(*errors.Validation); ok {
    57  				return ve.ValidateName("label-configuration")
    58  			} else if ce, ok := err.(*errors.CompositeError); ok {
    59  				return ce.ValidateName("label-configuration")
    60  			}
    61  			return err
    62  		}
    63  	}
    64  
    65  	return nil
    66  }
    67  
    68  func (m *EndpointConfigurationSpec) validateOptions(formats strfmt.Registry) error {
    69  	if swag.IsZero(m.Options) { // not required
    70  		return nil
    71  	}
    72  
    73  	if m.Options != nil {
    74  		if err := m.Options.Validate(formats); err != nil {
    75  			if ve, ok := err.(*errors.Validation); ok {
    76  				return ve.ValidateName("options")
    77  			} else if ce, ok := err.(*errors.CompositeError); ok {
    78  				return ce.ValidateName("options")
    79  			}
    80  			return err
    81  		}
    82  	}
    83  
    84  	return nil
    85  }
    86  
    87  // ContextValidate validate this endpoint configuration spec based on the context it is used
    88  func (m *EndpointConfigurationSpec) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
    89  	var res []error
    90  
    91  	if err := m.contextValidateLabelConfiguration(ctx, formats); err != nil {
    92  		res = append(res, err)
    93  	}
    94  
    95  	if err := m.contextValidateOptions(ctx, formats); err != nil {
    96  		res = append(res, err)
    97  	}
    98  
    99  	if len(res) > 0 {
   100  		return errors.CompositeValidationError(res...)
   101  	}
   102  	return nil
   103  }
   104  
   105  func (m *EndpointConfigurationSpec) contextValidateLabelConfiguration(ctx context.Context, formats strfmt.Registry) error {
   106  
   107  	if m.LabelConfiguration != nil {
   108  
   109  		if swag.IsZero(m.LabelConfiguration) { // not required
   110  			return nil
   111  		}
   112  
   113  		if err := m.LabelConfiguration.ContextValidate(ctx, formats); err != nil {
   114  			if ve, ok := err.(*errors.Validation); ok {
   115  				return ve.ValidateName("label-configuration")
   116  			} else if ce, ok := err.(*errors.CompositeError); ok {
   117  				return ce.ValidateName("label-configuration")
   118  			}
   119  			return err
   120  		}
   121  	}
   122  
   123  	return nil
   124  }
   125  
   126  func (m *EndpointConfigurationSpec) contextValidateOptions(ctx context.Context, formats strfmt.Registry) error {
   127  
   128  	if swag.IsZero(m.Options) { // not required
   129  		return nil
   130  	}
   131  
   132  	if err := m.Options.ContextValidate(ctx, formats); err != nil {
   133  		if ve, ok := err.(*errors.Validation); ok {
   134  			return ve.ValidateName("options")
   135  		} else if ce, ok := err.(*errors.CompositeError); ok {
   136  			return ce.ValidateName("options")
   137  		}
   138  		return err
   139  	}
   140  
   141  	return nil
   142  }
   143  
   144  // MarshalBinary interface implementation
   145  func (m *EndpointConfigurationSpec) MarshalBinary() ([]byte, error) {
   146  	if m == nil {
   147  		return nil, nil
   148  	}
   149  	return swag.WriteJSON(m)
   150  }
   151  
   152  // UnmarshalBinary interface implementation
   153  func (m *EndpointConfigurationSpec) UnmarshalBinary(b []byte) error {
   154  	var res EndpointConfigurationSpec
   155  	if err := swag.ReadJSON(b, &res); err != nil {
   156  		return err
   157  	}
   158  	*m = res
   159  	return nil
   160  }