Skip to content

Commit

Permalink
Emit plugin version number to debug output
Browse files Browse the repository at this point in the history
* printed in all verbose terraform execution `TF_LOG=DEBUG terraform apply`
* printed when running `terraform-provider-baremetal` plugin directly
  • Loading branch information
ccushing authored and codycushing committed May 20, 2017
1 parent c9d8d56 commit 5261c42
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 2 deletions.
10 changes: 8 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,13 @@ test_acceptance:
build:
go build -o terraform-provider-baremetal

cross: test_acceptance
version:
sed -i '' -e 's/version = ".*"/version = "\
$(shell curl -s https://api.github.com/repos/oracle/terraform-provider-baremetal/releases/latest | \
jq -r '.tag_name')\
"/g' version.go

release: version test_acceptance
gox -output "./bin/{{.OS}}_{{.Arch}}/terraform-provider-baremetal"

zip:
Expand All @@ -32,4 +38,4 @@ zip:
&& tar -czvf linux.tar.gz linux_386 linux_amd64 linux_arm \
&& tar -czvf openbsd.tar.gz openbsd_386 openbsd_amd64

.PHONY: clean fmt build cross test test_unit zip
.PHONY: clean fmt build release test test_unit zip version
2 changes: 2 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import (
)

func main() {
printVersion()

plugin.Serve(&plugin.ServeOpts{
ProviderFunc: func() terraform.ResourceProvider {
return Provider(providerConfig)
Expand Down
18 changes: 18 additions & 0 deletions version.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package main

import (
"log"
"strconv"
"strings"
)

// Current public release available on github, overwritten as build step, do not alter, see Makefile
const version = "v0.0.0"

func printVersion() {
// increment build number programatically since this will be the next public release
strs := strings.Split(version, ".")
build, _ := strconv.ParseInt(strs[2], 10, 64)
strs[2] = strconv.FormatInt(build+1, 10)
log.Printf("[INFO] terraform-provider-baremetal %s\n", strings.Join(strs, "."))
}

0 comments on commit 5261c42

Please sign in to comment.