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

feat: introduce experimental feature switch #613

Merged
merged 4 commits into from Apr 13, 2023

Conversation

qweeah
Copy link
Contributor

@qweeah qweeah commented Apr 4, 2023

This PR introduces an environmental variable, NOTATION_EXPERIMENTAL, as the switch for experimental features

  • If NOTATION_EXPERIMENTAL set to 1, then experimental features are enabled. All experimental features can be used with a prompt in the stderr output:
Caution: This feature is experimental and may not be fully tested or completed and may be deprecated. Report any issues to "https://github/notaryproject/notation"
  • Otherwise experimental features are disabled, using an experimental command will show
Error: "<COMMAND>" been marked as experimental and not enabled by default. To use it, please set NOTATION_EXPERIMENTAL=1 in your environment

or

Error: flags(s) --<FLAG1>,--<FLAG2> in "<COMMAND>" been marked as experimental and not enabled by default. To use it, please set NOTATION_EXPERIMENTAL=1 in your environment

Resolves #614.

@codecov-commenter
Copy link

codecov-commenter commented Apr 4, 2023

Codecov Report

Merging #613 (82e78a2) into main (0ec3b3d) will not change coverage.
The diff coverage is n/a.

📣 This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more

@@           Coverage Diff           @@
##             main     #613   +/-   ##
=======================================
  Coverage   34.43%   34.43%           
=======================================
  Files          32       32           
  Lines        1844     1844           
=======================================
  Hits          635      635           
  Misses       1188     1188           
  Partials       21       21           

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@qweeah qweeah force-pushed the experimental branch 3 times, most recently from ab76830 to a90cf97 Compare April 6, 2023 01:39
specs/notation-cli.md Outdated Show resolved Hide resolved
specs/notation-cli.md Outdated Show resolved Hide resolved
internal/experimental/experimental.go Outdated Show resolved Hide resolved
internal/experimental/experimental.go Outdated Show resolved Hide resolved
@qweeah qweeah force-pushed the experimental branch 4 times, most recently from 321757c to 1c31401 Compare April 10, 2023 06:33
Copy link
Contributor

@yizha1 yizha1 left a comment

Choose a reason for hiding this comment

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

One comment on sub-commands.

specs/notation-cli.md Outdated Show resolved Hide resolved
@qweeah qweeah force-pushed the experimental branch 3 times, most recently from 728aaf1 to 5c2738d Compare April 11, 2023 00:56
@qweeah qweeah changed the title feat!: add experimental mark for policy commands feat: introduce experimental feature switch Apr 11, 2023
@qweeah
Copy link
Contributor Author

qweeah commented Apr 11, 2023

@priteshbandi I have removed policy changes, can you help review the implementation

@yizha1 @FeynmanZhou @iamsamirzon @toddysm can you help review the user experience as well as the wording for the output in the PR description, thanks!

internal/experimental/experimental.go Outdated Show resolved Hide resolved
internal/experimental/experimental.go Outdated Show resolved Hide resolved
internal/experimental/experimental.go Outdated Show resolved Hide resolved
internal/experimental/experimental.go Outdated Show resolved Hide resolved
internal/experimental/experimental.go Outdated Show resolved Hide resolved
internal/experimental/experimental.go Outdated Show resolved Hide resolved
internal/experimental/experimental.go Outdated Show resolved Hide resolved
@qweeah qweeah force-pushed the experimental branch 2 times, most recently from 2866e1f to 5dd2527 Compare April 11, 2023 07:57
internal/experimental/experimental.go Outdated Show resolved Hide resolved
internal/experimental/experimental.go Outdated Show resolved Hide resolved
@qweeah qweeah force-pushed the experimental branch 3 times, most recently from 825c394 to e1bb96f Compare April 12, 2023 03:08
Copy link
Contributor

@patrickzheng200 patrickzheng200 left a comment

Choose a reason for hiding this comment

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

LGTM


// IsDisabled determines whether an experimental feature is disabled.
func IsDisabled() bool {
return os.Getenv(envName) != enabled
Copy link
Contributor

Choose a reason for hiding this comment

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

should we trim the white spaces here, for both key and value?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

For what purpose do we need to trim key and value?

Copy link
Contributor

Choose a reason for hiding this comment

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

In scenario where user calls following command to set env variable.
export NOTATION_EXPERIMENTAL=" 1"

Its an edge case, I am fine to ignore this.


// Error returns an error for a disabled experimental feature.
func Error(description string) error {
return fmt.Errorf("%s been marked as experimental and not enabled by default. To use it, please set %s=%s in your environment", description, envName, enabled)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
return fmt.Errorf("%s been marked as experimental and not enabled by default. To use it, please set %s=%s in your environment", description, envName, enabled)
return fmt.Errorf("%s is experimental and not enabled by default. To use, please set %s=%s environment variable", description, envName, enabled)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed accordingly. There is a case when multiple experimental flags the warning can be

flag(s) --foo,--bar,--baz in "notation test" is experimental and not enabled by default. To use, please set %s=%s environment variable

I am okay with the is here, @patrickzheng200 what do you think.

Copy link
Contributor

Choose a reason for hiding this comment

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

Changed accordingly. There is a case when multiple experimental flags the warning can be

flag(s) --foo,--bar,--baz in "notation test" is experimental and not enabled by default. To use, please set %s=%s environment variable

I am okay with the is here, @patrickzheng200 what do you think.

Yeah, we could have multiple flags marked as experimental, in this case, using is here is not very accurate.

internal/experimental/experimental.go Outdated Show resolved Hide resolved
Signed-off-by: Billy Zha <jinzha1@microsoft.com>

clean

Signed-off-by: Billy Zha <jinzha1@microsoft.com>

hide experimental

Signed-off-by: Billy Zha <jinzha1@microsoft.com>

fix e2e

Signed-off-by: Billy Zha <jinzha1@microsoft.com>

code clean

Signed-off-by: Billy Zha <jinzha1@microsoft.com>

remove policy changes

Signed-off-by: Billy Zha <jinzha1@microsoft.com>

update flag checker

Signed-off-by: Billy Zha <jinzha1@microsoft.com>

update type

Signed-off-by: Billy Zha <jinzha1@microsoft.com>

make output more readable

Signed-off-by: Billy Zha <jinzha1@microsoft.com>

resolve comments

Signed-off-by: Billy Zha <jinzha1@microsoft.com>

resolve comments

Signed-off-by: Billy Zha <jinzha1@microsoft.com>

remove unnecessary change

Signed-off-by: Billy Zha <jinzha1@microsoft.com>

resolve comments

Signed-off-by: Billy Zha <jinzha1@microsoft.com>
Signed-off-by: Billy Zha <jinzha1@microsoft.com>
Signed-off-by: Billy Zha <jinzha1@microsoft.com>
Signed-off-by: Billy Zha <jinzha1@microsoft.com>
Copy link
Contributor

@priteshbandi priteshbandi left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@shizhMSFT shizhMSFT left a comment

Choose a reason for hiding this comment

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

LGTM

@shizhMSFT shizhMSFT merged commit 24a9719 into notaryproject:main Apr 13, 2023
4 checks passed
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.

Support experimental feature
6 participants