github.com/kubearmor/cilium@v1.6.12/api/v1/models/datapath_mode.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/validate"
    15  )
    16  
    17  // DatapathMode Datapath mode
    18  // swagger:model DatapathMode
    19  type DatapathMode string
    20  
    21  const (
    22  
    23  	// DatapathModeVeth captures enum value "veth"
    24  	DatapathModeVeth DatapathMode = "veth"
    25  
    26  	// DatapathModeIpvlan captures enum value "ipvlan"
    27  	DatapathModeIpvlan DatapathMode = "ipvlan"
    28  )
    29  
    30  // for schema
    31  var datapathModeEnum []interface{}
    32  
    33  func init() {
    34  	var res []DatapathMode
    35  	if err := json.Unmarshal([]byte(`["veth","ipvlan"]`), &res); err != nil {
    36  		panic(err)
    37  	}
    38  	for _, v := range res {
    39  		datapathModeEnum = append(datapathModeEnum, v)
    40  	}
    41  }
    42  
    43  func (m DatapathMode) validateDatapathModeEnum(path, location string, value DatapathMode) error {
    44  	if err := validate.Enum(path, location, value, datapathModeEnum); err != nil {
    45  		return err
    46  	}
    47  	return nil
    48  }
    49  
    50  // Validate validates this datapath mode
    51  func (m DatapathMode) Validate(formats strfmt.Registry) error {
    52  	var res []error
    53  
    54  	// value enum
    55  	if err := m.validateDatapathModeEnum("", "body", m); err != nil {
    56  		return err
    57  	}
    58  
    59  	if len(res) > 0 {
    60  		return errors.CompositeValidationError(res...)
    61  	}
    62  	return nil
    63  }