// Code generated by protoc-gen-validate. DO NOT EDIT. // source: pkg/apis/common/v2/common.proto package common import ( "bytes" "errors" "fmt" "net" "net/mail" "net/url" "regexp" "sort" "strings" "time" "unicode/utf8" "google.golang.org/protobuf/types/known/anypb" ) // ensure the imports are used var ( _ = bytes.MinRead _ = errors.New("") _ = fmt.Print _ = utf8.UTFMax _ = (*regexp.Regexp)(nil) _ = (*strings.Reader)(nil) _ = net.IPv4len _ = time.Duration(0) _ = (*url.URL)(nil) _ = (*mail.Address)(nil) _ = anypb.Any{} _ = sort.Sort ) // Validate checks the field values on Peer with the rules defined in the proto // definition for this message. If any rules are violated, the first error // encountered is returned, or nil if there are no violations. func (m *Peer) Validate() error { return m.validate(false) } // ValidateAll checks the field values on Peer with the rules defined in the // proto definition for this message. If any rules are violated, the result is // a list of violation errors wrapped in PeerMultiError, or nil if none found. func (m *Peer) ValidateAll() error { return m.validate(true) } func (m *Peer) validate(all bool) error { if m == nil { return nil } var errors []error if utf8.RuneCountInString(m.GetId()) < 1 { err := PeerValidationError{ field: "Id", reason: "value length must be at least 1 runes", } if !all { return err } errors = append(errors, err) } if _, ok := Priority_name[int32(m.GetPriority())]; !ok { err := PeerValidationError{ field: "Priority", reason: "value must be one of the defined enum values", } if !all { return err } errors = append(errors, err) } if len(m.GetPieces()) > 0 { if len(m.GetPieces()) < 1 { err := PeerValidationError{ field: "Pieces", reason: "value must contain at least 1 item(s)", } if !all { return err } errors = append(errors, err) } for idx, item := range m.GetPieces() { _, _ = idx, item if all { switch v := interface{}(item).(type) { case interface{ ValidateAll() error }: if err := v.ValidateAll(); err != nil { errors = append(errors, PeerValidationError{ field: fmt.Sprintf("Pieces[%v]", idx), reason: "embedded message failed validation", cause: err, }) } case interface{ Validate() error }: if err := v.Validate(); err != nil { errors = append(errors, PeerValidationError{ field: fmt.Sprintf("Pieces[%v]", idx), reason: "embedded message failed validation", cause: err, }) } } } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return PeerValidationError{ field: fmt.Sprintf("Pieces[%v]", idx), reason: "embedded message failed validation", cause: err, } } } } } if m.GetCost() == nil { err := PeerValidationError{ field: "Cost", reason: "value is required", } if !all { return err } errors = append(errors, err) } if utf8.RuneCountInString(m.GetState()) < 1 { err := PeerValidationError{ field: "State", reason: "value length must be at least 1 runes", } if !all { return err } errors = append(errors, err) } if m.GetTask() == nil { err := PeerValidationError{ field: "Task", reason: "value is required", } if !all { return err } errors = append(errors, err) } if all { switch v := interface{}(m.GetTask()).(type) { case interface{ ValidateAll() error }: if err := v.ValidateAll(); err != nil { errors = append(errors, PeerValidationError{ field: "Task", reason: "embedded message failed validation", cause: err, }) } case interface{ Validate() error }: if err := v.Validate(); err != nil { errors = append(errors, PeerValidationError{ field: "Task", reason: "embedded message failed validation", cause: err, }) } } } else if v, ok := interface{}(m.GetTask()).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return PeerValidationError{ field: "Task", reason: "embedded message failed validation", cause: err, } } } if m.GetHost() == nil { err := PeerValidationError{ field: "Host", reason: "value is required", } if !all { return err } errors = append(errors, err) } if all { switch v := interface{}(m.GetHost()).(type) { case interface{ ValidateAll() error }: if err := v.ValidateAll(); err != nil { errors = append(errors, PeerValidationError{ field: "Host", reason: "embedded message failed validation", cause: err, }) } case interface{ Validate() error }: if err := v.Validate(); err != nil { errors = append(errors, PeerValidationError{ field: "Host", reason: "embedded message failed validation", cause: err, }) } } } else if v, ok := interface{}(m.GetHost()).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return PeerValidationError{ field: "Host", reason: "embedded message failed validation", cause: err, } } } // no validation rules for NeedBackToSource if m.GetCreatedAt() == nil { err := PeerValidationError{ field: "CreatedAt", reason: "value is required", } if !all { return err } errors = append(errors, err) } if m.GetUpdatedAt() == nil { err := PeerValidationError{ field: "UpdatedAt", reason: "value is required", } if !all { return err } errors = append(errors, err) } if m.Range != nil { if all { switch v := interface{}(m.GetRange()).(type) { case interface{ ValidateAll() error }: if err := v.ValidateAll(); err != nil { errors = append(errors, PeerValidationError{ field: "Range", reason: "embedded message failed validation", cause: err, }) } case interface{ Validate() error }: if err := v.Validate(); err != nil { errors = append(errors, PeerValidationError{ field: "Range", reason: "embedded message failed validation", cause: err, }) } } } else if v, ok := interface{}(m.GetRange()).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return PeerValidationError{ field: "Range", reason: "embedded message failed validation", cause: err, } } } } if len(errors) > 0 { return PeerMultiError(errors) } return nil } // PeerMultiError is an error wrapping multiple validation errors returned by // Peer.ValidateAll() if the designated constraints aren't met. type PeerMultiError []error // Error returns a concatenation of all the error messages it wraps. func (m PeerMultiError) Error() string { var msgs []string for _, err := range m { msgs = append(msgs, err.Error()) } return strings.Join(msgs, "; ") } // AllErrors returns a list of validation violation errors. func (m PeerMultiError) AllErrors() []error { return m } // PeerValidationError is the validation error returned by Peer.Validate if the // designated constraints aren't met. type PeerValidationError struct { field string reason string cause error key bool } // Field function returns field value. func (e PeerValidationError) Field() string { return e.field } // Reason function returns reason value. func (e PeerValidationError) Reason() string { return e.reason } // Cause function returns cause value. func (e PeerValidationError) Cause() error { return e.cause } // Key function returns key value. func (e PeerValidationError) Key() bool { return e.key } // ErrorName returns error name. func (e PeerValidationError) ErrorName() string { return "PeerValidationError" } // Error satisfies the builtin error interface func (e PeerValidationError) Error() string { cause := "" if e.cause != nil { cause = fmt.Sprintf(" | caused by: %v", e.cause) } key := "" if e.key { key = "key for " } return fmt.Sprintf( "invalid %sPeer.%s: %s%s", key, e.field, e.reason, cause) } var _ error = PeerValidationError{} var _ interface { Field() string Reason() string Key() bool Cause() error ErrorName() string } = PeerValidationError{} // Validate checks the field values on PersistentCachePeer with the rules // defined in the proto definition for this message. If any rules are // violated, the first error encountered is returned, or nil if there are no violations. func (m *PersistentCachePeer) Validate() error { return m.validate(false) } // ValidateAll checks the field values on PersistentCachePeer with the rules // defined in the proto definition for this message. If any rules are // violated, the result is a list of violation errors wrapped in // PersistentCachePeerMultiError, or nil if none found. func (m *PersistentCachePeer) ValidateAll() error { return m.validate(true) } func (m *PersistentCachePeer) validate(all bool) error { if m == nil { return nil } var errors []error if utf8.RuneCountInString(m.GetId()) < 1 { err := PersistentCachePeerValidationError{ field: "Id", reason: "value length must be at least 1 runes", } if !all { return err } errors = append(errors, err) } // no validation rules for Persistent if m.GetCost() == nil { err := PersistentCachePeerValidationError{ field: "Cost", reason: "value is required", } if !all { return err } errors = append(errors, err) } if utf8.RuneCountInString(m.GetState()) < 1 { err := PersistentCachePeerValidationError{ field: "State", reason: "value length must be at least 1 runes", } if !all { return err } errors = append(errors, err) } if m.GetTask() == nil { err := PersistentCachePeerValidationError{ field: "Task", reason: "value is required", } if !all { return err } errors = append(errors, err) } if all { switch v := interface{}(m.GetTask()).(type) { case interface{ ValidateAll() error }: if err := v.ValidateAll(); err != nil { errors = append(errors, PersistentCachePeerValidationError{ field: "Task", reason: "embedded message failed validation", cause: err, }) } case interface{ Validate() error }: if err := v.Validate(); err != nil { errors = append(errors, PersistentCachePeerValidationError{ field: "Task", reason: "embedded message failed validation", cause: err, }) } } } else if v, ok := interface{}(m.GetTask()).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return PersistentCachePeerValidationError{ field: "Task", reason: "embedded message failed validation", cause: err, } } } if m.GetHost() == nil { err := PersistentCachePeerValidationError{ field: "Host", reason: "value is required", } if !all { return err } errors = append(errors, err) } if all { switch v := interface{}(m.GetHost()).(type) { case interface{ ValidateAll() error }: if err := v.ValidateAll(); err != nil { errors = append(errors, PersistentCachePeerValidationError{ field: "Host", reason: "embedded message failed validation", cause: err, }) } case interface{ Validate() error }: if err := v.Validate(); err != nil { errors = append(errors, PersistentCachePeerValidationError{ field: "Host", reason: "embedded message failed validation", cause: err, }) } } } else if v, ok := interface{}(m.GetHost()).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return PersistentCachePeerValidationError{ field: "Host", reason: "embedded message failed validation", cause: err, } } } if m.GetCreatedAt() == nil { err := PersistentCachePeerValidationError{ field: "CreatedAt", reason: "value is required", } if !all { return err } errors = append(errors, err) } if m.GetUpdatedAt() == nil { err := PersistentCachePeerValidationError{ field: "UpdatedAt", reason: "value is required", } if !all { return err } errors = append(errors, err) } if len(errors) > 0 { return PersistentCachePeerMultiError(errors) } return nil } // PersistentCachePeerMultiError is an error wrapping multiple validation // errors returned by PersistentCachePeer.ValidateAll() if the designated // constraints aren't met. type PersistentCachePeerMultiError []error // Error returns a concatenation of all the error messages it wraps. func (m PersistentCachePeerMultiError) Error() string { var msgs []string for _, err := range m { msgs = append(msgs, err.Error()) } return strings.Join(msgs, "; ") } // AllErrors returns a list of validation violation errors. func (m PersistentCachePeerMultiError) AllErrors() []error { return m } // PersistentCachePeerValidationError is the validation error returned by // PersistentCachePeer.Validate if the designated constraints aren't met. type PersistentCachePeerValidationError struct { field string reason string cause error key bool } // Field function returns field value. func (e PersistentCachePeerValidationError) Field() string { return e.field } // Reason function returns reason value. func (e PersistentCachePeerValidationError) Reason() string { return e.reason } // Cause function returns cause value. func (e PersistentCachePeerValidationError) Cause() error { return e.cause } // Key function returns key value. func (e PersistentCachePeerValidationError) Key() bool { return e.key } // ErrorName returns error name. func (e PersistentCachePeerValidationError) ErrorName() string { return "PersistentCachePeerValidationError" } // Error satisfies the builtin error interface func (e PersistentCachePeerValidationError) Error() string { cause := "" if e.cause != nil { cause = fmt.Sprintf(" | caused by: %v", e.cause) } key := "" if e.key { key = "key for " } return fmt.Sprintf( "invalid %sPersistentCachePeer.%s: %s%s", key, e.field, e.reason, cause) } var _ error = PersistentCachePeerValidationError{} var _ interface { Field() string Reason() string Key() bool Cause() error ErrorName() string } = PersistentCachePeerValidationError{} // Validate checks the field values on Task with the rules defined in the proto // definition for this message. If any rules are violated, the first error // encountered is returned, or nil if there are no violations. func (m *Task) Validate() error { return m.validate(false) } // ValidateAll checks the field values on Task with the rules defined in the // proto definition for this message. If any rules are violated, the result is // a list of violation errors wrapped in TaskMultiError, or nil if none found. func (m *Task) ValidateAll() error { return m.validate(true) } func (m *Task) validate(all bool) error { if m == nil { return nil } var errors []error if utf8.RuneCountInString(m.GetId()) < 1 { err := TaskValidationError{ field: "Id", reason: "value length must be at least 1 runes", } if !all { return err } errors = append(errors, err) } if _, ok := TaskType_name[int32(m.GetType())]; !ok { err := TaskValidationError{ field: "Type", reason: "value must be one of the defined enum values", } if !all { return err } errors = append(errors, err) } if uri, err := url.Parse(m.GetUrl()); err != nil { err = TaskValidationError{ field: "Url", reason: "value must be a valid URI", cause: err, } if !all { return err } errors = append(errors, err) } else if !uri.IsAbs() { err := TaskValidationError{ field: "Url", reason: "value must be absolute", } if !all { return err } errors = append(errors, err) } // no validation rules for RequestHeader if m.GetPieceLength() < 1 { err := TaskValidationError{ field: "PieceLength", reason: "value must be greater than or equal to 1", } if !all { return err } errors = append(errors, err) } // no validation rules for ContentLength // no validation rules for PieceCount // no validation rules for SizeScope if len(m.GetPieces()) > 0 { if len(m.GetPieces()) < 1 { err := TaskValidationError{ field: "Pieces", reason: "value must contain at least 1 item(s)", } if !all { return err } errors = append(errors, err) } for idx, item := range m.GetPieces() { _, _ = idx, item if all { switch v := interface{}(item).(type) { case interface{ ValidateAll() error }: if err := v.ValidateAll(); err != nil { errors = append(errors, TaskValidationError{ field: fmt.Sprintf("Pieces[%v]", idx), reason: "embedded message failed validation", cause: err, }) } case interface{ Validate() error }: if err := v.Validate(); err != nil { errors = append(errors, TaskValidationError{ field: fmt.Sprintf("Pieces[%v]", idx), reason: "embedded message failed validation", cause: err, }) } } } else if v, ok := interface{}(item).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return TaskValidationError{ field: fmt.Sprintf("Pieces[%v]", idx), reason: "embedded message failed validation", cause: err, } } } } } if utf8.RuneCountInString(m.GetState()) < 1 { err := TaskValidationError{ field: "State", reason: "value length must be at least 1 runes", } if !all { return err } errors = append(errors, err) } // no validation rules for PeerCount // no validation rules for HasAvailablePeer if m.GetCreatedAt() == nil { err := TaskValidationError{ field: "CreatedAt", reason: "value is required", } if !all { return err } errors = append(errors, err) } if m.GetUpdatedAt() == nil { err := TaskValidationError{ field: "UpdatedAt", reason: "value is required", } if !all { return err } errors = append(errors, err) } if m.Digest != nil { if m.GetDigest() != "" { if !_Task_Digest_Pattern.MatchString(m.GetDigest()) { err := TaskValidationError{ field: "Digest", reason: "value does not match regex pattern \"^(md5:[a-fA-F0-9]{32}|sha1:[a-fA-F0-9]{40}|sha256:[a-fA-F0-9]{64}|sha512:[a-fA-F0-9]{128}|blake3:[a-fA-F0-9]{64}|crc32:[a-fA-F0-9]+)$\"", } if !all { return err } errors = append(errors, err) } } } if m.Tag != nil { // no validation rules for Tag } if m.Application != nil { // no validation rules for Application } if len(errors) > 0 { return TaskMultiError(errors) } return nil } // TaskMultiError is an error wrapping multiple validation errors returned by // Task.ValidateAll() if the designated constraints aren't met. type TaskMultiError []error // Error returns a concatenation of all the error messages it wraps. func (m TaskMultiError) Error() string { var msgs []string for _, err := range m { msgs = append(msgs, err.Error()) } return strings.Join(msgs, "; ") } // AllErrors returns a list of validation violation errors. func (m TaskMultiError) AllErrors() []error { return m } // TaskValidationError is the validation error returned by Task.Validate if the // designated constraints aren't met. type TaskValidationError struct { field string reason string cause error key bool } // Field function returns field value. func (e TaskValidationError) Field() string { return e.field } // Reason function returns reason value. func (e TaskValidationError) Reason() string { return e.reason } // Cause function returns cause value. func (e TaskValidationError) Cause() error { return e.cause } // Key function returns key value. func (e TaskValidationError) Key() bool { return e.key } // ErrorName returns error name. func (e TaskValidationError) ErrorName() string { return "TaskValidationError" } // Error satisfies the builtin error interface func (e TaskValidationError) Error() string { cause := "" if e.cause != nil { cause = fmt.Sprintf(" | caused by: %v", e.cause) } key := "" if e.key { key = "key for " } return fmt.Sprintf( "invalid %sTask.%s: %s%s", key, e.field, e.reason, cause) } var _ error = TaskValidationError{} var _ interface { Field() string Reason() string Key() bool Cause() error ErrorName() string } = TaskValidationError{} var _Task_Digest_Pattern = regexp.MustCompile("^(md5:[a-fA-F0-9]{32}|sha1:[a-fA-F0-9]{40}|sha256:[a-fA-F0-9]{64}|sha512:[a-fA-F0-9]{128}|blake3:[a-fA-F0-9]{64}|crc32:[a-fA-F0-9]+)$") // Validate checks the field values on PersistentCacheTask with the rules // defined in the proto definition for this message. If any rules are // violated, the first error encountered is returned, or nil if there are no violations. func (m *PersistentCacheTask) Validate() error { return m.validate(false) } // ValidateAll checks the field values on PersistentCacheTask with the rules // defined in the proto definition for this message. If any rules are // violated, the result is a list of violation errors wrapped in // PersistentCacheTaskMultiError, or nil if none found. func (m *PersistentCacheTask) ValidateAll() error { return m.validate(true) } func (m *PersistentCacheTask) validate(all bool) error { if m == nil { return nil } var errors []error if utf8.RuneCountInString(m.GetId()) < 1 { err := PersistentCacheTaskValidationError{ field: "Id", reason: "value length must be at least 1 runes", } if !all { return err } errors = append(errors, err) } if m.GetPersistentReplicaCount() < 1 { err := PersistentCacheTaskValidationError{ field: "PersistentReplicaCount", reason: "value must be greater than or equal to 1", } if !all { return err } errors = append(errors, err) } // no validation rules for CurrentPersistentReplicaCount // no validation rules for CurrentReplicaCount if !_PersistentCacheTask_Digest_Pattern.MatchString(m.GetDigest()) { err := PersistentCacheTaskValidationError{ field: "Digest", reason: "value does not match regex pattern \"^(md5:[a-fA-F0-9]{32}|sha1:[a-fA-F0-9]{40}|sha256:[a-fA-F0-9]{64}|sha512:[a-fA-F0-9]{128}|blake3:[a-fA-F0-9]{64}|crc32:[a-fA-F0-9]+)$\"", } if !all { return err } errors = append(errors, err) } if m.GetPieceLength() < 1 { err := PersistentCacheTaskValidationError{ field: "PieceLength", reason: "value must be greater than or equal to 1", } if !all { return err } errors = append(errors, err) } // no validation rules for ContentLength // no validation rules for PieceCount if utf8.RuneCountInString(m.GetState()) < 1 { err := PersistentCacheTaskValidationError{ field: "State", reason: "value length must be at least 1 runes", } if !all { return err } errors = append(errors, err) } if m.GetCreatedAt() == nil { err := PersistentCacheTaskValidationError{ field: "CreatedAt", reason: "value is required", } if !all { return err } errors = append(errors, err) } if m.GetUpdatedAt() == nil { err := PersistentCacheTaskValidationError{ field: "UpdatedAt", reason: "value is required", } if !all { return err } errors = append(errors, err) } if m.Tag != nil { // no validation rules for Tag } if m.Application != nil { // no validation rules for Application } if len(errors) > 0 { return PersistentCacheTaskMultiError(errors) } return nil } // PersistentCacheTaskMultiError is an error wrapping multiple validation // errors returned by PersistentCacheTask.ValidateAll() if the designated // constraints aren't met. type PersistentCacheTaskMultiError []error // Error returns a concatenation of all the error messages it wraps. func (m PersistentCacheTaskMultiError) Error() string { var msgs []string for _, err := range m { msgs = append(msgs, err.Error()) } return strings.Join(msgs, "; ") } // AllErrors returns a list of validation violation errors. func (m PersistentCacheTaskMultiError) AllErrors() []error { return m } // PersistentCacheTaskValidationError is the validation error returned by // PersistentCacheTask.Validate if the designated constraints aren't met. type PersistentCacheTaskValidationError struct { field string reason string cause error key bool } // Field function returns field value. func (e PersistentCacheTaskValidationError) Field() string { return e.field } // Reason function returns reason value. func (e PersistentCacheTaskValidationError) Reason() string { return e.reason } // Cause function returns cause value. func (e PersistentCacheTaskValidationError) Cause() error { return e.cause } // Key function returns key value. func (e PersistentCacheTaskValidationError) Key() bool { return e.key } // ErrorName returns error name. func (e PersistentCacheTaskValidationError) ErrorName() string { return "PersistentCacheTaskValidationError" } // Error satisfies the builtin error interface func (e PersistentCacheTaskValidationError) Error() string { cause := "" if e.cause != nil { cause = fmt.Sprintf(" | caused by: %v", e.cause) } key := "" if e.key { key = "key for " } return fmt.Sprintf( "invalid %sPersistentCacheTask.%s: %s%s", key, e.field, e.reason, cause) } var _ error = PersistentCacheTaskValidationError{} var _ interface { Field() string Reason() string Key() bool Cause() error ErrorName() string } = PersistentCacheTaskValidationError{} var _PersistentCacheTask_Digest_Pattern = regexp.MustCompile("^(md5:[a-fA-F0-9]{32}|sha1:[a-fA-F0-9]{40}|sha256:[a-fA-F0-9]{64}|sha512:[a-fA-F0-9]{128}|blake3:[a-fA-F0-9]{64}|crc32:[a-fA-F0-9]+)$") // Validate checks the field values on Host with the rules defined in the proto // definition for this message. If any rules are violated, the first error // encountered is returned, or nil if there are no violations. func (m *Host) Validate() error { return m.validate(false) } // ValidateAll checks the field values on Host with the rules defined in the // proto definition for this message. If any rules are violated, the result is // a list of violation errors wrapped in HostMultiError, or nil if none found. func (m *Host) ValidateAll() error { return m.validate(true) } func (m *Host) validate(all bool) error { if m == nil { return nil } var errors []error if utf8.RuneCountInString(m.GetId()) < 1 { err := HostValidationError{ field: "Id", reason: "value length must be at least 1 runes", } if !all { return err } errors = append(errors, err) } if m.GetType() > 3 { err := HostValidationError{ field: "Type", reason: "value must be less than or equal to 3", } if !all { return err } errors = append(errors, err) } if utf8.RuneCountInString(m.GetHostname()) < 1 { err := HostValidationError{ field: "Hostname", reason: "value length must be at least 1 runes", } if !all { return err } errors = append(errors, err) } if ip := net.ParseIP(m.GetIp()); ip == nil { err := HostValidationError{ field: "Ip", reason: "value must be a valid IP address", } if !all { return err } errors = append(errors, err) } if val := m.GetPort(); val < 1024 || val >= 65535 { err := HostValidationError{ field: "Port", reason: "value must be inside range [1024, 65535)", } if !all { return err } errors = append(errors, err) } if val := m.GetDownloadPort(); val < 1024 || val >= 65535 { err := HostValidationError{ field: "DownloadPort", reason: "value must be inside range [1024, 65535)", } if !all { return err } errors = append(errors, err) } // no validation rules for Os // no validation rules for Platform // no validation rules for PlatformFamily // no validation rules for PlatformVersion // no validation rules for KernelVersion // no validation rules for SchedulerClusterId // no validation rules for DisableShared if m.Cpu != nil { if all { switch v := interface{}(m.GetCpu()).(type) { case interface{ ValidateAll() error }: if err := v.ValidateAll(); err != nil { errors = append(errors, HostValidationError{ field: "Cpu", reason: "embedded message failed validation", cause: err, }) } case interface{ Validate() error }: if err := v.Validate(); err != nil { errors = append(errors, HostValidationError{ field: "Cpu", reason: "embedded message failed validation", cause: err, }) } } } else if v, ok := interface{}(m.GetCpu()).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return HostValidationError{ field: "Cpu", reason: "embedded message failed validation", cause: err, } } } } if m.Memory != nil { if all { switch v := interface{}(m.GetMemory()).(type) { case interface{ ValidateAll() error }: if err := v.ValidateAll(); err != nil { errors = append(errors, HostValidationError{ field: "Memory", reason: "embedded message failed validation", cause: err, }) } case interface{ Validate() error }: if err := v.Validate(); err != nil { errors = append(errors, HostValidationError{ field: "Memory", reason: "embedded message failed validation", cause: err, }) } } } else if v, ok := interface{}(m.GetMemory()).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return HostValidationError{ field: "Memory", reason: "embedded message failed validation", cause: err, } } } } if m.Network != nil { if all { switch v := interface{}(m.GetNetwork()).(type) { case interface{ ValidateAll() error }: if err := v.ValidateAll(); err != nil { errors = append(errors, HostValidationError{ field: "Network", reason: "embedded message failed validation", cause: err, }) } case interface{ Validate() error }: if err := v.Validate(); err != nil { errors = append(errors, HostValidationError{ field: "Network", reason: "embedded message failed validation", cause: err, }) } } } else if v, ok := interface{}(m.GetNetwork()).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return HostValidationError{ field: "Network", reason: "embedded message failed validation", cause: err, } } } } if m.Disk != nil { if all { switch v := interface{}(m.GetDisk()).(type) { case interface{ ValidateAll() error }: if err := v.ValidateAll(); err != nil { errors = append(errors, HostValidationError{ field: "Disk", reason: "embedded message failed validation", cause: err, }) } case interface{ Validate() error }: if err := v.Validate(); err != nil { errors = append(errors, HostValidationError{ field: "Disk", reason: "embedded message failed validation", cause: err, }) } } } else if v, ok := interface{}(m.GetDisk()).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return HostValidationError{ field: "Disk", reason: "embedded message failed validation", cause: err, } } } } if m.Build != nil { if all { switch v := interface{}(m.GetBuild()).(type) { case interface{ ValidateAll() error }: if err := v.ValidateAll(); err != nil { errors = append(errors, HostValidationError{ field: "Build", reason: "embedded message failed validation", cause: err, }) } case interface{ Validate() error }: if err := v.Validate(); err != nil { errors = append(errors, HostValidationError{ field: "Build", reason: "embedded message failed validation", cause: err, }) } } } else if v, ok := interface{}(m.GetBuild()).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return HostValidationError{ field: "Build", reason: "embedded message failed validation", cause: err, } } } } if len(errors) > 0 { return HostMultiError(errors) } return nil } // HostMultiError is an error wrapping multiple validation errors returned by // Host.ValidateAll() if the designated constraints aren't met. type HostMultiError []error // Error returns a concatenation of all the error messages it wraps. func (m HostMultiError) Error() string { var msgs []string for _, err := range m { msgs = append(msgs, err.Error()) } return strings.Join(msgs, "; ") } // AllErrors returns a list of validation violation errors. func (m HostMultiError) AllErrors() []error { return m } // HostValidationError is the validation error returned by Host.Validate if the // designated constraints aren't met. type HostValidationError struct { field string reason string cause error key bool } // Field function returns field value. func (e HostValidationError) Field() string { return e.field } // Reason function returns reason value. func (e HostValidationError) Reason() string { return e.reason } // Cause function returns cause value. func (e HostValidationError) Cause() error { return e.cause } // Key function returns key value. func (e HostValidationError) Key() bool { return e.key } // ErrorName returns error name. func (e HostValidationError) ErrorName() string { return "HostValidationError" } // Error satisfies the builtin error interface func (e HostValidationError) Error() string { cause := "" if e.cause != nil { cause = fmt.Sprintf(" | caused by: %v", e.cause) } key := "" if e.key { key = "key for " } return fmt.Sprintf( "invalid %sHost.%s: %s%s", key, e.field, e.reason, cause) } var _ error = HostValidationError{} var _ interface { Field() string Reason() string Key() bool Cause() error ErrorName() string } = HostValidationError{} // Validate checks the field values on CPU with the rules defined in the proto // definition for this message. If any rules are violated, the first error // encountered is returned, or nil if there are no violations. func (m *CPU) Validate() error { return m.validate(false) } // ValidateAll checks the field values on CPU with the rules defined in the // proto definition for this message. If any rules are violated, the result is // a list of violation errors wrapped in CPUMultiError, or nil if none found. func (m *CPU) ValidateAll() error { return m.validate(true) } func (m *CPU) validate(all bool) error { if m == nil { return nil } var errors []error // no validation rules for LogicalCount // no validation rules for PhysicalCount if m.GetPercent() < 0 { err := CPUValidationError{ field: "Percent", reason: "value must be greater than or equal to 0", } if !all { return err } errors = append(errors, err) } if m.GetProcessPercent() < 0 { err := CPUValidationError{ field: "ProcessPercent", reason: "value must be greater than or equal to 0", } if !all { return err } errors = append(errors, err) } if m.Times != nil { if all { switch v := interface{}(m.GetTimes()).(type) { case interface{ ValidateAll() error }: if err := v.ValidateAll(); err != nil { errors = append(errors, CPUValidationError{ field: "Times", reason: "embedded message failed validation", cause: err, }) } case interface{ Validate() error }: if err := v.Validate(); err != nil { errors = append(errors, CPUValidationError{ field: "Times", reason: "embedded message failed validation", cause: err, }) } } } else if v, ok := interface{}(m.GetTimes()).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return CPUValidationError{ field: "Times", reason: "embedded message failed validation", cause: err, } } } } if len(errors) > 0 { return CPUMultiError(errors) } return nil } // CPUMultiError is an error wrapping multiple validation errors returned by // CPU.ValidateAll() if the designated constraints aren't met. type CPUMultiError []error // Error returns a concatenation of all the error messages it wraps. func (m CPUMultiError) Error() string { var msgs []string for _, err := range m { msgs = append(msgs, err.Error()) } return strings.Join(msgs, "; ") } // AllErrors returns a list of validation violation errors. func (m CPUMultiError) AllErrors() []error { return m } // CPUValidationError is the validation error returned by CPU.Validate if the // designated constraints aren't met. type CPUValidationError struct { field string reason string cause error key bool } // Field function returns field value. func (e CPUValidationError) Field() string { return e.field } // Reason function returns reason value. func (e CPUValidationError) Reason() string { return e.reason } // Cause function returns cause value. func (e CPUValidationError) Cause() error { return e.cause } // Key function returns key value. func (e CPUValidationError) Key() bool { return e.key } // ErrorName returns error name. func (e CPUValidationError) ErrorName() string { return "CPUValidationError" } // Error satisfies the builtin error interface func (e CPUValidationError) Error() string { cause := "" if e.cause != nil { cause = fmt.Sprintf(" | caused by: %v", e.cause) } key := "" if e.key { key = "key for " } return fmt.Sprintf( "invalid %sCPU.%s: %s%s", key, e.field, e.reason, cause) } var _ error = CPUValidationError{} var _ interface { Field() string Reason() string Key() bool Cause() error ErrorName() string } = CPUValidationError{} // Validate checks the field values on CPUTimes with the rules defined in the // proto definition for this message. If any rules are violated, the first // error encountered is returned, or nil if there are no violations. func (m *CPUTimes) Validate() error { return m.validate(false) } // ValidateAll checks the field values on CPUTimes with the rules defined in // the proto definition for this message. If any rules are violated, the // result is a list of violation errors wrapped in CPUTimesMultiError, or nil // if none found. func (m *CPUTimes) ValidateAll() error { return m.validate(true) } func (m *CPUTimes) validate(all bool) error { if m == nil { return nil } var errors []error if m.GetUser() < 0 { err := CPUTimesValidationError{ field: "User", reason: "value must be greater than or equal to 0", } if !all { return err } errors = append(errors, err) } if m.GetSystem() < 0 { err := CPUTimesValidationError{ field: "System", reason: "value must be greater than or equal to 0", } if !all { return err } errors = append(errors, err) } if m.GetIdle() < 0 { err := CPUTimesValidationError{ field: "Idle", reason: "value must be greater than or equal to 0", } if !all { return err } errors = append(errors, err) } if m.GetNice() < 0 { err := CPUTimesValidationError{ field: "Nice", reason: "value must be greater than or equal to 0", } if !all { return err } errors = append(errors, err) } if m.GetIowait() < 0 { err := CPUTimesValidationError{ field: "Iowait", reason: "value must be greater than or equal to 0", } if !all { return err } errors = append(errors, err) } if m.GetIrq() < 0 { err := CPUTimesValidationError{ field: "Irq", reason: "value must be greater than or equal to 0", } if !all { return err } errors = append(errors, err) } if m.GetSoftirq() < 0 { err := CPUTimesValidationError{ field: "Softirq", reason: "value must be greater than or equal to 0", } if !all { return err } errors = append(errors, err) } if m.GetSteal() < 0 { err := CPUTimesValidationError{ field: "Steal", reason: "value must be greater than or equal to 0", } if !all { return err } errors = append(errors, err) } if m.GetGuest() < 0 { err := CPUTimesValidationError{ field: "Guest", reason: "value must be greater than or equal to 0", } if !all { return err } errors = append(errors, err) } if m.GetGuestNice() < 0 { err := CPUTimesValidationError{ field: "GuestNice", reason: "value must be greater than or equal to 0", } if !all { return err } errors = append(errors, err) } if len(errors) > 0 { return CPUTimesMultiError(errors) } return nil } // CPUTimesMultiError is an error wrapping multiple validation errors returned // by CPUTimes.ValidateAll() if the designated constraints aren't met. type CPUTimesMultiError []error // Error returns a concatenation of all the error messages it wraps. func (m CPUTimesMultiError) Error() string { var msgs []string for _, err := range m { msgs = append(msgs, err.Error()) } return strings.Join(msgs, "; ") } // AllErrors returns a list of validation violation errors. func (m CPUTimesMultiError) AllErrors() []error { return m } // CPUTimesValidationError is the validation error returned by // CPUTimes.Validate if the designated constraints aren't met. type CPUTimesValidationError struct { field string reason string cause error key bool } // Field function returns field value. func (e CPUTimesValidationError) Field() string { return e.field } // Reason function returns reason value. func (e CPUTimesValidationError) Reason() string { return e.reason } // Cause function returns cause value. func (e CPUTimesValidationError) Cause() error { return e.cause } // Key function returns key value. func (e CPUTimesValidationError) Key() bool { return e.key } // ErrorName returns error name. func (e CPUTimesValidationError) ErrorName() string { return "CPUTimesValidationError" } // Error satisfies the builtin error interface func (e CPUTimesValidationError) Error() string { cause := "" if e.cause != nil { cause = fmt.Sprintf(" | caused by: %v", e.cause) } key := "" if e.key { key = "key for " } return fmt.Sprintf( "invalid %sCPUTimes.%s: %s%s", key, e.field, e.reason, cause) } var _ error = CPUTimesValidationError{} var _ interface { Field() string Reason() string Key() bool Cause() error ErrorName() string } = CPUTimesValidationError{} // Validate checks the field values on Memory with the rules defined in the // proto definition for this message. If any rules are violated, the first // error encountered is returned, or nil if there are no violations. func (m *Memory) Validate() error { return m.validate(false) } // ValidateAll checks the field values on Memory with the rules defined in the // proto definition for this message. If any rules are violated, the result is // a list of violation errors wrapped in MemoryMultiError, or nil if none found. func (m *Memory) ValidateAll() error { return m.validate(true) } func (m *Memory) validate(all bool) error { if m == nil { return nil } var errors []error // no validation rules for Total // no validation rules for Available // no validation rules for Used if val := m.GetUsedPercent(); val < 0 || val > 100 { err := MemoryValidationError{ field: "UsedPercent", reason: "value must be inside range [0, 100]", } if !all { return err } errors = append(errors, err) } if val := m.GetProcessUsedPercent(); val < 0 || val > 100 { err := MemoryValidationError{ field: "ProcessUsedPercent", reason: "value must be inside range [0, 100]", } if !all { return err } errors = append(errors, err) } // no validation rules for Free if len(errors) > 0 { return MemoryMultiError(errors) } return nil } // MemoryMultiError is an error wrapping multiple validation errors returned by // Memory.ValidateAll() if the designated constraints aren't met. type MemoryMultiError []error // Error returns a concatenation of all the error messages it wraps. func (m MemoryMultiError) Error() string { var msgs []string for _, err := range m { msgs = append(msgs, err.Error()) } return strings.Join(msgs, "; ") } // AllErrors returns a list of validation violation errors. func (m MemoryMultiError) AllErrors() []error { return m } // MemoryValidationError is the validation error returned by Memory.Validate if // the designated constraints aren't met. type MemoryValidationError struct { field string reason string cause error key bool } // Field function returns field value. func (e MemoryValidationError) Field() string { return e.field } // Reason function returns reason value. func (e MemoryValidationError) Reason() string { return e.reason } // Cause function returns cause value. func (e MemoryValidationError) Cause() error { return e.cause } // Key function returns key value. func (e MemoryValidationError) Key() bool { return e.key } // ErrorName returns error name. func (e MemoryValidationError) ErrorName() string { return "MemoryValidationError" } // Error satisfies the builtin error interface func (e MemoryValidationError) Error() string { cause := "" if e.cause != nil { cause = fmt.Sprintf(" | caused by: %v", e.cause) } key := "" if e.key { key = "key for " } return fmt.Sprintf( "invalid %sMemory.%s: %s%s", key, e.field, e.reason, cause) } var _ error = MemoryValidationError{} var _ interface { Field() string Reason() string Key() bool Cause() error ErrorName() string } = MemoryValidationError{} // Validate checks the field values on Network with the rules defined in the // proto definition for this message. If any rules are violated, the first // error encountered is returned, or nil if there are no violations. func (m *Network) Validate() error { return m.validate(false) } // ValidateAll checks the field values on Network with the rules defined in the // proto definition for this message. If any rules are violated, the result is // a list of violation errors wrapped in NetworkMultiError, or nil if none found. func (m *Network) ValidateAll() error { return m.validate(true) } func (m *Network) validate(all bool) error { if m == nil { return nil } var errors []error // no validation rules for TcpConnectionCount // no validation rules for UploadTcpConnectionCount // no validation rules for DownloadRate // no validation rules for DownloadRateLimit // no validation rules for UploadRate // no validation rules for UploadRateLimit if m.Location != nil { // no validation rules for Location } if m.Idc != nil { // no validation rules for Idc } if len(errors) > 0 { return NetworkMultiError(errors) } return nil } // NetworkMultiError is an error wrapping multiple validation errors returned // by Network.ValidateAll() if the designated constraints aren't met. type NetworkMultiError []error // Error returns a concatenation of all the error messages it wraps. func (m NetworkMultiError) Error() string { var msgs []string for _, err := range m { msgs = append(msgs, err.Error()) } return strings.Join(msgs, "; ") } // AllErrors returns a list of validation violation errors. func (m NetworkMultiError) AllErrors() []error { return m } // NetworkValidationError is the validation error returned by Network.Validate // if the designated constraints aren't met. type NetworkValidationError struct { field string reason string cause error key bool } // Field function returns field value. func (e NetworkValidationError) Field() string { return e.field } // Reason function returns reason value. func (e NetworkValidationError) Reason() string { return e.reason } // Cause function returns cause value. func (e NetworkValidationError) Cause() error { return e.cause } // Key function returns key value. func (e NetworkValidationError) Key() bool { return e.key } // ErrorName returns error name. func (e NetworkValidationError) ErrorName() string { return "NetworkValidationError" } // Error satisfies the builtin error interface func (e NetworkValidationError) Error() string { cause := "" if e.cause != nil { cause = fmt.Sprintf(" | caused by: %v", e.cause) } key := "" if e.key { key = "key for " } return fmt.Sprintf( "invalid %sNetwork.%s: %s%s", key, e.field, e.reason, cause) } var _ error = NetworkValidationError{} var _ interface { Field() string Reason() string Key() bool Cause() error ErrorName() string } = NetworkValidationError{} // Validate checks the field values on Disk with the rules defined in the proto // definition for this message. If any rules are violated, the first error // encountered is returned, or nil if there are no violations. func (m *Disk) Validate() error { return m.validate(false) } // ValidateAll checks the field values on Disk with the rules defined in the // proto definition for this message. If any rules are violated, the result is // a list of violation errors wrapped in DiskMultiError, or nil if none found. func (m *Disk) ValidateAll() error { return m.validate(true) } func (m *Disk) validate(all bool) error { if m == nil { return nil } var errors []error // no validation rules for Total // no validation rules for Free // no validation rules for Used if val := m.GetUsedPercent(); val < 0 || val > 100 { err := DiskValidationError{ field: "UsedPercent", reason: "value must be inside range [0, 100]", } if !all { return err } errors = append(errors, err) } // no validation rules for InodesTotal // no validation rules for InodesUsed // no validation rules for InodesFree if val := m.GetInodesUsedPercent(); val < 0 || val > 100 { err := DiskValidationError{ field: "InodesUsedPercent", reason: "value must be inside range [0, 100]", } if !all { return err } errors = append(errors, err) } // no validation rules for ReadBandwidth // no validation rules for WriteBandwidth if len(errors) > 0 { return DiskMultiError(errors) } return nil } // DiskMultiError is an error wrapping multiple validation errors returned by // Disk.ValidateAll() if the designated constraints aren't met. type DiskMultiError []error // Error returns a concatenation of all the error messages it wraps. func (m DiskMultiError) Error() string { var msgs []string for _, err := range m { msgs = append(msgs, err.Error()) } return strings.Join(msgs, "; ") } // AllErrors returns a list of validation violation errors. func (m DiskMultiError) AllErrors() []error { return m } // DiskValidationError is the validation error returned by Disk.Validate if the // designated constraints aren't met. type DiskValidationError struct { field string reason string cause error key bool } // Field function returns field value. func (e DiskValidationError) Field() string { return e.field } // Reason function returns reason value. func (e DiskValidationError) Reason() string { return e.reason } // Cause function returns cause value. func (e DiskValidationError) Cause() error { return e.cause } // Key function returns key value. func (e DiskValidationError) Key() bool { return e.key } // ErrorName returns error name. func (e DiskValidationError) ErrorName() string { return "DiskValidationError" } // Error satisfies the builtin error interface func (e DiskValidationError) Error() string { cause := "" if e.cause != nil { cause = fmt.Sprintf(" | caused by: %v", e.cause) } key := "" if e.key { key = "key for " } return fmt.Sprintf( "invalid %sDisk.%s: %s%s", key, e.field, e.reason, cause) } var _ error = DiskValidationError{} var _ interface { Field() string Reason() string Key() bool Cause() error ErrorName() string } = DiskValidationError{} // Validate checks the field values on Build with the rules defined in the // proto definition for this message. If any rules are violated, the first // error encountered is returned, or nil if there are no violations. func (m *Build) Validate() error { return m.validate(false) } // ValidateAll checks the field values on Build with the rules defined in the // proto definition for this message. If any rules are violated, the result is // a list of violation errors wrapped in BuildMultiError, or nil if none found. func (m *Build) ValidateAll() error { return m.validate(true) } func (m *Build) validate(all bool) error { if m == nil { return nil } var errors []error // no validation rules for GitVersion if m.GitCommit != nil { // no validation rules for GitCommit } if m.GoVersion != nil { // no validation rules for GoVersion } if m.RustVersion != nil { // no validation rules for RustVersion } if m.Platform != nil { // no validation rules for Platform } if len(errors) > 0 { return BuildMultiError(errors) } return nil } // BuildMultiError is an error wrapping multiple validation errors returned by // Build.ValidateAll() if the designated constraints aren't met. type BuildMultiError []error // Error returns a concatenation of all the error messages it wraps. func (m BuildMultiError) Error() string { var msgs []string for _, err := range m { msgs = append(msgs, err.Error()) } return strings.Join(msgs, "; ") } // AllErrors returns a list of validation violation errors. func (m BuildMultiError) AllErrors() []error { return m } // BuildValidationError is the validation error returned by Build.Validate if // the designated constraints aren't met. type BuildValidationError struct { field string reason string cause error key bool } // Field function returns field value. func (e BuildValidationError) Field() string { return e.field } // Reason function returns reason value. func (e BuildValidationError) Reason() string { return e.reason } // Cause function returns cause value. func (e BuildValidationError) Cause() error { return e.cause } // Key function returns key value. func (e BuildValidationError) Key() bool { return e.key } // ErrorName returns error name. func (e BuildValidationError) ErrorName() string { return "BuildValidationError" } // Error satisfies the builtin error interface func (e BuildValidationError) Error() string { cause := "" if e.cause != nil { cause = fmt.Sprintf(" | caused by: %v", e.cause) } key := "" if e.key { key = "key for " } return fmt.Sprintf( "invalid %sBuild.%s: %s%s", key, e.field, e.reason, cause) } var _ error = BuildValidationError{} var _ interface { Field() string Reason() string Key() bool Cause() error ErrorName() string } = BuildValidationError{} // Validate checks the field values on Download with the rules defined in the // proto definition for this message. If any rules are violated, the first // error encountered is returned, or nil if there are no violations. func (m *Download) Validate() error { return m.validate(false) } // ValidateAll checks the field values on Download with the rules defined in // the proto definition for this message. If any rules are violated, the // result is a list of violation errors wrapped in DownloadMultiError, or nil // if none found. func (m *Download) ValidateAll() error { return m.validate(true) } func (m *Download) validate(all bool) error { if m == nil { return nil } var errors []error if uri, err := url.Parse(m.GetUrl()); err != nil { err = DownloadValidationError{ field: "Url", reason: "value must be a valid URI", cause: err, } if !all { return err } errors = append(errors, err) } else if !uri.IsAbs() { err := DownloadValidationError{ field: "Url", reason: "value must be absolute", } if !all { return err } errors = append(errors, err) } if _, ok := TaskType_name[int32(m.GetType())]; !ok { err := DownloadValidationError{ field: "Type", reason: "value must be one of the defined enum values", } if !all { return err } errors = append(errors, err) } if _, ok := Priority_name[int32(m.GetPriority())]; !ok { err := DownloadValidationError{ field: "Priority", reason: "value must be one of the defined enum values", } if !all { return err } errors = append(errors, err) } // no validation rules for RequestHeader // no validation rules for DisableBackToSource // no validation rules for NeedBackToSource // no validation rules for Prefetch // no validation rules for IsPrefetch if m.Digest != nil { if m.GetDigest() != "" { if !_Download_Digest_Pattern.MatchString(m.GetDigest()) { err := DownloadValidationError{ field: "Digest", reason: "value does not match regex pattern \"^(md5:[a-fA-F0-9]{32}|sha1:[a-fA-F0-9]{40}|sha256:[a-fA-F0-9]{64}|sha512:[a-fA-F0-9]{128}|blake3:[a-fA-F0-9]{64}|crc32:[a-fA-F0-9]+)$\"", } if !all { return err } errors = append(errors, err) } } } if m.Range != nil { if all { switch v := interface{}(m.GetRange()).(type) { case interface{ ValidateAll() error }: if err := v.ValidateAll(); err != nil { errors = append(errors, DownloadValidationError{ field: "Range", reason: "embedded message failed validation", cause: err, }) } case interface{ Validate() error }: if err := v.Validate(); err != nil { errors = append(errors, DownloadValidationError{ field: "Range", reason: "embedded message failed validation", cause: err, }) } } } else if v, ok := interface{}(m.GetRange()).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return DownloadValidationError{ field: "Range", reason: "embedded message failed validation", cause: err, } } } } if m.Tag != nil { // no validation rules for Tag } if m.Application != nil { // no validation rules for Application } if m.PieceLength != nil { if m.GetPieceLength() != 0 { if m.GetPieceLength() < 1 { err := DownloadValidationError{ field: "PieceLength", reason: "value must be greater than or equal to 1", } if !all { return err } errors = append(errors, err) } } } if m.OutputPath != nil { if m.GetOutputPath() != "" { if utf8.RuneCountInString(m.GetOutputPath()) < 1 { err := DownloadValidationError{ field: "OutputPath", reason: "value length must be at least 1 runes", } if !all { return err } errors = append(errors, err) } } } if m.Timeout != nil { if all { switch v := interface{}(m.GetTimeout()).(type) { case interface{ ValidateAll() error }: if err := v.ValidateAll(); err != nil { errors = append(errors, DownloadValidationError{ field: "Timeout", reason: "embedded message failed validation", cause: err, }) } case interface{ Validate() error }: if err := v.Validate(); err != nil { errors = append(errors, DownloadValidationError{ field: "Timeout", reason: "embedded message failed validation", cause: err, }) } } } else if v, ok := interface{}(m.GetTimeout()).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return DownloadValidationError{ field: "Timeout", reason: "embedded message failed validation", cause: err, } } } } if m.ObjectStorage != nil { if all { switch v := interface{}(m.GetObjectStorage()).(type) { case interface{ ValidateAll() error }: if err := v.ValidateAll(); err != nil { errors = append(errors, DownloadValidationError{ field: "ObjectStorage", reason: "embedded message failed validation", cause: err, }) } case interface{ Validate() error }: if err := v.Validate(); err != nil { errors = append(errors, DownloadValidationError{ field: "ObjectStorage", reason: "embedded message failed validation", cause: err, }) } } } else if v, ok := interface{}(m.GetObjectStorage()).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return DownloadValidationError{ field: "ObjectStorage", reason: "embedded message failed validation", cause: err, } } } } if m.Hdfs != nil { if all { switch v := interface{}(m.GetHdfs()).(type) { case interface{ ValidateAll() error }: if err := v.ValidateAll(); err != nil { errors = append(errors, DownloadValidationError{ field: "Hdfs", reason: "embedded message failed validation", cause: err, }) } case interface{ Validate() error }: if err := v.Validate(); err != nil { errors = append(errors, DownloadValidationError{ field: "Hdfs", reason: "embedded message failed validation", cause: err, }) } } } else if v, ok := interface{}(m.GetHdfs()).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return DownloadValidationError{ field: "Hdfs", reason: "embedded message failed validation", cause: err, } } } } if len(errors) > 0 { return DownloadMultiError(errors) } return nil } // DownloadMultiError is an error wrapping multiple validation errors returned // by Download.ValidateAll() if the designated constraints aren't met. type DownloadMultiError []error // Error returns a concatenation of all the error messages it wraps. func (m DownloadMultiError) Error() string { var msgs []string for _, err := range m { msgs = append(msgs, err.Error()) } return strings.Join(msgs, "; ") } // AllErrors returns a list of validation violation errors. func (m DownloadMultiError) AllErrors() []error { return m } // DownloadValidationError is the validation error returned by // Download.Validate if the designated constraints aren't met. type DownloadValidationError struct { field string reason string cause error key bool } // Field function returns field value. func (e DownloadValidationError) Field() string { return e.field } // Reason function returns reason value. func (e DownloadValidationError) Reason() string { return e.reason } // Cause function returns cause value. func (e DownloadValidationError) Cause() error { return e.cause } // Key function returns key value. func (e DownloadValidationError) Key() bool { return e.key } // ErrorName returns error name. func (e DownloadValidationError) ErrorName() string { return "DownloadValidationError" } // Error satisfies the builtin error interface func (e DownloadValidationError) Error() string { cause := "" if e.cause != nil { cause = fmt.Sprintf(" | caused by: %v", e.cause) } key := "" if e.key { key = "key for " } return fmt.Sprintf( "invalid %sDownload.%s: %s%s", key, e.field, e.reason, cause) } var _ error = DownloadValidationError{} var _ interface { Field() string Reason() string Key() bool Cause() error ErrorName() string } = DownloadValidationError{} var _Download_Digest_Pattern = regexp.MustCompile("^(md5:[a-fA-F0-9]{32}|sha1:[a-fA-F0-9]{40}|sha256:[a-fA-F0-9]{64}|sha512:[a-fA-F0-9]{128}|blake3:[a-fA-F0-9]{64}|crc32:[a-fA-F0-9]+)$") // Validate checks the field values on ObjectStorage with the rules defined in // the proto definition for this message. If any rules are violated, the first // error encountered is returned, or nil if there are no violations. func (m *ObjectStorage) Validate() error { return m.validate(false) } // ValidateAll checks the field values on ObjectStorage with the rules defined // in the proto definition for this message. If any rules are violated, the // result is a list of violation errors wrapped in ObjectStorageMultiError, or // nil if none found. func (m *ObjectStorage) ValidateAll() error { return m.validate(true) } func (m *ObjectStorage) validate(all bool) error { if m == nil { return nil } var errors []error if m.Region != nil { if m.GetRegion() != "" { if utf8.RuneCountInString(m.GetRegion()) < 1 { err := ObjectStorageValidationError{ field: "Region", reason: "value length must be at least 1 runes", } if !all { return err } errors = append(errors, err) } } } if m.Endpoint != nil { if m.GetEndpoint() != "" { if utf8.RuneCountInString(m.GetEndpoint()) < 1 { err := ObjectStorageValidationError{ field: "Endpoint", reason: "value length must be at least 1 runes", } if !all { return err } errors = append(errors, err) } } } if m.AccessKeyId != nil { if utf8.RuneCountInString(m.GetAccessKeyId()) < 1 { err := ObjectStorageValidationError{ field: "AccessKeyId", reason: "value length must be at least 1 runes", } if !all { return err } errors = append(errors, err) } } if m.AccessKeySecret != nil { if utf8.RuneCountInString(m.GetAccessKeySecret()) < 1 { err := ObjectStorageValidationError{ field: "AccessKeySecret", reason: "value length must be at least 1 runes", } if !all { return err } errors = append(errors, err) } } if m.SessionToken != nil { if m.GetSessionToken() != "" { if utf8.RuneCountInString(m.GetSessionToken()) < 1 { err := ObjectStorageValidationError{ field: "SessionToken", reason: "value length must be at least 1 runes", } if !all { return err } errors = append(errors, err) } } } if m.CredentialPath != nil { if m.GetCredentialPath() != "" { if utf8.RuneCountInString(m.GetCredentialPath()) < 1 { err := ObjectStorageValidationError{ field: "CredentialPath", reason: "value length must be at least 1 runes", } if !all { return err } errors = append(errors, err) } } } if m.PredefinedAcl != nil { if m.GetPredefinedAcl() != "" { if utf8.RuneCountInString(m.GetPredefinedAcl()) < 1 { err := ObjectStorageValidationError{ field: "PredefinedAcl", reason: "value length must be at least 1 runes", } if !all { return err } errors = append(errors, err) } } } if len(errors) > 0 { return ObjectStorageMultiError(errors) } return nil } // ObjectStorageMultiError is an error wrapping multiple validation errors // returned by ObjectStorage.ValidateAll() if the designated constraints // aren't met. type ObjectStorageMultiError []error // Error returns a concatenation of all the error messages it wraps. func (m ObjectStorageMultiError) Error() string { var msgs []string for _, err := range m { msgs = append(msgs, err.Error()) } return strings.Join(msgs, "; ") } // AllErrors returns a list of validation violation errors. func (m ObjectStorageMultiError) AllErrors() []error { return m } // ObjectStorageValidationError is the validation error returned by // ObjectStorage.Validate if the designated constraints aren't met. type ObjectStorageValidationError struct { field string reason string cause error key bool } // Field function returns field value. func (e ObjectStorageValidationError) Field() string { return e.field } // Reason function returns reason value. func (e ObjectStorageValidationError) Reason() string { return e.reason } // Cause function returns cause value. func (e ObjectStorageValidationError) Cause() error { return e.cause } // Key function returns key value. func (e ObjectStorageValidationError) Key() bool { return e.key } // ErrorName returns error name. func (e ObjectStorageValidationError) ErrorName() string { return "ObjectStorageValidationError" } // Error satisfies the builtin error interface func (e ObjectStorageValidationError) Error() string { cause := "" if e.cause != nil { cause = fmt.Sprintf(" | caused by: %v", e.cause) } key := "" if e.key { key = "key for " } return fmt.Sprintf( "invalid %sObjectStorage.%s: %s%s", key, e.field, e.reason, cause) } var _ error = ObjectStorageValidationError{} var _ interface { Field() string Reason() string Key() bool Cause() error ErrorName() string } = ObjectStorageValidationError{} // Validate checks the field values on HDFS with the rules defined in the proto // definition for this message. If any rules are violated, the first error // encountered is returned, or nil if there are no violations. func (m *HDFS) Validate() error { return m.validate(false) } // ValidateAll checks the field values on HDFS with the rules defined in the // proto definition for this message. If any rules are violated, the result is // a list of violation errors wrapped in HDFSMultiError, or nil if none found. func (m *HDFS) ValidateAll() error { return m.validate(true) } func (m *HDFS) validate(all bool) error { if m == nil { return nil } var errors []error if m.DelegationToken != nil { if m.GetDelegationToken() != "" { if utf8.RuneCountInString(m.GetDelegationToken()) < 1 { err := HDFSValidationError{ field: "DelegationToken", reason: "value length must be at least 1 runes", } if !all { return err } errors = append(errors, err) } } } if len(errors) > 0 { return HDFSMultiError(errors) } return nil } // HDFSMultiError is an error wrapping multiple validation errors returned by // HDFS.ValidateAll() if the designated constraints aren't met. type HDFSMultiError []error // Error returns a concatenation of all the error messages it wraps. func (m HDFSMultiError) Error() string { var msgs []string for _, err := range m { msgs = append(msgs, err.Error()) } return strings.Join(msgs, "; ") } // AllErrors returns a list of validation violation errors. func (m HDFSMultiError) AllErrors() []error { return m } // HDFSValidationError is the validation error returned by HDFS.Validate if the // designated constraints aren't met. type HDFSValidationError struct { field string reason string cause error key bool } // Field function returns field value. func (e HDFSValidationError) Field() string { return e.field } // Reason function returns reason value. func (e HDFSValidationError) Reason() string { return e.reason } // Cause function returns cause value. func (e HDFSValidationError) Cause() error { return e.cause } // Key function returns key value. func (e HDFSValidationError) Key() bool { return e.key } // ErrorName returns error name. func (e HDFSValidationError) ErrorName() string { return "HDFSValidationError" } // Error satisfies the builtin error interface func (e HDFSValidationError) Error() string { cause := "" if e.cause != nil { cause = fmt.Sprintf(" | caused by: %v", e.cause) } key := "" if e.key { key = "key for " } return fmt.Sprintf( "invalid %sHDFS.%s: %s%s", key, e.field, e.reason, cause) } var _ error = HDFSValidationError{} var _ interface { Field() string Reason() string Key() bool Cause() error ErrorName() string } = HDFSValidationError{} // Validate checks the field values on Range with the rules defined in the // proto definition for this message. If any rules are violated, the first // error encountered is returned, or nil if there are no violations. func (m *Range) Validate() error { return m.validate(false) } // ValidateAll checks the field values on Range with the rules defined in the // proto definition for this message. If any rules are violated, the result is // a list of violation errors wrapped in RangeMultiError, or nil if none found. func (m *Range) ValidateAll() error { return m.validate(true) } func (m *Range) validate(all bool) error { if m == nil { return nil } var errors []error // no validation rules for Start // no validation rules for Length if len(errors) > 0 { return RangeMultiError(errors) } return nil } // RangeMultiError is an error wrapping multiple validation errors returned by // Range.ValidateAll() if the designated constraints aren't met. type RangeMultiError []error // Error returns a concatenation of all the error messages it wraps. func (m RangeMultiError) Error() string { var msgs []string for _, err := range m { msgs = append(msgs, err.Error()) } return strings.Join(msgs, "; ") } // AllErrors returns a list of validation violation errors. func (m RangeMultiError) AllErrors() []error { return m } // RangeValidationError is the validation error returned by Range.Validate if // the designated constraints aren't met. type RangeValidationError struct { field string reason string cause error key bool } // Field function returns field value. func (e RangeValidationError) Field() string { return e.field } // Reason function returns reason value. func (e RangeValidationError) Reason() string { return e.reason } // Cause function returns cause value. func (e RangeValidationError) Cause() error { return e.cause } // Key function returns key value. func (e RangeValidationError) Key() bool { return e.key } // ErrorName returns error name. func (e RangeValidationError) ErrorName() string { return "RangeValidationError" } // Error satisfies the builtin error interface func (e RangeValidationError) Error() string { cause := "" if e.cause != nil { cause = fmt.Sprintf(" | caused by: %v", e.cause) } key := "" if e.key { key = "key for " } return fmt.Sprintf( "invalid %sRange.%s: %s%s", key, e.field, e.reason, cause) } var _ error = RangeValidationError{} var _ interface { Field() string Reason() string Key() bool Cause() error ErrorName() string } = RangeValidationError{} // Validate checks the field values on Piece with the rules defined in the // proto definition for this message. If any rules are violated, the first // error encountered is returned, or nil if there are no violations. func (m *Piece) Validate() error { return m.validate(false) } // ValidateAll checks the field values on Piece with the rules defined in the // proto definition for this message. If any rules are violated, the result is // a list of violation errors wrapped in PieceMultiError, or nil if none found. func (m *Piece) ValidateAll() error { return m.validate(true) } func (m *Piece) validate(all bool) error { if m == nil { return nil } var errors []error // no validation rules for Number // no validation rules for Offset // no validation rules for Length if m.GetDigest() != "" { if !_Piece_Digest_Pattern.MatchString(m.GetDigest()) { err := PieceValidationError{ field: "Digest", reason: "value does not match regex pattern \"^(md5:[a-fA-F0-9]{32}|sha1:[a-fA-F0-9]{40}|sha256:[a-fA-F0-9]{64}|sha512:[a-fA-F0-9]{128}|blake3:[a-fA-F0-9]{64}|crc32:[a-fA-F0-9]+)$\"", } if !all { return err } errors = append(errors, err) } } if m.GetCost() == nil { err := PieceValidationError{ field: "Cost", reason: "value is required", } if !all { return err } errors = append(errors, err) } if m.GetCreatedAt() == nil { err := PieceValidationError{ field: "CreatedAt", reason: "value is required", } if !all { return err } errors = append(errors, err) } if m.ParentId != nil { if m.GetParentId() != "" { if utf8.RuneCountInString(m.GetParentId()) < 1 { err := PieceValidationError{ field: "ParentId", reason: "value length must be at least 1 runes", } if !all { return err } errors = append(errors, err) } } } if m.Content != nil { if len(m.GetContent()) > 0 { if len(m.GetContent()) < 1 { err := PieceValidationError{ field: "Content", reason: "value length must be at least 1 bytes", } if !all { return err } errors = append(errors, err) } } } if m.TrafficType != nil { // no validation rules for TrafficType } if len(errors) > 0 { return PieceMultiError(errors) } return nil } // PieceMultiError is an error wrapping multiple validation errors returned by // Piece.ValidateAll() if the designated constraints aren't met. type PieceMultiError []error // Error returns a concatenation of all the error messages it wraps. func (m PieceMultiError) Error() string { var msgs []string for _, err := range m { msgs = append(msgs, err.Error()) } return strings.Join(msgs, "; ") } // AllErrors returns a list of validation violation errors. func (m PieceMultiError) AllErrors() []error { return m } // PieceValidationError is the validation error returned by Piece.Validate if // the designated constraints aren't met. type PieceValidationError struct { field string reason string cause error key bool } // Field function returns field value. func (e PieceValidationError) Field() string { return e.field } // Reason function returns reason value. func (e PieceValidationError) Reason() string { return e.reason } // Cause function returns cause value. func (e PieceValidationError) Cause() error { return e.cause } // Key function returns key value. func (e PieceValidationError) Key() bool { return e.key } // ErrorName returns error name. func (e PieceValidationError) ErrorName() string { return "PieceValidationError" } // Error satisfies the builtin error interface func (e PieceValidationError) Error() string { cause := "" if e.cause != nil { cause = fmt.Sprintf(" | caused by: %v", e.cause) } key := "" if e.key { key = "key for " } return fmt.Sprintf( "invalid %sPiece.%s: %s%s", key, e.field, e.reason, cause) } var _ error = PieceValidationError{} var _ interface { Field() string Reason() string Key() bool Cause() error ErrorName() string } = PieceValidationError{} var _Piece_Digest_Pattern = regexp.MustCompile("^(md5:[a-fA-F0-9]{32}|sha1:[a-fA-F0-9]{40}|sha256:[a-fA-F0-9]{64}|sha512:[a-fA-F0-9]{128}|blake3:[a-fA-F0-9]{64}|crc32:[a-fA-F0-9]+)$")