Skip to content

Commit

Permalink
feat: support master branch terraform-provider-harvester
Browse files Browse the repository at this point in the history
Signed-off-by: PoAn Yang <[email protected]>
  • Loading branch information
FrankYang0529 authored and lanfon72 committed Jul 15, 2024
1 parent 982fea0 commit f2db7aa
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
6 changes: 5 additions & 1 deletion config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,11 @@ image-cache-url: ''
terraform-scripts-location: 'terraform_test_artifacts'
# Rancher provider version, leave empty for the latest version. e.g. '' or '3.1.1'.
terraform-provider-rancher: ''
# Harvester provider version, leave empty for the latest version. e.g. '' or '0.6.3'.
# Harvester provider version:
# '' for the latest released version.
# '0.0.0-dev' for the latest version from master branch.
# '0.0.0-dev' requires Docker, because we will get plugin executable file from the container.
# '0.6.3' for the specific version.
terraform-provider-harvester: ''

# Backup Target S3
Expand Down
21 changes: 21 additions & 0 deletions harvester_e2e_tests/fixtures/terraform.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,27 @@ def initial_provider(self, kubeconfig, provider_version):
provider_source="harvester/harvester", provider_version=provider_version
))

# cleanup terraform plugin cache
local_plugin_path = "~/.terraform.d/plugins/registry.terraform.io"
local_plugin_tf = "harvester/harvester/0.0.0-dev/linux_amd64"
rv = run(
f"rm -rf ~/.terraform.d/plugins/registry.terraform.io/harvester/harvester &&"
f" mkdir -p {local_plugin_path}/{local_plugin_tf}",
shell=True, stdout=PIPE, stderr=PIPE, cwd=self.workdir)
assert not remove_ansicode(rv.stderr) and 0 == rv.returncode

if provider_version == "0.0.0-dev":
docker_plugin_path = "/root/.terraform.d/plugins/terraform.local/local"
docker_plugin_tf = "harvester/0.0.0-dev/linux_amd64/terraform-provider-harvester_v0.0.0-dev" # noqa: E501
rv = run(
f"docker run --pull=always -q --rm --name harv-tf-master-head"
f" -v {local_plugin_path}/{local_plugin_tf}:/_tf"
f" rancher/terraform-provider-harvester:master-head-amd64"
f' bash -c "cp {docker_plugin_path}/{docker_plugin_tf} /_tf/"',
shell=True, stdout=PIPE, stderr=PIPE, cwd=self.workdir
)
assert not remove_ansicode(rv.stderr) and 0 == rv.returncode

return self.execute("init")

def save_as(self, content, filename, ext=".tf"):
Expand Down

0 comments on commit f2db7aa

Please sign in to comment.