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

"HCL2"-based validate command #17539

Merged
merged 4 commits into from
Mar 13, 2018
Merged

"HCL2"-based validate command #17539

merged 4 commits into from
Mar 13, 2018

Commits on Mar 9, 2018

  1. command/format: include source snippets in diagnostics

    If we get a diagnostic message that references a source range, and if the
    source code for the referenced file is available, we'll show a snippet of
    the source code with the source range highlighted.
    
    At the moment we have no cache of source code, so in practice this
    codepath can never be visited. Callers to format.Diagnostic will be
    gradually updated in subsequent commits.
    apparentlymart committed Mar 9, 2018
    Configuration menu
    Copy the full SHA
    71f2b37 View commit details
    Browse the repository at this point in the history
  2. command: new Meta methods for accessing the new config loader

    We need to share a single config loader across all callers because that
    allows us to maintain the source code cache we'll use for snippets in
    error messages.
    
    Nothing calls this yet. Callers will be gradually updated away from Module
    and Config in subsequent commits.
    apparentlymart committed Mar 9, 2018
    Configuration menu
    Copy the full SHA
    4b033db View commit details
    Browse the repository at this point in the history
  3. command: beginnings of new config loader in "terraform validate"

    As part of some light reorganization of our commands, this new
    implementation no longer does validation of variables and will thus avoid
    the need to spin up a fully-valid context. Instead, its focus is on
    validating the configuration itself, regardless of any variables, state,
    etc.
    
    This change anticipates us later adding a -validate-only flag to
    "terraform plan" which will then take over the related use-case of
    checking if a particular execution of Terraform is valid, _including_ the
    state, variables, etc.
    
    Although leaving variables out of validate feels pretty arbitrary today
    while all of the variable sources are local anyway, we have plans to
    allow per-workspace variables to be stored in the backend in future and
    at that point it will no longer be possible to fully validate variables
    without accessing the backend. The "terraform plan" command explicitly
    requires access to the backend, while "terraform validate" is now
    explicitly for local-only validation of a single module.
    
    In a future commit this will be extended to do basic type checking of
    the configuration based on provider schemas, etc.
    apparentlymart committed Mar 9, 2018
    Configuration menu
    Copy the full SHA
    871afe5 View commit details
    Browse the repository at this point in the history

Commits on Mar 10, 2018

  1. command: "terraform validate" JSON support

    In the long run we'd like to offer machine-readable output for more
    commands, but for now we'll just start with a tactical feature in
    "terraform validate" since this is useful for automated testing scenarios,
    editor integrations, etc, and doesn't include any representations of types
    that are expected to have breaking changes in the near future.
    apparentlymart committed Mar 10, 2018
    Configuration menu
    Copy the full SHA
    cd106a5 View commit details
    Browse the repository at this point in the history