Skip to content
New issue

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

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

Already on GitHub? # to your account

feat: adds very basic feature flag capabilities #1058

Open
wants to merge 3 commits into
base: uds-tofu
Choose a base branch
from

Conversation

catsby
Copy link
Collaborator

@catsby catsby commented Jan 16, 2025

Description

Adds very basic --feature=<thing> feature flag support. NOTE: when integrating this I found the --feature flag support is at odds with the DisableFlagParsing.

Note: this PR is opened against the embed-tofu-binary branch.

Calling plan without feature tofu enabled:

$ uds plan

The 'plan' command is not enabled. Use the '--feature=tofu' flag or set the FEATURE_FLAG environment variable.

With feature tofu enabled:

$ FEATURE_FLAG=tofu uds plan
// OpenTofu plan stuff

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Other (security config, docs update, etc)

Checklist before merging

@catsby catsby requested a review from YrrepNoj January 16, 2025 22:53
@catsby catsby requested a review from a team as a code owner January 16, 2025 22:53
Base automatically changed from embed-tofu-binary to uds-tofu January 21, 2025 15:30
Copy link
Member

@YrrepNoj YrrepNoj left a comment

Choose a reason for hiding this comment

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

Only thing left is handling the flag parsing

src/cmd/vendored.go Outdated Show resolved Hide resolved
if !featureflags.IsEnabled("tofu") {
fmt.Println("The 'plan' command is not enabled. Use the '--feature=tofu' flag or set the FEATURE_FLAG environment variable.")
return nil
}
return useEmbeddedTofu()
},
DisableFlagParsing: true,
Copy link
Member

Choose a reason for hiding this comment

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

As you pointed out last week, flagParsing is currently disabled and will need to be handled in some way.

Context: I originally disabled flagParsing so that we can pass all the tofu flags directly as args. If flagParsing is not disabled we will have to manually capture all the flags the user is trying to provide to tofu and forward them along.

YrrepNoj and others added 2 commits January 21, 2025 10:34
chore: touch the src/cmd/bin/tofu file so it exists for tests, schema, and doc validation

chore: small hack to appease the linter for embeded files

chore: remove unnecessary todo comment

initial spike of feature flags

Signed-off-by: catsby <clint@defenseunicorns.com>

fix license

Signed-off-by: catsby <clint@defenseunicorns.com>

add feature flag gate to apply/plan stubs

Signed-off-by: catsby <clint@defenseunicorns.com>
Signed-off-by: catsby <clint@defenseunicorns.com>
Signed-off-by: catsby <clint@defenseunicorns.com>
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants