Skip to content

Commit

Permalink
Makefile: make dev uses packer for install
Browse files Browse the repository at this point in the history
When building the development version of the plugin, we now use
`packer plugins install` for that instead of moving it to the plugins
directory manually.

This target will require Packer 1.10.2 and above to function, as prior
versions don't support instaling pre-release versions of a plugin with
that command.
  • Loading branch information
lbajolet-hashicorp committed Mar 26, 2024
1 parent 869da13 commit c9e93b7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
8 changes: 3 additions & 5 deletions .github/workflows/test-plugin-e2e.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ jobs:
- name: Build packer plugin
run: |
cd $GITHUB_WORKSPACE
make dev
make build
- uses: actions/upload-artifact@v4
with:
name: packer-plugin-nutanix
path: ~/.config/packer/plugins/packer-plugin-nutanix
path: packer-plugin-nutanix
retention-days: 7

- name: build test list
Expand Down Expand Up @@ -72,9 +72,7 @@ jobs:

- name: Install plugin
run: |
mkdir -p ~/.config/packer/plugins/
cp /tmp/packer-plugin-nutanix ~/.config/packer/plugins/packer-plugin-nutanix
chmod 755 ~/.config/packer/plugins/packer-plugin-nutanix
packer plugins install --path /tmp/packer-plugin-nutanix "github.com/nutanix-cloud-native/nutanix"
- name: Run `packer init`
id: init
Expand Down
7 changes: 4 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
NAME=nutanix
BINARY=packer-plugin-${NAME}
PLUGIN_FQN="$(shell grep -E '^module' <go.mod | sed -E 's/module *//')"

COUNT?=1
TEST?=$(shell go list ./...)
Expand All @@ -10,9 +11,9 @@ HASHICORP_PACKER_PLUGIN_SDK_VERSION?=$(shell go list -m github.com/hashicorp/pac
build:
@go build -o ${BINARY}

dev: build
@mkdir -p ~/.config/packer/plugins
@mv ${BINARY} ~/.config/packer/plugins/${BINARY}
dev:
@go build -ldflags="-X '${PLUGIN_FQN}/version.VersionPrerelease=dev'" -o '${BINARY}'
packer plugins install --path ${BINARY} "$(shell echo "${PLUGIN_FQN}" | sed 's/packer-plugin-//')"

test:
@go test -race -count $(COUNT) $(TEST) -timeout=3m
Expand Down

0 comments on commit c9e93b7

Please sign in to comment.