github.com/cilium/cilium@v1.16.2/api/v1/models/attach_mode.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/validate"
    18  )
    19  
    20  // AttachMode Core datapath attachment mode
    21  //
    22  // swagger:model AttachMode
    23  type AttachMode string
    24  
    25  func NewAttachMode(value AttachMode) *AttachMode {
    26  	return &value
    27  }
    28  
    29  // Pointer returns a pointer to a freshly-allocated AttachMode.
    30  func (m AttachMode) Pointer() *AttachMode {
    31  	return &m
    32  }
    33  
    34  const (
    35  
    36  	// AttachModeTc captures enum value "tc"
    37  	AttachModeTc AttachMode = "tc"
    38  
    39  	// AttachModeTcx captures enum value "tcx"
    40  	AttachModeTcx AttachMode = "tcx"
    41  )
    42  
    43  // for schema
    44  var attachModeEnum []interface{}
    45  
    46  func init() {
    47  	var res []AttachMode
    48  	if err := json.Unmarshal([]byte(`["tc","tcx"]`), &res); err != nil {
    49  		panic(err)
    50  	}
    51  	for _, v := range res {
    52  		attachModeEnum = append(attachModeEnum, v)
    53  	}
    54  }
    55  
    56  func (m AttachMode) validateAttachModeEnum(path, location string, value AttachMode) error {
    57  	if err := validate.EnumCase(path, location, value, attachModeEnum, true); err != nil {
    58  		return err
    59  	}
    60  	return nil
    61  }
    62  
    63  // Validate validates this attach mode
    64  func (m AttachMode) Validate(formats strfmt.Registry) error {
    65  	var res []error
    66  
    67  	// value enum
    68  	if err := m.validateAttachModeEnum("", "body", m); err != nil {
    69  		return err
    70  	}
    71  
    72  	if len(res) > 0 {
    73  		return errors.CompositeValidationError(res...)
    74  	}
    75  	return nil
    76  }
    77  
    78  // ContextValidate validates this attach mode based on context it is used
    79  func (m AttachMode) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
    80  	return nil
    81  }