build: Allow building on non-terraform named directory (#25340)
* Allow building on non-terraform named directory * Fix gofmt errors * Fix generate-plugins.go unused variable error
This commit is contained in:
parent
81b83763e9
commit
0b3c0f64c2
|
@ -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
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Reference in New Issue