Merge pull request #767 from hashicorp/f-generate-enum

helper/schema: generate strings for ValueType
This commit is contained in:
Mitchell Hashimoto 2015-01-10 15:55:10 -08:00
commit e61077af1f
3 changed files with 29 additions and 7 deletions

View File

@ -2,26 +2,27 @@ TEST?=./...
default: test
bin: config/y.go
bin: config/y.go generate
@sh -c "'$(CURDIR)/scripts/build.sh'"
dev: config/y.go
dev: config/y.go generate
@TF_DEV=1 sh -c "'$(CURDIR)/scripts/build.sh'"
test: config/y.go
test: config/y.go generate
TF_ACC= go test $(TEST) $(TESTARGS) -timeout=10s -parallel=4
testacc: config/y.go
testacc: config/y.go generate
@if [ "$(TEST)" = "./..." ]; then \
echo "ERROR: Set TEST to a specific package"; \
exit 1; \
fi
TF_ACC=1 go test $(TEST) -v $(TESTARGS) -timeout 45m
testrace: config/y.go
testrace: config/y.go generate
TF_ACC= go test -race $(TEST) $(TESTARGS)
updatedeps: config/y.go
go get -u golang.org/x/tools/cmd/stringer
# Go 1.4 changed the format of `go get` a bit by requiring the
# canonical full path. We work around this and just force.
@if [ $(shell go version | cut -f3 -d" " | cut -f2 -d.) -lt 4 ]; then \
@ -37,4 +38,7 @@ config/y.go: config/expr.y
clean:
rm config/y.go
.PHONY: bin clean default test updatedeps
generate:
go generate ./...
.PHONY: bin clean default generate test updatedeps

View File

@ -11,6 +11,8 @@
// A good starting point is to view the Provider structure.
package schema
//go:generate stringer -type=ValueType
import (
"fmt"
"reflect"
@ -56,7 +58,7 @@ func (t ValueType) Zero() interface{} {
case typeObject:
return map[string]interface{}{}
default:
panic(fmt.Sprintf("unknown type %#v", t))
panic(fmt.Sprintf("unknown type %s", t))
}
}

View File

@ -0,0 +1,16 @@
// generated by stringer -type=ValueType; DO NOT EDIT
package schema
import "fmt"
const _ValueType_name = "TypeInvalidTypeBoolTypeIntTypeStringTypeListTypeMapTypeSettypeObject"
var _ValueType_index = [...]uint8{0, 11, 19, 26, 36, 44, 51, 58, 68}
func (i ValueType) String() string {
if i < 0 || i+1 >= ValueType(len(_ValueType_index)) {
return fmt.Sprintf("ValueType(%d)", i)
}
return _ValueType_name[_ValueType_index[i]:_ValueType_index[i+1]]
}