MCPcopy Index your code
hub / github.com/coder/coder / Validate

Method Validate

vpn/version.go:115–131  ·  view source on GitHub ↗

Validate returns an error if the version list is not sorted or contains duplicate major versions.

()

Source from the content-addressed store, hash-verified

113// Validate returns an error if the version list is not sorted or contains
114// duplicate major versions.
115func (vl RPCVersionList) Validate() error {
116 if len(vl.Versions) == 0 {
117 return xerrors.New("no versions")
118 }
119 for i := 0; i < len(vl.Versions); i++ {
120 if vl.Versions[i].Major == 0 {
121 return xerrors.Errorf("invalid version: %s", vl.Versions[i].String())
122 }
123 if i > 0 && vl.Versions[i-1].Major == vl.Versions[i].Major {
124 return xerrors.Errorf("duplicate major version: %d", vl.Versions[i].Major)
125 }
126 if i > 0 && vl.Versions[i-1].Major > vl.Versions[i].Major {
127 return xerrors.Errorf("versions are not sorted")
128 }
129 }
130 return nil
131}
132
133// IsCompatibleWith returns the lowest version that is compatible with both
134// version lists. If the versions are not compatible, the second return value

Callers 1

ParseRPCVersionListFunction · 0.95

Calls 3

NewMethod · 0.65
ErrorfMethod · 0.45
StringMethod · 0.45

Tested by

no test coverage detected