Skip to content

ethanmdavidson/packer-plugin-git

Folders and files

NameName
Last commit message
Last commit date
Apr 1, 2025
Mar 1, 2024
Apr 8, 2023
Jan 2, 2024
Mar 1, 2024
Jan 2, 2024
Feb 16, 2022
Mar 3, 2022
Mar 1, 2025
Jun 30, 2024
Nov 12, 2021
Mar 1, 2025
Mar 13, 2025
Mar 13, 2025
Mar 1, 2025

Repository files navigation

Git Packer Plugin

tests

A plugin for Packer which provides access to git. Compatible with Packer >= 1.7.0

Under the hood, it uses go-git.

Usage

Add the plugin to your packer config:

packer {
  required_plugins {
    git = {
      version = ">= 0.6.4"
      source  = "github.com/ethanmdavidson/git"
    }
  }
}

Add the data source:

data "git-commit" "example" { }

Now you should have access to info about the commit:

locals {
  hash = data.git-commit.example.hash
}

Examples

See the examples directory for some example code.

Components

See the docs for a reference of all the available components and their attributes.

Development

The GNUmakefile has all the commands you need to work with this repo. The typical development flow looks something like this:

  1. Make code changes, and add test cases for these changes.
  2. Run make generate to recreate generated code.
  3. Run make dev to build the plugin and install it locally.
  4. Run make testacc to run the acceptance tests. If there are failures, go back to step 1.
  5. Update examples in ./example directory if necessary.
  6. Run make run-example to test examples.
  7. Once the above steps are complete: commit, push, and open a PR!

For local development, you will need to install:

Check out the Packer docs on Developing Plugins for more detailed info on plugins.