redis: add attach command - #5120
Open
tripledoublev wants to merge 2 commits into
Open
Conversation
AttachDatabase (setting REDIS_URL as an app secret from a Redis add-on's public URL) previously existed only as an internal function, called by fly launch's Go code. There was no CLI subcommand, so external tooling that shells out to the flyctl binary (rather than linking against it) had no way to invoke this after `flyctl redis create` -- unlike Postgres, which already has `flyctl pg attach` for the same purpose. Add `flyctl redis attach <name> --app <app>`. Refactor AttachDatabase into a thin wrapper so the same logic works from either of flyctl's two generated GraphQL types that carry an add-on's name/public URL. Reject an empty public URL instead of silently setting REDIS_URL="", since a freshly created add-on may still be provisioning.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
AttachDatabase(setsREDIS_URLas an app secret from a Redis add-on's public URL) previously existed only as an internal Go function, called byfly launch's Go code. There was no CLI subcommand, so external tooling that shells out to the flyctl binary rather than linking against it had no way to invoke this afterflyctl redis create— unlike Postgres, which already hasflyctl pg attachfor the same purpose.Adds
flyctl redis attach <name> --app <app>.Details
AttachDatabaseinto a thin wrapper around a shared helper, so the same logic works from either of flyctl's two generated GraphQL types that carry an add-on's name/public URL (the existingfly launchcaller uses one, the new command'sGetAddOnlookup uses the other). The existing caller's behavior is unchanged.REDIS_URL="", since a freshly created add-on may still be provisioning when attach runs immediately after create.Verification
Independently reviewed by two separate models. First pass caught two real issues (a stray lock file leaking from an unguarded test config path, and the missing empty-URL guard above) — both fixed. Second pass re-verified from scratch post-fix, including confirming re-running attach doesn't risk clobbering a customer's
REDIS_URLon ordinary redeploys (deploy-only flows skip extension provisioning).go build/vet/test -raceandgolangci-lint(pinned to CI's v2.11.3) all pass clean.