Skip to content
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

Support multiple input parameters #470

Merged
merged 11 commits into from
Sep 7, 2021

Conversation

Trojan295
Copy link
Contributor

@Trojan295 Trojan295 commented Aug 31, 2021

Description

Changes proposed in this pull request:

  • Allow providing multiple user input parameters through CLI
  • Inject multiple input parameters in rendering

Testing

AFAIK we don't have any Interface with two input parameters. I added a test for this + you can run an existing Action, eg. setup a Bitnami Helm Postgresql using the following input parameters:

input-parameters:
  superuser:
    username: damian
    password: sup3rs3cr3t
  defaultDBName: postgres

Check also capact upgrade on a cluster from this PR and CLI compiled from this PR:

capact upgrade --action-name-prefix 'capact-upgrade-' --version @latest --helm-repo-url @latest --increase-resource-limits --wait

Related issue(s)

Resolves #468

@Trojan295 Trojan295 added area/engine Relates to Engine breaking Contains breaking change enhancement New feature or request labels Aug 31, 2021
@Trojan295 Trojan295 marked this pull request as ready for review September 1, 2021 08:36
@Trojan295 Trojan295 force-pushed the support-multiple-parameters branch 2 times, most recently from abe6fc3 to 19651ab Compare September 3, 2021 09:06
@@ -374,7 +374,11 @@ func mapToInputTypeInstances(capactCfg gqllocalapi.TypeInstance) ([]*gqlengine.I
}

func mapToInputParameters(params capact.InputParameters) (gqlengine.JSON, error) {
marshalled, err := json.Marshal(params)
parameters := map[string]interface{}{
"input-parameters": params,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe make it a constant?

// RUN apk add jq=1.6-r1

Command: []string{"sh", "-c"},
Args: []string{fmt.Sprintf(`cat "%s" | jq -r '%s' | tee "%s" && sleep 1`, inputFilepath, jqPath, outputFilepath)},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe instead of using jq to extract parameters, we can just store then in secrets as separate keys?
Instead of:

apiVersion: v1
data:
  parameters.json: eyJleHRyYS1wYXJhbWV0ZXJzIjp7ImRlZmF1bHREQk5hbWUiOiJleHRyYS1kYmRiIiwic3VwZXJ1c2VyIjp7InBhc3N3b3JkIjoiZXh0cmEtcGFzczEyMyIsInVzZXJuYW1lIjoiZXh0cmEifX0sImlucHV0LXBhcmFtZXRlcnMiOnsiZGVmYXVsdERCTmFtZSI6ImRiZGIiLCJzdXBlcnVzZXIiOnsicGFzc3dvcmQiOiJjYXBhY3QtcGFzczEyMyIsInVzZXJuYW1lIjoiY2FwYWN0In19fQ==

We could do:

apiVersion: v1
data:
  input-parameters: <base64>
  another-parameters: <base64>

@Trojan295 Trojan295 force-pushed the support-multiple-parameters branch 2 times, most recently from 361d31e to de6249f Compare September 6, 2021 12:54
@Trojan295 Trojan295 merged commit e55e2a0 into capactio:main Sep 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/engine Relates to Engine breaking Contains breaking change enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Improve handling input parameters by Action CR
2 participants