Giter VIP home page Giter VIP logo

puppet-git-hooks's Introduction

puppet-git-hooks

Git hooks to assist puppet module development. Client side hooks allow for various checks before commits are staged. Server side hooks are provided for infrastructural reinforcement of various standardization compliances.

Current supported pre-commit (client side) checks

  • Puppet manifest syntax
  • Puppet epp template syntax
  • Erb template syntax
  • Puppet-lint
  • Rspec-puppet
  • Yaml (hiera data) syntax
  • r10k puppetfile syntax

Current supported pre-receive (server side) checks

  • Puppet manifest syntax
  • Puppet epp template syntax
  • Erb template syntax
  • Ruby syntax
  • Puppet-lint
  • Yaml (hiera data) syntax

Installing dependencies

You can install all required dependencies with bundler. List of dependencies you will find in Gemfile. By default it installs puppet in version 3.8.6, if you wish, change it to one, which you use. To install run bundler inside your checkout:

bundle install

Usage

In your git repository you can symlink the pre-commit file from this repository to the .git/hooks/pre-commit of your repository you want to implement this feature.

$ ln -s /path/to/this/repo/puppet-git-hooks/pre-commit .git/hooks/pre-commit

If you are using git submodules this can be achieved by getting the gitdir from the .git file in your submodule and symlinking to that gitdir location/

$ cat .git
$ ln -s /path/to/this/repo/puppet-git-hooks/pre-commit ../path/to/git/dir/from/previous/command/hooks/pre-commit

deploy-git-hook

usage: deploy-git-hook -d /path/to/git/repository [-a] [-c] [-r] [-u]

-h            this help screen
-d path       install the hooks to the specified path
-a            deploy pre-commit and pre-receive hooks
-c            deploy only the pre-commit hook
-r            deploy only the pre-receive hook
-u            deploy only the post-update hook
-g            enable to install in Git Lab repo custom_hooks

returns status code of 0 for success, otherwise, failure

examples:

  1. to install pre-commit and pre-receive the hooks to foo git repo:
deploy-git-hook -d /path/to/foo -a
  1. to install only the pre-commit hook to bar git repo:
deploy-git-hook -d /path/to/bar -c
  1. to install only the pre-commit and pre-receive hook to foobar git repo:
deploy-git-hook -d /path/to/foobar -c -r

In a wrapper

You can call from your own custom pre-commit. This allows you to combine these with your own checks.

For example, if you've cloned this repo to ~/.puppet-git-hooks

The .git/hooks/pre-commit with your puppet code might look like this:

#!/bin/bash

# my_other_checks

# puppet-git-hooks
if [ -e ~/.puppet-git-hooks/pre-commit ]; then
~/.puppet-git-hooks/pre-commit
fi

Additionally you can call pre-commit script with two options -s and -a. First one silence standard informations, which file is currently being checked. Second one allow you to check whole repo, not only files changed locally.

Configuration

You can set configuration options in commit_hooks/config.cfg This file is sourced by the pre-commit/receive hooks.

Current options:

  • CHECK_PUPPET_LINT
  • USE_PUPPET_FUTURE_PARSER (only used by Puppet < 4)
  • CHECK_INITIAL_COMMIT
  • CHECK_RSPEC
  • PUPPET_LINT_OPTIONS
  • PUPPET_LINT_FAIL_ON_WARNINGS
  • UNSET_RUBY_ENV (for GitLab users)

Maintainers

We are still looking for additional maintainers. Please contact me via github issue if you are interested in helping maintain this project. Thank you!

puppet-git-hooks's People

Contributors

b4ldr avatar drwahl avatar fridim avatar frozenfoxx avatar garethhumphriesig avatar garethhumphriesworldpay avatar jayhenry1 avatar jcpunk avatar jhg03a avatar jschlyter avatar juasiepo avatar kasimon avatar klaas- avatar krzyzakp avatar mark0n avatar mc0e avatar mikemarseglia avatar millnert avatar mrjoshuap avatar natemccurdy avatar nmoura avatar pseiler avatar raskil avatar rgevaert avatar smbambling avatar ttarczynski avatar urielka avatar visibilityspots avatar zdenekjanda avatar

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.