Skip to content

Commit

Permalink
renaming: docker_repository -> docker_hub_repository
Browse files Browse the repository at this point in the history
Signed-off-by: Nick Santos <[email protected]>
  • Loading branch information
nicks committed Aug 22, 2024
1 parent 9c90292 commit 036832f
Show file tree
Hide file tree
Showing 16 changed files with 51 additions and 51 deletions.
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/03_new_resource.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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_<service>_<resource_name>`, e.g., `docker_repository_team`.
Please list any new resource(s) and/or data source(s). The naming format is `docker_<service>_<resource_name>`, 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"
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
Original file line number Diff line number Diff line change
@@ -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

Expand Down
Original file line number Diff line number Diff line change
@@ -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)



Expand Down
Original file line number Diff line number Diff line change
@@ -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)



Expand Down
Original file line number Diff line number Diff line change
@@ -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.

Expand Down
6 changes: 3 additions & 3 deletions examples/load-test/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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"
}
Expand Down
8 changes: 4 additions & 4 deletions examples/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,16 @@ 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"
full_description = "Lorem ipsum"
}

# 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"
}
Expand All @@ -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" {
Expand Down
2 changes: 1 addition & 1 deletion internal/provider/data_source_repositories.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
4 changes: 2 additions & 2 deletions internal/provider/data_source_repositories_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
),
},
},
Expand All @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion internal/provider/data_source_repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
4 changes: 2 additions & 2 deletions internal/provider/data_source_repository_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
),
},
},
Expand All @@ -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"
}
Expand Down
2 changes: 1 addition & 1 deletion internal/provider/resource_repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion internal/provider/resource_repository_team_permission.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
26 changes: 13 additions & 13 deletions internal/provider/resource_repository_team_permission_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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),
),
},
{
Expand All @@ -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),
),
},
{
Expand All @@ -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)
Expand All @@ -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"
}
Expand Down
26 changes: 13 additions & 13 deletions internal/provider/resource_repository_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
},
},
},
Expand All @@ -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"
Expand All @@ -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"
Expand Down

0 comments on commit 036832f

Please sign in to comment.