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

Add feature flag support #544

Merged
merged 4 commits into from
Jan 13, 2023
Merged

Add feature flag support #544

merged 4 commits into from
Jan 13, 2023

Conversation

noelbundick-msft
Copy link
Contributor

Description

What this PR does / why we need it:

Per the 2022-01-10 community call, we're moving forward with enabling Plugins as OCI Artifacts, and we want to place it behind a feature flag so that users can choose whether or not to enable the use of dynamic plugins

This PR adds support for basic feature flags based on env vars, which can be used to roll out new/optional/experimental features.

The general idea is:

  • Flags are registered in pkg/ratify/featureflag/featureflag.go
  • At startup, Ratify will enable/disable flags based on the corresponding environment variables
  • In code, we can use code like the following to toggle features
if featureflag.DynamicPlugins.Enabled {
  // do something interesting
}
  • This is also exposed to Helm, ex:
# current default: no flag env vars are emitted
$ helm template charts/ratify/ | grep RATIFY_DYNAMIC -C 2

# enable a feature flag. A new env var is added in the Ratify deployment YAML
$ helm template --set featureFlags.RATIFY_DYNAMIC_PLUGINS=true charts/ratify/ | grep RATIFY_DYNAMIC -C 2
                fieldRef:
                  fieldPath: metadata.namespace
            - name: RATIFY_DYNAMIC_PLUGINS
              value: "1"
          resources:

# disable a feature flag (ex: if a flag is enabled by default, but we want to turn it off)
helm template --set featureFlags.RATIFY_DYNAMIC_PLUGINS=false charts/ratify/ | grep RATIFY_DYNAMIC -C 2
                fieldRef:
                  fieldPath: metadata.namespace
            - name: RATIFY_DYNAMIC_PLUGINS
              value: "0"
          resources:

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Please also list any relevant details for your test configuration

  • Adds unit tests
  • Manually verified (per above) that the Helm chart works by default and with explicit values

Checklist:

  • Does the affected code have corresponding tests?
  • Are the changes documented, not just with inline documentation, but also with conceptual documentation such as an overview of a new feature, or task-based documentation like a tutorial? Consider if this change should be announced on your project blog.
  • Does this introduce breaking changes that would require an announcement or bumping the major version?
  • Do all new files have appropriate license header?

Copy link
Collaborator

@susanshi susanshi left a comment

Choose a reason for hiding this comment

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

thanks for setting this up. LGTM.

@akashsinghal akashsinghal merged commit 23fb675 into ratify-project:main Jan 13, 2023
@noelbundick-msft noelbundick-msft deleted the featureflags branch January 13, 2023 17:01
bspaans pushed a commit to bspaans/ratify that referenced this pull request Oct 17, 2023
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.

3 participants