Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docker_org_member: revamp the model #73

Merged
merged 1 commit into from
Dec 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Ignore Terraform state files
*.tfstate
*.tfstate.backup

# Store acceptance testing secrets in .env
.env
54 changes: 46 additions & 8 deletions docs/resources/org_member.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,33 +3,71 @@
page_title: "docker_org_member Resource - docker"
subcategory: ""
description: |-
Manages team members associated with an organization.
Manages members associated with an organization.
~> Note Only available when authenticated with a username and password as an owner of the org.
When a member is added to an organization, they don't have access to the
organization's repositories until they accept the invitation. The invitation is
sent to the email address associated with the user's Docker ID.
Example Usage

resource "docker_org_member" "example" {
org_name = "org_name"
role = "member"
username = "[email protected]"
email = "[email protected]"
}

Import State


import {
id = "org-name/user-name"
to = docker_org_member.example
}

resource "docker_org_member" "example" {
org_name = "org-name"
role = "member"
user_name = "user-name"
}
---

# docker_org_member (Resource)

Manages team members associated with an organization.
Manages members associated with an organization.

~> **Note** Only available when authenticated with a username and password as an owner of the org.

When a member is added to an organization, they don't have access to the
organization's repositories until they accept the invitation. The invitation is
sent to the email address associated with the user's Docker ID.

## Example Usage

```hcl
resource "docker_org_member" "example" {
org_name = "org_name"
role = "member"
username = "[email protected]"
email = "[email protected]"
}
```

## Import State

```hcl

import {
id = "org-name/user-name"
to = docker_org_member.example
}

resource "docker_org_member" "example" {
org_name = "org-name"
role = "member"
user_name = "user-name"
}

```



<!-- schema generated by tfplugindocs -->
Expand All @@ -39,12 +77,12 @@ resource "docker_org_member" "example" {

- `org_name` (String) Organization name
- `role` (String) Role assigned to the user within the organization (e.g., 'member', 'editor', 'owner').
- `user_name` (String) User name (email) of the member being associated with the team

### Optional

- `team_name` (String) Team name within the organization
- `email` (String) Email of the member. Either user_name or email must be specified.
- `user_name` (String) User name of the member. Either user_name or email must be specified.

### Read-Only

- `invite_id` (String) The ID of the invite. Used for managing the , especially for deletion.
- `invite_id` (String) The ID of the invite. Used for managing membership invites that haven't been accepted yet.
13 changes: 11 additions & 2 deletions internal/hubclient/client_organization.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,10 @@ type OrgInvite struct {
CreatedAt string `json:"created_at"`
}

type OrgInvitesListResponse struct {
Data []OrgInvite `json:"data"`
}

type OrgSettingImageAccessManagement struct {
RestrictedImages ImageAccessManagementRestrictedImages `json:"restricted_images"`
}
Expand Down Expand Up @@ -284,10 +288,15 @@ func (c *Client) SetOrgSettingRegistryAccessManagement(ctx context.Context, orgN
return c.GetOrgSettingRegistryAccessManagement(ctx, orgName)
}

func (c *Client) InviteOrgMember(ctx context.Context, orgName, teamName, role string, invitees []string, dryRun bool) (OrgInviteResponse, error) {
func (c *Client) ListOrgInvites(ctx context.Context, orgName string) ([]OrgInvite, error) {
var invites OrgInvitesListResponse
err := c.sendRequest(ctx, "GET", fmt.Sprintf("/orgs/%s/invites", orgName), nil, &invites)
return invites.Data, err
}

func (c *Client) InviteOrgMember(ctx context.Context, orgName, role string, invitees []string, dryRun bool) (OrgInviteResponse, error) {
inviteRequest := OrgMemberRequest{
Org: orgName,
Team: teamName,
Invitees: invitees,
Role: role,
DryRun: dryRun,
Expand Down
Loading
Loading