behaviors: enforce behavior id must have suite id as prefix

This commit is contained in:
Aaron Crickenberger 2020-06-03 11:03:52 -07:00
parent 85724cf2c3
commit d960bf1903
2 changed files with 11 additions and 7 deletions

View File

@ -23,6 +23,7 @@ import (
"os"
"path/filepath"
"regexp"
"strings"
"gopkg.in/yaml.v2"
)
@ -68,6 +69,9 @@ func ValidateSuite(suite *Suite) error {
if _, ok := behaviorsByID[b.ID]; ok {
errs = append(errs, fmt.Errorf("Duplicate behavior ID: %s", b.ID))
}
if !strings.HasPrefix(b.ID, suite.Suite) {
errs = append(errs, fmt.Errorf("Invalid behavior ID: %s, must have suite name as prefix: %s", b.ID, suite.Suite))
}
behaviorsByID[b.ID] = true
}
return utilerrors.NewAggregate(errs)

View File

@ -1,30 +1,30 @@
suite: service/spec
description: Base suite for services
behaviors:
- id: service/basic-create/selector
- id: service/spec/selector/present-during-create
description: When a Service resource is created with type "ClusterIP", "NodePort", or "LoadBalancer",
and a selector is specified, an Endpoints object is generated based with the IPs of pods with
label keys and values matching the selector.
- id: service/basic-create/no-selector
- id: service/spec/selector/absent-during-create
description: When a Service resource is created and a no selector is specified, no changes are made
to any corresponding Endpoints object.
- id: service/type/ClusterIP/empty
- id: service/spec/type/ClusterIP/empty
description: When the Service type is specified as "ClusterIP" and the clusterIP
field is empty, a cluster-internal IP address for load-balancing to endpoints is
allocated.
- id: service/type/ClusterIP/static
- id: service/spec/type/ClusterIP/static
description: When the Service type is specified as "ClusterIP" and the clusterIP
field is specified as an IP address in the cluster service range, and that IP is
not already assigned to another service, that IP is be allocated as a cluster-internal
IP address for load-balancing to endpoints.
- id: service/type/ClusterIP/None
- id: service/spec/type/ClusterIP/None
description: When the Service type is specified as "ClusterIP" and the clusterIP
field is "None", no virtual IP is allocated and the endpoints are published as a
set of endpoints rather than a stable IP.
- id: service/type/NodePort
- id: service/spec/type/NodePort
description: When the Service type is specified as "NodePort" , a cluster-internal
IP address for load-balancing to endpoints is allocated as for type "ClusterIP".
Additionally, a cluster-wide port is allocated on every node, routing to the clusterIP.
- id: service/type/ExternalName
- id: service/spec/type/ExternalName
description: When the Service type is specified as "ExternalName", the cluster DNS provider
publishes a CNAME pointing from the service to the specified external name.