Conversation
joshdover
left a comment
There was a problem hiding this comment.
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.
Co-authored-by: Josh Dover <1813008+joshdover@users.noreply.github.com>
|
I added a warning. It should appear in the console similarly to this: |
| // 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"` |
There was a problem hiding this comment.
Should we check somewhere that we only use beta or ga here? Or even only beta?
There was a problem hiding this comment.
I added a condition to check for "beta" and "ga" and report an error whenever there is a different level used.
| 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)) |
There was a problem hiding this comment.
Nit. Use a switch for valid values to simplify conditions?
| 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")) | |
| } |
This PR defines
release: betaflag 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.