From 5157a01b6e07aa55f3d2b6620ddf06f5d756959d Mon Sep 17 00:00:00 2001 From: Chioma Onyekpere Date: Fri, 29 Apr 2022 19:03:04 +0100 Subject: [PATCH 1/2] Switch from StringSlice to StringArray (#1931) * test for parameters with space Signed-off-by: Simpcyclassy * add contributor Signed-off-by: Simpcyclassy * handle bundle parameter escape Signed-off-by: Simpcyclassy * update parameters documentation Signed-off-by: Simpcyclassy * Merge branch 'release/v1' into parameter-space-error Signed-off-by: Simpcyclassy * array to slice paramenter Signed-off-by: Simpcyclassy * define params as array var Signed-off-by: Simpcyclassy * add schema version to yaml file Signed-off-by: Simpcyclassy * Help get PR merged * Run mage build to generate the cli command documentation to include the recent changes * Skip the failing test that was added. This PR has enough to fix the comma parsing, and a follow-up will fix this failing test for when a parameter has a space in it. Signed-off-by: Carolyn Van Slyck * Fix merge conflicts with release/v1 Signed-off-by: Carolyn Van Slyck Co-authored-by: Carolyn Van Slyck Signed-off-by: Chioma Onyekpere --- CONTRIBUTORS.md | 2 +- cmd/porter/bundle.go | 24 ++++++------ docs/content/cli/bundles_install.md | 24 ++++++------ docs/content/cli/bundles_invoke.md | 26 ++++++------- docs/content/cli/bundles_uninstall.md | 28 +++++++------- docs/content/cli/completion.md | 3 +- docs/content/cli/install.md | 24 ++++++------ docs/content/cli/invoke.md | 26 ++++++------- docs/content/cli/uninstall.md | 28 +++++++------- tests/integration/install_test.go | 24 ++++++++++++ .../bundle-with-string-params/helpers.sh | 17 +++++++++ .../bundle-with-string-params/porter.yaml | 37 +++++++++++++++++++ 12 files changed, 171 insertions(+), 92 deletions(-) create mode 100755 tests/integration/testdata/bundles/bundle-with-string-params/helpers.sh create mode 100644 tests/integration/testdata/bundles/bundle-with-string-params/porter.yaml diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index 6de7abf84..ef7af9cb9 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -60,4 +60,4 @@ and we will add you. **All** contributors belong here. 💯 * [Saksham Sharma](https://github.com/sakkshm26) * [Quentin Petraroia](https://github.com/qpetraroia) * [Tamir Kamara](https://github.com/tamirkamara) - +* [Chioma Onyekpere](https://github.com/Simpcyclassy) diff --git a/cmd/porter/bundle.go b/cmd/porter/bundle.go index 97008bddc..911084d13 100644 --- a/cmd/porter/bundle.go +++ b/cmd/porter/bundle.go @@ -142,11 +142,11 @@ For example, the 'debug' driver may be specified, which simply logs the info giv "Path to the porter manifest file. Defaults to the bundle in the current directory.") f.StringVar(&opts.CNABFile, "cnab-file", "", "Path to the CNAB bundle.json file.") - f.StringSliceVarP(&opts.ParameterSets, "parameter-set", "p", nil, + f.StringArrayVarP(&opts.ParameterSets, "parameter-set", "p", nil, "Name of a parameter set file for the bundle. May be either a named set of parameters or a filepath, and specified multiple times.") - f.StringSliceVar(&opts.Params, "param", nil, + f.StringArrayVar(&opts.Params, "param", nil, "Define an individual parameter in the form NAME=VALUE. Overrides parameters otherwise set via --parameter-set. May be specified multiple times.") - f.StringSliceVarP(&opts.CredentialIdentifiers, "cred", "c", nil, + f.StringArrayVarP(&opts.CredentialIdentifiers, "cred", "c", nil, "Credential to use when installing the bundle. May be either a named set of credentials or a filepath, and specified multiple times.") f.StringVarP(&opts.Driver, "driver", "d", porter.DefaultDriver, "Specify a driver to use. Allowed values: docker, debug") @@ -190,11 +190,11 @@ For example, the 'debug' driver may be specified, which simply logs the info giv "Path to the porter manifest file. Defaults to the bundle in the current directory.") f.StringVar(&opts.CNABFile, "cnab-file", "", "Path to the CNAB bundle.json file.") - f.StringSliceVarP(&opts.ParameterSets, "parameter-set", "p", nil, + f.StringArrayVarP(&opts.ParameterSets, "parameter-set", "p", nil, "Name of a parameter set file for the bundle. May be either a named set of parameters or a filepath, and specified multiple times.") - f.StringSliceVar(&opts.Params, "param", nil, + f.StringArrayVar(&opts.Params, "param", nil, "Define an individual parameter in the form NAME=VALUE. Overrides parameters otherwise set via --parameter-set. May be specified multiple times.") - f.StringSliceVarP(&opts.CredentialIdentifiers, "cred", "c", nil, + f.StringArrayVarP(&opts.CredentialIdentifiers, "cred", "c", nil, "Credential to use when installing the bundle. May be either a named set of credentials or a filepath, and specified multiple times.") f.StringVarP(&opts.Driver, "driver", "d", porter.DefaultDriver, "Specify a driver to use. Allowed values: docker, debug") @@ -241,11 +241,11 @@ For example, the 'debug' driver may be specified, which simply logs the info giv "Path to the porter manifest file. Defaults to the bundle in the current directory.") f.StringVar(&opts.CNABFile, "cnab-file", "", "Path to the CNAB bundle.json file.") - f.StringSliceVarP(&opts.ParameterSets, "parameter-set", "p", nil, + f.StringArrayVarP(&opts.ParameterSets, "parameter-set", "p", nil, "Name of a parameter set file for the bundle. May be either a named set of parameters or a filepath, and specified multiple times.") - f.StringSliceVar(&opts.Params, "param", nil, + f.StringArrayVar(&opts.Params, "param", nil, "Define an individual parameter in the form NAME=VALUE. Overrides parameters otherwise set via --parameter-set. May be specified multiple times.") - f.StringSliceVarP(&opts.CredentialIdentifiers, "cred", "c", nil, + f.StringArrayVarP(&opts.CredentialIdentifiers, "cred", "c", nil, "Credential to use when installing the bundle. May be either a named set of credentials or a filepath, and specified multiple times.") f.StringVarP(&opts.Driver, "driver", "d", porter.DefaultDriver, "Specify a driver to use. Allowed values: docker, debug") @@ -292,11 +292,11 @@ For example, the 'debug' driver may be specified, which simply logs the info giv "Path to the porter manifest file. Defaults to the bundle in the current directory. Optional unless a newer version of the bundle should be used to uninstall the bundle.") f.StringVar(&opts.CNABFile, "cnab-file", "", "Path to the CNAB bundle.json file.") - f.StringSliceVarP(&opts.ParameterSets, "parameter-set", "p", nil, + f.StringArrayVarP(&opts.ParameterSets, "parameter-set", "p", nil, "Name of a parameter set file for the bundle. May be either a named set of parameters or a filepath, and specified multiple times.") - f.StringSliceVar(&opts.Params, "param", nil, + f.StringArrayVar(&opts.Params, "param", nil, "Define an individual parameter in the form NAME=VALUE. Overrides parameters otherwise set via --parameter-set. May be specified multiple times.") - f.StringSliceVarP(&opts.CredentialIdentifiers, "cred", "c", nil, + f.StringArrayVarP(&opts.CredentialIdentifiers, "cred", "c", nil, "Credential to use when uninstalling the bundle. May be either a named set of credentials or a filepath, and specified multiple times.") f.StringVarP(&opts.Driver, "driver", "d", porter.DefaultDriver, "Specify a driver to use. Allowed values: docker, debug") diff --git a/docs/content/cli/bundles_install.md b/docs/content/cli/bundles_install.md index 16b8b8d31..48033f2ff 100644 --- a/docs/content/cli/bundles_install.md +++ b/docs/content/cli/bundles_install.md @@ -36,18 +36,18 @@ porter bundles install [INSTALLATION] [flags] ### Options ``` - --allow-docker-host-access Controls if the bundle should have access to the host's Docker daemon with elevated privileges. See https://porter.sh/configuration/#allow-docker-host-access for the full implications of this flag. - --cnab-file string Path to the CNAB bundle.json file. - -c, --cred strings Credential to use when installing the bundle. May be either a named set of credentials or a filepath, and specified multiple times. - -d, --driver string Specify a driver to use. Allowed values: docker, debug (default "docker") - -f, --file string Path to the porter manifest file. Defaults to the bundle in the current directory. - --force Force a fresh pull of the bundle - -h, --help help for install - --insecure-registry Don't require TLS for the registry - --no-logs Do not persist the bundle execution logs - --param strings Define an individual parameter in the form NAME=VALUE. Overrides parameters otherwise set via --parameter-set. May be specified multiple times. - -p, --parameter-set strings Name of a parameter set file for the bundle. May be either a named set of parameters or a filepath, and specified multiple times. - -r, --reference string Use a bundle in an OCI registry specified by the given reference. + --allow-docker-host-access Controls if the bundle should have access to the host's Docker daemon with elevated privileges. See https://porter.sh/configuration/#allow-docker-host-access for the full implications of this flag. + --cnab-file string Path to the CNAB bundle.json file. + -c, --cred strings Credential to use when installing the bundle. May be either a named set of credentials or a filepath, and specified multiple times. + -d, --driver string Specify a driver to use. Allowed values: docker, debug (default "docker") + -f, --file string Path to the porter manifest file. Defaults to the bundle in the current directory. + --force Force a fresh pull of the bundle + -h, --help help for install + --insecure-registry Don't require TLS for the registry + --no-logs Do not persist the bundle execution logs + --param stringArray Define an individual parameter in the form NAME=VALUE. Overrides parameters otherwise set via --parameter-set. May be specified multiple times. + -p, --parameter-set stringArray Name of a parameter set file for the bundle. May be either a named set of parameters or a filepath, and specified multiple times. + -r, --reference string Use a bundle in an OCI registry specified by the given reference. ``` ### Options inherited from parent commands diff --git a/docs/content/cli/bundles_invoke.md b/docs/content/cli/bundles_invoke.md index de5cfbc98..f05ec1cfb 100644 --- a/docs/content/cli/bundles_invoke.md +++ b/docs/content/cli/bundles_invoke.md @@ -36,19 +36,19 @@ porter bundles invoke [INSTALLATION] --action ACTION [flags] ### Options ``` - --action string Custom action name to invoke. - --allow-docker-host-access Controls if the bundle should have access to the host's Docker daemon with elevated privileges. See https://porter.sh/configuration/#allow-docker-host-access for the full implications of this flag. - --cnab-file string Path to the CNAB bundle.json file. - -c, --cred strings Credential to use when installing the bundle. May be either a named set of credentials or a filepath, and specified multiple times. - -d, --driver string Specify a driver to use. Allowed values: docker, debug (default "docker") - -f, --file string Path to the porter manifest file. Defaults to the bundle in the current directory. - --force Force a fresh pull of the bundle - -h, --help help for invoke - --insecure-registry Don't require TLS for the registry - --no-logs Do not persist the bundle execution logs - --param strings Define an individual parameter in the form NAME=VALUE. Overrides parameters otherwise set via --parameter-set. May be specified multiple times. - -p, --parameter-set strings Name of a parameter set file for the bundle. May be either a named set of parameters or a filepath, and specified multiple times. - -r, --reference string Use a bundle in an OCI registry specified by the given reference. + --action string Custom action name to invoke. + --allow-docker-host-access Controls if the bundle should have access to the host's Docker daemon with elevated privileges. See https://porter.sh/configuration/#allow-docker-host-access for the full implications of this flag. + --cnab-file string Path to the CNAB bundle.json file. + -c, --cred strings Credential to use when installing the bundle. May be either a named set of credentials or a filepath, and specified multiple times. + -d, --driver string Specify a driver to use. Allowed values: docker, debug (default "docker") + -f, --file string Path to the porter manifest file. Defaults to the bundle in the current directory. + --force Force a fresh pull of the bundle + -h, --help help for invoke + --insecure-registry Don't require TLS for the registry + --no-logs Do not persist the bundle execution logs + --param stringArray Define an individual parameter in the form NAME=VALUE. Overrides parameters otherwise set via --parameter-set. May be specified multiple times. + -p, --parameter-set stringArray Name of a parameter set file for the bundle. May be either a named set of parameters or a filepath, and specified multiple times. + -r, --reference string Use a bundle in an OCI registry specified by the given reference. ``` ### Options inherited from parent commands diff --git a/docs/content/cli/bundles_uninstall.md b/docs/content/cli/bundles_uninstall.md index 8560a328c..2f2cc4192 100644 --- a/docs/content/cli/bundles_uninstall.md +++ b/docs/content/cli/bundles_uninstall.md @@ -38,20 +38,20 @@ porter bundles uninstall [INSTALLATION] [flags] ### Options ``` - --allow-docker-host-access Controls if the bundle should have access to the host's Docker daemon with elevated privileges. See https://porter.sh/configuration/#allow-docker-host-access for the full implications of this flag. - --cnab-file string Path to the CNAB bundle.json file. - -c, --cred strings Credential to use when uninstalling the bundle. May be either a named set of credentials or a filepath, and specified multiple times. - --delete Delete all records associated with the installation, assuming the uninstall action succeeds - -d, --driver string Specify a driver to use. Allowed values: docker, debug (default "docker") - -f, --file string Path to the porter manifest file. Defaults to the bundle in the current directory. Optional unless a newer version of the bundle should be used to uninstall the bundle. - --force Force a fresh pull of the bundle - --force-delete UNSAFE. Delete all records associated with the installation, even if uninstall fails. This is intended for cleaning up test data and is not recommended for production environments. - -h, --help help for uninstall - --insecure-registry Don't require TLS for the registry - --no-logs Do not persist the bundle execution logs - --param strings Define an individual parameter in the form NAME=VALUE. Overrides parameters otherwise set via --parameter-set. May be specified multiple times. - -p, --parameter-set strings Name of a parameter set file for the bundle. May be either a named set of parameters or a filepath, and specified multiple times. - -r, --reference string Use a bundle in an OCI registry specified by the given reference. + --allow-docker-host-access Controls if the bundle should have access to the host's Docker daemon with elevated privileges. See https://porter.sh/configuration/#allow-docker-host-access for the full implications of this flag. + --cnab-file string Path to the CNAB bundle.json file. + -c, --cred strings Credential to use when uninstalling the bundle. May be either a named set of credentials or a filepath, and specified multiple times. + --delete Delete all records associated with the installation, assuming the uninstall action succeeds + -d, --driver string Specify a driver to use. Allowed values: docker, debug (default "docker") + -f, --file string Path to the porter manifest file. Defaults to the bundle in the current directory. Optional unless a newer version of the bundle should be used to uninstall the bundle. + --force Force a fresh pull of the bundle + --force-delete UNSAFE. Delete all records associated with the installation, even if uninstall fails. This is intended for cleaning up test data and is not recommended for production environments. + -h, --help help for uninstall + --insecure-registry Don't require TLS for the registry + --no-logs Do not persist the bundle execution logs + --param stringArray Define an individual parameter in the form NAME=VALUE. Overrides parameters otherwise set via --parameter-set. May be specified multiple times. + -p, --parameter-set stringArray Name of a parameter set file for the bundle. May be either a named set of parameters or a filepath, and specified multiple times. + -r, --reference string Use a bundle in an OCI registry specified by the given reference. ``` ### Options inherited from parent commands diff --git a/docs/content/cli/completion.md b/docs/content/cli/completion.md index dce1727a9..6468885a4 100644 --- a/docs/content/cli/completion.md +++ b/docs/content/cli/completion.md @@ -9,7 +9,8 @@ Generate completion script ### Synopsis -Capture the output of the completion command to a file for your shell environment. +Save the output of this command to a file and load the file into your shell. +For additional details see: https://porter.sh/install#command-completion ``` porter completion [bash|zsh|fish|powershell] diff --git a/docs/content/cli/install.md b/docs/content/cli/install.md index baefa2487..273242bb4 100644 --- a/docs/content/cli/install.md +++ b/docs/content/cli/install.md @@ -36,18 +36,18 @@ porter install [INSTALLATION] [flags] ### Options ``` - --allow-docker-host-access Controls if the bundle should have access to the host's Docker daemon with elevated privileges. See https://porter.sh/configuration/#allow-docker-host-access for the full implications of this flag. - --cnab-file string Path to the CNAB bundle.json file. - -c, --cred strings Credential to use when installing the bundle. May be either a named set of credentials or a filepath, and specified multiple times. - -d, --driver string Specify a driver to use. Allowed values: docker, debug (default "docker") - -f, --file string Path to the porter manifest file. Defaults to the bundle in the current directory. - --force Force a fresh pull of the bundle - -h, --help help for install - --insecure-registry Don't require TLS for the registry - --no-logs Do not persist the bundle execution logs - --param strings Define an individual parameter in the form NAME=VALUE. Overrides parameters otherwise set via --parameter-set. May be specified multiple times. - -p, --parameter-set strings Name of a parameter set file for the bundle. May be either a named set of parameters or a filepath, and specified multiple times. - -r, --reference string Use a bundle in an OCI registry specified by the given reference. + --allow-docker-host-access Controls if the bundle should have access to the host's Docker daemon with elevated privileges. See https://porter.sh/configuration/#allow-docker-host-access for the full implications of this flag. + --cnab-file string Path to the CNAB bundle.json file. + -c, --cred strings Credential to use when installing the bundle. May be either a named set of credentials or a filepath, and specified multiple times. + -d, --driver string Specify a driver to use. Allowed values: docker, debug (default "docker") + -f, --file string Path to the porter manifest file. Defaults to the bundle in the current directory. + --force Force a fresh pull of the bundle + -h, --help help for install + --insecure-registry Don't require TLS for the registry + --no-logs Do not persist the bundle execution logs + --param stringArray Define an individual parameter in the form NAME=VALUE. Overrides parameters otherwise set via --parameter-set. May be specified multiple times. + -p, --parameter-set stringArray Name of a parameter set file for the bundle. May be either a named set of parameters or a filepath, and specified multiple times. + -r, --reference string Use a bundle in an OCI registry specified by the given reference. ``` ### Options inherited from parent commands diff --git a/docs/content/cli/invoke.md b/docs/content/cli/invoke.md index e8576cb0e..2c1e51ebd 100644 --- a/docs/content/cli/invoke.md +++ b/docs/content/cli/invoke.md @@ -36,19 +36,19 @@ porter invoke [INSTALLATION] --action ACTION [flags] ### Options ``` - --action string Custom action name to invoke. - --allow-docker-host-access Controls if the bundle should have access to the host's Docker daemon with elevated privileges. See https://porter.sh/configuration/#allow-docker-host-access for the full implications of this flag. - --cnab-file string Path to the CNAB bundle.json file. - -c, --cred strings Credential to use when installing the bundle. May be either a named set of credentials or a filepath, and specified multiple times. - -d, --driver string Specify a driver to use. Allowed values: docker, debug (default "docker") - -f, --file string Path to the porter manifest file. Defaults to the bundle in the current directory. - --force Force a fresh pull of the bundle - -h, --help help for invoke - --insecure-registry Don't require TLS for the registry - --no-logs Do not persist the bundle execution logs - --param strings Define an individual parameter in the form NAME=VALUE. Overrides parameters otherwise set via --parameter-set. May be specified multiple times. - -p, --parameter-set strings Name of a parameter set file for the bundle. May be either a named set of parameters or a filepath, and specified multiple times. - -r, --reference string Use a bundle in an OCI registry specified by the given reference. + --action string Custom action name to invoke. + --allow-docker-host-access Controls if the bundle should have access to the host's Docker daemon with elevated privileges. See https://porter.sh/configuration/#allow-docker-host-access for the full implications of this flag. + --cnab-file string Path to the CNAB bundle.json file. + -c, --cred strings Credential to use when installing the bundle. May be either a named set of credentials or a filepath, and specified multiple times. + -d, --driver string Specify a driver to use. Allowed values: docker, debug (default "docker") + -f, --file string Path to the porter manifest file. Defaults to the bundle in the current directory. + --force Force a fresh pull of the bundle + -h, --help help for invoke + --insecure-registry Don't require TLS for the registry + --no-logs Do not persist the bundle execution logs + --param stringArray Define an individual parameter in the form NAME=VALUE. Overrides parameters otherwise set via --parameter-set. May be specified multiple times. + -p, --parameter-set stringArray Name of a parameter set file for the bundle. May be either a named set of parameters or a filepath, and specified multiple times. + -r, --reference string Use a bundle in an OCI registry specified by the given reference. ``` ### Options inherited from parent commands diff --git a/docs/content/cli/uninstall.md b/docs/content/cli/uninstall.md index 42d12cabd..a093cd35c 100644 --- a/docs/content/cli/uninstall.md +++ b/docs/content/cli/uninstall.md @@ -38,20 +38,20 @@ porter uninstall [INSTALLATION] [flags] ### Options ``` - --allow-docker-host-access Controls if the bundle should have access to the host's Docker daemon with elevated privileges. See https://porter.sh/configuration/#allow-docker-host-access for the full implications of this flag. - --cnab-file string Path to the CNAB bundle.json file. - -c, --cred strings Credential to use when uninstalling the bundle. May be either a named set of credentials or a filepath, and specified multiple times. - --delete Delete all records associated with the installation, assuming the uninstall action succeeds - -d, --driver string Specify a driver to use. Allowed values: docker, debug (default "docker") - -f, --file string Path to the porter manifest file. Defaults to the bundle in the current directory. Optional unless a newer version of the bundle should be used to uninstall the bundle. - --force Force a fresh pull of the bundle - --force-delete UNSAFE. Delete all records associated with the installation, even if uninstall fails. This is intended for cleaning up test data and is not recommended for production environments. - -h, --help help for uninstall - --insecure-registry Don't require TLS for the registry - --no-logs Do not persist the bundle execution logs - --param strings Define an individual parameter in the form NAME=VALUE. Overrides parameters otherwise set via --parameter-set. May be specified multiple times. - -p, --parameter-set strings Name of a parameter set file for the bundle. May be either a named set of parameters or a filepath, and specified multiple times. - -r, --reference string Use a bundle in an OCI registry specified by the given reference. + --allow-docker-host-access Controls if the bundle should have access to the host's Docker daemon with elevated privileges. See https://porter.sh/configuration/#allow-docker-host-access for the full implications of this flag. + --cnab-file string Path to the CNAB bundle.json file. + -c, --cred strings Credential to use when uninstalling the bundle. May be either a named set of credentials or a filepath, and specified multiple times. + --delete Delete all records associated with the installation, assuming the uninstall action succeeds + -d, --driver string Specify a driver to use. Allowed values: docker, debug (default "docker") + -f, --file string Path to the porter manifest file. Defaults to the bundle in the current directory. Optional unless a newer version of the bundle should be used to uninstall the bundle. + --force Force a fresh pull of the bundle + --force-delete UNSAFE. Delete all records associated with the installation, even if uninstall fails. This is intended for cleaning up test data and is not recommended for production environments. + -h, --help help for uninstall + --insecure-registry Don't require TLS for the registry + --no-logs Do not persist the bundle execution logs + --param stringArray Define an individual parameter in the form NAME=VALUE. Overrides parameters otherwise set via --parameter-set. May be specified multiple times. + -p, --parameter-set stringArray Name of a parameter set file for the bundle. May be either a named set of parameters or a filepath, and specified multiple times. + -r, --reference string Use a bundle in an OCI registry specified by the given reference. ``` ### Options inherited from parent commands diff --git a/tests/integration/install_test.go b/tests/integration/install_test.go index 0062c4c4b..9a08f901e 100644 --- a/tests/integration/install_test.go +++ b/tests/integration/install_test.go @@ -128,3 +128,27 @@ func TestInstall_withDockerignore(t *testing.T) { // We should check this once https://github.com/cnabio/cnab-go/issues/78 is closed require.EqualError(t, err, "1 error occurred:\n\t* container exit code: 1, message: \n\n") } + +func TestInstall_stringParam(t *testing.T) { + // Remove this skip when #1862 is fixed + t.Skip("This is a failing test for https://github.com/getporter/porter/issues/1862") + + p := porter.NewTestPorter(t) + defer p.Close() + p.SetupIntegrationTest() + p.Debug = false + + p.AddTestBundleDir("testdata/bundles/bundle-with-string-params", false) + + installOpts := porter.NewInstallOptions() + installOpts.Params = []string{"name=Demo Time"} + + err := installOpts.Validate(context.Background(), []string{}, p.Porter) + require.NoError(t, err) + + err = p.InstallBundle(context.Background(), installOpts) + require.NoError(t, err) + + output := p.TestConfig.TestContext.GetOutput() + require.Contains(t, output, "Hello, Demo Time", "expected action output to contain provided file contents") +} diff --git a/tests/integration/testdata/bundles/bundle-with-string-params/helpers.sh b/tests/integration/testdata/bundles/bundle-with-string-params/helpers.sh new file mode 100755 index 000000000..f23bfd932 --- /dev/null +++ b/tests/integration/testdata/bundles/bundle-with-string-params/helpers.sh @@ -0,0 +1,17 @@ +#!/usr/bin/env bash +set -euo pipefail + +install() { + echo Hello, $1 +} + +upgrade() { + echo $1 2.0 +} + +uninstall() { + echo Goodbye, $1 +} + +# Call the requested function and pass the arguments as-is +"$@" \ No newline at end of file diff --git a/tests/integration/testdata/bundles/bundle-with-string-params/porter.yaml b/tests/integration/testdata/bundles/bundle-with-string-params/porter.yaml new file mode 100644 index 000000000..1f064df9e --- /dev/null +++ b/tests/integration/testdata/bundles/bundle-with-string-params/porter.yaml @@ -0,0 +1,37 @@ +schemaVersion: 1.0.0-alpha.1 +name: porter-hello +version: 0.1.0 +description: "An example Porter configuration" +registry: getporter + +mixins: + - exec + +parameters: + - name: name + description: Name for our hello bundle + type: string + default: porter-hello + +install: + - exec: + description: "Install Hello World" + command: ./helpers.sh + arguments: + - install + - "{{ bundle.parameters.name }}" + +upgrade: + - exec: + description: "World 2.0" + command: ./helpers.sh + arguments: + - upgrade + +uninstall: + - exec: + description: "Uninstall Hello World" + command: ./helpers.sh + arguments: + - uninstall + From 9b9f8a10a129eac510da4e33783db917038b94ce Mon Sep 17 00:00:00 2001 From: Carolyn Van Slyck Date: Fri, 29 Apr 2022 14:02:13 -0500 Subject: [PATCH 2/2] Fix merge conflicts Signed-off-by: Carolyn Van Slyck --- docs/content/cli/bundles_install.md | 2 +- docs/content/cli/bundles_invoke.md | 2 +- docs/content/cli/bundles_uninstall.md | 2 +- docs/content/cli/bundles_upgrade.md | 24 ++++++++++++------------ docs/content/cli/install.md | 2 +- docs/content/cli/invoke.md | 2 +- docs/content/cli/uninstall.md | 2 +- docs/content/cli/upgrade.md | 24 ++++++++++++------------ tests/integration/install_test.go | 6 +++--- 9 files changed, 33 insertions(+), 33 deletions(-) diff --git a/docs/content/cli/bundles_install.md b/docs/content/cli/bundles_install.md index 48033f2ff..588bc8671 100644 --- a/docs/content/cli/bundles_install.md +++ b/docs/content/cli/bundles_install.md @@ -38,7 +38,7 @@ porter bundles install [INSTALLATION] [flags] ``` --allow-docker-host-access Controls if the bundle should have access to the host's Docker daemon with elevated privileges. See https://porter.sh/configuration/#allow-docker-host-access for the full implications of this flag. --cnab-file string Path to the CNAB bundle.json file. - -c, --cred strings Credential to use when installing the bundle. May be either a named set of credentials or a filepath, and specified multiple times. + -c, --cred stringArray Credential to use when installing the bundle. May be either a named set of credentials or a filepath, and specified multiple times. -d, --driver string Specify a driver to use. Allowed values: docker, debug (default "docker") -f, --file string Path to the porter manifest file. Defaults to the bundle in the current directory. --force Force a fresh pull of the bundle diff --git a/docs/content/cli/bundles_invoke.md b/docs/content/cli/bundles_invoke.md index f05ec1cfb..44ff30e96 100644 --- a/docs/content/cli/bundles_invoke.md +++ b/docs/content/cli/bundles_invoke.md @@ -39,7 +39,7 @@ porter bundles invoke [INSTALLATION] --action ACTION [flags] --action string Custom action name to invoke. --allow-docker-host-access Controls if the bundle should have access to the host's Docker daemon with elevated privileges. See https://porter.sh/configuration/#allow-docker-host-access for the full implications of this flag. --cnab-file string Path to the CNAB bundle.json file. - -c, --cred strings Credential to use when installing the bundle. May be either a named set of credentials or a filepath, and specified multiple times. + -c, --cred stringArray Credential to use when installing the bundle. May be either a named set of credentials or a filepath, and specified multiple times. -d, --driver string Specify a driver to use. Allowed values: docker, debug (default "docker") -f, --file string Path to the porter manifest file. Defaults to the bundle in the current directory. --force Force a fresh pull of the bundle diff --git a/docs/content/cli/bundles_uninstall.md b/docs/content/cli/bundles_uninstall.md index 2f2cc4192..11136c693 100644 --- a/docs/content/cli/bundles_uninstall.md +++ b/docs/content/cli/bundles_uninstall.md @@ -40,7 +40,7 @@ porter bundles uninstall [INSTALLATION] [flags] ``` --allow-docker-host-access Controls if the bundle should have access to the host's Docker daemon with elevated privileges. See https://porter.sh/configuration/#allow-docker-host-access for the full implications of this flag. --cnab-file string Path to the CNAB bundle.json file. - -c, --cred strings Credential to use when uninstalling the bundle. May be either a named set of credentials or a filepath, and specified multiple times. + -c, --cred stringArray Credential to use when uninstalling the bundle. May be either a named set of credentials or a filepath, and specified multiple times. --delete Delete all records associated with the installation, assuming the uninstall action succeeds -d, --driver string Specify a driver to use. Allowed values: docker, debug (default "docker") -f, --file string Path to the porter manifest file. Defaults to the bundle in the current directory. Optional unless a newer version of the bundle should be used to uninstall the bundle. diff --git a/docs/content/cli/bundles_upgrade.md b/docs/content/cli/bundles_upgrade.md index 8ac3a591a..0a9bbe8b9 100644 --- a/docs/content/cli/bundles_upgrade.md +++ b/docs/content/cli/bundles_upgrade.md @@ -36,18 +36,18 @@ porter bundles upgrade [INSTALLATION] [flags] ### Options ``` - --allow-docker-host-access Controls if the bundle should have access to the host's Docker daemon with elevated privileges. See https://porter.sh/configuration/#allow-docker-host-access for the full implications of this flag. - --cnab-file string Path to the CNAB bundle.json file. - -c, --cred strings Credential to use when installing the bundle. May be either a named set of credentials or a filepath, and specified multiple times. - -d, --driver string Specify a driver to use. Allowed values: docker, debug (default "docker") - -f, --file string Path to the porter manifest file. Defaults to the bundle in the current directory. - --force Force a fresh pull of the bundle - -h, --help help for upgrade - --insecure-registry Don't require TLS for the registry - --no-logs Do not persist the bundle execution logs - --param strings Define an individual parameter in the form NAME=VALUE. Overrides parameters otherwise set via --parameter-set. May be specified multiple times. - -p, --parameter-set strings Name of a parameter set file for the bundle. May be either a named set of parameters or a filepath, and specified multiple times. - -r, --reference string Use a bundle in an OCI registry specified by the given reference. + --allow-docker-host-access Controls if the bundle should have access to the host's Docker daemon with elevated privileges. See https://porter.sh/configuration/#allow-docker-host-access for the full implications of this flag. + --cnab-file string Path to the CNAB bundle.json file. + -c, --cred stringArray Credential to use when installing the bundle. May be either a named set of credentials or a filepath, and specified multiple times. + -d, --driver string Specify a driver to use. Allowed values: docker, debug (default "docker") + -f, --file string Path to the porter manifest file. Defaults to the bundle in the current directory. + --force Force a fresh pull of the bundle + -h, --help help for upgrade + --insecure-registry Don't require TLS for the registry + --no-logs Do not persist the bundle execution logs + --param stringArray Define an individual parameter in the form NAME=VALUE. Overrides parameters otherwise set via --parameter-set. May be specified multiple times. + -p, --parameter-set stringArray Name of a parameter set file for the bundle. May be either a named set of parameters or a filepath, and specified multiple times. + -r, --reference string Use a bundle in an OCI registry specified by the given reference. ``` ### Options inherited from parent commands diff --git a/docs/content/cli/install.md b/docs/content/cli/install.md index 273242bb4..d8bc350cb 100644 --- a/docs/content/cli/install.md +++ b/docs/content/cli/install.md @@ -38,7 +38,7 @@ porter install [INSTALLATION] [flags] ``` --allow-docker-host-access Controls if the bundle should have access to the host's Docker daemon with elevated privileges. See https://porter.sh/configuration/#allow-docker-host-access for the full implications of this flag. --cnab-file string Path to the CNAB bundle.json file. - -c, --cred strings Credential to use when installing the bundle. May be either a named set of credentials or a filepath, and specified multiple times. + -c, --cred stringArray Credential to use when installing the bundle. May be either a named set of credentials or a filepath, and specified multiple times. -d, --driver string Specify a driver to use. Allowed values: docker, debug (default "docker") -f, --file string Path to the porter manifest file. Defaults to the bundle in the current directory. --force Force a fresh pull of the bundle diff --git a/docs/content/cli/invoke.md b/docs/content/cli/invoke.md index 2c1e51ebd..483a42d22 100644 --- a/docs/content/cli/invoke.md +++ b/docs/content/cli/invoke.md @@ -39,7 +39,7 @@ porter invoke [INSTALLATION] --action ACTION [flags] --action string Custom action name to invoke. --allow-docker-host-access Controls if the bundle should have access to the host's Docker daemon with elevated privileges. See https://porter.sh/configuration/#allow-docker-host-access for the full implications of this flag. --cnab-file string Path to the CNAB bundle.json file. - -c, --cred strings Credential to use when installing the bundle. May be either a named set of credentials or a filepath, and specified multiple times. + -c, --cred stringArray Credential to use when installing the bundle. May be either a named set of credentials or a filepath, and specified multiple times. -d, --driver string Specify a driver to use. Allowed values: docker, debug (default "docker") -f, --file string Path to the porter manifest file. Defaults to the bundle in the current directory. --force Force a fresh pull of the bundle diff --git a/docs/content/cli/uninstall.md b/docs/content/cli/uninstall.md index a093cd35c..c1253fe1e 100644 --- a/docs/content/cli/uninstall.md +++ b/docs/content/cli/uninstall.md @@ -40,7 +40,7 @@ porter uninstall [INSTALLATION] [flags] ``` --allow-docker-host-access Controls if the bundle should have access to the host's Docker daemon with elevated privileges. See https://porter.sh/configuration/#allow-docker-host-access for the full implications of this flag. --cnab-file string Path to the CNAB bundle.json file. - -c, --cred strings Credential to use when uninstalling the bundle. May be either a named set of credentials or a filepath, and specified multiple times. + -c, --cred stringArray Credential to use when uninstalling the bundle. May be either a named set of credentials or a filepath, and specified multiple times. --delete Delete all records associated with the installation, assuming the uninstall action succeeds -d, --driver string Specify a driver to use. Allowed values: docker, debug (default "docker") -f, --file string Path to the porter manifest file. Defaults to the bundle in the current directory. Optional unless a newer version of the bundle should be used to uninstall the bundle. diff --git a/docs/content/cli/upgrade.md b/docs/content/cli/upgrade.md index 9c952fcbc..dc3e5fe36 100644 --- a/docs/content/cli/upgrade.md +++ b/docs/content/cli/upgrade.md @@ -36,18 +36,18 @@ porter upgrade [INSTALLATION] [flags] ### Options ``` - --allow-docker-host-access Controls if the bundle should have access to the host's Docker daemon with elevated privileges. See https://porter.sh/configuration/#allow-docker-host-access for the full implications of this flag. - --cnab-file string Path to the CNAB bundle.json file. - -c, --cred strings Credential to use when installing the bundle. May be either a named set of credentials or a filepath, and specified multiple times. - -d, --driver string Specify a driver to use. Allowed values: docker, debug (default "docker") - -f, --file string Path to the porter manifest file. Defaults to the bundle in the current directory. - --force Force a fresh pull of the bundle - -h, --help help for upgrade - --insecure-registry Don't require TLS for the registry - --no-logs Do not persist the bundle execution logs - --param strings Define an individual parameter in the form NAME=VALUE. Overrides parameters otherwise set via --parameter-set. May be specified multiple times. - -p, --parameter-set strings Name of a parameter set file for the bundle. May be either a named set of parameters or a filepath, and specified multiple times. - -r, --reference string Use a bundle in an OCI registry specified by the given reference. + --allow-docker-host-access Controls if the bundle should have access to the host's Docker daemon with elevated privileges. See https://porter.sh/configuration/#allow-docker-host-access for the full implications of this flag. + --cnab-file string Path to the CNAB bundle.json file. + -c, --cred stringArray Credential to use when installing the bundle. May be either a named set of credentials or a filepath, and specified multiple times. + -d, --driver string Specify a driver to use. Allowed values: docker, debug (default "docker") + -f, --file string Path to the porter manifest file. Defaults to the bundle in the current directory. + --force Force a fresh pull of the bundle + -h, --help help for upgrade + --insecure-registry Don't require TLS for the registry + --no-logs Do not persist the bundle execution logs + --param stringArray Define an individual parameter in the form NAME=VALUE. Overrides parameters otherwise set via --parameter-set. May be specified multiple times. + -p, --parameter-set stringArray Name of a parameter set file for the bundle. May be either a named set of parameters or a filepath, and specified multiple times. + -r, --reference string Use a bundle in an OCI registry specified by the given reference. ``` ### Options inherited from parent commands diff --git a/tests/integration/install_test.go b/tests/integration/install_test.go index 9a08f901e..52ad5c925 100644 --- a/tests/integration/install_test.go +++ b/tests/integration/install_test.go @@ -1,3 +1,4 @@ +//go:build integration // +build integration package integration @@ -134,7 +135,6 @@ func TestInstall_stringParam(t *testing.T) { t.Skip("This is a failing test for https://github.com/getporter/porter/issues/1862") p := porter.NewTestPorter(t) - defer p.Close() p.SetupIntegrationTest() p.Debug = false @@ -143,10 +143,10 @@ func TestInstall_stringParam(t *testing.T) { installOpts := porter.NewInstallOptions() installOpts.Params = []string{"name=Demo Time"} - err := installOpts.Validate(context.Background(), []string{}, p.Porter) + err := installOpts.Validate([]string{}, p.Porter) require.NoError(t, err) - err = p.InstallBundle(context.Background(), installOpts) + err = p.InstallBundle(installOpts) require.NoError(t, err) output := p.TestConfig.TestContext.GetOutput()