Skip to content

Commit

Permalink
Update urfave/cli/v2 to urfave/cli/v3 (#944)
Browse files Browse the repository at this point in the history
  • Loading branch information
serprex authored Dec 31, 2023
1 parent c6e284e commit 06e4197
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 39 deletions.
4 changes: 2 additions & 2 deletions flow/cmd/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ import (

type APIServerParams struct {
ctx context.Context
Port uint
GatewayPort uint
Port uint16
GatewayPort uint16
TemporalHostPort string
TemporalNamespace string
TemporalCert string
Expand Down
56 changes: 28 additions & 28 deletions flow/cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"syscall"

"github.com/PeerDB-io/peer-flow/logger"
"github.com/urfave/cli/v2"
"github.com/urfave/cli/v3"
_ "go.uber.org/automaxprocs"
)

Expand All @@ -29,56 +29,56 @@ func main() {
temporalHostPortFlag := &cli.StringFlag{
Name: "temporal-host-port",
Value: "localhost:7233",
EnvVars: []string{"TEMPORAL_HOST_PORT"},
Sources: cli.EnvVars("TEMPORAL_HOST_PORT"),
}

temporalCertFlag := cli.StringFlag{
Name: "temporal-cert",
Value: "", // default: no cert needed
EnvVars: []string{"TEMPORAL_CLIENT_CERT"},
Sources: cli.EnvVars("TEMPORAL_CLIENT_CERT"),
}

temporalKeyFlag := cli.StringFlag{
Name: "temporal-key",
Value: "", // default: no key needed
EnvVars: []string{"TEMPORAL_CLIENT_KEY"},
Sources: cli.EnvVars("TEMPORAL_CLIENT_KEY"),
}

profilingFlag := &cli.BoolFlag{
Name: "enable-profiling",
Value: false, // Default is off
Usage: "Enable profiling for the application",
EnvVars: []string{"ENABLE_PROFILING"},
Sources: cli.EnvVars("ENABLE_PROFILING"),
}

pyroscopeServerFlag := &cli.StringFlag{
Name: "pyroscope-server-address",
Value: "http://pyroscope:4040",
Usage: "HTTP server address for pyroscope",
EnvVars: []string{"PYROSCOPE_SERVER_ADDRESS"},
Sources: cli.EnvVars("PYROSCOPE_SERVER_ADDRESS"),
}

temporalNamespaceFlag := &cli.StringFlag{
Name: "temporal-namespace",
Value: "default",
Usage: "Temporal namespace to use for workflow orchestration",
EnvVars: []string{"PEERDB_TEMPORAL_NAMESPACE"},
Sources: cli.EnvVars("PEERDB_TEMPORAL_NAMESPACE"),
}

app := &cli.App{
app := &cli.Command{
Name: "PeerDB Flows CLI",
Commands: []*cli.Command{
{
Name: "worker",
Action: func(ctx *cli.Context) error {
temporalHostPort := ctx.String("temporal-host-port")
Action: func(ctx context.Context, cmd *cli.Command) error {
temporalHostPort := cmd.String("temporal-host-port")
return WorkerMain(&WorkerOptions{
TemporalHostPort: temporalHostPort,
EnableProfiling: ctx.Bool("enable-profiling"),
PyroscopeServer: ctx.String("pyroscope-server-address"),
TemporalNamespace: ctx.String("temporal-namespace"),
TemporalCert: ctx.String("temporal-cert"),
TemporalKey: ctx.String("temporal-key"),
EnableProfiling: cmd.Bool("enable-profiling"),
PyroscopeServer: cmd.String("pyroscope-server-address"),
TemporalNamespace: cmd.String("temporal-namespace"),
TemporalCert: cmd.String("temporal-cert"),
TemporalKey: cmd.String("temporal-key"),
})
},
Flags: []cli.Flag{
Expand All @@ -92,13 +92,13 @@ func main() {
},
{
Name: "snapshot-worker",
Action: func(ctx *cli.Context) error {
temporalHostPort := ctx.String("temporal-host-port")
Action: func(ctx context.Context, cmd *cli.Command) error {
temporalHostPort := cmd.String("temporal-host-port")
return SnapshotWorkerMain(&SnapshotWorkerOptions{
TemporalHostPort: temporalHostPort,
TemporalNamespace: ctx.String("temporal-namespace"),
TemporalCert: ctx.String("temporal-cert"),
TemporalKey: ctx.String("temporal-key"),
TemporalNamespace: cmd.String("temporal-namespace"),
TemporalCert: cmd.String("temporal-cert"),
TemporalKey: cmd.String("temporal-key"),
})
},
Flags: []cli.Flag{
Expand Down Expand Up @@ -126,24 +126,24 @@ func main() {
&temporalCertFlag,
&temporalKeyFlag,
},
Action: func(ctx *cli.Context) error {
temporalHostPort := ctx.String("temporal-host-port")
Action: func(ctx context.Context, cmd *cli.Command) error {
temporalHostPort := cmd.String("temporal-host-port")

return APIMain(&APIServerParams{
ctx: appCtx,
Port: ctx.Uint("port"),
Port: uint16(cmd.Uint("port")),
TemporalHostPort: temporalHostPort,
GatewayPort: ctx.Uint("gateway-port"),
TemporalNamespace: ctx.String("temporal-namespace"),
TemporalCert: ctx.String("temporal-cert"),
TemporalKey: ctx.String("temporal-key"),
GatewayPort: uint16(cmd.Uint("gateway-port")),
TemporalNamespace: cmd.String("temporal-namespace"),
TemporalCert: cmd.String("temporal-cert"),
TemporalKey: cmd.String("temporal-key"),
})
},
},
},
}

if err := app.Run(os.Args); err != nil {
if err := app.Run(context.Background(), os.Args); err != nil {
log.Fatalf("error running app: %v", err)
}
}
4 changes: 1 addition & 3 deletions flow/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ require (
github.com/snowflakedb/gosnowflake v1.7.1
github.com/stretchr/testify v1.8.4
github.com/twpayne/go-geos v0.14.0
github.com/urfave/cli/v2 v2.26.0
github.com/urfave/cli/v3 v3.0.0-alpha8
github.com/youmark/pkcs8 v0.0.0-20201027041543-1326539a0a0a
github.com/ysmood/got v0.38.2
go.temporal.io/api v1.26.0
Expand Down Expand Up @@ -102,7 +102,6 @@ require (
github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.16.9 // indirect
github.com/aws/aws-sdk-go-v2/service/s3 v1.47.7 // indirect
github.com/aws/smithy-go v1.19.0 // indirect
github.com/cpuguy83/go-md2man/v2 v2.0.3 // indirect
github.com/danieljoos/wincred v1.2.1 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/dvsekhvalnov/jose2go v1.6.0 // indirect
Expand Down Expand Up @@ -145,7 +144,6 @@ require (
github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/robfig/cron v1.2.0 // indirect
github.com/russross/blackfriday/v2 v2.1.0 // indirect
github.com/stretchr/objx v0.5.1 // indirect
github.com/xrash/smetrics v0.0.0-20231213231151-1d8dd44e695e // indirect
github.com/zeebo/xxh3 v1.0.2 // indirect
Expand Down
8 changes: 2 additions & 6 deletions flow/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,6 @@ github.com/cockroachdb/redact v1.1.5 h1:u1PMllDkdFfPWaNGMyLD1+so+aq3uUItthCFqzwP
github.com/cockroachdb/redact v1.1.5/go.mod h1:BVNblN9mBWFyMyqK1k3AAiSxhvhfK2oOZZ2lK+dpvRg=
github.com/cockroachdb/tokenbucket v0.0.0-20230807174530-cc333fc44b06 h1:zuQyyAKVxetITBuuhv3BI9cMrmStnpT18zmgmTxunpo=
github.com/cockroachdb/tokenbucket v0.0.0-20230807174530-cc333fc44b06/go.mod h1:7nc4anLGjupUW/PeY5qiNYsdNXj7zopG+eqsS7To5IQ=
github.com/cpuguy83/go-md2man/v2 v2.0.3 h1:qMCsGGgs+MAzDFyp9LpAe1Lqy/fY/qCovCm0qnXZOBM=
github.com/cpuguy83/go-md2man/v2 v2.0.3/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
github.com/danieljoos/wincred v1.2.1 h1:dl9cBrupW8+r5250DYkYxocLeZ1Y4vB1kxgtjxw8GQs=
github.com/danieljoos/wincred v1.2.1/go.mod h1:uGaFL9fDn3OLTvzCGulzE+SzjEe5NGlh5FdCcyfPwps=
Expand Down Expand Up @@ -354,8 +352,6 @@ github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTE
github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs=
github.com/rogpeppe/go-internal v1.12.0 h1:exVL4IDcn6na9z1rAb56Vxr+CgyK3nn3O+epU5NdKM8=
github.com/rogpeppe/go-internal v1.12.0/go.mod h1:E+RYuTGaKKdloAfM02xzb0FW3Paa99yedzYV+kq4uf4=
github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk=
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE=
github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ=
github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ=
Expand Down Expand Up @@ -383,8 +379,8 @@ github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcU
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
github.com/twpayne/go-geos v0.14.0 h1:yFPDj6EZq2rL74eOSn40tZA8zOnv6sRFFdtDWR7KpQ4=
github.com/twpayne/go-geos v0.14.0/go.mod h1:K6llLdkCFVIrUgGFs5V/DRS1jpwAXq8xxm2uwtlFT40=
github.com/urfave/cli/v2 v2.26.0 h1:3f3AMg3HpThFNT4I++TKOejZO8yU55t3JnnSr4S4QEI=
github.com/urfave/cli/v2 v2.26.0/go.mod h1:8qnjx1vcq5s2/wpsqoZFndg2CE5tNFyrTvS6SinrnYQ=
github.com/urfave/cli/v3 v3.0.0-alpha8 h1:H+qxFPoCkGzdF8KUMs2fEOZl5io/1QySgUiGfar8occ=
github.com/urfave/cli/v3 v3.0.0-alpha8/go.mod h1:0kK/RUFHyh+yIKSfWxwheGndfnrvYSmYFVeKCh03ZUc=
github.com/xrash/smetrics v0.0.0-20231213231151-1d8dd44e695e h1:+SOyEddqYF09QP7vr7CgJ1eti3pY9Fn3LHO1M1r/0sI=
github.com/xrash/smetrics v0.0.0-20231213231151-1d8dd44e695e/go.mod h1:N3UwUGtsrSj3ccvlPHLoLsHnpR27oXr4ZE984MbSER8=
github.com/youmark/pkcs8 v0.0.0-20201027041543-1326539a0a0a h1:fZHgsYlfvtyqToslyjUt3VOPF4J7aK/3MPcK7xp3PDk=
Expand Down

0 comments on commit 06e4197

Please sign in to comment.