Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate to github.com/urfave/cli/v3 #2951

Merged
merged 89 commits into from
Jul 17, 2024
Merged
Show file tree
Hide file tree
Changes from 18 commits
Commits
Show all changes
89 commits
Select commit Hold shift + click to select a range
a639f4d
switch to github.com/urfave/cli/v3
6543 Dec 14, 2023
60066ce
migration first round
6543 Dec 14, 2023
523e89b
next
6543 Dec 14, 2023
02c8fd3
next
6543 Dec 14, 2023
c82a6a5
done beside TODO
6543 Dec 14, 2023
533521b
Merge branch 'main' into urfave/cli/v3
6543 Jul 5, 2024
cbe5c30
fix things
6543 Jul 5, 2024
1f1c95b
get cli kinda working
6543 Jul 5, 2024
ede4b6b
Merge branch 'main' into urfave/cli/v3
6543 Jul 5, 2024
2f46d24
jup
6543 Jul 6, 2024
bbeae1c
make https://github.com/urfave/cli/pull/1945 afailable
6543 Jul 6, 2024
21b7845
server build
6543 Jul 6, 2024
b96fb27
fix name
6543 Jul 6, 2024
fad0d0f
fix name (2)
6543 Jul 6, 2024
575ef09
fix lint err
6543 Jul 6, 2024
f407175
use new cli interfaces
6543 Jul 6, 2024
14d980a
move context creation stack up
6543 Jul 6, 2024
eea7c69
use new cli interface
6543 Jul 6, 2024
29da6c1
rename CliContext to CliCommand
6543 Jul 6, 2024
8460d99
Merge branch 'main' into urfave/cli/v3
6543 Jul 8, 2024
6e2f727
use latest urfave cli v3
6543 Jul 8, 2024
986f206
fix spellcheck
6543 Jul 8, 2024
9bd83a7
todo solved
6543 Jul 8, 2024
62ff75d
Merge branch 'main' into urfave/cli/v3
6543 Jul 12, 2024
a782d81
dont block termination for 10sec without dooing nothing
6543 Jul 12, 2024
fb58efd
better var name
6543 Jul 12, 2024
e2e2bee
check if context got already cancled first
6543 Jul 12, 2024
21f1607
enhance cli exec termination
6543 Jul 12, 2024
997034c
min the context @interceptor
6543 Jul 12, 2024
ad47d42
respect the context
6543 Jul 12, 2024
b2cad0c
const of magic number
6543 Jul 12, 2024
ed3ff5b
magic of context
6543 Jul 12, 2024
6a71877
context moved through
6543 Jul 12, 2024
c9018ac
go mod tidy
6543 Jul 12, 2024
c82f037
dont stop to report health if error did ocure
6543 Jul 12, 2024
bc1e188
fix logic
6543 Jul 12, 2024
5c15385
dont report error if terminated gracefully
6543 Jul 12, 2024
9ad27a4
better error logging
6543 Jul 12, 2024
89d6281
Merge branch 'main' into urfave/cli/v3
6543 Jul 12, 2024
16a7ada
resolve todo
6543 Jul 12, 2024
14264b6
finish
6543 Jul 12, 2024
ceaf709
clean
6543 Jul 12, 2024
e328753
pass context to database migration
6543 Jul 12, 2024
a4579d6
agent pinger with context
6543 Jul 12, 2024
8add143
make server respect the context and stop gracefully
6543 Jul 13, 2024
07b628e
wrong scope
6543 Jul 13, 2024
db98cf7
logs etc ...
6543 Jul 13, 2024
26ec73a
more logs
6543 Jul 13, 2024
c0fa694
Merge branch 'main' into urfave/cli/v3
6543 Jul 13, 2024
6db3d3c
use cli context for agent
6543 Jul 13, 2024
49ef51c
make agent pinger context aware
6543 Jul 13, 2024
39606f3
clean
6543 Jul 13, 2024
bdf24ff
clean
6543 Jul 13, 2024
7ade9f0
register signal
6543 Jul 13, 2024
c1e6184
finish
6543 Jul 13, 2024
3dec060
finish
6543 Jul 13, 2024
7c0dd93
next
6543 Jul 13, 2024
ce188a7
more log output
6543 Jul 13, 2024
1953b40
Merge branch 'make-agent-context-aware' into urfave/cli/v3
6543 Jul 13, 2024
5c72479
part
6543 Jul 13, 2024
6970ae7
wow
6543 Jul 13, 2024
2a9dca1
nice log
6543 Jul 13, 2024
6151251
right msg
6543 Jul 13, 2024
aaa3886
Merge branch 'main' into gracefull-server-shutdown
6543 Jul 13, 2024
f89c996
Merge branch 'main' into make-agent-context-aware
6543 Jul 13, 2024
df22280
Merge branch 'main' into gracefull-server-shutdown
6543 Jul 13, 2024
1ffb3c6
reaplay refactor
6543 Jul 13, 2024
378afc2
Merge branch 'main' into make-agent-context-aware
6543 Jul 13, 2024
f950ac7
stop running pipelines gracefully
6543 Jul 13, 2024
8d4e0f2
agent grpc client: handle canceled case and more granualar logging
6543 Jul 13, 2024
9b45260
we now respect the cancel signal
6543 Jul 13, 2024
c4dce1b
look like we need that for now ...
6543 Jul 13, 2024
54bd6a1
Merge branch 'main' into make-agent-context-aware
6543 Jul 13, 2024
314a0e2
Merge branch 'main' into gracefull-server-shutdown
6543 Jul 13, 2024
f9693a2
Merge branch 'main' into make-agent-context-aware
6543 Jul 13, 2024
8d64260
Merge branch 'main' into urfave/cli/v3
6543 Jul 13, 2024
d1eb706
update generated
6543 Jul 13, 2024
3f11810
Merge branch 'make-agent-context-aware' into urfave/cli/v3
6543 Jul 13, 2024
af715a4
Merge branch 'gracefull-server-shutdown' into urfave/cli/v3
6543 Jul 13, 2024
6c8af69
i know what i do
6543 Jul 13, 2024
8adc67e
jup
6543 Jul 13, 2024
2463e6d
Merge branch 'main' into urfave/cli/v3
6543 Jul 13, 2024
3fd1da5
Merge branch 'main' into urfave/cli/v3
6543 Jul 14, 2024
003b8d9
we have the context created earlyer now
6543 Jul 14, 2024
058f28b
Merge branch 'main' into urfave/cli/v3
6543 Jul 16, 2024
ad2b91a
update deps
6543 Jul 16, 2024
33a91d7
Merge branch 'main' into urfave/cli/v3
6543 Jul 17, 2024
fe4aba2
Update pipeline/backend/types/config.go
6543 Jul 17, 2024
2dc3606
Merge branch 'main' into urfave/cli/v3
6543 Jul 17, 2024
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 .golangci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ linters:
- errchkjson
- gochecknoinits
- goheader
- gomoddirectives
# - gomoddirectives # TODO: enable once https://github.com/urfave/cli/pull/1945 merged
- gomodguard
- goprintffuncname
- importas
Expand Down
4 changes: 2 additions & 2 deletions cli/admin/admin.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
package admin

import (
"github.com/urfave/cli/v2"
"github.com/urfave/cli/v3"

"go.woodpecker-ci.org/woodpecker/v2/cli/admin/registry"
)
Expand All @@ -24,7 +24,7 @@ import (
var Command = &cli.Command{
Name: "admin",
Usage: "administer server settings",
Subcommands: []*cli.Command{
Commands: []*cli.Command{
registry.Command,
},
}
4 changes: 2 additions & 2 deletions cli/admin/registry/registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@
package registry

import (
"github.com/urfave/cli/v2"
"github.com/urfave/cli/v3"
)

// Command exports the registry command set.
var Command = &cli.Command{
Name: "registry",
Usage: "manage global registries",
Subcommands: []*cli.Command{
Commands: []*cli.Command{
registryCreateCmd,
registryDeleteCmd,
registryUpdateCmd,
Expand Down
7 changes: 4 additions & 3 deletions cli/admin/registry/registry_add.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,11 @@
package registry

import (
"context"
"os"
"strings"

"github.com/urfave/cli/v2"
"github.com/urfave/cli/v3"

"go.woodpecker-ci.org/woodpecker/v2/cli/internal"
"go.woodpecker-ci.org/woodpecker/v2/woodpecker-go/woodpecker"
Expand All @@ -45,14 +46,14 @@ var registryCreateCmd = &cli.Command{
},
}

func registryCreate(c *cli.Context) error {
func registryCreate(ctx context.Context, c *cli.Command) error {
var (
hostname = c.String("hostname")
username = c.String("username")
password = c.String("password")
)

client, err := internal.NewClient(c)
client, err := internal.NewClient(ctx, c)
if err != nil {
return err
}
Expand Down
7 changes: 4 additions & 3 deletions cli/admin/registry/registry_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,11 @@
package registry

import (
"context"
"html/template"
"os"

"github.com/urfave/cli/v2"
"github.com/urfave/cli/v3"

"go.woodpecker-ci.org/woodpecker/v2/cli/common"
"go.woodpecker-ci.org/woodpecker/v2/cli/internal"
Expand All @@ -38,13 +39,13 @@ var registryInfoCmd = &cli.Command{
},
}

func registryInfo(c *cli.Context) error {
func registryInfo(ctx context.Context, c *cli.Command) error {
var (
hostname = c.String("hostname")
format = c.String("format") + "\n"
)

client, err := internal.NewClient(c)
client, err := internal.NewClient(ctx, c)
if err != nil {
return err
}
Expand Down
7 changes: 4 additions & 3 deletions cli/admin/registry/registry_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,11 @@
package registry

import (
"context"
"html/template"
"os"

"github.com/urfave/cli/v2"
"github.com/urfave/cli/v3"

"go.woodpecker-ci.org/woodpecker/v2/cli/common"
"go.woodpecker-ci.org/woodpecker/v2/cli/internal"
Expand All @@ -33,10 +34,10 @@ var registryListCmd = &cli.Command{
},
}

func registryList(c *cli.Context) error {
func registryList(ctx context.Context, c *cli.Command) error {
format := c.String("format") + "\n"

client, err := internal.NewClient(c)
client, err := internal.NewClient(ctx, c)
if err != nil {
return err
}
Expand Down
8 changes: 5 additions & 3 deletions cli/admin/registry/registry_rm.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@
package registry

import (
"github.com/urfave/cli/v2"
"context"

"github.com/urfave/cli/v3"

"go.woodpecker-ci.org/woodpecker/v2/cli/internal"
)
Expand All @@ -33,10 +35,10 @@ var registryDeleteCmd = &cli.Command{
},
}

func registryDelete(c *cli.Context) error {
func registryDelete(ctx context.Context, c *cli.Command) error {
hostname := c.String("hostname")

client, err := internal.NewClient(c)
client, err := internal.NewClient(ctx, c)
if err != nil {
return err
}
Expand Down
7 changes: 4 additions & 3 deletions cli/admin/registry/registry_set.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,11 @@
package registry

import (
"context"
"os"
"strings"

"github.com/urfave/cli/v2"
"github.com/urfave/cli/v3"

"go.woodpecker-ci.org/woodpecker/v2/cli/common"
"go.woodpecker-ci.org/woodpecker/v2/cli/internal"
Expand Down Expand Up @@ -47,14 +48,14 @@ var registryUpdateCmd = &cli.Command{
},
}

func registryUpdate(c *cli.Context) error {
func registryUpdate(ctx context.Context, c *cli.Command) error {
var (
hostname = c.String("hostname")
username = c.String("username")
password = c.String("password")
)

client, err := internal.NewClient(c)
client, err := internal.NewClient(ctx, c)
if err != nil {
return err
}
Expand Down
16 changes: 8 additions & 8 deletions cli/common/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,49 +15,49 @@
package common

import (
"github.com/urfave/cli/v2"
"github.com/urfave/cli/v3"

"go.woodpecker-ci.org/woodpecker/v2/shared/logger"
)

var GlobalFlags = append([]cli.Flag{
&cli.StringFlag{
EnvVars: []string{"WOODPECKER_CONFIG"},
Sources: cli.EnvVars("WOODPECKER_CONFIG"),
Name: "config",
Aliases: []string{"c"},
Usage: "path to config file",
},
&cli.StringFlag{
EnvVars: []string{"WOODPECKER_SERVER"},
Sources: cli.EnvVars("WOODPECKER_SERVER"),
Name: "server",
Aliases: []string{"s"},
Usage: "server address",
},
&cli.StringFlag{
EnvVars: []string{"WOODPECKER_TOKEN"},
Sources: cli.EnvVars("WOODPECKER_TOKEN"),
Name: "token",
Aliases: []string{"t"},
Usage: "server auth token",
},
&cli.BoolFlag{
EnvVars: []string{"WOODPECKER_DISABLE_UPDATE_CHECK"},
Sources: cli.EnvVars("WOODPECKER_DISABLE_UPDATE_CHECK"),
Name: "disable-update-check",
Usage: "disable update check",
},
&cli.BoolFlag{
EnvVars: []string{"WOODPECKER_SKIP_VERIFY"},
Sources: cli.EnvVars("WOODPECKER_SKIP_VERIFY"),
Name: "skip-verify",
Usage: "skip ssl verification",
Hidden: true,
},
&cli.StringFlag{
EnvVars: []string{"SOCKS_PROXY"},
Sources: cli.EnvVars("SOCKS_PROXY"),
Name: "socks-proxy",
Usage: "socks proxy address",
Hidden: true,
},
&cli.BoolFlag{
EnvVars: []string{"SOCKS_PROXY_OFF"},
Sources: cli.EnvVars("SOCKS_PROXY_OFF"),
Name: "socks-proxy-off",
Usage: "socks proxy ignored",
Hidden: true,
Expand Down
18 changes: 9 additions & 9 deletions cli/common/hooks.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"time"

"github.com/rs/zerolog/log"
"github.com/urfave/cli/v2"
"github.com/urfave/cli/v3"

"go.woodpecker-ci.org/woodpecker/v2/cli/internal/config"
"go.woodpecker-ci.org/woodpecker/v2/cli/update"
Expand All @@ -17,12 +17,12 @@ var (
cancelWaitForUpdate context.CancelCauseFunc
)

func Before(c *cli.Context) error {
if err := setupGlobalLogger(c); err != nil {
func Before(ctx context.Context, c *cli.Command) error {
if err := setupGlobalLogger(ctx, c); err != nil {
return err
}

go func() {
go func(context.Context) {
if c.Bool("disable-update-check") {
return
}
Expand All @@ -37,23 +37,23 @@ func Before(c *cli.Context) error {

log.Debug().Msg("Checking for updates ...")

newVersion, err := update.CheckForUpdate(waitForUpdateCheck, false)
newVersion, err := update.CheckForUpdate(waitForUpdateCheck, false) //nolint:contextcheck
if err != nil {
log.Error().Err(err).Msgf("Failed to check for updates")
return
}

if newVersion != nil {
log.Warn().Msgf("A new version of woodpecker-cli is available: %s. Update by running: %s update", newVersion.Version, c.App.Name)
log.Warn().Msgf("A new version of woodpecker-cli is available: %s. Update by running: %s update", newVersion.Version, c.Root().Name)
} else {
log.Debug().Msgf("No update required")
}
}()
}(ctx)

return config.Load(c)
return config.Load(ctx, c)
}

func After(_ *cli.Context) error {
func After(_ context.Context, _ *cli.Command) error {
if waitForUpdateCheck != nil {
select {
case <-waitForUpdateCheck.Done():
Expand Down
13 changes: 7 additions & 6 deletions cli/common/pipeline.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,12 @@
package common

import (
"context"
"fmt"
"os"
"strings"

"github.com/urfave/cli/v2"
"github.com/urfave/cli/v3"

"go.woodpecker-ci.org/woodpecker/v2/shared/constant"
)
Expand All @@ -37,16 +38,16 @@ func DetectPipelineConfig() (isDir bool, config string, _ error) {
return false, "", fmt.Errorf("could not detect pipeline config")
}

func RunPipelineFunc(c *cli.Context, fileFunc, dirFunc func(*cli.Context, string) error) error {
func RunPipelineFunc(ctx context.Context, c *cli.Command, fileFunc, dirFunc func(context.Context, *cli.Command, string) error) error {
if c.Args().Len() == 0 {
isDir, path, err := DetectPipelineConfig()
if err != nil {
return err
}
if isDir {
return dirFunc(c, path)
return dirFunc(ctx, c, path)
}
return fileFunc(c, path)
return fileFunc(ctx, c, path)
}

multiArgs := c.Args().Len() > 1
Expand All @@ -59,11 +60,11 @@ func RunPipelineFunc(c *cli.Context, fileFunc, dirFunc func(*cli.Context, string
fmt.Println("#", fi.Name())
}
if fi.IsDir() {
if err := dirFunc(c, arg); err != nil {
if err := dirFunc(ctx, c, arg); err != nil {
return err
}
} else {
if err := fileFunc(c, arg); err != nil {
if err := fileFunc(ctx, c, arg); err != nil {
return err
}
}
Expand Down
8 changes: 5 additions & 3 deletions cli/common/zerologger.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,13 @@
package common

import (
"github.com/urfave/cli/v2"
"context"

"github.com/urfave/cli/v3"

"go.woodpecker-ci.org/woodpecker/v2/shared/logger"
)

func setupGlobalLogger(c *cli.Context) error {
return logger.SetupGlobalLogger(c, false)
func setupGlobalLogger(ctx context.Context, c *cli.Command) error {
return logger.SetupGlobalLogger(ctx, c, false)
}
4 changes: 2 additions & 2 deletions cli/cron/cron.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@
package cron

import (
"github.com/urfave/cli/v2"
"github.com/urfave/cli/v3"
)

// Command exports the cron command set.
var Command = &cli.Command{
Name: "cron",
Usage: "manage cron jobs",
Subcommands: []*cli.Command{
Commands: []*cli.Command{
cronCreateCmd,
cronDeleteCmd,
cronUpdateCmd,
Expand Down
Loading