Skip to content

Commit

Permalink
Update go-buildkite to v4.0.0 (#380)
Browse files Browse the repository at this point in the history
* Update go-buildkite to v4.0.0

* Update golangci v1.54.1 -> v1.61.0

* Fix package upload tests for v4
  • Loading branch information
moskyb authored Oct 22, 2024
1 parent 80141e2 commit 6b9ce44
Show file tree
Hide file tree
Showing 33 changed files with 201 additions and 187 deletions.
2 changes: 1 addition & 1 deletion .buildkite/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ version: '3.5'

services:
golangci-lint:
image: golangci/golangci-lint:v1.54.1
image: golangci/golangci-lint:v1.61.0
working_dir: /app
volumes:
- ..:/app
Expand Down
16 changes: 8 additions & 8 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ toolchain go1.22.5
require (
github.com/AlecAivazis/survey/v2 v2.3.7
github.com/MakeNowJust/heredoc v1.0.0
github.com/buildkite/go-buildkite/v3 v3.13.0
github.com/buildkite/go-buildkite/v4 v4.0.0
github.com/charmbracelet/bubbles v0.20.0
github.com/charmbracelet/bubbletea v1.1.1
github.com/charmbracelet/huh v0.6.0
Expand Down Expand Up @@ -55,7 +55,7 @@ require (
github.com/atotto/clipboard v0.1.4 // indirect
github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect
github.com/aymanbagabas/go-udiff v0.2.0 // indirect
github.com/cenkalti/backoff v1.1.1-0.20171020064038-309aa717adbf // indirect
github.com/cenkalti/backoff v2.2.1+incompatible // indirect
github.com/charmbracelet/glamour v0.8.0
github.com/cloudflare/circl v1.3.7 // indirect
github.com/cyphar/filepath-securejoin v0.2.4 // indirect
Expand All @@ -64,7 +64,7 @@ require (
github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 // indirect
github.com/go-git/go-billy/v5 v5.5.0 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/google/go-querystring v1.0.0 // indirect
github.com/google/go-querystring v1.1.0 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect
Expand Down Expand Up @@ -98,13 +98,13 @@ require (
github.com/xanzy/ssh-agent v0.3.3 // indirect
go.uber.org/atomic v1.9.0 // indirect
go.uber.org/multierr v1.9.0 // indirect
golang.org/x/crypto v0.25.0 // indirect
golang.org/x/crypto v0.28.0 // indirect
golang.org/x/exp v0.0.0-20240103183307-be819d1f06fc // indirect
golang.org/x/mod v0.17.0 // indirect
golang.org/x/net v0.27.0 // indirect
golang.org/x/sys v0.25.0 // indirect
golang.org/x/term v0.22.0 // indirect
golang.org/x/text v0.18.0 // indirect
golang.org/x/net v0.30.0 // indirect
golang.org/x/sys v0.26.0 // indirect
golang.org/x/term v0.25.0 // indirect
golang.org/x/text v0.19.0 // indirect
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/warnings.v0 v0.1.2 // indirect
Expand Down
34 changes: 18 additions & 16 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,13 @@ github.com/bmatcuk/doublestar/v4 v4.6.1 h1:FH9SifrbvJhnlQpztAx++wlkk70QBf0iBWDwN
github.com/bmatcuk/doublestar/v4 v4.6.1/go.mod h1:xBQ8jztBU6kakFMg+8WGxn0c6z1fTSPVIjEY1Wr7jzc=
github.com/bradleyjkemp/cupaloy/v2 v2.6.0 h1:knToPYa2xtfg42U3I6punFEjaGFKWQRXJwj0JTv4mTs=
github.com/bradleyjkemp/cupaloy/v2 v2.6.0/go.mod h1:bm7JXdkRd4BHJk9HpwqAI8BoAY1lps46Enkdqw6aRX0=
github.com/buildkite/go-buildkite/v3 v3.13.0 h1:8DxSmai9UND0n81BlKqNyCuLmiUSDroMhXq+BF28e7E=
github.com/buildkite/go-buildkite/v3 v3.13.0/go.mod h1:ux2rjcqNoE54wfFHO3Vlet+a57Tt2jqOqfc9Afs7R7g=
github.com/buildkite/go-buildkite/v4 v4.0.0 h1:uIF8rvkAlHBGDluXWS1Zpuun2ooOASAVVdgO2ujWb8w=
github.com/buildkite/go-buildkite/v4 v4.0.0/go.mod h1:xlYVIETMCk46KUkmfRoztoIf888KwdY5uZXNinZ1PX0=
github.com/bwesterb/go-ristretto v1.2.3/go.mod h1:fUIoIZaG73pV5biE2Blr2xEzDoMj7NFEuV9ekS419A0=
github.com/catppuccin/go v0.2.0 h1:ktBeIrIP42b/8FGiScP9sgrWOss3lw0Z5SktRoithGA=
github.com/catppuccin/go v0.2.0/go.mod h1:8IHJuMGaUUjQM82qBrGNBv7LFq6JI3NnQCF6MOlZjpc=
github.com/cenkalti/backoff v1.1.1-0.20171020064038-309aa717adbf h1:yxlp0s+Sge9UsKEK0Bsvjiopb9XRk+vxylmZ9eGBfm8=
github.com/cenkalti/backoff v1.1.1-0.20171020064038-309aa717adbf/go.mod h1:90ReRw6GdpyfrHakVjL/QHaoyV4aDUVVkXQJJJ3NXXM=
github.com/cenkalti/backoff v2.2.1+incompatible h1:tNowT99t7UNflLxfYYSlKYsBpXdEet03Pg2g16Swow4=
github.com/cenkalti/backoff v2.2.1+incompatible/go.mod h1:90ReRw6GdpyfrHakVjL/QHaoyV4aDUVVkXQJJJ3NXXM=
github.com/charmbracelet/bubbles v0.20.0 h1:jSZu6qD8cRQ6k9OMfR1WlM+ruM8fkPWkHvQWD9LIutE=
github.com/charmbracelet/bubbles v0.20.0/go.mod h1:39slydyswPy+uVOHZ5x/GjwVAFkCsV8IIVy+4MhzwwU=
github.com/charmbracelet/bubbletea v1.1.1 h1:KJ2/DnmpfqFtDNVTvYZ6zpPFL9iRCRr0qqKOCvppbPY=
Expand Down Expand Up @@ -115,10 +115,11 @@ github.com/go-git/go-git/v5 v5.12.0 h1:7Md+ndsjrzZxbddRDZjF14qK+NN56sy6wkqaVrjZt
github.com/go-git/go-git/v5 v5.12.0/go.mod h1:FTM9VKtnI2m65hNI/TenDDDnUf2Q9FHnXYjuz9i5OEY=
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da h1:oI5xCqsCo564l8iNU+DwB5epxmsaqB+rhGL0m5jtYqE=
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/google/go-querystring v1.0.0 h1:Xkwi/a1rcvNg1PPYe5vI8GbeBY/jrVuDX5ASuANWTrk=
github.com/google/go-querystring v1.0.0/go.mod h1:odCYkC5MyYFN7vkCjXpyrEuKhc/BUO6wN/zVPAxq5ck=
github.com/google/go-querystring v1.1.0 h1:AnCroh3fv4ZBgVIf1Iwtovgjaw/GiKJo8M8yD/fhyJ8=
github.com/google/go-querystring v1.1.0/go.mod h1:Kcdr2DB4koayq7X8pmAG4sNG59So17icRSOU623lUBU=
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/gorilla/css v1.0.1 h1:ntNaBIghp6JmvWnxbZKANoLyuXTPZ4cAMlo6RyhlbO8=
Expand Down Expand Up @@ -260,8 +261,8 @@ golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5y
golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
golang.org/x/crypto v0.3.1-0.20221117191849-2c476679df9a/go.mod h1:hebNnKkNXi2UzZN1eVRvBB7co0a+JxK6XbPiWVs/3J4=
golang.org/x/crypto v0.7.0/go.mod h1:pYwdfH91IfpZVANVyUOhSIPZaFoJGxTFbZhFTx+dXZU=
golang.org/x/crypto v0.25.0 h1:ypSNr+bnYL2YhwoMt2zPxHFmbAN1KZs/njMG3hxUp30=
golang.org/x/crypto v0.25.0/go.mod h1:T+wALwcMOSE0kXgUAnPAHqTLW+XHgcELELW8VaDgm/M=
golang.org/x/crypto v0.28.0 h1:GBDwsMXVQi34v5CCYUm2jkJvu4cbtru2U4TN2PSyQnw=
golang.org/x/crypto v0.28.0/go.mod h1:rmgy+3RHxRZMyY0jjAJShp2zgEdOqj2AO7U0pYmeQ7U=
golang.org/x/exp v0.0.0-20240103183307-be819d1f06fc h1:ao2WRsKSzW6KuUY9IWPwWahcHCgR0s52IfwutMfEbdM=
golang.org/x/exp v0.0.0-20240103183307-be819d1f06fc/go.mod h1:iRJReGqOEeBhDZGkGbynYwcHlctCvnjTYIamk7uXpHI=
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
Expand All @@ -275,8 +276,8 @@ golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug
golang.org/x/net v0.2.0/go.mod h1:KqCZLdyyvdV855qA2rE3GC2aiw5xGR5TEjj8smXukLY=
golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc=
golang.org/x/net v0.27.0 h1:5K3Njcw06/l2y9vpGCSdcxWOYHOUk3dVNGDXN+FvAys=
golang.org/x/net v0.27.0/go.mod h1:dDi0PyhWNoiUOrAS8uXv/vnScO4wnHQO4mj9fn/RytE=
golang.org/x/net v0.30.0 h1:AcW1SDZMkb8IpzCdQUaIq2sP4sZ4zw+55h6ynffypl4=
golang.org/x/net v0.30.0/go.mod h1:2wGyMJ5iFasEhkwi13ChkO/t1ECNC4X4eBKkVFyYFlU=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
Expand All @@ -299,24 +300,24 @@ golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.3.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.25.0 h1:r+8e+loiHxRqhXVl6ML1nO3l1+oFoWbnlu2Ehimmi34=
golang.org/x/sys v0.25.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.26.0 h1:KHjCJyddX0LoSTb3J+vWpupP9p0oznkqVk/IfjymZbo=
golang.org/x/sys v0.26.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
golang.org/x/term v0.2.0/go.mod h1:TVmDHMZPmdnySmBfhjOoOdhjzdE1h4u1VwSiw2l1Nuc=
golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k=
golang.org/x/term v0.6.0/go.mod h1:m6U89DPEgQRMq3DNkDClhWw02AUbt2daBVO4cn4Hv9U=
golang.org/x/term v0.22.0 h1:BbsgPEJULsl2fV/AT3v15Mjva5yXKQDyKf+TbDz7QJk=
golang.org/x/term v0.22.0/go.mod h1:F3qCibpT5AMpCRfhfT53vVJwhLtIVHhB9XDjfFvnMI4=
golang.org/x/term v0.25.0 h1:WtHI/ltw4NvSUig5KARz9h521QvRC8RmF/cuYqifU24=
golang.org/x/term v0.25.0/go.mod h1:RPyXicDX+6vLxogjjRxjgD2TKtmAO6NZBsBRfrOLu7M=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
golang.org/x/text v0.8.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8=
golang.org/x/text v0.18.0 h1:XvMDiNzPAl0jr17s6W9lcaIhGUfUORdGCNsuLmPG224=
golang.org/x/text v0.18.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY=
golang.org/x/text v0.19.0 h1:kTxAhCbGbxhK0IwgSKiMO5awPoDQ0RpfiVYBfK860YM=
golang.org/x/text v0.19.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20190125232054-d66bd3c5d5a6/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
Expand All @@ -325,6 +326,7 @@ golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU=
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d h1:vU5i/LfpvrRCpgM/VPfJLg5KjxD3E+hfT1SH+d9zLwg=
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d/go.mod h1:aiJjzUbINMkxbQROHiO6hDPo2LHcIPhhQsa9DLh0yGk=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
Expand Down
6 changes: 3 additions & 3 deletions internal/agent/item.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@ package agent
import (
"strings"

"github.com/buildkite/go-buildkite/v3/buildkite"
"github.com/buildkite/go-buildkite/v4"
)

// AgentListItem implements list.Item for displaying in a list
type AgentListItem struct {
*buildkite.Agent
buildkite.Agent
}

func (ali AgentListItem) FilterValue() string {
return strings.Join([]string{*ali.Name, ali.QueueName(), *ali.ConnectedState, *ali.Version}, " ")
return strings.Join([]string{ali.Name, ali.QueueName(), ali.ConnectedState, ali.Version}, " ")
}

func (ali AgentListItem) QueueName() string {
Expand Down
6 changes: 3 additions & 3 deletions internal/agent/item_delegate.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,9 @@ func (d listAgentDelegate) Render(w io.Writer, m list.Model, index int, item lis
s = &d.Styles
)
if agent, ok := item.(AgentListItem); ok {
name = *agent.Name
status = *agent.ConnectedState
version = *agent.Version
name = agent.Name
status = agent.ConnectedState
version = agent.Version
queue = agent.QueueName()
} else {
return
Expand Down
2 changes: 1 addition & 1 deletion internal/agent/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ func (m AgentListModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
}
case "w":
if agent, ok := m.agentList.SelectedItem().(AgentListItem); ok {
if err := browser.OpenURL(*agent.WebURL); err != nil {
if err := browser.OpenURL(agent.WebURL); err != nil {
return m, m.agentList.NewStatusMessage(fmt.Sprintf("Failed opening agent web url: %s", err.Error()))
}
}
Expand Down
26 changes: 13 additions & 13 deletions internal/agent/view.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,39 +7,39 @@ import (
"time"

"github.com/buildkite/cli/v3/pkg/style"
"github.com/buildkite/go-buildkite/v3/buildkite"
"github.com/buildkite/go-buildkite/v4"
"github.com/charmbracelet/lipgloss"
"github.com/charmbracelet/lipgloss/table"
)

func AgentDataTable(agent *buildkite.Agent) string {
func AgentDataTable(agent buildkite.Agent) string {
// Parse metadata and queue name from returned REST API Metadata list
metadata, queue := ParseMetadata(agent.Metadata)

tableOut := &bytes.Buffer{}
bold := lipgloss.NewStyle().Bold(true)
agentStateStyle := lipgloss.NewStyle().Bold(true).Foreground(MapStatusToColour(*agent.ConnectedState))
agentStateStyle := lipgloss.NewStyle().Bold(true).Foreground(MapStatusToColour(agent.ConnectedState))
queueStyle := lipgloss.NewStyle().Foreground(style.Teal)
versionStyle := lipgloss.NewStyle().Foreground(style.Grey)

fmt.Fprint(tableOut, bold.Render(*agent.Name))
fmt.Fprint(tableOut, bold.Render(agent.Name))

t := table.New().Border(lipgloss.HiddenBorder()).StyleFunc(func(row, col int) lipgloss.Style {
return lipgloss.NewStyle().PaddingRight(2)
})

// Construct table row data
t.Row("ID", *agent.ID)
t.Row("State", agentStateStyle.Render(*agent.ConnectedState))
t.Row("ID", agent.ID)
t.Row("State", agentStateStyle.Render(agent.ConnectedState))
t.Row("Queue", queueStyle.Render(queue))
t.Row("Version", versionStyle.Render(*agent.Version))
t.Row("Hostname", *agent.Hostname)
// t.Row("PID", *agent.)
t.Row("User Agent", *agent.UserAgent)
t.Row("IP Address", *agent.IPAddress)
// t.Row("OS", *agent.)
t.Row("Version", versionStyle.Render(agent.Version))
t.Row("Hostname", agent.Hostname)
// t.Row("PID", agent.)
t.Row("User Agent", agent.UserAgent)
t.Row("IP Address", agent.IPAddress)
// t.Row("OS", agent.)
t.Row("Connected", agent.CreatedAt.UTC().Format(time.RFC1123Z))
// t.Row("Stopped By", *agent.CreatedAt)
// t.Row("Stopped By", agent.CreatedAt)
t.Row("Metadata", metadata)

fmt.Fprint(tableOut, t.Render())
Expand Down
4 changes: 2 additions & 2 deletions internal/annotation/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ package annotation
import (
"fmt"

"github.com/buildkite/go-buildkite/v3/buildkite"
"github.com/buildkite/go-buildkite/v4"
"github.com/charmbracelet/lipgloss"
)

func AnnotationSummary(annotation *buildkite.Annotation) string {
summary := lipgloss.JoinVertical(lipgloss.Top,
lipgloss.NewStyle().Align(lipgloss.Left).Padding(0, 1).Render(),
lipgloss.NewStyle().Padding(0, 1).Border(lipgloss.RoundedBorder()).BorderForeground(renderAnnotationState(*annotation.Style)).Render(fmt.Sprintf("%s\t%s", renderAnnotationIcon(*annotation.Style), StripTags(*annotation.BodyHTML))),
lipgloss.NewStyle().Padding(0, 1).Border(lipgloss.RoundedBorder()).BorderForeground(renderAnnotationState(annotation.Style)).Render(fmt.Sprintf("%s\t%s", renderAnnotationIcon(annotation.Style), StripTags(annotation.BodyHTML))),
)
return summary
}
Expand Down
6 changes: 3 additions & 3 deletions internal/artifact/view.go
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
package artifact

import (
"github.com/buildkite/go-buildkite/v3/buildkite"
"github.com/buildkite/go-buildkite/v4"
"github.com/charmbracelet/lipgloss"
)

func ArtifactSummary(artifact *buildkite.Artifact) string {
artifactSummary := lipgloss.JoinVertical(lipgloss.Top,
lipgloss.NewStyle().Align(lipgloss.Left).Padding(0, 1).Render(),
lipgloss.JoinHorizontal(lipgloss.Left,
lipgloss.NewStyle().Width(60).Align(lipgloss.Left).Padding(0, 1).Render(*artifact.Path),
lipgloss.NewStyle().Align(lipgloss.Right).Padding(0, 1).Render(FormatBytes(*artifact.FileSize)),
lipgloss.NewStyle().Width(60).Align(lipgloss.Left).Padding(0, 1).Render(artifact.Path),
lipgloss.NewStyle().Align(lipgloss.Right).Padding(0, 1).Render(FormatBytes(artifact.FileSize)),
),
)

Expand Down
10 changes: 5 additions & 5 deletions internal/build/resolver/options/options.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
package options

import (
"context"

"github.com/buildkite/cli/v3/pkg/cmd/factory"
"github.com/buildkite/go-buildkite/v3/buildkite"
"github.com/buildkite/go-buildkite/v4"
"github.com/go-git/go-git/v5"
)

Expand Down Expand Up @@ -62,14 +64,12 @@ func ResolveCurrentUser(f *factory.Factory) OptionsFn {
if options.Creator != "" {
return nil
}
user, _, err := f.RestAPIClient.User.Get()
user, _, err := f.RestAPIClient.User.CurrentUser(context.TODO())
if err != nil {
return err
}
// set the user filter if the given user exists and a filter is not already set
if user != nil {
options.Creator = *user.ID
}
options.Creator = user.ID
return nil
}
}
7 changes: 4 additions & 3 deletions internal/build/resolver/with_options.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"github.com/buildkite/cli/v3/internal/build/resolver/options"
pipelineResolver "github.com/buildkite/cli/v3/internal/pipeline/resolver"
"github.com/buildkite/cli/v3/pkg/cmd/factory"
"github.com/buildkite/go-buildkite/v3/buildkite"
"github.com/buildkite/go-buildkite/v4"
)

func ResolveBuildWithOpts(f *factory.Factory, pipelineResolver pipelineResolver.PipelineResolverFn, listOpts ...options.OptionsFn) BuildResolverFn {
Expand All @@ -33,7 +33,8 @@ func ResolveBuildWithOpts(f *factory.Factory, pipelineResolver pipelineResolver.
}
}

builds, _, err := f.RestAPIClient.Builds.ListByPipeline(f.Config.OrganizationSlug(), pipeline.Name, opts)
builds, _, err := f.RestAPIClient.Builds.ListByPipeline(context.TODO(), f.Config.OrganizationSlug(), pipeline.Name, opts)
fmt.Println(builds, err)
if err != nil {
return nil, err
}
Expand All @@ -44,7 +45,7 @@ func ResolveBuildWithOpts(f *factory.Factory, pipelineResolver pipelineResolver.
return &build.Build{
Organization: f.Config.OrganizationSlug(),
Pipeline: pipeline.Name,
BuildNumber: *builds[0].Number,
BuildNumber: builds[0].Number,
}, nil
}
}
20 changes: 10 additions & 10 deletions internal/build/view.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,23 @@ import (
"strings"
"time"

"github.com/buildkite/go-buildkite/v3/buildkite"
"github.com/buildkite/go-buildkite/v4"
"github.com/charmbracelet/lipgloss"
)

func BuildSummary(build *buildkite.Build) string {
message := trimMessage(*build.Message)
buildInfo := fmt.Sprintf("%s %s %s", renderBuildNumber(*build.State, *build.Number), message, renderBuildState(*build.State, *build.Blocked))
func BuildSummary(build buildkite.Build) string {
message := trimMessage(build.Message)
buildInfo := fmt.Sprintf("%s %s %s", renderBuildNumber(build.State, build.Number), message, renderBuildState(build.State, build.Blocked))

source := fmt.Sprintf("Triggered via %s by %s ∘ Created on %s",
*build.Source,
build.Source,
buildCreator(build),
build.CreatedAt.UTC().Format(time.RFC1123Z))
hash := *build.Commit
hash := build.Commit
if len(hash) > 0 {
hash = hash[0:]
}
commitDetails := fmt.Sprintf("Branch: %s / Commit: %s \n", *build.Branch, hash)
commitDetails := fmt.Sprintf("Branch: %s / Commit: %s \n", build.Branch, hash)
summary := lipgloss.JoinVertical(lipgloss.Top,
lipgloss.NewStyle().Bold(true).Padding(0, 1).Render(buildInfo),
lipgloss.NewStyle().Padding(0, 1).Render(source),
Expand All @@ -31,11 +31,11 @@ func BuildSummary(build *buildkite.Build) string {
}

// buildCreator returns the creator of a build factoring in the creator/author fallback
func buildCreator(build *buildkite.Build) string {
if build.Creator != nil {
func buildCreator(build buildkite.Build) string {
if build.Creator.ID != "" {
return build.Creator.Name
}
if build.Author != nil {
if build.Author.Username != "" {
return build.Author.Name
}

Expand Down
Loading

0 comments on commit 6b9ce44

Please sign in to comment.