Hi, I’m trying to develop my custom provider.
But I have some troubles with CI on GitHub Actions and running tests on the local environment.
I have read some documents below:
- Implement a Provider with the Terraform Plugin Framework | Terraform | HashiCorp Developer
- Custom Framework Providers | Terraform | HashiCorp Developer
I forked template repository and started developing my first custom provider.
And then I got errors like this:
=== RUN TestAccDatabaseResource
database_resource_test.go:14: Step 1/3 error: Error running pre-apply refresh: exit status 1
Error: Inconsistent dependency lock file
The following dependency selections recorded in the lock file are
inconsistent with the current configuration:
- provider registry.terraform.io/okkez/mysql: required by this configuration but no version is selected
To make the initial dependency selections that will initialize the dependency
lock file, run:
terraform init
--- FAIL: TestAccDatabaseResource (0.25s)
How to solve these issues?
Current status:
I can use all resources and data sources in my custom provider.
I can run acceptance tests on the local environment with $HOME/.terraformrc file.
provider_installation {
dev_overrides {
"okkez/mysql" = "$GOPATH"
}
}
$ TF_ACC=1 go test -v ./internal/provider/
=== RUN TestAccDatabaseResource
--- PASS: TestAccDatabaseResource (5.22s)
=== RUN TestAccDefaultRoleResource
default_roles_resource_test.go:15: user: test-user-0187@%, role1: test-role-0119@%, role2: test-role-0963@%
--- PASS: TestAccDefaultRoleResource (5.11s)
=== RUN TestAccGlobalVariableResource
--- PASS: TestAccGlobalVariableResource (4.25s)
=== RUN TestAccGrantPrivilegeResource
grant_privilege_resource_test.go:14: database: test-database-0439 user: test-user-0478@%
--- PASS: TestAccGrantPrivilegeResource (4.04s)
=== RUN TestAccGrantRoleResource
grant_role_resource_test.go:14: user: test-user-0191, role1: test-role1-0646, role2: test-role2-0007
--- PASS: TestAccGrantRoleResource (4.43s)
=== RUN TestAccRoleResource
--- PASS: TestAccRoleResource (3.53s)
=== RUN TestAccTablesDataSource
--- PASS: TestAccTablesDataSource (1.28s)
=== RUN TestAccUserResource
--- PASS: TestAccUserResource (4.83s)
PASS
ok github.com/okkez/terraform-provider-mysql/internal/provider (cached)
I cannot run acceptance tests without $HOME/.terraformrc file
=== RUN TestAccDatabaseResource
2023-05-08T18:05:54.047+0900 [WARN] sdk.helper_resource: Error running Terraform CLI command: test_step_number=1
error=
| exit status 1
|
| Error: Inconsistent dependency lock file
|
| The following dependency selections recorded in the lock file are
| inconsistent with the current configuration:
| - provider registry.terraform.io/okkez/mysql: required by this configuration but no version is selected
|
| To make the initial dependency selections that will initialize the dependency
| lock file, run:
| terraform init
test_name=TestAccDatabaseResource test_terraform_path=/home/okkez/.local/share/rtx/installs/terraform/1.4.2/bin/terraform test_working_directory=/tmp/plugintest1512033159
2023-05-08T18:05:54.047+0900 [ERROR] sdk.helper_resource: Unexpected error: test_name=TestAccDatabaseResource test_terraform_path=/home/okkez/.local/share/rtx/installs/terraform/1.4.2/bin/terraform test_working_directory=/tmp/plugintest1512033159 test_step_number=1
error=
| Error running pre-apply refresh: exit status 1
|
| Error: Inconsistent dependency lock file
|
| The following dependency selections recorded in the lock file are
| inconsistent with the current configuration:
| - provider registry.terraform.io/okkez/mysql: required by this configuration but no version is selected
|
| To make the initial dependency selections that will initialize the dependency
| lock file, run:
| terraform init
database_resource_test.go:14: Step 1/3 error: Error running pre-apply refresh: exit status 1
Error: Inconsistent dependency lock file
The following dependency selections recorded in the lock file are
inconsistent with the current configuration:
- provider registry.terraform.io/okkez/mysql: required by this configuration but no version is selected
To make the initial dependency selections that will initialize the dependency
lock file, run:
terraform init
--- FAIL: TestAccDatabaseResource (0.13s)
Thanks,