-
Notifications
You must be signed in to change notification settings - Fork 193
Expand file tree
/
Copy pathmakefile
More file actions
74 lines (65 loc) · 3.39 KB
/
makefile
File metadata and controls
74 lines (65 loc) · 3.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
.PHONY: all
all: unified-docs
.PHONY: unified-docs
unified-docs:
@echo "Starting up the unified-docs Docker container"
docker compose --profile unified-docs up
.PHONY: clean
clean:
@echo "Stopping and removing Docker containers and images..."
docker compose --profile unified-docs down --rmi local; \
docker rmi hashicorp/dev-portal --force
@echo "Removing public/content and public/assets directories..."
rm -rf public/content public/assets
.PHONY: help
help:
@echo "Available commands:"
@echo " make : Run the unified-docs Docker container"
@echo " make clean : Stop and remove project Docker containers and images"
@echo " make help : Display this help message"
# The following targets are for code generation for packer partials
# In order to run these targets, go must be installed and your GOPATH must be set up
# to point to the correct directory. For example, I ran the following to set up the correct path:
# export PATH=$PATH:/Users/user.name/go/bin
# Your go path may be different depending on your OS and go installation method
# After setting up your go path, you can run the following command to generate partials docs:
# make generate
.PHONY: install-gen-deps
install-gen-deps: ## Install dependencies for code generation
@GO111MODULE=on go install github.com/dmarkham/enumer@master
@go install github.com/hashicorp/packer-plugin-sdk/cmd/packer-sdc@latest
# Environment variables for packer cloning:
# PACKER_REPO: Repository URL or local directory path
# Default: https://github.com/hashicorp/packer
# Example (local): PACKER_REPO=/path/to/local/packer
# Note: Local paths will copy all files including uncommitted changes
# PACKER_BRANCH: Branch name to clone (only used for remote repos)
# Default: main
# Example: PACKER_BRANCH=feature-branch
PACKER_REPO ?= https://github.com/hashicorp/packer
PACKER_BRANCH ?= main
.PHONY: clone-packer
clone-packer: ## Clone the Packer repository for code generation
rm -rf .content-source-repos/packer
@echo "==> Cloning Packer repository from $(PACKER_REPO)..."
@if echo "$(PACKER_REPO)" | grep -qE "^https://|^git@|^ssh://"; then \
echo "Cloning from remote repository (branch: $(PACKER_BRANCH))..."; \
git clone --depth=1 --filter=blob:none --branch=$(PACKER_BRANCH) $(PACKER_REPO) .content-source-repos/packer; \
else \
echo "Copying from local directory (includes uncommitted changes)..."; \
cp -r $(PACKER_REPO) .content-source-repos/packer; \
fi
@echo "Packer repository cloned into .content-source-repos/packer"
.PHONY: generate
generate: install-gen-deps clone-packer ## Generate dynamically generated code
@echo "==> removing autogenerated code..."
@find .content-source-repos/packer/post-processor .content-source-repos/packer/helper .content-source-repos/packer/builder .content-source-repos/packer/provisioner -type f | xargs grep -l '^// Code generated' | xargs rm -f
cd .content-source-repos/packer; PROJECT_ROOT="$(shell pwd)" go generate $(shell cd .content-source-repos/packer; go list ./... | grep -v packer-plugin-sdk)
.PHONY: generate-check
generate-check: generate ## Check go code generation is on par
@echo "==> Checking that auto-generated code is not changed..."
@git diff --exit-code; if [ $$? -eq 1 ]; then \
echo "Found diffs in go generated code."; \
echo "You can use the command: \`make generate\` to reformat code."; \
exit 1; \
fi