Skip to content

Commit

Permalink
Merge pull request #36 from buildkite/add-back-prefered-runtime-env-w…
Browse files Browse the repository at this point in the history
…ith-option

Add back preferred runtime env with option
  • Loading branch information
patrobinson authored Apr 26, 2024
2 parents c34b985 + e678690 commit 9839142
Showing 5 changed files with 157 additions and 150 deletions.
13 changes: 4 additions & 9 deletions interpolate_test.go
Original file line number Diff line number Diff line change
@@ -5,7 +5,6 @@ import (

"github.com/buildkite/go-pipeline/internal/env"
"github.com/buildkite/go-pipeline/ordered"
"github.com/google/go-cmp/cmp"
"gotest.tools/v3/assert"
)

@@ -264,15 +263,11 @@ func TestInterpolator(t *testing.T) {
t.Parallel()

runtimeEnv := env.New(env.CaseSensitive(tc.caseSensitive), env.FromMap(tc.runtimeEnv))
err := tc.input.Interpolate(runtimeEnv)
err := tc.input.Interpolate(runtimeEnv, false)
assert.NilError(t, err)
assert.DeepEqual(
t,
tc.input,
tc.expected,
cmp.Comparer(ordered.EqualSA),
cmp.Comparer(ordered.EqualSS),
)
if diff := diffPipeline(tc.input, tc.expected); diff != "" {
t.Errorf("parsed pipeline diff (-got +want):\n%s", diff)
}
})
}
}
4 changes: 4 additions & 0 deletions parser.go
Original file line number Diff line number Diff line change
@@ -9,6 +9,9 @@ import (
"gopkg.in/yaml.v3"
)

// Options are functional options for creating a new Env.
type Options func(*Pipeline)

// Parse parses a pipeline. It does not apply interpolation.
// Warnings are passed through the err return:
//
@@ -35,6 +38,7 @@ func Parse(src io.Reader) (*Pipeline, error) {
// with when handling different structural representations of the same
// configuration. Then decode _that_ into a pipeline.
p := new(Pipeline)

return p, ordered.Unmarshal(n, p)
}

4 changes: 2 additions & 2 deletions parser_matrix_test.go
Original file line number Diff line number Diff line change
@@ -438,10 +438,10 @@ steps:
if err != nil {
t.Fatalf("Parse(%q) error = %v", test.input, err)
}
if err := got.Interpolate(nil); err != nil {
if err := got.Interpolate(nil, false); err != nil {
t.Fatalf("Pipeline.Interpolate(nil) = %v", err)
}
if diff := cmp.Diff(got, test.want, cmp.Comparer(ordered.EqualSS)); diff != "" {
if diff := diffPipeline(got, test.want); diff != "" {
t.Errorf("parsed pipeline diff (-got +want):\n%s", diff)
}
gotJSON, err := json.MarshalIndent(got, "", " ")
Loading

0 comments on commit 9839142

Please sign in to comment.