-
Notifications
You must be signed in to change notification settings - Fork 212
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
fix(*): update parameter set logic to support file types #1137
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -307,6 +307,23 @@ func (p *Porter) loadParameterSets(params []string) (valuesource.Set, error) { | |
return nil, err | ||
} | ||
|
||
// A parameter may correspond to a Porter-specific parameter type of 'file' | ||
// If so, add value (filepath) directly to map and remove from pset | ||
for _, paramDef := range p.Manifest.Parameters { | ||
if paramDef.Type == "file" { | ||
for i, param := range pset.Parameters { | ||
if param.Name == paramDef.Name { | ||
// Pass through value (filepath) directly to resolvedParameters | ||
resolvedParameters[param.Name] = param.Source.Value | ||
// Eliminate this param from pset to prevent its resolution by | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What if instead of loading the manifest here and trying to check the parameters before it gets to the cnab-go code, we wrapped the cnab-go host secret store, and extended it in porter to support our custom file type property? Do you think it would be possible to change our support for the file type from a "hack" (that we shim in wherever we can fit it) to instead something that we override and support in the same struct/place that cnab-go supports the other types? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It may be possible, but my initial concern on going this direction was that this Say we do intend to proceed with adding to the cnab-go library. As there is pre-existing code to clean up (not intro'd in this PR), I'd definitely like to work off of a new issue mentioning this broader scope. The question would then be: do we want this fix (or a variant thereof) in the near-term to ensure functionality until the refactor (and corresponding cnab-go PR(s)) are scheduled to be worked on? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oops, miscommunication here. I was suggesting that we wrap the type defined in cnab-go responsible for resolving the parameter set and then extend it "inside of porter to support the file type". So the file type would continue to be porter only. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah, thank you. I think I have a better understanding now. I'll work with you to outline a strategy in a follow-up refactor in this area. |
||
// the cnab-go library, which doesn't support this parameter type | ||
pset.Parameters[i] = pset.Parameters[len(pset.Parameters)-1] | ||
pset.Parameters = pset.Parameters[:len(pset.Parameters)-1] | ||
} | ||
} | ||
} | ||
} | ||
|
||
rc, err := p.Parameters.ResolveAll(pset) | ||
if err != nil { | ||
return nil, err | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"name": "mypset", | ||
"created": "1983-04-18T01:02:03.000000004Z", | ||
"modified": "1983-04-18T01:02:03.000000004Z", | ||
"parameters": [ | ||
{ | ||
"name": "my-file-param", | ||
"source": { | ||
"path": "/local/path/to/my-file-param" | ||
} | ||
} | ||
] | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
name: HELLO_CUSTOM | ||
version: 0.1.0 | ||
description: "A bundle with a custom action" | ||
tag: getporter/porter-hello:v0.1.0 | ||
|
||
parameters: | ||
- name: my-file-param | ||
description: "My file param" | ||
type: file | ||
path: /container/path/to/file | ||
|
||
mixins: | ||
- exec | ||
|
||
install: | ||
- exec: | ||
description: "cat file" | ||
command: bash | ||
flags: | ||
c: '"cat /container/path/to/file"' | ||
|
||
uninstall: | ||
- exec: | ||
description: "cat file" | ||
command: bash | ||
flags: | ||
c: '"cat /container/path/to/file"' |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Hello Other World! |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"name": "mybun", | ||
"created": "2020-06-23T13:31:06.22727-06:00", | ||
"modified": "2020-06-23T13:31:44.692834-06:00", | ||
"parameters": [ | ||
{ | ||
"name": "myotherfile", | ||
"source": { | ||
"path": "./myotherfile" | ||
} | ||
} | ||
] | ||
} |
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.
ooh sneaky, I like it! π