github.com/cilium/cilium@v1.16.2/api/v1/models/debug_info.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  // DebugInfo groups some debugging related information on the agent
    21  //
    22  // swagger:model DebugInfo
    23  type DebugInfo struct {
    24  
    25  	// cilium memory map
    26  	CiliumMemoryMap string `json:"cilium-memory-map,omitempty"`
    27  
    28  	// cilium nodemonitor memory map
    29  	CiliumNodemonitorMemoryMap string `json:"cilium-nodemonitor-memory-map,omitempty"`
    30  
    31  	// cilium status
    32  	CiliumStatus *StatusResponse `json:"cilium-status,omitempty"`
    33  
    34  	// cilium version
    35  	CiliumVersion string `json:"cilium-version,omitempty"`
    36  
    37  	// encryption
    38  	Encryption *DebugInfoEncryption `json:"encryption,omitempty"`
    39  
    40  	// endpoint list
    41  	EndpointList []*Endpoint `json:"endpoint-list"`
    42  
    43  	// environment variables
    44  	EnvironmentVariables []string `json:"environment-variables"`
    45  
    46  	// kernel version
    47  	KernelVersion string `json:"kernel-version,omitempty"`
    48  
    49  	// policy
    50  	Policy *Policy `json:"policy,omitempty"`
    51  
    52  	// service list
    53  	ServiceList []*Service `json:"service-list"`
    54  
    55  	// subsystem
    56  	Subsystem map[string]string `json:"subsystem,omitempty"`
    57  }
    58  
    59  // Validate validates this debug info
    60  func (m *DebugInfo) Validate(formats strfmt.Registry) error {
    61  	var res []error
    62  
    63  	if err := m.validateCiliumStatus(formats); err != nil {
    64  		res = append(res, err)
    65  	}
    66  
    67  	if err := m.validateEncryption(formats); err != nil {
    68  		res = append(res, err)
    69  	}
    70  
    71  	if err := m.validateEndpointList(formats); err != nil {
    72  		res = append(res, err)
    73  	}
    74  
    75  	if err := m.validatePolicy(formats); err != nil {
    76  		res = append(res, err)
    77  	}
    78  
    79  	if err := m.validateServiceList(formats); err != nil {
    80  		res = append(res, err)
    81  	}
    82  
    83  	if len(res) > 0 {
    84  		return errors.CompositeValidationError(res...)
    85  	}
    86  	return nil
    87  }
    88  
    89  func (m *DebugInfo) validateCiliumStatus(formats strfmt.Registry) error {
    90  	if swag.IsZero(m.CiliumStatus) { // not required
    91  		return nil
    92  	}
    93  
    94  	if m.CiliumStatus != nil {
    95  		if err := m.CiliumStatus.Validate(formats); err != nil {
    96  			if ve, ok := err.(*errors.Validation); ok {
    97  				return ve.ValidateName("cilium-status")
    98  			} else if ce, ok := err.(*errors.CompositeError); ok {
    99  				return ce.ValidateName("cilium-status")
   100  			}
   101  			return err
   102  		}
   103  	}
   104  
   105  	return nil
   106  }
   107  
   108  func (m *DebugInfo) validateEncryption(formats strfmt.Registry) error {
   109  	if swag.IsZero(m.Encryption) { // not required
   110  		return nil
   111  	}
   112  
   113  	if m.Encryption != nil {
   114  		if err := m.Encryption.Validate(formats); err != nil {
   115  			if ve, ok := err.(*errors.Validation); ok {
   116  				return ve.ValidateName("encryption")
   117  			} else if ce, ok := err.(*errors.CompositeError); ok {
   118  				return ce.ValidateName("encryption")
   119  			}
   120  			return err
   121  		}
   122  	}
   123  
   124  	return nil
   125  }
   126  
   127  func (m *DebugInfo) validateEndpointList(formats strfmt.Registry) error {
   128  	if swag.IsZero(m.EndpointList) { // not required
   129  		return nil
   130  	}
   131  
   132  	for i := 0; i < len(m.EndpointList); i++ {
   133  		if swag.IsZero(m.EndpointList[i]) { // not required
   134  			continue
   135  		}
   136  
   137  		if m.EndpointList[i] != nil {
   138  			if err := m.EndpointList[i].Validate(formats); err != nil {
   139  				if ve, ok := err.(*errors.Validation); ok {
   140  					return ve.ValidateName("endpoint-list" + "." + strconv.Itoa(i))
   141  				} else if ce, ok := err.(*errors.CompositeError); ok {
   142  					return ce.ValidateName("endpoint-list" + "." + strconv.Itoa(i))
   143  				}
   144  				return err
   145  			}
   146  		}
   147  
   148  	}
   149  
   150  	return nil
   151  }
   152  
   153  func (m *DebugInfo) validatePolicy(formats strfmt.Registry) error {
   154  	if swag.IsZero(m.Policy) { // not required
   155  		return nil
   156  	}
   157  
   158  	if m.Policy != nil {
   159  		if err := m.Policy.Validate(formats); err != nil {
   160  			if ve, ok := err.(*errors.Validation); ok {
   161  				return ve.ValidateName("policy")
   162  			} else if ce, ok := err.(*errors.CompositeError); ok {
   163  				return ce.ValidateName("policy")
   164  			}
   165  			return err
   166  		}
   167  	}
   168  
   169  	return nil
   170  }
   171  
   172  func (m *DebugInfo) validateServiceList(formats strfmt.Registry) error {
   173  	if swag.IsZero(m.ServiceList) { // not required
   174  		return nil
   175  	}
   176  
   177  	for i := 0; i < len(m.ServiceList); i++ {
   178  		if swag.IsZero(m.ServiceList[i]) { // not required
   179  			continue
   180  		}
   181  
   182  		if m.ServiceList[i] != nil {
   183  			if err := m.ServiceList[i].Validate(formats); err != nil {
   184  				if ve, ok := err.(*errors.Validation); ok {
   185  					return ve.ValidateName("service-list" + "." + strconv.Itoa(i))
   186  				} else if ce, ok := err.(*errors.CompositeError); ok {
   187  					return ce.ValidateName("service-list" + "." + strconv.Itoa(i))
   188  				}
   189  				return err
   190  			}
   191  		}
   192  
   193  	}
   194  
   195  	return nil
   196  }
   197  
   198  // ContextValidate validate this debug info based on the context it is used
   199  func (m *DebugInfo) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
   200  	var res []error
   201  
   202  	if err := m.contextValidateCiliumStatus(ctx, formats); err != nil {
   203  		res = append(res, err)
   204  	}
   205  
   206  	if err := m.contextValidateEncryption(ctx, formats); err != nil {
   207  		res = append(res, err)
   208  	}
   209  
   210  	if err := m.contextValidateEndpointList(ctx, formats); err != nil {
   211  		res = append(res, err)
   212  	}
   213  
   214  	if err := m.contextValidatePolicy(ctx, formats); err != nil {
   215  		res = append(res, err)
   216  	}
   217  
   218  	if err := m.contextValidateServiceList(ctx, formats); err != nil {
   219  		res = append(res, err)
   220  	}
   221  
   222  	if len(res) > 0 {
   223  		return errors.CompositeValidationError(res...)
   224  	}
   225  	return nil
   226  }
   227  
   228  func (m *DebugInfo) contextValidateCiliumStatus(ctx context.Context, formats strfmt.Registry) error {
   229  
   230  	if m.CiliumStatus != nil {
   231  
   232  		if swag.IsZero(m.CiliumStatus) { // not required
   233  			return nil
   234  		}
   235  
   236  		if err := m.CiliumStatus.ContextValidate(ctx, formats); err != nil {
   237  			if ve, ok := err.(*errors.Validation); ok {
   238  				return ve.ValidateName("cilium-status")
   239  			} else if ce, ok := err.(*errors.CompositeError); ok {
   240  				return ce.ValidateName("cilium-status")
   241  			}
   242  			return err
   243  		}
   244  	}
   245  
   246  	return nil
   247  }
   248  
   249  func (m *DebugInfo) contextValidateEncryption(ctx context.Context, formats strfmt.Registry) error {
   250  
   251  	if m.Encryption != nil {
   252  
   253  		if swag.IsZero(m.Encryption) { // not required
   254  			return nil
   255  		}
   256  
   257  		if err := m.Encryption.ContextValidate(ctx, formats); err != nil {
   258  			if ve, ok := err.(*errors.Validation); ok {
   259  				return ve.ValidateName("encryption")
   260  			} else if ce, ok := err.(*errors.CompositeError); ok {
   261  				return ce.ValidateName("encryption")
   262  			}
   263  			return err
   264  		}
   265  	}
   266  
   267  	return nil
   268  }
   269  
   270  func (m *DebugInfo) contextValidateEndpointList(ctx context.Context, formats strfmt.Registry) error {
   271  
   272  	for i := 0; i < len(m.EndpointList); i++ {
   273  
   274  		if m.EndpointList[i] != nil {
   275  
   276  			if swag.IsZero(m.EndpointList[i]) { // not required
   277  				return nil
   278  			}
   279  
   280  			if err := m.EndpointList[i].ContextValidate(ctx, formats); err != nil {
   281  				if ve, ok := err.(*errors.Validation); ok {
   282  					return ve.ValidateName("endpoint-list" + "." + strconv.Itoa(i))
   283  				} else if ce, ok := err.(*errors.CompositeError); ok {
   284  					return ce.ValidateName("endpoint-list" + "." + strconv.Itoa(i))
   285  				}
   286  				return err
   287  			}
   288  		}
   289  
   290  	}
   291  
   292  	return nil
   293  }
   294  
   295  func (m *DebugInfo) contextValidatePolicy(ctx context.Context, formats strfmt.Registry) error {
   296  
   297  	if m.Policy != nil {
   298  
   299  		if swag.IsZero(m.Policy) { // not required
   300  			return nil
   301  		}
   302  
   303  		if err := m.Policy.ContextValidate(ctx, formats); err != nil {
   304  			if ve, ok := err.(*errors.Validation); ok {
   305  				return ve.ValidateName("policy")
   306  			} else if ce, ok := err.(*errors.CompositeError); ok {
   307  				return ce.ValidateName("policy")
   308  			}
   309  			return err
   310  		}
   311  	}
   312  
   313  	return nil
   314  }
   315  
   316  func (m *DebugInfo) contextValidateServiceList(ctx context.Context, formats strfmt.Registry) error {
   317  
   318  	for i := 0; i < len(m.ServiceList); i++ {
   319  
   320  		if m.ServiceList[i] != nil {
   321  
   322  			if swag.IsZero(m.ServiceList[i]) { // not required
   323  				return nil
   324  			}
   325  
   326  			if err := m.ServiceList[i].ContextValidate(ctx, formats); err != nil {
   327  				if ve, ok := err.(*errors.Validation); ok {
   328  					return ve.ValidateName("service-list" + "." + strconv.Itoa(i))
   329  				} else if ce, ok := err.(*errors.CompositeError); ok {
   330  					return ce.ValidateName("service-list" + "." + strconv.Itoa(i))
   331  				}
   332  				return err
   333  			}
   334  		}
   335  
   336  	}
   337  
   338  	return nil
   339  }
   340  
   341  // MarshalBinary interface implementation
   342  func (m *DebugInfo) MarshalBinary() ([]byte, error) {
   343  	if m == nil {
   344  		return nil, nil
   345  	}
   346  	return swag.WriteJSON(m)
   347  }
   348  
   349  // UnmarshalBinary interface implementation
   350  func (m *DebugInfo) UnmarshalBinary(b []byte) error {
   351  	var res DebugInfo
   352  	if err := swag.ReadJSON(b, &res); err != nil {
   353  		return err
   354  	}
   355  	*m = res
   356  	return nil
   357  }
   358  
   359  // DebugInfoEncryption debug info encryption
   360  //
   361  // swagger:model DebugInfoEncryption
   362  type DebugInfoEncryption struct {
   363  
   364  	// Status of the WireGuard agent
   365  	Wireguard *WireguardStatus `json:"wireguard,omitempty"`
   366  }
   367  
   368  // Validate validates this debug info encryption
   369  func (m *DebugInfoEncryption) Validate(formats strfmt.Registry) error {
   370  	var res []error
   371  
   372  	if err := m.validateWireguard(formats); err != nil {
   373  		res = append(res, err)
   374  	}
   375  
   376  	if len(res) > 0 {
   377  		return errors.CompositeValidationError(res...)
   378  	}
   379  	return nil
   380  }
   381  
   382  func (m *DebugInfoEncryption) validateWireguard(formats strfmt.Registry) error {
   383  	if swag.IsZero(m.Wireguard) { // not required
   384  		return nil
   385  	}
   386  
   387  	if m.Wireguard != nil {
   388  		if err := m.Wireguard.Validate(formats); err != nil {
   389  			if ve, ok := err.(*errors.Validation); ok {
   390  				return ve.ValidateName("encryption" + "." + "wireguard")
   391  			} else if ce, ok := err.(*errors.CompositeError); ok {
   392  				return ce.ValidateName("encryption" + "." + "wireguard")
   393  			}
   394  			return err
   395  		}
   396  	}
   397  
   398  	return nil
   399  }
   400  
   401  // ContextValidate validate this debug info encryption based on the context it is used
   402  func (m *DebugInfoEncryption) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
   403  	var res []error
   404  
   405  	if err := m.contextValidateWireguard(ctx, formats); err != nil {
   406  		res = append(res, err)
   407  	}
   408  
   409  	if len(res) > 0 {
   410  		return errors.CompositeValidationError(res...)
   411  	}
   412  	return nil
   413  }
   414  
   415  func (m *DebugInfoEncryption) contextValidateWireguard(ctx context.Context, formats strfmt.Registry) error {
   416  
   417  	if m.Wireguard != nil {
   418  
   419  		if swag.IsZero(m.Wireguard) { // not required
   420  			return nil
   421  		}
   422  
   423  		if err := m.Wireguard.ContextValidate(ctx, formats); err != nil {
   424  			if ve, ok := err.(*errors.Validation); ok {
   425  				return ve.ValidateName("encryption" + "." + "wireguard")
   426  			} else if ce, ok := err.(*errors.CompositeError); ok {
   427  				return ce.ValidateName("encryption" + "." + "wireguard")
   428  			}
   429  			return err
   430  		}
   431  	}
   432  
   433  	return nil
   434  }
   435  
   436  // MarshalBinary interface implementation
   437  func (m *DebugInfoEncryption) MarshalBinary() ([]byte, error) {
   438  	if m == nil {
   439  		return nil, nil
   440  	}
   441  	return swag.WriteJSON(m)
   442  }
   443  
   444  // UnmarshalBinary interface implementation
   445  func (m *DebugInfoEncryption) UnmarshalBinary(b []byte) error {
   446  	var res DebugInfoEncryption
   447  	if err := swag.ReadJSON(b, &res); err != nil {
   448  		return err
   449  	}
   450  	*m = res
   451  	return nil
   452  }