Last active
November 28, 2024 12:37
-
-
Save nazarewk/9421835b12445359e9c78b78a59eda61 to your computer and use it in GitHub Desktop.
demonstration of OpenTofu filesystem mirror issue with version `0.0.0`
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
set -xeEuo pipefail | |
trap 'echo "Error when executing $BASH_COMMAND at line $LINENO!" >&2' ERR | |
dir="$(mktemp -d "$PWD/tofu-report.XXXXXX")" | |
tf_root="$dir/tf-root" | |
: "${KEEP:="0"}" | |
trap 'test "$KEEP" == 1 || rm -rf "$dir" || :' EXIT | |
export TF_CLI_CONFIG_FILE="$dir/.tofurc" | |
PLUGINS_DIR="$dir/plugins" | |
PROVIDER="registry.terraform.io/hashicorp/scaffolding" | |
GOOS="$(go env GOOS)" | |
GOARCH="$(go env GOARCH)" | |
cat <<EOF >"$TF_CLI_CONFIG_FILE" | |
provider_installation { | |
filesystem_mirror { | |
path = "$PLUGINS_DIR" | |
include = ["$PROVIDER"] | |
} | |
direct { | |
exclude = ["$PROVIDER"] | |
} | |
} | |
EOF | |
git clone "https://github.com/hashicorp/terraform-provider-scaffolding-framework" "$dir/repo" | |
for PROVIDER_VERSION in 0.0.1 0.0.0; do | |
MIRROR_PATH="$PLUGINS_DIR/$PROVIDER/$PROVIDER_VERSION/${GOOS}_${GOARCH}/terraform-provider-scaffolding_v$PROVIDER_VERSION" | |
tf_root="$dir/tf/v$PROVIDER_VERSION" | |
mkdir -p "${MIRROR_PATH%/*}" "$tf_root" | |
(cd "$dir/repo" && go build -o "$MIRROR_PATH" ".") | |
cat <<EOF >"$tf_root/main.tf" | |
terraform { | |
required_providers { | |
scaffolding = { | |
source = "$PROVIDER" | |
version = "$PROVIDER_VERSION" | |
} | |
} | |
} | |
EOF | |
( | |
cd "$tf_root" | |
export TF_LOG=trace | |
export TF_LOG_PATH="$tf_root/log.txt" | |
tofu init | |
) || echo "tofu errored!" | |
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2024-11-28T13:35:42.592+0100 [INFO] OpenTofu version: 1.8.5 | |
2024-11-28T13:35:42.592+0100 [DEBUG] using github.com/hashicorp/go-tfe v1.36.0 | |
2024-11-28T13:35:42.592+0100 [DEBUG] using github.com/opentofu/hcl/v2 v2.0.0-20240416130056-03228b26f391 | |
2024-11-28T13:35:42.592+0100 [DEBUG] using github.com/hashicorp/terraform-svchost v0.1.1 | |
2024-11-28T13:35:42.592+0100 [DEBUG] using github.com/zclconf/go-cty v1.14.4 | |
2024-11-28T13:35:42.592+0100 [INFO] Go runtime version: go1.23.3 | |
2024-11-28T13:35:42.592+0100 [INFO] CLI args: []string{"tofu", "init"} | |
2024-11-28T13:35:42.592+0100 [TRACE] Stdout is a terminal of width 181 | |
2024-11-28T13:35:42.592+0100 [TRACE] Stderr is a terminal of width 181 | |
2024-11-28T13:35:42.592+0100 [TRACE] Stdin is a terminal | |
2024-11-28T13:35:42.592+0100 [DEBUG] Attempting to open CLI config file: /home/kdn/.config/JetBrains/IntelliJIdea2024.3/scratches/tofu-report.OtWtNZ/.tofurc | |
2024-11-28T13:35:42.592+0100 [INFO] Loading CLI configuration from /home/kdn/.config/JetBrains/IntelliJIdea2024.3/scratches/tofu-report.OtWtNZ/.tofurc | |
2024-11-28T13:35:42.592+0100 [DEBUG] Not reading CLI config directory because config location is overridden by environment variable | |
2024-11-28T13:35:42.592+0100 [DEBUG] Explicit provider installation configuration is set | |
2024-11-28T13:35:42.592+0100 [TRACE] Selected provider installation method cliconfig.ProviderInstallationFilesystemMirror("/home/kdn/.config/JetBrains/IntelliJIdea2024.3/scratches/tofu-report.OtWtNZ/plugins") with includes [registry.terraform.io/hashicorp/scaffolding] and excludes [] | |
2024-11-28T13:35:42.592+0100 [TRACE] Selected provider installation method cliconfig.ProviderInstallationDirect with includes [] and excludes [registry.terraform.io/hashicorp/scaffolding] | |
2024-11-28T13:35:42.592+0100 [DEBUG] Found the config directory: /home/kdn/.config/opentofu | |
2024-11-28T13:35:42.593+0100 [INFO] CLI command args: []string{"init"} | |
2024-11-28T13:35:42.593+0100 [TRACE] Meta.Backend: no config given or present on disk, so returning nil config | |
2024-11-28T13:35:42.593+0100 [TRACE] Meta.Backend: backend has not previously been initialized in this working directory | |
2024-11-28T13:35:42.593+0100 [DEBUG] New state was assigned lineage "bb300d0c-5172-449d-dffe-22faa3fa230d" | |
2024-11-28T13:35:42.593+0100 [TRACE] Meta.Backend: using default local state only (no backend configuration, and no existing initialized backend) | |
2024-11-28T13:35:42.593+0100 [TRACE] Meta.Backend: instantiated backend of type <nil> | |
2024-11-28T13:35:42.593+0100 [DEBUG] checking for provisioner in "." | |
2024-11-28T13:35:42.593+0100 [DEBUG] checking for provisioner in "/nix/store/wzpdfc7mbw9malnwillz9a172y9ijwnm-opentofu-1.8.5/bin" | |
2024-11-28T13:35:42.593+0100 [TRACE] Meta.Backend: backend <nil> does not support operations, so wrapping it in a local backend | |
2024-11-28T13:35:42.593+0100 [TRACE] backend/local: state manager for workspace "default" will: | |
- read initial snapshot from terraform.tfstate | |
- write new snapshots to terraform.tfstate | |
- create any backup at terraform.tfstate.backup | |
2024-11-28T13:35:42.593+0100 [TRACE] statemgr.Filesystem: reading initial snapshot from terraform.tfstate | |
2024-11-28T13:35:42.593+0100 [TRACE] statemgr.Filesystem: snapshot file has nil snapshot, but that's okay | |
2024-11-28T13:35:42.593+0100 [TRACE] statemgr.Filesystem: read nil snapshot | |
2024-11-28T13:35:42.594+0100 [TRACE] getproviders.SearchLocalDirectory: found registry.terraform.io/hashicorp/scaffolding v0.0.0 for linux_amd64 at /home/kdn/.config/JetBrains/IntelliJIdea2024.3/scratches/tofu-report.OtWtNZ/plugins/registry.terraform.io/hashicorp/scaffolding/0.0.0/linux_amd64 | |
2024-11-28T13:35:42.594+0100 [TRACE] getproviders.SearchLocalDirectory: found registry.terraform.io/hashicorp/scaffolding v0.0.1 for linux_amd64 at /home/kdn/.config/JetBrains/IntelliJIdea2024.3/scratches/tofu-report.OtWtNZ/plugins/registry.terraform.io/hashicorp/scaffolding/0.0.1/linux_amd64 | |
2024-11-28T13:35:42.594+0100 [DEBUG] no available releases match the given constraints 0.0.0 | |
2024-11-28T13:35:42.594+0100 [DEBUG] Available releases: [0.0.0 0.0.1] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
+ trap 'echo "Error when executing $BASH_COMMAND at line $LINENO!" >&2' ERR | |
++ mktemp -d /home/kdn/.config/JetBrains/IntelliJIdea2024.3/scratches/tofu-report.XXXXXX | |
+ dir=/home/kdn/.config/JetBrains/IntelliJIdea2024.3/scratches/tofu-report.OtWtNZ | |
+ tf_root=/home/kdn/.config/JetBrains/IntelliJIdea2024.3/scratches/tofu-report.OtWtNZ/tf-root | |
+ : 1 | |
+ trap 'test "$KEEP" == 1 || rm -rf "$dir" || :' EXIT | |
+ export TF_CLI_CONFIG_FILE=/home/kdn/.config/JetBrains/IntelliJIdea2024.3/scratches/tofu-report.OtWtNZ/.tofurc | |
+ TF_CLI_CONFIG_FILE=/home/kdn/.config/JetBrains/IntelliJIdea2024.3/scratches/tofu-report.OtWtNZ/.tofurc | |
+ PLUGINS_DIR=/home/kdn/.config/JetBrains/IntelliJIdea2024.3/scratches/tofu-report.OtWtNZ/plugins | |
+ PROVIDER=registry.terraform.io/hashicorp/scaffolding | |
++ go env GOOS | |
+ GOOS=linux | |
++ go env GOARCH | |
+ GOARCH=amd64 | |
+ cat | |
+ git clone https://github.com/hashicorp/terraform-provider-scaffolding-framework /home/kdn/.config/JetBrains/IntelliJIdea2024.3/scratches/tofu-report.OtWtNZ/repo | |
Cloning into '/home/kdn/.config/JetBrains/IntelliJIdea2024.3/scratches/tofu-report.OtWtNZ/repo'... | |
remote: Enumerating objects: 1123, done. | |
remote: Counting objects: 100% (588/588), done. | |
remote: Compressing objects: 100% (206/206), done. | |
remote: Total 1123 (delta 526), reused 388 (delta 382), pack-reused 535 (from 1) | |
Receiving objects: 100% (1123/1123), 456.16 KiB | 4.80 MiB/s, done. | |
Resolving deltas: 100% (829/829), done. | |
+ for PROVIDER_VERSION in 0.0.1 0.0.0 | |
+ MIRROR_PATH=/home/kdn/.config/JetBrains/IntelliJIdea2024.3/scratches/tofu-report.OtWtNZ/plugins/registry.terraform.io/hashicorp/scaffolding/0.0.1/linux_amd64/terraform-provider-scaffolding_v0.0.1 | |
+ tf_root=/home/kdn/.config/JetBrains/IntelliJIdea2024.3/scratches/tofu-report.OtWtNZ/tf/v0.0.1 | |
+ mkdir -p /home/kdn/.config/JetBrains/IntelliJIdea2024.3/scratches/tofu-report.OtWtNZ/plugins/registry.terraform.io/hashicorp/scaffolding/0.0.1/linux_amd64 /home/kdn/.config/JetBrains/IntelliJIdea2024.3/scratches/tofu-report.OtWtNZ/tf/v0.0.1 | |
+ cd /home/kdn/.config/JetBrains/IntelliJIdea2024.3/scratches/tofu-report.OtWtNZ/repo | |
+ go build -o /home/kdn/.config/JetBrains/IntelliJIdea2024.3/scratches/tofu-report.OtWtNZ/plugins/registry.terraform.io/hashicorp/scaffolding/0.0.1/linux_amd64/terraform-provider-scaffolding_v0.0.1 . | |
+ cat | |
+ cd /home/kdn/.config/JetBrains/IntelliJIdea2024.3/scratches/tofu-report.OtWtNZ/tf/v0.0.1 | |
+ export TF_LOG=trace | |
+ TF_LOG=trace | |
+ export TF_LOG_PATH=/home/kdn/.config/JetBrains/IntelliJIdea2024.3/scratches/tofu-report.OtWtNZ/tf/v0.0.1/log.txt | |
+ TF_LOG_PATH=/home/kdn/.config/JetBrains/IntelliJIdea2024.3/scratches/tofu-report.OtWtNZ/tf/v0.0.1/log.txt | |
+ tofu init | |
Initializing the backend... | |
Initializing provider plugins... | |
- Finding registry.terraform.io/hashicorp/scaffolding versions matching "0.0.1"... | |
- Installing registry.terraform.io/hashicorp/scaffolding v0.0.1... | |
- Installed registry.terraform.io/hashicorp/scaffolding v0.0.1 (unauthenticated) | |
OpenTofu has created a lock file .terraform.lock.hcl to record the provider | |
selections it made above. Include this file in your version control repository | |
so that OpenTofu can guarantee to make the same selections by default when | |
you run "tofu init" in the future. | |
╷ | |
│ Warning: Incomplete lock file information for providers | |
│ | |
│ Due to your customized provider installation methods, OpenTofu was forced to calculate lock file checksums locally for the following providers: | |
│ - registry.terraform.io/hashicorp/scaffolding | |
│ | |
│ The current .terraform.lock.hcl file only includes checksums for linux_amd64, so OpenTofu running on another platform will fail to install these providers. | |
│ | |
│ To calculate additional checksums for another platform, run: | |
│ tofu providers lock -platform=linux_amd64 | |
│ (where linux_amd64 is the platform to generate) | |
╵ | |
OpenTofu has been successfully initialized! | |
You may now begin working with OpenTofu. Try running "tofu plan" to see | |
any changes that are required for your infrastructure. All OpenTofu commands | |
should now work. | |
If you ever set or change modules or backend configuration for OpenTofu, | |
rerun this command to reinitialize your working directory. If you forget, other | |
commands will detect it and remind you to do so if necessary. | |
+ for PROVIDER_VERSION in 0.0.1 0.0.0 | |
+ MIRROR_PATH=/home/kdn/.config/JetBrains/IntelliJIdea2024.3/scratches/tofu-report.OtWtNZ/plugins/registry.terraform.io/hashicorp/scaffolding/0.0.0/linux_amd64/terraform-provider-scaffolding_v0.0.0 | |
+ tf_root=/home/kdn/.config/JetBrains/IntelliJIdea2024.3/scratches/tofu-report.OtWtNZ/tf/v0.0.0 | |
+ mkdir -p /home/kdn/.config/JetBrains/IntelliJIdea2024.3/scratches/tofu-report.OtWtNZ/plugins/registry.terraform.io/hashicorp/scaffolding/0.0.0/linux_amd64 /home/kdn/.config/JetBrains/IntelliJIdea2024.3/scratches/tofu-report.OtWtNZ/tf/v0.0.0 | |
+ cd /home/kdn/.config/JetBrains/IntelliJIdea2024.3/scratches/tofu-report.OtWtNZ/repo | |
+ go build -o /home/kdn/.config/JetBrains/IntelliJIdea2024.3/scratches/tofu-report.OtWtNZ/plugins/registry.terraform.io/hashicorp/scaffolding/0.0.0/linux_amd64/terraform-provider-scaffolding_v0.0.0 . | |
+ cat | |
+ cd /home/kdn/.config/JetBrains/IntelliJIdea2024.3/scratches/tofu-report.OtWtNZ/tf/v0.0.0 | |
+ export TF_LOG=trace | |
+ TF_LOG=trace | |
+ export TF_LOG_PATH=/home/kdn/.config/JetBrains/IntelliJIdea2024.3/scratches/tofu-report.OtWtNZ/tf/v0.0.0/log.txt | |
+ TF_LOG_PATH=/home/kdn/.config/JetBrains/IntelliJIdea2024.3/scratches/tofu-report.OtWtNZ/tf/v0.0.0/log.txt | |
+ tofu init | |
Initializing the backend... | |
Initializing provider plugins... | |
- Finding registry.terraform.io/hashicorp/scaffolding versions matching "0.0.0"... | |
╷ | |
│ Error: Failed to resolve provider packages | |
│ | |
│ Could not resolve provider registry.terraform.io/hashicorp/scaffolding: no available releases match the given constraints 0.0.0 | |
╵ | |
+ echo 'tofu errored!' | |
tofu errored! | |
+ test 1 == 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment