Skip to content

Commit

Permalink
Merge pull request #541 from carolynvs/exec-split-args-flags
Browse files Browse the repository at this point in the history
Split the exec arguments into flags and args
  • Loading branch information
carolynvs-msft authored Aug 23, 2019
2 parents d2c2520 + 92cd1f1 commit 15307ce
Show file tree
Hide file tree
Showing 48 changed files with 618 additions and 608 deletions.
5 changes: 2 additions & 3 deletions build/testdata/bundles/mysql/porter.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,8 @@ ping:
- exec:
description: "Ping"
command: "bash"
arguments:
- -c
- echo ping
flags:
c: echo ping

uninstall:
- helm:
Expand Down
5 changes: 2 additions & 3 deletions build/testdata/bundles/wordpress/porter.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,8 @@ ping:
- exec:
description: "Ping"
command: "bash"
arguments:
- -c
- echo ping
flags:
c: echo ping

uninstall:
- helm:
Expand Down
20 changes: 8 additions & 12 deletions docs/content/build-image.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,15 @@ install:
- exec:
description: "Install Hello World"
command: bash
arguments:
- -c
- echo Hello World
flags:
c: echo Hello World

uninstall:
- exec:
description: "Uninstall Hello World"
command: bash
arguments:
- -c
- echo Goodbye World
flags:
c: echo Goodbye World

#dependencies:
# - name: mysql
Expand Down Expand Up @@ -270,17 +268,15 @@ install:
- exec:
description: "Say Hello"
command: bash
arguments:
- -c
- echo Hello World
flags:
c: echo Hello World
uninstall:
- exec:
description: "Say Goodbye"
command: bash
arguments:
- -c
- echo Goodbye World
flags:
c: echo Goodbye World
```

This bundle, for example, declares a dependency on a bundle named `mysql`. The CNAB specification doesn't provide a mechanism for handling dependency resolution. Porter supplements the CNAB spec to support dependencies by resolving any dependencies at build time, including the contents of each dependency in the invocation image. At runtime the contents of that bundle will therefore be in the bundle and the Porter runtime component can execute them successfully.
Expand Down
5 changes: 2 additions & 3 deletions docs/content/mixin-architecture.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,8 @@ install:
- exec:
description: "Say Hello"
command: bash
arguments:
- -c
- echo Hello World
flags:
c: echo Hello World
```
## Mixin API
Expand Down
5 changes: 2 additions & 3 deletions docs/content/mixin-commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -224,9 +224,8 @@ status:
- exec:
description: "Run a rando command, don't care what action I'm in"
command: bash
arguments:
- -c
- echo "Don't mind me, just getting the status of something..."
flags:
c: echo "Don't mind me, just getting the status of something..."
```

# version
Expand Down
28 changes: 25 additions & 3 deletions docs/content/mixins/exec.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,29 @@ Source: https://github.com/deislabs/porter/tree/master/pkg/exec
porter mixin install terraform --feed-url https://cdn.deislabs.io/porter/atom.xml
```

## Mixin Syntax

```yaml
exec:
description: "Description of the command"
command: cmd
arguments:
- arg1
- arg2
flags:
a: flag-value
long-flag: true
repeated-flag:
- flag-value1
- flag-value2
```
This is executed as:
```
$ cmd arg1 arg2 -a flag-value --long-flag true --repeated-flag flag-value1 --repeated-flag flag-value2
```

### Examples

Run a command
Expand All @@ -20,9 +43,8 @@ install:
- exec:
description: "Install Hello World"
command: bash
arguments:
- -c
- echo Hello World
flags:
c: echo Hello World
```
Run a script
Expand Down
10 changes: 4 additions & 6 deletions docs/content/quickstart.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,15 @@ install:
- description: "Install Hello World"
exec:
command: bash
arguments:
- -c
- echo Hello World
flags:
c: echo Hello World
uninstall:
- description: "Uninstall Hello World"
exec:
command: bash
arguments:
- -c
- echo Goodbye World
flags:
c: echo Goodbye World
```

## Build the bundle
Expand Down
5 changes: 2 additions & 3 deletions docs/content/slides/pack-your-bags-msp/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -473,9 +473,8 @@ install:
- exec:
description: "Install Hello World"
command: bash
arguments:
- -c
- echo Hello World
flags:
c: echo Hello World
```
---
Expand Down
5 changes: 2 additions & 3 deletions docs/content/slides/pack-your-bags/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -519,9 +519,8 @@ install:
- exec:
description: "Install Hello World"
command: bash
arguments:
- -c
- echo Hello World
flags:
c: echo Hello World
```
---
Expand Down
5 changes: 2 additions & 3 deletions docs/content/wiring.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,8 @@ install:
- description: "Install Hello World"
exec:
command: bash
arguments:
- -c
- "{{ bundle.parameters.command }}"
flags:
c: "{{ bundle.parameters.command }}"
```

NOTE: These references must be quoted, as in the examples above.
Expand Down
5 changes: 2 additions & 3 deletions examples/aks-spring-music/porter.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,8 @@ uninstall:
- exec:
description: "Uninstall Spring Music Demo"
command: bash
arguments:
- -c
- echo App should be uninstalled here, but it is not
flags:
c: echo App should be uninstalled here, but it is not

credentials:
- name: SUBSCRIPTION_ID
Expand Down
5 changes: 2 additions & 3 deletions examples/azure-tf-example/porter.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,8 @@ install:
- exec:
description: "Emit the key in base64 encoded form"
command: bash
arguments:
- -c
- echo "Here is a the storage account key (base64 encoded) ==> $(echo {{bundle.outputs.STORAGE_ACCOUNT_KEY}} | base64)"
flags:
c: echo "Here is a the storage account key (base64 encoded) ==> $(echo {{bundle.outputs.STORAGE_ACCOUNT_KEY}} | base64)"

- terraform:
description: "Create Azure CosmosDB and Event Hubs"
Expand Down
5 changes: 2 additions & 3 deletions examples/kubernetes-mixin-example/porter.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,8 @@ install:
- exec:
description: "Echo the IP Address"
command: bash
arguments:
- -c
- "echo 'You will find the service at: {{bundle.outputs.IP_ADDRESS}}'"
flags:
c: "echo 'You will find the service at: {{bundle.outputs.IP_ADDRESS}}'"

uninstall:
- kubernetes:
Expand Down
2 changes: 1 addition & 1 deletion pkg/cnab/config_adapter/stamp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"github.com/stretchr/testify/require"
)

var simpleManifestDigest = "3f4c199b5b279b5457b00f20b7680e5b1fe644e89005dc8c4f7adf64565252fa"
var simpleManifestDigest = "74ef9c4abc7dfc41566ba28d9fcfab9c70baa0ca5ca434c71298689487f554e8"

func TestConfig_ComputeManifestDigest(t *testing.T) {
c := config.NewTestConfig(t)
Expand Down
25 changes: 10 additions & 15 deletions pkg/cnab/config_adapter/testdata/porter-with-custom-action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,38 +17,33 @@ install:
- exec:
description: "Install Hello World"
command: bash
arguments:
- -c
- echo Hello World
flags:
c: echo Hello World

upgrade:
- exec:
description: "World 2.0"
command: bash
arguments:
- -c
- echo World 2.0
flags:
c: echo World 2.0

status:
- exec:
description: "Get World Status"
command: bash
arguments:
- -c
- echo The world is on fire
flags:
c: echo The world is on fire

zombies:
- exec:
description: "Trigger zombie apocalypse"
command: bash
arguments:
- -c
- echo oh noes my brains
flags:
c: echo oh noes my brains

uninstall:
- exec:
description: "Uninstall Hello World"
command: bash
arguments:
- -c
- echo Goodbye World
flags:
c: echo Goodbye World
15 changes: 6 additions & 9 deletions pkg/cnab/config_adapter/testdata/porter-with-deps.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,22 +22,19 @@ install:
- exec:
description: "Install Hello World"
command: bash
arguments:
- -c
- echo Hello World
flags:
c: echo Hello World

upgrade:
- exec:
description: "World 2.0"
command: bash
arguments:
- -c
- echo World 2.0
flags:
c: echo World 2.0

uninstall:
- exec:
description: "Uninstall Hello World"
command: bash
arguments:
- -c
- echo Goodbye World
flags:
c: echo Goodbye World
15 changes: 6 additions & 9 deletions pkg/cnab/config_adapter/testdata/porter-with-parameters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,22 +45,19 @@ install:
- exec:
description: "Install Hello World"
command: bash
arguments:
- -c
- echo Hello World
flags:
c: echo Hello World

upgrade:
- exec:
description: "World 2.0"
command: bash
arguments:
- -c
- echo World 2.0
flags:
c: echo World 2.0

uninstall:
- exec:
description: "Uninstall Hello World"
command: bash
arguments:
- -c
- echo Goodbye World
flags:
c: echo Goodbye World
15 changes: 6 additions & 9 deletions pkg/cnab/config_adapter/testdata/porter.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,19 @@ install:
- exec:
description: "Say Hello"
command: bash
arguments:
- -c
- echo Hello World
flags:
c: echo Hello World

status:
- exec:
description: "Get World Status"
command: bash
arguments:
- -c
- echo The world is on fire
flags:
c: echo The world is on fire

uninstall:
- exec:
description: "Say Goodbye"
command: bash
arguments:
- -c
- echo Goodbye World
flags:
c: echo Goodbye World
8 changes: 4 additions & 4 deletions pkg/config/runtime-manifest_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -425,10 +425,10 @@ func TestResolveSliceWithAMap(t *testing.T) {
t.Logf("install data %v", installStep.Data)
exec := installStep.Data["exec"].(map[interface{}]interface{})
assert.NotNil(t, exec)
args := exec["arguments"].([]interface{})
assert.Len(t, args, 2)
assert.Equal(t, "echo hello world", args[1].(string))
assert.NotNil(t, args)
flags := exec["flags"].(map[interface{}]interface{})
assert.Len(t, flags, 1)
assert.Equal(t, "echo hello world", flags["c"].(string))
assert.NotNil(t, flags)
}

func TestResolveMultipleStepOutputs(t *testing.T) {
Expand Down
5 changes: 2 additions & 3 deletions pkg/config/testdata/param-test-in-block.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,5 @@ uninstall:
- exec:
description: "Uninstall Hello World"
command: bash
arguments:
- -c
- echo Goodbye World
flags:
c: echo Goodbye World
Loading

0 comments on commit 15307ce

Please sign in to comment.