diff --git a/contracts/go/seats/meshcatalog/contract.go b/contracts/go/seats/meshcatalog/contract.go index 32870c7c..4c98ac35 100644 --- a/contracts/go/seats/meshcatalog/contract.go +++ b/contracts/go/seats/meshcatalog/contract.go @@ -58,13 +58,12 @@ const SubjectManifestAccepted = "mesh.seat.mesh-catalog.event.manifest-accepted" const SubjectManifestRefused = "mesh.seat.mesh-catalog.event.manifest-refused" const ( - StateManifests = "manifests" - StateModules = "modules" - StateCandidates = "candidates" - StateVerdicts = "verdicts" - StatePredefined = "predefined" - StateConfigCandidates = "config-candidates" - StatePackages = "packages" + StateManifests = "manifests" + StateModules = "modules" + StateCandidates = "candidates" + StateVerdicts = "verdicts" + StatePredefined = "predefined" + StatePackages = "packages" ) // ManifestsByDigestKey is the key of one value of the state manifests under the form "". @@ -221,37 +220,6 @@ func DecodePredefinedByListValue(raw []byte) (PredefinedByListValue, error) { return v, nil } -// ConfigCandidatesByPullKey is the key of one value of the state config-candidates under the form "". -func ConfigCandidatesByPullKey(pull string) string { return pull } - -// ParseConfigCandidatesByPullKey reads the parts of a key of the form "", in the order of the form; the last result is false for a key of another form. -func ParseConfigCandidatesByPullKey(key string) (string, bool) { - rest := key - if rest == "" { - return "", false - } - v0 := rest - rest = "" - if rest != "" { - return "", false - } - return v0, true -} - -// DecodeConfigCandidatesByPullValue reads one value of the state config-candidates under the form "", refusing a field ConfigCandidatesByPullValue does not know and any text after the value. -func DecodeConfigCandidatesByPullValue(raw []byte) (ConfigCandidatesByPullValue, error) { - var v ConfigCandidatesByPullValue - dec := json.NewDecoder(bytes.NewReader(raw)) - dec.DisallowUnknownFields() - if err := dec.Decode(&v); err != nil { - return v, err - } - if dec.More() { - return v, errors.New("text after the value") - } - return v, nil -} - // PackagesByModuleKey is the key of one value of the state packages under the form "". func PackagesByModuleKey(module string) string { return module } @@ -584,39 +552,6 @@ type PredefinedByListValue struct { V int64 `json:"v,omitempty"` } -// ConfigCandidatesByPullValueDeclaresValueValue is a type of the contract. -type ConfigCandidatesByPullValueDeclaresValueValue struct { - // the default - Default any `json:"default"` - Description string `json:"description,omitempty"` - // the allowed values - Enum any `json:"enum,omitempty"` - Kind string `json:"kind"` - // a declared bound; 0 is a bound, absent is none - Maximum *float64 `json:"maximum,omitempty"` - // a declared bound; 0 is a bound, absent is none - Minimum *float64 `json:"minimum,omitempty"` - Pattern string `json:"pattern,omitempty"` - Predefined string `json:"predefined,omitempty"` - Required bool `json:"required,omitempty"` - Runtime bool `json:"runtime,omitempty"` - Trusted bool `json:"trusted,omitempty"` - Type string `json:"type,omitempty"` - Why string `json:"why"` -} - -// ConfigCandidatesByPullValue is one value of the state config-candidates under the key . -type ConfigCandidatesByPullValue struct { - // when (RFC 3339 time) - At *time.Time `json:"at,omitempty"` - // module to key to declaration - Declares map[string]map[string]ConfigCandidatesByPullValueDeclaresValueValue `json:"declares"` - Head string `json:"head"` - Pull string `json:"pull"` - // the layout version - V int64 `json:"v,omitempty"` -} - // PackagesByModuleValuePackagesItem is a type of the contract. type PackagesByModuleValuePackagesItem struct { Digest string `json:"digest"` diff --git a/contracts/go/seats/meshcatalog/contract_test.go b/contracts/go/seats/meshcatalog/contract_test.go index b6d95b15..8c962d92 100644 --- a/contracts/go/seats/meshcatalog/contract_test.go +++ b/contracts/go/seats/meshcatalog/contract_test.go @@ -27,18 +27,6 @@ func TestFixtures(t *testing.T) { decode: func(b []byte) (any, error) { var v VerdictsByDigestValue; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil}, {name: "the predefined list", subject: "", given: "{\"commit\":\"cccccccccccccccccccccccccccccccccccccccc\",\"list\":{\"streams\":[]},\"v\":1}", wire: "{\"commit\":\"cccccccccccccccccccccccccccccccccccccccc\",\"list\":{\"streams\":[]},\"v\":1}", decode: func(b []byte) (any, error) { var v PredefinedByListValue; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil}, - {name: "a pull request's configuration", subject: "", given: "{\"declares\":{\"nats\":{\"limit\":{\"default\":1,\"kind\":\"setting\",\"why\":\"a bound\"}}},\"head\":\"cccccccccccccccccccccccccccccccccccccccc\",\"pull\":\"novox/mesh-catalog#1\",\"v\":1}", wire: "{\"declares\":{\"nats\":{\"limit\":{\"default\":1,\"kind\":\"setting\",\"why\":\"a bound\"}}},\"head\":\"cccccccccccccccccccccccccccccccccccccccc\",\"pull\":\"novox/mesh-catalog#1\",\"v\":1}", - decode: func(b []byte) (any, error) { - var v ConfigCandidatesByPullValue - err := json.Unmarshal(b, &v) - return v, err - }, subjectIs: nil}, - {name: "a pull request's configuration state whose bounds are declared 0 (a zero is a bound, not none)", subject: "", given: "{\"declares\":{\"nats\":{\"limit\":{\"default\":0,\"kind\":\"setting\",\"maximum\":0,\"minimum\":0,\"why\":\"a bound\"}}},\"head\":\"cccccccccccccccccccccccccccccccccccccccc\",\"pull\":\"novox/mesh-catalog#1\",\"v\":1}", wire: "{\"declares\":{\"nats\":{\"limit\":{\"default\":0,\"kind\":\"setting\",\"maximum\":0,\"minimum\":0,\"why\":\"a bound\"}}},\"head\":\"cccccccccccccccccccccccccccccccccccccccc\",\"pull\":\"novox/mesh-catalog#1\",\"v\":1}", - decode: func(b []byte) (any, error) { - var v ConfigCandidatesByPullValue - err := json.Unmarshal(b, &v) - return v, err - }, subjectIs: nil}, {name: "a published Go module", subject: "", given: "{\"commit\":\"cccccccccccccccccccccccccccccccccccccccc\",\"module\":\"git.novox.be/novox/mesh-sdk/go\",\"packages\":[{\"digest\":\"ab\",\"package\":\"git.novox.be/novox/mesh-sdk/go/keys\"}],\"repository\":\"novox/mesh-sdk\",\"v\":1}", wire: "{\"commit\":\"cccccccccccccccccccccccccccccccccccccccc\",\"module\":\"git.novox.be/novox/mesh-sdk/go\",\"packages\":[{\"digest\":\"ab\",\"package\":\"git.novox.be/novox/mesh-sdk/go/keys\"}],\"repository\":\"novox/mesh-sdk\",\"v\":1}", decode: func(b []byte) (any, error) { var v PackagesByModuleValue; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil}, {name: "a package series", subject: "", given: "{\"name\":\"go-keys\",\"series\":\"0.1\",\"v\":1}", wire: "{\"name\":\"go-keys\",\"series\":\"0.1\",\"v\":1}",