mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2026-03-16 17:54:07 +01:00
Migrate to github.com/urfave/cli/v3 (#2951)
This commit is contained in:
@@ -18,7 +18,7 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
|
||||
"github.com/urfave/cli/v2"
|
||||
"github.com/urfave/cli/v3"
|
||||
|
||||
"go.woodpecker-ci.org/woodpecker/v2/server/services/encryption/types"
|
||||
"go.woodpecker-ci.org/woodpecker/v2/server/store"
|
||||
@@ -30,8 +30,8 @@ type aesConfiguration struct {
|
||||
clients []types.EncryptionClient
|
||||
}
|
||||
|
||||
func newAES(ctx *cli.Context, s store.Store) types.EncryptionServiceBuilder {
|
||||
key := ctx.String(rawKeyConfigFlag)
|
||||
func newAES(c *cli.Command, s store.Store) types.EncryptionServiceBuilder {
|
||||
key := c.String(rawKeyConfigFlag)
|
||||
return &aesConfiguration{key, s, nil}
|
||||
}
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ package encryption
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/urfave/cli/v2"
|
||||
"github.com/urfave/cli/v3"
|
||||
|
||||
"go.woodpecker-ci.org/woodpecker/v2/server/services/encryption/types"
|
||||
"go.woodpecker-ci.org/woodpecker/v2/server/store"
|
||||
@@ -25,12 +25,12 @@ import (
|
||||
|
||||
type builder struct {
|
||||
store store.Store
|
||||
ctx *cli.Context
|
||||
c *cli.Command
|
||||
clients []types.EncryptionClient
|
||||
}
|
||||
|
||||
func Encryption(ctx *cli.Context, s store.Store) types.EncryptionBuilder {
|
||||
return &builder{store: s, ctx: ctx}
|
||||
func Encryption(c *cli.Command, s store.Store) types.EncryptionBuilder {
|
||||
return &builder{store: s, c: c}
|
||||
}
|
||||
|
||||
func (b builder) WithClient(client types.EncryptionClient) types.EncryptionBuilder {
|
||||
@@ -44,7 +44,7 @@ func (b builder) Build() error {
|
||||
return err
|
||||
}
|
||||
|
||||
disableFlag := b.ctx.Bool(disableEncryptionConfigFlag)
|
||||
disableFlag := b.c.Bool(disableEncryptionConfigFlag)
|
||||
|
||||
keyType, err := b.detectKeyType()
|
||||
if err != nil {
|
||||
|
||||
@@ -48,8 +48,8 @@ func (b builder) isEnabled() (bool, error) {
|
||||
}
|
||||
|
||||
func (b builder) detectKeyType() (string, error) {
|
||||
rawKeyPresent := b.ctx.IsSet(rawKeyConfigFlag)
|
||||
tinkKeysetPresent := b.ctx.IsSet(tinkKeysetFilepathConfigFlag)
|
||||
rawKeyPresent := b.c.IsSet(rawKeyConfigFlag)
|
||||
tinkKeysetPresent := b.c.IsSet(tinkKeysetFilepathConfigFlag)
|
||||
switch {
|
||||
case rawKeyPresent && tinkKeysetPresent:
|
||||
return "", errors.New(errMessageCantUseBothServices)
|
||||
@@ -64,9 +64,9 @@ func (b builder) detectKeyType() (string, error) {
|
||||
func (b builder) serviceBuilder(keyType string) (types.EncryptionServiceBuilder, error) {
|
||||
switch {
|
||||
case keyType == keyTypeTink:
|
||||
return newTink(b.ctx, b.store), nil
|
||||
return newTink(b.c, b.store), nil
|
||||
case keyType == keyTypeRaw:
|
||||
return newAES(b.ctx, b.store), nil
|
||||
return newAES(b.c, b.store), nil
|
||||
case keyType == keyTypeNone:
|
||||
return &noEncryptionBuilder{}, nil
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
|
||||
"github.com/urfave/cli/v2"
|
||||
"github.com/urfave/cli/v3"
|
||||
|
||||
"go.woodpecker-ci.org/woodpecker/v2/server/services/encryption/types"
|
||||
"go.woodpecker-ci.org/woodpecker/v2/server/store"
|
||||
@@ -30,8 +30,8 @@ type tinkConfiguration struct {
|
||||
clients []types.EncryptionClient
|
||||
}
|
||||
|
||||
func newTink(ctx *cli.Context, s store.Store) types.EncryptionServiceBuilder {
|
||||
filepath := ctx.String(tinkKeysetFilepathConfigFlag)
|
||||
func newTink(c *cli.Command, s store.Store) types.EncryptionServiceBuilder {
|
||||
filepath := c.String(tinkKeysetFilepathConfigFlag)
|
||||
return &tinkConfiguration{filepath, s, nil}
|
||||
}
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/jellydator/ttlcache/v3"
|
||||
"github.com/urfave/cli/v2"
|
||||
"github.com/urfave/cli/v3"
|
||||
|
||||
"go.woodpecker-ci.org/woodpecker/v2/server/forge"
|
||||
"go.woodpecker-ci.org/woodpecker/v2/server/model"
|
||||
@@ -61,7 +61,7 @@ type manager struct {
|
||||
setupForge SetupForge
|
||||
}
|
||||
|
||||
func NewManager(c *cli.Context, store store.Store, setupForge SetupForge) (Manager, error) {
|
||||
func NewManager(c *cli.Command, store store.Store, setupForge SetupForge) (Manager, error) {
|
||||
signaturePrivateKey, signaturePublicKey, err := setupSignatureKeys(store)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
||||
@@ -24,7 +24,7 @@ import (
|
||||
"strings"
|
||||
|
||||
"github.com/rs/zerolog/log"
|
||||
"github.com/urfave/cli/v2"
|
||||
"github.com/urfave/cli/v3"
|
||||
|
||||
"go.woodpecker-ci.org/woodpecker/v2/server/model"
|
||||
"go.woodpecker-ci.org/woodpecker/v2/server/services/config"
|
||||
@@ -57,13 +57,13 @@ func setupSecretService(store store.Store) secret.Service {
|
||||
return secret.NewDB(store)
|
||||
}
|
||||
|
||||
func setupConfigService(c *cli.Context, privateSignatureKey crypto.PrivateKey) (config.Service, error) {
|
||||
func setupConfigService(c *cli.Command, privateSignatureKey crypto.PrivateKey) (config.Service, error) {
|
||||
timeout := c.Duration("forge-timeout")
|
||||
retries := c.Uint("forge-retry")
|
||||
if retries == 0 {
|
||||
return nil, fmt.Errorf("WOODPECKER_FORGE_RETRY can not be 0")
|
||||
}
|
||||
configFetcher := config.NewForge(timeout, retries)
|
||||
configFetcher := config.NewForge(timeout, uint(retries))
|
||||
|
||||
if endpoint := c.String("config-service-endpoint"); endpoint != "" {
|
||||
httpFetcher := config.NewHTTP(endpoint, privateSignatureKey)
|
||||
@@ -100,7 +100,7 @@ func setupSignatureKeys(_store store.Store) (crypto.PrivateKey, crypto.PublicKey
|
||||
return privateKey, privateKey.Public(), nil
|
||||
}
|
||||
|
||||
func setupForgeService(c *cli.Context, _store store.Store) error {
|
||||
func setupForgeService(c *cli.Command, _store store.Store) error {
|
||||
_forge, err := _store.ForgeGet(1)
|
||||
if err != nil && !errors.Is(err, types.RecordNotExist) {
|
||||
return err
|
||||
|
||||
Reference in New Issue
Block a user