Skip to content

Commit

Permalink
renamed OptCluster to Cluster (#146)
Browse files Browse the repository at this point in the history
Signed-off-by: Matthias Hanel <mh@synadia.com>
  • Loading branch information
matthiashanel authored Feb 8, 2021
1 parent 397d4ee commit ff814ca
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
21 changes: 12 additions & 9 deletions v2/account_claims.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,16 @@ func (o *OperatorLimits) Validate(_ *ValidationResults) {

// Mapping for publishes
type WeightedMapping struct {
Subject Subject `json:"subject"`
Weight uint8 `json:"weight,omitempty"`
OptCluster string `json:"cluster,omitempty"`
Subject Subject `json:"subject"`
Weight uint8 `json:"weight,omitempty"`
Cluster string `json:"cluster,omitempty"`
}

func (m *WeightedMapping) GetWeight() uint8 {
if m.Weight == 0 {
return 100
}
return m.Weight
}

type Mapping map[Subject][]WeightedMapping
Expand All @@ -103,11 +110,7 @@ func (m *Mapping) Validate(vr *ValidationResults) {
vr.AddError("Subject %q in weighted mapping %q is not allowed to contains wildcard",
string(wm.Subject), ubFrom)
}
weight := wm.Weight
if wm.Weight == 0 {
weight += 100
}
total += weight
total += wm.GetWeight()
}
if total > 100 {
vr.AddError("Mapping %q exceeds 100%% among all of it's weighted to mappings", ubFrom)
Expand All @@ -127,7 +130,7 @@ type Account struct {
SigningKeys SigningKeys `json:"signing_keys,omitempty"`
Revocations RevocationList `json:"revocations,omitempty"`
DefaultPermissions Permissions `json:"default_permissions,omitempty"`
Mappings Mapping `json:"mappings,omitempty"`
Mappings Mapping `json:"mappings,omitempty"`
Info
GenericFields
}
Expand Down
2 changes: 1 addition & 1 deletion v2/account_claims_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -620,7 +620,7 @@ func TestAccountMapping(t *testing.T) { // don't block encoding!!!
vr = &ValidationResults{}
account.Mappings = Mapping{}
account.AddMapping("foo4",
WeightedMapping{Subject: "to1" }, // no weight means 100
WeightedMapping{Subject: "to1"}, // no weight means 100
WeightedMapping{Subject: "to2", Weight: 1})
account.Validate(vr)
if !vr.IsBlocking(false) {
Expand Down

0 comments on commit ff814ca

Please sign in to comment.