Skip to content

Commit bad2bf2

Browse files
add staticcheck
1 parent 7dee288 commit bad2bf2

File tree

5 files changed

+32
-12
lines changed

5 files changed

+32
-12
lines changed

GNUmakefile

+24-11
Original file line numberDiff line numberDiff line change
@@ -5,37 +5,50 @@ HASHICORP_PACKER_PLUGIN_SDK_VERSION?=$(shell go list -m github.com/hashicorp/pac
55
COUNT?=1
66
TEST?=$(shell go list ./...)
77

8-
.PHONY: dev
8+
prep: phony
9+
go install honnef.co/go/tools/cmd/staticcheck@latest
910

10-
build:
11+
build: phony
1112
@go build -o ${BINARY}
1213

13-
dev: build
14+
dev: phony build
1415
@mkdir -p ~/.packer.d/plugins/
1516
@mv ${BINARY} ~/.packer.d/plugins/${BINARY}
1617

17-
run-example: dev
18+
run-example: phony dev
1819
@packer build ./example
1920

20-
test:
21-
@go test -race -count $(COUNT) $(TEST) -timeout=3m
21+
test: phony
22+
go mod tidy
23+
go fmt ./...
24+
go vet ./...
25+
staticcheck -checks="all" -tests ./...
26+
go test -race -count $(COUNT) $(TEST) -timeout=3m
2227

2328
# the acceptance tests have a weird habit of messing up the tty (e.g. turning off echo mode, so
2429
# terminal stops showing what you type). If this happens to you, run `reset` or `stty sane` to fix.
25-
testacc: dev
30+
testacc: phony dev
2631
@PACKER_ACC=1 go test -count $(COUNT) -v $(TEST) -timeout=120m
2732

28-
install-packer-sdc: ## Install packer software development command
33+
install-packer-sdc: phony ## Install packer software development command
2934
@go install github.com/hashicorp/packer-plugin-sdk/cmd/packer-sdc@${HASHICORP_PACKER_PLUGIN_SDK_VERSION}
3035

31-
ci-release-docs: install-packer-sdc
36+
ci-release-docs: phony install-packer-sdc
3237
@packer-sdc renderdocs -src docs -partials docs-partials/ -dst docs/
3338
@/bin/sh -c "[ -d docs ] && zip -r docs.zip docs/"
3439

35-
plugin-check: install-packer-sdc build
40+
plugin-check: phony install-packer-sdc build
3641
@packer-sdc plugin-check ${BINARY}
3742

38-
generate: install-packer-sdc
43+
generate: phony install-packer-sdc
3944
@go generate -v ./...
4045
packer-sdc renderdocs -src ./docs -dst ./.docs -partials ./docs-partials
4146
# see the .docs folder for a preview of the docs
47+
48+
# instead of listing every target in .PHONY, we create one
49+
# 'phony' target which all the other targets depend on.
50+
# This saves me from having to remember to add each new target
51+
# to the .PHONY list, and is a little cleaner than putting
52+
# `.PHONY: target` before each target
53+
.PHONY: phony
54+
phony:

common/common.go

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// Package common contains some logic that is shared by all datasources
12
package common
23

34
import (

datasource/commit/data.go

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// Package commit contains logic for providing commit data to Packer
2+
//
13
//go:generate packer-sdc mapstructure-to-hcl2 -type Config,DatasourceOutput
24
package commit
35

datasource/repository/data.go

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// Package repository contains logic for providing repo data to Packer
2+
//
13
//go:generate packer-sdc mapstructure-to-hcl2 -type Config,DatasourceOutput
24
package repository
35

@@ -93,7 +95,7 @@ func (d *Datasource) Execute() (cty.Value, error) {
9395
log.Printf("output.Head: '%s'\n", output.Head)
9496

9597
output.IsClean = status.IsClean()
96-
log.Printf("output.IsClean: '%s'\n", output.IsClean)
98+
log.Printf("output.IsClean: '%t'\n", output.IsClean)
9799

98100
output.Branches = make([]string, 0)
99101
_ = branchIter.ForEach(func(reference *plumbing.Reference) error {

datasource/tree/data.go

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// Package tree contains logic for providing working tree data to Packer
2+
//
13
//go:generate packer-sdc mapstructure-to-hcl2 -type Config,DatasourceOutput
24
package tree
35

0 commit comments

Comments
 (0)