Skip to content

Commit

Permalink
[cmd/mdatagen]: Add feature gates support to metadata-schema.yaml
Browse files Browse the repository at this point in the history
  • Loading branch information
narcis96 committed Oct 16, 2024
1 parent a7d019f commit 7514949
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 0 deletions.
34 changes: 34 additions & 0 deletions cmd/mdatagen/internal/loader.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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
}
17 changes: 17 additions & 0 deletions cmd/mdatagen/metadata-schema.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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: <string|int|double|bool>
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:
<feature_gate.name>:
#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:

0 comments on commit 7514949

Please sign in to comment.