forked from huaweicloud/packer-plugin-huaweicloud
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3ca9ec3
commit efb6afb
Showing
3 changed files
with
77 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
NAME=huaweicloud | ||
BINARY=packer-plugin-${NAME} | ||
PLUGIN_DIR = ~/.packer.d/plugins | ||
PLUGIN_FILE = ${PLUGIN_DIR}/${BINARY} | ||
|
||
COUNT?=1 | ||
TEST?=$(shell go list ./...) | ||
|
||
.PHONY: install | ||
|
||
build: | ||
go build -o ${BINARY} | ||
|
||
install: build | ||
@mkdir -p ${PLUGIN_DIR} | ||
mv ${BINARY} ${PLUGIN_FILE} | ||
|
||
run-example: install | ||
@packer build ./example | ||
|
||
vet: | ||
@echo "go vet ." | ||
@go vet $$(go list ./...) ; if [ $$? -eq 1 ]; then \ | ||
echo ""; \ | ||
echo "Vet found suspicious constructs. Please check the reported constructs"; \ | ||
echo "and fix them if necessary before submitting the code for review."; \ | ||
exit 1; \ | ||
fi | ||
|
||
test: | ||
go test -v -count $(COUNT) $(TEST) -timeout=3m | ||
|
||
testacc: install | ||
@PACKER_ACC=1 go test -count $(COUNT) -v $(TEST) -timeout=120m | ||
|
||
.PHONY: clean | ||
clean: | ||
rm -rf ${BINARY} ${PLUGIN_FILE} | ||
|
||
install-gen-deps: ## Install dependencies for code generation | ||
# @go install github.com/hashicorp/packer-plugin-sdk/cmd/packer-sdc | ||
|
||
generate: ## install-gen-deps | ||
@echo "==> removing autogenerated markdown..." | ||
@find docs-partials/ -type f | xargs grep -l '^<!-- Code generated' | xargs rm -f | ||
@echo "==> removing autogenerated code..." | ||
@find ./ -type f | xargs grep -l '^// Code generated' | xargs rm -f | ||
PROJECT_ROOT="$(CURDIR)" go generate ./... | ||
|
||
ci-release-docs: | ||
@go install github.com/hashicorp/packer-plugin-sdk/cmd/packer-sdc@8d357e87ab267b7c37c907f6a4f9337b98d46e6d | ||
@packer-sdc renderdocs -src docs -partials docs-partials/ -dst docs/ | ||
@/bin/sh -c "[ -d docs ] && zip -r docs.zip docs/" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,35 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
|
||
"github.com/hashicorp/packer-plugin-sdk/plugin" | ||
"github.com/hashicorp/packer-plugin-sdk/version" | ||
ecsbuilder "github.com/huaweicloud/packer-builder-huaweicloud-ecs/builder/ecs" | ||
) | ||
|
||
var ( | ||
// Version is the main version number that is being run at the moment. | ||
Version = "0.3.0" | ||
|
||
// VersionPrerelease is A pre-release marker for the Version. If this is "" | ||
// (empty string) then it means that it is a final release. Otherwise, this | ||
// is a pre-release such as "dev" (in development), "beta", "rc1", etc. | ||
VersionPrerelease = "dev" | ||
|
||
// PluginVersion is used by the plugin set to allow Packer to recognize | ||
// what version this plugin is. | ||
PluginVersion = version.InitializePluginVersion(Version, VersionPrerelease) | ||
) | ||
|
||
func main() { | ||
server, err := plugin.Server() | ||
pps := plugin.NewSet() | ||
pps.RegisterBuilder("ecs", new(ecsbuilder.Builder)) | ||
pps.SetVersion(PluginVersion) | ||
err := pps.Run() | ||
if err != nil { | ||
panic(err) | ||
fmt.Fprintln(os.Stderr, err.Error()) | ||
os.Exit(1) | ||
} | ||
|
||
server.RegisterBuilder(new(ecsbuilder.Builder)) | ||
server.Serve() | ||
} |