feat: removed hard-coded configuration parameters in preparation for automated client deployment - #65
feat: removed hard-coded configuration parameters in preparation for automated client deployment#65bakirFS wants to merge 10 commits into
Conversation
238d4f1 to
6f71b54
Compare
| # Manifest variables: substituted into manifest.yml by the Forge CLI from | ||
| # the shell at deploy time. Only override the SaaS defaults when provided. | ||
| - name: Set manifest variables | ||
| run: | | ||
| if [ -n "${{ vars.FORGE_APP_ID }}" ]; then | ||
| echo "FORGE_APP_ID=${{ vars.FORGE_APP_ID }}" >> "$GITHUB_ENV" | ||
| fi | ||
| if [ -n "${{ vars.FLAGSMITH_BACKEND_HOST }}" ]; then | ||
| echo "FLAGSMITH_BACKEND_HOST=${{ vars.FLAGSMITH_BACKEND_HOST }}" >> "$GITHUB_ENV" | ||
| fi | ||
| # Runtime variables: stored by Forge and read via process.env in functions. | ||
| # Set them when provided; otherwise unset any stale value so the code falls | ||
| # back to SaaS defaults. Unsetting is idempotent (|| true tolerates absence). | ||
| - name: Set runtime variables | ||
| run: | | ||
| if [ -n "${{ vars.FLAGSMITH_API_V1 }}" ]; then | ||
| forge variables set FLAGSMITH_API_V1 "${{ vars.FLAGSMITH_API_V1 }}" --environment ${{ inputs.environment }} | ||
| else | ||
| forge variables unset FLAGSMITH_API_V1 --environment ${{ inputs.environment }} || true | ||
| fi | ||
| if [ -n "${{ vars.FLAGSMITH_APP }}" ]; then | ||
| forge variables set FLAGSMITH_APP "${{ vars.FLAGSMITH_APP }}" --environment ${{ inputs.environment }} | ||
| else | ||
| forge variables unset FLAGSMITH_APP --environment ${{ inputs.environment }} || true | ||
| fi |
There was a problem hiding this comment.
Now, I do understand why we have this logic to verify if the values exists, but thinking about it logically this YAML file is only used by us for deploying to our SaaS environments, and these variables are all visible in the Github interface (since they're vars and not secrets) so I would suggest that this workflow shouldn't care about whether they exist or not.
| # Manifest variables: substituted into manifest.yml by the Forge CLI from | |
| # the shell at deploy time. Only override the SaaS defaults when provided. | |
| - name: Set manifest variables | |
| run: | | |
| if [ -n "${{ vars.FORGE_APP_ID }}" ]; then | |
| echo "FORGE_APP_ID=${{ vars.FORGE_APP_ID }}" >> "$GITHUB_ENV" | |
| fi | |
| if [ -n "${{ vars.FLAGSMITH_BACKEND_HOST }}" ]; then | |
| echo "FLAGSMITH_BACKEND_HOST=${{ vars.FLAGSMITH_BACKEND_HOST }}" >> "$GITHUB_ENV" | |
| fi | |
| # Runtime variables: stored by Forge and read via process.env in functions. | |
| # Set them when provided; otherwise unset any stale value so the code falls | |
| # back to SaaS defaults. Unsetting is idempotent (|| true tolerates absence). | |
| - name: Set runtime variables | |
| run: | | |
| if [ -n "${{ vars.FLAGSMITH_API_V1 }}" ]; then | |
| forge variables set FLAGSMITH_API_V1 "${{ vars.FLAGSMITH_API_V1 }}" --environment ${{ inputs.environment }} | |
| else | |
| forge variables unset FLAGSMITH_API_V1 --environment ${{ inputs.environment }} || true | |
| fi | |
| if [ -n "${{ vars.FLAGSMITH_APP }}" ]; then | |
| forge variables set FLAGSMITH_APP "${{ vars.FLAGSMITH_APP }}" --environment ${{ inputs.environment }} | |
| else | |
| forge variables unset FLAGSMITH_APP --environment ${{ inputs.environment }} || true | |
| fi | |
| # Manifest variables: substituted into manifest.yml by the Forge CLI from | |
| # the shell at deploy time. | |
| - name: Set manifest variables | |
| run: | | |
| echo "FORGE_APP_ID=${{ vars.FORGE_APP_ID }}" >> "$GITHUB_ENV" | |
| echo "FLAGSMITH_BACKEND_HOST=${{ vars.FLAGSMITH_BACKEND_HOST }}" >> "$GITHUB_ENV" | |
| # Runtime variables: stored by Forge and read via process.env in functions. | |
| run: | | |
| forge variables set FLAGSMITH_API_V1 "${{ vars.FLAGSMITH_API_V1 }}" --environment ${{ inputs.environment }} | |
| forge variables set FLAGSMITH_APP "${{ vars.FLAGSMITH_APP }}" --environment ${{ inputs.environment }} |
There was a problem hiding this comment.
Not sure I understood you, did you mean I should remove the if statement since the values will always be set?
There was a problem hiding this comment.
Confirmed in Slack - yes, that's what I mean.
| if (config === undefined) { | ||
| return <Spinner label="Loading feature flag state" />; | ||
| } |
There was a problem hiding this comment.
I'm not sure why config would ever be undefined? And if it were, why that would be temporary (and hence warrant a spinner)?
| import { customInvoke } from "./invoke"; | ||
| export { Config } from "../backend/config"; | ||
|
|
||
| /** Read frontend-visible configuration from the backend resolver */ |
There was a problem hiding this comment.
Reading across the frontend / backend separations feels a bit odd here - is there a way around this?
Prevents the encryption prompt from failing the deploy in CI's non-TTY environment. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Contributes to #59
Created this PR to remove hard-coded variables from code which caused us to have bespoke deployments for each customer using private cloud.
I left old hard-coded values as defaults, so if you want to override them you need to provide values in github variables.
Those are: FLAGSMITH_BACKEND_HOST, FORGE_APP_ID, FLAGSMITH_APP and FLAGSMITH_API_V1.
Changes have been tested by providing invalid manifest variables (FLAGSMITH_BACKEND_HOST) which made the deployment fail and by providing invalid runtime variables (FLAGSMITH_API_V1) which deployed the app but not communicate with the API.