Skip to content

Add --env flag for generate --from-store - #1033

Merged
alexellis merged 1 commit into
masterfrom
generate-env-flag
Oct 6, 2026
Merged

alexellis merged 1 commit into
masterfrom
generate-env-flag

Conversation

@alexellis

Copy link
Copy Markdown
Member

Description

Adds --env / -e ENVVAR=VALUE to generate, for use with --from-store.

Users scaffolding a stack.yaml for a store function typically need to add environment variables, such as OAuth settings, before running deploy. Until now the from-store path only supported --label and --annotation, so environment variables could only be added by editing the generated file by hand.

  • One or more --env flags are accepted, parsed with the same util.ParseMap pattern used by --label/--annotation, with malformed values rejected before any store request is made
  • Values are merged over the store item's environment with the user's values taking precedence, and fprocess is folded in before the merge so it survives unless explicitly overridden
  • Applies to both outputs: the new --output stack.yaml scaffold and the Function CRD path

Note: the same change also landed on master directly (0e4bcb9) before the PR was raised; this branch carries the identical diff for review.

Motivation and Context

Completes flag parity for the --output stack.yaml scaffold, which is aimed at overriding pre-built deployments such as adding OAuth environment variables and secrets before running deploy.

How Has This Been Tested?

  • Test_runGenerate_FromStoreEnv runs runGenerate end-to-end against a test store, asserting store env override, new env keys, and fprocess retention in stack output, plus the merged env in CRD output
  • Test_runGenerate_FromStoreEnvParseError covers malformed --env values
  • Full go test ./commands/... passes; verified live against the store with faas-cli generate --from-store nodeinfo --output stack.yaml --env read_timeout=120 -e plain_text=Enabled

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I've read the contribution guidelines.
  • I've run the linters or tests to check my contribution.

Users scaffolding a stack.yaml for a store function typically need
to add environment variables, such as OAuth settings, before
running deploy. Allow one or more --env / -e ENVVAR=VALUE flags,
merged over the store item's environment with the user's values
taking precedence. Applies to both the stack.yaml and CRD outputs.

Signed-off-by: Alex Ellis (OpenFaaS Ltd) <alexellis2@gmail.com>
@reviewfn

reviewfn Bot commented Oct 6, 2026

Copy link
Copy Markdown

AI Pull Request Overview

Disclaimer: This review was generated by automated AI and may contain errors. Do not trust its outputs without human verification.

Summary

  • Adds --env / -e support to generate for store-based function generation.
  • Parses environment overrides with the existing map parser and returns a targeted error for malformed values.
  • Merges user-provided environment values over store-provided values, matching existing store deploy precedence.
  • Preserves fprocess by folding it into the environment before applying user overrides.
  • Covers both stack.yaml and Function CRD output paths in the new tests.

Approval rating (1-10)

9/10. The change is small, consistent with existing patterns, and covered across the relevant output modes.

Summary per file

Summary per file
File path Summary
commands/generate.go Adds --env/-e parsing and store environment merge for generated output.
commands/generate_test.go Adds coverage for env overrides, fprocess retention, CRD output, and parse errors.

Overall Assessment

The scoped changes are straightforward and align with the existing --label, --annotation, and store deploy environment merge behavior. I did not find a concrete correctness, compatibility, security, or regression issue in the final diff.

Detailed Review

Detailed Review

No findings.

AI agent details.

Agent processing time: 1m9.913s
Environment preparation time: 3.613s
Total time from webhook: 1m18.822s

@alexellis
alexellis merged commit 0e4bcb9 into master Oct 6, 2026
3 checks passed
@alexellis
alexellis deleted the generate-env-flag branch October 6, 2026 07:47
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