From 036832f0e75cf73ed80d863556948b63f255a0f0 Mon Sep 17 00:00:00 2001 From: Nick Santos Date: Thu, 22 Aug 2024 10:14:16 -0400 Subject: [PATCH] renaming: docker_repository -> docker_hub_repository Signed-off-by: Nick Santos --- .github/ISSUE_TEMPLATE/03_new_resource.yml | 2 +- README.md | 2 +- .../{repositories.md => hub_repositories.md} | 4 +-- .../{repository.md => hub_repository.md} | 4 +-- .../{repository.md => hub_repository.md} | 4 +-- ...n.md => hub_repository_team_permission.md} | 4 +-- examples/load-test/main.tf | 6 ++--- examples/main.tf | 8 +++--- internal/provider/data_source_repositories.go | 2 +- .../provider/data_source_repositories_test.go | 4 +-- internal/provider/data_source_repository.go | 2 +- .../provider/data_source_repository_test.go | 4 +-- internal/provider/resource_repository.go | 2 +- .../resource_repository_team_permission.go | 2 +- ...esource_repository_team_permission_test.go | 26 +++++++++---------- internal/provider/resource_repository_test.go | 26 +++++++++---------- 16 files changed, 51 insertions(+), 51 deletions(-) rename docs/data-sources/{repositories.md => hub_repositories.md} (88%) rename docs/data-sources/{repository.md => hub_repository.md} (84%) rename docs/resources/{repository.md => hub_repository.md} (85%) rename docs/resources/{repository_team_permission.md => hub_repository_team_permission.md} (79%) diff --git a/.github/ISSUE_TEMPLATE/03_new_resource.yml b/.github/ISSUE_TEMPLATE/03_new_resource.yml index 0815fc4..7fb25a7 100644 --- a/.github/ISSUE_TEMPLATE/03_new_resource.yml +++ b/.github/ISSUE_TEMPLATE/03_new_resource.yml @@ -28,7 +28,7 @@ body: attributes: label: Requested Resource(s) and/or Data Source(s) description: | - Please list any new resource(s) and/or data source(s). The naming format is `docker__`, e.g., `docker_repository_team`. + Please list any new resource(s) and/or data source(s). The naming format is `docker__`, e.g., `docker_hub_repository`. A best guess is helpful, even if you're unsure of exactly what the end result will look like. This helps maintainers and the community better understand how you (someone who is in need of this request) envisions it. placeholder: "* docker_xxx_yyy" diff --git a/README.md b/README.md index 2985277..a7021e4 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ This repository is a _template_ for a [Terraform](https://www.terraform.io) prov - Examples (`examples/`) and generated documentation (`docs/`), - Miscellaneous meta files. -These files contain boilerplate code that you will need to edit to create your own Terraform provider. Tutorials for creating Terraform providers can be found on the [HashiCorp Developer](https://developer.hashicorp.com/terraform/tutorials/providers-plugin-framework) platform. _Terraform Plugin Framework specific guides are titled accordingly._ +These files contain boilerplate code that you will need to edit to create your own Terraform provider. Tutorials for creating Terraform providers can be found on the [HashiCorp Developer](https://developer.hashicorp.com/terraform/tutorials/providers-plugin-framework) platform. _sTerraform Plugin Framework specific guides are titled accordingly._ Please see the [GitHub template repository documentation](https://help.github.com/en/github/creating-cloning-and-archiving-repositories/creating-a-repository-from-a-template) for how to create a new repository from this template on GitHub. diff --git a/docs/data-sources/repositories.md b/docs/data-sources/hub_repositories.md similarity index 88% rename from docs/data-sources/repositories.md rename to docs/data-sources/hub_repositories.md index 5510f09..e6113e7 100644 --- a/docs/data-sources/repositories.md +++ b/docs/data-sources/hub_repositories.md @@ -1,12 +1,12 @@ --- # generated by https://github.com/hashicorp/terraform-plugin-docs -page_title: "docker_repositories Data Source - docker" +page_title: "docker_hub_repositories Data Source - docker" subcategory: "" description: |- Docker Hub Repositories --- -# docker_repositories (Data Source) +# docker_hub_repositories (Data Source) Docker Hub Repositories diff --git a/docs/data-sources/repository.md b/docs/data-sources/hub_repository.md similarity index 84% rename from docs/data-sources/repository.md rename to docs/data-sources/hub_repository.md index f3e1814..bb3c543 100644 --- a/docs/data-sources/repository.md +++ b/docs/data-sources/hub_repository.md @@ -1,12 +1,12 @@ --- # generated by https://github.com/hashicorp/terraform-plugin-docs -page_title: "docker_repository Data Source - docker" +page_title: "docker_hub_repository Data Source - docker" subcategory: "" description: |- --- -# docker_repository (Data Source) +# docker_hub_repository (Data Source) diff --git a/docs/resources/repository.md b/docs/resources/hub_repository.md similarity index 85% rename from docs/resources/repository.md rename to docs/resources/hub_repository.md index 2619d82..ff46afd 100644 --- a/docs/resources/repository.md +++ b/docs/resources/hub_repository.md @@ -1,12 +1,12 @@ --- # generated by https://github.com/hashicorp/terraform-plugin-docs -page_title: "docker_repository Resource - docker" +page_title: "docker_hub_repository Resource - docker" subcategory: "" description: |- --- -# docker_repository (Resource) +# docker_hub_repository (Resource) diff --git a/docs/resources/repository_team_permission.md b/docs/resources/hub_repository_team_permission.md similarity index 79% rename from docs/resources/repository_team_permission.md rename to docs/resources/hub_repository_team_permission.md index 2f0c014..3b82de2 100644 --- a/docs/resources/repository_team_permission.md +++ b/docs/resources/hub_repository_team_permission.md @@ -1,12 +1,12 @@ --- # generated by https://github.com/hashicorp/terraform-plugin-docs -page_title: "docker_repository_team_permission Resource - docker" +page_title: "docker_hub_repository_team_permission Resource - docker" subcategory: "" description: |- Manages the permissions for a team and repository. --- -# docker_repository_team_permission (Resource) +# docker_hub_repository_team_permission (Resource) Manages the permissions for a team and repository. diff --git a/examples/load-test/main.tf b/examples/load-test/main.tf index 5ca9f87..8399f8f 100644 --- a/examples/load-test/main.tf +++ b/examples/load-test/main.tf @@ -51,7 +51,7 @@ resource "docker_org_team_member_association" "example_association" { } # Create 200 repositories with variations -resource "docker_repository" "org_repo" { +resource "docker_hub_repository" "org_hub_repo" { count = 200 namespace = "dockerterraform" name = format("%s-%03d", element(var.repo_names, 0), count.index + 1) @@ -60,9 +60,9 @@ resource "docker_repository" "org_repo" { } # Repository team permissions with variations -resource "docker_repository_team_permission" "test" { +resource "docker_hub_repository_team_permission" "test" { count = 200 - repo_id = docker_repository.org_repo[count.index].id + repo_id = docker_hub_repository.org_hub_repo[count.index].id team_id = docker_org_team.terraform_team[count.index].id permission = "admin" } diff --git a/examples/main.tf b/examples/main.tf index 375f16d..c1c7a1a 100644 --- a/examples/main.tf +++ b/examples/main.tf @@ -29,7 +29,7 @@ resource "docker_org_team_member_association" "example_association" { } # Create repository -resource "docker_repository" "org_repo" { +resource "docker_hub_repository" "org_hub_repo" { namespace = "dockerterraform" name = "docker-terraform-repo-demo" description = "This is a repo demo" @@ -37,8 +37,8 @@ resource "docker_repository" "org_repo" { } # Create repository team permission -resource "docker_repository_team_permission" "test" { - repo_id = docker_repository.org_repo.id +resource "docker_hub_repository_team_permission" "test" { + repo_id = docker_hub_repository.org_hub_repo.id team_id = docker_org_team.terraform-team.id permission = "admin" } @@ -52,7 +52,7 @@ resource "docker_access_token" "new_token_v2" { # Output Demos output "repo_output" { - value = resource.docker_repository.org_repo + value = resource.docker_hub_repository.org_hub_repo } output "org_team_output" { diff --git a/internal/provider/data_source_repositories.go b/internal/provider/data_source_repositories.go index bf5e8aa..8d1c95a 100644 --- a/internal/provider/data_source_repositories.go +++ b/internal/provider/data_source_repositories.go @@ -41,7 +41,7 @@ type Repository struct { } func (d *RepositoriesDataSource) Metadata(ctx context.Context, req datasource.MetadataRequest, resp *datasource.MetadataResponse) { - resp.TypeName = req.ProviderTypeName + "_repositories" + resp.TypeName = req.ProviderTypeName + "_hub_repositories" } func (d *RepositoriesDataSource) Schema(ctx context.Context, req datasource.SchemaRequest, resp *datasource.SchemaResponse) { diff --git a/internal/provider/data_source_repositories_test.go b/internal/provider/data_source_repositories_test.go index 08c4fa4..0fd4ad5 100644 --- a/internal/provider/data_source_repositories_test.go +++ b/internal/provider/data_source_repositories_test.go @@ -16,7 +16,7 @@ func TestAccRepositoriesDataSource(t *testing.T) { { Config: testReposExampleDataSourceConfig(), Check: resource.ComposeAggregateTestCheckFunc( - resource.TestCheckResourceAttr("data.docker_repositories.test", "id", os.Getenv("DOCKER_USERNAME")+"/repositories"), + resource.TestCheckResourceAttr("data.docker_hub_repositories.test", "id", os.Getenv("DOCKER_USERNAME")+"/repositories"), ), }, }, @@ -29,7 +29,7 @@ provider "docker" { host = "https://hub-stage.docker.com/v2" } -data "docker_repositories" "test" { +data "docker_hub_repositories" "test" { namespace = "` + os.Getenv("DOCKER_USERNAME") + `" max_number_results = 10 } diff --git a/internal/provider/data_source_repository.go b/internal/provider/data_source_repository.go index 9340075..7a05b5e 100644 --- a/internal/provider/data_source_repository.go +++ b/internal/provider/data_source_repository.go @@ -35,7 +35,7 @@ type RepositoryDataSourceModel struct { } func (d *RepositoryDataSource) Metadata(ctx context.Context, req datasource.MetadataRequest, resp *datasource.MetadataResponse) { - resp.TypeName = req.ProviderTypeName + "_repository" + resp.TypeName = req.ProviderTypeName + "_hub_repository" } func (d *RepositoryDataSource) Schema(ctx context.Context, req datasource.SchemaRequest, resp *datasource.SchemaResponse) { diff --git a/internal/provider/data_source_repository_test.go b/internal/provider/data_source_repository_test.go index 6ec1769..0df0b1e 100644 --- a/internal/provider/data_source_repository_test.go +++ b/internal/provider/data_source_repository_test.go @@ -15,7 +15,7 @@ func TestAccRepositoryDataSource(t *testing.T) { { Config: testAccExampleDataSourceConfig, Check: resource.ComposeAggregateTestCheckFunc( - resource.TestCheckResourceAttr("data.docker_repository.test", "id", "ryanhristovski/data-source-example"), + resource.TestCheckResourceAttr("data.docker_hub_repository.test", "id", "ryanhristovski/data-source-example"), ), }, }, @@ -26,7 +26,7 @@ const testAccExampleDataSourceConfig = ` provider "docker" { host = "https://hub-stage.docker.com/v2" } -data "docker_repository" "test" { +data "docker_hub_repository" "test" { namespace = "ryanhristovski" name = "data-source-example" } diff --git a/internal/provider/resource_repository.go b/internal/provider/resource_repository.go index c7cfc03..f873077 100644 --- a/internal/provider/resource_repository.go +++ b/internal/provider/resource_repository.go @@ -120,7 +120,7 @@ func (r *RepositoryResource) Delete(ctx context.Context, req resource.DeleteRequ // Metadata implements resource.Resource. func (r *RepositoryResource) Metadata(_ context.Context, req resource.MetadataRequest, resp *resource.MetadataResponse) { - resp.TypeName = req.ProviderTypeName + "_repository" + resp.TypeName = req.ProviderTypeName + "_hub_repository" } // Read implements resource.Resource. diff --git a/internal/provider/resource_repository_team_permission.go b/internal/provider/resource_repository_team_permission.go index a3aa664..295f914 100644 --- a/internal/provider/resource_repository_team_permission.go +++ b/internal/provider/resource_repository_team_permission.go @@ -58,7 +58,7 @@ func (r *RepositoryTeamPermissionResource) Configure(ctx context.Context, req re } func (r *RepositoryTeamPermissionResource) Metadata(ctx context.Context, req resource.MetadataRequest, resp *resource.MetadataResponse) { - resp.TypeName = req.ProviderTypeName + "_repository_team_permission" + resp.TypeName = req.ProviderTypeName + "_hub_repository_team_permission" } func (r *RepositoryTeamPermissionResource) Schema(ctx context.Context, req resource.SchemaRequest, resp *resource.SchemaResponse) { diff --git a/internal/provider/resource_repository_team_permission_test.go b/internal/provider/resource_repository_team_permission_test.go index e09fcdc..53e1fc5 100644 --- a/internal/provider/resource_repository_team_permission_test.go +++ b/internal/provider/resource_repository_team_permission_test.go @@ -21,9 +21,9 @@ func TestAccRepositoryTeamPermission(t *testing.T) { // create Config: testAccRepositoryTeamPermission(orgName, teamName, repoName, hubclient.TeamRepoPermissionLevelRead), Check: resource.ComposeAggregateTestCheckFunc( - resource.TestCheckResourceAttrPair("docker_repository_team_permission.test", "repo_id", "docker_repository.test", "id"), - resource.TestCheckResourceAttrPair("docker_repository_team_permission.test", "team_id", "docker_org_team.test", "id"), - resource.TestCheckResourceAttr("docker_repository_team_permission.test", "permission", hubclient.TeamRepoPermissionLevelRead), + resource.TestCheckResourceAttrPair("docker_hub_repository_team_permission.test", "repo_id", "docker_hub_repository.test", "id"), + resource.TestCheckResourceAttrPair("docker_hub_repository_team_permission.test", "team_id", "docker_org_team.test", "id"), + resource.TestCheckResourceAttr("docker_hub_repository_team_permission.test", "permission", hubclient.TeamRepoPermissionLevelRead), ), }, { @@ -34,20 +34,20 @@ func TestAccRepositoryTeamPermission(t *testing.T) { teamID := state.RootModule().Resources["docker_org_team.test"].Primary.Attributes["id"] return orgName + "/" + repoName + "/" + teamID, nil }, - ResourceName: "docker_repository_team_permission.test", + ResourceName: "docker_hub_repository_team_permission.test", Check: resource.ComposeAggregateTestCheckFunc( - resource.TestCheckResourceAttrPair("docker_repository_team_permission.test", "repo_id", "docker_repository.test", "id"), - resource.TestCheckResourceAttrPair("docker_repository_team_permission.test", "team_id", "docker_org_team.test", "id"), - resource.TestCheckResourceAttr("docker_repository_team_permission.test", "permission", hubclient.TeamRepoPermissionLevelRead), + resource.TestCheckResourceAttrPair("docker_hub_repository_team_permission.test", "repo_id", "docker_hub_repository.test", "id"), + resource.TestCheckResourceAttrPair("docker_hub_repository_team_permission.test", "team_id", "docker_org_team.test", "id"), + resource.TestCheckResourceAttr("docker_hub_repository_team_permission.test", "permission", hubclient.TeamRepoPermissionLevelRead), ), }, { // update permission Config: testAccRepositoryTeamPermission(orgName, teamName, repoName, hubclient.TeamRepoPermissionLevelAdmin), Check: resource.ComposeAggregateTestCheckFunc( - resource.TestCheckResourceAttrPair("docker_repository_team_permission.test", "repo_id", "docker_repository.test", "id"), - resource.TestCheckResourceAttrPair("docker_repository_team_permission.test", "team_id", "docker_org_team.test", "id"), - resource.TestCheckResourceAttr("docker_repository_team_permission.test", "permission", hubclient.TeamRepoPermissionLevelAdmin), + resource.TestCheckResourceAttrPair("docker_hub_repository_team_permission.test", "repo_id", "docker_hub_repository.test", "id"), + resource.TestCheckResourceAttrPair("docker_hub_repository_team_permission.test", "team_id", "docker_org_team.test", "id"), + resource.TestCheckResourceAttr("docker_hub_repository_team_permission.test", "permission", hubclient.TeamRepoPermissionLevelAdmin), ), }, { @@ -69,7 +69,7 @@ resource "docker_org_team" "test" { team_name = "%[2]s" } -resource "docker_repository" "test" { +resource "docker_hub_repository" "test" { namespace = "%[1]s" name = "%[3]s" }`, orgName, teamName, repoName) @@ -79,8 +79,8 @@ func testAccRepositoryTeamPermission(orgName, teamName, repoName string, permiss return fmt.Sprintf(` %[1]s -resource "docker_repository_team_permission" "test" { - repo_id = docker_repository.test.id +resource "docker_hub_repository_team_permission" "test" { + repo_id = docker_hub_repository.test.id team_id = docker_org_team.test.id permission = "%[2]s" } diff --git a/internal/provider/resource_repository_test.go b/internal/provider/resource_repository_test.go index 9d57d90..23aae5e 100644 --- a/internal/provider/resource_repository_test.go +++ b/internal/provider/resource_repository_test.go @@ -16,29 +16,29 @@ func TestRepositoryResource(t *testing.T) { { Config: testRepositoryResourceConfig(), Check: resource.ComposeAggregateTestCheckFunc( - resource.TestCheckResourceAttrSet("docker_repository.test", "id"), - resource.TestCheckResourceAttr("docker_repository.test", "name", "example-repo"), - resource.TestCheckResourceAttr("docker_repository.test", "namespace", os.Getenv("DOCKER_USERNAME")), - resource.TestCheckResourceAttr("docker_repository.test", "description", "Example repository"), - resource.TestCheckNoResourceAttr("docker_repository.test", "full_description"), - resource.TestCheckResourceAttr("docker_repository.test", "private", "false"), + resource.TestCheckResourceAttrSet("docker_hub_repository.test", "id"), + resource.TestCheckResourceAttr("docker_hub_repository.test", "name", "example-repo"), + resource.TestCheckResourceAttr("docker_hub_repository.test", "namespace", os.Getenv("DOCKER_USERNAME")), + resource.TestCheckResourceAttr("docker_hub_repository.test", "description", "Example repository"), + resource.TestCheckNoResourceAttr("docker_hub_repository.test", "full_description"), + resource.TestCheckResourceAttr("docker_hub_repository.test", "private", "false"), ), }, { Config: testRepositoryResourceConfigUpdated(), Check: resource.ComposeAggregateTestCheckFunc( - resource.TestCheckResourceAttr("docker_repository.test", "description", "Updated example repository"), - resource.TestCheckResourceAttr("docker_repository.test", "full_description", "Full description update"), - resource.TestCheckResourceAttr("docker_repository.test", "private", "true"), + resource.TestCheckResourceAttr("docker_hub_repository.test", "description", "Updated example repository"), + resource.TestCheckResourceAttr("docker_hub_repository.test", "full_description", "Full description update"), + resource.TestCheckResourceAttr("docker_hub_repository.test", "private", "true"), ), }, { - ResourceName: "docker_repository.test", + ResourceName: "docker_hub_repository.test", ImportState: true, ImportStateVerify: true, ImportStateVerifyIdentifierAttribute: "id", ImportStateIdFunc: func(state *terraform.State) (string, error) { - return state.RootModule().Resources["docker_repository.test"].Primary.Attributes["id"], nil + return state.RootModule().Resources["docker_hub_repository.test"].Primary.Attributes["id"], nil }, }, }, @@ -47,7 +47,7 @@ func TestRepositoryResource(t *testing.T) { func testRepositoryResourceConfig() string { return ` -resource "docker_repository" "test" { +resource "docker_hub_repository" "test" { name = "example-repo" namespace = "` + os.Getenv("DOCKER_USERNAME") + `" description = "Example repository" @@ -58,7 +58,7 @@ resource "docker_repository" "test" { func testRepositoryResourceConfigUpdated() string { return ` -resource "docker_repository" "test" { +resource "docker_hub_repository" "test" { name = "example-repo" namespace = "` + os.Getenv("DOCKER_USERNAME") + `" description = "Updated example repository"