Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Strict YAML parsing. #570

Merged
merged 1 commit into from
May 21, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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