Skip to content
Open
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
2 changes: 1 addition & 1 deletion cmd/agent/pause.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
)

type PauseCmd struct {
AgentID string `arg:"" help:"Agent ID to pause"`
AgentID string `arg:"" help:"Agent UUID to pause"`
Note string `help:"A descriptive note to record why the agent is paused"`
TimeoutInMinutes int `help:"Timeout after which the agent is automatically resumed, in minutes" default:"5"`
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/agent/resume.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
)

type ResumeCmd struct {
AgentID string `arg:"" help:"Agent ID to resume"`
AgentID string `arg:"" help:"Agent UUID to resume"`
}

func (c *ResumeCmd) Help() string {
Expand Down
4 changes: 2 additions & 2 deletions cmd/cluster/cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -361,8 +361,8 @@ func TestUpdateCmdValidate(t *testing.T) {
wantErr: false,
},
{
name: "only default-queue-id",
cmd: UpdateCmd{ClusterUUID: "cluster-1", DefaultQueueID: "queue-123"},
name: "only default-queue-uuid",
cmd: UpdateCmd{ClusterUUID: "cluster-1", DefaultQueueUUID: "queue-123"},
wantErr: false,
},
{
Expand Down
22 changes: 11 additions & 11 deletions cmd/cluster/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,20 @@ import (
)

type UpdateCmd struct {
ClusterUUID string `arg:"" help:"Cluster UUID to update" name:"cluster-uuid"`
Name string `help:"New name for the cluster" optional:""`
Description string `help:"New description for the cluster" optional:""`
Emoji string `help:"New emoji for the cluster (e.g. :rocket:)" optional:""`
Color string `help:"New color hex code for the cluster (e.g. #FF0000)" optional:""`
DefaultQueueID string `help:"UUID of the queue to set as the default" optional:"" name:"default-queue-id"`
ClusterUUID string `arg:"" help:"Cluster UUID to update" name:"cluster-uuid"`
Name string `help:"New name for the cluster" optional:""`
Description string `help:"New description for the cluster" optional:""`
Emoji string `help:"New emoji for the cluster (e.g. :rocket:)" optional:""`
Color string `help:"New color hex code for the cluster (e.g. #FF0000)" optional:""`
DefaultQueueUUID string `help:"UUID of the queue to set as the default" optional:"" name:"default-queue-uuid" aliases:"default-queue-id"`
output.OutputFlags
}

func (c *UpdateCmd) Help() string {
return `
Update a cluster's settings.

At least one of --name, --description, --emoji, --color, or --default-queue-id must be provided.
At least one of --name, --description, --emoji, --color, or --default-queue-uuid must be provided.

Examples:
# Update a cluster's name
Expand All @@ -40,16 +40,16 @@ Examples:
$ bk cluster update my-cluster-uuid --description "Updated description" --color "#00FF00"

# Set the default queue
$ bk cluster update my-cluster-uuid --default-queue-id my-queue-uuid
$ bk cluster update my-cluster-uuid --default-queue-uuid my-queue-uuid

# Output the updated cluster as JSON
$ bk cluster update my-cluster-uuid --name "New Name" -o json
`
}

func (c *UpdateCmd) Validate() error {
if c.Name == "" && c.Description == "" && c.Emoji == "" && c.Color == "" && c.DefaultQueueID == "" {
return fmt.Errorf("at least one of --name, --description, --emoji, --color, or --default-queue-id must be provided")
if c.Name == "" && c.Description == "" && c.Emoji == "" && c.Color == "" && c.DefaultQueueUUID == "" {
return fmt.Errorf("at least one of --name, --description, --emoji, --color, or --default-queue-uuid must be provided")
}
return nil
}
Expand Down Expand Up @@ -79,7 +79,7 @@ func (c *UpdateCmd) Run(kongCtx *kong.Context, globals cli.GlobalFlags) error {
Description: c.Description,
Emoji: c.Emoji,
Color: c.Color,
DefaultQueueID: c.DefaultQueueID,
DefaultQueueID: c.DefaultQueueUUID,
}

var cluster buildkite.Cluster
Expand Down
2 changes: 1 addition & 1 deletion cmd/job/cancel.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
)

type CancelCmd struct {
JobID string `arg:"" help:"Job ID to cancel" required:""`
JobID string `arg:"" help:"Job UUID to cancel" required:""`
Web bool `help:"Open the job in a web browser after it has been cancelled" short:"w"`
}

Expand Down
10 changes: 5 additions & 5 deletions cmd/secret/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (

type DeleteCmd struct {
ClusterUUID string `help:"The UUID of the cluster" required:"" name:"cluster-uuid"`
SecretID string `help:"The UUID of the secret to delete" required:"" name:"secret-id"`
SecretUUID string `help:"The UUID of the secret to delete" required:"" name:"secret-uuid" aliases:"secret-id"`
}

func (c *DeleteCmd) Help() string {
Expand All @@ -27,10 +27,10 @@ You will be prompted to confirm deletion unless --yes is set.

Examples:
# Delete a secret (with confirmation prompt)
$ bk secret delete --cluster-uuid my-cluster-uuid --secret-id my-secret-id
$ bk secret delete --cluster-uuid my-cluster-uuid --secret-uuid my-secret-uuid

# Delete a secret without confirmation
$ bk secret delete --cluster-uuid my-cluster-uuid --secret-id my-secret-id --yes
$ bk secret delete --cluster-uuid my-cluster-uuid --secret-uuid my-secret-uuid --yes
`
}

Expand All @@ -51,7 +51,7 @@ func (c *DeleteCmd) Run(kongCtx *kong.Context, globals cli.GlobalFlags) error {
ctx, stop := signal.NotifyContext(context.Background(), os.Interrupt, syscall.SIGTERM)
defer stop()

confirmed, err := bkIO.Confirm(f, fmt.Sprintf("Are you sure you want to delete secret %s?", c.SecretID))
confirmed, err := bkIO.Confirm(f, fmt.Sprintf("Are you sure you want to delete secret %s?", c.SecretUUID))
if err != nil {
return err
}
Expand All @@ -61,7 +61,7 @@ func (c *DeleteCmd) Run(kongCtx *kong.Context, globals cli.GlobalFlags) error {
}

if err = bkIO.SpinWhile(f, "Deleting secret", func() error {
_, err = f.RestAPIClient.ClusterSecrets.Delete(ctx, f.Config.OrganizationSlug(), c.ClusterUUID, c.SecretID)
_, err = f.RestAPIClient.ClusterSecrets.Delete(ctx, f.Config.OrganizationSlug(), c.ClusterUUID, c.SecretUUID)
return err
}); err != nil {
return fmt.Errorf("error deleting secret: %v", err)
Expand Down
8 changes: 4 additions & 4 deletions cmd/secret/get.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (

type GetCmd struct {
ClusterUUID string `help:"The UUID of the cluster" required:"" name:"cluster-uuid"`
SecretID string `help:"The UUID of the secret to view" required:"" name:"secret-id"`
SecretUUID string `help:"The UUID of the secret to view" required:"" name:"secret-uuid" aliases:"secret-id"`
output.OutputFlags
}

Expand All @@ -30,10 +30,10 @@ View details of a cluster secret.

Examples:
# View a secret
$ bk secret get --cluster-uuid my-cluster-uuid --secret-id my-secret-id
$ bk secret get --cluster-uuid my-cluster-uuid --secret-uuid my-secret-uuid

# View a secret in JSON format
$ bk secret get --cluster-uuid my-cluster-uuid --secret-id my-secret-id -o json
$ bk secret get --cluster-uuid my-cluster-uuid --secret-uuid my-secret-uuid -o json
`
}

Expand All @@ -60,7 +60,7 @@ func (c *GetCmd) Run(kongCtx *kong.Context, globals cli.GlobalFlags) error {
var secret buildkite.ClusterSecret
if err = bkIO.SpinWhile(f, "Loading secret", func() error {
var apiErr error
secret, _, apiErr = f.RestAPIClient.ClusterSecrets.Get(ctx, f.Config.OrganizationSlug(), c.ClusterUUID, c.SecretID)
secret, _, apiErr = f.RestAPIClient.ClusterSecrets.Get(ctx, f.Config.OrganizationSlug(), c.ClusterUUID, c.SecretUUID)
return apiErr
}); err != nil {
return fmt.Errorf("error fetching secret: %v", err)
Expand Down
10 changes: 5 additions & 5 deletions cmd/secret/secret_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -307,27 +307,27 @@ func TestUpdateCmdValidate(t *testing.T) {
}{
{
name: "no flags set",
cmd: UpdateCmd{ClusterUUID: "c", SecretID: "s"},
cmd: UpdateCmd{ClusterUUID: "c", SecretUUID: "s"},
wantErr: true,
},
{
name: "only description",
cmd: UpdateCmd{ClusterUUID: "c", SecretID: "s", Description: "new desc"},
cmd: UpdateCmd{ClusterUUID: "c", SecretUUID: "s", Description: "new desc"},
wantErr: false,
},
{
name: "only policy",
cmd: UpdateCmd{ClusterUUID: "c", SecretID: "s", Policy: "new policy"},
cmd: UpdateCmd{ClusterUUID: "c", SecretUUID: "s", Policy: "new policy"},
wantErr: false,
},
{
name: "only update-value",
cmd: UpdateCmd{ClusterUUID: "c", SecretID: "s", UpdateValue: true},
cmd: UpdateCmd{ClusterUUID: "c", SecretUUID: "s", UpdateValue: true},
wantErr: false,
},
{
name: "description and update-value",
cmd: UpdateCmd{ClusterUUID: "c", SecretID: "s", Description: "desc", UpdateValue: true},
cmd: UpdateCmd{ClusterUUID: "c", SecretUUID: "s", Description: "desc", UpdateValue: true},
wantErr: false,
},
}
Expand Down
14 changes: 7 additions & 7 deletions cmd/secret/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (

type UpdateCmd struct {
ClusterUUID string `help:"The UUID of the cluster" required:"" name:"cluster-uuid"`
SecretID string `help:"The UUID of the secret to update" required:"" name:"secret-id"`
SecretUUID string `help:"The UUID of the secret to update" required:"" name:"secret-uuid" aliases:"secret-id"`
Description string `help:"Update the description of the secret" optional:""`
Policy string `help:"Update the access policy for the secret (YAML format)" optional:""`
UpdateValue bool `help:"Prompt to update the secret value" optional:"" name:"update-value"`
Expand All @@ -33,13 +33,13 @@ Use --update-value to be prompted for a new secret value (input will be masked).

Examples:
# Update a secret's description
$ bk secret update --cluster-uuid my-cluster-uuid --secret-id my-secret-id --description "New description"
$ bk secret update --cluster-uuid my-cluster-uuid --secret-uuid my-secret-uuid --description "New description"

# Update a secret's value
$ bk secret update --cluster-uuid my-cluster-uuid --secret-id my-secret-id --update-value
$ bk secret update --cluster-uuid my-cluster-uuid --secret-uuid my-secret-uuid --update-value

# Update both description and value
$ bk secret update --cluster-uuid my-cluster-uuid --secret-id my-secret-id --description "New description" --update-value
$ bk secret update --cluster-uuid my-cluster-uuid --secret-uuid my-secret-uuid --description "New description" --update-value
`
}

Expand Down Expand Up @@ -85,7 +85,7 @@ func (c *UpdateCmd) Run(kongCtx *kong.Context, globals cli.GlobalFlags) error {
}

if err = bkIO.SpinWhile(f, "Updating secret value", func() error {
_, err = f.RestAPIClient.ClusterSecrets.UpdateValue(ctx, org, c.ClusterUUID, c.SecretID, buildkite.ClusterSecretValueUpdate{
_, err = f.RestAPIClient.ClusterSecrets.UpdateValue(ctx, org, c.ClusterUUID, c.SecretUUID, buildkite.ClusterSecretValueUpdate{
Value: value,
})
return err
Expand All @@ -98,7 +98,7 @@ func (c *UpdateCmd) Run(kongCtx *kong.Context, globals cli.GlobalFlags) error {
if c.Description != "" || c.Policy != "" {
if err = bkIO.SpinWhile(f, "Updating secret", func() error {
var apiErr error
secret, _, apiErr = f.RestAPIClient.ClusterSecrets.Update(ctx, org, c.ClusterUUID, c.SecretID, buildkite.ClusterSecretUpdate{
secret, _, apiErr = f.RestAPIClient.ClusterSecrets.Update(ctx, org, c.ClusterUUID, c.SecretUUID, buildkite.ClusterSecretUpdate{
Description: c.Description,
Policy: c.Policy,
})
Expand All @@ -110,7 +110,7 @@ func (c *UpdateCmd) Run(kongCtx *kong.Context, globals cli.GlobalFlags) error {
// Fetch the secret to display current state
if err = bkIO.SpinWhile(f, "Loading secret", func() error {
var apiErr error
secret, _, apiErr = f.RestAPIClient.ClusterSecrets.Get(ctx, org, c.ClusterUUID, c.SecretID)
secret, _, apiErr = f.RestAPIClient.ClusterSecrets.Get(ctx, org, c.ClusterUUID, c.SecretUUID)
return apiErr
}); err != nil {
return fmt.Errorf("error fetching secret: %v", err)
Expand Down