$ go test ./... ? github.com/hashicorp/terraform/internal/backend [no test files] ok github.com/hashicorp/terraform 0.065s ok github.com/hashicorp/terraform/internal/addrs 0.030s ok github.com/hashicorp/terraform/internal/backend/backendbase 0.007s ok github.com/hashicorp/terraform/internal/backend/backendrun 0.009s ok github.com/hashicorp/terraform/internal/backend/init 0.051s ? github.com/hashicorp/terraform/internal/cloudplugin/cloudproto1 [no test files] ? github.com/hashicorp/terraform/internal/cloudplugin/mock_cloudproto1 [no test files] ok github.com/hashicorp/terraform/internal/backend/local 6.211s ok github.com/hashicorp/terraform/internal/backend/remote 4.009s ok github.com/hashicorp/terraform/internal/backend/remote-state/http 7.266s ok github.com/hashicorp/terraform/internal/backend/remote-state/inmem 0.010s ok github.com/hashicorp/terraform/internal/builtin/providers/terraform 0.150s ok github.com/hashicorp/terraform/internal/builtin/provisioners/file 0.008s ok github.com/hashicorp/terraform/internal/builtin/provisioners/local-exec 0.196s ok github.com/hashicorp/terraform/internal/builtin/provisioners/remote-exec 2.050s ok github.com/hashicorp/terraform/internal/checks 0.060s ? github.com/hashicorp/terraform/internal/command/jsonformat/collections [no test files] ? github.com/hashicorp/terraform/internal/command/jsonformat/computed [no test files] ? github.com/hashicorp/terraform/internal/command/jsonformat/jsondiff [no test files] ? github.com/hashicorp/terraform/internal/command/jsonformat/structured [no test files] ? github.com/hashicorp/terraform/internal/command/testing [no test files] ? github.com/hashicorp/terraform/internal/e2e [no test files] ? github.com/hashicorp/terraform/internal/experiments [no test files] ? github.com/hashicorp/terraform/internal/getmodules [no test files] ? github.com/hashicorp/terraform/internal/grpcwrap [no test files] ? github.com/hashicorp/terraform/internal/lang/langrefs [no test files] ? github.com/hashicorp/terraform/internal/lang/marks [no test files] ? github.com/hashicorp/terraform/internal/lang/types [no test files] ? github.com/hashicorp/terraform/internal/modsdir [no test files] ? github.com/hashicorp/terraform/internal/plans/planproto [no test files] ? github.com/hashicorp/terraform/internal/plugin/mock_proto [no test files] ? github.com/hashicorp/terraform/internal/plugin6/mock_proto [no test files] ? github.com/hashicorp/terraform/internal/provider-simple [no test files] ? github.com/hashicorp/terraform/internal/provider-simple/main [no test files] ? github.com/hashicorp/terraform/internal/provider-simple-v6 [no test files] ? github.com/hashicorp/terraform/internal/provider-simple-v6/main [no test files] ? github.com/hashicorp/terraform/internal/provider-terraform/main [no test files] ok github.com/hashicorp/terraform/internal/cloud 36.011s ok github.com/hashicorp/terraform/internal/cloud/cloudplan 0.111s ok github.com/hashicorp/terraform/internal/cloud/e2e 8.538s ok github.com/hashicorp/terraform/internal/cloudplugin 0.239s ok github.com/hashicorp/terraform/internal/cloudplugin/cloudplugin1 0.029s ok github.com/hashicorp/terraform/internal/collections 0.013s ? github.com/hashicorp/terraform/internal/providers/testing [no test files] ? github.com/hashicorp/terraform/internal/provisioner-local-exec/main [no test files] ? github.com/hashicorp/terraform/internal/provisioners [no test files] ? github.com/hashicorp/terraform/internal/registry/test [no test files] ? github.com/hashicorp/terraform/internal/replacefile [no test files] ? github.com/hashicorp/terraform/internal/rpcapi/dynrpcserver [no test files] ? github.com/hashicorp/terraform/internal/rpcapi/dynrpcserver/generator [no test files] ? github.com/hashicorp/terraform/internal/rpcapi/terraform1 [no test files] ? github.com/hashicorp/terraform/internal/stacks/stackconfig/stackconfigtypes [no test files] ? github.com/hashicorp/terraform/internal/stacks/stackconfig/typeexpr [no test files] ? github.com/hashicorp/terraform/internal/schemarepo/loadschemas [no test files] ? github.com/hashicorp/terraform/internal/schemarepo [no test files] ? github.com/hashicorp/terraform/internal/stacks/stackaddrs [no test files] ? github.com/hashicorp/terraform/internal/stacks/stackruntime/hooks [no test files] ? github.com/hashicorp/terraform/internal/stacks/stackruntime/testing [no test files] ? github.com/hashicorp/terraform/internal/stacks/stackutils [no test files] ? github.com/hashicorp/terraform/internal/tfplugin5 [no test files] ? github.com/hashicorp/terraform/internal/tfplugin6 [no test files] ? github.com/hashicorp/terraform/tools/loggraphdiff [no test files] ? github.com/hashicorp/terraform/tools/protobuf-compile [no test files] ok github.com/hashicorp/terraform/internal/command 88.238s ok github.com/hashicorp/terraform/internal/command/arguments 0.014s ok github.com/hashicorp/terraform/internal/command/cliconfig 0.027s ok github.com/hashicorp/terraform/internal/command/clistate 0.010s ok github.com/hashicorp/terraform/internal/command/e2etest 30.692s ok github.com/hashicorp/terraform/internal/command/format 0.010s ok github.com/hashicorp/terraform/internal/command/jsonchecks 0.009s ok github.com/hashicorp/terraform/internal/command/jsonconfig 0.013s ok github.com/hashicorp/terraform/internal/command/jsonformat 0.111s ok github.com/hashicorp/terraform/internal/command/jsonformat/computed/renderers 0.035s ok github.com/hashicorp/terraform/internal/command/jsonformat/differ 0.058s ok github.com/hashicorp/terraform/internal/command/jsonformat/structured/attribute_path 0.014s ok github.com/hashicorp/terraform/internal/command/jsonfunction 0.019s ok github.com/hashicorp/terraform/internal/command/jsonplan 0.028s ok github.com/hashicorp/terraform/internal/command/jsonprovider 0.024s ok github.com/hashicorp/terraform/internal/command/jsonstate 0.036s ok github.com/hashicorp/terraform/internal/command/views 3.473s ok github.com/hashicorp/terraform/internal/command/views/json 0.053s ok github.com/hashicorp/terraform/internal/command/webbrowser 0.016s ok github.com/hashicorp/terraform/internal/command/workdir 0.029s ok github.com/hashicorp/terraform/internal/communicator 1.049s ok github.com/hashicorp/terraform/internal/communicator/remote 0.010s [no tests to run] ok github.com/hashicorp/terraform/internal/communicator/shared 0.005s ok github.com/hashicorp/terraform/internal/communicator/ssh 3.183s ok github.com/hashicorp/terraform/internal/communicator/winrm 0.045s ok github.com/hashicorp/terraform/internal/configs 7.155s ok github.com/hashicorp/terraform/internal/configs/configload 0.888s ok github.com/hashicorp/terraform/internal/configs/configschema 0.038s ok github.com/hashicorp/terraform/internal/configs/configtesting 0.004s ok github.com/hashicorp/terraform/internal/configs/hcl2shim 0.036s ok github.com/hashicorp/terraform/internal/copy 0.012s ok github.com/hashicorp/terraform/internal/dag 2.168s ok github.com/hashicorp/terraform/internal/depsfile 0.214s ok github.com/hashicorp/terraform/internal/didyoumean 0.012s ok github.com/hashicorp/terraform/internal/genconfig 0.051s ok github.com/hashicorp/terraform/internal/getmodules/moduleaddrs 0.063s ok github.com/hashicorp/terraform/internal/getproviders 4.428s ok github.com/hashicorp/terraform/internal/getproviders/providerreqs 0.101s ok github.com/hashicorp/terraform/internal/helper/slowmessage 0.105s ok github.com/hashicorp/terraform/internal/httpclient 0.020s ok github.com/hashicorp/terraform/internal/initwd 0.312s ok github.com/hashicorp/terraform/internal/instances 0.019s ok github.com/hashicorp/terraform/internal/ipaddr 0.026s ok github.com/hashicorp/terraform/internal/lang 0.250s ok github.com/hashicorp/terraform/internal/lang/blocktoattr 0.016s ok github.com/hashicorp/terraform/internal/lang/funcs 0.792s ok github.com/hashicorp/terraform/internal/lang/globalref 0.326s ok github.com/hashicorp/terraform/internal/logging 0.004s ok github.com/hashicorp/terraform/internal/moduledeps 0.021s ok github.com/hashicorp/terraform/internal/moduletest 0.203s ok github.com/hashicorp/terraform/internal/moduletest/config 0.028s ok github.com/hashicorp/terraform/internal/moduletest/hcl 0.045s ok github.com/hashicorp/terraform/internal/moduletest/mocking 0.025s ok github.com/hashicorp/terraform/internal/namedvals 0.010s ok github.com/hashicorp/terraform/internal/plans 0.018s ok github.com/hashicorp/terraform/internal/plans/deferring 0.010s ok github.com/hashicorp/terraform/internal/plans/objchange 0.115s ok github.com/hashicorp/terraform/internal/plans/planfile 0.331s ok github.com/hashicorp/terraform/internal/plugin 0.040s ok github.com/hashicorp/terraform/internal/plugin/convert 0.027s ok github.com/hashicorp/terraform/internal/plugin/discovery 0.013s ok github.com/hashicorp/terraform/internal/plugin6 0.028s ok github.com/hashicorp/terraform/internal/plugin6/convert 0.022s ok github.com/hashicorp/terraform/internal/promising 0.041s ok github.com/hashicorp/terraform/internal/providercache 0.232s ok github.com/hashicorp/terraform/internal/providers 0.012s ok github.com/hashicorp/terraform/internal/refactoring 0.261s ok github.com/hashicorp/terraform/internal/registry 3.826s ok github.com/hashicorp/terraform/internal/registry/regsrc 0.008s ok github.com/hashicorp/terraform/internal/registry/response 0.010s ok github.com/hashicorp/terraform/internal/releaseauth 0.167s ok github.com/hashicorp/terraform/internal/repl 0.096s ok github.com/hashicorp/terraform/internal/rpcapi 0.263s ok github.com/hashicorp/terraform/internal/stacks/stackconfig 0.017s ok github.com/hashicorp/terraform/internal/stacks/stackplan 0.029s ok github.com/hashicorp/terraform/internal/stacks/stackruntime 0.484s ok github.com/hashicorp/terraform/internal/stacks/stackruntime/internal/stackeval 1.489s ok github.com/hashicorp/terraform/internal/stacks/stackstate 0.022s ok github.com/hashicorp/terraform/internal/stacks/stackstate/statekeys 0.028s ok github.com/hashicorp/terraform/internal/stacks/tfstackdata1 0.017s ok github.com/hashicorp/terraform/internal/states 0.018s ok github.com/hashicorp/terraform/internal/states/remote 0.032s ok github.com/hashicorp/terraform/internal/states/statefile 0.070s ok github.com/hashicorp/terraform/internal/states/statemgr 5.951s ok github.com/hashicorp/terraform/internal/terminal 0.005s ok github.com/hashicorp/terraform/internal/terraform 8.988s ok github.com/hashicorp/terraform/internal/tfdiags 0.012s ok github.com/hashicorp/terraform/version 0.003s
テストを実行してみたところ、[no test files] が多数見つかりました。 少し気になりますので、テストのカバレッジを見てみます。
$ go test -cover Terraform has no command named "bar".
To see all of Terraform's top-level commands, run: terraform -help PASS coverage: 36.7% of statements ok github.com/hashicorp/terraform 0.049s
# Get the parent directory of where this script is. SOURCE="${BASH_SOURCE[0]}" while [ -h "$SOURCE" ] ; do SOURCE="$(readlink "$SOURCE")"; done DIR="$( cd -P "$( dirname "$SOURCE" )/.." && pwd )"
上記を踏まえて、さっそくビルドしてみます。
$ /usr/bin/bash build.sh ==> Removing old directory... ==> Installing gox... ==> Building... Number of parallel builds: 11
if [ "${TF_DEV}x" = "x" ]; then # Zip and copy to the dist dir echo"==> Packaging..." for PLATFORM in $(find ./pkg -mindepth 1 -maxdepth 1 -type d); do OSARCH=$(basename${PLATFORM}) echo"--> ${OSARCH}"
pushd$PLATFORM >/dev/null 2>&1 zip ../${OSARCH}.zip ./* popd >/dev/null 2>&1 done fi
Terraform crashed! This is always indicative of a bug within Terraform. Please report the crash with Terraform[1] so that we can fix this.
When reporting bugs, please include your terraform version, the stack trace shown below, and any additional information which may help replicate the issue.
err = openTelemetryInit() if err != nil { // openTelemetryInit can only fail if Terraform was run with an // explicit environment variable to enable telemetry collection, // so in typical use we cannot get here. Ui.Error(fmt.Sprintf("Could not initialize telemetry: %s", err)) Ui.Error(fmt.Sprintf("Unset environment variable %s if you don't intend to collect telemetry from Terraform.", openTelemetryExporterEnvVar)) return1 } var ctx context.Context var otelSpan trace.Span { // At minimum we emit a span covering the entire command execution. _, displayArgs := shquot.POSIXShellSplit(os.Args) ctx, otelSpan = tracer.Start(context.Background(), fmt.Sprintf("terraform %s", displayArgs)) defer otelSpan.End() }
// If this environment variable is set to "otlp" when running Terraform CLI // then we'll enable an experimental OTLP trace exporter. // // BEWARE! This is not a committed external interface. // // Everything about this is experimental and subject to change in future // releases. Do not depend on anything about the structure of this output. // This mechanism might be removed altogether if a different strategy seems // better based on experience with this experiment. const openTelemetryExporterEnvVar = "OTEL_TRACES_EXPORTER"
2024-03-25T05:07:16.800+0900 [DEBUG] using github.com/hashicorp/go-tfe v1.41.0 2024-03-25T05:07:16.800+0900 [DEBUG] using github.com/hashicorp/hcl/v2 v2.20.0 2024-03-25T05:07:16.800+0900 [DEBUG] using github.com/hashicorp/terraform-svchost v0.1.1 2024-03-25T05:07:16.800+0900 [DEBUG] using github.com/zclconf/go-cty v1.14.3
// experimentsAllowed can be set to any non-empty string using Go linker // arguments in order to enable the use of experimental features for a // particular Terraform build: // // go install -ldflags="-X 'main.experimentsAllowed=yes'" // // By default this variable is initialized as empty, in which case // experimental features are not available.
コメントの内容に従うと、terraform のビルド時に
go install -ldflags="-X 'main.experimentsAllowed=yes'"
# In release mode we don't want debug information in the binary and we don't # want the -dev version marker if [[ -n "${TF_RELEASE}" ]]; then LD_FLAGS="-s -w -X 'github.com/hashicorp/terraform/version.dev=no'" fi
今回は TF_RELEASE を利用しないので、以下の分岐を追加します。
if [[ -n "${TF_RELEASE}" ]]; then LD_FLAGS="-s -w -X 'github.com/hashicorp/terraform/version.dev=no'" else LD_FLAGS="-X 'main.experimentsAllowed=yes'" fi
streams, err := terminal.Init() if err != nil { Ui.Error(fmt.Sprintf("Failed to configure the terminal: %s", err)) return1 } if streams.Stdout.IsTerminal() { log.Printf("[TRACE] Stdout is a terminal of width %d", streams.Stdout.Columns()) } else { log.Printf("[TRACE] Stdout is not a terminal") } if streams.Stderr.IsTerminal() { log.Printf("[TRACE] Stderr is a terminal of width %d", streams.Stderr.Columns()) } else { log.Printf("[TRACE] Stderr is not a terminal") } if streams.Stdin.IsTerminal() { log.Printf("[TRACE] Stdin is a terminal") } else { log.Printf("[TRACE] Stdin is not a terminal") }