Skip to content

Commit

Permalink
Merge pull request #570 from dgageot/strict-yaml
Browse files Browse the repository at this point in the history
Strict YAML parsing.
  • Loading branch information
dgageot authored May 21, 2018
2 parents 9e04271 + 3672849 commit 86d4cef
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
18 changes: 9 additions & 9 deletions pkg/skaffold/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ build:
artifacts:
- imageName: example
deploy:
name: example
kubectl: {}
`
completeConfig = `
apiVersion: skaffold/v1alpha2
Expand All @@ -58,7 +58,7 @@ build:
googleCloudBuild:
projectId: ID
deploy:
name: example
kubectl: {}
`
badConfig = "bad config"
)
Expand Down Expand Up @@ -88,7 +88,7 @@ func TestParseConfig(t *testing.T) {
withTagPolicy(v1alpha2.TagPolicy{GitTagger: &v1alpha2.GitTagger{}}),
withDockerArtifact("example", ".", "Dockerfile"),
),
withDeploy(),
withKubectlDeploy(),
),
},
{
Expand All @@ -100,7 +100,7 @@ func TestParseConfig(t *testing.T) {
withDockerArtifact("image1", "./examples/app1", "Dockerfile.dev"),
withBazelArtifact("image2", "./examples/app2", "//:example.tar"),
),
withDeploy(),
withKubectlDeploy(),
),
},
{
Expand Down Expand Up @@ -146,13 +146,13 @@ func withGCBBuild(id string, ops ...func(*v1alpha2.BuildConfig)) func(*SkaffoldC
}
}

func withDeploy(ops ...func(*v1alpha2.DeployConfig)) func(*SkaffoldConfig) {
func withKubectlDeploy() func(*SkaffoldConfig) {
return func(cfg *SkaffoldConfig) {
d := v1alpha2.DeployConfig{}
for _, op := range ops {
op(&d)
cfg.Deploy = v1alpha2.DeployConfig{
DeployType: v1alpha2.DeployType{
KubectlDeploy: &v1alpha2.KubectlDeploy{},
},
}
cfg.Deploy = d
}
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/skaffold/schema/v1alpha1/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ func (config *SkaffoldConfig) Parse(contents []byte, useDefault bool) error {
*config = SkaffoldConfig{}
}

return yaml.Unmarshal(contents, config)
return yaml.UnmarshalStrict(contents, config)
}

func (config *SkaffoldConfig) getDefaultForMode(dev bool) *SkaffoldConfig {
Expand Down
2 changes: 1 addition & 1 deletion pkg/skaffold/schema/v1alpha2/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ type BazelArtifact struct {

// Parse reads a SkaffoldConfig from yaml.
func (c *SkaffoldConfig) Parse(contents []byte, useDefaults bool) error {
if err := yaml.Unmarshal(contents, c); err != nil {
if err := yaml.UnmarshalStrict(contents, c); err != nil {
return err
}

Expand Down

0 comments on commit 86d4cef

Please sign in to comment.