diff --git a/scripts/build.sh b/scripts/build.sh index 344e39d69..ef5c1c2e3 100755 --- a/scripts/build.sh +++ b/scripts/build.sh @@ -61,7 +61,7 @@ gox \ -arch="${XC_ARCH}" \ -osarch="${XC_EXCLUDE_OSARCH}" \ -ldflags "${LD_FLAGS}" \ - -output "pkg/{{.OS}}_{{.Arch}}/${PWD##*/}" \ + -output "pkg/{{.OS}}_{{.Arch}}/terraform" \ . # Move all the compiled things to the $GOPATH/bin diff --git a/scripts/generate-plugins.go b/scripts/generate-plugins.go index 0859fe5a2..24030bcf6 100644 --- a/scripts/generate-plugins.go +++ b/scripts/generate-plugins.go @@ -19,9 +19,8 @@ import ( const target = "command/internal_plugin_list.go" func main() { - wd, _ := os.Getwd() - if filepath.Base(wd) != "terraform" { - log.Fatalf("This program must be invoked in the terraform project root; in %s", wd) + if isProjectRoot() == false { + log.Fatalf("This program must be invoked in the terraform project root") } //// Collect all of the data we need about plugins we have in the project @@ -80,6 +79,15 @@ func makeProviderMap(items []plugin) string { return output } +func isProjectRoot() bool { + _, err := os.Stat("go.mod") + if os.IsNotExist(err) { + return false + } + + return true +} + // makeProvisionerMap creates a map of provisioners like this: // // "chef": chefprovisioner.Provisioner,