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

Validate command checks for missing parameter values #323

Merged
merged 3 commits into from
Mar 22, 2020

Conversation

orien
Copy link
Member

@orien orien commented Mar 20, 2020

An implementation of the improvement suggested in #189.

There is some custom code in the apply command that checks for parameters with no values. If blank parameters are found, it aborts the process and prints a friendly message.

In this proposal, the code has been extracted to a separate class, ParameterValidator and the validate command modified to use this check. It prints out the same helpful message if it finds this issue.

myapp_vpc: invalid
Empty/blank parameters detected. Please provide values for these parameters:
 - ParamOne
 - ParamTwo
Parameters will be read from files matching the following globs:
 - parameters/myapp_vpc.y*ml
 - parameters/us-east-1/myapp_vpc.y*ml

@orien orien linked an issue Mar 20, 2020 that may be closed by this pull request
failed!(message)
end
pv = ParameterValidator.new(stack: @proposed_stack, stack_definition: @stack_definition)
failed!(pv.error_message) if pv.missing_parameters?
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extract this functionality to the new ParameterValidator class.


def missing_parameters?
missing_parameters.any?
end
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extract this functionality to the new ParameterValidator class.

StackMaster.stdout.print "#{@stack_definition.stack_name}: "
template_body = TemplateCompiler.compile(@config, @stack_definition.compiler, @stack_definition.template_dir, @stack_definition.template, compile_time_parameters, @stack_definition.compiler_options)
cf.validate_template(template_body: TemplateUtils.maybe_compressed_template_body(template_body))
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This template compilation logic is duplicated in the Stack class. It all seems to work by just using the Stack class directly via the refactoring in 6af37cb, and it keeps things DRY.

if parameter_validator.missing_parameters?
StackMaster.stdout.puts "invalid\n#{parameter_validator.error_message}"
return false
end
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Validate that all the parameters are provided.

Copy link
Contributor

@petervandoros petervandoros left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! 👍

Copy link
Contributor

@patrobinson patrobinson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice.

@orien orien merged commit 14dc64c into master Mar 22, 2020
@orien orien deleted the validate-checks-for-missing-param-values branch March 22, 2020 23:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

stack_master validate should validate parameters
3 participants