github.com/cilium/cilium@v1.16.2/api/v1/models/controller_statuses.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  	"strconv"
    14  
    15  	"github.com/go-openapi/errors"
    16  	"github.com/go-openapi/strfmt"
    17  	"github.com/go-openapi/swag"
    18  )
    19  
    20  // ControllerStatuses Collection of controller statuses
    21  //
    22  // swagger:model ControllerStatuses
    23  type ControllerStatuses []*ControllerStatus
    24  
    25  // Validate validates this controller statuses
    26  func (m ControllerStatuses) Validate(formats strfmt.Registry) error {
    27  	var res []error
    28  
    29  	for i := 0; i < len(m); i++ {
    30  		if swag.IsZero(m[i]) { // not required
    31  			continue
    32  		}
    33  
    34  		if m[i] != nil {
    35  			if err := m[i].Validate(formats); err != nil {
    36  				if ve, ok := err.(*errors.Validation); ok {
    37  					return ve.ValidateName(strconv.Itoa(i))
    38  				} else if ce, ok := err.(*errors.CompositeError); ok {
    39  					return ce.ValidateName(strconv.Itoa(i))
    40  				}
    41  				return err
    42  			}
    43  		}
    44  
    45  	}
    46  
    47  	if len(res) > 0 {
    48  		return errors.CompositeValidationError(res...)
    49  	}
    50  	return nil
    51  }
    52  
    53  // ContextValidate validate this controller statuses based on the context it is used
    54  func (m ControllerStatuses) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
    55  	var res []error
    56  
    57  	for i := 0; i < len(m); i++ {
    58  
    59  		if m[i] != nil {
    60  
    61  			if swag.IsZero(m[i]) { // not required
    62  				return nil
    63  			}
    64  
    65  			if err := m[i].ContextValidate(ctx, formats); err != nil {
    66  				if ve, ok := err.(*errors.Validation); ok {
    67  					return ve.ValidateName(strconv.Itoa(i))
    68  				} else if ce, ok := err.(*errors.CompositeError); ok {
    69  					return ce.ValidateName(strconv.Itoa(i))
    70  				}
    71  				return err
    72  			}
    73  		}
    74  
    75  	}
    76  
    77  	if len(res) > 0 {
    78  		return errors.CompositeValidationError(res...)
    79  	}
    80  	return nil
    81  }