Skip to content

Define beta features in spec#341

Merged
mtojek merged 9 commits intoelastic:mainfrom
mtojek:feature-beta-spec
May 24, 2022
Merged

Define beta features in spec#341
mtojek merged 9 commits intoelastic:mainfrom
mtojek:feature-beta-spec

Conversation

@mtojek
Copy link
Copy Markdown
Contributor

@mtojek mtojek commented May 23, 2022

This PR defines release: beta flag for folder specs. Requested by @joshdover in comment.

Related: #328

It might be hard to test it without providing a fake spec, so I'd rather test it against #328.

@mtojek mtojek self-assigned this May 23, 2022
@mtojek mtojek requested a review from joshdover May 23, 2022 11:45
@mtojek mtojek marked this pull request as ready for review May 23, 2022 11:45
@mtojek mtojek requested a review from a team as a code owner May 23, 2022 11:45
@elasticmachine
Copy link
Copy Markdown

elasticmachine commented May 23, 2022

💚 Build Succeeded

the below badges are clickable and redirect to their specific view in the CI or DOCS
Pipeline View Test View Changes Artifacts preview preview

Expand to view the summary

Build stats

  • Start Time: 2022-05-24T12:40:05.135+0000

  • Duration: 2 min 21 sec

🤖 GitHub comments

To re-run your PR in the CI, just comment with:

  • /test : Re-trigger the build.

joshdover
joshdover previously approved these changes May 23, 2022
Copy link
Copy Markdown
Contributor

@joshdover joshdover left a comment

Choose a reason for hiding this comment

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

LGTM, thanks for adding this. It would be nice if we could emit warnings when beta features are used in non-GA packages too so that developers aren't surprised right when they're hoping to make a package GA. Let's consider that nice-to-have though unless it's easy to implement now.

Comment thread code/go/internal/validator/folder_spec.go Outdated
Co-authored-by: Josh Dover <1813008+joshdover@users.noreply.github.com>
@mtojek
Copy link
Copy Markdown
Contributor Author

mtojek commented May 23, 2022

I added a warning. It should appear in the console similarly to this:

2022/05/23 14:20:16 Warning: package with non-stable semantic version and active beta features (enabled in [../../../../test/packages/missing_required_fields/_dev]) can't be released as stable version.

joshdover
joshdover previously approved these changes May 23, 2022
jsoriano
jsoriano previously approved these changes May 23, 2022
Comment thread code/go/internal/validator/folder_spec.go Outdated
// Release type of the spec: beta, ga.
// Packages using beta features won't be able to go GA.
// Default release: ga
Release string `yaml:"release"`
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Should we check somewhere that we only use beta or ga here? Or even only beta?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I added a condition to check for "beta" and "ga" and report an error whenever there is a different level used.

jsoriano
jsoriano previously approved these changes May 24, 2022
Comment on lines +90 to +95
if s.Release != "" && s.Release != "beta" {
errs = append(errs, errors.Errorf("unsupport release level, supported values: beta, ga"))
} else if s.Release == "beta" && pkg.Version.Prerelease() == "" {
errs = append(errs, errors.Errorf("spec for [%s] defines beta features which can't be enabled for packages with a stable semantic version", pkg.Path(path)))
} else if s.Release == "beta" && pkg.Version.Prerelease() != "" {
log.Printf("Warning: package with non-stable semantic version and active beta features (enabled in [%s]) can't be released as stable version.q", pkg.Path(path))
Copy link
Copy Markdown
Member

@jsoriano jsoriano May 24, 2022

Choose a reason for hiding this comment

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

Nit. Use a switch for valid values to simplify conditions?

Suggested change
if s.Release != "" && s.Release != "beta" {
errs = append(errs, errors.Errorf("unsupport release level, supported values: beta, ga"))
} else if s.Release == "beta" && pkg.Version.Prerelease() == "" {
errs = append(errs, errors.Errorf("spec for [%s] defines beta features which can't be enabled for packages with a stable semantic version", pkg.Path(path)))
} else if s.Release == "beta" && pkg.Version.Prerelease() != "" {
log.Printf("Warning: package with non-stable semantic version and active beta features (enabled in [%s]) can't be released as stable version.q", pkg.Path(path))
switch s.Release {
case "", "ga":
case "beta":
if pkg.Version.Prerelease() == "" {
errs = append(errs, errors.Errorf("spec for [%s] defines beta features which can't be enabled for packages with a stable semantic version", pkg.Path(path)))
} else {
log.Printf("Warning: package with non-stable semantic version and active beta features (enabled in [%s]) can't be released as stable version.q", pkg.Path(path))
}
default:
errs = append(errs, errors.Errorf("unsupport release level, supported values: beta, ga"))
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed

@mtojek mtojek merged commit dd3f26e into elastic:main May 24, 2022
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.

4 participants