From f34ddccf6f2ed48dfe94426b1d2c3bfefcf458fa Mon Sep 17 00:00:00 2001 From: Nick Santos Date: Mon, 23 Sep 2024 12:04:41 -0400 Subject: [PATCH] repository: add docs on how to create permissions importantly, this example creates a dependency from the permission to the repo. Signed-off-by: Nick Santos --- .../hub_repository_team_permission.md | 27 +++++++++++++++++++ .../resource_repository_team_permission.go | 16 +++++++++++ 2 files changed, 43 insertions(+) diff --git a/docs/resources/hub_repository_team_permission.md b/docs/resources/hub_repository_team_permission.md index 5c81848..8b00246 100644 --- a/docs/resources/hub_repository_team_permission.md +++ b/docs/resources/hub_repository_team_permission.md @@ -7,6 +7,18 @@ description: |- ~> Note When used with a Personal Access Token authentication (PAT), the PAT should have the "Read, Write, and Delete" scope to create and delete team permissions. The owner of the PAT must be an editor of the org. + Example Usage + + resource "docker_hub_repository" "my_repo" { + namespace = "my-namespace" + name = "my-repo" + } + + resource "docker_hub_repository_team_permission" "my_repo" { + repo_id = docker_hub_repository.my_repo.id + team_id = 123456 + permission = "admin" + } --- # docker_hub_repository_team_permission (Resource) @@ -17,6 +29,21 @@ Grants team permissions to an image repository. have the "Read, Write, and Delete" scope to create and delete team permissions. The owner of the PAT must be an editor of the org. +## Example Usage + +```hcl +resource "docker_hub_repository" "my_repo" { + namespace = "my-namespace" + name = "my-repo" +} + +resource "docker_hub_repository_team_permission" "my_repo" { + repo_id = docker_hub_repository.my_repo.id + team_id = 123456 + permission = "admin" +} +``` + diff --git a/internal/provider/resource_repository_team_permission.go b/internal/provider/resource_repository_team_permission.go index 0dfe919..7c7b482 100644 --- a/internal/provider/resource_repository_team_permission.go +++ b/internal/provider/resource_repository_team_permission.go @@ -68,6 +68,22 @@ func (r *RepositoryTeamPermissionResource) Schema(ctx context.Context, req resou ~> **Note** When used with a Personal Access Token authentication (PAT), the PAT should have the "Read, Write, and Delete" scope to create and delete team permissions. The owner of the PAT must be an editor of the org. + +## Example Usage + +` + "```hcl" + ` +resource "docker_hub_repository" "my_repo" { + namespace = "my-namespace" + name = "my-repo" +} + +resource "docker_hub_repository_team_permission" "my_repo" { + repo_id = docker_hub_repository.my_repo.id + team_id = 123456 + permission = "admin" +} +` + "```" + ` + `, Attributes: map[string]schema.Attribute{