-
Notifications
You must be signed in to change notification settings - Fork 116
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
Raise an error when 'kind' is missing #280
Conversation
lib/kubernetes-deploy/errors.rb
Outdated
@@ -2,6 +2,7 @@ | |||
module KubernetesDeploy | |||
class FatalDeploymentError < StandardError; end | |||
class KubectlError < StandardError; end | |||
class InvalidResourceError < StandardError; end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should probably use InvalidTemplateError from the PR I just finally rebased and merged. (please rebase 🙏 )
cbe92f2
to
8ccf6e6
Compare
Rebase completed, its a hair different as a result. |
19e0799
to
e4a8db8
Compare
e4a8db8
to
88f4a9f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just minor comments.
@@ -31,7 +31,9 @@ class << self | |||
def build(namespace:, context:, definition:, logger:, statsd_tags:) | |||
opts = { namespace: namespace, context: context, definition: definition, logger: logger, | |||
statsd_tags: statsd_tags } | |||
if KubernetesDeploy.const_defined?(definition["kind"]) | |||
if definition["kind"].blank? | |||
raise InvalidTemplateError.new("Template missing 'Kind'", filename: nil, content: definition.to_s) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since we have a valid case for not requiring filename
now, let's make the default nil in the initializer so you can leave it off here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
assert_logs_match_all([ | ||
"Invalid template: missing_kind.yml", | ||
"> Error message:", | ||
"Template missing 'Kind'" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's add an assertion that proves the content is printed too
CHANGELOG.md
Outdated
@@ -14,6 +14,8 @@ | |||
*Bug Fixes* | |||
- Prevent calling sleep with a negative value ([#273](https://github.com/Shopify/kubernetes-deploy/pull/273)) | |||
- Prevent no-op redeploys of bad code from hanging forever ([#262](https://github.com/Shopify/kubernetes-deploy/pull/262)) | |||
- Display a nice error instead of crashing when a YAML document is missing 'Kind' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This needs to be moved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Currently we crash with a stack dump if a yaml document is missing a
Kind
. This PR prints a nice error instead of crashingFixes: #277