Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[cmd/mdatagen]: Add feature gates support to metadata-schema.yaml #11466

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

narcis96
Copy link
Contributor

@narcis96 narcis96 commented Oct 16, 2024

Description:
Added feature-gates section to metadata-schema.yaml together with id, description, stage and other required. This information can then be used for code generation, documentation generation and by other consumers of the metadata.yaml file

Link to tracking Issue: #9860

@narcis96 narcis96 requested a review from a team as a code owner October 16, 2024 10:44
@narcis96 narcis96 requested a review from mx-psi October 16, 2024 10:44
Copy link
Member

@mx-psi mx-psi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Left some comments

cmd/mdatagen/internal/loader.go Outdated Show resolved Hide resolved
cmd/mdatagen/internal/loader.go Show resolved Hide resolved
cmd/mdatagen/internal/loader.go Outdated Show resolved Hide resolved
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are missing the code generation! We need to generate something like this:

var myFeatureGate = featuregate.GlobalRegistry().MustRegister(
"namespaced.uniqueIdentifier",
featuregate.Stable,
featuregate.WithRegisterFromVersion("v0.65.0")
featuregate.WithRegisterDescription("A brief description of what the gate controls"),
featuregate.WithRegisterReferenceURL("https://github.com/open-telemetry/opentelemetry-collector/issues/6167"),
featuregate.WithRegisterToVersion("v0.70.0"))

@narcis96 narcis96 force-pushed the narcis/feature_gates_in_metadata.yaml_file branch from 7514949 to 05ec7bf Compare October 17, 2024 11:38
}

func (f *featureGate) validate(parser *confmap.Conf) error {
if !parser.IsSet("id") {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should also check for stage, that is also a required field

Comment on lines +430 to +438
if !versionRegexp.MatchString(fmt.Sprintf("%v", parser.Get("from_version"))) {
err = append(err, fmt.Errorf("invalid character(s) in from_version"))
}
if !versionRegexp.MatchString(fmt.Sprintf("%v", parser.Get("to_version"))) {
err = append(err, fmt.Errorf("invalid character(s) in to_version"))
}
if !referenceURLRegexp.MatchString(fmt.Sprintf("%v", parser.Get("reference_url"))) {
err = append(err, fmt.Errorf("invalid character(s) in reference_url"))
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All of these should check first where the field is set, otherwise they are effectively required, aren't they?

For example, instead of:

if !versionRegexp.MatchString(fmt.Sprintf("%v", parser.Get("from_version"))) {
	err = append(err, fmt.Errorf("invalid character(s) in from_version"))
}

we should do something similar to this

if parser.IsSet("from_version") && !versionRegexp.MatchString(fmt.Sprintf("%v", parser.Get("from_version"))) {
	err = append(err, fmt.Errorf("invalid character(s) in from_version"))
}

Copy link

codecov bot commented Oct 17, 2024

Codecov Report

Attention: Patch coverage is 0% with 23 lines in your changes missing coverage. Please review.

Project coverage is 92.03%. Comparing base (a7d019f) to head (05ec7bf).
Report is 11 commits behind head on main.

Files with missing lines Patch % Lines
cmd/mdatagen/internal/loader.go 0.00% 23 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #11466      +/-   ##
==========================================
- Coverage   92.15%   92.03%   -0.12%     
==========================================
  Files         432      433       +1     
  Lines       20253    20412     +159     
==========================================
+ Hits        18664    18787     +123     
- Misses       1228     1261      +33     
- Partials      361      364       +3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants