Skip to content

Commit

Permalink
documentation/lint (#537)
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelquigley committed Dec 11, 2024
1 parent d0c9c45 commit 7cf2910
Show file tree
Hide file tree
Showing 3 changed files with 146 additions and 10 deletions.
2 changes: 1 addition & 1 deletion cmd/zrok/orgAdminOverview.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ type orgAdminOverviewCommand struct {
func newOrgAdminOverviewCommand() *orgAdminOverviewCommand {
cmd := &cobra.Command{
Use: "overview <organizationToken> <accountEmail>",
Short: "Retrieve account overview for organization account (requires admin)",
Short: "Retrieve account overview for organization member account",
Args: cobra.ExactArgs(2),
}
command := &orgAdminOverviewCommand{cmd: cmd}
Expand Down
22 changes: 13 additions & 9 deletions cmd/zrok/orgMemberships.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,18 @@ func (c *orgMembershipsCommand) run(_ *cobra.Command, _ []string) {
panic(err)
}

fmt.Println()
t := table.NewWriter()
t.SetOutputMirror(os.Stdout)
t.SetStyle(table.StyleColoredDark)
t.AppendHeader(table.Row{"Organization Token", "Description", "Admin?"})
for _, i := range in.Payload.Memberships {
t.AppendRow(table.Row{i.Token, i.Description, i.Admin})
if len(in.Payload.Memberships) > 0 {
fmt.Println()
t := table.NewWriter()
t.SetOutputMirror(os.Stdout)
t.SetStyle(table.StyleColoredDark)
t.AppendHeader(table.Row{"Organization Token", "Description", "Admin?"})
for _, i := range in.Payload.Memberships {
t.AppendRow(table.Row{i.Token, i.Description, i.Admin})
}
t.Render()
fmt.Println()
} else {
fmt.Println("no organization memberships.")
}
t.Render()
fmt.Println()
}
132 changes: 132 additions & 0 deletions docs/guides/organizations.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,135 @@ Future zrok releases will include additional organization features, including `-

## Configuring an Organization

The API endpoints used to manage organizations and their members require a site-level `ZROK_ADMIN_TOKEN` to access. See the [self-hosting guide](self-hosting/linux/#configure-the-controller) for details on configuring admin tokens.

### Create an Organization

The `zrok admin create organization` command is used to create organizations:

```
$ zrok admin create organization --help
Create a new organization
Usage:
zrok admin create organization [flags]
Aliases:
organization, org
Flags:
-d, --description string Organization description
-h, --help help for organization
Global Flags:
-p, --panic Panic instead of showing pretty errors
-v, --verbose Enable verbose logging
```

Use the `-d` flag to add a description that shows up in end-user membership listings.

We'll create an example organization:

```
$ zrok admin create organization -d "documentation"
[ 0.006] INFO main.(*adminCreateOrganizationCommand).run: created new organization with token 'gK1XRvthq7ci'
```

### List Organizations

We use the `zrok admin list organizations` command to list our organizations:

```
$ zrok admin list organizations
ORGANIZATION TOKEN DESCRIPTION
gK1XRvthq7ci documentation
```

### Add a Member to an Organization

We use the `zrok admin create org-member` command to add members to organizations:

```
$ zrok admin create org-member
Error: accepts 2 arg(s), received 0
Usage:
zrok admin create org-member <accountEmail> <organizationToken> [flags]
Aliases:
org-member, member
Flags:
--admin Make the new account an admin of the organization
-h, --help help for org-member
Global Flags:
-p, --panic Panic instead of showing pretty errors
-v, --verbose Enable verbose logging
```

Like this:

```
$ zrok admin create org-member [email protected] gK1XRvthq7ci
[ 0.006] INFO main.(*adminCreateOrgMemberCommand).run: added '[email protected]' to organization 'gK1XRvthq7ci
```

The `--admin` flag can be added to the `zrok admin create org-member` command to mark the member as an administrator of the organization.

### List Members of an Organization

```
$ zrok admin list org-members gK1XRvthq7ci
ACCOUNT EMAIL ADMIN?
[email protected] false
```

### Removing Organizations and Members

The `zrok admin delete org-member` and `zrok admin delete organization` commands are available to clean up organizations and their membership lists.

## End-user Organization Administrator Commands

When a zrok account is added to an organization as an administrator it allows them to use the `zrok organization admin` commands, which include:

```
$ zrok organization admin
Organization admin commands
Usage:
zrok organization admin [command]
Available Commands:
list List the members of an organization
overview Retrieve account overview for organization member account
Flags:
-h, --help help for admin
Global Flags:
-p, --panic Panic instead of showing pretty errors
-v, --verbose Enable verbose logging
Use "zrok organization admin [command] --help" for more information about a command.
```

The `zrok organization admin list` command is used to list the members of an organization.

The `zrok organization admin overview` command is used to retrieve an overview of an organization member account. This is functionally equivalent to what the `zrok overview` command does, but it allows an organization admin to retrieve the overview for another zrok account.

## End-user Organization Commands

All zrok accounts can use the `zrok organization memberships` command to list the organizations they're a member of:

```
$ zrok organization memberships
ORGANIZATION TOKEN DESCRIPTION ADMIN?
gK1XRvthq7ci documentation false
```



0 comments on commit 7cf2910

Please sign in to comment.