-
Notifications
You must be signed in to change notification settings - Fork 222
Object file parameter #3487
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
Object file parameter #3487
Conversation
Enable users to load object-type parameters from JSON files using
the @ prefix syntax, similar to curl and kubectl. This provides a
convenient way to pass complex configuration objects without inline
JSON strings.
Usage:
porter install --param config=@/path/to/config.json
porter install --param config='{"key": "value"}'
Parameter sets also support @ prefix:
parameters:
- name: config
source:
value: @/path/to/config.json
Security considerations:
- Only applies to user-provided values (CLI flags/parameter sets)
- Does NOT work with default values in bundle definitions
- Validates JSON structure before processing
- Clear error messages for missing files or invalid JSON
Changes:
- Add @ prefix detection in getUnconvertedValueFromRaw()
- Read and validate JSON file contents for object parameters
- Add comprehensive unit tests covering success/error cases
- Add test fixtures for valid/invalid JSON scenarios
Signed-off-by: Kim Christensen <[email protected]>
Add comprehensive integration tests for object-type parameters loaded from files using the @ prefix syntax. Tests cover: - CLI parameter with @ prefix reading from file - Inline JSON parameter without @ prefix - Parameter set with @ prefix - Error handling for missing files - Error handling for invalid JSON files Also adds test bundle that uses template syntax to access object parameter fields in bundle execution steps. Signed-off-by: Kim <[email protected]> Signed-off-by: Kim Christensen <[email protected]>
Update CLI help text and user documentation to describe the @ prefix syntax for loading object parameters from JSON files. Changes include: - Updated --param flag help text with @ prefix example - Added @ prefix examples to install/upgrade/invoke commands - Added "Object Parameters from Files" section to intro docs - Updated quickstart guide with @ prefix usage - Enhanced parameter set file format documentation - Added example of @ prefix in parameter set YAML The documentation emphasizes the security constraint that @ prefix only works for user-provided values, not defaults. Signed-off-by: Kim <[email protected]> Signed-off-by: Kim Christensen <[email protected]>
Signed-off-by: Kim Christensen <[email protected]>
|
In parameter sets, there's |
dgannon991
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, and the comments for why it's safe were useful, cheers!
That is a really good point. It might already work I will check |
|
@lbergnehr It already works, I will update the documentation to show that configuration |
Update documentation to describe the proper `path` source syntax for parameter set definitions instead of the `@` prefix. Changes: - Clarify that `@` prefix is only for CLI --param flags - Add comprehensive examples showing `path` source in both YAML and JSON format for parameter set definitions - Update parameter set example to use schemaVersion 1.1.0 - Remove incorrect documentation about `@` prefix in value sources - Distinguish between CLI usage (@Prefix) and parameter set usage (path source) The `path` source is the correct way to reference files in parameter set definitions, while the `@` prefix remains a convenient shortcut for command-line parameter overrides. Signed-off-by: Kim Christensen <[email protected]>
|
@dgannon991 @lbergnehr I have update the documentation to how to use path source when using parameter sets, instead of the |
Signed-off-by: Kim Christensen <[email protected]>
What does this change
This change adds support for loading object-type parameters from JSON files using the
@prefix syntax. When passing object parameters via CLI or parameter sets, users can now reference an external JSON file instead of providing inline JSON.Example usage:
Where a parameter set might contain:
Key features:
type: objectin the bundle--paramCLI flags and parameter setvaluesourcesWhat issue does it fix
Closes #3257
Notes for the reviewer
@prefix logic is implemented inpkg/porter/parameters.go:getUnconvertedValueFromRaw()@prefix only works for user-provided parameter values (CLI/parameter sets), not for default values defined in bundle manifests, preventing potential security issues with malicious bundles@prefix, treating it as a literal string value for backward compatibilityChecklist