Skip to content

redis: add attach command - #5120

Open
tripledoublev wants to merge 2 commits into
masterfrom
vincent/redis-attach-cmd
Open

redis: add attach command#5120
tripledoublev wants to merge 2 commits into
masterfrom
vincent/redis-attach-cmd

Conversation

@tripledoublev

Copy link
Copy Markdown
Contributor

Summary

AttachDatabase (sets REDIS_URL as an app secret from a Redis add-on's public URL) previously existed only as an internal Go 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.

Adds flyctl redis attach <name> --app <app>.

Details

  • Refactored AttachDatabase into 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 existing fly launch caller uses one, the new command's GetAddOn lookup uses the other). The existing caller's behavior is unchanged.
  • Added a guard: reject an empty public URL instead of silently setting 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_URL on ordinary redeploys (deploy-only flows skip extension provisioning).

go build/vet/test -race and golangci-lint (pinned to CI's v2.11.3) all pass clean.

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.
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.

1 participant