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

Commitaee782e

Browse files
committed
Merge remote-tracking branch 'origin/main' into update-documentation-link/kira-pilot
2 parents61050cd +f581724 commitaee782e

File tree

99 files changed

+2251
-1003
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

99 files changed

+2251
-1003
lines changed

‎.github/workflows/coder.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ jobs:
4242
-name:golangci-lint
4343
uses:golangci/golangci-lint-action@v3.1.0
4444
with:
45-
version:v1.45.2
45+
version:v1.46.0
4646

4747
style-lint-typescript:
4848
name:"style/lint/typescript"

‎.golangci.yaml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ linters-settings:
7777
# - sloppyReassign
7878
-sloppyTypeAssert
7979
-sortSlice
80-
#- sprintfQuotedString
80+
-sprintfQuotedString
8181
-sqlQuery
8282
# - stringConcatSimplify
8383
# - stringXbytes
@@ -105,6 +105,13 @@ linters-settings:
105105
failOn:all
106106
rules:rules.go
107107

108+
staticcheck:
109+
# https://staticcheck.io/docs/options#checks
110+
# We disable SA1019 because it gets angry about our usage of xerrors. We
111+
# intentionally xerrors because stack frame support didn't make it into the
112+
# stdlib port.
113+
checks:["all", "-SA1019"]
114+
108115
goimports:
109116
local-prefixes:coder.com,cdr.dev,go.coder.com,github.com/cdr,github.com/coder
110117

@@ -235,7 +242,7 @@ linters:
235242
# without testing any exported functions. This is enabled to promote
236243
# decomposing a package before testing it's internals. A function caller
237244
# should be able to test most of the functionality from exported functions.
238-
#
245+
#
239246
# There are edge-cases to this rule, but they should be carefully considered
240247
# to avoid structural inconsistency.
241248
-testpackage

‎.goreleaser.yaml

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,18 @@ builds:
3232
["-s -w -X github.com/coder/coder/buildinfo.tag={{ .Version }}"]
3333
env:[CGO_ENABLED=0]
3434
goos:[darwin, linux, windows]
35-
goarch:[amd64]
35+
goarch:[amd64, arm, arm64]
36+
goarm:["7"]
37+
# Only build arm 7 for Linux
38+
ignore:
39+
-goos:windows
40+
goarm:'7'
41+
-goos:darwin
42+
goarm:'7'
3643
hooks:
3744
# The "trimprefix" appends ".exe" on Windows.
3845
post:|
39-
cp {{.Path}} site/out/bin/coder-{{ .Os }}-{{ .Arch }}{{ trimprefix .Name "coder" }}
46+
cp {{.Path}} site/out/bin/coder-{{ .Os }}-{{ .Arch }}{{if .Arm }}v{{ .Arm }}{{ end }}{{trimprefix .Name "coder" }}
4047
4148
-id:coder-linux
4249
dir:cmd/coder
@@ -45,7 +52,8 @@ builds:
4552
["-s -w -X github.com/coder/coder/buildinfo.tag={{ .Version }}"]
4653
env:[CGO_ENABLED=0]
4754
goos:[linux]
48-
goarch:[amd64, arm64]
55+
goarch:[amd64, arm, arm64]
56+
goarm:["7"]
4957

5058
-id:coder-windows
5159
dir:cmd/coder

‎Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ site/out/index.html: $(shell find ./site -not -path './site/node_modules/*' -typ
8383
# Restores GITKEEP files!
8484
git checkout HEAD site/out
8585

86-
site/src/api/typesGenerated.ts:$(shell find codersdk -type f -name '*.go')
86+
site/src/api/typesGenerated.ts:scripts/apitypings/main.go$(shell find codersdk -type f -name '*.go')
8787
go run scripts/apitypings/main.go> site/src/api/typesGenerated.ts
8888
cd site&& yarn run format:types
8989

‎cli/autostart.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,12 @@ The default schedule is at 09:00 in your local timezone (TZ env, UTC by default)
1818

1919
funcautostart()*cobra.Command {
2020
autostartCmd:=&cobra.Command{
21-
Use:"autostart enable <workspace>",
22-
Short:"schedule a workspace to automatically start at a regular time",
23-
Long:autostartDescriptionLong,
24-
Example:"coder autostart enable my-workspace --minute 30 --hour 9 --days 1-5 --tz Europe/Dublin",
25-
Hidden:true,
21+
Annotations:workspaceCommand,
22+
Use:"autostart enable <workspace>",
23+
Short:"schedule a workspace to automatically start at a regular time",
24+
Long:autostartDescriptionLong,
25+
Example:"coder autostart enable my-workspace --minute 30 --hour 9 --days 1-5 --tz Europe/Dublin",
26+
Hidden:true,
2627
}
2728

2829
autostartCmd.AddCommand(autostartEnable())

‎cli/cliui/cliui_darwin.go

Lines changed: 0 additions & 31 deletions
This file was deleted.

‎cli/cliui/cliui_other.go

Lines changed: 0 additions & 10 deletions
This file was deleted.

‎cli/cliui/prompt.go

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import (
77
"fmt"
88
"os"
99
"os/signal"
10-
"runtime"
1110
"strings"
1211

1312
"github.com/bgentry/speakeasy"
@@ -48,16 +47,6 @@ func Prompt(cmd *cobra.Command, opts PromptOptions) (string, error) {
4847
ifopts.Secret&&isInputFile&&isatty.IsTerminal(inFile.Fd()) {
4948
line,err=speakeasy.Ask("")
5049
}else {
51-
if!opts.IsConfirm&&runtime.GOOS=="darwin"&&isInputFile {
52-
varrestorefunc()
53-
restore,err=removeLineLengthLimit(int(inFile.Fd()))
54-
iferr!=nil {
55-
errCh<-err
56-
return
57-
}
58-
deferrestore()
59-
}
60-
6150
reader:=bufio.NewReader(cmd.InOrStdin())
6251
line,err=reader.ReadString('\n')
6352

‎cli/cliui/table.go

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
package cliui
2+
3+
import (
4+
"strings"
5+
6+
"github.com/jedib0t/go-pretty/v6/table"
7+
)
8+
9+
// Table creates a new table with standardized styles.
10+
funcTable() table.Writer {
11+
tableWriter:=table.NewWriter()
12+
tableWriter.Style().Box.PaddingLeft=""
13+
tableWriter.Style().Box.PaddingRight=" "
14+
tableWriter.Style().Options.DrawBorder=false
15+
tableWriter.Style().Options.SeparateHeader=false
16+
tableWriter.Style().Options.SeparateColumns=false
17+
returntableWriter
18+
}
19+
20+
// FilterTableColumns returns configurations to hide columns
21+
// that are not provided in the array. If the array is empty,
22+
// no filtering will occur!
23+
funcFilterTableColumns(header table.Row,columns []string) []table.ColumnConfig {
24+
iflen(columns)==0 {
25+
returnnil
26+
}
27+
columnConfigs:=make([]table.ColumnConfig,0)
28+
for_,headerTextRaw:=rangeheader {
29+
headerText,_:=headerTextRaw.(string)
30+
hidden:=true
31+
for_,column:=rangecolumns {
32+
ifstrings.EqualFold(strings.ReplaceAll(column,"_"," "),headerText) {
33+
hidden=false
34+
break
35+
}
36+
}
37+
columnConfigs=append(columnConfigs, table.ColumnConfig{
38+
Name:headerText,
39+
Hidden:hidden,
40+
})
41+
}
42+
returncolumnConfigs
43+
}

‎cli/configssh.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,9 @@ func configSSH() *cobra.Command {
3636
skipProxyCommandbool
3737
)
3838
cmd:=&cobra.Command{
39-
Use:"config-ssh",
39+
Annotations:workspaceCommand,
40+
Use:"config-ssh",
41+
Short:"Populate your SSH config with Host entries for all of your workspaces",
4042
RunE:func(cmd*cobra.Command,args []string)error {
4143
client,err:=createClient(cmd)
4244
iferr!=nil {

‎cli/create.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,9 @@ func create() *cobra.Command {
2020
templateNamestring
2121
)
2222
cmd:=&cobra.Command{
23-
Use:"create [name]",
24-
Short:"Create a workspace from a template",
23+
Annotations:workspaceCommand,
24+
Use:"create [name]",
25+
Short:"Create a workspace from a template",
2526
RunE:func(cmd*cobra.Command,args []string)error {
2627
client,err:=createClient(cmd)
2728
iferr!=nil {

‎cli/delete.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,11 @@ import (
1313
// nolint
1414
funcdelete()*cobra.Command {
1515
return&cobra.Command{
16-
Use:"delete <workspace>",
17-
Aliases: []string{"rm"},
18-
Args:cobra.ExactArgs(1),
16+
Annotations:workspaceCommand,
17+
Use:"delete <workspace>",
18+
Short:"Delete a workspace",
19+
Aliases: []string{"rm"},
20+
Args:cobra.ExactArgs(1),
1921
RunE:func(cmd*cobra.Command,args []string)error {
2022
client,err:=createClient(cmd)
2123
iferr!=nil {

‎cli/gitssh_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ func TestGitSSH(t *testing.T) {
6060

6161
// start workspace agent
6262
cmd,root:=clitest.New(t,"agent","--agent-token",agentToken,"--agent-url",client.URL.String())
63-
agentClient:=&*client
63+
agentClient:=client
6464
clitest.SetupConfig(t,agentClient,root)
6565
ctx,cancelFunc:=context.WithCancel(context.Background())
6666
defercancelFunc()

‎cli/list.go

Lines changed: 65 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@ package cli
22

33
import (
44
"fmt"
5+
"strings"
6+
"time"
57

8+
"github.com/google/uuid"
69
"github.com/jedib0t/go-pretty/v6/table"
710
"github.com/spf13/cobra"
811

@@ -12,19 +15,20 @@ import (
1215
)
1316

1417
funclist()*cobra.Command {
15-
return&cobra.Command{
16-
Use:"list",
17-
Aliases: []string{"ls"},
18+
var (
19+
columns []string
20+
)
21+
cmd:=&cobra.Command{
22+
Annotations:workspaceCommand,
23+
Use:"list",
24+
Short:"List all workspaces",
25+
Aliases: []string{"ls"},
1826
RunE:func(cmd*cobra.Command,args []string)error {
1927
client,err:=createClient(cmd)
2028
iferr!=nil {
2129
returnerr
2230
}
23-
organization,err:=currentOrganization(cmd,client)
24-
iferr!=nil {
25-
returnerr
26-
}
27-
workspaces,err:=client.WorkspacesByOwner(cmd.Context(),organization.ID,codersdk.Me)
31+
workspaces,err:=client.WorkspacesByUser(cmd.Context(),codersdk.Me)
2832
iferr!=nil {
2933
returnerr
3034
}
@@ -35,11 +39,22 @@ func list() *cobra.Command {
3539
_,_=fmt.Fprintln(cmd.OutOrStdout())
3640
returnnil
3741
}
42+
users,err:=client.Users(cmd.Context(), codersdk.UsersRequest{})
43+
iferr!=nil {
44+
returnerr
45+
}
46+
usersByID:=map[uuid.UUID]codersdk.User{}
47+
for_,user:=rangeusers {
48+
usersByID[user.ID]=user
49+
}
3850

39-
tableWriter:=table.NewWriter()
40-
tableWriter.SetStyle(table.StyleLight)
41-
tableWriter.Style().Options.SeparateColumns=false
42-
tableWriter.AppendHeader(table.Row{"Workspace","Template","Status","Last Built","Outdated"})
51+
tableWriter:=cliui.Table()
52+
header:= table.Row{"workspace","template","status","last built","outdated"}
53+
tableWriter.AppendHeader(header)
54+
tableWriter.SortBy([]table.SortBy{{
55+
Name:"workspace",
56+
}})
57+
tableWriter.SetColumnConfigs(cliui.FilterTableColumns(header,columns))
4358

4459
for_,workspace:=rangeworkspaces {
4560
status:=""
@@ -51,32 +66,62 @@ func list() *cobra.Command {
5166

5267
switchworkspace.LatestBuild.Transition {
5368
casedatabase.WorkspaceTransitionStart:
54-
status="start"
69+
status="Running"
5570
ifinProgress {
56-
status="starting"
71+
status="Starting"
5772
}
5873
casedatabase.WorkspaceTransitionStop:
59-
status="stop"
74+
status="Stopped"
6075
ifinProgress {
61-
status="stopping"
76+
status="Stopping"
6277
}
6378
casedatabase.WorkspaceTransitionDelete:
64-
status="delete"
79+
status="Deleted"
6580
ifinProgress {
66-
status="deleting"
81+
status="Deleting"
6782
}
6883
}
84+
ifworkspace.LatestBuild.Job.Status==codersdk.ProvisionerJobFailed {
85+
status="Failed"
86+
}
87+
88+
duration:=time.Now().UTC().Sub(workspace.LatestBuild.Job.CreatedAt).Truncate(time.Second)
89+
ifduration>time.Hour {
90+
duration=duration.Truncate(time.Hour)
91+
}
92+
ifduration>time.Minute {
93+
duration=duration.Truncate(time.Minute)
94+
}
95+
days:=0
96+
forduration.Hours()>24 {
97+
days++
98+
duration-=24*time.Hour
99+
}
100+
durationDisplay:=duration.String()
101+
ifdays>0 {
102+
durationDisplay=fmt.Sprintf("%dd%s",days,durationDisplay)
103+
}
104+
ifstrings.HasSuffix(durationDisplay,"m0s") {
105+
durationDisplay=durationDisplay[:len(durationDisplay)-2]
106+
}
107+
ifstrings.HasSuffix(durationDisplay,"h0m") {
108+
durationDisplay=durationDisplay[:len(durationDisplay)-2]
109+
}
69110

111+
user:=usersByID[workspace.OwnerID]
70112
tableWriter.AppendRow(table.Row{
71-
cliui.Styles.Bold.Render(workspace.Name),
113+
user.Username+"/"+workspace.Name,
72114
workspace.TemplateName,
73115
status,
74-
workspace.LatestBuild.Job.CreatedAt.Format("January 2, 2006"),
116+
durationDisplay,
75117
workspace.Outdated,
76118
})
77119
}
78120
_,err=fmt.Fprintln(cmd.OutOrStdout(),tableWriter.Render())
79121
returnerr
80122
},
81123
}
124+
cmd.Flags().StringArrayVarP(&columns,"column","c",nil,
125+
"Specify a column to filter in the table.")
126+
returncmd
82127
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp