Skip to content

Commit

Permalink
Merge pull request #16 from vdice/feat/impl-suppress-output
Browse files Browse the repository at this point in the history
feat(action.go): implement the SuppressesOutput interface
  • Loading branch information
vdice committed Mar 31, 2020
2 parents ac386ff + c7aaaad commit 5cb02db
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 6 deletions.
18 changes: 12 additions & 6 deletions pkg/aws/action.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,18 +49,20 @@ func (a Action) GetSteps() []builder.ExecutableStep {

var _ builder.ExecutableStep = Step{}
var _ builder.StepWithOutputs = Step{}
var _ builder.SuppressesOutput = Step{}

type Step struct {
Instruction `yaml:"aws"`
}

type Instruction struct {
Description string `yaml:"description"`
Service string `yaml:"service"`
Operation string `yaml:"operation"`
Arguments []string `yaml:"arguments,omitempty"`
Flags builder.Flags `yaml:"flags,omitempty"`
Outputs []Output `yaml:"outputs,omitempty"`
Description string `yaml:"description"`
Service string `yaml:"service"`
Operation string `yaml:"operation"`
Arguments []string `yaml:"arguments,omitempty"`
Flags builder.Flags `yaml:"flags,omitempty"`
Outputs []Output `yaml:"outputs,omitempty"`
SuppressOutput bool `yaml:"suppress-output,omitempty"`
}

func (s Step) GetCommand() string {
Expand Down Expand Up @@ -93,6 +95,10 @@ func (s Step) GetOutputs() []builder.Output {
return outputs
}

func (s Step) SuppressesOutput() bool {
return s.SuppressOutput
}

var _ builder.OutputJsonPath = Output{}

type Output struct {
Expand Down
17 changes: 17 additions & 0 deletions pkg/aws/action_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ func TestMixin_UnmarshalInstallAction(t *testing.T) {
assert.Equal(t, builder.Flags{
builder.NewFlag("image-id", "ami-xxxxxxxx"),
builder.NewFlag("instance-type", "t2.micro")}, step.Flags)

assert.Equal(t, false, step.SuppressOutput)
assert.Equal(t, false, step.SuppressesOutput())
}

func TestMixin_UnmarshalUpgradeAction(t *testing.T) {
Expand Down Expand Up @@ -142,3 +145,17 @@ func TestMixin_UnmarshalInvalidStep(t *testing.T) {
require.Error(t, err)
assert.Contains(t, err.Error(), "invalid yaml type for flag env")
}

func TestStep_SuppressesOutput(t *testing.T) {
b, err := ioutil.ReadFile("testdata/step-input-suppress-output.yaml")
require.NoError(t, err)

var action Action
err = yaml.Unmarshal(b, &action)
require.NoError(t, err)
require.Len(t, action.Steps, 1)

step := action.Steps[0]
assert.Equal(t, true, step.SuppressOutput)
assert.Equal(t, true, step.SuppressesOutput())
}
7 changes: 7 additions & 0 deletions pkg/aws/testdata/step-input-suppress-output.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
action:
- aws:
description: "Supressed Surprise"
arguments:
- "surprise"
- "me"
suppress-output: true

0 comments on commit 5cb02db

Please sign in to comment.