mirror of
https://github.com/k3s-io/kubernetes.git
synced 2026-07-19 07:25:19 +00:00
rename stability Level to TagStabilityLevel
This commit is contained in:
@@ -247,9 +247,9 @@ type typeNode struct {
|
||||
// hasValidations. These let us emit the iteration code for list and
|
||||
// map types, but we might not have enough information to know if we can
|
||||
// skip them at discovery time.
|
||||
typeValIterations validators.Validations // validations on each val
|
||||
typeKeyIterations validators.Validations // validations on each key
|
||||
lowestStabilityLevel validators.StabilityLevel // populated to the lowest stability level of any validation in this type
|
||||
typeValIterations validators.Validations // validations on each val
|
||||
typeKeyIterations validators.Validations // validations on each key
|
||||
lowestStabilityLevel validators.TagStabilityLevel // populated to the lowest stability level of any validation in this type
|
||||
}
|
||||
|
||||
// DiscoverType walks the given type recursively, building a type-graph in this
|
||||
@@ -306,7 +306,7 @@ func (td *typeDiscoverer) discoverType(t *types.Type, fldPath *field.Path) (*typ
|
||||
// This is the type-node being assembled in the rest of this function.
|
||||
thisNode := &typeNode{
|
||||
valueType: t,
|
||||
lowestStabilityLevel: validators.Stable,
|
||||
lowestStabilityLevel: validators.TagStabilityLevelStable,
|
||||
}
|
||||
td.typeNodes[t] = thisNode
|
||||
|
||||
@@ -595,7 +595,7 @@ func (td *typeDiscoverer) verifySupportedType(t *types.Type) error {
|
||||
// discoverStruct walks a struct type recursively.
|
||||
func (td *typeDiscoverer) discoverStruct(thisNode *typeNode, fldPath *field.Path) error {
|
||||
var fields []*childNode
|
||||
structLowestStability := validators.Stable
|
||||
structLowestStability := validators.TagStabilityLevelStable
|
||||
|
||||
klog.V(5).InfoS("discoverStruct", "type", thisNode.valueType)
|
||||
|
||||
@@ -813,8 +813,8 @@ func (td *typeDiscoverer) discoverStruct(thisNode *typeNode, fldPath *field.Path
|
||||
// analyzeFieldTags processes the tags for a field, checking for declarative native
|
||||
// validation and stability levels.
|
||||
// This returns lowest stability level of tags for the field.
|
||||
func (td *typeDiscoverer) analyzeFieldTags(tags []codetags.Tag, node *childNode, fldPath *field.Path) (validators.StabilityLevel, error) {
|
||||
fieldLowestStabilityLevel := validators.Stable
|
||||
func (td *typeDiscoverer) analyzeFieldTags(tags []codetags.Tag, node *childNode, fldPath *field.Path) (validators.TagStabilityLevel, error) {
|
||||
fieldLowestStabilityLevel := validators.TagStabilityLevelStable
|
||||
var isDeclarativeNative bool
|
||||
for _, tag := range tags {
|
||||
if tag.Name == declarativeNativeTag {
|
||||
@@ -838,13 +838,13 @@ func (td *typeDiscoverer) analyzeFieldTags(tags []codetags.Tag, node *childNode,
|
||||
if stability, err := td.validator.Stability(tag.Name); err != nil {
|
||||
// This case should ideally not be hit if our tag registry is complete.
|
||||
return fieldLowestStabilityLevel, fmt.Errorf("field %s: error occurred while finding stability level for %s tag: %w", fldPath.String(), tag.Name, err)
|
||||
} else if stability != validators.Stable {
|
||||
} else if stability != validators.TagStabilityLevelStable {
|
||||
return fieldLowestStabilityLevel, fmt.Errorf("field %s: +k8s:declarativeValidationNative can only be used with stable validation tags, but found %q which is %s", fldPath.String(), tag.Name, stability)
|
||||
}
|
||||
}
|
||||
|
||||
// If the type has non stable validations.
|
||||
if node.node != nil && node.node.lowestStabilityLevel != validators.Stable {
|
||||
if node.node != nil && node.node.lowestStabilityLevel != validators.TagStabilityLevelStable {
|
||||
return fieldLowestStabilityLevel, fmt.Errorf("field %s: is marked with +k8s:declarativeValidationNative but its type %q contains non-stable validation tags", fldPath.String(), node.node.valueType.Name)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -492,7 +492,7 @@ func TestDiscoverStruct(t *testing.T) {
|
||||
name string
|
||||
typeToTest *types.Type
|
||||
expectErr error
|
||||
expectedStabilityLevel validators.StabilityLevel
|
||||
expectedStabilityLevel validators.TagStabilityLevel
|
||||
}{
|
||||
{
|
||||
name: "simple struct with stable validations",
|
||||
@@ -524,7 +524,7 @@ func TestDiscoverStruct(t *testing.T) {
|
||||
},
|
||||
},
|
||||
expectErr: nil,
|
||||
expectedStabilityLevel: validators.Stable,
|
||||
expectedStabilityLevel: validators.TagStabilityLevelStable,
|
||||
},
|
||||
{
|
||||
name: "struct with non-stable validation on a field",
|
||||
@@ -541,7 +541,7 @@ func TestDiscoverStruct(t *testing.T) {
|
||||
},
|
||||
},
|
||||
expectErr: nil,
|
||||
expectedStabilityLevel: validators.Alpha,
|
||||
expectedStabilityLevel: validators.TagStabilityLevelAlpha,
|
||||
},
|
||||
{
|
||||
name: "struct with declarative native fields with stable validations",
|
||||
@@ -571,7 +571,7 @@ func TestDiscoverStruct(t *testing.T) {
|
||||
},
|
||||
},
|
||||
expectErr: nil,
|
||||
expectedStabilityLevel: validators.Stable,
|
||||
expectedStabilityLevel: validators.TagStabilityLevelStable,
|
||||
},
|
||||
{
|
||||
name: "struct with declarative native field string with non-stable validations",
|
||||
@@ -629,7 +629,7 @@ func TestDiscoverStruct(t *testing.T) {
|
||||
},
|
||||
},
|
||||
expectErr: nil,
|
||||
expectedStabilityLevel: validators.Stable,
|
||||
expectedStabilityLevel: validators.TagStabilityLevelStable,
|
||||
},
|
||||
{
|
||||
name: "struct with a field whose type has non-stable validations",
|
||||
@@ -656,7 +656,7 @@ func TestDiscoverStruct(t *testing.T) {
|
||||
},
|
||||
},
|
||||
expectErr: nil,
|
||||
expectedStabilityLevel: validators.Alpha,
|
||||
expectedStabilityLevel: validators.TagStabilityLevelAlpha,
|
||||
},
|
||||
}
|
||||
for _, tc := range testCases {
|
||||
|
||||
@@ -226,7 +226,7 @@ func (evtv eachValTagValidator) getMapValidations(t *types.Type, validations Val
|
||||
func (evtv eachValTagValidator) Docs() TagDoc {
|
||||
doc := TagDoc{
|
||||
Tag: evtv.TagName(),
|
||||
StabilityLevel: Alpha,
|
||||
StabilityLevel: TagStabilityLevelAlpha,
|
||||
Scopes: evtv.ValidScopes().UnsortedList(),
|
||||
Description: "Declares a validation for each value in a map or list.",
|
||||
Payloads: []TagPayloadDoc{{
|
||||
@@ -309,7 +309,7 @@ func (ektv eachKeyTagValidator) Docs() TagDoc {
|
||||
doc := TagDoc{
|
||||
Tag: ektv.TagName(),
|
||||
Scopes: ektv.ValidScopes().UnsortedList(),
|
||||
StabilityLevel: Alpha,
|
||||
StabilityLevel: TagStabilityLevelAlpha,
|
||||
Description: "Declares a validation for each value in a map or list.",
|
||||
Payloads: []TagPayloadDoc{{
|
||||
Description: "<validation-tag>",
|
||||
|
||||
@@ -62,7 +62,7 @@ func (*enumExcludeTagValidator) GetValidations(_ Context, _ codetags.Tag) (Valid
|
||||
func (eetv *enumExcludeTagValidator) Docs() TagDoc {
|
||||
return TagDoc{
|
||||
Tag: eetv.TagName(),
|
||||
StabilityLevel: Alpha,
|
||||
StabilityLevel: TagStabilityLevelAlpha,
|
||||
Scopes: eetv.ValidScopes().UnsortedList(),
|
||||
Description: `Indicates that an constant value is not part of an enum, even if the constant's type is tagged with k8s:enum.
|
||||
May be conditionally excluded via +k8s:ifEnabled(Option)=+k8s:enumExclude or +k8s:ifDisabled(Option)=+k8s:enumExclude.
|
||||
@@ -194,7 +194,7 @@ func (etv *enumTagValidator) GetValidations(context Context, _ codetags.Tag) (Va
|
||||
func (etv *enumTagValidator) Docs() TagDoc {
|
||||
return TagDoc{
|
||||
Tag: etv.TagName(),
|
||||
StabilityLevel: Stable,
|
||||
StabilityLevel: TagStabilityLevelStable,
|
||||
Scopes: etv.ValidScopes().UnsortedList(),
|
||||
Description: "Indicates that a string type is an enum. All constant values of this type are considered values in the enum unless excluded using +k8s:enumExclude.",
|
||||
}
|
||||
|
||||
@@ -98,7 +98,7 @@ func (v neqTagValidator) GetValidations(context Context, tag codetags.Tag) (Vali
|
||||
func (v neqTagValidator) Docs() TagDoc {
|
||||
return TagDoc{
|
||||
Tag: v.TagName(),
|
||||
StabilityLevel: Alpha,
|
||||
StabilityLevel: TagStabilityLevelAlpha,
|
||||
Scopes: v.ValidScopes().UnsortedList(),
|
||||
Description: "Verifies the field's value is not equal to a specific disallowed value. Supports string, integer, and boolean types.",
|
||||
PayloadsRequired: true,
|
||||
|
||||
@@ -123,7 +123,7 @@ func getFormatValidationFunction(format string) (FunctionGen, error) {
|
||||
func (ftv formatTagValidator) Docs() TagDoc {
|
||||
return TagDoc{
|
||||
Tag: ftv.TagName(),
|
||||
StabilityLevel: Stable,
|
||||
StabilityLevel: TagStabilityLevelStable,
|
||||
Scopes: ftv.ValidScopes().UnsortedList(),
|
||||
Description: "Indicates that a string field has a particular format.",
|
||||
Payloads: []TagPayloadDoc{{ // Keep this list alphabetized.
|
||||
|
||||
@@ -59,7 +59,7 @@ func (immutableTagValidator) GetValidations(context Context, _ codetags.Tag) (Va
|
||||
func (itv immutableTagValidator) Docs() TagDoc {
|
||||
return TagDoc{
|
||||
Tag: itv.TagName(),
|
||||
StabilityLevel: Alpha,
|
||||
StabilityLevel: TagStabilityLevelAlpha,
|
||||
Scopes: itv.ValidScopes().UnsortedList(),
|
||||
Description: "Indicates that a field may not be updated.",
|
||||
}
|
||||
|
||||
@@ -249,7 +249,7 @@ func parseTypedValue(value string, argType codetags.ArgType) (any, codetags.Valu
|
||||
func (itv itemTagValidator) Docs() TagDoc {
|
||||
doc := TagDoc{
|
||||
Tag: itv.TagName(),
|
||||
StabilityLevel: Stable,
|
||||
StabilityLevel: TagStabilityLevelStable,
|
||||
Scopes: itv.ValidScopes().UnsortedList(),
|
||||
Description: "Declares a validation for an item of a slice declared as a +k8s:listType=map. " +
|
||||
"The item to match is declared by providing field-value pair arguments. All key fields must be specified.",
|
||||
|
||||
@@ -79,7 +79,7 @@ func (maxLengthTagValidator) GetValidations(context Context, tag codetags.Tag) (
|
||||
func (mltv maxLengthTagValidator) Docs() TagDoc {
|
||||
return TagDoc{
|
||||
Tag: mltv.TagName(),
|
||||
StabilityLevel: Stable,
|
||||
StabilityLevel: TagStabilityLevelStable,
|
||||
Scopes: mltv.ValidScopes().UnsortedList(),
|
||||
Description: "Indicates that a string field has a limit on its length.",
|
||||
Payloads: []TagPayloadDoc{{
|
||||
@@ -137,7 +137,7 @@ func (maxItemsTagValidator) GetValidations(context Context, tag codetags.Tag) (V
|
||||
func (mitv maxItemsTagValidator) Docs() TagDoc {
|
||||
return TagDoc{
|
||||
Tag: mitv.TagName(),
|
||||
StabilityLevel: Stable,
|
||||
StabilityLevel: TagStabilityLevelStable,
|
||||
Scopes: mitv.ValidScopes().UnsortedList(),
|
||||
Description: "Indicates that a list has a limit on its size.",
|
||||
Payloads: []TagPayloadDoc{{
|
||||
@@ -187,7 +187,7 @@ func (minimumTagValidator) GetValidations(context Context, tag codetags.Tag) (Va
|
||||
func (mtv minimumTagValidator) Docs() TagDoc {
|
||||
return TagDoc{
|
||||
Tag: mtv.TagName(),
|
||||
StabilityLevel: Stable,
|
||||
StabilityLevel: TagStabilityLevelStable,
|
||||
Scopes: mtv.ValidScopes().UnsortedList(),
|
||||
Description: "Indicates that a numeric field has a minimum value.",
|
||||
Payloads: []TagPayloadDoc{{
|
||||
|
||||
@@ -182,7 +182,7 @@ func (lttv listTypeTagValidator) GetValidations(context Context, tag codetags.Ta
|
||||
func (lttv listTypeTagValidator) Docs() TagDoc {
|
||||
doc := TagDoc{
|
||||
Tag: lttv.TagName(),
|
||||
StabilityLevel: Stable,
|
||||
StabilityLevel: TagStabilityLevelStable,
|
||||
Scopes: lttv.ValidScopes().UnsortedList(),
|
||||
Description: "Declares a list field's semantic type and ownership behavior. atomic: single ownership, set: shared ownership with uniqueness, map: shared ownership with key-based uniqueness.",
|
||||
Payloads: []TagPayloadDoc{{
|
||||
@@ -250,7 +250,7 @@ func (lmktv listMapKeyTagValidator) GetValidations(context Context, tag codetags
|
||||
func (lmktv listMapKeyTagValidator) Docs() TagDoc {
|
||||
doc := TagDoc{
|
||||
Tag: lmktv.TagName(),
|
||||
StabilityLevel: Stable,
|
||||
StabilityLevel: TagStabilityLevelStable,
|
||||
Scopes: lmktv.ValidScopes().UnsortedList(),
|
||||
Description: "Declares a named sub-field of a list's value-type to be part of the list-map key.",
|
||||
Payloads: []TagPayloadDoc{{
|
||||
@@ -319,7 +319,7 @@ func (utv uniqueTagValidator) GetValidations(context Context, tag codetags.Tag)
|
||||
func (utv uniqueTagValidator) Docs() TagDoc {
|
||||
doc := TagDoc{
|
||||
Tag: utv.TagName(),
|
||||
StabilityLevel: Alpha,
|
||||
StabilityLevel: TagStabilityLevelAlpha,
|
||||
Scopes: utv.ValidScopes().UnsortedList(),
|
||||
Description: "Declares that a list field's elements are unique. This tag can be used with listType=atomic to add uniqueness constraints, or independently to specify uniqueness semantics.",
|
||||
Payloads: []TagPayloadDoc{{
|
||||
@@ -369,7 +369,7 @@ func (cutv customUniqueTagValidator) GetValidations(context Context, tag codetag
|
||||
func (cutv customUniqueTagValidator) Docs() TagDoc {
|
||||
doc := TagDoc{
|
||||
Tag: cutv.TagName(),
|
||||
StabilityLevel: Alpha,
|
||||
StabilityLevel: TagStabilityLevelAlpha,
|
||||
Scopes: cutv.ValidScopes().UnsortedList(),
|
||||
Description: "Indicates that uniqueness validation for this list is implemented via custom, handwritten validation. This disables generation of uniqueness validation for this list.",
|
||||
Payloads: nil,
|
||||
|
||||
@@ -55,6 +55,6 @@ func (d *declarativeValidationNative) Docs() TagDoc {
|
||||
Tag: d.TagName(),
|
||||
Description: "Indicates that all validations for the field, including any on the field's type, are declarative and do not have a corresponding handwritten equivalent. This is only allowed for validations that are 'Stable'. When used, validation errors will be marked to show they originated from a declarative-only validation.",
|
||||
Scopes: d.ValidScopes().UnsortedList(),
|
||||
StabilityLevel: Stable,
|
||||
StabilityLevel: TagStabilityLevelStable,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@ func (opaqueTypeTagValidator) GetValidations(_ Context, _ codetags.Tag) (Validat
|
||||
func (opaqueTypeTagValidator) Docs() TagDoc {
|
||||
doc := TagDoc{
|
||||
Tag: opaqueTypeTagName,
|
||||
StabilityLevel: Alpha,
|
||||
StabilityLevel: TagStabilityLevelAlpha,
|
||||
Scopes: []Scope{ScopeField},
|
||||
Description: "Indicates that any validations declared on the referenced type will be ignored. " +
|
||||
"If a referenced type's package is not included in the generator's current " +
|
||||
|
||||
@@ -81,7 +81,7 @@ func (itv ifTagValidator) GetValidations(context Context, tag codetags.Tag) (Val
|
||||
func (itv ifTagValidator) Docs() TagDoc {
|
||||
doc := TagDoc{
|
||||
Tag: itv.TagName(),
|
||||
StabilityLevel: Alpha,
|
||||
StabilityLevel: TagStabilityLevelAlpha,
|
||||
Args: []TagArgDoc{{
|
||||
Description: "<option>",
|
||||
Type: codetags.ArgTypeString,
|
||||
|
||||
@@ -60,7 +60,7 @@ func (reg *registry) addTagValidator(tv TagValidator) {
|
||||
panic(fmt.Sprintf("tag %q was registered twice", name))
|
||||
}
|
||||
switch level := tv.Docs().StabilityLevel; level {
|
||||
case Alpha, Beta, Stable:
|
||||
case TagStabilityLevelAlpha, TagStabilityLevelBeta, TagStabilityLevelStable:
|
||||
// valid
|
||||
case "":
|
||||
panic(fmt.Sprintf("tag %q is missing stability level", name))
|
||||
@@ -289,11 +289,11 @@ type Validator interface {
|
||||
Docs() []TagDoc
|
||||
|
||||
// Stability returns the stability level for a given tag.
|
||||
Stability(tag string) (StabilityLevel, error)
|
||||
Stability(tag string) (TagStabilityLevel, error)
|
||||
}
|
||||
|
||||
// Stability returns the stability level for a given tag.
|
||||
func (reg *registry) Stability(tag string) (StabilityLevel, error) {
|
||||
func (reg *registry) Stability(tag string) (TagStabilityLevel, error) {
|
||||
tagName := strings.TrimPrefix(tag, "+")
|
||||
tv, ok := reg.tagValidators[tagName]
|
||||
if !ok {
|
||||
|
||||
@@ -309,13 +309,13 @@ func (rtv requirednessTagValidator) Docs() TagDoc {
|
||||
|
||||
switch rtv.mode {
|
||||
case requirednessRequired:
|
||||
doc.StabilityLevel = Stable
|
||||
doc.StabilityLevel = TagStabilityLevelStable
|
||||
doc.Description = "Indicates that a field must be specified by clients."
|
||||
case requirednessOptional:
|
||||
doc.StabilityLevel = Stable
|
||||
doc.StabilityLevel = TagStabilityLevelStable
|
||||
doc.Description = "Indicates that a field is optional to clients."
|
||||
case requirednessForbidden:
|
||||
doc.StabilityLevel = Alpha
|
||||
doc.StabilityLevel = TagStabilityLevelAlpha
|
||||
doc.Description = "Indicates that a field may not be specified."
|
||||
default:
|
||||
panic(fmt.Sprintf("unknown requiredness mode: %q", rtv.mode))
|
||||
|
||||
@@ -134,7 +134,7 @@ func (stv subfieldTagValidator) GetValidations(context Context, tag codetags.Tag
|
||||
func (stv subfieldTagValidator) Docs() TagDoc {
|
||||
return TagDoc{
|
||||
Tag: stv.TagName(),
|
||||
StabilityLevel: Stable,
|
||||
StabilityLevel: TagStabilityLevelStable,
|
||||
Scopes: stv.ValidScopes().UnsortedList(),
|
||||
Description: "Declares a validation for a subfield of a struct.",
|
||||
Args: []TagArgDoc{{
|
||||
|
||||
@@ -127,7 +127,7 @@ func (fixedResultTagValidator) toFixedResultArgs(in codetags.Tag) (fixedResultAr
|
||||
func (frtv fixedResultTagValidator) Docs() TagDoc {
|
||||
doc := TagDoc{
|
||||
Tag: frtv.TagName(),
|
||||
StabilityLevel: Alpha,
|
||||
StabilityLevel: TagStabilityLevelAlpha,
|
||||
Scopes: frtv.ValidScopes().UnsortedList(),
|
||||
}
|
||||
doc.PayloadsType = codetags.ValueTypeString
|
||||
|
||||
@@ -139,7 +139,7 @@ func (udtv unionDiscriminatorTagValidator) GetValidations(context Context, tag c
|
||||
func (udtv unionDiscriminatorTagValidator) Docs() TagDoc {
|
||||
return TagDoc{
|
||||
Tag: udtv.TagName(),
|
||||
StabilityLevel: Beta,
|
||||
StabilityLevel: TagStabilityLevelBeta,
|
||||
Scopes: udtv.ValidScopes().UnsortedList(),
|
||||
Description: "Indicates that this field is the discriminator for a union.",
|
||||
Args: []TagArgDoc{{
|
||||
@@ -178,7 +178,7 @@ func (umtv unionMemberTagValidator) GetValidations(context Context, tag codetags
|
||||
func (umtv unionMemberTagValidator) Docs() TagDoc {
|
||||
return TagDoc{
|
||||
Tag: umtv.TagName(),
|
||||
StabilityLevel: Stable,
|
||||
StabilityLevel: TagStabilityLevelStable,
|
||||
Scopes: umtv.ValidScopes().UnsortedList(),
|
||||
Description: "Indicates that this field is a member of a union.",
|
||||
Args: []TagArgDoc{{
|
||||
|
||||
@@ -125,7 +125,7 @@ func constraintName(c validate.UpdateConstraint) string {
|
||||
func (utc updateTagCollector) Docs() TagDoc {
|
||||
return TagDoc{
|
||||
Tag: utc.TagName(),
|
||||
StabilityLevel: Alpha,
|
||||
StabilityLevel: TagStabilityLevelAlpha,
|
||||
Scopes: utc.ValidScopes().UnsortedList(),
|
||||
PayloadsType: codetags.ValueTypeString,
|
||||
Description: "Provides constraints on the allowed update operations of a field. " +
|
||||
|
||||
@@ -247,29 +247,29 @@ type ListSelectorTerm struct {
|
||||
Value any
|
||||
}
|
||||
|
||||
// StabilityLevel indicates the stability of a validation tag.
|
||||
type StabilityLevel string
|
||||
// TagStabilityLevel indicates the stability of a validation tag.
|
||||
type TagStabilityLevel string
|
||||
|
||||
const (
|
||||
// Alpha indicates that a tag's semantics may change in the future.
|
||||
Alpha StabilityLevel = "Alpha"
|
||||
// Beta indicates that a tag's semantics will remain unchanged for the
|
||||
// TagStabilityLevelAlpha indicates that a tag's semantics may change in the future.
|
||||
TagStabilityLevelAlpha TagStabilityLevel = "Alpha"
|
||||
// TagStabilityLevelBeta indicates that a tag's semantics will remain unchanged for the
|
||||
// foreseeable future. This is used for soaking tags before qualifying to stable.
|
||||
Beta StabilityLevel = "Beta"
|
||||
// Stable indicates that a tag's semantics will remain unchanged for the
|
||||
TagStabilityLevelBeta TagStabilityLevel = "Beta"
|
||||
// TagStabilityLevelStable indicates that a tag's semantics will remain unchanged for the
|
||||
// foreseeable future.
|
||||
Stable StabilityLevel = "Stable"
|
||||
TagStabilityLevelStable TagStabilityLevel = "Stable"
|
||||
)
|
||||
|
||||
var stabilityOrder = map[StabilityLevel]int{
|
||||
Alpha: 0,
|
||||
Beta: 1,
|
||||
Stable: 2,
|
||||
var stabilityOrder = map[TagStabilityLevel]int{
|
||||
TagStabilityLevelAlpha: 0,
|
||||
TagStabilityLevelBeta: 1,
|
||||
TagStabilityLevelStable: 2,
|
||||
}
|
||||
|
||||
// Min returns the minimum of two stability levels, or an error if either
|
||||
// stability level is unknown.
|
||||
func (s StabilityLevel) Min(other StabilityLevel) (StabilityLevel, error) {
|
||||
func (s TagStabilityLevel) Min(other TagStabilityLevel) (TagStabilityLevel, error) {
|
||||
sOrder, okS := stabilityOrder[s]
|
||||
if !okS {
|
||||
return "", fmt.Errorf("unknown stability level %q", s)
|
||||
@@ -290,7 +290,7 @@ type TagDoc struct {
|
||||
// Tag is the tag name, without the leading '+'.
|
||||
Tag string
|
||||
// StabilityLevel is the stability level of the tag.
|
||||
StabilityLevel StabilityLevel
|
||||
StabilityLevel TagStabilityLevel
|
||||
// Args lists any arguments this tag might take.
|
||||
Args []TagArgDoc `json:",omitempty"`
|
||||
// Usage is how the tag is used, including arguments.
|
||||
|
||||
@@ -121,7 +121,7 @@ func (zmtv zeroOrOneOfMemberTagValidator) Docs() TagDoc {
|
||||
return TagDoc{
|
||||
Tag: zmtv.TagName(),
|
||||
Scopes: zmtv.ValidScopes().UnsortedList(),
|
||||
StabilityLevel: Stable,
|
||||
StabilityLevel: TagStabilityLevelStable,
|
||||
Description: "Indicates that this field is a member of a zero-or-one-of union.",
|
||||
Docs: "A zero-or-one-of union allows at most one member to be set. Unlike regular unions, having no members set is valid.",
|
||||
Warning: "This tag should only be used on sets of list items, and never on struct fields directly.",
|
||||
|
||||
Reference in New Issue
Block a user