Skip to content

Commit 91a95e6

Browse files
committed
separate exec plugin Action from Spec
Following commits will add the ability to reference an exec plugin Action from a nested Spec `on.fail` field, so we simply separate out the Action bit from the Spec in the exec plugin here. Signed-off-by: Jay Pipes <[email protected]>
1 parent 0d8a00e commit 91a95e6

File tree

3 files changed

+25
-12
lines changed

3 files changed

+25
-12
lines changed

plugin/exec/action.go

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// Use and distribution licensed under the Apache license version 2.
2+
//
3+
// See the COPYING file in the root project directory for full text.
4+
5+
package exec
6+
7+
// Action describes a single execution of one or more commands via the
8+
// operating system's `exec` family of functions.
9+
type Action struct {
10+
// Exec is the exact command to execute.
11+
//
12+
// You may execute more than one command but must include the `shell` field
13+
// to indicate that the command should be run in a shell. It is best
14+
// practice, however, to simply use multiple `exec` specs instead of
15+
// executing multiple commands in a single shell call.
16+
Exec string `yaml:"exec"`
17+
// Shell is the specific shell to use in executing the command. If empty
18+
// (the default), no shell is used to execute the command and instead the
19+
// operating system's `exec` family of calls is used.
20+
Shell string `yaml:"shell,omitempty"`
21+
}

plugin/exec/parse_test.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,9 @@ func TestSimpleCommand(t *testing.T) {
5757
Index: 0,
5858
Defaults: &gdttypes.Defaults{},
5959
},
60-
Exec: "ls",
60+
Action: gdtexec.Action{
61+
Exec: "ls",
62+
},
6163
},
6264
}
6365
assert.Equal(expTests, s.Tests)

plugin/exec/spec.go

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,7 @@ import (
1212
// operating system's `exec` family of functions.
1313
type Spec struct {
1414
gdttypes.Spec
15-
// Exec is the exact command to execute.
16-
//
17-
// You may execute more than one command but must include the `shell` field
18-
// to indicate that the command should be run in a shell. It is best
19-
// practice, however, to simply use multiple `exec` specs instead of
20-
// executing multiple commands in a single shell call.
21-
Exec string `yaml:"exec"`
22-
// Shell is the specific shell to use in executing the command. If empty
23-
// (the default), no shell is used to execute the command and instead the
24-
// operating system's `exec` family of calls is used.
25-
Shell string `yaml:"shell,omitempty"`
15+
Action
2616
// Assert is an object containing the conditions that the Spec will assert.
2717
Assert *Expect `yaml:"assert,omitempty"`
2818
}

0 commit comments

Comments
 (0)