From a0b3d2cf5fcb756ed9eab580a1d7764e06c8cb33 Mon Sep 17 00:00:00 2001 From: Dustin Strobel Date: Sun, 23 Jun 2024 10:55:11 +0200 Subject: [PATCH 01/27] chore: add vagrant files for testacc --- vagrant/Makefile | 7 +++++++ vagrant/Vagrantfile | 35 ++++++++++++++++++++++++++++++++++- vagrant/ed25519.pub | 1 + vagrant/id_rsa.pub | 1 + vagrant/vagrant.env | 18 ++++++++++++++++++ 5 files changed, 61 insertions(+), 1 deletion(-) create mode 100644 vagrant/Makefile create mode 100644 vagrant/ed25519.pub create mode 100644 vagrant/id_rsa.pub create mode 100644 vagrant/vagrant.env diff --git a/vagrant/Makefile b/vagrant/Makefile new file mode 100644 index 0000000..6d59597 --- /dev/null +++ b/vagrant/Makefile @@ -0,0 +1,7 @@ +.PHONY: vagrant-up +vagrant-up: + @vagrant up + +.PHONY: vagrant-down +vagrant-down: + @vagrant destroy --force diff --git a/vagrant/Vagrantfile b/vagrant/Vagrantfile index 1540d04..f0fa14d 100644 --- a/vagrant/Vagrantfile +++ b/vagrant/Vagrantfile @@ -1,7 +1,40 @@ # -*- mode: ruby -*- # vi: set ft=ruby : +# Read SSH public keys from files +ssh_public_key_rsa = File.readlines('id_rsa.pub').first.strip +ssh_public_key_ed25519 = File.readlines('ed25519.pub').first.strip + # Configure vagrant boxes Vagrant.configure("2") do |config| - config.vm.box = "d-strobel/win2022sc" + + # Windows Server 2022 Standard Core + config.vm.define "win2022sc" do |win2022sc| + win2022sc.vm.box = "d-strobel/win2022sc" + + win2022sc.vm.provision "shell", inline: <<-SHELL + $sshPath = "C:\\ProgramData\\ssh\\administrators_authorized_keys" + Set-Content -Path $sshPath -Value $null + icacls.exe $sshPath /inheritance:r /grant Administrators:F /grant SYSTEM:F + + Add-Content -Force -Path $sshPath -Value '#{ssh_public_key_rsa}' + Add-Content -Force -Path $sshPath -Value '#{ssh_public_key_ed25519}' + SHELL + end + + # Windows Server 2022 Standard Core with Active Directory + config.vm.define "win2022ad" do |win2022ad| + win2022ad.vm.box = "d-strobel/win2022sc-ad" + win2022ad.winrm.username = "vagrant\\vagrant" + + win2022ad.vm.provision "shell", inline: <<-SHELL + $sshPath = "C:\\ProgramData\\ssh\\administrators_authorized_keys" + Set-Content -Path $sshPath -Value $null + icacls.exe $sshPath /inheritance:r /grant Administrators:F /grant SYSTEM:F + + Add-Content -Force -Path $sshPath -Value '#{ssh_public_key_rsa}' + Add-Content -Force -Path $sshPath -Value '#{ssh_public_key_ed25519}' + SHELL + end + end diff --git a/vagrant/ed25519.pub b/vagrant/ed25519.pub new file mode 100644 index 0000000..d682049 --- /dev/null +++ b/vagrant/ed25519.pub @@ -0,0 +1 @@ +ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAII0qouQNpprgoan7FpPRf3hdXEaLAbpEezKYRz3+bf2H dstrobel@NB0784 diff --git a/vagrant/id_rsa.pub b/vagrant/id_rsa.pub new file mode 100644 index 0000000..693961a --- /dev/null +++ b/vagrant/id_rsa.pub @@ -0,0 +1 @@ +ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQCJUn4ZiFDyIq7EfScLK0YsuSz86vWmUzs01Si4bPPe7TAcWr7noQ1LTEig4DCGHI40YK95JkivKem01ZjV1KdM4ZVQ7GKe8PCsma8nFL7OhdmY/4Fh4jB73AM1+2dU+4twe5p/Wyj5LO2JCnmutvSui7fJxVf2sOpAFnoK9fEXy8O8oPcPKGq6WUAHxM9TTDOYGRIp+9CTwKs44ZwYQ1qVNQl44Nk1VzJRbMgJ10YGYPH8bVLqrwIE4jycdrI7yqtKAYDBpEhdAY+F+SnI8/oCOYL1WI05YGJf6TNQsw/+Mu/sSUtequruBfwCUNPttyRFx6TQxe+q4RSHCjRGaU4436reDX5NUh0ZKumZjMQ8+fFMq80PbkGsfRMAAKAOfbjcRP8/smaCMRX+DSwmvB005gnm8RLtUrH1M3Vhck2QRmJlQW2fY5ub9tqMfPf5JOrY55GOKwkVaMTADUcT7ot21QDHooqH4872UvkpKN40yMYYuVI5xwBVVj1oiAKbviU= dstrobel@NB0784 diff --git a/vagrant/vagrant.env b/vagrant/vagrant.env new file mode 100644 index 0000000..1b74d47 --- /dev/null +++ b/vagrant/vagrant.env @@ -0,0 +1,18 @@ +# Connections variables for the default windows host +export GOWINDOWS_TEST_HOST=127.0.0.1 +export GOWINDOWS_TEST_USERNAME=vagrant +export GOWINDOWS_TEST_PASSWORD=vagrant +export GOWINDOWS_TEST_SSH_PORT=1222 +export GOWINDOWS_TEST_SSH_PRIVATE_KEY_ED25519_PATH=./fixtures/ed25519 +export GOWINDOWS_TEST_SSH_PRIVATE_KEY_RSA_PATH=./fixtures/id_rsa +export GOWINDOWS_TEST_WINRM_HTTP_PORT=15985 +export GOWINDOWS_TEST_WINRM_HTTPS_PORT=15986 + +# Connection variables for the Active-Directory host +export GOWINDOWS_TEST_AD_HOST=127.0.0.1 +export GOWINDOWS_TEST_AD_USERNAME=vagrant +export GOWINDOWS_TEST_AD_USERNAME_PRE2K=vagrant\vagrant +export GOWINDOWS_TEST_AD_PASSWORD=vagrant +export GOWINDOWS_TEST_AD_SSH_PORT=2222 +export GOWINDOWS_TEST_AD_WINRM_HTTP_PORT=25985 +export GOWINDOWS_TEST_AD_WINRM_HTTPS_PORT=25986 From 9fd6e73e8ba381b6f5ca0e6ff9a11d35e23bb53b Mon Sep 17 00:00:00 2001 From: Dustin Strobel Date: Thu, 26 Sep 2024 23:55:56 +0200 Subject: [PATCH 02/27] chore: rename GNUmakefile -> Makefile --- GNUmakefile => Makefile | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) rename GNUmakefile => Makefile (58%) diff --git a/GNUmakefile b/Makefile similarity index 58% rename from GNUmakefile rename to Makefile index a6aa81b..1846fb9 100644 --- a/GNUmakefile +++ b/Makefile @@ -4,6 +4,13 @@ OK_COLOR=\033[32;01m ERROR_COLOR=\033[31;01m WARN_COLOR=\033[33;01m +# Source .env file if available +ifneq ("$(wildcard .env)","") + include .env +else + include ./vagrant/vagrant.env +endif + # Generate all .PHONY: generate generate: @@ -13,4 +20,4 @@ generate: # Run acceptance tests .PHONY: testacc testacc: - TF_ACC=1 go test ./... -v $(TESTARGS) -timeout 120m + TF_ACC=1 go test ./internal/provider/... -v $(TESTARGS) -timeout 120m From 42ca5ac4fc544c25a259858287ee889223423e4a Mon Sep 17 00:00:00 2001 From: Dustin Strobel Date: Thu, 26 Sep 2024 23:57:38 +0200 Subject: [PATCH 03/27] chore: change go package name --- go.mod | 56 ++++--- go.sum | 145 +++++++++++------- internal/provider/configure.go | 2 +- .../provider/local/local_group_data_source.go | 2 +- .../local/local_group_member_resource.go | 2 +- .../local/local_group_members_data_source.go | 2 +- .../provider/local/local_group_resource.go | 2 +- .../local/local_groups_data_source.go | 2 +- .../provider/local/local_user_data_source.go | 2 +- .../provider/local/local_user_resource.go | 2 +- .../provider/local/local_users_data_source.go | 2 +- internal/provider/provider.go | 4 +- internal/provider/validate.go | 2 +- main.go | 2 +- 14 files changed, 135 insertions(+), 92 deletions(-) diff --git a/go.mod b/go.mod index a33cfdd..119bae7 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module terraform-provider-windows +module github.com/d-strobel/terraform-provider-windows go 1.22 @@ -8,13 +8,28 @@ require ( github.com/d-strobel/gowindows v1.1.0 github.com/hashicorp/terraform-plugin-codegen-framework v0.3.1 github.com/hashicorp/terraform-plugin-docs v0.17.0 - github.com/hashicorp/terraform-plugin-framework v1.5.0 + github.com/hashicorp/terraform-plugin-framework v1.11.0 github.com/hashicorp/terraform-plugin-framework-timetypes v0.3.0 github.com/hashicorp/terraform-plugin-framework-validators v0.12.0 - github.com/hashicorp/terraform-plugin-go v0.20.0 + github.com/hashicorp/terraform-plugin-go v0.23.0 github.com/hashicorp/terraform-plugin-log v0.9.0 ) +require ( + github.com/agext/levenshtein v1.2.2 // indirect + github.com/google/go-cmp v0.6.0 // indirect + github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320 // indirect + github.com/hashicorp/hcl/v2 v2.21.0 // indirect + github.com/hashicorp/logutils v1.0.0 // indirect + github.com/hashicorp/terraform-plugin-sdk/v2 v2.34.0 // indirect + github.com/mitchellh/go-wordwrap v1.0.0 // indirect + github.com/mitchellh/mapstructure v1.5.0 // indirect + github.com/vmihailenco/msgpack v4.0.4+incompatible // indirect + golang.org/x/sync v0.7.0 // indirect + golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d // indirect + google.golang.org/appengine v1.6.8 // indirect +) + require ( github.com/Azure/go-ntlmssp v0.0.0-20221128193559-754e69321358 // indirect github.com/ChrisTrenkamp/goxpath v0.0.0-20210404020558-97928f7e12b6 // indirect @@ -22,7 +37,7 @@ require ( github.com/Masterminds/goutils v1.1.1 // indirect github.com/Masterminds/semver/v3 v3.2.1 // indirect github.com/Masterminds/sprig/v3 v3.2.3 // indirect - github.com/ProtonMail/go-crypto v0.0.0-20230828082145-3c4c8a2d2371 // indirect + github.com/ProtonMail/go-crypto v1.1.0-alpha.2 // indirect github.com/apparentlymart/go-textseg/v15 v15.0.0 // indirect github.com/armon/go-radix v1.0.0 // indirect github.com/bgentry/speakeasy v0.1.0 // indirect @@ -32,21 +47,22 @@ require ( github.com/fatih/color v1.16.0 // indirect github.com/go-logr/logr v1.3.0 // indirect github.com/gofrs/uuid v4.4.0+incompatible // indirect - github.com/golang/protobuf v1.5.3 // indirect - github.com/google/uuid v1.4.0 // indirect + github.com/golang/protobuf v1.5.4 // indirect + github.com/google/uuid v1.6.0 // indirect github.com/hashicorp/cli v1.1.6 // indirect github.com/hashicorp/errwrap v1.1.0 // indirect github.com/hashicorp/go-checkpoint v0.5.0 // indirect github.com/hashicorp/go-cleanhttp v0.5.2 // indirect - github.com/hashicorp/go-hclog v1.5.0 // indirect + github.com/hashicorp/go-hclog v1.6.3 // indirect github.com/hashicorp/go-multierror v1.1.1 // indirect github.com/hashicorp/go-plugin v1.6.0 // indirect github.com/hashicorp/go-uuid v1.0.3 // indirect - github.com/hashicorp/go-version v1.6.0 // indirect - github.com/hashicorp/hc-install v0.6.2 // indirect - github.com/hashicorp/terraform-exec v0.20.0 // indirect - github.com/hashicorp/terraform-json v0.20.0 // indirect + github.com/hashicorp/go-version v1.7.0 // indirect + github.com/hashicorp/hc-install v0.7.0 // indirect + github.com/hashicorp/terraform-exec v0.21.0 // indirect + github.com/hashicorp/terraform-json v0.22.1 // indirect github.com/hashicorp/terraform-plugin-codegen-spec v0.1.1-0.20231024091233-c659ac8a54fc // indirect + github.com/hashicorp/terraform-plugin-testing v1.9.0 github.com/hashicorp/terraform-registry-address v0.2.3 // indirect github.com/hashicorp/terraform-svchost v0.1.1 // indirect github.com/hashicorp/yamux v0.1.1 // indirect @@ -80,15 +96,15 @@ require ( github.com/xeipuuv/gojsonschema v1.2.0 // indirect github.com/yuin/goldmark v1.6.0 // indirect github.com/yuin/goldmark-meta v1.1.0 // indirect - github.com/zclconf/go-cty v1.14.1 // indirect - golang.org/x/crypto v0.22.0 // indirect + github.com/zclconf/go-cty v1.14.4 // indirect + golang.org/x/crypto v0.25.0 // indirect golang.org/x/exp v0.0.0-20230809150735-7b3493d9a819 // indirect - golang.org/x/mod v0.14.0 // indirect - golang.org/x/net v0.23.0 // indirect - golang.org/x/sys v0.19.0 // indirect - golang.org/x/text v0.15.0 // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20231002182017-d307bd883b97 // indirect - google.golang.org/grpc v1.60.0 // indirect - google.golang.org/protobuf v1.31.0 // indirect + golang.org/x/mod v0.17.0 // indirect + golang.org/x/net v0.25.0 // indirect + golang.org/x/sys v0.22.0 // indirect + golang.org/x/text v0.16.0 // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20240227224415-6ceb2ff114de // indirect + google.golang.org/grpc v1.63.2 // indirect + google.golang.org/protobuf v1.34.0 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect ) diff --git a/go.sum b/go.sum index ee12177..57f6a80 100644 --- a/go.sum +++ b/go.sum @@ -17,8 +17,11 @@ github.com/Masterminds/sprig/v3 v3.2.3 h1:eL2fZNezLomi0uOLqjQoN6BfsDD+fyLtgbJMAj github.com/Masterminds/sprig/v3 v3.2.3/go.mod h1:rXcFaZ2zZbLRJv/xSysmlgIM1u11eBaRMhvYXJNkGuM= github.com/Microsoft/go-winio v0.6.1 h1:9/kr64B9VUZrLm5YYwbGtUJnMgqWVOdUAXu6Migciow= github.com/Microsoft/go-winio v0.6.1/go.mod h1:LRdKpFKfdobln8UmuiYcKPot9D2v6svN5+sAH+4kjUM= -github.com/ProtonMail/go-crypto v0.0.0-20230828082145-3c4c8a2d2371 h1:kkhsdkhsCvIsutKu5zLMgWtgh9YxGCNAw8Ad8hjwfYg= -github.com/ProtonMail/go-crypto v0.0.0-20230828082145-3c4c8a2d2371/go.mod h1:EjAoLdwvbIOoOQr3ihjnSoLZRtE8azugULFRteWMNc0= +github.com/ProtonMail/go-crypto v1.1.0-alpha.2 h1:bkyFVUP+ROOARdgCiJzNQo2V2kiB97LyUpzH9P6Hrlg= +github.com/ProtonMail/go-crypto v1.1.0-alpha.2/go.mod h1:rA3QumHc/FZ8pAHreoekgiAbzpNsfQAosU5td4SnOrE= +github.com/agext/levenshtein v1.2.2 h1:0S/Yg6LYmFJ5stwQeRp6EeOcCbj7xiqQSdNelsXvaqE= +github.com/agext/levenshtein v1.2.2/go.mod h1:JEDfjyjHDjOF/1e4FlBE/PkbqA9OfWu2ki2W0IB5558= +github.com/apparentlymart/go-textseg/v12 v12.0.0/go.mod h1:S/4uRK2UtaQttw1GenVJEynmyUenKwP++x/+DdGV/Ec= github.com/apparentlymart/go-textseg/v15 v15.0.0 h1:uYvfpb3DyLSCGWnctWKGj857c6ew1u1fNQOlOtuGxQY= github.com/apparentlymart/go-textseg/v15 v15.0.0/go.mod h1:K8XmNZdhEBkdlyDdvbmmsvpAG721bKi0joRfFdHIWJ4= github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8= @@ -32,8 +35,6 @@ github.com/bodgit/windows v1.0.1 h1:tF7K6KOluPYygXa3Z2594zxlkbKPAOvqr97etrGNIz4= github.com/bodgit/windows v1.0.1/go.mod h1:a6JLwrB4KrTR5hBpp8FI9/9W9jJfeQ2h4XDXU74ZCdM= github.com/bufbuild/protocompile v0.4.0 h1:LbFKd2XowZvQ/kajzguUp2DC9UEIQhIq77fZZlaQsNA= github.com/bufbuild/protocompile v0.4.0/go.mod h1:3v93+mbWn/v3xzN+31nwkJfrEpAUwp+BagBSZWx+TP8= -github.com/bwesterb/go-ristretto v1.2.3/go.mod h1:fUIoIZaG73pV5biE2Blr2xEzDoMj7NFEuV9ekS419A0= -github.com/cloudflare/circl v1.3.3/go.mod h1:5XYMA4rFBvNIrhs50XuiBJ15vF2pZn4nnUKZrLbUZFA= github.com/cloudflare/circl v1.3.7 h1:qlCDlTPz2n9fu58M0Nh1J/JzcFpfgkFHHX3O35r5vcU= github.com/cloudflare/circl v1.3.7/go.mod h1:sRTcRWXGLrKw6yIGJ+l7amYJFfAXbZG0kBSc8r4zxgA= github.com/cyphar/filepath-securejoin v0.2.4 h1:Ugdm7cg7i6ZK6x3xDF1oEu1nfkyfH53EtKeQYTC3kyg= @@ -55,24 +56,29 @@ github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 h1:+zs/tPmkDkHx3U66D github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376/go.mod h1:an3vInlBmSxCcxctByoQdvwPiA7DTK7jaaFDBTtu0ic= github.com/go-git/go-billy/v5 v5.5.0 h1:yEY4yhzCDuMGSv83oGxiBotRzhwhNr8VZyphhiu+mTU= github.com/go-git/go-billy/v5 v5.5.0/go.mod h1:hmexnoNsr2SJU1Ju67OaNz5ASJY3+sHgFRpCtpDCKow= -github.com/go-git/go-git/v5 v5.10.1 h1:tu8/D8i+TWxgKpzQ3Vc43e+kkhXqtsZCKI/egajKnxk= -github.com/go-git/go-git/v5 v5.10.1/go.mod h1:uEuHjxkHap8kAl//V5F/nNWwqIYtP/402ddd05mp0wg= +github.com/go-git/go-git/v5 v5.12.0 h1:7Md+ndsjrzZxbddRDZjF14qK+NN56sy6wkqaVrjZtys= +github.com/go-git/go-git/v5 v5.12.0/go.mod h1:FTM9VKtnI2m65hNI/TenDDDnUf2Q9FHnXYjuz9i5OEY= github.com/go-logr/logr v1.3.0 h1:2y3SDp0ZXuc6/cjLSZ+Q3ir+QB9T/iG5yYRXqsagWSY= github.com/go-logr/logr v1.3.0/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= +github.com/go-test/deep v1.0.3 h1:ZrJSEWsXzPOxaZnFteGEfooLba+ju3FYIbOrS+rQd68= +github.com/go-test/deep v1.0.3/go.mod h1:wGDj63lr65AM2AQyKZd/NYHGb0R+1RLqB8NKt3aSFNA= github.com/gofrs/uuid v4.4.0+incompatible h1:3qXRTX8/NbyulANqlc0lchS1gqAVxRgsuW1YrTJupqA= github.com/gofrs/uuid v4.4.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM= github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da h1:oI5xCqsCo564l8iNU+DwB5epxmsaqB+rhGL0m5jtYqE= github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= +github.com/golang/protobuf v1.1.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= -github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg= -github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= +github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= +github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek= +github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= +github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/google/uuid v1.4.0 h1:MtMxsa51/r9yyhkyLsVeVt0B+BGQZzpQiTQ4eHZ8bc4= -github.com/google/uuid v1.4.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= +github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/gorilla/securecookie v1.1.1 h1:miw7JPhV+b/lAHSXz4qd/nN9jRiAFV5FwjeKyCS8BvQ= github.com/gorilla/securecookie v1.1.1/go.mod h1:ra0sb63/xPlUeL+yeDciTfxMRAA+MP+HVt/4epWDjd4= github.com/gorilla/sessions v1.2.1 h1:DHd3rPN5lE3Ts3D8rKkQ8x/0kqfeNmBAaiSi+o7FsgI= @@ -87,8 +93,10 @@ github.com/hashicorp/go-checkpoint v0.5.0/go.mod h1:7nfLNL10NsxqO4iWuW6tWW0HjZuD github.com/hashicorp/go-cleanhttp v0.5.0/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= github.com/hashicorp/go-cleanhttp v0.5.2 h1:035FKYIWjmULyFRBKPs8TBQoi0x6d9G4xc9neXJWAZQ= github.com/hashicorp/go-cleanhttp v0.5.2/go.mod h1:kO/YDlP8L1346E6Sodw+PrpBSV4/SoxCXGY6BqNFT48= -github.com/hashicorp/go-hclog v1.5.0 h1:bI2ocEMgcVlz55Oj1xZNBsVi900c7II+fWDyV9o+13c= -github.com/hashicorp/go-hclog v1.5.0/go.mod h1:W4Qnvbt70Wk/zYJryRzDRU/4r0kIg0PVHBcfoyhpF5M= +github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320 h1:1/D3zfFHttUKaCaGKZ/dR2roBXv0vKbSCnssIldfQdI= +github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320/go.mod h1:EiZBMaudVLy8fmjf9Npq1dq9RalhveqZG5w/yz3mHWs= +github.com/hashicorp/go-hclog v1.6.3 h1:Qr2kF+eVWjTiYmU7Y31tYlP1h0q/X3Nl3tPGdaB11/k= +github.com/hashicorp/go-hclog v1.6.3/go.mod h1:W4Qnvbt70Wk/zYJryRzDRU/4r0kIg0PVHBcfoyhpF5M= github.com/hashicorp/go-multierror v1.0.0/go.mod h1:dHtQlpGsu+cZNNAkkCN/P3hoUDHhCYQXV3UM06sGGrk= github.com/hashicorp/go-multierror v1.1.1 h1:H5DkEtf6CXdFp0N0Em5UCwQpXMWke8IA0+lD48awMYo= github.com/hashicorp/go-multierror v1.1.1/go.mod h1:iw975J/qwKPdAO1clOe2L8331t/9/fmwbPZ6JB6eMoM= @@ -98,30 +106,38 @@ github.com/hashicorp/go-uuid v1.0.0/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/b github.com/hashicorp/go-uuid v1.0.2/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= github.com/hashicorp/go-uuid v1.0.3 h1:2gKiV6YVmrJ1i2CKKa9obLvRieoRGviZFL26PcT/Co8= github.com/hashicorp/go-uuid v1.0.3/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= -github.com/hashicorp/go-version v1.6.0 h1:feTTfFNnjP967rlCxM/I9g701jU+RN74YKx2mOkIeek= -github.com/hashicorp/go-version v1.6.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= -github.com/hashicorp/hc-install v0.6.2 h1:V1k+Vraqz4olgZ9UzKiAcbman9i9scg9GgSt/U3mw/M= -github.com/hashicorp/hc-install v0.6.2/go.mod h1:2JBpd+NCFKiHiu/yYCGaPyPHhZLxXTpz8oreHa/a3Ps= -github.com/hashicorp/terraform-exec v0.20.0 h1:DIZnPsqzPGuUnq6cH8jWcPunBfY+C+M8JyYF3vpnuEo= -github.com/hashicorp/terraform-exec v0.20.0/go.mod h1:ckKGkJWbsNqFKV1itgMnE0hY9IYf1HoiekpuN0eWoDw= -github.com/hashicorp/terraform-json v0.20.0 h1:cJcvn4gIOTi0SD7pIy+xiofV1zFA3hza+6K+fo52IX8= -github.com/hashicorp/terraform-json v0.20.0/go.mod h1:qdeBs11ovMzo5puhrRibdD6d2Dq6TyE/28JiU4tIQxk= +github.com/hashicorp/go-version v1.7.0 h1:5tqGy27NaOTB8yJKUZELlFAS/LTKJkrmONwQKeRZfjY= +github.com/hashicorp/go-version v1.7.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= +github.com/hashicorp/hc-install v0.7.0 h1:Uu9edVqjKQxxuD28mR5TikkKDd/p55S8vzPC1659aBk= +github.com/hashicorp/hc-install v0.7.0/go.mod h1:ELmmzZlGnEcqoUMKUuykHaPCIR1sYLYX+KSggWSKZuA= +github.com/hashicorp/hcl/v2 v2.21.0 h1:lve4q/o/2rqwYOgUg3y3V2YPyD1/zkCLGjIV74Jit14= +github.com/hashicorp/hcl/v2 v2.21.0/go.mod h1:62ZYHrXgPoX8xBnzl8QzbWq4dyDsDtfCRgIq1rbJEvA= +github.com/hashicorp/logutils v1.0.0 h1:dLEQVugN8vlakKOUE3ihGLTZJRB4j+M2cdTm/ORI65Y= +github.com/hashicorp/logutils v1.0.0/go.mod h1:QIAnNjmIWmVIIkWDTG1z5v++HQmx9WQRO+LraFDTW64= +github.com/hashicorp/terraform-exec v0.21.0 h1:uNkLAe95ey5Uux6KJdua6+cv8asgILFVWkd/RG0D2XQ= +github.com/hashicorp/terraform-exec v0.21.0/go.mod h1:1PPeMYou+KDUSSeRE9szMZ/oHf4fYUmB923Wzbq1ICg= +github.com/hashicorp/terraform-json v0.22.1 h1:xft84GZR0QzjPVWs4lRUwvTcPnegqlyS7orfb5Ltvec= +github.com/hashicorp/terraform-json v0.22.1/go.mod h1:JbWSQCLFSXFFhg42T7l9iJwdGXBYV8fmmD6o/ML4p3A= github.com/hashicorp/terraform-plugin-codegen-framework v0.3.1 h1:KxlB825szn9DOB7jQnWqSxaVZ5PfDdwLKqoSFDTdn2Y= github.com/hashicorp/terraform-plugin-codegen-framework v0.3.1/go.mod h1:Lu/w6jNYqHCl5U6C3TndDrAk/4icJ2wZfD3DhEIPOic= github.com/hashicorp/terraform-plugin-codegen-spec v0.1.1-0.20231024091233-c659ac8a54fc h1:VmMk5vOSJgpWOuBsI4ZBZkcsrkLq0fKoyKvKFnbBuxk= github.com/hashicorp/terraform-plugin-codegen-spec v0.1.1-0.20231024091233-c659ac8a54fc/go.mod h1:PQn6bDD8UWoAVJoHXqFk2i/RmLbeQBjbiP38i+E+YIw= github.com/hashicorp/terraform-plugin-docs v0.17.0 h1:H1Yc+bgB//Geau5g7YKkhG5v9tghI3vplfIYTOl85Uw= github.com/hashicorp/terraform-plugin-docs v0.17.0/go.mod h1:cKC8GSLE+0a0bi7LtlpXgrqnlRDCGoGDn15PTEA+Ang= -github.com/hashicorp/terraform-plugin-framework v1.5.0 h1:8kcvqJs/x6QyOFSdeAyEgsenVOUeC/IyKpi2ul4fjTg= -github.com/hashicorp/terraform-plugin-framework v1.5.0/go.mod h1:6waavirukIlFpVpthbGd2PUNYaFedB0RwW3MDzJ/rtc= +github.com/hashicorp/terraform-plugin-framework v1.11.0 h1:M7+9zBArexHFXDx/pKTxjE6n/2UCXY6b8FIq9ZYhwfE= +github.com/hashicorp/terraform-plugin-framework v1.11.0/go.mod h1:qBXLDn69kM97NNVi/MQ9qgd1uWWsVftGSnygYG1tImM= github.com/hashicorp/terraform-plugin-framework-timetypes v0.3.0 h1:egR4InfakWkgepZNUATWGwkrPhaAYOTEybPfEol+G/I= github.com/hashicorp/terraform-plugin-framework-timetypes v0.3.0/go.mod h1:9vjvl36aY1p6KltaA5QCvGC5hdE/9t4YuhGftw6WOgE= github.com/hashicorp/terraform-plugin-framework-validators v0.12.0 h1:HOjBuMbOEzl7snOdOoUfE2Jgeto6JOjLVQ39Ls2nksc= github.com/hashicorp/terraform-plugin-framework-validators v0.12.0/go.mod h1:jfHGE/gzjxYz6XoUwi/aYiiKrJDeutQNUtGQXkaHklg= -github.com/hashicorp/terraform-plugin-go v0.20.0 h1:oqvoUlL+2EUbKNsJbIt3zqqZ7wi6lzn4ufkn/UA51xQ= -github.com/hashicorp/terraform-plugin-go v0.20.0/go.mod h1:Rr8LBdMlY53a3Z/HpP+ZU3/xCDqtKNCkeI9qOyT10QE= +github.com/hashicorp/terraform-plugin-go v0.23.0 h1:AALVuU1gD1kPb48aPQUjug9Ir/125t+AAurhqphJ2Co= +github.com/hashicorp/terraform-plugin-go v0.23.0/go.mod h1:1E3Cr9h2vMlahWMbsSEcNrOCxovCZhOOIXjFHbjc/lQ= github.com/hashicorp/terraform-plugin-log v0.9.0 h1:i7hOA+vdAItN1/7UrfBqBwvYPQ9TFvymaRGZED3FCV0= github.com/hashicorp/terraform-plugin-log v0.9.0/go.mod h1:rKL8egZQ/eXSyDqzLUuwUYLVdlYeamldAHSxjUFADow= +github.com/hashicorp/terraform-plugin-sdk/v2 v2.34.0 h1:kJiWGx2kiQVo97Y5IOGR4EMcZ8DtMswHhUuFibsCQQE= +github.com/hashicorp/terraform-plugin-sdk/v2 v2.34.0/go.mod h1:sl/UoabMc37HA6ICVMmGO+/0wofkVIRxf+BMb/dnoIg= +github.com/hashicorp/terraform-plugin-testing v1.9.0 h1:xOsQRqqlHKXpFq6etTxih3ubdK3HVDtfE1IY7Rpd37o= +github.com/hashicorp/terraform-plugin-testing v1.9.0/go.mod h1:fhhVx/8+XNJZTD5o3b4stfZ6+q7z9+lIWigIYdT6/44= github.com/hashicorp/terraform-registry-address v0.2.3 h1:2TAiKJ1A3MAkZlH1YI/aTVcLZRu7JseiXNRHbOAyoTI= github.com/hashicorp/terraform-registry-address v0.2.3/go.mod h1:lFHA76T8jfQteVfT7caREqguFrW3c4MFSPhZB7HHgUM= github.com/hashicorp/terraform-svchost v0.1.1 h1:EZZimZ1GxdqFRinZ1tpJwVxxt49xc/S52uzrw4x0jKQ= @@ -154,8 +170,11 @@ github.com/jhump/protoreflect v1.15.1 h1:HUMERORf3I3ZdX05WaQ6MIpd/NJ434hTp5YiKgf github.com/jhump/protoreflect v1.15.1/go.mod h1:jD/2GMKKE6OqX8qTjhADU1e6DShO+gavG9e0Q693nKo= github.com/kevinburke/ssh_config v1.2.0 h1:x584FjTGwHzMwvHx18PXxbBVzfnxogHaAReU4gf13a4= github.com/kevinburke/ssh_config v1.2.0/go.mod h1:CT57kijsi8u/K/BOFA39wgDQJ9CxiF4nAY/ojJ6r6mM= +github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= +github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= +github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/masterzen/simplexml v0.0.0-20190410153822-31eea3082786 h1:2ZKn+w/BJeL43sCxI2jhPLRv73oVVOjEKZjKkflyqxg= @@ -182,6 +201,10 @@ github.com/mitchellh/copystructure v1.2.0 h1:vpKXTN4ewci03Vljg/q9QvCGUDttBOGBIa1 github.com/mitchellh/copystructure v1.2.0/go.mod h1:qLl+cE2AmVv+CoeAwDPye/v+N2HKCj9FbZEVFJRxO9s= github.com/mitchellh/go-testing-interface v1.14.1 h1:jrgshOhYAUVNMAJiKbEu7EqAwgJJ2JqpQmpLJOu07cU= github.com/mitchellh/go-testing-interface v1.14.1/go.mod h1:gfgS7OtZj6MA4U1UrDRp04twqAjfvlZyCfX3sDjEym8= +github.com/mitchellh/go-wordwrap v1.0.0 h1:6GlHJ/LTGMrIJbwgdqdl2eEH8o+Exx/0m8ir9Gns0u4= +github.com/mitchellh/go-wordwrap v1.0.0/go.mod h1:ZXFpozHsX6DPmq2I0TCekCxypsnAUbP2oI0UX1GXzOo= +github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY= +github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= github.com/mitchellh/reflectwalk v1.0.0/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw= github.com/mitchellh/reflectwalk v1.0.2 h1:G2LzWKi524PWgd3mLHV8Y5k7s6XUvT0Gef6zxSIeXaQ= github.com/mitchellh/reflectwalk v1.0.2/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw= @@ -198,13 +221,13 @@ github.com/rogpeppe/go-internal v1.12.0 h1:exVL4IDcn6na9z1rAb56Vxr+CgyK3nn3O+epU github.com/rogpeppe/go-internal v1.12.0/go.mod h1:E+RYuTGaKKdloAfM02xzb0FW3Paa99yedzYV+kq4uf4= github.com/russross/blackfriday v1.6.0 h1:KqfZb0pUVN2lYqZUYRddxF4OR8ZMURnJIG5Y3VRLtww= github.com/russross/blackfriday v1.6.0/go.mod h1:ti0ldHuxg49ri4ksnFxlkCfN+hvslNlmVHqNRXXJNAY= -github.com/sergi/go-diff v1.2.0 h1:XU+rvMAioB0UC3q1MFrIQy4Vo5/4VsRDQQXHsEya6xQ= -github.com/sergi/go-diff v1.2.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM= +github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3 h1:n661drycOFuPLCN3Uc8sB6B/s6Z4t2xvBgU1htSHuq8= +github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3/go.mod h1:A0bzQcvG0E7Rwjx0REVgAGH58e96+X0MeOfepqsbeW4= github.com/shopspring/decimal v1.2.0/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o= github.com/shopspring/decimal v1.3.1 h1:2Usl1nmF/WZucqkFZhnfFYxxxu8LG21F6nPQBE5gKV8= github.com/shopspring/decimal v1.3.1/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o= -github.com/skeema/knownhosts v1.2.1 h1:SHWdIUa82uGZz+F+47k8SY4QhhI291cXCpopT1lK2AQ= -github.com/skeema/knownhosts v1.2.1/go.mod h1:xYbVRSPxqBZFrdmDyMmsOs+uX1UZC3nTN3ThzgDxUwo= +github.com/skeema/knownhosts v1.2.2 h1:Iug2P4fLmDw9f41PB6thxUkNUkJzB5i+1/exaj40L3A= +github.com/skeema/knownhosts v1.2.2/go.mod h1:xYbVRSPxqBZFrdmDyMmsOs+uX1UZC3nTN3ThzgDxUwo= github.com/spf13/cast v1.3.1/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE= github.com/spf13/cast v1.5.1 h1:R+kOtfhWQE6TVQzY+4D7wJLBgkdVasCEFxSUBYBYIlA= github.com/spf13/cast v1.5.1/go.mod h1:b9PdjNptOpzXr7Rq1q9gJML/2cdGQAo69NKzQ10KN48= @@ -226,6 +249,9 @@ github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsT github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= github.com/tidwall/transform v0.0.0-20201103190739-32f242e2dbde h1:AMNpJRc7P+GTwVbl8DkK2I9I8BBUzNiHuH/tlxrpan0= github.com/tidwall/transform v0.0.0-20201103190739-32f242e2dbde/go.mod h1:MvrEmduDUz4ST5pGZ7CABCnOU5f3ZiOAZzT6b1A6nX8= +github.com/vmihailenco/msgpack v3.3.3+incompatible/go.mod h1:fy3FlTQTDXWkZ7Bh6AcGMlsjHatGryHQYUTf1ShIgkk= +github.com/vmihailenco/msgpack v4.0.4+incompatible h1:dSLoQfGFAo3F6OoNhwUmLwVgaUXK79GlxNBwueZn0xI= +github.com/vmihailenco/msgpack v4.0.4+incompatible/go.mod h1:fy3FlTQTDXWkZ7Bh6AcGMlsjHatGryHQYUTf1ShIgkk= github.com/vmihailenco/msgpack/v5 v5.4.1 h1:cQriyiUvjTwOHg8QZaPihLWeRAAVoCpE00IUPn0Bjt8= github.com/vmihailenco/msgpack/v5 v5.4.1/go.mod h1:GaZTsDaehaPpQVyxrf5mtQlH+pc21PIudVV/E3rRQok= github.com/vmihailenco/tagparser/v2 v2.0.0 h1:y09buUbR+b5aycVFQs/g70pqKVZNBmxwAhO7/IwNM9g= @@ -244,24 +270,23 @@ github.com/yuin/goldmark v1.6.0 h1:boZcn2GTjpsynOsC0iJHnBWa4Bi0qzfJjthwauItG68= github.com/yuin/goldmark v1.6.0/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= github.com/yuin/goldmark-meta v1.1.0 h1:pWw+JLHGZe8Rk0EGsMVssiNb/AaPMHfSRszZeUeiOUc= github.com/yuin/goldmark-meta v1.1.0/go.mod h1:U4spWENafuA7Zyg+Lj5RqK/MF+ovMYtBvXi1lBb2VP0= -github.com/zclconf/go-cty v1.14.1 h1:t9fyA35fwjjUMcmL5hLER+e/rEPqrbCK1/OSE4SI9KA= -github.com/zclconf/go-cty v1.14.1/go.mod h1:VvMs5i0vgZdhYawQNq5kePSpLAoz8u1xvZgrPIxfnZE= +github.com/zclconf/go-cty v1.14.4 h1:uXXczd9QDGsgu0i/QFR/hzI5NYCHLf6NQw/atrbnhq8= +github.com/zclconf/go-cty v1.14.4/go.mod h1:VvMs5i0vgZdhYawQNq5kePSpLAoz8u1xvZgrPIxfnZE= +github.com/zclconf/go-cty-debug v0.0.0-20240509010212-0d6042c53940 h1:4r45xpDWB6ZMSMNJFMOjqrGHynW3DIBuR2H9j0ug+Mo= +github.com/zclconf/go-cty-debug v0.0.0-20240509010212-0d6042c53940/go.mod h1:CmBdvvj3nqzfzJ6nTCIwDTPZ56aVGvDrmztiO5g3qrM= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20200414173820-0848c9571904/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200820211705-5c72a883971a/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.3.0/go.mod h1:hebNnKkNXi2UzZN1eVRvBB7co0a+JxK6XbPiWVs/3J4= -golang.org/x/crypto v0.3.1-0.20221117191849-2c476679df9a/go.mod h1:hebNnKkNXi2UzZN1eVRvBB7co0a+JxK6XbPiWVs/3J4= golang.org/x/crypto v0.6.0/go.mod h1:OFC/31mSvZgRz0V1QTNCzfAI1aIRzbiufJtkMIlEp58= -golang.org/x/crypto v0.7.0/go.mod h1:pYwdfH91IfpZVANVyUOhSIPZaFoJGxTFbZhFTx+dXZU= -golang.org/x/crypto v0.22.0 h1:g1v0xeRhjcugydODzvb3mEM9SQ0HGp9s/nh3COQ/C30= -golang.org/x/crypto v0.22.0/go.mod h1:vr6Su+7cTlO45qkww3VDJlzDn0ctJvRgYbC2NvXHt+M= +golang.org/x/crypto v0.25.0 h1:ypSNr+bnYL2YhwoMt2zPxHFmbAN1KZs/njMG3hxUp30= +golang.org/x/crypto v0.25.0/go.mod h1:T+wALwcMOSE0kXgUAnPAHqTLW+XHgcELELW8VaDgm/M= golang.org/x/exp v0.0.0-20230809150735-7b3493d9a819 h1:EDuYyU/MkFXllv9QF9819VlI9a4tzGuCbhG0ExK9o1U= golang.org/x/exp v0.0.0-20230809150735-7b3493d9a819/go.mod h1:FXUEEKJgO7OQYeo8N01OfiKP8RXMtf6e8aTskBGqWdc= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= -golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= -golang.org/x/mod v0.14.0 h1:dGoOF9QVLYng8IHTm7BAyWqCqSheQ5pYWGhzW00YJr0= -golang.org/x/mod v0.14.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= +golang.org/x/mod v0.17.0 h1:zY54UmvipHiNd+pm+m0x9KhZ9hl1/7QNMyxXbc6ICqA= +golang.org/x/mod v0.17.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200114155413-6afb5195e5aa/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= @@ -270,12 +295,13 @@ golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug golang.org/x/net v0.2.0/go.mod h1:KqCZLdyyvdV855qA2rE3GC2aiw5xGR5TEjj8smXukLY= golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= -golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc= -golang.org/x/net v0.23.0 h1:7EYJ93RZ9vYSZAIb2x3lnuvqO5zneoD6IvWjuhfxjTs= -golang.org/x/net v0.23.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg= +golang.org/x/net v0.25.0 h1:d/OCCoBEUq33pjydKrGQhw7IlUPI2Oylr+8qLx49kac= +golang.org/x/net v0.25.0/go.mod h1:JkAGAh7GEvH74S6FOH42FLoXpXbE/aqXSrIQjXgsiwM= +golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M= +golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -289,42 +315,43 @@ golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.3.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.19.0 h1:q5f1RH2jigJ1MoAWp2KTp3gm5zAGFUTarQZ5U386+4o= -golang.org/x/sys v0.19.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.22.0 h1:RI27ohtqKCnwULzJLqkv897zojh5/DwS/ENaMzUOaWI= +golang.org/x/sys v0.22.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.2.0/go.mod h1:TVmDHMZPmdnySmBfhjOoOdhjzdE1h4u1VwSiw2l1Nuc= golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= -golang.org/x/term v0.6.0/go.mod h1:m6U89DPEgQRMq3DNkDClhWw02AUbt2daBVO4cn4Hv9U= -golang.org/x/term v0.19.0 h1:+ThwsDv+tYfnJFhF4L8jITxu1tdTWRTZpdsWgEgjL6Q= -golang.org/x/term v0.19.0/go.mod h1:2CuTdWZ7KHSQwUzKva0cbMg6q2DMI3Mmxp+gKJbskEk= +golang.org/x/term v0.22.0 h1:BbsgPEJULsl2fV/AT3v15Mjva5yXKQDyKf+TbDz7QJk= +golang.org/x/term v0.22.0/go.mod h1:F3qCibpT5AMpCRfhfT53vVJwhLtIVHhB9XDjfFvnMI4= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= +golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ= golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= -golang.org/x/text v0.8.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= -golang.org/x/text v0.15.0 h1:h1V/4gjBv8v9cjcR6+AR5+/cIYK5N/WAgiv4xlsEtAk= -golang.org/x/text v0.15.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= +golang.org/x/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4= +golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= -golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU= -golang.org/x/tools v0.17.0 h1:FvmRgNOcs3kOa+T20R1uhfP9F6HgG2mfxDv1vrx1Htc= -golang.org/x/tools v0.17.0/go.mod h1:xsh6VxdV005rRVaS6SSAf9oiAqljS7UZUacMZ8Bnsps= +golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d h1:vU5i/LfpvrRCpgM/VPfJLg5KjxD3E+hfT1SH+d9zLwg= +golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d/go.mod h1:aiJjzUbINMkxbQROHiO6hDPo2LHcIPhhQsa9DLh0yGk= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -google.golang.org/genproto/googleapis/rpc v0.0.0-20231002182017-d307bd883b97 h1:6GQBEOdGkX6MMTLT9V+TjtIRZCw9VPD5Z+yHY9wMgS0= -google.golang.org/genproto/googleapis/rpc v0.0.0-20231002182017-d307bd883b97/go.mod h1:v7nGkzlmW8P3n/bKmWBn2WpBjpOEx8Q6gMueudAmKfY= -google.golang.org/grpc v1.60.0 h1:6FQAR0kM31P6MRdeluor2w2gPaS4SVNrD/DNTxrQ15k= -google.golang.org/grpc v1.60.0/go.mod h1:OlCHIeLYqSSsLi6i49B5QGdzaMZK9+M7LXN2FKz4eGM= +google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= +google.golang.org/appengine v1.6.8 h1:IhEN5q69dyKagZPYMSdIjS2HqprW324FRQZJcGqPAsM= +google.golang.org/appengine v1.6.8/go.mod h1:1jJ3jBArFh5pcgW8gCtRJnepW8FzD1V44FJffLiz/Ds= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240227224415-6ceb2ff114de h1:cZGRis4/ot9uVm639a+rHCUaG0JJHEsdyzSQTMX+suY= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240227224415-6ceb2ff114de/go.mod h1:H4O17MA/PE9BsGx3w+a+W2VOLLD1Qf7oJneAoU6WktY= +google.golang.org/grpc v1.63.2 h1:MUeiw1B2maTVZthpU5xvASfTh3LDbxHd6IJ6QQVU+xM= +google.golang.org/grpc v1.63.2/go.mod h1:WAX/8DgncnokcFUldAxq7GeB5DXHDbMF+lLvDomNkRA= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= -google.golang.org/protobuf v1.31.0 h1:g0LDEJHgrBl9N9r17Ru3sqWhkIx2NB67okBHPwC7hs8= -google.golang.org/protobuf v1.31.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= +google.golang.org/protobuf v1.34.0 h1:Qo/qEd2RZPCf2nKuorzksSknv0d3ERwp1vFG38gSmH4= +google.golang.org/protobuf v1.34.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= diff --git a/internal/provider/configure.go b/internal/provider/configure.go index aabef5d..c5542ba 100644 --- a/internal/provider/configure.go +++ b/internal/provider/configure.go @@ -5,9 +5,9 @@ import ( "context" "fmt" + "github.com/d-strobel/terraform-provider-windows/internal/generate/provider_windows" "os" "strconv" - "terraform-provider-windows/internal/generate/provider_windows" "github.com/hashicorp/terraform-plugin-framework/provider" "github.com/hashicorp/terraform-plugin-log/tflog" diff --git a/internal/provider/local/local_group_data_source.go b/internal/provider/local/local_group_data_source.go index 598b327..633c87b 100644 --- a/internal/provider/local/local_group_data_source.go +++ b/internal/provider/local/local_group_data_source.go @@ -3,7 +3,7 @@ package local import ( "context" "fmt" - "terraform-provider-windows/internal/generate/datasource_local_group" + "github.com/d-strobel/terraform-provider-windows/internal/generate/datasource_local_group" "github.com/d-strobel/gowindows" "github.com/d-strobel/gowindows/windows/local/accounts" diff --git a/internal/provider/local/local_group_member_resource.go b/internal/provider/local/local_group_member_resource.go index ed0921b..8c0243f 100644 --- a/internal/provider/local/local_group_member_resource.go +++ b/internal/provider/local/local_group_member_resource.go @@ -3,7 +3,7 @@ package local import ( "context" "fmt" - "terraform-provider-windows/internal/generate/resource_local_group_member" + "github.com/d-strobel/terraform-provider-windows/internal/generate/resource_local_group_member" "github.com/d-strobel/gowindows" "github.com/d-strobel/gowindows/windows/local/accounts" diff --git a/internal/provider/local/local_group_members_data_source.go b/internal/provider/local/local_group_members_data_source.go index 24b59e6..4116017 100644 --- a/internal/provider/local/local_group_members_data_source.go +++ b/internal/provider/local/local_group_members_data_source.go @@ -3,7 +3,7 @@ package local import ( "context" "fmt" - "terraform-provider-windows/internal/generate/datasource_local_group_members" + "github.com/d-strobel/terraform-provider-windows/internal/generate/datasource_local_group_members" "github.com/d-strobel/gowindows" "github.com/d-strobel/gowindows/windows/local/accounts" diff --git a/internal/provider/local/local_group_resource.go b/internal/provider/local/local_group_resource.go index d7dbc6e..3136f45 100644 --- a/internal/provider/local/local_group_resource.go +++ b/internal/provider/local/local_group_resource.go @@ -3,7 +3,7 @@ package local import ( "context" "fmt" - "terraform-provider-windows/internal/generate/resource_local_group" + "github.com/d-strobel/terraform-provider-windows/internal/generate/resource_local_group" "github.com/d-strobel/gowindows" "github.com/d-strobel/gowindows/windows/local/accounts" diff --git a/internal/provider/local/local_groups_data_source.go b/internal/provider/local/local_groups_data_source.go index 9252eda..aaab1dc 100644 --- a/internal/provider/local/local_groups_data_source.go +++ b/internal/provider/local/local_groups_data_source.go @@ -3,7 +3,7 @@ package local import ( "context" "fmt" - "terraform-provider-windows/internal/generate/datasource_local_groups" + "github.com/d-strobel/terraform-provider-windows/internal/generate/datasource_local_groups" "github.com/d-strobel/gowindows" "github.com/d-strobel/gowindows/winerror" diff --git a/internal/provider/local/local_user_data_source.go b/internal/provider/local/local_user_data_source.go index a86650b..264561f 100644 --- a/internal/provider/local/local_user_data_source.go +++ b/internal/provider/local/local_user_data_source.go @@ -3,7 +3,7 @@ package local import ( "context" "fmt" - "terraform-provider-windows/internal/generate/datasource_local_user" + "github.com/d-strobel/terraform-provider-windows/internal/generate/datasource_local_user" "time" "github.com/d-strobel/gowindows" diff --git a/internal/provider/local/local_user_resource.go b/internal/provider/local/local_user_resource.go index 736ad0a..9ff787f 100644 --- a/internal/provider/local/local_user_resource.go +++ b/internal/provider/local/local_user_resource.go @@ -3,8 +3,8 @@ package local import ( "context" "fmt" + "github.com/d-strobel/terraform-provider-windows/internal/generate/resource_local_user" "regexp" - "terraform-provider-windows/internal/generate/resource_local_user" "time" "github.com/d-strobel/gowindows" diff --git a/internal/provider/local/local_users_data_source.go b/internal/provider/local/local_users_data_source.go index f727288..bb7a76f 100644 --- a/internal/provider/local/local_users_data_source.go +++ b/internal/provider/local/local_users_data_source.go @@ -3,7 +3,7 @@ package local import ( "context" "fmt" - "terraform-provider-windows/internal/generate/datasource_local_users" + "github.com/d-strobel/terraform-provider-windows/internal/generate/datasource_local_users" "time" "github.com/d-strobel/gowindows" diff --git a/internal/provider/provider.go b/internal/provider/provider.go index 469ed1c..f302124 100644 --- a/internal/provider/provider.go +++ b/internal/provider/provider.go @@ -2,8 +2,8 @@ package provider import ( "context" - "terraform-provider-windows/internal/generate/provider_windows" - "terraform-provider-windows/internal/provider/local" + "github.com/d-strobel/terraform-provider-windows/internal/generate/provider_windows" + "github.com/d-strobel/terraform-provider-windows/internal/provider/local" "github.com/hashicorp/terraform-plugin-framework/datasource" "github.com/hashicorp/terraform-plugin-framework/provider" diff --git a/internal/provider/validate.go b/internal/provider/validate.go index 61c2a14..47bbe71 100644 --- a/internal/provider/validate.go +++ b/internal/provider/validate.go @@ -3,8 +3,8 @@ package provider import ( "context" "fmt" + "github.com/d-strobel/terraform-provider-windows/internal/generate/provider_windows" "os" - "terraform-provider-windows/internal/generate/provider_windows" "github.com/hashicorp/terraform-plugin-framework-validators/providervalidator" "github.com/hashicorp/terraform-plugin-framework/path" diff --git a/main.go b/main.go index 41ed305..2cc109b 100644 --- a/main.go +++ b/main.go @@ -5,7 +5,7 @@ import ( "flag" "log" - "terraform-provider-windows/internal/provider" + "github.com/d-strobel/terraform-provider-windows/internal/provider" "github.com/hashicorp/terraform-plugin-framework/providerserver" ) From c75d32d948cb68c25939d17316201fdbd5c0d173 Mon Sep 17 00:00:00 2001 From: Dustin Strobel Date: Thu, 26 Sep 2024 23:58:23 +0200 Subject: [PATCH 04/27] test: add helper acctest package --- internal/acctest/acctest.go | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 internal/acctest/acctest.go diff --git a/internal/acctest/acctest.go b/internal/acctest/acctest.go new file mode 100644 index 0000000..5d10d55 --- /dev/null +++ b/internal/acctest/acctest.go @@ -0,0 +1,29 @@ +package acctest + +import ( + "github.com/d-strobel/terraform-provider-windows/internal/provider" + "github.com/hashicorp/terraform-plugin-framework/providerserver" + "github.com/hashicorp/terraform-plugin-go/tfprotov6" +) + +// TestAccProtoV6ProviderFactories are used to instantiate a provider during acceptance testing. +var TestAccProtoV6ProviderFactories = map[string]func() (tfprotov6.ProviderServer, error){ + "windows": providerserver.NewProtocol6WithError(provider.New("test")()), +} + +// ProviderConfig returns a provider configuration for use in acceptance tests. +func ProviderConfig() string { + return ` +provider "windows" { + endpoint = "127.0.0.1" + + winrm = { + username = "vagrant" + password = "vagrant" + port = 15985 + insecure = true + use_tls = false + } +} +` +} From 885a2e4caaf65e46d61b6ef088b6c6cd6e5e149a Mon Sep 17 00:00:00 2001 From: Dustin Strobel Date: Fri, 27 Sep 2024 00:01:19 +0200 Subject: [PATCH 05/27] chore: fmt json --- internal/schema/provider_windows.json | 244 +++++++++++++------------- 1 file changed, 122 insertions(+), 122 deletions(-) diff --git a/internal/schema/provider_windows.json b/internal/schema/provider_windows.json index d934535..2a077ce 100644 --- a/internal/schema/provider_windows.json +++ b/internal/schema/provider_windows.json @@ -1,129 +1,129 @@ { - "version": "0.1", - "provider": { - "name": "windows", - "schema": { + "version": "0.1", + "provider": { + "name": "windows", + "schema": { + "attributes": [ + { + "name": "endpoint", + "string": { + "optional_required": "required", + "description": "Define the hostname or ip-address of the target Windows system." + } + }, + { + "name": "ssh", + "single_nested": { + "optional_required": "optional", + "description": "Define the SSH connection parameters. Exactly one of 'winrm' or 'ssh' must be set for the provider to connect to a Windows target system. Define an empty 'ssh' attribute if you wish to use the environment variables.", "attributes": [ - { - "name": "endpoint", - "string": { - "optional_required": "required", - "description": "Define the hostname or ip-address of the target Windows system." - } - }, - { - "name": "ssh", - "single_nested": { - "optional_required": "optional", - "description": "Define the SSH connection parameters. Exactly one of 'winrm' or 'ssh' must be set for the provider to connect to a Windows target system. Define an empty 'ssh' attribute if you wish to use the environment variables.", - "attributes": [ - { - "name": "insecure", - "bool": { - "optional_required": "optional", - "description": "(Env: `WIN_SSH_INSECURE`) (Default: `false`)
Accept insecure SSH connections. This includes e.g. the acceptance of unknown or changed host keys." - } - }, - { - "name": "known_hosts_path", - "string": { - "optional_required": "optional", - "description": "(Env: `WIN_SSH_KNOWN_HOSTS_PATH`)
Define the path to the known hosts file to connect with the target Windows system." - } - }, - { - "name": "password", - "string": { - "optional_required": "optional", - "sensitive": true, - "description": "(Env: `WIN_SSH_PASSWORD`)
Define the password to connect with the target Windows system. Exactly one of 'password', 'private_key' or 'private_key_path' is required if ssh is set." - } - }, - { - "name": "port", - "int64": { - "optional_required": "optional", - "description": "(Env: `WIN_SSH_PORT`) (Default: `22`)
Define the port to connect with the target Windows system." - } - }, - { - "name": "private_key", - "string": { - "optional_required": "optional", - "sensitive": true, - "description": "(Env: `WIN_SSH_PRIVATE_KEY`)
Define the private key to connect with the target Windows system. Exactly one of 'password', 'private_key' or 'private_key_path' is required if ssh is set." - } - }, - { - "name": "private_key_path", - "string": { - "optional_required": "optional", - "description": "(Env: `WIN_SSH_PRIVATE_KEY_PATH`)
Define the path to the private key file to connect with the target Windows system. Exactly one of 'password', 'private_key' or 'private_key_path' is required if ssh is set." - } - }, - { - "name": "username", - "string": { - "optional_required": "optional", - "description": "(Env: `WIN_SSH_USERNAME`)
Define the username to connect with the target Windows system. Required if ssh is set." - } - } - ] - } - }, - { - "name": "winrm", - "single_nested": { - "optional_required": "optional", - "description": "Define the WinRM connection parameters. Exactly one of 'winrm' or 'ssh' must be set for the provider to connect to a Windows target system. Define an empty 'winrm' attribute if you wish to use the environment variables.", - "attributes": [ - { - "name": "insecure", - "bool": { - "optional_required": "optional", - "description": "(Env: `WIN_WINRM_INSECURE`) (Default: `false`)
Accept insecure WinRM connection. This includes e.g. the acceptance of untrusted certificates." - } - }, - { - "name": "password", - "string": { - "optional_required": "optional", - "description": "(Env: `WIN_WINRM_PASSWORD`)
Define the password to connect with the target Windows system. Required if winrm is set.", - "sensitive": true - } - }, - { - "name": "port", - "int64": { - "optional_required": "optional", - "description": "(Env: `WIN_WINRM_PORT`) (Default: `5986`)
Define the port to connect with the target Windows system." - } - }, - { - "name": "timeout", - "int64": { - "optional_required": "optional", - "description": "(Env: `WIN_WINRM_TIMEOUT`) (Default: `0`)
Define the connection timeout in minutes for the target Windows system." - } - }, - { - "name": "use_tls", - "bool": { - "optional_required": "optional", - "description": "(Env: `WIN_WINRM_USE_TLS`) (Default: `true`)
Define if TLS (https) should be used to connect with the target Windows system." - } - }, - { - "name": "username", - "string": { - "optional_required": "optional", - "description": "(Env: `WIN_WINRM_USERNAME`)
Define the username to connect with the target Windows system. Required if winrm is set." - } - } - ] - } + { + "name": "insecure", + "bool": { + "optional_required": "optional", + "description": "(Env: `WIN_SSH_INSECURE`) (Default: `false`)
Accept insecure SSH connections. This includes e.g. the acceptance of unknown or changed host keys." } + }, + { + "name": "known_hosts_path", + "string": { + "optional_required": "optional", + "description": "(Env: `WIN_SSH_KNOWN_HOSTS_PATH`)
Define the path to the known hosts file to connect with the target Windows system." + } + }, + { + "name": "password", + "string": { + "optional_required": "optional", + "sensitive": true, + "description": "(Env: `WIN_SSH_PASSWORD`)
Define the password to connect with the target Windows system. Exactly one of 'password', 'private_key' or 'private_key_path' is required if ssh is set." + } + }, + { + "name": "port", + "int64": { + "optional_required": "optional", + "description": "(Env: `WIN_SSH_PORT`) (Default: `22`)
Define the port to connect with the target Windows system." + } + }, + { + "name": "private_key", + "string": { + "optional_required": "optional", + "sensitive": true, + "description": "(Env: `WIN_SSH_PRIVATE_KEY`)
Define the private key to connect with the target Windows system. Exactly one of 'password', 'private_key' or 'private_key_path' is required if ssh is set." + } + }, + { + "name": "private_key_path", + "string": { + "optional_required": "optional", + "description": "(Env: `WIN_SSH_PRIVATE_KEY_PATH`)
Define the path to the private key file to connect with the target Windows system. Exactly one of 'password', 'private_key' or 'private_key_path' is required if ssh is set." + } + }, + { + "name": "username", + "string": { + "optional_required": "optional", + "description": "(Env: `WIN_SSH_USERNAME`)
Define the username to connect with the target Windows system. Required if ssh is set." + } + } + ] + } + }, + { + "name": "winrm", + "single_nested": { + "optional_required": "optional", + "description": "Define the WinRM connection parameters. Exactly one of 'winrm' or 'ssh' must be set for the provider to connect to a Windows target system. Define an empty 'winrm' attribute if you wish to use the environment variables.", + "attributes": [ + { + "name": "insecure", + "bool": { + "optional_required": "optional", + "description": "(Env: `WIN_WINRM_INSECURE`) (Default: `false`)
Accept insecure WinRM connection. This includes e.g. the acceptance of untrusted certificates." + } + }, + { + "name": "password", + "string": { + "optional_required": "optional", + "description": "(Env: `WIN_WINRM_PASSWORD`)
Define the password to connect with the target Windows system. Required if winrm is set.", + "sensitive": true + } + }, + { + "name": "port", + "int64": { + "optional_required": "optional", + "description": "(Env: `WIN_WINRM_PORT`) (Default: `5986`)
Define the port to connect with the target Windows system." + } + }, + { + "name": "timeout", + "int64": { + "optional_required": "optional", + "description": "(Env: `WIN_WINRM_TIMEOUT`) (Default: `0`)
Define the connection timeout in minutes for the target Windows system." + } + }, + { + "name": "use_tls", + "bool": { + "optional_required": "optional", + "description": "(Env: `WIN_WINRM_USE_TLS`) (Default: `true`)
Define if TLS (https) should be used to connect with the target Windows system." + } + }, + { + "name": "username", + "string": { + "optional_required": "optional", + "description": "(Env: `WIN_WINRM_USERNAME`)
Define the username to connect with the target Windows system. Required if winrm is set." + } + } ] + } } + ] } + } } From 5ffa632bbfe84ca29f0f497451f2206666a8955a Mon Sep 17 00:00:00 2001 From: Dustin Strobel Date: Fri, 27 Sep 2024 00:06:59 +0200 Subject: [PATCH 06/27] test: add test for data-source windows_local_group --- .../local/local_group_data_source_test.go | 50 +++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 internal/provider/local/local_group_data_source_test.go diff --git a/internal/provider/local/local_group_data_source_test.go b/internal/provider/local/local_group_data_source_test.go new file mode 100644 index 0000000..6d7dd1c --- /dev/null +++ b/internal/provider/local/local_group_data_source_test.go @@ -0,0 +1,50 @@ +package local_test + +import ( + "testing" + + "github.com/d-strobel/terraform-provider-windows/internal/acctest" + "github.com/hashicorp/terraform-plugin-testing/helper/resource" +) + +func TestAccLocalGroupDataSource(t *testing.T) { + resource.Test(t, resource.TestCase{ + ProtoV6ProviderFactories: acctest.TestAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + // Check if the data source works with name + { + Config: acctest.ProviderConfig() + ` + data "windows_local_group" "test" { + name = "Administrators" + } + `, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("data.windows_local_group.test", "id", "S-1-5-32-544"), + resource.TestCheckResourceAttr("data.windows_local_group.test", "sid", "S-1-5-32-544"), + resource.TestCheckResourceAttr("data.windows_local_group.test", "name", "Administrators"), + resource.TestCheckResourceAttr("data.windows_local_group.test", "description", "Administrators have complete and unrestricted access to the computer/domain"), + ), + }, + // Check if the data source works with SID + { + Config: acctest.ProviderConfig() + ` + data "windows_local_group" "test" { + sid = "S-1-5-32-544" + } + `, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("data.windows_local_group.test", "id", "S-1-5-32-544"), + resource.TestCheckResourceAttr("data.windows_local_group.test", "sid", "S-1-5-32-544"), + resource.TestCheckResourceAttr("data.windows_local_group.test", "name", "Administrators"), + resource.TestCheckResourceAttr("data.windows_local_group.test", "description", "Administrators have complete and unrestricted access to the computer/domain"), + ), + }, + }, + }) +} + +// const testAccLocalGroupDataSourceConfig = ` +// data "windows_local_group" "test" { +// name = "Administrators" +// } +// ` From debc50b310cf59e7f0204506541cfd7fc26cdfc5 Mon Sep 17 00:00:00 2001 From: Dustin Strobel Date: Fri, 27 Sep 2024 00:10:52 +0200 Subject: [PATCH 07/27] chore: remove old code --- internal/provider/local/local_group_data_source_test.go | 6 ------ 1 file changed, 6 deletions(-) diff --git a/internal/provider/local/local_group_data_source_test.go b/internal/provider/local/local_group_data_source_test.go index 6d7dd1c..66a4a4a 100644 --- a/internal/provider/local/local_group_data_source_test.go +++ b/internal/provider/local/local_group_data_source_test.go @@ -42,9 +42,3 @@ func TestAccLocalGroupDataSource(t *testing.T) { }, }) } - -// const testAccLocalGroupDataSourceConfig = ` -// data "windows_local_group" "test" { -// name = "Administrators" -// } -// ` From 20b0d9974230602564e6e5d8a53ed60487c10bf0 Mon Sep 17 00:00:00 2001 From: Dustin Strobel Date: Fri, 27 Sep 2024 00:15:05 +0200 Subject: [PATCH 08/27] docs: add acctest package comment --- internal/acctest/acctest.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/internal/acctest/acctest.go b/internal/acctest/acctest.go index 5d10d55..e23048d 100644 --- a/internal/acctest/acctest.go +++ b/internal/acctest/acctest.go @@ -1,3 +1,4 @@ +// package acctest contains utilities for acceptance testing. package acctest import ( @@ -6,7 +7,8 @@ import ( "github.com/hashicorp/terraform-plugin-go/tfprotov6" ) -// TestAccProtoV6ProviderFactories are used to instantiate a provider during acceptance testing. +// TestAccProtoV6ProviderFactories are used to instantiate a provider during acceptance testing +// and should therefore be imported in the test files. var TestAccProtoV6ProviderFactories = map[string]func() (tfprotov6.ProviderServer, error){ "windows": providerserver.NewProtocol6WithError(provider.New("test")()), } From 3a17933f844538d4740177d4b43daef0b31053f0 Mon Sep 17 00:00:00 2001 From: Dustin Strobel Date: Sun, 29 Sep 2024 00:30:17 +0200 Subject: [PATCH 09/27] test: add test for windows_local_group resource --- .../local/local_group_resource_test.go | 41 +++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 internal/provider/local/local_group_resource_test.go diff --git a/internal/provider/local/local_group_resource_test.go b/internal/provider/local/local_group_resource_test.go new file mode 100644 index 0000000..9692654 --- /dev/null +++ b/internal/provider/local/local_group_resource_test.go @@ -0,0 +1,41 @@ +package local_test + +import ( + "testing" + + "github.com/d-strobel/terraform-provider-windows/internal/acctest" + "github.com/hashicorp/terraform-plugin-testing/helper/resource" +) + +func TestAccLocalGroupResource(t *testing.T) { + resource.Test(t, resource.TestCase{ + ProtoV6ProviderFactories: acctest.TestAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + // Create and Read testing + { + Config: acctest.ProviderConfig() + ` + resource "windows_local_group" "test" { + name = "Test" + } + `, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("windows_local_group.test", "name", "Test"), + resource.TestCheckResourceAttr("windows_local_group.test", "description", " "), + ), + }, + // Update and Read testing + { + Config: acctest.ProviderConfig() + ` + resource "windows_local_group" "test" { + name = "Test" + description = "Test description" + } + `, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("windows_local_group.test", "name", "Test"), + resource.TestCheckResourceAttr("windows_local_group.test", "description", "Test description"), + ), + }, + }, + }) +} From a887aa31bc26a19376e584d23c1ed2b0ba8deac5 Mon Sep 17 00:00:00 2001 From: Dustin Strobel Date: Sun, 29 Sep 2024 01:43:16 +0200 Subject: [PATCH 10/27] test: add test for windows_local_groups data-source --- .../local/local_groups_data_source_test.go | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 internal/provider/local/local_groups_data_source_test.go diff --git a/internal/provider/local/local_groups_data_source_test.go b/internal/provider/local/local_groups_data_source_test.go new file mode 100644 index 0000000..c3a7cbf --- /dev/null +++ b/internal/provider/local/local_groups_data_source_test.go @@ -0,0 +1,34 @@ +package local_test + +import ( + "testing" + + "github.com/d-strobel/terraform-provider-windows/internal/acctest" + "github.com/hashicorp/terraform-plugin-testing/helper/resource" +) + +func TestAccLocalGroupsDataSource(t *testing.T) { + resource.Test(t, resource.TestCase{ + ProtoV6ProviderFactories: acctest.TestAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + // Read testing + { + Config: acctest.ProviderConfig() + ` + data "windows_local_groups" "test" {} + `, + Check: resource.ComposeAggregateTestCheckFunc( + // Check first group in the list + resource.TestCheckResourceAttr("data.windows_local_groups.test", "groups.0.id", "S-1-5-32-579"), + resource.TestCheckResourceAttr("data.windows_local_groups.test", "groups.0.sid", "S-1-5-32-579"), + resource.TestCheckResourceAttr("data.windows_local_groups.test", "groups.0.name", "Access Control Assistance Operators"), + resource.TestCheckResourceAttr("data.windows_local_groups.test", "groups.0.description", "Members of this group can remotely query authorization attributes and permissions for resources on this computer."), + // Check second group in the list + resource.TestCheckResourceAttr("data.windows_local_groups.test", "groups.1.id", "S-1-5-32-544"), + resource.TestCheckResourceAttr("data.windows_local_groups.test", "groups.1.sid", "S-1-5-32-544"), + resource.TestCheckResourceAttr("data.windows_local_groups.test", "groups.1.name", "Administrators"), + resource.TestCheckResourceAttr("data.windows_local_groups.test", "groups.1.description", "Administrators have complete and unrestricted access to the computer/domain"), + ), + }, + }, + }) +} From 4fe3cc1bdf452c3c81525237eac534c5ac02d1db Mon Sep 17 00:00:00 2001 From: Dustin Strobel Date: Sun, 29 Sep 2024 02:53:07 +0200 Subject: [PATCH 11/27] test: add test for windows_local_user resource --- .../local/local_user_resource_test.go | 146 ++++++++++++++++++ 1 file changed, 146 insertions(+) create mode 100644 internal/provider/local/local_user_resource_test.go diff --git a/internal/provider/local/local_user_resource_test.go b/internal/provider/local/local_user_resource_test.go new file mode 100644 index 0000000..a263f4b --- /dev/null +++ b/internal/provider/local/local_user_resource_test.go @@ -0,0 +1,146 @@ +package local_test + +import ( + "testing" + + "github.com/d-strobel/terraform-provider-windows/internal/acctest" + "github.com/hashicorp/terraform-plugin-testing/helper/resource" +) + +func TestAccLocalUserResource(t *testing.T) { + resource.Test(t, resource.TestCase{ + ProtoV6ProviderFactories: acctest.TestAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + // Create and Read testing only name + { + Config: acctest.ProviderConfig() + ` + resource "windows_local_user" "test_1" { + name = "test-1" + } + `, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("windows_local_user.test_1", "name", "test-1"), + resource.TestCheckResourceAttr("windows_local_user.test_1", "full_name", ""), + resource.TestCheckResourceAttr("windows_local_user.test_1", "description", ""), + resource.TestCheckNoResourceAttr("windows_local_user.test_1", "password"), + resource.TestCheckResourceAttr("windows_local_user.test_1", "enabled", "true"), + resource.TestCheckResourceAttr("windows_local_user.test_1", "account_expires", "0001-01-01T00:00:00Z"), + resource.TestCheckResourceAttr("windows_local_user.test_1", "password_never_expires", "true"), + resource.TestCheckResourceAttr("windows_local_user.test_1", "user_may_change_password", "true"), + resource.TestCheckResourceAttr("windows_local_user.test_1", "last_logon", "0001-01-01T00:00:00Z"), + resource.TestCheckResourceAttr("windows_local_user.test_1", "password_changeable_date", "0001-01-01T00:00:00Z"), + resource.TestCheckResourceAttr("windows_local_user.test_1", "password_expires", "0001-01-01T00:00:00Z"), + resource.TestCheckResourceAttr("windows_local_user.test_1", "password_last_set", "0001-01-01T00:00:00Z"), + resource.TestCheckResourceAttrSet("windows_local_user.test_1", "id"), + resource.TestCheckResourceAttrSet("windows_local_user.test_1", "sid"), + ), + }, + // Update and Read testing only name + { + Config: acctest.ProviderConfig() + ` + resource "windows_local_user" "test_1" { + name = "test-1" + enabled = false + } + `, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("windows_local_user.test_1", "name", "test-1"), + resource.TestCheckResourceAttr("windows_local_user.test_1", "full_name", ""), + resource.TestCheckResourceAttr("windows_local_user.test_1", "description", ""), + resource.TestCheckNoResourceAttr("windows_local_user.test_1", "password"), + resource.TestCheckResourceAttr("windows_local_user.test_1", "enabled", "false"), + resource.TestCheckResourceAttr("windows_local_user.test_1", "account_expires", "0001-01-01T00:00:00Z"), + resource.TestCheckResourceAttr("windows_local_user.test_1", "password_never_expires", "true"), + resource.TestCheckResourceAttr("windows_local_user.test_1", "user_may_change_password", "true"), + resource.TestCheckResourceAttr("windows_local_user.test_1", "last_logon", "0001-01-01T00:00:00Z"), + resource.TestCheckResourceAttr("windows_local_user.test_1", "password_changeable_date", "0001-01-01T00:00:00Z"), + resource.TestCheckResourceAttr("windows_local_user.test_1", "password_expires", "0001-01-01T00:00:00Z"), + resource.TestCheckResourceAttr("windows_local_user.test_1", "password_last_set", "0001-01-01T00:00:00Z"), + resource.TestCheckResourceAttrSet("windows_local_user.test_1", "id"), + resource.TestCheckResourceAttrSet("windows_local_user.test_1", "sid"), + ), + }, + // Create and Read testing with name + password + { + Config: acctest.ProviderConfig() + ` + resource "windows_local_user" "test_2" { + name = "test-2" + password = "Supersecretpassword1234" + } + `, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("windows_local_user.test_2", "name", "test-2"), + resource.TestCheckResourceAttr("windows_local_user.test_2", "full_name", ""), + resource.TestCheckResourceAttr("windows_local_user.test_2", "description", ""), + resource.TestCheckResourceAttr("windows_local_user.test_2", "enabled", "true"), + resource.TestCheckResourceAttr("windows_local_user.test_2", "password", "Supersecretpassword1234"), + resource.TestCheckResourceAttr("windows_local_user.test_2", "account_expires", "0001-01-01T00:00:00Z"), + resource.TestCheckResourceAttr("windows_local_user.test_2", "password_never_expires", "true"), + resource.TestCheckResourceAttr("windows_local_user.test_2", "user_may_change_password", "true"), + resource.TestCheckResourceAttr("windows_local_user.test_2", "last_logon", "0001-01-01T00:00:00Z"), + resource.TestCheckResourceAttr("windows_local_user.test_2", "password_expires", "0001-01-01T00:00:00Z"), + resource.TestCheckResourceAttrSet("windows_local_user.test_2", "password_changeable_date"), + resource.TestCheckResourceAttrSet("windows_local_user.test_2", "password_last_set"), + resource.TestCheckResourceAttrSet("windows_local_user.test_2", "id"), + resource.TestCheckResourceAttrSet("windows_local_user.test_2", "sid"), + ), + }, + // Update and Read testing with name + password + { + Config: acctest.ProviderConfig() + ` + resource "windows_local_user" "test_2" { + name = "test-2" + password = "NEWSupersecretpassword1234" + } + `, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("windows_local_user.test_2", "name", "test-2"), + resource.TestCheckResourceAttr("windows_local_user.test_2", "full_name", ""), + resource.TestCheckResourceAttr("windows_local_user.test_2", "description", ""), + resource.TestCheckResourceAttr("windows_local_user.test_2", "enabled", "true"), + resource.TestCheckResourceAttr("windows_local_user.test_2", "password", "NEWSupersecretpassword1234"), + resource.TestCheckResourceAttr("windows_local_user.test_2", "account_expires", "0001-01-01T00:00:00Z"), + resource.TestCheckResourceAttr("windows_local_user.test_2", "password_never_expires", "true"), + resource.TestCheckResourceAttr("windows_local_user.test_2", "user_may_change_password", "true"), + resource.TestCheckResourceAttr("windows_local_user.test_2", "last_logon", "0001-01-01T00:00:00Z"), + resource.TestCheckResourceAttr("windows_local_user.test_2", "password_expires", "0001-01-01T00:00:00Z"), + resource.TestCheckResourceAttrSet("windows_local_user.test_2", "password_changeable_date"), + resource.TestCheckResourceAttrSet("windows_local_user.test_2", "password_last_set"), + resource.TestCheckResourceAttrSet("windows_local_user.test_2", "id"), + resource.TestCheckResourceAttrSet("windows_local_user.test_2", "sid"), + ), + }, + // Create and Read testing with all possible parameters + { + Config: acctest.ProviderConfig() + ` + resource "windows_local_user" "test_3" { + name = "test-3" + full_name = "Test User 3" + description = "Test user for Terraform test" + password = "SuperSecretPassword123!" + account_expires = "2072-12-31T23:59:59Z" + enabled = false + password_never_expires = false + user_may_change_password = false + } + `, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("windows_local_user.test_3", "name", "test-3"), + resource.TestCheckResourceAttr("windows_local_user.test_3", "full_name", "Test User 3"), + resource.TestCheckResourceAttr("windows_local_user.test_3", "description", "Test user for Terraform test"), + resource.TestCheckResourceAttr("windows_local_user.test_3", "password", "SuperSecretPassword123!"), + resource.TestCheckResourceAttr("windows_local_user.test_3", "account_expires", "2072-12-31T23:59:59Z"), + resource.TestCheckResourceAttr("windows_local_user.test_3", "enabled", "false"), + resource.TestCheckResourceAttr("windows_local_user.test_3", "password_never_expires", "false"), + resource.TestCheckResourceAttr("windows_local_user.test_3", "user_may_change_password", "false"), + resource.TestCheckResourceAttr("windows_local_user.test_3", "last_logon", "0001-01-01T00:00:00Z"), + resource.TestCheckResourceAttrSet("windows_local_user.test_3", "password_expires"), + resource.TestCheckResourceAttrSet("windows_local_user.test_3", "password_changeable_date"), + resource.TestCheckResourceAttrSet("windows_local_user.test_3", "password_last_set"), + resource.TestCheckResourceAttrSet("windows_local_user.test_3", "id"), + resource.TestCheckResourceAttrSet("windows_local_user.test_3", "sid"), + ), + }, + }, + }) +} From 10d026b1de132996797ee8d8b3d75bfad1e1542c Mon Sep 17 00:00:00 2001 From: Dustin Strobel Date: Sun, 29 Sep 2024 23:16:20 +0200 Subject: [PATCH 12/27] test: add test for windows_local_user data-source --- .../local/local_user_data_source_test.go | 60 +++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 internal/provider/local/local_user_data_source_test.go diff --git a/internal/provider/local/local_user_data_source_test.go b/internal/provider/local/local_user_data_source_test.go new file mode 100644 index 0000000..eb18ae2 --- /dev/null +++ b/internal/provider/local/local_user_data_source_test.go @@ -0,0 +1,60 @@ +package local_test + +import ( + "testing" + + "github.com/d-strobel/terraform-provider-windows/internal/acctest" + "github.com/hashicorp/terraform-plugin-testing/helper/resource" +) + +func TestAccLocalUserDataSource(t *testing.T) { + resource.Test(t, resource.TestCase{ + ProtoV6ProviderFactories: acctest.TestAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + // Read testing with name + { + Config: acctest.ProviderConfig() + ` + data "windows_local_user" "test" { + name = "Administrator" + } + `, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("data.windows_local_user.test", "name", "Administrator"), + resource.TestCheckResourceAttr("data.windows_local_user.test", "full_name", ""), + resource.TestCheckResourceAttr("data.windows_local_user.test", "description", "Built-in account for administering the computer/domain"), + resource.TestCheckResourceAttr("data.windows_local_user.test", "account_expires", "0001-01-01T00:00:00Z"), + resource.TestCheckResourceAttr("data.windows_local_user.test", "enabled", "true"), + resource.TestCheckResourceAttr("data.windows_local_user.test", "user_may_change_password", "true"), + resource.TestCheckResourceAttr("data.windows_local_user.test", "last_logon", "0001-01-01T00:00:00Z"), + resource.TestCheckResourceAttrSet("data.windows_local_user.test", "password_expires"), + resource.TestCheckResourceAttrSet("data.windows_local_user.test", "password_changeable_date"), + resource.TestCheckResourceAttrSet("data.windows_local_user.test", "password_last_set"), + resource.TestCheckResourceAttr("data.windows_local_user.test", "id", "S-1-5-21-153895498-367353507-3704405138-500"), + resource.TestCheckResourceAttr("data.windows_local_user.test", "sid", "S-1-5-21-153895498-367353507-3704405138-500"), + ), + }, + // Read testing with SID + { + Config: acctest.ProviderConfig() + ` + data "windows_local_user" "test" { + sid = "S-1-5-21-153895498-367353507-3704405138-500" + } + `, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("data.windows_local_user.test", "name", "Administrator"), + resource.TestCheckResourceAttr("data.windows_local_user.test", "full_name", ""), + resource.TestCheckResourceAttr("data.windows_local_user.test", "description", "Built-in account for administering the computer/domain"), + resource.TestCheckResourceAttr("data.windows_local_user.test", "account_expires", "0001-01-01T00:00:00Z"), + resource.TestCheckResourceAttr("data.windows_local_user.test", "enabled", "true"), + resource.TestCheckResourceAttr("data.windows_local_user.test", "user_may_change_password", "true"), + resource.TestCheckResourceAttr("data.windows_local_user.test", "last_logon", "0001-01-01T00:00:00Z"), + resource.TestCheckResourceAttrSet("data.windows_local_user.test", "password_expires"), + resource.TestCheckResourceAttrSet("data.windows_local_user.test", "password_changeable_date"), + resource.TestCheckResourceAttrSet("data.windows_local_user.test", "password_last_set"), + resource.TestCheckResourceAttr("data.windows_local_user.test", "id", "S-1-5-21-153895498-367353507-3704405138-500"), + resource.TestCheckResourceAttr("data.windows_local_user.test", "sid", "S-1-5-21-153895498-367353507-3704405138-500"), + ), + }, + }, + }) +} From 9f37d2aa2132ec54039d75951ce448e908beb4e7 Mon Sep 17 00:00:00 2001 From: Dustin Strobel Date: Sun, 29 Sep 2024 23:26:32 +0200 Subject: [PATCH 13/27] test: add test for windows_local_users data-source --- .../local/local_users_data_source_test.go | 50 +++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 internal/provider/local/local_users_data_source_test.go diff --git a/internal/provider/local/local_users_data_source_test.go b/internal/provider/local/local_users_data_source_test.go new file mode 100644 index 0000000..73e21ef --- /dev/null +++ b/internal/provider/local/local_users_data_source_test.go @@ -0,0 +1,50 @@ +package local_test + +import ( + "testing" + + "github.com/d-strobel/terraform-provider-windows/internal/acctest" + "github.com/hashicorp/terraform-plugin-testing/helper/resource" +) + +func TestAccLocalUsersDataSource(t *testing.T) { + resource.Test(t, resource.TestCase{ + ProtoV6ProviderFactories: acctest.TestAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + // Read testing with name + { + Config: acctest.ProviderConfig() + ` + data "windows_local_users" "test" {} + `, + Check: resource.ComposeAggregateTestCheckFunc( + // Check first user in the list + resource.TestCheckResourceAttr("data.windows_local_users.test", "users.0.name", "Administrator"), + resource.TestCheckResourceAttr("data.windows_local_users.test", "users.0.full_name", ""), + resource.TestCheckResourceAttr("data.windows_local_users.test", "users.0.description", "Built-in account for administering the computer/domain"), + resource.TestCheckResourceAttr("data.windows_local_users.test", "users.0.account_expires", "0001-01-01T00:00:00Z"), + resource.TestCheckResourceAttr("data.windows_local_users.test", "users.0.enabled", "true"), + resource.TestCheckResourceAttr("data.windows_local_users.test", "users.0.user_may_change_password", "true"), + resource.TestCheckResourceAttr("data.windows_local_users.test", "users.0.last_logon", "0001-01-01T00:00:00Z"), + resource.TestCheckResourceAttrSet("data.windows_local_users.test", "users.0.password_expires"), + resource.TestCheckResourceAttrSet("data.windows_local_users.test", "users.0.password_changeable_date"), + resource.TestCheckResourceAttrSet("data.windows_local_users.test", "users.0.password_last_set"), + resource.TestCheckResourceAttr("data.windows_local_users.test", "users.0.id", "S-1-5-21-153895498-367353507-3704405138-500"), + resource.TestCheckResourceAttr("data.windows_local_users.test", "users.0.sid", "S-1-5-21-153895498-367353507-3704405138-500"), + // Check second user in the list + resource.TestCheckResourceAttr("data.windows_local_users.test", "users.1.name", "DefaultAccount"), + resource.TestCheckResourceAttr("data.windows_local_users.test", "users.1.full_name", ""), + resource.TestCheckResourceAttr("data.windows_local_users.test", "users.1.description", "A user account managed by the system."), + resource.TestCheckResourceAttr("data.windows_local_users.test", "users.1.account_expires", "0001-01-01T00:00:00Z"), + resource.TestCheckResourceAttr("data.windows_local_users.test", "users.1.enabled", "false"), + resource.TestCheckResourceAttr("data.windows_local_users.test", "users.1.user_may_change_password", "true"), + resource.TestCheckResourceAttr("data.windows_local_users.test", "users.1.last_logon", "0001-01-01T00:00:00Z"), + resource.TestCheckResourceAttrSet("data.windows_local_users.test", "users.1.password_expires"), + resource.TestCheckResourceAttrSet("data.windows_local_users.test", "users.1.password_changeable_date"), + resource.TestCheckResourceAttrSet("data.windows_local_users.test", "users.1.password_last_set"), + resource.TestCheckResourceAttr("data.windows_local_users.test", "users.1.id", "S-1-5-21-153895498-367353507-3704405138-503"), + resource.TestCheckResourceAttr("data.windows_local_users.test", "users.1.sid", "S-1-5-21-153895498-367353507-3704405138-503"), + ), + }, + }, + }) +} From fab828261b4c44c1e4405e42ee732322ecc9b8b3 Mon Sep 17 00:00:00 2001 From: Dustin Strobel Date: Sun, 29 Sep 2024 23:40:10 +0200 Subject: [PATCH 14/27] test: add test for windows_local_group_members data-source --- .../local_group_members_data_source_test.go | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 internal/provider/local/local_group_members_data_source_test.go diff --git a/internal/provider/local/local_group_members_data_source_test.go b/internal/provider/local/local_group_members_data_source_test.go new file mode 100644 index 0000000..e929eba --- /dev/null +++ b/internal/provider/local/local_group_members_data_source_test.go @@ -0,0 +1,36 @@ +package local_test + +import ( + "regexp" + "testing" + + "github.com/d-strobel/terraform-provider-windows/internal/acctest" + "github.com/hashicorp/terraform-plugin-testing/helper/resource" +) + +func TestAccLocalGroupMembersDataSource(t *testing.T) { + resource.Test(t, resource.TestCase{ + ProtoV6ProviderFactories: acctest.TestAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + // Read testing + { + Config: acctest.ProviderConfig() + ` + data "windows_local_group_members" "test" { + name = "Administrators" + } + `, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("data.windows_local_group_members.test", "name", "Administrators"), + // Check first group in the list + resource.TestCheckResourceAttr("data.windows_local_group_members.test", "members.0.sid", "S-1-5-21-153895498-367353507-3704405138-500"), + resource.TestCheckResourceAttr("data.windows_local_group_members.test", "members.0.object_class", "User"), + resource.TestMatchResourceAttr("data.windows_local_group_members.test", "members.0.name", regexp.MustCompile(`Administrator$`)), + // Check second group in the list + resource.TestCheckResourceAttr("data.windows_local_group_members.test", "members.1.sid", "S-1-5-21-153895498-367353507-3704405138-1000"), + resource.TestCheckResourceAttr("data.windows_local_group_members.test", "members.1.object_class", "User"), + resource.TestMatchResourceAttr("data.windows_local_group_members.test", "members.1.name", regexp.MustCompile(`vagrant$`)), + ), + }, + }, + }) +} From 0bec0756f7af0c9b5f61a8e1c8150f44faba4a34 Mon Sep 17 00:00:00 2001 From: Dustin Strobel Date: Sun, 29 Sep 2024 23:57:11 +0200 Subject: [PATCH 15/27] test: add test for windows_local_group_member resource --- .../local/local_group_member_resource_test.go | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 internal/provider/local/local_group_member_resource_test.go diff --git a/internal/provider/local/local_group_member_resource_test.go b/internal/provider/local/local_group_member_resource_test.go new file mode 100644 index 0000000..c696609 --- /dev/null +++ b/internal/provider/local/local_group_member_resource_test.go @@ -0,0 +1,30 @@ +package local_test + +import ( + "testing" + + "github.com/d-strobel/terraform-provider-windows/internal/acctest" + "github.com/hashicorp/terraform-plugin-testing/helper/resource" +) + +func TestAccLocalGroupMemberResource(t *testing.T) { + resource.Test(t, resource.TestCase{ + ProtoV6ProviderFactories: acctest.TestAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + // Create and Read testing with Guest user in Administrators group + { + Config: acctest.ProviderConfig() + ` + resource "windows_local_group_member" "test" { + group_id = "S-1-5-32-544" + member_id = "S-1-5-21-153895498-367353507-3704405138-501" + } + `, + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("windows_local_group_member.test", "group_id", "S-1-5-32-544"), + resource.TestCheckResourceAttr("windows_local_group_member.test", "member_id", "S-1-5-21-153895498-367353507-3704405138-501"), + resource.TestCheckResourceAttr("windows_local_group_member.test", "id", "S-1-5-32-544/member/S-1-5-21-153895498-367353507-3704405138-501"), + ), + }, + }, + }) +} From 9d93a0a3a985e13c8920bfaf5c9fd90f50c589c3 Mon Sep 17 00:00:00 2001 From: Dustin Strobel Date: Sun, 13 Oct 2024 14:06:11 +0200 Subject: [PATCH 16/27] chore: rename test environment variables --- vagrant/vagrant.env | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/vagrant/vagrant.env b/vagrant/vagrant.env index 1b74d47..cc4ebd2 100644 --- a/vagrant/vagrant.env +++ b/vagrant/vagrant.env @@ -1,18 +1,18 @@ # Connections variables for the default windows host -export GOWINDOWS_TEST_HOST=127.0.0.1 -export GOWINDOWS_TEST_USERNAME=vagrant -export GOWINDOWS_TEST_PASSWORD=vagrant -export GOWINDOWS_TEST_SSH_PORT=1222 -export GOWINDOWS_TEST_SSH_PRIVATE_KEY_ED25519_PATH=./fixtures/ed25519 -export GOWINDOWS_TEST_SSH_PRIVATE_KEY_RSA_PATH=./fixtures/id_rsa -export GOWINDOWS_TEST_WINRM_HTTP_PORT=15985 -export GOWINDOWS_TEST_WINRM_HTTPS_PORT=15986 +export TFWINDOWS_TEST_HOST=127.0.0.1 +export TFWINDOWS_TEST_USERNAME=vagrant +export TFWINDOWS_TEST_PASSWORD=vagrant +export TFWINDOWS_TEST_SSH_PORT=1222 +export TFWINDOWS_TEST_SSH_PRIVATE_KEY_ED25519_PATH=../acctest/fixtures/ed25519 +export TFWINDOWS_TEST_SSH_PRIVATE_KEY_RSA_PATH=../acctest/fixtures/id_rsa +export TFWINDOWS_TEST_WINRM_HTTP_PORT=15985 +export TFWINDOWS_TEST_WINRM_HTTPS_PORT=15986 # Connection variables for the Active-Directory host -export GOWINDOWS_TEST_AD_HOST=127.0.0.1 -export GOWINDOWS_TEST_AD_USERNAME=vagrant -export GOWINDOWS_TEST_AD_USERNAME_PRE2K=vagrant\vagrant -export GOWINDOWS_TEST_AD_PASSWORD=vagrant -export GOWINDOWS_TEST_AD_SSH_PORT=2222 -export GOWINDOWS_TEST_AD_WINRM_HTTP_PORT=25985 -export GOWINDOWS_TEST_AD_WINRM_HTTPS_PORT=25986 +export TFWINDOWS_TEST_AD_HOST=127.0.0.1 +export TFWINDOWS_TEST_AD_USERNAME=vagrant +export TFWINDOWS_TEST_AD_USERNAME_PRE2K=vagrant\vagrant +export TFWINDOWS_TEST_AD_PASSWORD=vagrant +export TFWINDOWS_TEST_AD_SSH_PORT=2222 +export TFWINDOWS_TEST_AD_WINRM_HTTP_PORT=25985 +export TFWINDOWS_TEST_AD_WINRM_HTTPS_PORT=25986 From d2b1afe5fe945cfc350a27c9cbe83593bf61251d Mon Sep 17 00:00:00 2001 From: Dustin Strobel Date: Sun, 13 Oct 2024 14:08:23 +0200 Subject: [PATCH 17/27] chore: add test fixture files --- internal/acctest/fixtures/ed25519 | 7 ++++++ internal/acctest/fixtures/id_rsa | 38 +++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+) create mode 100644 internal/acctest/fixtures/ed25519 create mode 100644 internal/acctest/fixtures/id_rsa diff --git a/internal/acctest/fixtures/ed25519 b/internal/acctest/fixtures/ed25519 new file mode 100644 index 0000000..ff7df17 --- /dev/null +++ b/internal/acctest/fixtures/ed25519 @@ -0,0 +1,7 @@ +-----BEGIN OPENSSH PRIVATE KEY----- +b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAAAMwAAAAtzc2gtZW +QyNTUxOQAAACCNKqLkDaaa4KGp+xaT0X94XVxGiwG6RHsymEc9/m39hwAAAJjpeDkr6Xg5 +KwAAAAtzc2gtZWQyNTUxOQAAACCNKqLkDaaa4KGp+xaT0X94XVxGiwG6RHsymEc9/m39hw +AAAEAMT15+Ut2N+m9HW9wXgIeVR+qKeoT3UlVCxxnPsnoA5o0qouQNpprgoan7FpPRf3hd +XEaLAbpEezKYRz3+bf2HAAAAD2RzdHJvYmVsQE5CMDc4NAECAwQFBg== +-----END OPENSSH PRIVATE KEY----- diff --git a/internal/acctest/fixtures/id_rsa b/internal/acctest/fixtures/id_rsa new file mode 100644 index 0000000..d620d25 --- /dev/null +++ b/internal/acctest/fixtures/id_rsa @@ -0,0 +1,38 @@ +-----BEGIN OPENSSH PRIVATE KEY----- +b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAABlwAAAAdzc2gtcn +NhAAAAAwEAAQAAAYEAiVJ+GYhQ8iKuxH0nCytGLLks/Or1plM7NNUouGzz3u0wHFq+56EN +S0xIoOAwhhyONGCveSZIrynptNWY1dSnTOGVUOxinvDwrJmvJxS+zoXZmP+BYeIwe9wDNf +tnVPuLcHuaf1so+SztiQp5rrb0rou3ycVX9rDqQBZ6CvXxF8vDvKD3DyhqullAB8TPU0wz +mBkSKfvQk8CrOOGcGENalTUJeODZNVcyUWzICddGBmDx/G1S6q8CBOI8nHayO8qrSgGAwa +RIXQGPhfkpyPP6AjmC9ViNOWBiX+kzULMP/jLv7ElLXqrq7gX8AlDT7bckRcek0MXvquEU +hwo0RmlOON+q3g1+TVIdGSrpmYzEPPnxTKvND25BrH0TAACgDn243ET/P7JmgjEV/g0sJr +wdNOYJ5vES7VKx9TN1YXJNkEZiZUFtn2Obm/bajHz3+STq2OeRjisJFWjEwA1HE+6LdtUA +x6KKh+PO9lL5KSjeNMjGGLlSOccAVVY9aIgCm74lAAAFiFgjsIpYI7CKAAAAB3NzaC1yc2 +EAAAGBAIlSfhmIUPIirsR9JwsrRiy5LPzq9aZTOzTVKLhs897tMBxavuehDUtMSKDgMIYc +jjRgr3kmSK8p6bTVmNXUp0zhlVDsYp7w8KyZrycUvs6F2Zj/gWHiMHvcAzX7Z1T7i3B7mn +9bKPks7YkKea629K6Lt8nFV/aw6kAWegr18RfLw7yg9w8oarpZQAfEz1NMM5gZEin70JPA +qzjhnBhDWpU1CXjg2TVXMlFsyAnXRgZg8fxtUuqvAgTiPJx2sjvKq0oBgMGkSF0Bj4X5Kc +jz+gI5gvVYjTlgYl/pM1CzD/4y7+xJS16q6u4F/AJQ0+23JEXHpNDF76rhFIcKNEZpTjjf +qt4Nfk1SHRkq6ZmMxDz58UyrzQ9uQax9EwAAoA59uNxE/z+yZoIxFf4NLCa8HTTmCebxEu +1SsfUzdWFyTZBGYmVBbZ9jm5v22ox89/kk6tjnkY4rCRVoxMANRxPui3bVAMeiiofjzvZS ++Sko3jTIxhi5UjnHAFVWPWiIApu+JQAAAAMBAAEAAAGAAKRLMpNZqOyb/+qDiMVB3GqBIi +1270t9baHIQTj3/RdMZtWFvJiIqahId8Emwgv7i96MYRtssmTfwHQIPkC7mbc9UkN/aVot +xcVNh67xIw8YgvVll6+Eper4KyhqxX95vjX6PkvX6b/sANf01Q58sa+Q58B/yL44oy93tN +VoRnjELNjvKhVBs5Qbxjap06weWsDDPhyzvNh3YhpirhXHEgbftr6fadKwyYLq7Gn+SclX +6nYYVkBx/WYjkBeifZvnJiLBob8pVycIppsv5NxF86wC967Y5VoCQBo0J4OpgvrJtI5TUD +rHumN5Eg+Zxcbh2mkYuAcakx7Ryhg3I8dqFgjBVX6YtWIsZipgCdVGOqa15t1U9SR1T97S +LFUu3BQ+6dara/mo9oCGtSCN/AF5KvaZUEW+ORhGfynkebCuuMh5hWE7kNjO9YNZ1okMsI +ekRQrznSTcakD2ieFQYL1Fxxv2vXVH+5BQfAF+PUrBg+R0LbOEFLEhI8en3s8Ci2ABAAAA +wQC7IyEzZgNP1ttwOtoHHAKMcFTGZ2AMPJSHC7XegyHwhdmvA/WBM8D9cP4ygELPDis4hR +TPtF8+D3MLaSyEHsbk5ZJpdYfn6PhkYlaTNykIiSd5MLGL2IucKs8w0QCsdGVP8MLTelhX +AreSS/0LCvJdhfGkHiQx6ebBtZWhhpydwFqoN6QZPj2H+KzMjawfonvusrNjZ5Qt5bXr1+ +FslaH7eFzsK3+Blfwo6UGEOh/kEe32dp7Xv4lRWd+BTD85wCoAAADBAMIopxPNiwRTgnZT +yptxJLJPNEnlZutClzZ5qAG2DN/YHnhwYn1usYu9YFkBrjjWCZoVYDTxUVhWHKfdUO27ay +JHL80ZnD51/k+CdYVsYYS8+mWe5Ty8am3nQZ3nQmk4WXVx1+mrGcfci2Ny17zIUKJygHR1 +baqNON+tgZ0YJ5h8YxeU/P/cRgmk5bgOpY4fwzjCKm49/wdatMcAokxfQv/Qyrun6Gh+yx +QHahVB0tHZXfAtWjn+LyoHur1hBV7fwQAAAMEAtQ9+COCTxUM6+VVua/A+bsB1nI9Sjo3j +MDhnfAmHHpT98PS4anhwSaNUK50jH1EssdPzbiDFibxbaAHTlwWkQ/tlmpAhmN5zhPOBwV +uOuOK2EEm1/mglxpfuRQZ1bS7Pzw3NPq0zwa7BGkOrWTYpV2wkLn7QQxI7dqF6UyVEQ+xe +tWbfmfZNbBdGW5HV38IZM+bDs5a4pULkhZcsnZVMcb1pZUZTFoyd4o2Azz/sCeLt/7o9jo +i4DQejeXYY2zdlAAAAD2RzdHJvYmVsQE5CMDc4NAECAw== +-----END OPENSSH PRIVATE KEY----- From d921d9a5208a3a12afa051182afbd0b6ce578c7d Mon Sep 17 00:00:00 2001 From: Dustin Strobel Date: Sun, 13 Oct 2024 14:23:50 +0200 Subject: [PATCH 18/27] test: add opentofu acctesting to Makefile --- Makefile | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 1846fb9..3d0b119 100644 --- a/Makefile +++ b/Makefile @@ -17,7 +17,30 @@ generate: @printf "$(OK_COLOR)==> Go generate$(NO_COLOR)\n" @go generate ./... +# Setup requirements +.PHONY: vagrant-up +vagrant-up: + @printf "$(OK_COLOR)==> Setup vagrant machines$(NO_COLOR)\n" + @$(MAKE) -C vagrant vagrant-up + +# Remove requirements +.PHONY: vagrant-down +vagrant-down: + @printf "$(OK_COLOR)==> Remove vagrant machines$(NO_COLOR)\n" + @$(MAKE) -C vagrant vagrant-down + # Run acceptance tests .PHONY: testacc -testacc: +testacc: testacc-terraform testacc-opentofu + +# Run Terraform acceptance tests +.PHONY: testacc-terraform +testacc-terraform: + @printf "$(OK_COLOR)==> Run Terraform acceptance tests$(NO_COLOR)\n" TF_ACC=1 go test ./internal/provider/... -v $(TESTARGS) -timeout 120m + +# Run OpenTofu acceptance tests +.PHONY: testacc-opentofu +testacc-opentofu: + @printf "$(OK_COLOR)==> Run OpenTofu acceptance tests$(NO_COLOR)\n" + TF_ACC_TERRAFORM_PATH="$(shell which tofu)" TF_ACC_PROVIDER_NAMESPACE="hashicorp" TF_ACC_PROVIDER_HOST="registry.opentofu.org" TF_ACC=1 go test ./internal/provider/... -v $(TESTARGS) -timeout 120m From ad0d9a1b359e1be72409e2c3633bb711e24d65ec Mon Sep 17 00:00:00 2001 From: Dustin Strobel Date: Sun, 13 Oct 2024 23:38:20 +0200 Subject: [PATCH 19/27] chore(deps): update go mod --- go.mod | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/go.mod b/go.mod index 119bae7..c06b0a7 100644 --- a/go.mod +++ b/go.mod @@ -17,6 +17,7 @@ require ( require ( github.com/agext/levenshtein v1.2.2 // indirect + github.com/davecgh/go-spew v1.1.1 // indirect github.com/google/go-cmp v0.6.0 // indirect github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320 // indirect github.com/hashicorp/hcl/v2 v2.21.0 // indirect @@ -24,10 +25,12 @@ require ( github.com/hashicorp/terraform-plugin-sdk/v2 v2.34.0 // indirect github.com/mitchellh/go-wordwrap v1.0.0 // indirect github.com/mitchellh/mapstructure v1.5.0 // indirect + github.com/pmezard/go-difflib v1.0.0 // indirect github.com/vmihailenco/msgpack v4.0.4+incompatible // indirect golang.org/x/sync v0.7.0 // indirect golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d // indirect google.golang.org/appengine v1.6.8 // indirect + gopkg.in/yaml.v3 v3.0.1 // indirect ) require ( @@ -88,6 +91,7 @@ require ( github.com/russross/blackfriday v1.6.0 // indirect github.com/shopspring/decimal v1.3.1 // indirect github.com/spf13/cast v1.5.1 // indirect + github.com/stretchr/testify v1.9.0 github.com/tidwall/transform v0.0.0-20201103190739-32f242e2dbde // indirect github.com/vmihailenco/msgpack/v5 v5.4.1 // indirect github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect From 2fb251d2ed0b0bbede6e3c140f0b68248ac0511a Mon Sep 17 00:00:00 2001 From: Dustin Strobel Date: Sun, 13 Oct 2024 23:51:34 +0200 Subject: [PATCH 20/27] test: add acctest for provider configs --- internal/acctest/acctest.go | 36 ++++-- internal/provider/provider_test.go | 194 +++++++++++++++++++++++++++++ 2 files changed, 217 insertions(+), 13 deletions(-) create mode 100644 internal/provider/provider_test.go diff --git a/internal/acctest/acctest.go b/internal/acctest/acctest.go index e23048d..c03e764 100644 --- a/internal/acctest/acctest.go +++ b/internal/acctest/acctest.go @@ -2,6 +2,9 @@ package acctest import ( + "fmt" + "os" + "github.com/d-strobel/terraform-provider-windows/internal/provider" "github.com/hashicorp/terraform-plugin-framework/providerserver" "github.com/hashicorp/terraform-plugin-go/tfprotov6" @@ -13,19 +16,26 @@ var TestAccProtoV6ProviderFactories = map[string]func() (tfprotov6.ProviderServe "windows": providerserver.NewProtocol6WithError(provider.New("test")()), } -// ProviderConfig returns a provider configuration for use in acceptance tests. +// ProviderConfig returns a default WinRM provider configuration for use in acceptance tests. +// Use this function in the test files to set up the provider configuration for non domain joined windows machines. func ProviderConfig() string { - return ` -provider "windows" { - endpoint = "127.0.0.1" + // Load environment variables are present + host := os.Getenv("TFWINDOWS_TEST_HOST") + username := os.Getenv("TFWINDOWS_TEST_USERNAME") + password := os.Getenv("TFWINDOWS_TEST_PASSWORD") + port := os.Getenv("TFWINDOWS_TEST_WINRM_HTTP_PORT") - winrm = { - username = "vagrant" - password = "vagrant" - port = 15985 - insecure = true - use_tls = false - } -} -` + return fmt.Sprintf(` + provider "windows" { + endpoint = "%s" + + winrm = { + username = "%s" + password = "%s" + port = %s + insecure = true + use_tls = false + } + } + `, host, username, password, port) } diff --git a/internal/provider/provider_test.go b/internal/provider/provider_test.go new file mode 100644 index 0000000..cf29233 --- /dev/null +++ b/internal/provider/provider_test.go @@ -0,0 +1,194 @@ +package provider_test + +import ( + "fmt" + "os" + "testing" + + "github.com/d-strobel/terraform-provider-windows/internal/acctest" + "github.com/hashicorp/terraform-plugin-testing/helper/resource" + "github.com/stretchr/testify/assert" +) + +func TestAccProvider(t *testing.T) { + // Skip test if TF_ACC is not set + if os.Getenv("TF_ACC") == "" { + t.Skip("Acceptance tests skipped unless TF_ACC is set") + } + + // Load and assert environment variables + host := os.Getenv("TFWINDOWS_TEST_HOST") + assert.NotEmpty(t, host, "Environment variable not set: TFWINDOWS_TEST_HOST") + + username := os.Getenv("TFWINDOWS_TEST_USERNAME") + assert.NotEmpty(t, username, "Environment variable not set: TFWINDOWS_TEST_USERNAME") + + password := os.Getenv("TFWINDOWS_TEST_PASSWORD") + assert.NotEmpty(t, password, "Environment variable not set: TFWINDOWS_TEST_PASSWORD") + + httpPort := os.Getenv("TFWINDOWS_TEST_WINRM_HTTP_PORT") + assert.NotEmpty(t, httpPort, "Environment variable not set: TFWINDOWS_TEST_WINRM_HTTP_PORT") + + httpsPort := os.Getenv("TFWINDOWS_TEST_WINRM_HTTPS_PORT") + assert.NotEmpty(t, httpsPort, "Environment variable not set: TFWINDOWS_TEST_WINRM_HTTPS_PORT") + + sshPort := os.Getenv("TFWINDOWS_TEST_SSH_PORT") + assert.NotEmpty(t, sshPort, "Environment variable not set: TFWINDOWS_TEST_SSH_PORT") + + sshKeyED25519Path := os.Getenv("TFWINDOWS_TEST_SSH_PRIVATE_KEY_ED25519_PATH") + assert.NotEmpty(t, sshKeyED25519Path, "Environment variable not set: TFWINDOWS_TEST_SSH_PRIVATE_KEY_ED25519_PATH") + + sshKeyED25519, err := os.ReadFile(sshKeyED25519Path) + assert.NoError(t, err, "Failed to read ED25519 private key file") + + sshKeyRSAPath := os.Getenv("TFWINDOWS_TEST_SSH_PRIVATE_KEY_RSA_PATH") + assert.NotEmpty(t, sshKeyRSAPath, "Environment variable not set: TFWINDOWS_TEST_SSH_PRIVATE_KEY_RSA_PATH") + + sshKeyRSA, err := os.ReadFile(sshKeyRSAPath) + assert.NoError(t, err, "Failed to read RSA private key file") + + const providerTestDatasourceConfig = ` + data "windows_local_group" "test" { + name = "Administrators" + } + ` + + // Acceptance tests for different provider configurations + resource.Test(t, resource.TestCase{ + ProtoV6ProviderFactories: acctest.TestAccProtoV6ProviderFactories, + Steps: []resource.TestStep{ + // WinRM with HTTP + { + Config: providerTestDatasourceConfig + fmt.Sprintf(` + provider "windows" { + endpoint = "%s" + + winrm = { + username = "%s" + password = "%s" + port = %s + insecure = true + use_tls = false + } + } + `, host, username, password, httpPort), + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("data.windows_local_group.test", "name", "Administrators"), + ), + }, + // WinRM over HTTPS + { + Config: providerTestDatasourceConfig + fmt.Sprintf(` + provider "windows" { + endpoint = "%s" + + winrm = { + username = "%s" + password = "%s" + port = %s + insecure = true + use_tls = true + } + } + `, host, username, password, httpsPort), + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("data.windows_local_group.test", "name", "Administrators"), + ), + }, + // SSH with username and password + { + Config: providerTestDatasourceConfig + fmt.Sprintf(` + provider "windows" { + endpoint = "%s" + + ssh = { + username = "%s" + password = "%s" + port = %s + insecure = true + } + } + `, host, username, password, sshPort), + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("data.windows_local_group.test", "name", "Administrators"), + ), + }, + // SSH with ED25519 publicKeyauthentication + { + Config: providerTestDatasourceConfig + fmt.Sprintf(` + provider "windows" { + endpoint = "%s" + + ssh = { + username = "%s" + private_key_path = "%s" + port = %s + insecure = true + } + } + `, host, username, sshKeyED25519Path, sshPort), + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("data.windows_local_group.test", "name", "Administrators"), + ), + }, + // SSH with RSA publicKeyauthentication + { + Config: providerTestDatasourceConfig + fmt.Sprintf(` + provider "windows" { + endpoint = "%s" + + ssh = { + username = "%s" + private_key_path = "%s" + port = %s + insecure = true + } + } + `, host, username, sshKeyRSAPath, sshPort), + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("data.windows_local_group.test", "name", "Administrators"), + ), + }, + // SSH with ED25519 publicKeyauthentication + { + Config: providerTestDatasourceConfig + fmt.Sprintf(` + provider "windows" { + endpoint = "%s" + + ssh = { + username = "%s" + port = %s + insecure = true + private_key = < Date: Sun, 13 Oct 2024 23:52:09 +0200 Subject: [PATCH 21/27] test: update local subpackage tests --- internal/provider/local/local_group_resource_test.go | 4 ++++ internal/provider/local/local_user_resource_test.go | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/internal/provider/local/local_group_resource_test.go b/internal/provider/local/local_group_resource_test.go index 9692654..20097ad 100644 --- a/internal/provider/local/local_group_resource_test.go +++ b/internal/provider/local/local_group_resource_test.go @@ -21,6 +21,8 @@ func TestAccLocalGroupResource(t *testing.T) { Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckResourceAttr("windows_local_group.test", "name", "Test"), resource.TestCheckResourceAttr("windows_local_group.test", "description", " "), + resource.TestCheckResourceAttrSet("windows_local_group.test", "id"), + resource.TestCheckResourceAttrSet("windows_local_group.test", "sid"), ), }, // Update and Read testing @@ -34,6 +36,8 @@ func TestAccLocalGroupResource(t *testing.T) { Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckResourceAttr("windows_local_group.test", "name", "Test"), resource.TestCheckResourceAttr("windows_local_group.test", "description", "Test description"), + resource.TestCheckResourceAttrSet("windows_local_group.test", "id"), + resource.TestCheckResourceAttrSet("windows_local_group.test", "sid"), ), }, }, diff --git a/internal/provider/local/local_user_resource_test.go b/internal/provider/local/local_user_resource_test.go index a263f4b..053e049 100644 --- a/internal/provider/local/local_user_resource_test.go +++ b/internal/provider/local/local_user_resource_test.go @@ -31,6 +31,7 @@ func TestAccLocalUserResource(t *testing.T) { resource.TestCheckResourceAttr("windows_local_user.test_1", "password_changeable_date", "0001-01-01T00:00:00Z"), resource.TestCheckResourceAttr("windows_local_user.test_1", "password_expires", "0001-01-01T00:00:00Z"), resource.TestCheckResourceAttr("windows_local_user.test_1", "password_last_set", "0001-01-01T00:00:00Z"), + resource.TestCheckResourceAttr("windows_local_user.test_1", "password_required", "false"), resource.TestCheckResourceAttrSet("windows_local_user.test_1", "id"), resource.TestCheckResourceAttrSet("windows_local_user.test_1", "sid"), ), @@ -56,6 +57,7 @@ func TestAccLocalUserResource(t *testing.T) { resource.TestCheckResourceAttr("windows_local_user.test_1", "password_changeable_date", "0001-01-01T00:00:00Z"), resource.TestCheckResourceAttr("windows_local_user.test_1", "password_expires", "0001-01-01T00:00:00Z"), resource.TestCheckResourceAttr("windows_local_user.test_1", "password_last_set", "0001-01-01T00:00:00Z"), + resource.TestCheckResourceAttr("windows_local_user.test_1", "password_required", "false"), resource.TestCheckResourceAttrSet("windows_local_user.test_1", "id"), resource.TestCheckResourceAttrSet("windows_local_user.test_1", "sid"), ), @@ -79,6 +81,7 @@ func TestAccLocalUserResource(t *testing.T) { resource.TestCheckResourceAttr("windows_local_user.test_2", "user_may_change_password", "true"), resource.TestCheckResourceAttr("windows_local_user.test_2", "last_logon", "0001-01-01T00:00:00Z"), resource.TestCheckResourceAttr("windows_local_user.test_2", "password_expires", "0001-01-01T00:00:00Z"), + resource.TestCheckResourceAttr("windows_local_user.test_2", "password_required", "false"), resource.TestCheckResourceAttrSet("windows_local_user.test_2", "password_changeable_date"), resource.TestCheckResourceAttrSet("windows_local_user.test_2", "password_last_set"), resource.TestCheckResourceAttrSet("windows_local_user.test_2", "id"), @@ -104,6 +107,7 @@ func TestAccLocalUserResource(t *testing.T) { resource.TestCheckResourceAttr("windows_local_user.test_2", "user_may_change_password", "true"), resource.TestCheckResourceAttr("windows_local_user.test_2", "last_logon", "0001-01-01T00:00:00Z"), resource.TestCheckResourceAttr("windows_local_user.test_2", "password_expires", "0001-01-01T00:00:00Z"), + resource.TestCheckResourceAttr("windows_local_user.test_2", "password_required", "false"), resource.TestCheckResourceAttrSet("windows_local_user.test_2", "password_changeable_date"), resource.TestCheckResourceAttrSet("windows_local_user.test_2", "password_last_set"), resource.TestCheckResourceAttrSet("windows_local_user.test_2", "id"), @@ -134,6 +138,7 @@ func TestAccLocalUserResource(t *testing.T) { resource.TestCheckResourceAttr("windows_local_user.test_3", "password_never_expires", "false"), resource.TestCheckResourceAttr("windows_local_user.test_3", "user_may_change_password", "false"), resource.TestCheckResourceAttr("windows_local_user.test_3", "last_logon", "0001-01-01T00:00:00Z"), + resource.TestCheckResourceAttr("windows_local_user.test_3", "password_required", "false"), resource.TestCheckResourceAttrSet("windows_local_user.test_3", "password_expires"), resource.TestCheckResourceAttrSet("windows_local_user.test_3", "password_changeable_date"), resource.TestCheckResourceAttrSet("windows_local_user.test_3", "password_last_set"), From 598e4c632a86430880c6e77dae21abf90d840a23 Mon Sep 17 00:00:00 2001 From: Dustin Strobel Date: Sun, 13 Oct 2024 23:53:04 +0200 Subject: [PATCH 22/27] chore: remove vagrant ad machine for current state of project --- vagrant/Vagrantfile | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/vagrant/Vagrantfile b/vagrant/Vagrantfile index f0fa14d..be176d0 100644 --- a/vagrant/Vagrantfile +++ b/vagrant/Vagrantfile @@ -23,18 +23,18 @@ Vagrant.configure("2") do |config| end # Windows Server 2022 Standard Core with Active Directory - config.vm.define "win2022ad" do |win2022ad| - win2022ad.vm.box = "d-strobel/win2022sc-ad" - win2022ad.winrm.username = "vagrant\\vagrant" - - win2022ad.vm.provision "shell", inline: <<-SHELL - $sshPath = "C:\\ProgramData\\ssh\\administrators_authorized_keys" - Set-Content -Path $sshPath -Value $null - icacls.exe $sshPath /inheritance:r /grant Administrators:F /grant SYSTEM:F - - Add-Content -Force -Path $sshPath -Value '#{ssh_public_key_rsa}' - Add-Content -Force -Path $sshPath -Value '#{ssh_public_key_ed25519}' - SHELL - end + # config.vm.define "win2022ad" do |win2022ad| + # win2022ad.vm.box = "d-strobel/win2022sc-ad" + # win2022ad.winrm.username = "vagrant\\vagrant" + # + # win2022ad.vm.provision "shell", inline: <<-SHELL + # $sshPath = "C:\\ProgramData\\ssh\\administrators_authorized_keys" + # Set-Content -Path $sshPath -Value $null + # icacls.exe $sshPath /inheritance:r /grant Administrators:F /grant SYSTEM:F + # + # Add-Content -Force -Path $sshPath -Value '#{ssh_public_key_rsa}' + # Add-Content -Force -Path $sshPath -Value '#{ssh_public_key_ed25519}' + # SHELL + # end end From b9c73638d0b4d183dde79d81edc44c93ba6f2d61 Mon Sep 17 00:00:00 2001 From: Dustin Strobel Date: Thu, 17 Oct 2024 17:17:52 +0200 Subject: [PATCH 23/27] test: add import testing for resource windows_local_user --- .../local/local_user_resource_test.go | 49 +++++++++++-------- 1 file changed, 28 insertions(+), 21 deletions(-) diff --git a/internal/provider/local/local_user_resource_test.go b/internal/provider/local/local_user_resource_test.go index 053e049..57ceee2 100644 --- a/internal/provider/local/local_user_resource_test.go +++ b/internal/provider/local/local_user_resource_test.go @@ -36,6 +36,13 @@ func TestAccLocalUserResource(t *testing.T) { resource.TestCheckResourceAttrSet("windows_local_user.test_1", "sid"), ), }, + // Import testing + { + ResourceName: "windows_local_user.test_1", + ImportState: true, + ImportStateVerify: true, + ImportStateVerifyIgnore: []string{"password_never_expires"}, + }, // Update and Read testing only name { Config: acctest.ProviderConfig() + ` @@ -65,11 +72,11 @@ func TestAccLocalUserResource(t *testing.T) { // Create and Read testing with name + password { Config: acctest.ProviderConfig() + ` - resource "windows_local_user" "test_2" { - name = "test-2" - password = "Supersecretpassword1234" - } - `, + resource "windows_local_user" "test_2" { + name = "test-2" + password = "Supersecretpassword1234" + } + `, Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckResourceAttr("windows_local_user.test_2", "name", "test-2"), resource.TestCheckResourceAttr("windows_local_user.test_2", "full_name", ""), @@ -91,11 +98,11 @@ func TestAccLocalUserResource(t *testing.T) { // Update and Read testing with name + password { Config: acctest.ProviderConfig() + ` - resource "windows_local_user" "test_2" { - name = "test-2" - password = "NEWSupersecretpassword1234" - } - `, + resource "windows_local_user" "test_2" { + name = "test-2" + password = "NEWSupersecretpassword1234" + } + `, Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckResourceAttr("windows_local_user.test_2", "name", "test-2"), resource.TestCheckResourceAttr("windows_local_user.test_2", "full_name", ""), @@ -117,17 +124,17 @@ func TestAccLocalUserResource(t *testing.T) { // Create and Read testing with all possible parameters { Config: acctest.ProviderConfig() + ` - resource "windows_local_user" "test_3" { - name = "test-3" - full_name = "Test User 3" - description = "Test user for Terraform test" - password = "SuperSecretPassword123!" - account_expires = "2072-12-31T23:59:59Z" - enabled = false - password_never_expires = false - user_may_change_password = false - } - `, + resource "windows_local_user" "test_3" { + name = "test-3" + full_name = "Test User 3" + description = "Test user for Terraform test" + password = "SuperSecretPassword123!" + account_expires = "2072-12-31T23:59:59Z" + enabled = false + password_never_expires = false + user_may_change_password = false + } + `, Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckResourceAttr("windows_local_user.test_3", "name", "test-3"), resource.TestCheckResourceAttr("windows_local_user.test_3", "full_name", "Test User 3"), From f93ac9ed5dbac4d2af1fd78fe203030e833189c4 Mon Sep 17 00:00:00 2001 From: Dustin Strobel Date: Thu, 17 Oct 2024 17:18:42 +0200 Subject: [PATCH 24/27] fix: resource windows_local_user import. standard should be import by id --- internal/provider/local/local_user_resource.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/internal/provider/local/local_user_resource.go b/internal/provider/local/local_user_resource.go index 9ff787f..3f356ba 100644 --- a/internal/provider/local/local_user_resource.go +++ b/internal/provider/local/local_user_resource.go @@ -135,7 +135,7 @@ func (r *localUserResource) Read(ctx context.Context, req resource.ReadRequest, } // Read API call logic - winResp, err := r.client.LocalAccounts.UserRead(ctx, accounts.UserReadParams{SID: data.Sid.ValueString()}) + winResp, err := r.client.LocalAccounts.UserRead(ctx, accounts.UserReadParams{SID: data.Id.ValueString()}) if err != nil { tflog.Error(ctx, "Received unexpected error from remote windows client", map[string]interface{}{ "command": winerror.UnwrapCommand(err), @@ -275,5 +275,5 @@ func (r *localUserResource) Delete(ctx context.Context, req resource.DeleteReque } func (r *localUserResource) ImportState(ctx context.Context, req resource.ImportStateRequest, resp *resource.ImportStateResponse) { - resource.ImportStatePassthroughID(ctx, path.Root("sid"), req, resp) + resource.ImportStatePassthroughID(ctx, path.Root("id"), req, resp) } From 3aaeff4e62795a43a78c31cdfe9c56007259e04b Mon Sep 17 00:00:00 2001 From: Dustin Strobel Date: Thu, 17 Oct 2024 17:19:07 +0200 Subject: [PATCH 25/27] test: add import test for windows_local_group --- internal/provider/local/local_group_resource_test.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/internal/provider/local/local_group_resource_test.go b/internal/provider/local/local_group_resource_test.go index 20097ad..b7b6bdc 100644 --- a/internal/provider/local/local_group_resource_test.go +++ b/internal/provider/local/local_group_resource_test.go @@ -25,6 +25,12 @@ func TestAccLocalGroupResource(t *testing.T) { resource.TestCheckResourceAttrSet("windows_local_group.test", "sid"), ), }, + // Import testing + { + ResourceName: "windows_local_group.test", + ImportState: true, + ImportStateVerify: true, + }, // Update and Read testing { Config: acctest.ProviderConfig() + ` From 7454b7e2fb30db2393fd9c689529080e97a8d701 Mon Sep 17 00:00:00 2001 From: Dustin Strobel Date: Thu, 17 Oct 2024 18:11:32 +0200 Subject: [PATCH 26/27] test: add import test for resource windows_local_group_member --- internal/provider/local/local_group_member_resource_test.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/internal/provider/local/local_group_member_resource_test.go b/internal/provider/local/local_group_member_resource_test.go index c696609..59e57e4 100644 --- a/internal/provider/local/local_group_member_resource_test.go +++ b/internal/provider/local/local_group_member_resource_test.go @@ -25,6 +25,12 @@ func TestAccLocalGroupMemberResource(t *testing.T) { resource.TestCheckResourceAttr("windows_local_group_member.test", "id", "S-1-5-32-544/member/S-1-5-21-153895498-367353507-3704405138-501"), ), }, + // Import testing + { + ResourceName: "windows_local_group_member.test", + ImportState: true, + ImportStateVerify: true, + }, }, }) } From 1aa3bedee65ee6e827ce01221f206ce7fd361c45 Mon Sep 17 00:00:00 2001 From: Dustin Strobel Date: Thu, 17 Oct 2024 18:12:20 +0200 Subject: [PATCH 27/27] feat: implement import state for resource windows_local_group_member --- .../local/local_group_member_resource.go | 28 +++++++++++++++++-- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/internal/provider/local/local_group_member_resource.go b/internal/provider/local/local_group_member_resource.go index 8c0243f..aa7f634 100644 --- a/internal/provider/local/local_group_member_resource.go +++ b/internal/provider/local/local_group_member_resource.go @@ -3,11 +3,14 @@ package local import ( "context" "fmt" + "strings" + "github.com/d-strobel/terraform-provider-windows/internal/generate/resource_local_group_member" "github.com/d-strobel/gowindows" "github.com/d-strobel/gowindows/windows/local/accounts" "github.com/d-strobel/gowindows/winerror" + "github.com/hashicorp/terraform-plugin-framework/path" "github.com/hashicorp/terraform-plugin-framework/resource" "github.com/hashicorp/terraform-plugin-framework/types" "github.com/hashicorp/terraform-plugin-log/tflog" @@ -86,17 +89,28 @@ func (r *localGroupMemberResource) Read(ctx context.Context, req resource.ReadRe // Read Terraform prior state data into the model resp.Diagnostics.Append(req.State.Get(ctx, &data)...) + // Split the ID into SID and Member + resourceId := data.Id.ValueString() + resourceIdParts := strings.Split(resourceId, "/member/") + if len(resourceIdParts) != 2 { + resp.Diagnostics.AddError( + "Invalid Import ID", + fmt.Sprintf("Expected import ID format: '/member/', got: %s", resourceId), + ) + } + if resp.Diagnostics.HasError() { return } // Read API call logic params := accounts.GroupMemberReadParams{ - SID: data.GroupId.ValueString(), - Member: data.MemberId.ValueString(), + SID: resourceIdParts[0], + Member: resourceIdParts[1], } - if _, err := r.client.LocalAccounts.GroupMemberRead(ctx, params); err != nil { + winResp, err := r.client.LocalAccounts.GroupMemberRead(ctx, params) + if err != nil { tflog.Error(ctx, "Received unexpected error from remote windows client", map[string]interface{}{ "command": winerror.UnwrapCommand(err), }) @@ -104,6 +118,10 @@ func (r *localGroupMemberResource) Read(ctx context.Context, req resource.ReadRe return } + // Set read values + data.GroupId = types.StringValue(params.SID) + data.MemberId = types.StringValue(winResp.SID.Value) + // Save updated data into Terraform state resp.Diagnostics.Append(resp.State.Set(ctx, &data)...) } @@ -136,3 +154,7 @@ func (r *localGroupMemberResource) Delete(ctx context.Context, req resource.Dele return } } + +func (r *localGroupMemberResource) ImportState(ctx context.Context, req resource.ImportStateRequest, resp *resource.ImportStateResponse) { + resource.ImportStatePassthroughID(ctx, path.Root("id"), req, resp) +}