From 8ea6eb1cc335afeb4eae129d92d77d261e7173d0 Mon Sep 17 00:00:00 2001 From: Brad Rydzewski Date: Thu, 30 May 2019 08:14:47 -0700 Subject: [PATCH] fix for issue #42 --- CHANGELOG.md | 6 ++++++ yaml/parse.go | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index c8adcf7..3e432b6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,10 +5,16 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## [Unreleased] +### Added + +### Fixed + +## [1.1.0] - 2019-05-30 ### Fixed - Support for yaml merge keys, by [@bradrydzewski](https://github.com/bradrydzewski). - Improve how colon characters are escaped, by [@bradrydzewski](https://github.com/bradrydzewski). Issue [#45](https://github.com/drone/drone-yaml/issues/45). - Improve how pipe and caret characters are escaped, by [@bradrydzewski](https://github.com/bradrydzewski). Issue [#44](https://github.com/drone/drone-yaml/issues/44). +- Error when empty document or missing kind attribute, by [@bradrydzewski](https://github.com/bradrydzewski). Issue [#42](https://github.com/drone/drone-yaml/issues/42). ## [1.0.9] - 2019-05-20 ### Added diff --git a/yaml/parse.go b/yaml/parse.go index 82ff09a..522ff79 100644 --- a/yaml/parse.go +++ b/yaml/parse.go @@ -17,6 +17,7 @@ package yaml import ( "bufio" "bytes" + "errors" "io" "os" "strings" @@ -24,6 +25,8 @@ import ( "github.com/buildkite/yaml" ) +var errorMissingKind = errors.New("yaml: missing kind attribute") + // Parse parses the configuration from io.Reader r. func Parse(r io.Reader) (*Manifest, error) { resources, err := ParseRaw(r) @@ -39,6 +42,9 @@ func Parse(r io.Reader) (*Manifest, error) { if err != nil { return nil, err } + if resource.GetKind() == "" { + return nil, errorMissingKind + } manifest.Resources = append( manifest.Resources, resource,