github.com/kubearmor/cilium@v1.6.12/api/v1/models/b_p_f_map.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  	"strconv"
    10  
    11  	strfmt "github.com/go-openapi/strfmt"
    12  
    13  	"github.com/go-openapi/errors"
    14  	"github.com/go-openapi/swag"
    15  )
    16  
    17  // BPFMap BPF map definition and content
    18  // swagger:model BPFMap
    19  type BPFMap struct {
    20  
    21  	// Contents of cache
    22  	Cache []*BPFMapEntry `json:"cache"`
    23  
    24  	// Path to BPF map
    25  	Path string `json:"path,omitempty"`
    26  }
    27  
    28  // Validate validates this b p f map
    29  func (m *BPFMap) Validate(formats strfmt.Registry) error {
    30  	var res []error
    31  
    32  	if err := m.validateCache(formats); err != nil {
    33  		res = append(res, err)
    34  	}
    35  
    36  	if len(res) > 0 {
    37  		return errors.CompositeValidationError(res...)
    38  	}
    39  	return nil
    40  }
    41  
    42  func (m *BPFMap) validateCache(formats strfmt.Registry) error {
    43  
    44  	if swag.IsZero(m.Cache) { // not required
    45  		return nil
    46  	}
    47  
    48  	for i := 0; i < len(m.Cache); i++ {
    49  		if swag.IsZero(m.Cache[i]) { // not required
    50  			continue
    51  		}
    52  
    53  		if m.Cache[i] != nil {
    54  			if err := m.Cache[i].Validate(formats); err != nil {
    55  				if ve, ok := err.(*errors.Validation); ok {
    56  					return ve.ValidateName("cache" + "." + strconv.Itoa(i))
    57  				}
    58  				return err
    59  			}
    60  		}
    61  
    62  	}
    63  
    64  	return nil
    65  }
    66  
    67  // MarshalBinary interface implementation
    68  func (m *BPFMap) MarshalBinary() ([]byte, error) {
    69  	if m == nil {
    70  		return nil, nil
    71  	}
    72  	return swag.WriteJSON(m)
    73  }
    74  
    75  // UnmarshalBinary interface implementation
    76  func (m *BPFMap) UnmarshalBinary(b []byte) error {
    77  	var res BPFMap
    78  	if err := swag.ReadJSON(b, &res); err != nil {
    79  		return err
    80  	}
    81  	*m = res
    82  	return nil
    83  }