Coder Social home page Coder Social logo

pre-commit-packer's Introduction

pre-commit-packer

GitHub Build Status

This is a set of pre-commit hooks intended for projects using Packer.

Available Hooks

Hook name Description
packer_validate Validate all Packer templates.
packer_fmt Check that Packer HCL templates are properly formatted.

Usage

repos:
  - repo: https://github.com/cisagov/pre-commit-packer
    rev: v0.0.2
    hooks:
      - id: packer_validate
        args:
          - manual_file_entry
      - id: packer_fmt

Notes about the packer_validate hook

This hook matches any paths ending in packer.json and .pkr.hcl by default. File paths can be added for checking manually as additional arguments.

Contributing

We welcome contributions! Please see CONTRIBUTING.md for details.

License

This project is in the worldwide public domain.

This project is in the public domain within the United States, and copyright and related rights in the work worldwide are waived through the CC0 1.0 Universal public domain dedication.

All contributions to this project will be released under the CC0 dedication. By submitting a pull request, you are agreeing to comply with this waiver of copyright interest.

pre-commit-packer's People

Contributors

arcsector avatar dav3r avatar dependabot[bot] avatar felddy avatar hillaryj avatar jasonodoom avatar jmorrowomni avatar jsf9k avatar mcdonnnj avatar michaelsaki avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pre-commit-packer's Issues

Please publish new release

No release in almost a year despite active development.. forcing use of rev: develop in the pre-commit-config.yml, which generates a warning always.

image

Provide argument pass-through to `packer` in the hooks

๐Ÿ’ก Summary

The hooks in this pre-commit configuration should all argument pass-through to the underlying packer call.

Motivation and context

This feature would allow support for modern configurations by allowing pass-through of build variables and/or passing in a pkrvars file.

Acceptance criteria

How do we know when this work is done?

  • Able to pass command line options through to packer in the hook arguments.

packer_fmt says there are no files to check when file exists

๐Ÿ› Summary

When running the packer_fmt hook the message I receive is:
Packer Format........................................(no files to check)Skipped

Even though I have .pkr.hcl file in my repository

To reproduce

Steps to reproduce the behavior:

  1. Create a .pre-commit-config.yml something like this:
repos:
  - repo: https://github.com/pre-commit/pre-commit-hooks
    rev: v4.2.0
    hooks:
      - id: pretty-format-json
        args: ["--autofix", "--no-sort-keys", "--indent=2"]
      - id: fix-byte-order-marker
      - id: check-added-large-files
        args: ["--maxkb=500"]
      - id: check-case-conflict
      - id: check-executables-have-shebangs
      - id: check-symlinks
      - id: check-merge-conflict
      - id: detect-private-key
      - id: detect-aws-credentials
        args: ["--allow-missing-credentials"]
      - id: trailing-whitespace

  - repo: https://github.com/cisagov/pre-commit-packer
    rev: v0.0.2
    hooks:
      - id: packer_validate
      - id: packer_fmt
  1. Create some dummy config file with the .pkr.hcl extension.
packer {
  required_plugins {
    amazon = {
      version = ">= 0.0.2"
      source  = "github.com/hashicorp/amazon"
    }
  }
}

Expected behavior

I should not receive the no files to check message.

Any helpful log output or screenshots

Paste the results here:
When running the command pre-commit run --all-files --color always I get the following output:

pretty format json...................................(no files to check)Skipped
fix utf-8 byte order marker..............................................Passed
check for added large files..............................................Passed
check for case conflicts.................................................Passed
check that executables have shebangs.................(no files to check)Skipped
check for broken symlinks............................(no files to check)Skipped
check for merge conflicts................................................Passed
detect private key.......................................................Passed
detect aws credentials...................................................Passed
trim trailing whitespace.................................................Passed
Packer Validate..........................................................Passed
Packer Format........................................(no files to check)Skipped

Can't go through validate hook with an pkrvars file as input

๐Ÿ’ก Summary

It would be great to allow the args to specify the path to the pkrvars file to be used when validating the packer files

Motivation and context

as of today the basic command with packer works :
packer validate -var-file="inputs/dev.pkrvars.hcl" .

However when using the pre-commit hook validate there is no way to map with the righ pkrvars file.
This would be useful because...

Implementation notes

Please provide details for implementation, such as:

an example would be :

repos:

Acceptance criteria

How do we know when this work is done?

  • Ability to run validate by providing a pkrvars.hcl file as input

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.