Skip to content

Commit

Permalink
use the new multi-component server
Browse files Browse the repository at this point in the history
  • Loading branch information
ShiChangkuo committed Apr 25, 2021
1 parent 3ca9ec3 commit efb6afb
Show file tree
Hide file tree
Showing 3 changed files with 77 additions and 62 deletions.
53 changes: 53 additions & 0 deletions GNUmakefile
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/"
57 changes: 0 additions & 57 deletions Makefile

This file was deleted.

29 changes: 24 additions & 5 deletions main.go
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()
}

0 comments on commit efb6afb

Please sign in to comment.