...

Source file src/github.com/emissary-ingress/emissary/v3/pkg/api/envoy/admin/v2alpha/server_info.pb.validate.go

Documentation: github.com/emissary-ingress/emissary/v3/pkg/api/envoy/admin/v2alpha

     1  // Code generated by protoc-gen-validate. DO NOT EDIT.
     2  // source: envoy/admin/v2alpha/server_info.proto
     3  
     4  package v2alpha
     5  
     6  import (
     7  	"bytes"
     8  	"errors"
     9  	"fmt"
    10  	"net"
    11  	"net/mail"
    12  	"net/url"
    13  	"regexp"
    14  	"sort"
    15  	"strings"
    16  	"time"
    17  	"unicode/utf8"
    18  
    19  	"google.golang.org/protobuf/types/known/anypb"
    20  )
    21  
    22  // ensure the imports are used
    23  var (
    24  	_ = bytes.MinRead
    25  	_ = errors.New("")
    26  	_ = fmt.Print
    27  	_ = utf8.UTFMax
    28  	_ = (*regexp.Regexp)(nil)
    29  	_ = (*strings.Reader)(nil)
    30  	_ = net.IPv4len
    31  	_ = time.Duration(0)
    32  	_ = (*url.URL)(nil)
    33  	_ = (*mail.Address)(nil)
    34  	_ = anypb.Any{}
    35  	_ = sort.Sort
    36  )
    37  
    38  // Validate checks the field values on ServerInfo with the rules defined in the
    39  // proto definition for this message. If any rules are violated, the first
    40  // error encountered is returned, or nil if there are no violations.
    41  func (m *ServerInfo) Validate() error {
    42  	return m.validate(false)
    43  }
    44  
    45  // ValidateAll checks the field values on ServerInfo with the rules defined in
    46  // the proto definition for this message. If any rules are violated, the
    47  // result is a list of violation errors wrapped in ServerInfoMultiError, or
    48  // nil if none found.
    49  func (m *ServerInfo) ValidateAll() error {
    50  	return m.validate(true)
    51  }
    52  
    53  func (m *ServerInfo) validate(all bool) error {
    54  	if m == nil {
    55  		return nil
    56  	}
    57  
    58  	var errors []error
    59  
    60  	// no validation rules for Version
    61  
    62  	// no validation rules for State
    63  
    64  	if all {
    65  		switch v := interface{}(m.GetUptimeCurrentEpoch()).(type) {
    66  		case interface{ ValidateAll() error }:
    67  			if err := v.ValidateAll(); err != nil {
    68  				errors = append(errors, ServerInfoValidationError{
    69  					field:  "UptimeCurrentEpoch",
    70  					reason: "embedded message failed validation",
    71  					cause:  err,
    72  				})
    73  			}
    74  		case interface{ Validate() error }:
    75  			if err := v.Validate(); err != nil {
    76  				errors = append(errors, ServerInfoValidationError{
    77  					field:  "UptimeCurrentEpoch",
    78  					reason: "embedded message failed validation",
    79  					cause:  err,
    80  				})
    81  			}
    82  		}
    83  	} else if v, ok := interface{}(m.GetUptimeCurrentEpoch()).(interface{ Validate() error }); ok {
    84  		if err := v.Validate(); err != nil {
    85  			return ServerInfoValidationError{
    86  				field:  "UptimeCurrentEpoch",
    87  				reason: "embedded message failed validation",
    88  				cause:  err,
    89  			}
    90  		}
    91  	}
    92  
    93  	if all {
    94  		switch v := interface{}(m.GetUptimeAllEpochs()).(type) {
    95  		case interface{ ValidateAll() error }:
    96  			if err := v.ValidateAll(); err != nil {
    97  				errors = append(errors, ServerInfoValidationError{
    98  					field:  "UptimeAllEpochs",
    99  					reason: "embedded message failed validation",
   100  					cause:  err,
   101  				})
   102  			}
   103  		case interface{ Validate() error }:
   104  			if err := v.Validate(); err != nil {
   105  				errors = append(errors, ServerInfoValidationError{
   106  					field:  "UptimeAllEpochs",
   107  					reason: "embedded message failed validation",
   108  					cause:  err,
   109  				})
   110  			}
   111  		}
   112  	} else if v, ok := interface{}(m.GetUptimeAllEpochs()).(interface{ Validate() error }); ok {
   113  		if err := v.Validate(); err != nil {
   114  			return ServerInfoValidationError{
   115  				field:  "UptimeAllEpochs",
   116  				reason: "embedded message failed validation",
   117  				cause:  err,
   118  			}
   119  		}
   120  	}
   121  
   122  	// no validation rules for HotRestartVersion
   123  
   124  	if all {
   125  		switch v := interface{}(m.GetCommandLineOptions()).(type) {
   126  		case interface{ ValidateAll() error }:
   127  			if err := v.ValidateAll(); err != nil {
   128  				errors = append(errors, ServerInfoValidationError{
   129  					field:  "CommandLineOptions",
   130  					reason: "embedded message failed validation",
   131  					cause:  err,
   132  				})
   133  			}
   134  		case interface{ Validate() error }:
   135  			if err := v.Validate(); err != nil {
   136  				errors = append(errors, ServerInfoValidationError{
   137  					field:  "CommandLineOptions",
   138  					reason: "embedded message failed validation",
   139  					cause:  err,
   140  				})
   141  			}
   142  		}
   143  	} else if v, ok := interface{}(m.GetCommandLineOptions()).(interface{ Validate() error }); ok {
   144  		if err := v.Validate(); err != nil {
   145  			return ServerInfoValidationError{
   146  				field:  "CommandLineOptions",
   147  				reason: "embedded message failed validation",
   148  				cause:  err,
   149  			}
   150  		}
   151  	}
   152  
   153  	if len(errors) > 0 {
   154  		return ServerInfoMultiError(errors)
   155  	}
   156  
   157  	return nil
   158  }
   159  
   160  // ServerInfoMultiError is an error wrapping multiple validation errors
   161  // returned by ServerInfo.ValidateAll() if the designated constraints aren't met.
   162  type ServerInfoMultiError []error
   163  
   164  // Error returns a concatenation of all the error messages it wraps.
   165  func (m ServerInfoMultiError) Error() string {
   166  	var msgs []string
   167  	for _, err := range m {
   168  		msgs = append(msgs, err.Error())
   169  	}
   170  	return strings.Join(msgs, "; ")
   171  }
   172  
   173  // AllErrors returns a list of validation violation errors.
   174  func (m ServerInfoMultiError) AllErrors() []error { return m }
   175  
   176  // ServerInfoValidationError is the validation error returned by
   177  // ServerInfo.Validate if the designated constraints aren't met.
   178  type ServerInfoValidationError struct {
   179  	field  string
   180  	reason string
   181  	cause  error
   182  	key    bool
   183  }
   184  
   185  // Field function returns field value.
   186  func (e ServerInfoValidationError) Field() string { return e.field }
   187  
   188  // Reason function returns reason value.
   189  func (e ServerInfoValidationError) Reason() string { return e.reason }
   190  
   191  // Cause function returns cause value.
   192  func (e ServerInfoValidationError) Cause() error { return e.cause }
   193  
   194  // Key function returns key value.
   195  func (e ServerInfoValidationError) Key() bool { return e.key }
   196  
   197  // ErrorName returns error name.
   198  func (e ServerInfoValidationError) ErrorName() string { return "ServerInfoValidationError" }
   199  
   200  // Error satisfies the builtin error interface
   201  func (e ServerInfoValidationError) Error() string {
   202  	cause := ""
   203  	if e.cause != nil {
   204  		cause = fmt.Sprintf(" | caused by: %v", e.cause)
   205  	}
   206  
   207  	key := ""
   208  	if e.key {
   209  		key = "key for "
   210  	}
   211  
   212  	return fmt.Sprintf(
   213  		"invalid %sServerInfo.%s: %s%s",
   214  		key,
   215  		e.field,
   216  		e.reason,
   217  		cause)
   218  }
   219  
   220  var _ error = ServerInfoValidationError{}
   221  
   222  var _ interface {
   223  	Field() string
   224  	Reason() string
   225  	Key() bool
   226  	Cause() error
   227  	ErrorName() string
   228  } = ServerInfoValidationError{}
   229  
   230  // Validate checks the field values on CommandLineOptions with the rules
   231  // defined in the proto definition for this message. If any rules are
   232  // violated, the first error encountered is returned, or nil if there are no violations.
   233  func (m *CommandLineOptions) Validate() error {
   234  	return m.validate(false)
   235  }
   236  
   237  // ValidateAll checks the field values on CommandLineOptions with the rules
   238  // defined in the proto definition for this message. If any rules are
   239  // violated, the result is a list of violation errors wrapped in
   240  // CommandLineOptionsMultiError, or nil if none found.
   241  func (m *CommandLineOptions) ValidateAll() error {
   242  	return m.validate(true)
   243  }
   244  
   245  func (m *CommandLineOptions) validate(all bool) error {
   246  	if m == nil {
   247  		return nil
   248  	}
   249  
   250  	var errors []error
   251  
   252  	// no validation rules for BaseId
   253  
   254  	// no validation rules for Concurrency
   255  
   256  	// no validation rules for ConfigPath
   257  
   258  	// no validation rules for ConfigYaml
   259  
   260  	// no validation rules for AllowUnknownStaticFields
   261  
   262  	// no validation rules for RejectUnknownDynamicFields
   263  
   264  	// no validation rules for AdminAddressPath
   265  
   266  	// no validation rules for LocalAddressIpVersion
   267  
   268  	// no validation rules for LogLevel
   269  
   270  	// no validation rules for ComponentLogLevel
   271  
   272  	// no validation rules for LogFormat
   273  
   274  	// no validation rules for LogFormatEscaped
   275  
   276  	// no validation rules for LogPath
   277  
   278  	// no validation rules for ServiceCluster
   279  
   280  	// no validation rules for ServiceNode
   281  
   282  	// no validation rules for ServiceZone
   283  
   284  	if all {
   285  		switch v := interface{}(m.GetFileFlushInterval()).(type) {
   286  		case interface{ ValidateAll() error }:
   287  			if err := v.ValidateAll(); err != nil {
   288  				errors = append(errors, CommandLineOptionsValidationError{
   289  					field:  "FileFlushInterval",
   290  					reason: "embedded message failed validation",
   291  					cause:  err,
   292  				})
   293  			}
   294  		case interface{ Validate() error }:
   295  			if err := v.Validate(); err != nil {
   296  				errors = append(errors, CommandLineOptionsValidationError{
   297  					field:  "FileFlushInterval",
   298  					reason: "embedded message failed validation",
   299  					cause:  err,
   300  				})
   301  			}
   302  		}
   303  	} else if v, ok := interface{}(m.GetFileFlushInterval()).(interface{ Validate() error }); ok {
   304  		if err := v.Validate(); err != nil {
   305  			return CommandLineOptionsValidationError{
   306  				field:  "FileFlushInterval",
   307  				reason: "embedded message failed validation",
   308  				cause:  err,
   309  			}
   310  		}
   311  	}
   312  
   313  	if all {
   314  		switch v := interface{}(m.GetDrainTime()).(type) {
   315  		case interface{ ValidateAll() error }:
   316  			if err := v.ValidateAll(); err != nil {
   317  				errors = append(errors, CommandLineOptionsValidationError{
   318  					field:  "DrainTime",
   319  					reason: "embedded message failed validation",
   320  					cause:  err,
   321  				})
   322  			}
   323  		case interface{ Validate() error }:
   324  			if err := v.Validate(); err != nil {
   325  				errors = append(errors, CommandLineOptionsValidationError{
   326  					field:  "DrainTime",
   327  					reason: "embedded message failed validation",
   328  					cause:  err,
   329  				})
   330  			}
   331  		}
   332  	} else if v, ok := interface{}(m.GetDrainTime()).(interface{ Validate() error }); ok {
   333  		if err := v.Validate(); err != nil {
   334  			return CommandLineOptionsValidationError{
   335  				field:  "DrainTime",
   336  				reason: "embedded message failed validation",
   337  				cause:  err,
   338  			}
   339  		}
   340  	}
   341  
   342  	if all {
   343  		switch v := interface{}(m.GetParentShutdownTime()).(type) {
   344  		case interface{ ValidateAll() error }:
   345  			if err := v.ValidateAll(); err != nil {
   346  				errors = append(errors, CommandLineOptionsValidationError{
   347  					field:  "ParentShutdownTime",
   348  					reason: "embedded message failed validation",
   349  					cause:  err,
   350  				})
   351  			}
   352  		case interface{ Validate() error }:
   353  			if err := v.Validate(); err != nil {
   354  				errors = append(errors, CommandLineOptionsValidationError{
   355  					field:  "ParentShutdownTime",
   356  					reason: "embedded message failed validation",
   357  					cause:  err,
   358  				})
   359  			}
   360  		}
   361  	} else if v, ok := interface{}(m.GetParentShutdownTime()).(interface{ Validate() error }); ok {
   362  		if err := v.Validate(); err != nil {
   363  			return CommandLineOptionsValidationError{
   364  				field:  "ParentShutdownTime",
   365  				reason: "embedded message failed validation",
   366  				cause:  err,
   367  			}
   368  		}
   369  	}
   370  
   371  	// no validation rules for Mode
   372  
   373  	// no validation rules for MaxStats
   374  
   375  	// no validation rules for MaxObjNameLen
   376  
   377  	// no validation rules for DisableHotRestart
   378  
   379  	// no validation rules for EnableMutexTracing
   380  
   381  	// no validation rules for RestartEpoch
   382  
   383  	// no validation rules for CpusetThreads
   384  
   385  	if len(errors) > 0 {
   386  		return CommandLineOptionsMultiError(errors)
   387  	}
   388  
   389  	return nil
   390  }
   391  
   392  // CommandLineOptionsMultiError is an error wrapping multiple validation errors
   393  // returned by CommandLineOptions.ValidateAll() if the designated constraints
   394  // aren't met.
   395  type CommandLineOptionsMultiError []error
   396  
   397  // Error returns a concatenation of all the error messages it wraps.
   398  func (m CommandLineOptionsMultiError) Error() string {
   399  	var msgs []string
   400  	for _, err := range m {
   401  		msgs = append(msgs, err.Error())
   402  	}
   403  	return strings.Join(msgs, "; ")
   404  }
   405  
   406  // AllErrors returns a list of validation violation errors.
   407  func (m CommandLineOptionsMultiError) AllErrors() []error { return m }
   408  
   409  // CommandLineOptionsValidationError is the validation error returned by
   410  // CommandLineOptions.Validate if the designated constraints aren't met.
   411  type CommandLineOptionsValidationError struct {
   412  	field  string
   413  	reason string
   414  	cause  error
   415  	key    bool
   416  }
   417  
   418  // Field function returns field value.
   419  func (e CommandLineOptionsValidationError) Field() string { return e.field }
   420  
   421  // Reason function returns reason value.
   422  func (e CommandLineOptionsValidationError) Reason() string { return e.reason }
   423  
   424  // Cause function returns cause value.
   425  func (e CommandLineOptionsValidationError) Cause() error { return e.cause }
   426  
   427  // Key function returns key value.
   428  func (e CommandLineOptionsValidationError) Key() bool { return e.key }
   429  
   430  // ErrorName returns error name.
   431  func (e CommandLineOptionsValidationError) ErrorName() string {
   432  	return "CommandLineOptionsValidationError"
   433  }
   434  
   435  // Error satisfies the builtin error interface
   436  func (e CommandLineOptionsValidationError) Error() string {
   437  	cause := ""
   438  	if e.cause != nil {
   439  		cause = fmt.Sprintf(" | caused by: %v", e.cause)
   440  	}
   441  
   442  	key := ""
   443  	if e.key {
   444  		key = "key for "
   445  	}
   446  
   447  	return fmt.Sprintf(
   448  		"invalid %sCommandLineOptions.%s: %s%s",
   449  		key,
   450  		e.field,
   451  		e.reason,
   452  		cause)
   453  }
   454  
   455  var _ error = CommandLineOptionsValidationError{}
   456  
   457  var _ interface {
   458  	Field() string
   459  	Reason() string
   460  	Key() bool
   461  	Cause() error
   462  	ErrorName() string
   463  } = CommandLineOptionsValidationError{}
   464  

View as plain text