From 7514949f332d5b396f5ff967959e638753313547 Mon Sep 17 00:00:00 2001 From: Gemene Narcis Date: Wed, 16 Oct 2024 13:42:20 +0300 Subject: [PATCH] [cmd/mdatagen]: Add feature gates support to metadata-schema.yaml --- cmd/mdatagen/internal/loader.go | 34 +++++++++++++++++++++++++++++++ cmd/mdatagen/metadata-schema.yaml | 17 ++++++++++++++++ 2 files changed, 51 insertions(+) diff --git a/cmd/mdatagen/internal/loader.go b/cmd/mdatagen/internal/loader.go index b51fc86f141..3fe502b3d1f 100644 --- a/cmd/mdatagen/internal/loader.go +++ b/cmd/mdatagen/internal/loader.go @@ -40,6 +40,16 @@ func (mn AttributeName) RenderUnexported() (string, error) { return FormatIdentifier(string(mn), false) } +type featureGateName string + +func (mn featureGateName) Render() (string, error) { + return formatIdentifier(string(mn), true) +} + +func (mn featureGateName) RenderUnexported() (string, error) { + return formatIdentifier(string(mn), false) +} + // ValueType defines an attribute value type. type ValueType struct { // ValueType is type of the attribute value. @@ -296,6 +306,8 @@ type Metadata struct { ShortFolderName string `mapstructure:"-"` // Tests is the set of tests generated with the component Tests tests `mapstructure:"tests"` + // FeatureGates that can be used for the component. + FeatureGates map[featureGateName]featureGate `mapstructure:"feature_gates"` } func setAttributesFullName(attrs map[AttributeName]Attribute) { @@ -373,3 +385,25 @@ func packageName() (string, error) { } return strings.TrimSpace(string(output)), nil } + +type featureGate struct { + // Optional. + Id string `mapstructure:"id"` + // Description describes the purpose of the attribute. + Description string `mapstructure:"description"` + // Stage current stage at which the feature gate is in the development lifecyle + Stage string `mapstructure:"stage"` + // ReferenceURL can optionally give the url of the feature_gate + ReferenceURL string `mapstructure:"referenceURL"` + // FromVersion optional field which gives the release version from which the gate has been given the current stage + FromVersion string `mapstructure:"fromVersion"` + // ToVersion optional field which gives the release version till which the gate the gate had the given lifecycle stage + ToVersion string `mapstructure:"toVersion"` + // FeatureGateName name of the feature gate + FeatureGateName featureGateName `mapstructure:"-"` +} + +// Name returns the name of the feature gate +func (fg featureGate) Name() featureGateName { + return fg.FeatureGateName +} \ No newline at end of file diff --git a/cmd/mdatagen/metadata-schema.yaml b/cmd/mdatagen/metadata-schema.yaml index afd1f09b62a..ba02f83dc37 100644 --- a/cmd/mdatagen/metadata-schema.yaml +++ b/cmd/mdatagen/metadata-schema.yaml @@ -175,3 +175,20 @@ telemetry: # Optional: array of attributes that were defined in the attributes section that are emitted by this metric. # Note: Only the following attribute types are supported: attributes: [string] + +#Optional: Gate is an immutable object that is owned by the Registry and represents an individual feature that +# may be enabled or disabled based on the lifecycle state of the feature and CLI flags specified by the user. +feature_gates: + : + #Optional: id of the feature gate + id: + #Required: description of the gate + description: + #Required: current stage at which the feature gate is in the development lifecyle + stage: + #Optional: link to the issue where the gate has been discussed + referenceURL: + #Optional: the release version from which the gate has been given the current stage + fromVersion: + #Optional: the release version till which the gate had the given lifecycle stage + toVersion: \ No newline at end of file