Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit5633489

Browse files
committed
add tags to cli
1 parentb01b553 commit5633489

File tree

2 files changed

+22
-3
lines changed

2 files changed

+22
-3
lines changed

‎enterprise/cli/provisionerkeys.go

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,10 @@ func (r *RootCmd) provisionerKeys() *serpent.Command {
3333
}
3434

3535
func (r*RootCmd)provisionerKeysCreate()*serpent.Command {
36-
orgContext:=agpl.NewOrganizationContext()
36+
var (
37+
orgContext=agpl.NewOrganizationContext()
38+
rawTags []string
39+
)
3740

3841
client:=new(codersdk.Client)
3942
cmd:=&serpent.Command{
@@ -51,8 +54,14 @@ func (r *RootCmd) provisionerKeysCreate() *serpent.Command {
5154
returnxerrors.Errorf("current organization: %w",err)
5255
}
5356

57+
tags,err:=agpl.ParseProvisionerTags(rawTags)
58+
iferr!=nil {
59+
returnerr
60+
}
61+
5462
res,err:=client.CreateProvisionerKey(ctx,org.ID, codersdk.CreateProvisionerKeyRequest{
5563
Name:inv.Args[0],
64+
Tags:tags,
5665
})
5766
iferr!=nil {
5867
returnxerrors.Errorf("create provisioner key: %w",err)
@@ -69,7 +78,15 @@ func (r *RootCmd) provisionerKeysCreate() *serpent.Command {
6978
},
7079
}
7180

72-
cmd.Options= serpent.OptionSet{}
81+
cmd.Options= serpent.OptionSet{
82+
{
83+
Flag:"tag",
84+
FlagShorthand:"t",
85+
Env:"CODER_PROVISIONERD_TAGS",
86+
Description:"Tags to filter provisioner jobs by.",
87+
Value:serpent.StringArrayOf(&rawTags),
88+
},
89+
}
7390
orgContext.AttachOptions(cmd)
7491

7592
returncmd

‎enterprise/cli/provisionerkeys_test.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ func TestProvisionerKeys(t *testing.T) {
4141
ctx:=testutil.Context(t,testutil.WaitMedium)
4242
inv,conf:=newCLI(
4343
t,
44-
"provisioner","keys","create",name,
44+
"provisioner","keys","create",name,"--tag","foo=bar",
4545
)
4646

4747
pty:=ptytest.New(t)
@@ -77,8 +77,10 @@ func TestProvisionerKeys(t *testing.T) {
7777
require.Contains(t,line,"NAME")
7878
require.Contains(t,line,"CREATED AT")
7979
require.Contains(t,line,"ORGANIZATION ID")
80+
require.Contains(t,line,"TAGS")
8081
line=pty.ReadLine(ctx)
8182
require.Contains(t,line,strings.ToLower(name))
83+
require.Contains(t,line,"map[foo:bar]")
8284

8385
inv,conf=newCLI(
8486
t,

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp