Skip to content

Commit

Permalink
Merge pull request #13 from vdice/feat/impl-suppress-output
Browse files Browse the repository at this point in the history
feat(action.go): implement SuppressesOutput interface
  • Loading branch information
vdice authored Mar 31, 2020
2 parents 466fb4f + 973c05b commit 239e604
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 6 deletions.
18 changes: 12 additions & 6 deletions pkg/gcloud/action.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,16 @@ type Step struct {

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

type Instruction struct {
Description string `yaml:"description"`
Groups Groups `yaml:"groups"`
Command string `yaml:"command"`
Arguments []string `yaml:"arguments,omitempty"`
Flags builder.Flags `yaml:"flags,omitempty"`
Outputs []Output `yaml:"outputs,omitempty"`
Description string `yaml:"description"`
Groups Groups `yaml:"groups"`
Command string `yaml:"command"`
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 @@ -97,6 +99,10 @@ func (s Step) GetOutputs() []builder.Output {
return outputs
}

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

type Groups []string

func (groups *Groups) UnmarshalYAML(unmarshal func(interface{}) error) error {
Expand Down
17 changes: 17 additions & 0 deletions pkg/gcloud/action_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ func TestMixin_UnmarshalInstallAction(t *testing.T) {
assert.Equal(t, builder.Flags{
builder.NewFlag("ssh-config-file", "./gce-ssh-config"),
builder.NewFlag("ssh-key-file", "./gce-ssh-key")}, step.Flags)

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

func TestMixin_UnmarshalUpgradeAction(t *testing.T) {
Expand Down Expand Up @@ -131,3 +134,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/gcloud/testdata/step-input-suppress-output.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
action:
- gcloud:
description: "Supressed Surprise"
arguments:
- "surprise"
- "me"
suppress-output: true

0 comments on commit 239e604

Please sign in to comment.