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: Update user info every 24h and adds command with feature flag #193

Merged
merged 6 commits into from
Sep 29, 2021

Conversation

raulb
Copy link
Member

@raulb raulb commented Sep 27, 2021

Description of change

This pull-request adds the ability to create a CLI command that depends on a Meroxa User Feature Flag. These are returned by the API endpoint /v1/users/me and when that API endpoint is used in meroxa whoami we also make sure we update this information.

To make sure user information is not stale, we'll start fetching this information every 24hours since last time was updated.

To demo the usage of feature flags, this pull-request also adds the environment command which could aliased as env or environment.

Fixes https://github.com/meroxa/product/issues/113

Depends on https://github.com/meroxa/meroxa-go/pull/53.

Type of change

  • New feature
  • Bug fix
  • Refactor
  • Documentation

How was this tested?

  • Unit Tests
  • Tested in staging

Demo

Before this pull-request

  • We didn't check for feature flags.

After this pull-request

Without feature flag enabled

$ meroxa env
Error: feature flag "environments" required. reach out to [email protected] for more information

With feature flag enabled

$ meroxa env
Welcome to a new world

@raulb raulb changed the title Rb/feature flags feat: Update user info every 24h and adds command with feature flag Sep 27, 2021
@raulb raulb force-pushed the rb/feature-flags branch 2 times, most recently from 7a09af8 to 11c48d0 Compare September 27, 2021 13:23
@raulb raulb requested a review from lovromazgon September 27, 2021 13:32
@raulb raulb marked this pull request as ready for review September 27, 2021 13:32
@raulb raulb self-assigned this Sep 27, 2021
@raulb raulb requested a review from dianadoherty September 28, 2021 10:01
Comment on lines 629 to 635
flagRequired := v.FeatureFlag()
userFeatureFlags := global.Config.GetStringSlice(global.UserFeatureFlagsEnv)

if !hasFeatureFlag(userFeatureFlags, flagRequired) {
return fmt.Errorf("your account does not have access to the %q feature. Reach out to [email protected] for more information", flagRequired)
}
Copy link
Member

Choose a reason for hiding this comment

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

Can this be moved outside of the PreRunE function? I think we already have all the info at that point, don't we? If we do, then we could already detect if the feature flag is enabled and un-hide the command (cmd.Hidden = false).

Copy link
Member

Choose a reason for hiding this comment

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

Oh no, I see we read the config only after all commands are built (here). We could consider reading the config before even building the commands (here).

Copy link
Member Author

Choose a reason for hiding this comment

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

For context, @lovromazgon and I paired today to explore this option and we both agreed that the effort to make it work is currently not worth it. Maybe in a future iteration we'll revisit this.

Co-authored-by: Diana Doherty <[email protected]>
@raulb raulb merged commit d37a7db into master Sep 29, 2021
@raulb raulb deleted the rb/feature-flags branch September 29, 2021 16:07
@terrancej terrancej added the cli label Oct 7, 2021
@terrancej terrancej added this to the Stage 1 milestone Oct 7, 2021
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