github.com/cilium/cilium@v1.16.2/api/v1/models/routing.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  	"encoding/json"
    14  
    15  	"github.com/go-openapi/errors"
    16  	"github.com/go-openapi/strfmt"
    17  	"github.com/go-openapi/swag"
    18  	"github.com/go-openapi/validate"
    19  )
    20  
    21  // Routing Status of routing
    22  //
    23  // +k8s:deepcopy-gen=true
    24  //
    25  // swagger:model Routing
    26  type Routing struct {
    27  
    28  	// Datapath routing mode for cross-cluster connectivity
    29  	// Enum: [Native Tunnel]
    30  	InterHostRoutingMode string `json:"inter-host-routing-mode,omitempty"`
    31  
    32  	// Datapath routing mode for connectivity within the host
    33  	// Enum: [BPF Legacy]
    34  	IntraHostRoutingMode string `json:"intra-host-routing-mode,omitempty"`
    35  
    36  	// Tunnel protocol in use for cross-cluster connectivity
    37  	TunnelProtocol string `json:"tunnel-protocol,omitempty"`
    38  }
    39  
    40  // Validate validates this routing
    41  func (m *Routing) Validate(formats strfmt.Registry) error {
    42  	var res []error
    43  
    44  	if err := m.validateInterHostRoutingMode(formats); err != nil {
    45  		res = append(res, err)
    46  	}
    47  
    48  	if err := m.validateIntraHostRoutingMode(formats); err != nil {
    49  		res = append(res, err)
    50  	}
    51  
    52  	if len(res) > 0 {
    53  		return errors.CompositeValidationError(res...)
    54  	}
    55  	return nil
    56  }
    57  
    58  var routingTypeInterHostRoutingModePropEnum []interface{}
    59  
    60  func init() {
    61  	var res []string
    62  	if err := json.Unmarshal([]byte(`["Native","Tunnel"]`), &res); err != nil {
    63  		panic(err)
    64  	}
    65  	for _, v := range res {
    66  		routingTypeInterHostRoutingModePropEnum = append(routingTypeInterHostRoutingModePropEnum, v)
    67  	}
    68  }
    69  
    70  const (
    71  
    72  	// RoutingInterHostRoutingModeNative captures enum value "Native"
    73  	RoutingInterHostRoutingModeNative string = "Native"
    74  
    75  	// RoutingInterHostRoutingModeTunnel captures enum value "Tunnel"
    76  	RoutingInterHostRoutingModeTunnel string = "Tunnel"
    77  )
    78  
    79  // prop value enum
    80  func (m *Routing) validateInterHostRoutingModeEnum(path, location string, value string) error {
    81  	if err := validate.EnumCase(path, location, value, routingTypeInterHostRoutingModePropEnum, true); err != nil {
    82  		return err
    83  	}
    84  	return nil
    85  }
    86  
    87  func (m *Routing) validateInterHostRoutingMode(formats strfmt.Registry) error {
    88  	if swag.IsZero(m.InterHostRoutingMode) { // not required
    89  		return nil
    90  	}
    91  
    92  	// value enum
    93  	if err := m.validateInterHostRoutingModeEnum("inter-host-routing-mode", "body", m.InterHostRoutingMode); err != nil {
    94  		return err
    95  	}
    96  
    97  	return nil
    98  }
    99  
   100  var routingTypeIntraHostRoutingModePropEnum []interface{}
   101  
   102  func init() {
   103  	var res []string
   104  	if err := json.Unmarshal([]byte(`["BPF","Legacy"]`), &res); err != nil {
   105  		panic(err)
   106  	}
   107  	for _, v := range res {
   108  		routingTypeIntraHostRoutingModePropEnum = append(routingTypeIntraHostRoutingModePropEnum, v)
   109  	}
   110  }
   111  
   112  const (
   113  
   114  	// RoutingIntraHostRoutingModeBPF captures enum value "BPF"
   115  	RoutingIntraHostRoutingModeBPF string = "BPF"
   116  
   117  	// RoutingIntraHostRoutingModeLegacy captures enum value "Legacy"
   118  	RoutingIntraHostRoutingModeLegacy string = "Legacy"
   119  )
   120  
   121  // prop value enum
   122  func (m *Routing) validateIntraHostRoutingModeEnum(path, location string, value string) error {
   123  	if err := validate.EnumCase(path, location, value, routingTypeIntraHostRoutingModePropEnum, true); err != nil {
   124  		return err
   125  	}
   126  	return nil
   127  }
   128  
   129  func (m *Routing) validateIntraHostRoutingMode(formats strfmt.Registry) error {
   130  	if swag.IsZero(m.IntraHostRoutingMode) { // not required
   131  		return nil
   132  	}
   133  
   134  	// value enum
   135  	if err := m.validateIntraHostRoutingModeEnum("intra-host-routing-mode", "body", m.IntraHostRoutingMode); err != nil {
   136  		return err
   137  	}
   138  
   139  	return nil
   140  }
   141  
   142  // ContextValidate validates this routing based on context it is used
   143  func (m *Routing) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
   144  	return nil
   145  }
   146  
   147  // MarshalBinary interface implementation
   148  func (m *Routing) MarshalBinary() ([]byte, error) {
   149  	if m == nil {
   150  		return nil, nil
   151  	}
   152  	return swag.WriteJSON(m)
   153  }
   154  
   155  // UnmarshalBinary interface implementation
   156  func (m *Routing) UnmarshalBinary(b []byte) error {
   157  	var res Routing
   158  	if err := swag.ReadJSON(b, &res); err != nil {
   159  		return err
   160  	}
   161  	*m = res
   162  	return nil
   163  }