github.com/cilium/cilium@v1.16.2/api/v1/models/k8s_status.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  // K8sStatus Status of Kubernetes integration
    22  //
    23  // +k8s:deepcopy-gen=true
    24  //
    25  // swagger:model K8sStatus
    26  type K8sStatus struct {
    27  
    28  	// k8s api versions
    29  	K8sAPIVersions []string `json:"k8s-api-versions"`
    30  
    31  	// Human readable status/error/warning message
    32  	Msg string `json:"msg,omitempty"`
    33  
    34  	// State the component is in
    35  	// Enum: [Ok Warning Failure Disabled]
    36  	State string `json:"state,omitempty"`
    37  }
    38  
    39  // Validate validates this k8s status
    40  func (m *K8sStatus) Validate(formats strfmt.Registry) error {
    41  	var res []error
    42  
    43  	if err := m.validateState(formats); err != nil {
    44  		res = append(res, err)
    45  	}
    46  
    47  	if len(res) > 0 {
    48  		return errors.CompositeValidationError(res...)
    49  	}
    50  	return nil
    51  }
    52  
    53  var k8sStatusTypeStatePropEnum []interface{}
    54  
    55  func init() {
    56  	var res []string
    57  	if err := json.Unmarshal([]byte(`["Ok","Warning","Failure","Disabled"]`), &res); err != nil {
    58  		panic(err)
    59  	}
    60  	for _, v := range res {
    61  		k8sStatusTypeStatePropEnum = append(k8sStatusTypeStatePropEnum, v)
    62  	}
    63  }
    64  
    65  const (
    66  
    67  	// K8sStatusStateOk captures enum value "Ok"
    68  	K8sStatusStateOk string = "Ok"
    69  
    70  	// K8sStatusStateWarning captures enum value "Warning"
    71  	K8sStatusStateWarning string = "Warning"
    72  
    73  	// K8sStatusStateFailure captures enum value "Failure"
    74  	K8sStatusStateFailure string = "Failure"
    75  
    76  	// K8sStatusStateDisabled captures enum value "Disabled"
    77  	K8sStatusStateDisabled string = "Disabled"
    78  )
    79  
    80  // prop value enum
    81  func (m *K8sStatus) validateStateEnum(path, location string, value string) error {
    82  	if err := validate.EnumCase(path, location, value, k8sStatusTypeStatePropEnum, true); err != nil {
    83  		return err
    84  	}
    85  	return nil
    86  }
    87  
    88  func (m *K8sStatus) validateState(formats strfmt.Registry) error {
    89  	if swag.IsZero(m.State) { // not required
    90  		return nil
    91  	}
    92  
    93  	// value enum
    94  	if err := m.validateStateEnum("state", "body", m.State); err != nil {
    95  		return err
    96  	}
    97  
    98  	return nil
    99  }
   100  
   101  // ContextValidate validates this k8s status based on context it is used
   102  func (m *K8sStatus) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
   103  	return nil
   104  }
   105  
   106  // MarshalBinary interface implementation
   107  func (m *K8sStatus) MarshalBinary() ([]byte, error) {
   108  	if m == nil {
   109  		return nil, nil
   110  	}
   111  	return swag.WriteJSON(m)
   112  }
   113  
   114  // UnmarshalBinary interface implementation
   115  func (m *K8sStatus) UnmarshalBinary(b []byte) error {
   116  	var res K8sStatus
   117  	if err := swag.ReadJSON(b, &res); err != nil {
   118  		return err
   119  	}
   120  	*m = res
   121  	return nil
   122  }