Skip to content

feat: add workspace settings commands for studios workspace settings configurability#633

Open
georgi-seqera wants to merge 1 commit into
masterfrom
feat/workspace-studio-settings
Open

feat: add workspace settings commands for studios workspace settings configurability#633
georgi-seqera wants to merge 1 commit into
masterfrom
feat/workspace-studio-settings

Conversation

@georgi-seqera

Copy link
Copy Markdown
Contributor

Summary

Adds a new command tree under workspaces for inspecting and configuring a workspace's Studios settings.

tw workspaces settings studios view   -i <id> | -n <org/ws>
tw workspaces settings studios update -i <id> | -n <org/ws> [options]

Four independent attributes are exposed:

  • containerRepository
  • nameStrategy (none | tagPrefix | imageSuffix)
  • lifespanHours
  • privateStudioByDefault.

update is a partial / merge-from-current operation — only the options you pass are changed, the rest are preserved.


workspaces settings studios view

Show the current Studios settings for a workspace, by ID or by Org/Workspace name.

# By ID (table)
tw workspaces settings studios view -i <workspace-id>

# By name
tw workspaces settings studios view -n my-org/my-workspace

# JSON
tw -o json workspaces settings studios view -i <workspace-id>

workspaces settings studios update

Update one, several, or all attributes. Untouched attributes are left as-is.

# Single attribute
tw workspaces settings studios update -i <workspace-id> --lifespan-hours 8

# Multiple attributes at once
tw workspaces settings studios update -i <workspace-id> \
    --container-repository "195996028523.dkr.ecr.eu-west-1.amazonaws.com/studios" \
    --name-strategy tagPrefix \
    --lifespan-hours 8 \
    --private-by-default

# Negatable boolean (disable private-by-default)
tw workspaces settings studios update -i <workspace-id> --no-private-by-default

Options

Flag Description
--container-repository <repo> Default container repository for Studios images
--reset-container-repository Clear the container repository (sends explicit null)
--name-strategy <none|tagPrefix|imageSuffix> Image-naming strategy
--reset-name-strategy Clear the naming strategy (sends explicit null)
--lifespan-hours <int> Maximum session lifespan in hours (0 = unlimited)
--[no-]private-by-default Whether new Studios are private by default (tri-state)

Notes:

  • --reset-* flags send explicit null and are mutually exclusive with their set counterpart.
  • --name-strategy none is a real value, distinct from --reset-name-strategy.
  • At least one set/reset option is required; otherwise the command prints a usage error.

Regression testing — full command examples

Prerequisites

The studios settings commands identify the workspace with -i/--id (numeric workspace ID) or -n/--name (OrganizationName/WorkspaceName) — there is no -w flag here.

export TOWER_ACCESS_TOKEN="<your-token>"
export TOWER_API_ENDPOINT="https://<your-platform-host>/api"  # omit for cloud
export WORKSPACE_ID="<numeric-workspace-id>"                  # used with -i
export WORKSPACE_NAME="<OrganizationName/WorkspaceName>"      # used with -n

1. View settings

# By ID (table)
tw workspaces settings studios view -i "$WORKSPACE_ID"

# By name
tw workspaces settings studios view -n "$WORKSPACE_NAME"

# JSON baseline (capture for later comparison)
tw -o json workspaces settings studios view -i "$WORKSPACE_ID"

2. Update a single attribute

# Set the session lifespan
tw workspaces settings studios update -i "$WORKSPACE_ID" --lifespan-hours 12

# Verify only that attribute changed
tw workspaces settings studios view -i "$WORKSPACE_ID"

# Set the default container repository
tw workspaces settings studios update -i "$WORKSPACE_ID" \
    --container-repository "195996028523.dkr.ecr.eu-west-1.amazonaws.com/studios"

3. Name strategy (enum)

Accepts none, tagPrefix, or imageSuffix (case-insensitive; the enum constant names NONE, TAG_PREFIX, IMAGE_SUFFIX are also accepted).

tw workspaces settings studios update -i "$WORKSPACE_ID" --name-strategy tagPrefix
tw workspaces settings studios update -i "$WORKSPACE_ID" --name-strategy imageSuffix
tw workspaces settings studios update -i "$WORKSPACE_ID" --name-strategy none

# Invalid value is rejected
tw workspaces settings studios update -i "$WORKSPACE_ID" --name-strategy bogus

4. Private-by-default (negatable boolean)

# Enable
tw workspaces settings studios update -i "$WORKSPACE_ID" --private-by-default

# Disable
tw workspaces settings studios update -i "$WORKSPACE_ID" --no-private-by-default

5. Update multiple attributes at once

tw workspaces settings studios update -i "$WORKSPACE_ID" \
    --container-repository "195996028523.dkr.ecr.eu-west-1.amazonaws.com/studios" \
    --name-strategy tagPrefix \
    --lifespan-hours 8 \
    --private-by-default

# Verify all four
tw workspaces settings studios view -i "$WORKSPACE_ID"

6. Reset (clear) nullable attributes

--reset-* flags send an explicit null — distinct from --name-strategy none, which sets the strategy to the real value none.

# Clear container repository
tw workspaces settings studios update -i "$WORKSPACE_ID" --reset-container-repository

# Clear name strategy
tw workspaces settings studios update -i "$WORKSPACE_ID" --reset-name-strategy

# Verify both now show as empty (`-`)
tw workspaces settings studios view -i "$WORKSPACE_ID"

7. Validation / error cases

# No options provided — usage error
tw workspaces settings studios update -i "$WORKSPACE_ID"

# Set + reset the same attribute — mutually exclusive error
tw workspaces settings studios update -i "$WORKSPACE_ID" \
    --container-repository "some/repo" --reset-container-repository

tw workspaces settings studios update -i "$WORKSPACE_ID" \
    --name-strategy tagPrefix --reset-name-strategy

# Missing workspace reference — required-arg error
tw workspaces settings studios update --lifespan-hours 8

# Unknown workspace ID — not-found error
tw workspaces settings studios view -i 1

8. By-name equivalents

Every command above also works with -n "$WORKSPACE_NAME" instead of -i "$WORKSPACE_ID".

tw workspaces settings studios update -n "$WORKSPACE_NAME" --lifespan-hours 6
tw -o json workspaces settings studios view -n "$WORKSPACE_NAME"

9. Help text

tw workspaces settings --help
tw workspaces settings studios --help
tw workspaces settings studios view --help
tw workspaces settings studios update --help

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant