mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-11-24 08:02:18 +02:00
Migrate to github.com/urfave/cli/v3 (#2951)
This commit is contained in:
parent
e39345688d
commit
cd5f6f71a2
@ -15,7 +15,7 @@
|
|||||||
package admin
|
package admin
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/urfave/cli/v2"
|
"github.com/urfave/cli/v3"
|
||||||
|
|
||||||
"go.woodpecker-ci.org/woodpecker/v2/cli/admin/registry"
|
"go.woodpecker-ci.org/woodpecker/v2/cli/admin/registry"
|
||||||
)
|
)
|
||||||
@ -24,7 +24,7 @@ import (
|
|||||||
var Command = &cli.Command{
|
var Command = &cli.Command{
|
||||||
Name: "admin",
|
Name: "admin",
|
||||||
Usage: "administer server settings",
|
Usage: "administer server settings",
|
||||||
Subcommands: []*cli.Command{
|
Commands: []*cli.Command{
|
||||||
registry.Command,
|
registry.Command,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -15,14 +15,14 @@
|
|||||||
package registry
|
package registry
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/urfave/cli/v2"
|
"github.com/urfave/cli/v3"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Command exports the registry command set.
|
// Command exports the registry command set.
|
||||||
var Command = &cli.Command{
|
var Command = &cli.Command{
|
||||||
Name: "registry",
|
Name: "registry",
|
||||||
Usage: "manage global registries",
|
Usage: "manage global registries",
|
||||||
Subcommands: []*cli.Command{
|
Commands: []*cli.Command{
|
||||||
registryCreateCmd,
|
registryCreateCmd,
|
||||||
registryDeleteCmd,
|
registryDeleteCmd,
|
||||||
registryUpdateCmd,
|
registryUpdateCmd,
|
||||||
|
@ -15,10 +15,11 @@
|
|||||||
package registry
|
package registry
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"os"
|
"os"
|
||||||
"strings"
|
"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/cli/internal"
|
||||||
"go.woodpecker-ci.org/woodpecker/v2/woodpecker-go/woodpecker"
|
"go.woodpecker-ci.org/woodpecker/v2/woodpecker-go/woodpecker"
|
||||||
@ -45,14 +46,14 @@ var registryCreateCmd = &cli.Command{
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
func registryCreate(c *cli.Context) error {
|
func registryCreate(ctx context.Context, c *cli.Command) error {
|
||||||
var (
|
var (
|
||||||
hostname = c.String("hostname")
|
hostname = c.String("hostname")
|
||||||
username = c.String("username")
|
username = c.String("username")
|
||||||
password = c.String("password")
|
password = c.String("password")
|
||||||
)
|
)
|
||||||
|
|
||||||
client, err := internal.NewClient(c)
|
client, err := internal.NewClient(ctx, c)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -15,10 +15,11 @@
|
|||||||
package registry
|
package registry
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"html/template"
|
"html/template"
|
||||||
"os"
|
"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/common"
|
||||||
"go.woodpecker-ci.org/woodpecker/v2/cli/internal"
|
"go.woodpecker-ci.org/woodpecker/v2/cli/internal"
|
||||||
@ -38,13 +39,13 @@ var registryInfoCmd = &cli.Command{
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
func registryInfo(c *cli.Context) error {
|
func registryInfo(ctx context.Context, c *cli.Command) error {
|
||||||
var (
|
var (
|
||||||
hostname = c.String("hostname")
|
hostname = c.String("hostname")
|
||||||
format = c.String("format") + "\n"
|
format = c.String("format") + "\n"
|
||||||
)
|
)
|
||||||
|
|
||||||
client, err := internal.NewClient(c)
|
client, err := internal.NewClient(ctx, c)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -15,10 +15,11 @@
|
|||||||
package registry
|
package registry
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"html/template"
|
"html/template"
|
||||||
"os"
|
"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/common"
|
||||||
"go.woodpecker-ci.org/woodpecker/v2/cli/internal"
|
"go.woodpecker-ci.org/woodpecker/v2/cli/internal"
|
||||||
@ -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"
|
format := c.String("format") + "\n"
|
||||||
|
|
||||||
client, err := internal.NewClient(c)
|
client, err := internal.NewClient(ctx, c)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,9 @@
|
|||||||
package registry
|
package registry
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/urfave/cli/v2"
|
"context"
|
||||||
|
|
||||||
|
"github.com/urfave/cli/v3"
|
||||||
|
|
||||||
"go.woodpecker-ci.org/woodpecker/v2/cli/internal"
|
"go.woodpecker-ci.org/woodpecker/v2/cli/internal"
|
||||||
)
|
)
|
||||||
@ -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")
|
hostname := c.String("hostname")
|
||||||
|
|
||||||
client, err := internal.NewClient(c)
|
client, err := internal.NewClient(ctx, c)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -15,10 +15,11 @@
|
|||||||
package registry
|
package registry
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"os"
|
"os"
|
||||||
"strings"
|
"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/common"
|
||||||
"go.woodpecker-ci.org/woodpecker/v2/cli/internal"
|
"go.woodpecker-ci.org/woodpecker/v2/cli/internal"
|
||||||
@ -47,14 +48,14 @@ var registryUpdateCmd = &cli.Command{
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
func registryUpdate(c *cli.Context) error {
|
func registryUpdate(ctx context.Context, c *cli.Command) error {
|
||||||
var (
|
var (
|
||||||
hostname = c.String("hostname")
|
hostname = c.String("hostname")
|
||||||
username = c.String("username")
|
username = c.String("username")
|
||||||
password = c.String("password")
|
password = c.String("password")
|
||||||
)
|
)
|
||||||
|
|
||||||
client, err := internal.NewClient(c)
|
client, err := internal.NewClient(ctx, c)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -15,49 +15,49 @@
|
|||||||
package common
|
package common
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/urfave/cli/v2"
|
"github.com/urfave/cli/v3"
|
||||||
|
|
||||||
"go.woodpecker-ci.org/woodpecker/v2/shared/logger"
|
"go.woodpecker-ci.org/woodpecker/v2/shared/logger"
|
||||||
)
|
)
|
||||||
|
|
||||||
var GlobalFlags = append([]cli.Flag{
|
var GlobalFlags = append([]cli.Flag{
|
||||||
&cli.StringFlag{
|
&cli.StringFlag{
|
||||||
EnvVars: []string{"WOODPECKER_CONFIG"},
|
Sources: cli.EnvVars("WOODPECKER_CONFIG"),
|
||||||
Name: "config",
|
Name: "config",
|
||||||
Aliases: []string{"c"},
|
Aliases: []string{"c"},
|
||||||
Usage: "path to config file",
|
Usage: "path to config file",
|
||||||
},
|
},
|
||||||
&cli.StringFlag{
|
&cli.StringFlag{
|
||||||
EnvVars: []string{"WOODPECKER_SERVER"},
|
Sources: cli.EnvVars("WOODPECKER_SERVER"),
|
||||||
Name: "server",
|
Name: "server",
|
||||||
Aliases: []string{"s"},
|
Aliases: []string{"s"},
|
||||||
Usage: "server address",
|
Usage: "server address",
|
||||||
},
|
},
|
||||||
&cli.StringFlag{
|
&cli.StringFlag{
|
||||||
EnvVars: []string{"WOODPECKER_TOKEN"},
|
Sources: cli.EnvVars("WOODPECKER_TOKEN"),
|
||||||
Name: "token",
|
Name: "token",
|
||||||
Aliases: []string{"t"},
|
Aliases: []string{"t"},
|
||||||
Usage: "server auth token",
|
Usage: "server auth token",
|
||||||
},
|
},
|
||||||
&cli.BoolFlag{
|
&cli.BoolFlag{
|
||||||
EnvVars: []string{"WOODPECKER_DISABLE_UPDATE_CHECK"},
|
Sources: cli.EnvVars("WOODPECKER_DISABLE_UPDATE_CHECK"),
|
||||||
Name: "disable-update-check",
|
Name: "disable-update-check",
|
||||||
Usage: "disable update check",
|
Usage: "disable update check",
|
||||||
},
|
},
|
||||||
&cli.BoolFlag{
|
&cli.BoolFlag{
|
||||||
EnvVars: []string{"WOODPECKER_SKIP_VERIFY"},
|
Sources: cli.EnvVars("WOODPECKER_SKIP_VERIFY"),
|
||||||
Name: "skip-verify",
|
Name: "skip-verify",
|
||||||
Usage: "skip ssl verification",
|
Usage: "skip ssl verification",
|
||||||
Hidden: true,
|
Hidden: true,
|
||||||
},
|
},
|
||||||
&cli.StringFlag{
|
&cli.StringFlag{
|
||||||
EnvVars: []string{"SOCKS_PROXY"},
|
Sources: cli.EnvVars("SOCKS_PROXY"),
|
||||||
Name: "socks-proxy",
|
Name: "socks-proxy",
|
||||||
Usage: "socks proxy address",
|
Usage: "socks proxy address",
|
||||||
Hidden: true,
|
Hidden: true,
|
||||||
},
|
},
|
||||||
&cli.BoolFlag{
|
&cli.BoolFlag{
|
||||||
EnvVars: []string{"SOCKS_PROXY_OFF"},
|
Sources: cli.EnvVars("SOCKS_PROXY_OFF"),
|
||||||
Name: "socks-proxy-off",
|
Name: "socks-proxy-off",
|
||||||
Usage: "socks proxy ignored",
|
Usage: "socks proxy ignored",
|
||||||
Hidden: true,
|
Hidden: true,
|
||||||
|
@ -6,7 +6,7 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/rs/zerolog/log"
|
"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/internal/config"
|
||||||
"go.woodpecker-ci.org/woodpecker/v2/cli/update"
|
"go.woodpecker-ci.org/woodpecker/v2/cli/update"
|
||||||
@ -17,12 +17,12 @@ var (
|
|||||||
cancelWaitForUpdate context.CancelCauseFunc
|
cancelWaitForUpdate context.CancelCauseFunc
|
||||||
)
|
)
|
||||||
|
|
||||||
func Before(c *cli.Context) error {
|
func Before(ctx context.Context, c *cli.Command) error {
|
||||||
if err := setupGlobalLogger(c); err != nil {
|
if err := setupGlobalLogger(ctx, c); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
go func() {
|
go func(context.Context) {
|
||||||
if c.Bool("disable-update-check") {
|
if c.Bool("disable-update-check") {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -37,23 +37,23 @@ func Before(c *cli.Context) error {
|
|||||||
|
|
||||||
log.Debug().Msg("Checking for updates ...")
|
log.Debug().Msg("Checking for updates ...")
|
||||||
|
|
||||||
newVersion, err := update.CheckForUpdate(waitForUpdateCheck, false)
|
newVersion, err := update.CheckForUpdate(waitForUpdateCheck, false) //nolint:contextcheck
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error().Err(err).Msgf("Failed to check for updates")
|
log.Error().Err(err).Msgf("Failed to check for updates")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if newVersion != nil {
|
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 {
|
} else {
|
||||||
log.Debug().Msgf("No update required")
|
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 {
|
if waitForUpdateCheck != nil {
|
||||||
select {
|
select {
|
||||||
case <-waitForUpdateCheck.Done():
|
case <-waitForUpdateCheck.Done():
|
||||||
|
@ -15,11 +15,12 @@
|
|||||||
package common
|
package common
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/urfave/cli/v2"
|
"github.com/urfave/cli/v3"
|
||||||
|
|
||||||
"go.woodpecker-ci.org/woodpecker/v2/shared/constant"
|
"go.woodpecker-ci.org/woodpecker/v2/shared/constant"
|
||||||
)
|
)
|
||||||
@ -37,16 +38,16 @@ func DetectPipelineConfig() (isDir bool, config string, _ error) {
|
|||||||
return false, "", fmt.Errorf("could not detect pipeline config")
|
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 {
|
if c.Args().Len() == 0 {
|
||||||
isDir, path, err := DetectPipelineConfig()
|
isDir, path, err := DetectPipelineConfig()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if isDir {
|
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
|
multiArgs := c.Args().Len() > 1
|
||||||
@ -59,11 +60,11 @@ func RunPipelineFunc(c *cli.Context, fileFunc, dirFunc func(*cli.Context, string
|
|||||||
fmt.Println("#", fi.Name())
|
fmt.Println("#", fi.Name())
|
||||||
}
|
}
|
||||||
if fi.IsDir() {
|
if fi.IsDir() {
|
||||||
if err := dirFunc(c, arg); err != nil {
|
if err := dirFunc(ctx, c, arg); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if err := fileFunc(c, arg); err != nil {
|
if err := fileFunc(ctx, c, arg); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,11 +15,13 @@
|
|||||||
package common
|
package common
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/urfave/cli/v2"
|
"context"
|
||||||
|
|
||||||
|
"github.com/urfave/cli/v3"
|
||||||
|
|
||||||
"go.woodpecker-ci.org/woodpecker/v2/shared/logger"
|
"go.woodpecker-ci.org/woodpecker/v2/shared/logger"
|
||||||
)
|
)
|
||||||
|
|
||||||
func setupGlobalLogger(c *cli.Context) error {
|
func setupGlobalLogger(ctx context.Context, c *cli.Command) error {
|
||||||
return logger.SetupGlobalLogger(c, false)
|
return logger.SetupGlobalLogger(ctx, c, false)
|
||||||
}
|
}
|
||||||
|
@ -15,14 +15,14 @@
|
|||||||
package cron
|
package cron
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/urfave/cli/v2"
|
"github.com/urfave/cli/v3"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Command exports the cron command set.
|
// Command exports the cron command set.
|
||||||
var Command = &cli.Command{
|
var Command = &cli.Command{
|
||||||
Name: "cron",
|
Name: "cron",
|
||||||
Usage: "manage cron jobs",
|
Usage: "manage cron jobs",
|
||||||
Subcommands: []*cli.Command{
|
Commands: []*cli.Command{
|
||||||
cronCreateCmd,
|
cronCreateCmd,
|
||||||
cronDeleteCmd,
|
cronDeleteCmd,
|
||||||
cronUpdateCmd,
|
cronUpdateCmd,
|
||||||
|
@ -15,10 +15,11 @@
|
|||||||
package cron
|
package cron
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"html/template"
|
"html/template"
|
||||||
"os"
|
"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/common"
|
||||||
"go.woodpecker-ci.org/woodpecker/v2/cli/internal"
|
"go.woodpecker-ci.org/woodpecker/v2/cli/internal"
|
||||||
@ -50,9 +51,9 @@ var cronCreateCmd = &cli.Command{
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
func cronCreate(c *cli.Context) error {
|
func cronCreate(ctx context.Context, c *cli.Command) error {
|
||||||
var (
|
var (
|
||||||
jobName = c.String("name")
|
cronName = c.String("name")
|
||||||
branch = c.String("branch")
|
branch = c.String("branch")
|
||||||
schedule = c.String("schedule")
|
schedule = c.String("schedule")
|
||||||
repoIDOrFullName = c.String("repository")
|
repoIDOrFullName = c.String("repository")
|
||||||
@ -62,7 +63,7 @@ func cronCreate(c *cli.Context) error {
|
|||||||
repoIDOrFullName = c.Args().First()
|
repoIDOrFullName = c.Args().First()
|
||||||
}
|
}
|
||||||
|
|
||||||
client, err := internal.NewClient(c)
|
client, err := internal.NewClient(ctx, c)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -73,7 +74,7 @@ func cronCreate(c *cli.Context) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
cron := &woodpecker.Cron{
|
cron := &woodpecker.Cron{
|
||||||
Name: jobName,
|
Name: cronName,
|
||||||
Branch: branch,
|
Branch: branch,
|
||||||
Schedule: schedule,
|
Schedule: schedule,
|
||||||
}
|
}
|
||||||
|
@ -15,10 +15,11 @@
|
|||||||
package cron
|
package cron
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"html/template"
|
"html/template"
|
||||||
"os"
|
"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/common"
|
||||||
"go.woodpecker-ci.org/woodpecker/v2/cli/internal"
|
"go.woodpecker-ci.org/woodpecker/v2/cli/internal"
|
||||||
@ -40,16 +41,16 @@ var cronInfoCmd = &cli.Command{
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
func cronInfo(c *cli.Context) error {
|
func cronInfo(ctx context.Context, c *cli.Command) error {
|
||||||
var (
|
var (
|
||||||
jobID = c.Int64("id")
|
cronID = c.Int("id")
|
||||||
repoIDOrFullName = c.String("repository")
|
repoIDOrFullName = c.String("repository")
|
||||||
format = c.String("format") + "\n"
|
format = c.String("format") + "\n"
|
||||||
)
|
)
|
||||||
if repoIDOrFullName == "" {
|
if repoIDOrFullName == "" {
|
||||||
repoIDOrFullName = c.Args().First()
|
repoIDOrFullName = c.Args().First()
|
||||||
}
|
}
|
||||||
client, err := internal.NewClient(c)
|
client, err := internal.NewClient(ctx, c)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -58,7 +59,7 @@ func cronInfo(c *cli.Context) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
cron, err := client.CronGet(repoID, jobID)
|
cron, err := client.CronGet(repoID, cronID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -15,10 +15,11 @@
|
|||||||
package cron
|
package cron
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"html/template"
|
"html/template"
|
||||||
"os"
|
"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/common"
|
||||||
"go.woodpecker-ci.org/woodpecker/v2/cli/internal"
|
"go.woodpecker-ci.org/woodpecker/v2/cli/internal"
|
||||||
@ -35,7 +36,7 @@ var cronListCmd = &cli.Command{
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
func cronList(c *cli.Context) error {
|
func cronList(ctx context.Context, c *cli.Command) error {
|
||||||
var (
|
var (
|
||||||
format = c.String("format") + "\n"
|
format = c.String("format") + "\n"
|
||||||
repoIDOrFullName = c.String("repository")
|
repoIDOrFullName = c.String("repository")
|
||||||
@ -43,7 +44,7 @@ func cronList(c *cli.Context) error {
|
|||||||
if repoIDOrFullName == "" {
|
if repoIDOrFullName == "" {
|
||||||
repoIDOrFullName = c.Args().First()
|
repoIDOrFullName = c.Args().First()
|
||||||
}
|
}
|
||||||
client, err := internal.NewClient(c)
|
client, err := internal.NewClient(ctx, c)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -15,9 +15,10 @@
|
|||||||
package cron
|
package cron
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"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/common"
|
||||||
"go.woodpecker-ci.org/woodpecker/v2/cli/internal"
|
"go.woodpecker-ci.org/woodpecker/v2/cli/internal"
|
||||||
@ -38,15 +39,15 @@ var cronDeleteCmd = &cli.Command{
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
func cronDelete(c *cli.Context) error {
|
func cronDelete(ctx context.Context, c *cli.Command) error {
|
||||||
var (
|
var (
|
||||||
jobID = c.Int64("id")
|
cronID = c.Int("id")
|
||||||
repoIDOrFullName = c.String("repository")
|
repoIDOrFullName = c.String("repository")
|
||||||
)
|
)
|
||||||
if repoIDOrFullName == "" {
|
if repoIDOrFullName == "" {
|
||||||
repoIDOrFullName = c.Args().First()
|
repoIDOrFullName = c.Args().First()
|
||||||
}
|
}
|
||||||
client, err := internal.NewClient(c)
|
client, err := internal.NewClient(ctx, c)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -54,7 +55,7 @@ func cronDelete(c *cli.Context) error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
err = client.CronDelete(repoID, jobID)
|
err = client.CronDelete(repoID, cronID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -15,10 +15,11 @@
|
|||||||
package cron
|
package cron
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"html/template"
|
"html/template"
|
||||||
"os"
|
"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/common"
|
||||||
"go.woodpecker-ci.org/woodpecker/v2/cli/internal"
|
"go.woodpecker-ci.org/woodpecker/v2/cli/internal"
|
||||||
@ -53,10 +54,10 @@ var cronUpdateCmd = &cli.Command{
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
func cronUpdate(c *cli.Context) error {
|
func cronUpdate(ctx context.Context, c *cli.Command) error {
|
||||||
var (
|
var (
|
||||||
repoIDOrFullName = c.String("repository")
|
repoIDOrFullName = c.String("repository")
|
||||||
jobID = c.Int64("id")
|
cronID = c.Int("id")
|
||||||
jobName = c.String("name")
|
jobName = c.String("name")
|
||||||
branch = c.String("branch")
|
branch = c.String("branch")
|
||||||
schedule = c.String("schedule")
|
schedule = c.String("schedule")
|
||||||
@ -65,7 +66,7 @@ func cronUpdate(c *cli.Context) error {
|
|||||||
if repoIDOrFullName == "" {
|
if repoIDOrFullName == "" {
|
||||||
repoIDOrFullName = c.Args().First()
|
repoIDOrFullName = c.Args().First()
|
||||||
}
|
}
|
||||||
client, err := internal.NewClient(c)
|
client, err := internal.NewClient(ctx, c)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -74,7 +75,7 @@ func cronUpdate(c *cli.Context) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
cron := &woodpecker.Cron{
|
cron := &woodpecker.Cron{
|
||||||
ID: jobID,
|
ID: cronID,
|
||||||
Name: jobName,
|
Name: jobName,
|
||||||
Branch: branch,
|
Branch: branch,
|
||||||
Schedule: schedule,
|
Schedule: schedule,
|
||||||
|
@ -15,12 +15,13 @@
|
|||||||
package deploy
|
package deploy
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"html/template"
|
"html/template"
|
||||||
"os"
|
"os"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"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/common"
|
||||||
"go.woodpecker-ci.org/woodpecker/v2/cli/internal"
|
"go.woodpecker-ci.org/woodpecker/v2/cli/internal"
|
||||||
@ -57,8 +58,8 @@ var Command = &cli.Command{
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
func deploy(c *cli.Context) error {
|
func deploy(ctx context.Context, c *cli.Command) error {
|
||||||
client, err := internal.NewClient(c)
|
client, err := internal.NewClient(ctx, c)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -26,7 +26,7 @@ import (
|
|||||||
|
|
||||||
"github.com/drone/envsubst"
|
"github.com/drone/envsubst"
|
||||||
"github.com/rs/zerolog/log"
|
"github.com/rs/zerolog/log"
|
||||||
"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/common"
|
||||||
"go.woodpecker-ci.org/woodpecker/v2/cli/lint"
|
"go.woodpecker-ci.org/woodpecker/v2/cli/lint"
|
||||||
@ -59,11 +59,11 @@ var backends = []backend_types.Backend{
|
|||||||
local.New(),
|
local.New(),
|
||||||
}
|
}
|
||||||
|
|
||||||
func run(c *cli.Context) error {
|
func run(ctx context.Context, c *cli.Command) error {
|
||||||
return common.RunPipelineFunc(c, execFile, execDir)
|
return common.RunPipelineFunc(ctx, c, execFile, execDir)
|
||||||
}
|
}
|
||||||
|
|
||||||
func execDir(c *cli.Context, dir string) error {
|
func execDir(ctx context.Context, c *cli.Command, dir string) error {
|
||||||
// TODO: respect pipeline dependency
|
// TODO: respect pipeline dependency
|
||||||
repoPath := c.String("repo-path")
|
repoPath := c.String("repo-path")
|
||||||
if repoPath != "" {
|
if repoPath != "" {
|
||||||
@ -82,7 +82,7 @@ func execDir(c *cli.Context, dir string) error {
|
|||||||
// check if it is a regular file (not dir)
|
// check if it is a regular file (not dir)
|
||||||
if info.Mode().IsRegular() && (strings.HasSuffix(info.Name(), ".yaml") || strings.HasSuffix(info.Name(), ".yml")) {
|
if info.Mode().IsRegular() && (strings.HasSuffix(info.Name(), ".yaml") || strings.HasSuffix(info.Name(), ".yml")) {
|
||||||
fmt.Println("#", info.Name())
|
fmt.Println("#", info.Name())
|
||||||
_ = runExec(c, path, repoPath) // TODO: should we drop errors or store them and report back?
|
_ = runExec(ctx, c, path, repoPath) // TODO: should we drop errors or store them and report back?
|
||||||
fmt.Println("")
|
fmt.Println("")
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@ -91,7 +91,7 @@ func execDir(c *cli.Context, dir string) error {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func execFile(c *cli.Context, file string) error {
|
func execFile(ctx context.Context, c *cli.Command, file string) error {
|
||||||
repoPath := c.String("repo-path")
|
repoPath := c.String("repo-path")
|
||||||
if repoPath != "" {
|
if repoPath != "" {
|
||||||
repoPath, _ = filepath.Abs(repoPath)
|
repoPath, _ = filepath.Abs(repoPath)
|
||||||
@ -101,10 +101,10 @@ func execFile(c *cli.Context, file string) error {
|
|||||||
if runtime.GOOS == "windows" {
|
if runtime.GOOS == "windows" {
|
||||||
repoPath = convertPathForWindows(repoPath)
|
repoPath = convertPathForWindows(repoPath)
|
||||||
}
|
}
|
||||||
return runExec(c, file, repoPath)
|
return runExec(ctx, c, file, repoPath)
|
||||||
}
|
}
|
||||||
|
|
||||||
func runExec(c *cli.Context, file, repoPath string) error {
|
func runExec(ctx context.Context, c *cli.Command, file, repoPath string) error {
|
||||||
dat, err := os.ReadFile(file)
|
dat, err := os.ReadFile(file)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@ -119,7 +119,7 @@ func runExec(c *cli.Context, file, repoPath string) error {
|
|||||||
axes = append(axes, matrix.Axis{})
|
axes = append(axes, matrix.Axis{})
|
||||||
}
|
}
|
||||||
for _, axis := range axes {
|
for _, axis := range axes {
|
||||||
err := execWithAxis(c, file, repoPath, axis)
|
err := execWithAxis(ctx, c, file, repoPath, axis)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -127,8 +127,8 @@ func runExec(c *cli.Context, file, repoPath string) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func execWithAxis(c *cli.Context, file, repoPath string, axis matrix.Axis) error {
|
func execWithAxis(ctx context.Context, c *cli.Command, file, repoPath string, axis matrix.Axis) error {
|
||||||
metadata := metadataFromContext(c, axis)
|
metadata := metadataFromContext(ctx, c, axis)
|
||||||
environ := metadata.Environ()
|
environ := metadata.Environ()
|
||||||
var secrets []compiler.Secret
|
var secrets []compiler.Secret
|
||||||
for key, val := range metadata.Workflow.Matrix {
|
for key, val := range metadata.Workflow.Matrix {
|
||||||
@ -235,7 +235,7 @@ func execWithAxis(c *cli.Context, file, repoPath string, axis matrix.Axis) error
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
backendCtx := context.WithValue(c.Context, backend_types.CliContext, c)
|
backendCtx := context.WithValue(ctx, backend_types.CliCommand, c)
|
||||||
backendEngine, err := backend.FindBackend(backendCtx, backends, c.String("backend-engine"))
|
backendEngine, err := backend.FindBackend(backendCtx, backends, c.String("backend-engine"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@ -245,21 +245,21 @@ func execWithAxis(c *cli.Context, file, repoPath string, axis matrix.Axis) error
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx, cancel := context.WithTimeout(context.Background(), c.Duration("timeout"))
|
pipelineCtx, cancel := context.WithTimeout(context.Background(), c.Duration("timeout"))
|
||||||
defer cancel()
|
defer cancel()
|
||||||
ctx = utils.WithContextSigtermCallback(ctx, func() {
|
pipelineCtx = utils.WithContextSigtermCallback(pipelineCtx, func() {
|
||||||
fmt.Println("ctrl+c received, terminating process")
|
fmt.Printf("ctrl+c received, terminating current pipeline '%s'\n", confStr)
|
||||||
})
|
})
|
||||||
|
|
||||||
return pipeline.New(compiled,
|
return pipeline.New(compiled,
|
||||||
pipeline.WithContext(ctx),
|
pipeline.WithContext(pipelineCtx), //nolint:contextcheck
|
||||||
pipeline.WithTracer(pipeline.DefaultTracer),
|
pipeline.WithTracer(pipeline.DefaultTracer),
|
||||||
pipeline.WithLogger(defaultLogger),
|
pipeline.WithLogger(defaultLogger),
|
||||||
pipeline.WithBackend(backendEngine),
|
pipeline.WithBackend(backendEngine),
|
||||||
pipeline.WithDescription(map[string]string{
|
pipeline.WithDescription(map[string]string{
|
||||||
"CLI": "exec",
|
"CLI": "exec",
|
||||||
}),
|
}),
|
||||||
).Run(c.Context)
|
).Run(ctx)
|
||||||
}
|
}
|
||||||
|
|
||||||
// convertPathForWindows converts a path to use slash separators
|
// convertPathForWindows converts a path to use slash separators
|
||||||
|
@ -17,41 +17,41 @@ package exec
|
|||||||
import (
|
import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/urfave/cli/v2"
|
"github.com/urfave/cli/v3"
|
||||||
|
|
||||||
"go.woodpecker-ci.org/woodpecker/v2/shared/constant"
|
"go.woodpecker-ci.org/woodpecker/v2/shared/constant"
|
||||||
)
|
)
|
||||||
|
|
||||||
var flags = []cli.Flag{
|
var flags = []cli.Flag{
|
||||||
&cli.BoolFlag{
|
&cli.BoolFlag{
|
||||||
EnvVars: []string{"WOODPECKER_LOCAL"},
|
Sources: cli.EnvVars("WOODPECKER_LOCAL"),
|
||||||
Name: "local",
|
Name: "local",
|
||||||
Usage: "run from local directory",
|
Usage: "run from local directory",
|
||||||
Value: true,
|
Value: true,
|
||||||
},
|
},
|
||||||
&cli.StringFlag{
|
&cli.StringFlag{
|
||||||
EnvVars: []string{"WOODPECKER_REPO_PATH"},
|
Sources: cli.EnvVars("WOODPECKER_REPO_PATH"),
|
||||||
Name: "repo-path",
|
Name: "repo-path",
|
||||||
Usage: "path to local repository",
|
Usage: "path to local repository",
|
||||||
},
|
},
|
||||||
&cli.DurationFlag{
|
&cli.DurationFlag{
|
||||||
EnvVars: []string{"WOODPECKER_TIMEOUT"},
|
Sources: cli.EnvVars("WOODPECKER_TIMEOUT"),
|
||||||
Name: "timeout",
|
Name: "timeout",
|
||||||
Usage: "pipeline timeout",
|
Usage: "pipeline timeout",
|
||||||
Value: time.Hour,
|
Value: time.Hour,
|
||||||
},
|
},
|
||||||
&cli.StringSliceFlag{
|
&cli.StringSliceFlag{
|
||||||
EnvVars: []string{"WOODPECKER_VOLUMES"},
|
Sources: cli.EnvVars("WOODPECKER_VOLUMES"),
|
||||||
Name: "volumes",
|
Name: "volumes",
|
||||||
Usage: "pipeline volumes",
|
Usage: "pipeline volumes",
|
||||||
},
|
},
|
||||||
&cli.StringSliceFlag{
|
&cli.StringSliceFlag{
|
||||||
EnvVars: []string{"WOODPECKER_NETWORKS"},
|
Sources: cli.EnvVars("WOODPECKER_NETWORKS"),
|
||||||
Name: "network",
|
Name: "network",
|
||||||
Usage: "external networks",
|
Usage: "external networks",
|
||||||
},
|
},
|
||||||
&cli.StringFlag{
|
&cli.StringFlag{
|
||||||
EnvVars: []string{"WOODPECKER_PREFIX"},
|
Sources: cli.EnvVars("WOODPECKER_PREFIX"),
|
||||||
Name: "prefix",
|
Name: "prefix",
|
||||||
Value: "woodpecker",
|
Value: "woodpecker",
|
||||||
Usage: "prefix used for containers, volumes, networks, ... created by woodpecker",
|
Usage: "prefix used for containers, volumes, networks, ... created by woodpecker",
|
||||||
@ -60,10 +60,10 @@ var flags = []cli.Flag{
|
|||||||
&cli.StringSliceFlag{
|
&cli.StringSliceFlag{
|
||||||
Name: "privileged",
|
Name: "privileged",
|
||||||
Usage: "privileged plugins",
|
Usage: "privileged plugins",
|
||||||
Value: cli.NewStringSlice(constant.PrivilegedPlugins...),
|
Value: constant.PrivilegedPlugins,
|
||||||
},
|
},
|
||||||
&cli.StringFlag{
|
&cli.StringFlag{
|
||||||
EnvVars: []string{"WOODPECKER_BACKEND"},
|
Sources: cli.EnvVars("WOODPECKER_BACKEND"),
|
||||||
Name: "backend-engine",
|
Name: "backend-engine",
|
||||||
Usage: "backend engine to run pipelines on",
|
Usage: "backend engine to run pipelines on",
|
||||||
Value: "auto-detect",
|
Value: "auto-detect",
|
||||||
@ -73,17 +73,17 @@ var flags = []cli.Flag{
|
|||||||
// backend options for pipeline compiler
|
// backend options for pipeline compiler
|
||||||
//
|
//
|
||||||
&cli.StringFlag{
|
&cli.StringFlag{
|
||||||
EnvVars: []string{"WOODPECKER_BACKEND_NO_PROXY", "NO_PROXY", "no_proxy"},
|
Sources: cli.EnvVars("WOODPECKER_BACKEND_NO_PROXY", "NO_PROXY", "no_proxy"),
|
||||||
Usage: "if set, pass the environment variable down as \"NO_PROXY\" to steps",
|
Usage: "if set, pass the environment variable down as \"NO_PROXY\" to steps",
|
||||||
Name: "backend-no-proxy",
|
Name: "backend-no-proxy",
|
||||||
},
|
},
|
||||||
&cli.StringFlag{
|
&cli.StringFlag{
|
||||||
EnvVars: []string{"WOODPECKER_BACKEND_HTTP_PROXY", "HTTP_PROXY", "http_proxy"},
|
Sources: cli.EnvVars("WOODPECKER_BACKEND_HTTP_PROXY", "HTTP_PROXY", "http_proxy"),
|
||||||
Usage: "if set, pass the environment variable down as \"HTTP_PROXY\" to steps",
|
Usage: "if set, pass the environment variable down as \"HTTP_PROXY\" to steps",
|
||||||
Name: "backend-http-proxy",
|
Name: "backend-http-proxy",
|
||||||
},
|
},
|
||||||
&cli.StringFlag{
|
&cli.StringFlag{
|
||||||
EnvVars: []string{"WOODPECKER_BACKEND_HTTPS_PROXY", "HTTPS_PROXY", "https_proxy"},
|
Sources: cli.EnvVars("WOODPECKER_BACKEND_HTTPS_PROXY", "HTTPS_PROXY", "https_proxy"),
|
||||||
Usage: "if set, pass the environment variable down as \"HTTPS_PROXY\" to steps",
|
Usage: "if set, pass the environment variable down as \"HTTPS_PROXY\" to steps",
|
||||||
Name: "backend-https-proxy",
|
Name: "backend-https-proxy",
|
||||||
},
|
},
|
||||||
@ -97,12 +97,12 @@ var flags = []cli.Flag{
|
|||||||
// workspace default
|
// workspace default
|
||||||
//
|
//
|
||||||
&cli.StringFlag{
|
&cli.StringFlag{
|
||||||
EnvVars: []string{"CI_WORKSPACE_BASE"},
|
Sources: cli.EnvVars("CI_WORKSPACE_BASE"),
|
||||||
Name: "workspace-base",
|
Name: "workspace-base",
|
||||||
Value: "/woodpecker",
|
Value: "/woodpecker",
|
||||||
},
|
},
|
||||||
&cli.StringFlag{
|
&cli.StringFlag{
|
||||||
EnvVars: []string{"CI_WORKSPACE_PATH"},
|
Sources: cli.EnvVars("CI_WORKSPACE_PATH"),
|
||||||
Name: "workspace-path",
|
Name: "workspace-path",
|
||||||
Value: "src",
|
Value: "src",
|
||||||
},
|
},
|
||||||
@ -110,218 +110,218 @@ var flags = []cli.Flag{
|
|||||||
// netrc parameters
|
// netrc parameters
|
||||||
//
|
//
|
||||||
&cli.StringFlag{
|
&cli.StringFlag{
|
||||||
EnvVars: []string{"CI_NETRC_USERNAME"},
|
Sources: cli.EnvVars("CI_NETRC_USERNAME"),
|
||||||
Name: "netrc-username",
|
Name: "netrc-username",
|
||||||
},
|
},
|
||||||
&cli.StringFlag{
|
&cli.StringFlag{
|
||||||
EnvVars: []string{"CI_NETRC_PASSWORD"},
|
Sources: cli.EnvVars("CI_NETRC_PASSWORD"),
|
||||||
Name: "netrc-password",
|
Name: "netrc-password",
|
||||||
},
|
},
|
||||||
&cli.StringFlag{
|
&cli.StringFlag{
|
||||||
EnvVars: []string{"CI_NETRC_MACHINE"},
|
Sources: cli.EnvVars("CI_NETRC_MACHINE"),
|
||||||
Name: "netrc-machine",
|
Name: "netrc-machine",
|
||||||
},
|
},
|
||||||
//
|
//
|
||||||
// metadata parameters
|
// metadata parameters
|
||||||
//
|
//
|
||||||
&cli.StringFlag{
|
&cli.StringFlag{
|
||||||
EnvVars: []string{"CI_SYSTEM_PLATFORM"},
|
Sources: cli.EnvVars("CI_SYSTEM_PLATFORM"),
|
||||||
Name: "system-platform",
|
Name: "system-platform",
|
||||||
},
|
},
|
||||||
&cli.StringFlag{
|
&cli.StringFlag{
|
||||||
EnvVars: []string{"CI_SYSTEM_NAME"},
|
Sources: cli.EnvVars("CI_SYSTEM_NAME"),
|
||||||
Name: "system-name",
|
Name: "system-name",
|
||||||
Value: "woodpecker",
|
Value: "woodpecker",
|
||||||
},
|
},
|
||||||
&cli.StringFlag{
|
&cli.StringFlag{
|
||||||
EnvVars: []string{"CI_SYSTEM_URL"},
|
Sources: cli.EnvVars("CI_SYSTEM_URL"),
|
||||||
Name: "system-url",
|
Name: "system-url",
|
||||||
Value: "https://github.com/woodpecker-ci/woodpecker",
|
Value: "https://github.com/woodpecker-ci/woodpecker",
|
||||||
},
|
},
|
||||||
&cli.StringFlag{
|
&cli.StringFlag{
|
||||||
EnvVars: []string{"CI_REPO"},
|
Sources: cli.EnvVars("CI_REPO"),
|
||||||
Name: "repo",
|
Name: "repo",
|
||||||
Usage: "full repo name",
|
Usage: "full repo name",
|
||||||
},
|
},
|
||||||
&cli.StringFlag{
|
&cli.StringFlag{
|
||||||
EnvVars: []string{"CI_REPO_REMOTE_ID"},
|
Sources: cli.EnvVars("CI_REPO_REMOTE_ID"),
|
||||||
Name: "repo-remote-id",
|
Name: "repo-remote-id",
|
||||||
},
|
},
|
||||||
&cli.StringFlag{
|
&cli.StringFlag{
|
||||||
EnvVars: []string{"CI_REPO_URL"},
|
Sources: cli.EnvVars("CI_REPO_URL"),
|
||||||
Name: "repo-url",
|
Name: "repo-url",
|
||||||
},
|
},
|
||||||
&cli.StringFlag{
|
&cli.StringFlag{
|
||||||
EnvVars: []string{"CI_REPO_CLONE_URL"},
|
Sources: cli.EnvVars("CI_REPO_CLONE_URL"),
|
||||||
Name: "repo-clone-url",
|
Name: "repo-clone-url",
|
||||||
},
|
},
|
||||||
&cli.StringFlag{
|
&cli.StringFlag{
|
||||||
EnvVars: []string{"CI_REPO_CLONE_SSH_URL"},
|
Sources: cli.EnvVars("CI_REPO_CLONE_SSH_URL"),
|
||||||
Name: "repo-clone-ssh-url",
|
Name: "repo-clone-ssh-url",
|
||||||
},
|
},
|
||||||
&cli.StringFlag{
|
&cli.StringFlag{
|
||||||
EnvVars: []string{"CI_REPO_PRIVATE"},
|
Sources: cli.EnvVars("CI_REPO_PRIVATE"),
|
||||||
Name: "repo-private",
|
Name: "repo-private",
|
||||||
},
|
},
|
||||||
&cli.BoolFlag{
|
&cli.BoolFlag{
|
||||||
EnvVars: []string{"CI_REPO_TRUSTED"},
|
Sources: cli.EnvVars("CI_REPO_TRUSTED"),
|
||||||
Name: "repo-trusted",
|
Name: "repo-trusted",
|
||||||
},
|
},
|
||||||
&cli.IntFlag{
|
&cli.IntFlag{
|
||||||
EnvVars: []string{"CI_PIPELINE_NUMBER"},
|
Sources: cli.EnvVars("CI_PIPELINE_NUMBER"),
|
||||||
Name: "pipeline-number",
|
Name: "pipeline-number",
|
||||||
},
|
},
|
||||||
&cli.IntFlag{
|
&cli.IntFlag{
|
||||||
EnvVars: []string{"CI_PIPELINE_PARENT"},
|
Sources: cli.EnvVars("CI_PIPELINE_PARENT"),
|
||||||
Name: "pipeline-parent",
|
Name: "pipeline-parent",
|
||||||
},
|
},
|
||||||
&cli.Int64Flag{
|
&cli.IntFlag{
|
||||||
EnvVars: []string{"CI_PIPELINE_CREATED"},
|
Sources: cli.EnvVars("CI_PIPELINE_CREATED"),
|
||||||
Name: "pipeline-created",
|
Name: "pipeline-created",
|
||||||
},
|
},
|
||||||
&cli.Int64Flag{
|
&cli.IntFlag{
|
||||||
EnvVars: []string{"CI_PIPELINE_STARTED"},
|
Sources: cli.EnvVars("CI_PIPELINE_STARTED"),
|
||||||
Name: "pipeline-started",
|
Name: "pipeline-started",
|
||||||
},
|
},
|
||||||
&cli.Int64Flag{
|
&cli.IntFlag{
|
||||||
EnvVars: []string{"CI_PIPELINE_FINISHED"},
|
Sources: cli.EnvVars("CI_PIPELINE_FINISHED"),
|
||||||
Name: "pipeline-finished",
|
Name: "pipeline-finished",
|
||||||
},
|
},
|
||||||
&cli.StringFlag{
|
&cli.StringFlag{
|
||||||
EnvVars: []string{"CI_PIPELINE_STATUS"},
|
Sources: cli.EnvVars("CI_PIPELINE_STATUS"),
|
||||||
Name: "pipeline-status",
|
Name: "pipeline-status",
|
||||||
},
|
},
|
||||||
&cli.StringFlag{
|
&cli.StringFlag{
|
||||||
EnvVars: []string{"CI_PIPELINE_EVENT"},
|
Sources: cli.EnvVars("CI_PIPELINE_EVENT"),
|
||||||
Name: "pipeline-event",
|
Name: "pipeline-event",
|
||||||
Value: "manual",
|
Value: "manual",
|
||||||
},
|
},
|
||||||
&cli.StringFlag{
|
&cli.StringFlag{
|
||||||
EnvVars: []string{"CI_PIPELINE_URL"},
|
Sources: cli.EnvVars("CI_PIPELINE_URL"),
|
||||||
Name: "pipeline-url",
|
Name: "pipeline-url",
|
||||||
},
|
},
|
||||||
&cli.StringFlag{
|
&cli.StringFlag{
|
||||||
EnvVars: []string{"CI_PIPELINE_DEPLOY_TARGET", "CI_PIPELINE_TARGET"}, // TODO: remove CI_PIPELINE_TARGET in 3.x
|
Sources: cli.EnvVars("CI_PIPELINE_DEPLOY_TARGET", "CI_PIPELINE_TARGET"), // TODO: remove CI_PIPELINE_TARGET in 3.x
|
||||||
Name: "pipeline-deploy-to",
|
Name: "pipeline-deploy-to",
|
||||||
},
|
},
|
||||||
&cli.StringFlag{
|
&cli.StringFlag{
|
||||||
EnvVars: []string{"CI_PIPELINE_DEPLOY_TASK", "CI_PIPELINE_TASK"}, // TODO: remove CI_PIPELINE_TASK in 3.x
|
Sources: cli.EnvVars("CI_PIPELINE_DEPLOY_TASK", "CI_PIPELINE_TASK"), // TODO: remove CI_PIPELINE_TASK in 3.x
|
||||||
Name: "pipeline-deploy-task",
|
Name: "pipeline-deploy-task",
|
||||||
},
|
},
|
||||||
&cli.StringFlag{
|
&cli.StringFlag{
|
||||||
EnvVars: []string{"CI_COMMIT_SHA"},
|
Sources: cli.EnvVars("CI_COMMIT_SHA"),
|
||||||
Name: "commit-sha",
|
Name: "commit-sha",
|
||||||
},
|
},
|
||||||
&cli.StringFlag{
|
&cli.StringFlag{
|
||||||
EnvVars: []string{"CI_COMMIT_REF"},
|
Sources: cli.EnvVars("CI_COMMIT_REF"),
|
||||||
Name: "commit-ref",
|
Name: "commit-ref",
|
||||||
},
|
},
|
||||||
&cli.StringFlag{
|
&cli.StringFlag{
|
||||||
EnvVars: []string{"CI_COMMIT_REFSPEC"},
|
Sources: cli.EnvVars("CI_COMMIT_REFSPEC"),
|
||||||
Name: "commit-refspec",
|
Name: "commit-refspec",
|
||||||
},
|
},
|
||||||
&cli.StringFlag{
|
&cli.StringFlag{
|
||||||
EnvVars: []string{"CI_COMMIT_BRANCH"},
|
Sources: cli.EnvVars("CI_COMMIT_BRANCH"),
|
||||||
Name: "commit-branch",
|
Name: "commit-branch",
|
||||||
},
|
},
|
||||||
&cli.StringFlag{
|
&cli.StringFlag{
|
||||||
EnvVars: []string{"CI_COMMIT_MESSAGE"},
|
Sources: cli.EnvVars("CI_COMMIT_MESSAGE"),
|
||||||
Name: "commit-message",
|
Name: "commit-message",
|
||||||
},
|
},
|
||||||
&cli.StringFlag{
|
&cli.StringFlag{
|
||||||
EnvVars: []string{"CI_COMMIT_AUTHOR_NAME"},
|
Sources: cli.EnvVars("CI_COMMIT_AUTHOR_NAME"),
|
||||||
Name: "commit-author-name",
|
Name: "commit-author-name",
|
||||||
},
|
},
|
||||||
&cli.StringFlag{
|
&cli.StringFlag{
|
||||||
EnvVars: []string{"CI_COMMIT_AUTHOR_AVATAR"},
|
Sources: cli.EnvVars("CI_COMMIT_AUTHOR_AVATAR"),
|
||||||
Name: "commit-author-avatar",
|
Name: "commit-author-avatar",
|
||||||
},
|
},
|
||||||
&cli.StringFlag{
|
&cli.StringFlag{
|
||||||
EnvVars: []string{"CI_COMMIT_AUTHOR_EMAIL"},
|
Sources: cli.EnvVars("CI_COMMIT_AUTHOR_EMAIL"),
|
||||||
Name: "commit-author-email",
|
Name: "commit-author-email",
|
||||||
},
|
},
|
||||||
&cli.IntFlag{
|
&cli.IntFlag{
|
||||||
EnvVars: []string{"CI_PREV_PIPELINE_NUMBER"},
|
Sources: cli.EnvVars("CI_PREV_PIPELINE_NUMBER"),
|
||||||
Name: "prev-pipeline-number",
|
Name: "prev-pipeline-number",
|
||||||
},
|
},
|
||||||
&cli.Int64Flag{
|
&cli.IntFlag{
|
||||||
EnvVars: []string{"CI_PREV_PIPELINE_CREATED"},
|
Sources: cli.EnvVars("CI_PREV_PIPELINE_CREATED"),
|
||||||
Name: "prev-pipeline-created",
|
Name: "prev-pipeline-created",
|
||||||
},
|
},
|
||||||
&cli.Int64Flag{
|
&cli.IntFlag{
|
||||||
EnvVars: []string{"CI_PREV_PIPELINE_STARTED"},
|
Sources: cli.EnvVars("CI_PREV_PIPELINE_STARTED"),
|
||||||
Name: "prev-pipeline-started",
|
Name: "prev-pipeline-started",
|
||||||
},
|
},
|
||||||
&cli.Int64Flag{
|
&cli.IntFlag{
|
||||||
EnvVars: []string{"CI_PREV_PIPELINE_FINISHED"},
|
Sources: cli.EnvVars("CI_PREV_PIPELINE_FINISHED"),
|
||||||
Name: "prev-pipeline-finished",
|
Name: "prev-pipeline-finished",
|
||||||
},
|
},
|
||||||
&cli.StringFlag{
|
&cli.StringFlag{
|
||||||
EnvVars: []string{"CI_PREV_PIPELINE_STATUS"},
|
Sources: cli.EnvVars("CI_PREV_PIPELINE_STATUS"),
|
||||||
Name: "prev-pipeline-status",
|
Name: "prev-pipeline-status",
|
||||||
},
|
},
|
||||||
&cli.StringFlag{
|
&cli.StringFlag{
|
||||||
EnvVars: []string{"CI_PREV_PIPELINE_EVENT"},
|
Sources: cli.EnvVars("CI_PREV_PIPELINE_EVENT"),
|
||||||
Name: "prev-pipeline-event",
|
Name: "prev-pipeline-event",
|
||||||
},
|
},
|
||||||
&cli.StringFlag{
|
&cli.StringFlag{
|
||||||
EnvVars: []string{"CI_PREV_PIPELINE_URL"},
|
Sources: cli.EnvVars("CI_PREV_PIPELINE_URL"),
|
||||||
Name: "prev-pipeline-url",
|
Name: "prev-pipeline-url",
|
||||||
},
|
},
|
||||||
&cli.StringFlag{
|
&cli.StringFlag{
|
||||||
EnvVars: []string{"CI_PREV_COMMIT_SHA"},
|
Sources: cli.EnvVars("CI_PREV_COMMIT_SHA"),
|
||||||
Name: "prev-commit-sha",
|
Name: "prev-commit-sha",
|
||||||
},
|
},
|
||||||
&cli.StringFlag{
|
&cli.StringFlag{
|
||||||
EnvVars: []string{"CI_PREV_COMMIT_REF"},
|
Sources: cli.EnvVars("CI_PREV_COMMIT_REF"),
|
||||||
Name: "prev-commit-ref",
|
Name: "prev-commit-ref",
|
||||||
},
|
},
|
||||||
&cli.StringFlag{
|
&cli.StringFlag{
|
||||||
EnvVars: []string{"CI_PREV_COMMIT_REFSPEC"},
|
Sources: cli.EnvVars("CI_PREV_COMMIT_REFSPEC"),
|
||||||
Name: "prev-commit-refspec",
|
Name: "prev-commit-refspec",
|
||||||
},
|
},
|
||||||
&cli.StringFlag{
|
&cli.StringFlag{
|
||||||
EnvVars: []string{"CI_PREV_COMMIT_BRANCH"},
|
Sources: cli.EnvVars("CI_PREV_COMMIT_BRANCH"),
|
||||||
Name: "prev-commit-branch",
|
Name: "prev-commit-branch",
|
||||||
},
|
},
|
||||||
&cli.StringFlag{
|
&cli.StringFlag{
|
||||||
EnvVars: []string{"CI_PREV_COMMIT_MESSAGE"},
|
Sources: cli.EnvVars("CI_PREV_COMMIT_MESSAGE"),
|
||||||
Name: "prev-commit-message",
|
Name: "prev-commit-message",
|
||||||
},
|
},
|
||||||
&cli.StringFlag{
|
&cli.StringFlag{
|
||||||
EnvVars: []string{"CI_PREV_COMMIT_AUTHOR_NAME"},
|
Sources: cli.EnvVars("CI_PREV_COMMIT_AUTHOR_NAME"),
|
||||||
Name: "prev-commit-author-name",
|
Name: "prev-commit-author-name",
|
||||||
},
|
},
|
||||||
&cli.StringFlag{
|
&cli.StringFlag{
|
||||||
EnvVars: []string{"CI_PREV_COMMIT_AUTHOR_AVATAR"},
|
Sources: cli.EnvVars("CI_PREV_COMMIT_AUTHOR_AVATAR"),
|
||||||
Name: "prev-commit-author-avatar",
|
Name: "prev-commit-author-avatar",
|
||||||
},
|
},
|
||||||
&cli.StringFlag{
|
&cli.StringFlag{
|
||||||
EnvVars: []string{"CI_PREV_COMMIT_AUTHOR_EMAIL"},
|
Sources: cli.EnvVars("CI_PREV_COMMIT_AUTHOR_EMAIL"),
|
||||||
Name: "prev-commit-author-email",
|
Name: "prev-commit-author-email",
|
||||||
},
|
},
|
||||||
&cli.IntFlag{
|
&cli.IntFlag{
|
||||||
EnvVars: []string{"CI_WORKFLOW_NAME"},
|
Sources: cli.EnvVars("CI_WORKFLOW_NAME"),
|
||||||
Name: "workflow-name",
|
Name: "workflow-name",
|
||||||
},
|
},
|
||||||
&cli.IntFlag{
|
&cli.IntFlag{
|
||||||
EnvVars: []string{"CI_WORKFLOW_NUMBER"},
|
Sources: cli.EnvVars("CI_WORKFLOW_NUMBER"),
|
||||||
Name: "workflow-number",
|
Name: "workflow-number",
|
||||||
},
|
},
|
||||||
&cli.IntFlag{
|
&cli.IntFlag{
|
||||||
EnvVars: []string{"CI_STEP_NAME"},
|
Sources: cli.EnvVars("CI_STEP_NAME"),
|
||||||
Name: "step-name",
|
Name: "step-name",
|
||||||
},
|
},
|
||||||
&cli.StringSliceFlag{
|
&cli.StringSliceFlag{
|
||||||
EnvVars: []string{"CI_ENV"},
|
Sources: cli.EnvVars("CI_ENV"),
|
||||||
Name: "env",
|
Name: "env",
|
||||||
},
|
},
|
||||||
&cli.StringFlag{
|
&cli.StringFlag{
|
||||||
EnvVars: []string{"CI_FORGE_TYPE"},
|
Sources: cli.EnvVars("CI_FORGE_TYPE"),
|
||||||
Name: "forge-type",
|
Name: "forge-type",
|
||||||
},
|
},
|
||||||
&cli.StringFlag{
|
&cli.StringFlag{
|
||||||
EnvVars: []string{"CI_FORGE_URL"},
|
Sources: cli.EnvVars("CI_FORGE_URL"),
|
||||||
Name: "forge-url",
|
Name: "forge-url",
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -15,10 +15,11 @@
|
|||||||
package exec
|
package exec
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"runtime"
|
"runtime"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/urfave/cli/v2"
|
"github.com/urfave/cli/v3"
|
||||||
|
|
||||||
"go.woodpecker-ci.org/woodpecker/v2/pipeline/frontend/metadata"
|
"go.woodpecker-ci.org/woodpecker/v2/pipeline/frontend/metadata"
|
||||||
"go.woodpecker-ci.org/woodpecker/v2/pipeline/frontend/yaml/matrix"
|
"go.woodpecker-ci.org/woodpecker/v2/pipeline/frontend/yaml/matrix"
|
||||||
@ -26,7 +27,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// return the metadata from the cli context.
|
// return the metadata from the cli context.
|
||||||
func metadataFromContext(c *cli.Context, axis matrix.Axis) metadata.Metadata {
|
func metadataFromContext(_ context.Context, c *cli.Command, axis matrix.Axis) metadata.Metadata {
|
||||||
platform := c.String("system-platform")
|
platform := c.String("system-platform")
|
||||||
if platform == "" {
|
if platform == "" {
|
||||||
platform = runtime.GOOS + "/" + runtime.GOARCH
|
platform = runtime.GOOS + "/" + runtime.GOARCH
|
||||||
@ -52,11 +53,11 @@ func metadataFromContext(c *cli.Context, axis matrix.Axis) metadata.Metadata {
|
|||||||
Trusted: c.Bool("repo-trusted"),
|
Trusted: c.Bool("repo-trusted"),
|
||||||
},
|
},
|
||||||
Curr: metadata.Pipeline{
|
Curr: metadata.Pipeline{
|
||||||
Number: c.Int64("pipeline-number"),
|
Number: c.Int("pipeline-number"),
|
||||||
Parent: c.Int64("pipeline-parent"),
|
Parent: c.Int("pipeline-parent"),
|
||||||
Created: c.Int64("pipeline-created"),
|
Created: c.Int("pipeline-created"),
|
||||||
Started: c.Int64("pipeline-started"),
|
Started: c.Int("pipeline-started"),
|
||||||
Finished: c.Int64("pipeline-finished"),
|
Finished: c.Int("pipeline-finished"),
|
||||||
Status: c.String("pipeline-status"),
|
Status: c.String("pipeline-status"),
|
||||||
Event: c.String("pipeline-event"),
|
Event: c.String("pipeline-event"),
|
||||||
ForgeURL: c.String("pipeline-url"),
|
ForgeURL: c.String("pipeline-url"),
|
||||||
@ -76,10 +77,10 @@ func metadataFromContext(c *cli.Context, axis matrix.Axis) metadata.Metadata {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
Prev: metadata.Pipeline{
|
Prev: metadata.Pipeline{
|
||||||
Number: c.Int64("prev-pipeline-number"),
|
Number: c.Int("prev-pipeline-number"),
|
||||||
Created: c.Int64("prev-pipeline-created"),
|
Created: c.Int("prev-pipeline-created"),
|
||||||
Started: c.Int64("prev-pipeline-started"),
|
Started: c.Int("prev-pipeline-started"),
|
||||||
Finished: c.Int64("prev-pipeline-finished"),
|
Finished: c.Int("prev-pipeline-finished"),
|
||||||
Status: c.String("prev-pipeline-status"),
|
Status: c.String("prev-pipeline-status"),
|
||||||
Event: c.String("prev-pipeline-event"),
|
Event: c.String("prev-pipeline-event"),
|
||||||
ForgeURL: c.String("prev-pipeline-url"),
|
ForgeURL: c.String("prev-pipeline-url"),
|
||||||
@ -98,12 +99,12 @@ func metadataFromContext(c *cli.Context, axis matrix.Axis) metadata.Metadata {
|
|||||||
},
|
},
|
||||||
Workflow: metadata.Workflow{
|
Workflow: metadata.Workflow{
|
||||||
Name: c.String("workflow-name"),
|
Name: c.String("workflow-name"),
|
||||||
Number: c.Int("workflow-number"),
|
Number: int(c.Int("workflow-number")),
|
||||||
Matrix: axis,
|
Matrix: axis,
|
||||||
},
|
},
|
||||||
Step: metadata.Step{
|
Step: metadata.Step{
|
||||||
Name: c.String("step-name"),
|
Name: c.String("step-name"),
|
||||||
Number: c.Int("step-number"),
|
Number: int(c.Int("step-number")),
|
||||||
},
|
},
|
||||||
Sys: metadata.System{
|
Sys: metadata.System{
|
||||||
Name: c.String("system-name"),
|
Name: c.String("system-name"),
|
||||||
|
@ -15,10 +15,11 @@
|
|||||||
package info
|
package info
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"os"
|
"os"
|
||||||
"text/template"
|
"text/template"
|
||||||
|
|
||||||
"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/common"
|
||||||
"go.woodpecker-ci.org/woodpecker/v2/cli/internal"
|
"go.woodpecker-ci.org/woodpecker/v2/cli/internal"
|
||||||
@ -33,8 +34,8 @@ var Command = &cli.Command{
|
|||||||
Flags: []cli.Flag{common.FormatFlag(tmplInfo, true)},
|
Flags: []cli.Flag{common.FormatFlag(tmplInfo, true)},
|
||||||
}
|
}
|
||||||
|
|
||||||
func info(c *cli.Context) error {
|
func info(ctx context.Context, c *cli.Command) error {
|
||||||
client, err := internal.NewClient(c)
|
client, err := internal.NewClient(ctx, c)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package config
|
package config
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
"os"
|
"os"
|
||||||
@ -8,7 +9,7 @@ import (
|
|||||||
|
|
||||||
"github.com/adrg/xdg"
|
"github.com/adrg/xdg"
|
||||||
"github.com/rs/zerolog/log"
|
"github.com/rs/zerolog/log"
|
||||||
"github.com/urfave/cli/v2"
|
"github.com/urfave/cli/v3"
|
||||||
"github.com/zalando/go-keyring"
|
"github.com/zalando/go-keyring"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -32,12 +33,12 @@ func (c *Config) MergeIfNotSet(c2 *Config) {
|
|||||||
|
|
||||||
var skipSetupForCommands = []string{"setup", "help", "h", "version", "update", "lint", "exec", ""}
|
var skipSetupForCommands = []string{"setup", "help", "h", "version", "update", "lint", "exec", ""}
|
||||||
|
|
||||||
func Load(c *cli.Context) error {
|
func Load(ctx context.Context, c *cli.Command) error {
|
||||||
if firstArg := c.Args().First(); slices.Contains(skipSetupForCommands, firstArg) {
|
if firstArg := c.Args().First(); slices.Contains(skipSetupForCommands, firstArg) {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
config, err := Get(c, c.String("config"))
|
config, err := Get(ctx, c, c.String("config"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -80,11 +81,11 @@ func getConfigPath(configPath string) (string, error) {
|
|||||||
return configPath, nil
|
return configPath, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func Get(ctx *cli.Context, _configPath string) (*Config, error) {
|
func Get(_ context.Context, c *cli.Command, _configPath string) (*Config, error) {
|
||||||
c := &Config{
|
conf := &Config{
|
||||||
LogLevel: ctx.String("log-level"),
|
LogLevel: c.String("log-level"),
|
||||||
Token: ctx.String("token"),
|
Token: c.String("token"),
|
||||||
ServerURL: ctx.String("server"),
|
ServerURL: c.String("server"),
|
||||||
}
|
}
|
||||||
|
|
||||||
configPath, err := getConfigPath(_configPath)
|
configPath, err := getConfigPath(_configPath)
|
||||||
@ -109,33 +110,33 @@ func Get(ctx *cli.Context, _configPath string) (*Config, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
c.MergeIfNotSet(configFromFile)
|
conf.MergeIfNotSet(configFromFile)
|
||||||
log.Debug().Msg("Loaded config from file")
|
log.Debug().Msg("Loaded config from file")
|
||||||
}
|
}
|
||||||
|
|
||||||
// if server or token are explicitly set, use them
|
// if server or token are explicitly set, use them
|
||||||
if ctx.IsSet("server") || ctx.IsSet("token") {
|
if c.IsSet("server") || c.IsSet("token") {
|
||||||
return c, nil
|
return conf, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// load token from keyring
|
// load token from keyring
|
||||||
service := ctx.App.Name
|
service := c.Root().Name
|
||||||
secret, err := keyring.Get(service, c.ServerURL)
|
secret, err := keyring.Get(service, conf.ServerURL)
|
||||||
if errors.Is(err, keyring.ErrUnsupportedPlatform) {
|
if errors.Is(err, keyring.ErrUnsupportedPlatform) {
|
||||||
log.Warn().Msg("Keyring is not supported on this platform")
|
log.Warn().Msg("Keyring is not supported on this platform")
|
||||||
return c, nil
|
return conf, nil
|
||||||
}
|
}
|
||||||
if errors.Is(err, keyring.ErrNotFound) {
|
if errors.Is(err, keyring.ErrNotFound) {
|
||||||
log.Warn().Msg("Token not found in keyring")
|
log.Warn().Msg("Token not found in keyring")
|
||||||
return c, nil
|
return conf, nil
|
||||||
}
|
}
|
||||||
c.Token = secret
|
conf.Token = secret
|
||||||
|
|
||||||
return c, nil
|
return conf, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func Save(ctx *cli.Context, _configPath string, c *Config) error {
|
func Save(_ context.Context, c *cli.Command, _configPath string, conf *Config) error {
|
||||||
config, err := json.Marshal(c)
|
config, err := json.Marshal(conf)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -146,8 +147,8 @@ func Save(ctx *cli.Context, _configPath string, c *Config) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// save token to keyring
|
// save token to keyring
|
||||||
service := ctx.App.Name
|
service := c.Root().Name
|
||||||
err = keyring.Set(service, c.ServerURL, c.Token)
|
err = keyring.Set(service, conf.ServerURL, conf.Token)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
package internal
|
package internal
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"crypto/tls"
|
"crypto/tls"
|
||||||
"crypto/x509"
|
"crypto/x509"
|
||||||
"fmt"
|
"fmt"
|
||||||
@ -25,7 +26,7 @@ import (
|
|||||||
|
|
||||||
vsc_url "github.com/gitsight/go-vcsurl"
|
vsc_url "github.com/gitsight/go-vcsurl"
|
||||||
"github.com/rs/zerolog/log"
|
"github.com/rs/zerolog/log"
|
||||||
"github.com/urfave/cli/v2"
|
"github.com/urfave/cli/v3"
|
||||||
"golang.org/x/net/proxy"
|
"golang.org/x/net/proxy"
|
||||||
"golang.org/x/oauth2"
|
"golang.org/x/oauth2"
|
||||||
|
|
||||||
@ -33,7 +34,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// NewClient returns a new client from the CLI context.
|
// NewClient returns a new client from the CLI context.
|
||||||
func NewClient(c *cli.Context) (woodpecker.Client, error) {
|
func NewClient(ctx context.Context, c *cli.Command) (woodpecker.Client, error) {
|
||||||
var (
|
var (
|
||||||
skip = c.Bool("skip-verify")
|
skip = c.Bool("skip-verify")
|
||||||
socks = c.String("socks-proxy")
|
socks = c.String("socks-proxy")
|
||||||
@ -63,8 +64,7 @@ func NewClient(c *cli.Context) (woodpecker.Client, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
config := new(oauth2.Config)
|
config := new(oauth2.Config)
|
||||||
client := config.Client(
|
client := config.Client(ctx,
|
||||||
c.Context,
|
|
||||||
&oauth2.Token{
|
&oauth2.Token{
|
||||||
AccessToken: token,
|
AccessToken: token,
|
||||||
},
|
},
|
||||||
|
@ -15,13 +15,14 @@
|
|||||||
package lint
|
package lint
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"path"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"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/common"
|
||||||
"go.woodpecker-ci.org/woodpecker/v2/pipeline/frontend/yaml"
|
"go.woodpecker-ci.org/woodpecker/v2/pipeline/frontend/yaml"
|
||||||
@ -36,11 +37,11 @@ var Command = &cli.Command{
|
|||||||
Action: lint,
|
Action: lint,
|
||||||
}
|
}
|
||||||
|
|
||||||
func lint(c *cli.Context) error {
|
func lint(ctx context.Context, c *cli.Command) error {
|
||||||
return common.RunPipelineFunc(c, lintFile, lintDir)
|
return common.RunPipelineFunc(ctx, c, lintFile, lintDir)
|
||||||
}
|
}
|
||||||
|
|
||||||
func lintDir(c *cli.Context, dir string) error {
|
func lintDir(ctx context.Context, c *cli.Command, dir string) error {
|
||||||
var errorStrings []string
|
var errorStrings []string
|
||||||
if err := filepath.Walk(dir, func(path string, info os.FileInfo, e error) error {
|
if err := filepath.Walk(dir, func(path string, info os.FileInfo, e error) error {
|
||||||
if e != nil {
|
if e != nil {
|
||||||
@ -50,7 +51,7 @@ func lintDir(c *cli.Context, dir string) error {
|
|||||||
// check if it is a regular file (not dir)
|
// check if it is a regular file (not dir)
|
||||||
if info.Mode().IsRegular() && (strings.HasSuffix(info.Name(), ".yaml") || strings.HasSuffix(info.Name(), ".yml")) {
|
if info.Mode().IsRegular() && (strings.HasSuffix(info.Name(), ".yaml") || strings.HasSuffix(info.Name(), ".yml")) {
|
||||||
fmt.Println("#", info.Name())
|
fmt.Println("#", info.Name())
|
||||||
if err := lintFile(c, path); err != nil {
|
if err := lintFile(ctx, c, path); err != nil {
|
||||||
errorStrings = append(errorStrings, err.Error())
|
errorStrings = append(errorStrings, err.Error())
|
||||||
}
|
}
|
||||||
fmt.Println("")
|
fmt.Println("")
|
||||||
@ -68,7 +69,7 @@ func lintDir(c *cli.Context, dir string) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func lintFile(_ *cli.Context, file string) error {
|
func lintFile(_ context.Context, _ *cli.Command, file string) error {
|
||||||
fi, err := os.Open(file)
|
fi, err := os.Open(file)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -15,14 +15,14 @@
|
|||||||
package log
|
package log
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/urfave/cli/v2"
|
"github.com/urfave/cli/v3"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Command exports the log command set.
|
// Command exports the log command set.
|
||||||
var Command = &cli.Command{
|
var Command = &cli.Command{
|
||||||
Name: "log",
|
Name: "log",
|
||||||
Usage: "manage logs",
|
Usage: "manage logs",
|
||||||
Subcommands: []*cli.Command{
|
Commands: []*cli.Command{
|
||||||
logPurgeCmd,
|
logPurgeCmd,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -15,10 +15,11 @@
|
|||||||
package log
|
package log
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"github.com/urfave/cli/v2"
|
"github.com/urfave/cli/v3"
|
||||||
|
|
||||||
"go.woodpecker-ci.org/woodpecker/v2/cli/internal"
|
"go.woodpecker-ci.org/woodpecker/v2/cli/internal"
|
||||||
)
|
)
|
||||||
@ -30,8 +31,8 @@ var logPurgeCmd = &cli.Command{
|
|||||||
Action: logPurge,
|
Action: logPurge,
|
||||||
}
|
}
|
||||||
|
|
||||||
func logPurge(c *cli.Context) (err error) {
|
func logPurge(ctx context.Context, c *cli.Command) (err error) {
|
||||||
client, err := internal.NewClient(c)
|
client, err := internal.NewClient(ctx, c)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -15,9 +15,11 @@
|
|||||||
package loglevel
|
package loglevel
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
"github.com/rs/zerolog"
|
"github.com/rs/zerolog"
|
||||||
"github.com/rs/zerolog/log"
|
"github.com/rs/zerolog/log"
|
||||||
"github.com/urfave/cli/v2"
|
"github.com/urfave/cli/v3"
|
||||||
|
|
||||||
"go.woodpecker-ci.org/woodpecker/v2/cli/internal"
|
"go.woodpecker-ci.org/woodpecker/v2/cli/internal"
|
||||||
"go.woodpecker-ci.org/woodpecker/v2/woodpecker-go/woodpecker"
|
"go.woodpecker-ci.org/woodpecker/v2/woodpecker-go/woodpecker"
|
||||||
@ -31,8 +33,8 @@ var Command = &cli.Command{
|
|||||||
Action: logLevel,
|
Action: logLevel,
|
||||||
}
|
}
|
||||||
|
|
||||||
func logLevel(c *cli.Context) error {
|
func logLevel(ctx context.Context, c *cli.Command) error {
|
||||||
client, err := internal.NewClient(c)
|
client, err := internal.NewClient(ctx, c)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
package org
|
package org
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/urfave/cli/v2"
|
"github.com/urfave/cli/v3"
|
||||||
|
|
||||||
"go.woodpecker-ci.org/woodpecker/v2/cli/org/registry"
|
"go.woodpecker-ci.org/woodpecker/v2/cli/org/registry"
|
||||||
)
|
)
|
||||||
@ -24,7 +24,7 @@ import (
|
|||||||
var Command = &cli.Command{
|
var Command = &cli.Command{
|
||||||
Name: "org",
|
Name: "org",
|
||||||
Usage: "manage organizations",
|
Usage: "manage organizations",
|
||||||
Subcommands: []*cli.Command{
|
Commands: []*cli.Command{
|
||||||
registry.Command,
|
registry.Command,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,7 @@ package registry
|
|||||||
import (
|
import (
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"github.com/urfave/cli/v2"
|
"github.com/urfave/cli/v3"
|
||||||
|
|
||||||
"go.woodpecker-ci.org/woodpecker/v2/woodpecker-go/woodpecker"
|
"go.woodpecker-ci.org/woodpecker/v2/woodpecker-go/woodpecker"
|
||||||
)
|
)
|
||||||
@ -26,7 +26,7 @@ import (
|
|||||||
var Command = &cli.Command{
|
var Command = &cli.Command{
|
||||||
Name: "registry",
|
Name: "registry",
|
||||||
Usage: "manage organization registries",
|
Usage: "manage organization registries",
|
||||||
Subcommands: []*cli.Command{
|
Commands: []*cli.Command{
|
||||||
registryCreateCmd,
|
registryCreateCmd,
|
||||||
registryDeleteCmd,
|
registryDeleteCmd,
|
||||||
registryUpdateCmd,
|
registryUpdateCmd,
|
||||||
@ -35,7 +35,7 @@ var Command = &cli.Command{
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
func parseTargetArgs(client woodpecker.Client, c *cli.Context) (orgID int64, err error) {
|
func parseTargetArgs(client woodpecker.Client, c *cli.Command) (orgID int64, err error) {
|
||||||
orgIDOrName := c.String("organization")
|
orgIDOrName := c.String("organization")
|
||||||
if orgIDOrName == "" {
|
if orgIDOrName == "" {
|
||||||
orgIDOrName = c.Args().First()
|
orgIDOrName = c.Args().First()
|
||||||
|
@ -15,10 +15,11 @@
|
|||||||
package registry
|
package registry
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"os"
|
"os"
|
||||||
"strings"
|
"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/common"
|
||||||
"go.woodpecker-ci.org/woodpecker/v2/cli/internal"
|
"go.woodpecker-ci.org/woodpecker/v2/cli/internal"
|
||||||
@ -48,14 +49,14 @@ var registryCreateCmd = &cli.Command{
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
func registryCreate(c *cli.Context) error {
|
func registryCreate(ctx context.Context, c *cli.Command) error {
|
||||||
var (
|
var (
|
||||||
hostname = c.String("hostname")
|
hostname = c.String("hostname")
|
||||||
username = c.String("username")
|
username = c.String("username")
|
||||||
password = c.String("password")
|
password = c.String("password")
|
||||||
)
|
)
|
||||||
|
|
||||||
client, err := internal.NewClient(c)
|
client, err := internal.NewClient(ctx, c)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -15,10 +15,11 @@
|
|||||||
package registry
|
package registry
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"html/template"
|
"html/template"
|
||||||
"os"
|
"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/common"
|
||||||
"go.woodpecker-ci.org/woodpecker/v2/cli/internal"
|
"go.woodpecker-ci.org/woodpecker/v2/cli/internal"
|
||||||
@ -40,13 +41,13 @@ var registryInfoCmd = &cli.Command{
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
func registryInfo(c *cli.Context) error {
|
func registryInfo(ctx context.Context, c *cli.Command) error {
|
||||||
var (
|
var (
|
||||||
hostname = c.String("hostname")
|
hostname = c.String("hostname")
|
||||||
format = c.String("format") + "\n"
|
format = c.String("format") + "\n"
|
||||||
)
|
)
|
||||||
|
|
||||||
client, err := internal.NewClient(c)
|
client, err := internal.NewClient(ctx, c)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -15,10 +15,11 @@
|
|||||||
package registry
|
package registry
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"html/template"
|
"html/template"
|
||||||
"os"
|
"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/common"
|
||||||
"go.woodpecker-ci.org/woodpecker/v2/cli/internal"
|
"go.woodpecker-ci.org/woodpecker/v2/cli/internal"
|
||||||
@ -35,10 +36,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"
|
format := c.String("format") + "\n"
|
||||||
|
|
||||||
client, err := internal.NewClient(c)
|
client, err := internal.NewClient(ctx, c)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,9 @@
|
|||||||
package registry
|
package registry
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/urfave/cli/v2"
|
"context"
|
||||||
|
|
||||||
|
"github.com/urfave/cli/v3"
|
||||||
|
|
||||||
"go.woodpecker-ci.org/woodpecker/v2/cli/common"
|
"go.woodpecker-ci.org/woodpecker/v2/cli/common"
|
||||||
"go.woodpecker-ci.org/woodpecker/v2/cli/internal"
|
"go.woodpecker-ci.org/woodpecker/v2/cli/internal"
|
||||||
@ -36,10 +38,10 @@ var registryDeleteCmd = &cli.Command{
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
func registryDelete(c *cli.Context) error {
|
func registryDelete(ctx context.Context, c *cli.Command) error {
|
||||||
hostname := c.String("hostname")
|
hostname := c.String("hostname")
|
||||||
|
|
||||||
client, err := internal.NewClient(c)
|
client, err := internal.NewClient(ctx, c)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -15,10 +15,11 @@
|
|||||||
package registry
|
package registry
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"os"
|
"os"
|
||||||
"strings"
|
"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/common"
|
||||||
"go.woodpecker-ci.org/woodpecker/v2/cli/internal"
|
"go.woodpecker-ci.org/woodpecker/v2/cli/internal"
|
||||||
@ -48,14 +49,14 @@ var registryUpdateCmd = &cli.Command{
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
func registryUpdate(c *cli.Context) error {
|
func registryUpdate(ctx context.Context, c *cli.Command) error {
|
||||||
var (
|
var (
|
||||||
hostname = c.String("hostname")
|
hostname = c.String("hostname")
|
||||||
username = c.String("username")
|
username = c.String("username")
|
||||||
password = c.String("password")
|
password = c.String("password")
|
||||||
)
|
)
|
||||||
|
|
||||||
client, err := internal.NewClient(c)
|
client, err := internal.NewClient(ctx, c)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -15,10 +15,11 @@
|
|||||||
package pipeline
|
package pipeline
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"github.com/urfave/cli/v2"
|
"github.com/urfave/cli/v3"
|
||||||
|
|
||||||
"go.woodpecker-ci.org/woodpecker/v2/cli/internal"
|
"go.woodpecker-ci.org/woodpecker/v2/cli/internal"
|
||||||
)
|
)
|
||||||
@ -30,9 +31,9 @@ var pipelineApproveCmd = &cli.Command{
|
|||||||
Action: pipelineApprove,
|
Action: pipelineApprove,
|
||||||
}
|
}
|
||||||
|
|
||||||
func pipelineApprove(c *cli.Context) (err error) {
|
func pipelineApprove(ctx context.Context, c *cli.Command) (err error) {
|
||||||
repoIDOrFullName := c.Args().First()
|
repoIDOrFullName := c.Args().First()
|
||||||
client, err := internal.NewClient(c)
|
client, err := internal.NewClient(ctx, c)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -15,9 +15,10 @@
|
|||||||
package pipeline
|
package pipeline
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"strings"
|
"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/common"
|
||||||
"go.woodpecker-ci.org/woodpecker/v2/cli/internal"
|
"go.woodpecker-ci.org/woodpecker/v2/cli/internal"
|
||||||
@ -42,9 +43,9 @@ var pipelineCreateCmd = &cli.Command{
|
|||||||
}...),
|
}...),
|
||||||
}
|
}
|
||||||
|
|
||||||
func pipelineCreate(c *cli.Context) error {
|
func pipelineCreate(ctx context.Context, c *cli.Command) error {
|
||||||
repoIDOrFullName := c.Args().First()
|
repoIDOrFullName := c.Args().First()
|
||||||
client, err := internal.NewClient(c)
|
client, err := internal.NewClient(ctx, c)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -15,10 +15,11 @@
|
|||||||
package pipeline
|
package pipeline
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"github.com/urfave/cli/v2"
|
"github.com/urfave/cli/v3"
|
||||||
|
|
||||||
"go.woodpecker-ci.org/woodpecker/v2/cli/internal"
|
"go.woodpecker-ci.org/woodpecker/v2/cli/internal"
|
||||||
)
|
)
|
||||||
@ -30,9 +31,9 @@ var pipelineDeclineCmd = &cli.Command{
|
|||||||
Action: pipelineDecline,
|
Action: pipelineDecline,
|
||||||
}
|
}
|
||||||
|
|
||||||
func pipelineDecline(c *cli.Context) (err error) {
|
func pipelineDecline(ctx context.Context, c *cli.Command) (err error) {
|
||||||
repoIDOrFullName := c.Args().First()
|
repoIDOrFullName := c.Args().First()
|
||||||
client, err := internal.NewClient(c)
|
client, err := internal.NewClient(ctx, c)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -15,9 +15,10 @@
|
|||||||
package pipeline
|
package pipeline
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"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/common"
|
||||||
"go.woodpecker-ci.org/woodpecker/v2/cli/internal"
|
"go.woodpecker-ci.org/woodpecker/v2/cli/internal"
|
||||||
@ -32,9 +33,9 @@ var pipelineInfoCmd = &cli.Command{
|
|||||||
Flags: common.OutputFlags("table"),
|
Flags: common.OutputFlags("table"),
|
||||||
}
|
}
|
||||||
|
|
||||||
func pipelineInfo(c *cli.Context) error {
|
func pipelineInfo(ctx context.Context, c *cli.Command) error {
|
||||||
repoIDOrFullName := c.Args().First()
|
repoIDOrFullName := c.Args().First()
|
||||||
client, err := internal.NewClient(c)
|
client, err := internal.NewClient(ctx, c)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -15,10 +15,11 @@
|
|||||||
package pipeline
|
package pipeline
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"github.com/urfave/cli/v2"
|
"github.com/urfave/cli/v3"
|
||||||
|
|
||||||
"go.woodpecker-ci.org/woodpecker/v2/cli/internal"
|
"go.woodpecker-ci.org/woodpecker/v2/cli/internal"
|
||||||
)
|
)
|
||||||
@ -31,14 +32,14 @@ var pipelineKillCmd = &cli.Command{
|
|||||||
Hidden: true,
|
Hidden: true,
|
||||||
}
|
}
|
||||||
|
|
||||||
func pipelineKill(c *cli.Context) (err error) {
|
func pipelineKill(ctx context.Context, c *cli.Command) (err error) {
|
||||||
number, err := strconv.ParseInt(c.Args().Get(1), 10, 64)
|
number, err := strconv.ParseInt(c.Args().Get(1), 10, 64)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
repoIDOrFullName := c.Args().First()
|
repoIDOrFullName := c.Args().First()
|
||||||
client, err := internal.NewClient(c)
|
client, err := internal.NewClient(ctx, c)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,9 @@
|
|||||||
package pipeline
|
package pipeline
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/urfave/cli/v2"
|
"context"
|
||||||
|
|
||||||
|
"github.com/urfave/cli/v3"
|
||||||
|
|
||||||
"go.woodpecker-ci.org/woodpecker/v2/cli/common"
|
"go.woodpecker-ci.org/woodpecker/v2/cli/common"
|
||||||
"go.woodpecker-ci.org/woodpecker/v2/cli/internal"
|
"go.woodpecker-ci.org/woodpecker/v2/cli/internal"
|
||||||
@ -36,9 +38,9 @@ var pipelineLastCmd = &cli.Command{
|
|||||||
}...),
|
}...),
|
||||||
}
|
}
|
||||||
|
|
||||||
func pipelineLast(c *cli.Context) error {
|
func pipelineLast(ctx context.Context, c *cli.Command) error {
|
||||||
repoIDOrFullName := c.Args().First()
|
repoIDOrFullName := c.Args().First()
|
||||||
client, err := internal.NewClient(c)
|
client, err := internal.NewClient(ctx, c)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,9 @@
|
|||||||
package pipeline
|
package pipeline
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/urfave/cli/v2"
|
"context"
|
||||||
|
|
||||||
|
"github.com/urfave/cli/v3"
|
||||||
|
|
||||||
"go.woodpecker-ci.org/woodpecker/v2/cli/common"
|
"go.woodpecker-ci.org/woodpecker/v2/cli/common"
|
||||||
"go.woodpecker-ci.org/woodpecker/v2/cli/internal"
|
"go.woodpecker-ci.org/woodpecker/v2/cli/internal"
|
||||||
@ -49,19 +51,19 @@ var pipelineListCmd = &cli.Command{
|
|||||||
}...),
|
}...),
|
||||||
}
|
}
|
||||||
|
|
||||||
func List(c *cli.Context) error {
|
func List(ctx context.Context, c *cli.Command) error {
|
||||||
client, err := internal.NewClient(c)
|
client, err := internal.NewClient(ctx, c)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
resources, err := pipelineList(c, client)
|
resources, err := pipelineList(ctx, c, client)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return pipelineOutput(c, resources)
|
return pipelineOutput(c, resources)
|
||||||
}
|
}
|
||||||
|
|
||||||
func pipelineList(c *cli.Context, client woodpecker.Client) ([]woodpecker.Pipeline, error) {
|
func pipelineList(_ context.Context, c *cli.Command, client woodpecker.Client) ([]woodpecker.Pipeline, error) {
|
||||||
resources := make([]woodpecker.Pipeline, 0)
|
resources := make([]woodpecker.Pipeline, 0)
|
||||||
|
|
||||||
repoIDOrFullName := c.Args().First()
|
repoIDOrFullName := c.Args().First()
|
||||||
@ -78,7 +80,7 @@ func pipelineList(c *cli.Context, client woodpecker.Client) ([]woodpecker.Pipeli
|
|||||||
branch := c.String("branch")
|
branch := c.String("branch")
|
||||||
event := c.String("event")
|
event := c.String("event")
|
||||||
status := c.String("status")
|
status := c.String("status")
|
||||||
limit := c.Int("limit")
|
limit := int(c.Int("limit"))
|
||||||
|
|
||||||
var count int
|
var count int
|
||||||
for _, pipeline := range pipelines {
|
for _, pipeline := range pipelines {
|
||||||
|
@ -1,13 +1,14 @@
|
|||||||
package pipeline
|
package pipeline
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
"io"
|
"io"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"github.com/stretchr/testify/mock"
|
"github.com/stretchr/testify/mock"
|
||||||
"github.com/urfave/cli/v2"
|
"github.com/urfave/cli/v3"
|
||||||
|
|
||||||
"go.woodpecker-ci.org/woodpecker/v2/woodpecker-go/woodpecker"
|
"go.woodpecker-ci.org/woodpecker/v2/woodpecker-go/woodpecker"
|
||||||
"go.woodpecker-ci.org/woodpecker/v2/woodpecker-go/woodpecker/mocks"
|
"go.woodpecker-ci.org/woodpecker/v2/woodpecker-go/woodpecker/mocks"
|
||||||
@ -109,12 +110,10 @@ func TestPipelineList(t *testing.T) {
|
|||||||
mockClient.On("PipelineList", mock.Anything).Return(tt.pipelines, tt.pipelineErr)
|
mockClient.On("PipelineList", mock.Anything).Return(tt.pipelines, tt.pipelineErr)
|
||||||
mockClient.On("RepoLookup", mock.Anything).Return(&woodpecker.Repo{ID: tt.repoID}, nil)
|
mockClient.On("RepoLookup", mock.Anything).Return(&woodpecker.Repo{ID: tt.repoID}, nil)
|
||||||
|
|
||||||
app := &cli.App{Writer: io.Discard}
|
|
||||||
c := cli.NewContext(app, nil, nil)
|
|
||||||
|
|
||||||
command := pipelineListCmd
|
command := pipelineListCmd
|
||||||
command.Action = func(c *cli.Context) error {
|
command.Writer = io.Discard
|
||||||
pipelines, err := pipelineList(c, mockClient)
|
command.Action = func(ctx context.Context, c *cli.Command) error {
|
||||||
|
pipelines, err := pipelineList(ctx, c, mockClient)
|
||||||
if tt.wantErr != nil {
|
if tt.wantErr != nil {
|
||||||
assert.EqualError(t, err, tt.wantErr.Error())
|
assert.EqualError(t, err, tt.wantErr.Error())
|
||||||
return nil
|
return nil
|
||||||
@ -126,7 +125,7 @@ func TestPipelineList(t *testing.T) {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
_ = command.Run(c, tt.args...)
|
_ = command.Run(context.Background(), tt.args)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,10 +15,11 @@
|
|||||||
package pipeline
|
package pipeline
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"github.com/urfave/cli/v2"
|
"github.com/urfave/cli/v3"
|
||||||
|
|
||||||
"go.woodpecker-ci.org/woodpecker/v2/cli/internal"
|
"go.woodpecker-ci.org/woodpecker/v2/cli/internal"
|
||||||
)
|
)
|
||||||
@ -30,9 +31,9 @@ var pipelineLogsCmd = &cli.Command{
|
|||||||
Action: pipelineLogs,
|
Action: pipelineLogs,
|
||||||
}
|
}
|
||||||
|
|
||||||
func pipelineLogs(c *cli.Context) error {
|
func pipelineLogs(ctx context.Context, c *cli.Command) error {
|
||||||
repoIDOrFullName := c.Args().First()
|
repoIDOrFullName := c.Args().First()
|
||||||
client, err := internal.NewClient(c)
|
client, err := internal.NewClient(ctx, c)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -20,7 +20,7 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"text/template"
|
"text/template"
|
||||||
|
|
||||||
"github.com/urfave/cli/v2"
|
"github.com/urfave/cli/v3"
|
||||||
|
|
||||||
"go.woodpecker-ci.org/woodpecker/v2/cli/output"
|
"go.woodpecker-ci.org/woodpecker/v2/cli/output"
|
||||||
"go.woodpecker-ci.org/woodpecker/v2/woodpecker-go/woodpecker"
|
"go.woodpecker-ci.org/woodpecker/v2/woodpecker-go/woodpecker"
|
||||||
@ -30,7 +30,7 @@ import (
|
|||||||
var Command = &cli.Command{
|
var Command = &cli.Command{
|
||||||
Name: "pipeline",
|
Name: "pipeline",
|
||||||
Usage: "manage pipelines",
|
Usage: "manage pipelines",
|
||||||
Subcommands: []*cli.Command{
|
Commands: []*cli.Command{
|
||||||
pipelineListCmd,
|
pipelineListCmd,
|
||||||
pipelineLastCmd,
|
pipelineLastCmd,
|
||||||
pipelineLogsCmd,
|
pipelineLogsCmd,
|
||||||
@ -46,7 +46,7 @@ var Command = &cli.Command{
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
func pipelineOutput(c *cli.Context, resources []woodpecker.Pipeline, fd ...io.Writer) error {
|
func pipelineOutput(c *cli.Command, resources []woodpecker.Pipeline, fd ...io.Writer) error {
|
||||||
outFmt, outOpt := output.ParseOutputOptions(c.String("output"))
|
outFmt, outOpt := output.ParseOutputOptions(c.String("output"))
|
||||||
noHeader := c.Bool("output-no-headers")
|
noHeader := c.Bool("output-no-headers")
|
||||||
|
|
||||||
|
@ -2,11 +2,12 @@ package pipeline
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
"context"
|
||||||
"io"
|
"io"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"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/common"
|
||||||
"go.woodpecker-ci.org/woodpecker/v2/woodpecker-go/woodpecker"
|
"go.woodpecker-ci.org/woodpecker/v2/woodpecker-go/woodpecker"
|
||||||
@ -59,13 +60,11 @@ func TestPipelineOutput(t *testing.T) {
|
|||||||
|
|
||||||
for _, tt := range tests {
|
for _, tt := range tests {
|
||||||
t.Run(tt.name, func(t *testing.T) {
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
app := &cli.App{Writer: io.Discard}
|
command := &cli.Command{
|
||||||
c := cli.NewContext(app, nil, nil)
|
Writer: io.Discard,
|
||||||
|
Name: "output",
|
||||||
command := &cli.Command{}
|
Flags: common.OutputFlags("table"),
|
||||||
command.Name = "output"
|
Action: func(_ context.Context, c *cli.Command) error {
|
||||||
command.Flags = common.OutputFlags("table")
|
|
||||||
command.Action = func(c *cli.Context) error {
|
|
||||||
var buf bytes.Buffer
|
var buf bytes.Buffer
|
||||||
err := pipelineOutput(c, pipelines, &buf)
|
err := pipelineOutput(c, pipelines, &buf)
|
||||||
|
|
||||||
@ -78,9 +77,10 @@ func TestPipelineOutput(t *testing.T) {
|
|||||||
assert.Equal(t, tt.expected, buf.String())
|
assert.Equal(t, tt.expected, buf.String())
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
_ = command.Run(c, tt.args...)
|
_ = command.Run(context.Background(), tt.args)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,11 +15,12 @@
|
|||||||
package pipeline
|
package pipeline
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"os"
|
"os"
|
||||||
"strconv"
|
"strconv"
|
||||||
"text/template"
|
"text/template"
|
||||||
|
|
||||||
"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/common"
|
||||||
"go.woodpecker-ci.org/woodpecker/v2/cli/internal"
|
"go.woodpecker-ci.org/woodpecker/v2/cli/internal"
|
||||||
@ -33,9 +34,9 @@ var pipelinePsCmd = &cli.Command{
|
|||||||
Flags: []cli.Flag{common.FormatFlag(tmplPipelinePs)},
|
Flags: []cli.Flag{common.FormatFlag(tmplPipelinePs)},
|
||||||
}
|
}
|
||||||
|
|
||||||
func pipelinePs(c *cli.Context) error {
|
func pipelinePs(ctx context.Context, c *cli.Command) error {
|
||||||
repoIDOrFullName := c.Args().First()
|
repoIDOrFullName := c.Args().First()
|
||||||
client, err := internal.NewClient(c)
|
client, err := internal.NewClient(ctx, c)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -15,11 +15,12 @@
|
|||||||
package pipeline
|
package pipeline
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"text/template"
|
"text/template"
|
||||||
|
|
||||||
"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/common"
|
||||||
"go.woodpecker-ci.org/woodpecker/v2/cli/internal"
|
"go.woodpecker-ci.org/woodpecker/v2/cli/internal"
|
||||||
@ -33,8 +34,8 @@ var pipelineQueueCmd = &cli.Command{
|
|||||||
Flags: []cli.Flag{common.FormatFlag(tmplPipelineQueue)},
|
Flags: []cli.Flag{common.FormatFlag(tmplPipelineQueue)},
|
||||||
}
|
}
|
||||||
|
|
||||||
func pipelineQueue(c *cli.Context) error {
|
func pipelineQueue(ctx context.Context, c *cli.Command) error {
|
||||||
client, err := internal.NewClient(c)
|
client, err := internal.NewClient(ctx, c)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -15,11 +15,12 @@
|
|||||||
package pipeline
|
package pipeline
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"github.com/urfave/cli/v2"
|
"github.com/urfave/cli/v3"
|
||||||
|
|
||||||
"go.woodpecker-ci.org/woodpecker/v2/cli/internal"
|
"go.woodpecker-ci.org/woodpecker/v2/cli/internal"
|
||||||
)
|
)
|
||||||
@ -38,9 +39,9 @@ var pipelineStartCmd = &cli.Command{
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
func pipelineStart(c *cli.Context) (err error) {
|
func pipelineStart(ctx context.Context, c *cli.Command) (err error) {
|
||||||
repoIDOrFullName := c.Args().First()
|
repoIDOrFullName := c.Args().First()
|
||||||
client, err := internal.NewClient(c)
|
client, err := internal.NewClient(ctx, c)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -15,10 +15,11 @@
|
|||||||
package pipeline
|
package pipeline
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"github.com/urfave/cli/v2"
|
"github.com/urfave/cli/v3"
|
||||||
|
|
||||||
"go.woodpecker-ci.org/woodpecker/v2/cli/internal"
|
"go.woodpecker-ci.org/woodpecker/v2/cli/internal"
|
||||||
)
|
)
|
||||||
@ -30,9 +31,9 @@ var pipelineStopCmd = &cli.Command{
|
|||||||
Action: pipelineStop,
|
Action: pipelineStop,
|
||||||
}
|
}
|
||||||
|
|
||||||
func pipelineStop(c *cli.Context) (err error) {
|
func pipelineStop(ctx context.Context, c *cli.Command) (err error) {
|
||||||
repoIDOrFullName := c.Args().First()
|
repoIDOrFullName := c.Args().First()
|
||||||
client, err := internal.NewClient(c)
|
client, err := internal.NewClient(ctx, c)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
package registry
|
package registry
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/urfave/cli/v2"
|
"github.com/urfave/cli/v3"
|
||||||
|
|
||||||
"go.woodpecker-ci.org/woodpecker/v2/cli/internal"
|
"go.woodpecker-ci.org/woodpecker/v2/cli/internal"
|
||||||
"go.woodpecker-ci.org/woodpecker/v2/woodpecker-go/woodpecker"
|
"go.woodpecker-ci.org/woodpecker/v2/woodpecker-go/woodpecker"
|
||||||
@ -25,7 +25,7 @@ import (
|
|||||||
var Command = &cli.Command{
|
var Command = &cli.Command{
|
||||||
Name: "registry",
|
Name: "registry",
|
||||||
Usage: "manage registries",
|
Usage: "manage registries",
|
||||||
Subcommands: []*cli.Command{
|
Commands: []*cli.Command{
|
||||||
registryCreateCmd,
|
registryCreateCmd,
|
||||||
registryDeleteCmd,
|
registryDeleteCmd,
|
||||||
registryUpdateCmd,
|
registryUpdateCmd,
|
||||||
@ -34,7 +34,7 @@ var Command = &cli.Command{
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
func parseTargetArgs(client woodpecker.Client, c *cli.Context) (repoID int64, err error) {
|
func parseTargetArgs(client woodpecker.Client, c *cli.Command) (repoID int64, err error) {
|
||||||
repoIDOrFullName := c.String("repository")
|
repoIDOrFullName := c.String("repository")
|
||||||
if repoIDOrFullName == "" {
|
if repoIDOrFullName == "" {
|
||||||
repoIDOrFullName = c.Args().First()
|
repoIDOrFullName = c.Args().First()
|
||||||
|
@ -15,10 +15,11 @@
|
|||||||
package registry
|
package registry
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"os"
|
"os"
|
||||||
"strings"
|
"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/common"
|
||||||
"go.woodpecker-ci.org/woodpecker/v2/cli/internal"
|
"go.woodpecker-ci.org/woodpecker/v2/cli/internal"
|
||||||
@ -48,14 +49,14 @@ var registryCreateCmd = &cli.Command{
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
func registryCreate(c *cli.Context) error {
|
func registryCreate(ctx context.Context, c *cli.Command) error {
|
||||||
var (
|
var (
|
||||||
hostname = c.String("hostname")
|
hostname = c.String("hostname")
|
||||||
username = c.String("username")
|
username = c.String("username")
|
||||||
password = c.String("password")
|
password = c.String("password")
|
||||||
)
|
)
|
||||||
|
|
||||||
client, err := internal.NewClient(c)
|
client, err := internal.NewClient(ctx, c)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -15,10 +15,11 @@
|
|||||||
package registry
|
package registry
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"html/template"
|
"html/template"
|
||||||
"os"
|
"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/common"
|
||||||
"go.woodpecker-ci.org/woodpecker/v2/cli/internal"
|
"go.woodpecker-ci.org/woodpecker/v2/cli/internal"
|
||||||
@ -40,13 +41,13 @@ var registryInfoCmd = &cli.Command{
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
func registryInfo(c *cli.Context) error {
|
func registryInfo(ctx context.Context, c *cli.Command) error {
|
||||||
var (
|
var (
|
||||||
hostname = c.String("hostname")
|
hostname = c.String("hostname")
|
||||||
format = c.String("format") + "\n"
|
format = c.String("format") + "\n"
|
||||||
)
|
)
|
||||||
|
|
||||||
client, err := internal.NewClient(c)
|
client, err := internal.NewClient(ctx, c)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -15,10 +15,11 @@
|
|||||||
package registry
|
package registry
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"html/template"
|
"html/template"
|
||||||
"os"
|
"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/common"
|
||||||
"go.woodpecker-ci.org/woodpecker/v2/cli/internal"
|
"go.woodpecker-ci.org/woodpecker/v2/cli/internal"
|
||||||
@ -35,10 +36,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"
|
format := c.String("format") + "\n"
|
||||||
|
|
||||||
client, err := internal.NewClient(c)
|
client, err := internal.NewClient(ctx, c)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,9 @@
|
|||||||
package registry
|
package registry
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/urfave/cli/v2"
|
"context"
|
||||||
|
|
||||||
|
"github.com/urfave/cli/v3"
|
||||||
|
|
||||||
"go.woodpecker-ci.org/woodpecker/v2/cli/common"
|
"go.woodpecker-ci.org/woodpecker/v2/cli/common"
|
||||||
"go.woodpecker-ci.org/woodpecker/v2/cli/internal"
|
"go.woodpecker-ci.org/woodpecker/v2/cli/internal"
|
||||||
@ -36,10 +38,10 @@ var registryDeleteCmd = &cli.Command{
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
func registryDelete(c *cli.Context) error {
|
func registryDelete(ctx context.Context, c *cli.Command) error {
|
||||||
hostname := c.String("hostname")
|
hostname := c.String("hostname")
|
||||||
|
|
||||||
client, err := internal.NewClient(c)
|
client, err := internal.NewClient(ctx, c)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -15,10 +15,11 @@
|
|||||||
package registry
|
package registry
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"os"
|
"os"
|
||||||
"strings"
|
"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/common"
|
||||||
"go.woodpecker-ci.org/woodpecker/v2/cli/internal"
|
"go.woodpecker-ci.org/woodpecker/v2/cli/internal"
|
||||||
@ -48,14 +49,14 @@ var registryUpdateCmd = &cli.Command{
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
func registryUpdate(c *cli.Context) error {
|
func registryUpdate(ctx context.Context, c *cli.Command) error {
|
||||||
var (
|
var (
|
||||||
hostname = c.String("hostname")
|
hostname = c.String("hostname")
|
||||||
username = c.String("username")
|
username = c.String("username")
|
||||||
password = c.String("password")
|
password = c.String("password")
|
||||||
)
|
)
|
||||||
|
|
||||||
client, err := internal.NewClient(c)
|
client, err := internal.NewClient(ctx, c)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
package repo
|
package repo
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/urfave/cli/v2"
|
"github.com/urfave/cli/v3"
|
||||||
|
|
||||||
"go.woodpecker-ci.org/woodpecker/v2/cli/repo/registry"
|
"go.woodpecker-ci.org/woodpecker/v2/cli/repo/registry"
|
||||||
)
|
)
|
||||||
@ -24,7 +24,7 @@ import (
|
|||||||
var Command = &cli.Command{
|
var Command = &cli.Command{
|
||||||
Name: "repo",
|
Name: "repo",
|
||||||
Usage: "manage repositories",
|
Usage: "manage repositories",
|
||||||
Subcommands: []*cli.Command{
|
Commands: []*cli.Command{
|
||||||
repoListCmd,
|
repoListCmd,
|
||||||
repoInfoCmd,
|
repoInfoCmd,
|
||||||
repoAddCmd,
|
repoAddCmd,
|
||||||
|
@ -15,10 +15,11 @@
|
|||||||
package repo
|
package repo
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"github.com/urfave/cli/v2"
|
"github.com/urfave/cli/v3"
|
||||||
|
|
||||||
"go.woodpecker-ci.org/woodpecker/v2/cli/internal"
|
"go.woodpecker-ci.org/woodpecker/v2/cli/internal"
|
||||||
)
|
)
|
||||||
@ -30,14 +31,14 @@ var repoAddCmd = &cli.Command{
|
|||||||
Action: repoAdd,
|
Action: repoAdd,
|
||||||
}
|
}
|
||||||
|
|
||||||
func repoAdd(c *cli.Context) error {
|
func repoAdd(ctx context.Context, c *cli.Command) error {
|
||||||
_forgeRemoteID := c.Args().First()
|
_forgeRemoteID := c.Args().First()
|
||||||
forgeRemoteID, err := strconv.Atoi(_forgeRemoteID)
|
forgeRemoteID, err := strconv.Atoi(_forgeRemoteID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("invalid forge remote id: %s", _forgeRemoteID)
|
return fmt.Errorf("invalid forge remote id: %s", _forgeRemoteID)
|
||||||
}
|
}
|
||||||
|
|
||||||
client, err := internal.NewClient(c)
|
client, err := internal.NewClient(ctx, c)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -15,9 +15,10 @@
|
|||||||
package repo
|
package repo
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/urfave/cli/v2"
|
"github.com/urfave/cli/v3"
|
||||||
|
|
||||||
"go.woodpecker-ci.org/woodpecker/v2/cli/internal"
|
"go.woodpecker-ci.org/woodpecker/v2/cli/internal"
|
||||||
)
|
)
|
||||||
@ -29,9 +30,9 @@ var repoChownCmd = &cli.Command{
|
|||||||
Action: repoChown,
|
Action: repoChown,
|
||||||
}
|
}
|
||||||
|
|
||||||
func repoChown(c *cli.Context) error {
|
func repoChown(ctx context.Context, c *cli.Command) error {
|
||||||
repoIDOrFullName := c.Args().First()
|
repoIDOrFullName := c.Args().First()
|
||||||
client, err := internal.NewClient(c)
|
client, err := internal.NewClient(ctx, c)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -15,10 +15,11 @@
|
|||||||
package repo
|
package repo
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"os"
|
"os"
|
||||||
"text/template"
|
"text/template"
|
||||||
|
|
||||||
"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/common"
|
||||||
"go.woodpecker-ci.org/woodpecker/v2/cli/internal"
|
"go.woodpecker-ci.org/woodpecker/v2/cli/internal"
|
||||||
@ -32,9 +33,9 @@ var repoInfoCmd = &cli.Command{
|
|||||||
Flags: []cli.Flag{common.FormatFlag(tmplRepoInfo)},
|
Flags: []cli.Flag{common.FormatFlag(tmplRepoInfo)},
|
||||||
}
|
}
|
||||||
|
|
||||||
func repoInfo(c *cli.Context) error {
|
func repoInfo(ctx context.Context, c *cli.Command) error {
|
||||||
repoIDOrFullName := c.Args().First()
|
repoIDOrFullName := c.Args().First()
|
||||||
client, err := internal.NewClient(c)
|
client, err := internal.NewClient(ctx, c)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -15,10 +15,11 @@
|
|||||||
package repo
|
package repo
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"os"
|
"os"
|
||||||
"text/template"
|
"text/template"
|
||||||
|
|
||||||
"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/common"
|
||||||
"go.woodpecker-ci.org/woodpecker/v2/cli/internal"
|
"go.woodpecker-ci.org/woodpecker/v2/cli/internal"
|
||||||
@ -38,8 +39,8 @@ var repoListCmd = &cli.Command{
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
func repoList(c *cli.Context) error {
|
func repoList(ctx context.Context, c *cli.Command) error {
|
||||||
client, err := internal.NewClient(c)
|
client, err := internal.NewClient(ctx, c)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -15,9 +15,10 @@
|
|||||||
package repo
|
package repo
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/urfave/cli/v2"
|
"github.com/urfave/cli/v3"
|
||||||
|
|
||||||
"go.woodpecker-ci.org/woodpecker/v2/cli/internal"
|
"go.woodpecker-ci.org/woodpecker/v2/cli/internal"
|
||||||
)
|
)
|
||||||
@ -29,9 +30,9 @@ var repoRepairCmd = &cli.Command{
|
|||||||
Action: repoRepair,
|
Action: repoRepair,
|
||||||
}
|
}
|
||||||
|
|
||||||
func repoRepair(c *cli.Context) error {
|
func repoRepair(ctx context.Context, c *cli.Command) error {
|
||||||
repoIDOrFullName := c.Args().First()
|
repoIDOrFullName := c.Args().First()
|
||||||
client, err := internal.NewClient(c)
|
client, err := internal.NewClient(ctx, c)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -15,9 +15,10 @@
|
|||||||
package repo
|
package repo
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/urfave/cli/v2"
|
"github.com/urfave/cli/v3"
|
||||||
|
|
||||||
"go.woodpecker-ci.org/woodpecker/v2/cli/internal"
|
"go.woodpecker-ci.org/woodpecker/v2/cli/internal"
|
||||||
)
|
)
|
||||||
@ -29,9 +30,9 @@ var repoRemoveCmd = &cli.Command{
|
|||||||
Action: repoRemove,
|
Action: repoRemove,
|
||||||
}
|
}
|
||||||
|
|
||||||
func repoRemove(c *cli.Context) error {
|
func repoRemove(ctx context.Context, c *cli.Command) error {
|
||||||
repoIDOrFullName := c.Args().First()
|
repoIDOrFullName := c.Args().First()
|
||||||
client, err := internal.NewClient(c)
|
client, err := internal.NewClient(ctx, c)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -15,10 +15,11 @@
|
|||||||
package repo
|
package repo
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"os"
|
"os"
|
||||||
"text/template"
|
"text/template"
|
||||||
|
|
||||||
"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/common"
|
||||||
"go.woodpecker-ci.org/woodpecker/v2/cli/internal"
|
"go.woodpecker-ci.org/woodpecker/v2/cli/internal"
|
||||||
@ -33,8 +34,8 @@ var repoSyncCmd = &cli.Command{
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TODO: remove this and add an option to the list cmd as we do not store the remote repo list anymore
|
// TODO: remove this and add an option to the list cmd as we do not store the remote repo list anymore
|
||||||
func repoSync(c *cli.Context) error {
|
func repoSync(ctx context.Context, c *cli.Command) error {
|
||||||
client, err := internal.NewClient(c)
|
client, err := internal.NewClient(ctx, c)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -15,10 +15,11 @@
|
|||||||
package repo
|
package repo
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/urfave/cli/v2"
|
"github.com/urfave/cli/v3"
|
||||||
|
|
||||||
"go.woodpecker-ci.org/woodpecker/v2/cli/internal"
|
"go.woodpecker-ci.org/woodpecker/v2/cli/internal"
|
||||||
"go.woodpecker-ci.org/woodpecker/v2/woodpecker-go/woodpecker"
|
"go.woodpecker-ci.org/woodpecker/v2/woodpecker-go/woodpecker"
|
||||||
@ -61,9 +62,9 @@ var repoUpdateCmd = &cli.Command{
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
func repoUpdate(c *cli.Context) error {
|
func repoUpdate(ctx context.Context, c *cli.Command) error {
|
||||||
repoIDOrFullName := c.Args().First()
|
repoIDOrFullName := c.Args().First()
|
||||||
client, err := internal.NewClient(c)
|
client, err := internal.NewClient(ctx, c)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -78,7 +79,7 @@ func repoUpdate(c *cli.Context) error {
|
|||||||
timeout = c.Duration("timeout")
|
timeout = c.Duration("timeout")
|
||||||
trusted = c.Bool("trusted")
|
trusted = c.Bool("trusted")
|
||||||
gated = c.Bool("gated")
|
gated = c.Bool("gated")
|
||||||
pipelineCounter = c.Int("pipeline-counter")
|
pipelineCounter = int(c.Int("pipeline-counter"))
|
||||||
unsafe = c.Bool("unsafe")
|
unsafe = c.Bool("unsafe")
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@ import (
|
|||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"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/cli/internal"
|
||||||
"go.woodpecker-ci.org/woodpecker/v2/woodpecker-go/woodpecker"
|
"go.woodpecker-ci.org/woodpecker/v2/woodpecker-go/woodpecker"
|
||||||
@ -29,7 +29,7 @@ import (
|
|||||||
var Command = &cli.Command{
|
var Command = &cli.Command{
|
||||||
Name: "secret",
|
Name: "secret",
|
||||||
Usage: "manage secrets",
|
Usage: "manage secrets",
|
||||||
Subcommands: []*cli.Command{
|
Commands: []*cli.Command{
|
||||||
secretCreateCmd,
|
secretCreateCmd,
|
||||||
secretDeleteCmd,
|
secretDeleteCmd,
|
||||||
secretUpdateCmd,
|
secretUpdateCmd,
|
||||||
@ -38,7 +38,7 @@ var Command = &cli.Command{
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
func parseTargetArgs(client woodpecker.Client, c *cli.Context) (global bool, orgID, repoID int64, err error) {
|
func parseTargetArgs(client woodpecker.Client, c *cli.Command) (global bool, orgID, repoID int64, err error) {
|
||||||
if c.Bool("global") {
|
if c.Bool("global") {
|
||||||
return true, -1, -1, nil
|
return true, -1, -1, nil
|
||||||
}
|
}
|
||||||
|
@ -15,10 +15,11 @@
|
|||||||
package secret
|
package secret
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"os"
|
"os"
|
||||||
"strings"
|
"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/common"
|
||||||
"go.woodpecker-ci.org/woodpecker/v2/cli/internal"
|
"go.woodpecker-ci.org/woodpecker/v2/cli/internal"
|
||||||
@ -56,8 +57,8 @@ var secretCreateCmd = &cli.Command{
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
func secretCreate(c *cli.Context) error {
|
func secretCreate(ctx context.Context, c *cli.Command) error {
|
||||||
client, err := internal.NewClient(c)
|
client, err := internal.NewClient(ctx, c)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -15,10 +15,11 @@
|
|||||||
package secret
|
package secret
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"html/template"
|
"html/template"
|
||||||
"os"
|
"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/common"
|
||||||
"go.woodpecker-ci.org/woodpecker/v2/cli/internal"
|
"go.woodpecker-ci.org/woodpecker/v2/cli/internal"
|
||||||
@ -45,12 +46,12 @@ var secretInfoCmd = &cli.Command{
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
func secretInfo(c *cli.Context) error {
|
func secretInfo(ctx context.Context, c *cli.Command) error {
|
||||||
var (
|
var (
|
||||||
secretName = c.String("name")
|
secretName = c.String("name")
|
||||||
format = c.String("format") + "\n"
|
format = c.String("format") + "\n"
|
||||||
)
|
)
|
||||||
client, err := internal.NewClient(c)
|
client, err := internal.NewClient(ctx, c)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -15,11 +15,12 @@
|
|||||||
package secret
|
package secret
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"html/template"
|
"html/template"
|
||||||
"os"
|
"os"
|
||||||
"strings"
|
"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/common"
|
||||||
"go.woodpecker-ci.org/woodpecker/v2/cli/internal"
|
"go.woodpecker-ci.org/woodpecker/v2/cli/internal"
|
||||||
@ -42,10 +43,10 @@ var secretListCmd = &cli.Command{
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
func secretList(c *cli.Context) error {
|
func secretList(ctx context.Context, c *cli.Command) error {
|
||||||
format := c.String("format") + "\n"
|
format := c.String("format") + "\n"
|
||||||
|
|
||||||
client, err := internal.NewClient(c)
|
client, err := internal.NewClient(ctx, c)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,9 @@
|
|||||||
package secret
|
package secret
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/urfave/cli/v2"
|
"context"
|
||||||
|
|
||||||
|
"github.com/urfave/cli/v3"
|
||||||
|
|
||||||
"go.woodpecker-ci.org/woodpecker/v2/cli/common"
|
"go.woodpecker-ci.org/woodpecker/v2/cli/common"
|
||||||
"go.woodpecker-ci.org/woodpecker/v2/cli/internal"
|
"go.woodpecker-ci.org/woodpecker/v2/cli/internal"
|
||||||
@ -40,10 +42,10 @@ var secretDeleteCmd = &cli.Command{
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
func secretDelete(c *cli.Context) error {
|
func secretDelete(ctx context.Context, c *cli.Command) error {
|
||||||
secretName := c.String("name")
|
secretName := c.String("name")
|
||||||
|
|
||||||
client, err := internal.NewClient(c)
|
client, err := internal.NewClient(ctx, c)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -15,10 +15,11 @@
|
|||||||
package secret
|
package secret
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"os"
|
"os"
|
||||||
"strings"
|
"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/common"
|
||||||
"go.woodpecker-ci.org/woodpecker/v2/cli/internal"
|
"go.woodpecker-ci.org/woodpecker/v2/cli/internal"
|
||||||
@ -56,8 +57,8 @@ var secretUpdateCmd = &cli.Command{
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
func secretUpdate(c *cli.Context) error {
|
func secretUpdate(ctx context.Context, c *cli.Command) error {
|
||||||
client, err := internal.NewClient(c)
|
client, err := internal.NewClient(ctx, c)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,12 @@
|
|||||||
package setup
|
package setup
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/rs/zerolog/log"
|
"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/internal/config"
|
||||||
"go.woodpecker-ci.org/woodpecker/v2/cli/setup/ui"
|
"go.woodpecker-ci.org/woodpecker/v2/cli/setup/ui"
|
||||||
@ -15,7 +16,6 @@ import (
|
|||||||
var Command = &cli.Command{
|
var Command = &cli.Command{
|
||||||
Name: "setup",
|
Name: "setup",
|
||||||
Usage: "setup the woodpecker-cli for the first time",
|
Usage: "setup the woodpecker-cli for the first time",
|
||||||
Args: true,
|
|
||||||
ArgsUsage: "[server]",
|
ArgsUsage: "[server]",
|
||||||
Flags: []cli.Flag{
|
Flags: []cli.Flag{
|
||||||
&cli.StringFlag{
|
&cli.StringFlag{
|
||||||
@ -30,8 +30,8 @@ var Command = &cli.Command{
|
|||||||
Action: setup,
|
Action: setup,
|
||||||
}
|
}
|
||||||
|
|
||||||
func setup(c *cli.Context) error {
|
func setup(ctx context.Context, c *cli.Command) error {
|
||||||
_config, err := config.Get(c, c.String("config"))
|
_config, err := config.Get(ctx, c, c.String("config"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
} else if _config != nil {
|
} else if _config != nil {
|
||||||
@ -68,7 +68,7 @@ func setup(c *cli.Context) error {
|
|||||||
|
|
||||||
token := c.String("token")
|
token := c.String("token")
|
||||||
if token == "" {
|
if token == "" {
|
||||||
token, err = receiveTokenFromUI(c.Context, serverURL)
|
token, err = receiveTokenFromUI(ctx, serverURL)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -78,7 +78,7 @@ func setup(c *cli.Context) error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
err = config.Save(c, c.String("config"), &config.Config{
|
err = config.Save(ctx, c, c.String("config"), &config.Config{
|
||||||
ServerURL: serverURL,
|
ServerURL: serverURL,
|
||||||
Token: token,
|
Token: token,
|
||||||
LogLevel: "info",
|
LogLevel: "info",
|
||||||
|
@ -1,12 +1,13 @@
|
|||||||
package update
|
package update
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
|
||||||
"github.com/rs/zerolog/log"
|
"github.com/rs/zerolog/log"
|
||||||
"github.com/urfave/cli/v2"
|
"github.com/urfave/cli/v3"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Command exports the update command.
|
// Command exports the update command.
|
||||||
@ -22,10 +23,10 @@ var Command = &cli.Command{
|
|||||||
Action: update,
|
Action: update,
|
||||||
}
|
}
|
||||||
|
|
||||||
func update(c *cli.Context) error {
|
func update(ctx context.Context, c *cli.Command) error {
|
||||||
log.Info().Msg("Checking for updates ...")
|
log.Info().Msg("Checking for updates ...")
|
||||||
|
|
||||||
newVersion, err := CheckForUpdate(c.Context, c.Bool("force"))
|
newVersion, err := CheckForUpdate(ctx, c.Bool("force"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -38,7 +39,7 @@ func update(c *cli.Context) error {
|
|||||||
log.Info().Msgf("New version %s is available! Updating ...", newVersion.Version)
|
log.Info().Msgf("New version %s is available! Updating ...", newVersion.Version)
|
||||||
|
|
||||||
var tarFilePath string
|
var tarFilePath string
|
||||||
tarFilePath, err = downloadNewVersion(c.Context, newVersion.AssetURL)
|
tarFilePath, err = downloadNewVersion(ctx, newVersion.AssetURL)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -15,14 +15,14 @@
|
|||||||
package user
|
package user
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/urfave/cli/v2"
|
"github.com/urfave/cli/v3"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Command exports the user command set.
|
// Command exports the user command set.
|
||||||
var Command = &cli.Command{
|
var Command = &cli.Command{
|
||||||
Name: "user",
|
Name: "user",
|
||||||
Usage: "manage users",
|
Usage: "manage users",
|
||||||
Subcommands: []*cli.Command{
|
Commands: []*cli.Command{
|
||||||
userListCmd,
|
userListCmd,
|
||||||
userInfoCmd,
|
userInfoCmd,
|
||||||
userAddCmd,
|
userAddCmd,
|
||||||
|
@ -15,9 +15,10 @@
|
|||||||
package user
|
package user
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/urfave/cli/v2"
|
"github.com/urfave/cli/v3"
|
||||||
|
|
||||||
"go.woodpecker-ci.org/woodpecker/v2/cli/internal"
|
"go.woodpecker-ci.org/woodpecker/v2/cli/internal"
|
||||||
"go.woodpecker-ci.org/woodpecker/v2/woodpecker-go/woodpecker"
|
"go.woodpecker-ci.org/woodpecker/v2/woodpecker-go/woodpecker"
|
||||||
@ -30,10 +31,10 @@ var userAddCmd = &cli.Command{
|
|||||||
Action: userAdd,
|
Action: userAdd,
|
||||||
}
|
}
|
||||||
|
|
||||||
func userAdd(c *cli.Context) error {
|
func userAdd(ctx context.Context, c *cli.Command) error {
|
||||||
login := c.Args().First()
|
login := c.Args().First()
|
||||||
|
|
||||||
client, err := internal.NewClient(c)
|
client, err := internal.NewClient(ctx, c)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -15,11 +15,12 @@
|
|||||||
package user
|
package user
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"text/template"
|
"text/template"
|
||||||
|
|
||||||
"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/common"
|
||||||
"go.woodpecker-ci.org/woodpecker/v2/cli/internal"
|
"go.woodpecker-ci.org/woodpecker/v2/cli/internal"
|
||||||
@ -33,8 +34,8 @@ var userInfoCmd = &cli.Command{
|
|||||||
Flags: []cli.Flag{common.FormatFlag(tmplUserInfo)},
|
Flags: []cli.Flag{common.FormatFlag(tmplUserInfo)},
|
||||||
}
|
}
|
||||||
|
|
||||||
func userInfo(c *cli.Context) error {
|
func userInfo(ctx context.Context, c *cli.Command) error {
|
||||||
client, err := internal.NewClient(c)
|
client, err := internal.NewClient(ctx, c)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -15,10 +15,11 @@
|
|||||||
package user
|
package user
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"os"
|
"os"
|
||||||
"text/template"
|
"text/template"
|
||||||
|
|
||||||
"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/common"
|
||||||
"go.woodpecker-ci.org/woodpecker/v2/cli/internal"
|
"go.woodpecker-ci.org/woodpecker/v2/cli/internal"
|
||||||
@ -32,8 +33,8 @@ var userListCmd = &cli.Command{
|
|||||||
Flags: []cli.Flag{common.FormatFlag(tmplUserList)},
|
Flags: []cli.Flag{common.FormatFlag(tmplUserList)},
|
||||||
}
|
}
|
||||||
|
|
||||||
func userList(c *cli.Context) error {
|
func userList(ctx context.Context, c *cli.Command) error {
|
||||||
client, err := internal.NewClient(c)
|
client, err := internal.NewClient(ctx, c)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -15,9 +15,10 @@
|
|||||||
package user
|
package user
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/urfave/cli/v2"
|
"github.com/urfave/cli/v3"
|
||||||
|
|
||||||
"go.woodpecker-ci.org/woodpecker/v2/cli/internal"
|
"go.woodpecker-ci.org/woodpecker/v2/cli/internal"
|
||||||
)
|
)
|
||||||
@ -29,10 +30,10 @@ var userRemoveCmd = &cli.Command{
|
|||||||
Action: userRemove,
|
Action: userRemove,
|
||||||
}
|
}
|
||||||
|
|
||||||
func userRemove(c *cli.Context) error {
|
func userRemove(ctx context.Context, c *cli.Command) error {
|
||||||
login := c.Args().First()
|
login := c.Args().First()
|
||||||
|
|
||||||
client, err := internal.NewClient(c)
|
client, err := internal.NewClient(ctx, c)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -27,7 +27,7 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/rs/zerolog/log"
|
"github.com/rs/zerolog/log"
|
||||||
"github.com/urfave/cli/v2"
|
"github.com/urfave/cli/v3"
|
||||||
"golang.org/x/sync/errgroup"
|
"golang.org/x/sync/errgroup"
|
||||||
"google.golang.org/grpc"
|
"google.golang.org/grpc"
|
||||||
"google.golang.org/grpc/codes"
|
"google.golang.org/grpc/codes"
|
||||||
@ -62,11 +62,7 @@ var (
|
|||||||
shutdownCtx = context.Background()
|
shutdownCtx = context.Background()
|
||||||
)
|
)
|
||||||
|
|
||||||
func run(c *cli.Context, backends []types.Backend) error {
|
func run(ctx context.Context, c *cli.Command, backends []types.Backend) error {
|
||||||
ctx := utils.WithContextSigtermCallback(c.Context, func() {
|
|
||||||
log.Info().Msg("termination signal is received, shutting down agent")
|
|
||||||
})
|
|
||||||
|
|
||||||
agentCtx, ctxCancel := context.WithCancelCause(ctx)
|
agentCtx, ctxCancel := context.WithCancelCause(ctx)
|
||||||
stopAgentFunc = func(err error) {
|
stopAgentFunc = func(err error) {
|
||||||
msg := "shutdown of whole agent"
|
msg := "shutdown of whole agent"
|
||||||
@ -90,7 +86,7 @@ func run(c *cli.Context, backends []types.Backend) error {
|
|||||||
hostname, _ = os.Hostname()
|
hostname, _ = os.Hostname()
|
||||||
}
|
}
|
||||||
|
|
||||||
counter.Polling = c.Int("max-workflows")
|
counter.Polling = int(c.Int("max-workflows"))
|
||||||
counter.Running = 0
|
counter.Running = 0
|
||||||
|
|
||||||
if c.Bool("healthcheck") {
|
if c.Bool("healthcheck") {
|
||||||
@ -139,7 +135,7 @@ func run(c *cli.Context, backends []types.Backend) error {
|
|||||||
grpcClientCtx, grpcClientCtxCancel := context.WithCancelCause(context.Background())
|
grpcClientCtx, grpcClientCtxCancel := context.WithCancelCause(context.Background())
|
||||||
defer grpcClientCtxCancel(nil)
|
defer grpcClientCtxCancel(nil)
|
||||||
authClient := agent_rpc.NewAuthGrpcClient(authConn, agentToken, agentConfig.AgentID)
|
authClient := agent_rpc.NewAuthGrpcClient(authConn, agentToken, agentConfig.AgentID)
|
||||||
authInterceptor, err := agent_rpc.NewAuthInterceptor(grpcClientCtx, authClient, authInterceptorRefreshInterval)
|
authInterceptor, err := agent_rpc.NewAuthInterceptor(grpcClientCtx, authClient, authInterceptorRefreshInterval) //nolint:contextcheck
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -165,7 +161,7 @@ func run(c *cli.Context, backends []types.Backend) error {
|
|||||||
grpcCtx := metadata.NewOutgoingContext(grpcClientCtx, metadata.Pairs("hostname", hostname))
|
grpcCtx := metadata.NewOutgoingContext(grpcClientCtx, metadata.Pairs("hostname", hostname))
|
||||||
|
|
||||||
// check if grpc server version is compatible with agent
|
// check if grpc server version is compatible with agent
|
||||||
grpcServerVersion, err := client.Version(grpcCtx)
|
grpcServerVersion, err := client.Version(grpcCtx) //nolint:contextcheck
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error().Err(err).Msg("could not get grpc server version")
|
log.Error().Err(err).Msg("could not get grpc server version")
|
||||||
return err
|
return err
|
||||||
@ -180,7 +176,7 @@ func run(c *cli.Context, backends []types.Backend) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// new engine
|
// new engine
|
||||||
backendCtx := context.WithValue(agentCtx, types.CliContext, c)
|
backendCtx := context.WithValue(agentCtx, types.CliCommand, c)
|
||||||
backendName := c.String("backend-engine")
|
backendName := c.String("backend-engine")
|
||||||
backendEngine, err := backend.FindBackend(backendCtx, backends, backendName)
|
backendEngine, err := backend.FindBackend(backendCtx, backends, backendName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -200,8 +196,8 @@ func run(c *cli.Context, backends []types.Backend) error {
|
|||||||
}
|
}
|
||||||
log.Debug().Msgf("loaded %s backend engine", backendEngine.Name())
|
log.Debug().Msgf("loaded %s backend engine", backendEngine.Name())
|
||||||
|
|
||||||
maxWorkflows := c.Int("max-workflows")
|
maxWorkflows := int(c.Int("max-workflows"))
|
||||||
agentConfig.AgentID, err = client.RegisterAgent(grpcCtx, engInfo.Platform, backendEngine.Name(), version.String(), maxWorkflows)
|
agentConfig.AgentID, err = client.RegisterAgent(grpcCtx, engInfo.Platform, backendEngine.Name(), version.String(), maxWorkflows) //nolint:contextcheck
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -291,19 +287,19 @@ func run(c *cli.Context, backends []types.Backend) error {
|
|||||||
return serviceWaitingGroup.Wait()
|
return serviceWaitingGroup.Wait()
|
||||||
}
|
}
|
||||||
|
|
||||||
func runWithRetry(backendEngines []types.Backend) func(c *cli.Context) error {
|
func runWithRetry(backendEngines []types.Backend) func(ctx context.Context, c *cli.Command) error {
|
||||||
return func(c *cli.Context) error {
|
return func(ctx context.Context, c *cli.Command) error {
|
||||||
if err := logger.SetupGlobalLogger(c, true); err != nil {
|
if err := logger.SetupGlobalLogger(ctx, c, true); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
initHealth()
|
initHealth()
|
||||||
|
|
||||||
retryCount := c.Int("connect-retry-count")
|
retryCount := int(c.Int("connect-retry-count"))
|
||||||
retryDelay := c.Duration("connect-retry-delay")
|
retryDelay := c.Duration("connect-retry-delay")
|
||||||
var err error
|
var err error
|
||||||
for i := 0; i < retryCount; i++ {
|
for i := 0; i < retryCount; i++ {
|
||||||
if err = run(c, backendEngines); status.Code(err) == codes.Unavailable {
|
if err = run(ctx, c, backendEngines); status.Code(err) == codes.Unavailable {
|
||||||
log.Warn().Err(err).Msg(fmt.Sprintf("cannot connect to server, retrying in %v", retryDelay))
|
log.Warn().Err(err).Msg(fmt.Sprintf("cannot connect to server, retrying in %v", retryDelay))
|
||||||
time.Sleep(retryDelay)
|
time.Sleep(retryDelay)
|
||||||
} else {
|
} else {
|
||||||
|
@ -19,93 +19,94 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/urfave/cli/v2"
|
"github.com/urfave/cli/v3"
|
||||||
)
|
)
|
||||||
|
|
||||||
//nolint:mnd
|
//nolint:mnd
|
||||||
var flags = []cli.Flag{
|
var flags = []cli.Flag{
|
||||||
&cli.StringFlag{
|
&cli.StringFlag{
|
||||||
EnvVars: []string{"WOODPECKER_SERVER"},
|
Sources: cli.EnvVars("WOODPECKER_SERVER"),
|
||||||
Name: "server",
|
Name: "server",
|
||||||
Usage: "server address",
|
Usage: "server address",
|
||||||
Value: "localhost:9000",
|
Value: "localhost:9000",
|
||||||
},
|
},
|
||||||
&cli.StringFlag{
|
&cli.StringFlag{
|
||||||
EnvVars: []string{"WOODPECKER_AGENT_SECRET"},
|
|
||||||
Name: "grpc-token",
|
Name: "grpc-token",
|
||||||
Usage: "server-agent shared token",
|
Usage: "server-agent shared token",
|
||||||
FilePath: os.Getenv("WOODPECKER_AGENT_SECRET_FILE"),
|
Sources: cli.NewValueSourceChain(
|
||||||
|
cli.File(os.Getenv("WOODPECKER_AGENT_SECRET_FILE")),
|
||||||
|
cli.EnvVar("WOODPECKER_AGENT_SECRET")),
|
||||||
},
|
},
|
||||||
&cli.BoolFlag{
|
&cli.BoolFlag{
|
||||||
EnvVars: []string{"WOODPECKER_GRPC_SECURE"},
|
Sources: cli.EnvVars("WOODPECKER_GRPC_SECURE"),
|
||||||
Name: "grpc-secure",
|
Name: "grpc-secure",
|
||||||
Usage: "should the connection to WOODPECKER_SERVER be made using a secure transport",
|
Usage: "should the connection to WOODPECKER_SERVER be made using a secure transport",
|
||||||
},
|
},
|
||||||
&cli.BoolFlag{
|
&cli.BoolFlag{
|
||||||
EnvVars: []string{"WOODPECKER_GRPC_VERIFY"},
|
Sources: cli.EnvVars("WOODPECKER_GRPC_VERIFY"),
|
||||||
Name: "grpc-skip-insecure",
|
Name: "grpc-skip-insecure",
|
||||||
Usage: "should the grpc server certificate be verified, only valid when WOODPECKER_GRPC_SECURE is true",
|
Usage: "should the grpc server certificate be verified, only valid when WOODPECKER_GRPC_SECURE is true",
|
||||||
Value: true,
|
Value: true,
|
||||||
},
|
},
|
||||||
&cli.StringFlag{
|
&cli.StringFlag{
|
||||||
EnvVars: []string{"WOODPECKER_HOSTNAME"},
|
Sources: cli.EnvVars("WOODPECKER_HOSTNAME"),
|
||||||
Name: "hostname",
|
Name: "hostname",
|
||||||
Usage: "agent hostname",
|
Usage: "agent hostname",
|
||||||
},
|
},
|
||||||
&cli.StringFlag{
|
&cli.StringFlag{
|
||||||
EnvVars: []string{"WOODPECKER_AGENT_CONFIG_FILE"},
|
Sources: cli.EnvVars("WOODPECKER_AGENT_CONFIG_FILE"),
|
||||||
Name: "agent-config",
|
Name: "agent-config",
|
||||||
Usage: "agent config file path, if set empty the agent will be stateless and unregister on termination",
|
Usage: "agent config file path, if set empty the agent will be stateless and unregister on termination",
|
||||||
Value: "/etc/woodpecker/agent.conf",
|
Value: "/etc/woodpecker/agent.conf",
|
||||||
},
|
},
|
||||||
&cli.StringSliceFlag{
|
&cli.StringSliceFlag{
|
||||||
EnvVars: []string{"WOODPECKER_FILTER_LABELS"},
|
Sources: cli.EnvVars("WOODPECKER_FILTER_LABELS"),
|
||||||
Name: "filter",
|
Name: "filter",
|
||||||
Usage: "List of labels to filter tasks on. An agent must be assigned every tag listed in a task to be selected.",
|
Usage: "List of labels to filter tasks on. An agent must be assigned every tag listed in a task to be selected.",
|
||||||
},
|
},
|
||||||
&cli.IntFlag{
|
&cli.IntFlag{
|
||||||
EnvVars: []string{"WOODPECKER_MAX_WORKFLOWS", "WOODPECKER_MAX_PROCS"}, // cspell:words PROCS
|
Sources: cli.EnvVars("WOODPECKER_MAX_WORKFLOWS", "WOODPECKER_MAX_PROCS"), // cspell:words PROCS
|
||||||
Name: "max-workflows",
|
Name: "max-workflows",
|
||||||
Usage: "agent parallel workflows",
|
Usage: "agent parallel workflows",
|
||||||
Value: 1,
|
Value: 1,
|
||||||
},
|
},
|
||||||
&cli.BoolFlag{
|
&cli.BoolFlag{
|
||||||
EnvVars: []string{"WOODPECKER_HEALTHCHECK"},
|
Sources: cli.EnvVars("WOODPECKER_HEALTHCHECK"),
|
||||||
Name: "healthcheck",
|
Name: "healthcheck",
|
||||||
Usage: "enable healthcheck endpoint",
|
Usage: "enable healthcheck endpoint",
|
||||||
Value: true,
|
Value: true,
|
||||||
},
|
},
|
||||||
&cli.StringFlag{
|
&cli.StringFlag{
|
||||||
EnvVars: []string{"WOODPECKER_HEALTHCHECK_ADDR"},
|
Sources: cli.EnvVars("WOODPECKER_HEALTHCHECK_ADDR"),
|
||||||
Name: "healthcheck-addr",
|
Name: "healthcheck-addr",
|
||||||
Usage: "healthcheck endpoint address",
|
Usage: "healthcheck endpoint address",
|
||||||
Value: ":3000",
|
Value: ":3000",
|
||||||
},
|
},
|
||||||
&cli.DurationFlag{
|
&cli.DurationFlag{
|
||||||
EnvVars: []string{"WOODPECKER_KEEPALIVE_TIME"},
|
Sources: cli.EnvVars("WOODPECKER_KEEPALIVE_TIME"),
|
||||||
Name: "keepalive-time",
|
Name: "keepalive-time",
|
||||||
Usage: "after a duration of this time of no activity, the agent pings the server to check if the transport is still alive",
|
Usage: "after a duration of this time of no activity, the agent pings the server to check if the transport is still alive",
|
||||||
},
|
},
|
||||||
&cli.DurationFlag{
|
&cli.DurationFlag{
|
||||||
EnvVars: []string{"WOODPECKER_KEEPALIVE_TIMEOUT"},
|
Sources: cli.EnvVars("WOODPECKER_KEEPALIVE_TIMEOUT"),
|
||||||
Name: "keepalive-timeout",
|
Name: "keepalive-timeout",
|
||||||
Usage: "after pinging for a keepalive check, the agent waits for a duration of this time before closing the connection if no activity",
|
Usage: "after pinging for a keepalive check, the agent waits for a duration of this time before closing the connection if no activity",
|
||||||
Value: time.Second * 20,
|
Value: time.Second * 20,
|
||||||
},
|
},
|
||||||
&cli.StringFlag{
|
&cli.StringFlag{
|
||||||
EnvVars: []string{"WOODPECKER_BACKEND"},
|
Sources: cli.EnvVars("WOODPECKER_BACKEND"),
|
||||||
Name: "backend-engine",
|
Name: "backend-engine",
|
||||||
Usage: "backend to run pipelines on",
|
Usage: "backend to run pipelines on",
|
||||||
Value: "auto-detect",
|
Value: "auto-detect",
|
||||||
},
|
},
|
||||||
&cli.IntFlag{
|
&cli.IntFlag{
|
||||||
EnvVars: []string{"WOODPECKER_CONNECT_RETRY_COUNT"},
|
Sources: cli.EnvVars("WOODPECKER_CONNECT_RETRY_COUNT"),
|
||||||
Name: "connect-retry-count",
|
Name: "connect-retry-count",
|
||||||
Usage: "number of times to retry connecting to the server",
|
Usage: "number of times to retry connecting to the server",
|
||||||
Value: 5,
|
Value: 5,
|
||||||
},
|
},
|
||||||
&cli.DurationFlag{
|
&cli.DurationFlag{
|
||||||
EnvVars: []string{"WOODPECKER_CONNECT_RETRY_DELAY"},
|
Sources: cli.EnvVars("WOODPECKER_CONNECT_RETRY_DELAY"),
|
||||||
Name: "connect-retry-delay",
|
Name: "connect-retry-delay",
|
||||||
Usage: "duration to wait before retrying to connect to the server",
|
Usage: "duration to wait before retrying to connect to the server",
|
||||||
Value: time.Second * 2,
|
Value: time.Second * 2,
|
||||||
|
@ -15,13 +15,14 @@
|
|||||||
package core
|
package core
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/rs/zerolog/log"
|
"github.com/rs/zerolog/log"
|
||||||
"github.com/urfave/cli/v2"
|
"github.com/urfave/cli/v3"
|
||||||
|
|
||||||
"go.woodpecker-ci.org/woodpecker/v2/agent"
|
"go.woodpecker-ci.org/woodpecker/v2/agent"
|
||||||
"go.woodpecker-ci.org/woodpecker/v2/version"
|
"go.woodpecker-ci.org/woodpecker/v2/version"
|
||||||
@ -81,8 +82,7 @@ var counter = &agent.State{
|
|||||||
|
|
||||||
// handles pinging the endpoint and returns an error if the
|
// handles pinging the endpoint and returns an error if the
|
||||||
// agent is in an unhealthy state.
|
// agent is in an unhealthy state.
|
||||||
func pinger(c *cli.Context) error {
|
func pinger(ctx context.Context, c *cli.Command) error {
|
||||||
ctx := c.Context
|
|
||||||
healthcheckAddress := c.String("healthcheck-addr")
|
healthcheckAddress := c.String("healthcheck-addr")
|
||||||
if strings.HasPrefix(healthcheckAddress, ":") {
|
if strings.HasPrefix(healthcheckAddress, ":") {
|
||||||
// this seems sufficient according to https://pkg.go.dev/net#Dial
|
// this seems sufficient according to https://pkg.go.dev/net#Dial
|
||||||
|
@ -15,12 +15,13 @@
|
|||||||
package core
|
package core
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
// Load config from .env file.
|
// Load config from .env file.
|
||||||
_ "github.com/joho/godotenv/autoload"
|
_ "github.com/joho/godotenv/autoload"
|
||||||
"github.com/rs/zerolog/log"
|
"github.com/rs/zerolog/log"
|
||||||
"github.com/urfave/cli/v2"
|
"github.com/urfave/cli/v3"
|
||||||
|
|
||||||
backend "go.woodpecker-ci.org/woodpecker/v2/pipeline/backend/types"
|
backend "go.woodpecker-ci.org/woodpecker/v2/pipeline/backend/types"
|
||||||
"go.woodpecker-ci.org/woodpecker/v2/shared/logger"
|
"go.woodpecker-ci.org/woodpecker/v2/shared/logger"
|
||||||
@ -28,8 +29,8 @@ import (
|
|||||||
"go.woodpecker-ci.org/woodpecker/v2/version"
|
"go.woodpecker-ci.org/woodpecker/v2/version"
|
||||||
)
|
)
|
||||||
|
|
||||||
func RunAgent(backends []backend.Backend) {
|
func RunAgent(ctx context.Context, backends []backend.Backend) {
|
||||||
app := cli.NewApp()
|
app := &cli.Command{}
|
||||||
app.Name = "woodpecker-agent"
|
app.Name = "woodpecker-agent"
|
||||||
app.Version = version.String()
|
app.Version = version.String()
|
||||||
app.Usage = "woodpecker agent"
|
app.Usage = "woodpecker agent"
|
||||||
@ -47,7 +48,7 @@ func RunAgent(backends []backend.Backend) {
|
|||||||
}
|
}
|
||||||
app.Flags = agentFlags
|
app.Flags = agentFlags
|
||||||
|
|
||||||
if err := app.Run(os.Args); err != nil {
|
if err := app.Run(ctx, os.Args); err != nil {
|
||||||
log.Fatal().Err(err).Msg("error running agent") //nolint:forbidigo
|
log.Fatal().Err(err).Msg("error running agent") //nolint:forbidigo
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,11 +15,16 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
|
"github.com/rs/zerolog/log"
|
||||||
|
|
||||||
"go.woodpecker-ci.org/woodpecker/v2/cmd/agent/core"
|
"go.woodpecker-ci.org/woodpecker/v2/cmd/agent/core"
|
||||||
"go.woodpecker-ci.org/woodpecker/v2/pipeline/backend/docker"
|
"go.woodpecker-ci.org/woodpecker/v2/pipeline/backend/docker"
|
||||||
"go.woodpecker-ci.org/woodpecker/v2/pipeline/backend/kubernetes"
|
"go.woodpecker-ci.org/woodpecker/v2/pipeline/backend/kubernetes"
|
||||||
"go.woodpecker-ci.org/woodpecker/v2/pipeline/backend/local"
|
"go.woodpecker-ci.org/woodpecker/v2/pipeline/backend/local"
|
||||||
backendTypes "go.woodpecker-ci.org/woodpecker/v2/pipeline/backend/types"
|
backendTypes "go.woodpecker-ci.org/woodpecker/v2/pipeline/backend/types"
|
||||||
|
"go.woodpecker-ci.org/woodpecker/v2/shared/utils"
|
||||||
)
|
)
|
||||||
|
|
||||||
var backends = []backendTypes.Backend{
|
var backends = []backendTypes.Backend{
|
||||||
@ -29,5 +34,8 @@ var backends = []backendTypes.Backend{
|
|||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
core.RunAgent(backends)
|
ctx := utils.WithContextSigtermCallback(context.Background(), func() {
|
||||||
|
log.Info().Msg("termination signal is received, shutting down agent")
|
||||||
|
})
|
||||||
|
core.RunAgent(ctx, backends)
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/urfave/cli/v2"
|
"github.com/urfave/cli/v3"
|
||||||
|
|
||||||
"go.woodpecker-ci.org/woodpecker/v2/cli/admin"
|
"go.woodpecker-ci.org/woodpecker/v2/cli/admin"
|
||||||
"go.woodpecker-ci.org/woodpecker/v2/cli/common"
|
"go.woodpecker-ci.org/woodpecker/v2/cli/common"
|
||||||
@ -38,12 +38,12 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
//go:generate go run docs.go app.go
|
//go:generate go run docs.go app.go
|
||||||
func newApp() *cli.App {
|
func newApp() *cli.Command {
|
||||||
app := cli.NewApp()
|
app := &cli.Command{}
|
||||||
app.Name = "woodpecker-cli"
|
app.Name = "woodpecker-cli"
|
||||||
app.Description = "Woodpecker command line utility"
|
app.Description = "Woodpecker command line utility"
|
||||||
app.Version = version.String()
|
app.Version = version.String()
|
||||||
app.EnableBashCompletion = true
|
app.Usage = "command line utility"
|
||||||
app.Flags = common.GlobalFlags
|
app.Flags = common.GlobalFlags
|
||||||
app.Before = common.Before
|
app.Before = common.Before
|
||||||
app.After = common.After
|
app.After = common.After
|
||||||
|
@ -19,11 +19,13 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
|
docs "github.com/urfave/cli-docs/v3"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
app := newApp()
|
app := newApp()
|
||||||
md, err := app.ToMarkdown()
|
md, err := docs.ToMarkdown(app)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
@ -15,15 +15,22 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
_ "github.com/joho/godotenv/autoload"
|
_ "github.com/joho/godotenv/autoload"
|
||||||
"github.com/rs/zerolog/log"
|
"github.com/rs/zerolog/log"
|
||||||
|
|
||||||
|
"go.woodpecker-ci.org/woodpecker/v2/shared/utils"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
ctx := utils.WithContextSigtermCallback(context.Background(), func() {
|
||||||
|
log.Info().Msg("termination signal is received, terminate cli")
|
||||||
|
})
|
||||||
|
|
||||||
app := newApp()
|
app := newApp()
|
||||||
if err := app.Run(os.Args); err != nil {
|
if err := app.Run(ctx, os.Args); err != nil {
|
||||||
log.Fatal().Err(err).Msg("error running cli") //nolint:forbidigo
|
log.Fatal().Err(err).Msg("error running cli") //nolint:forbidigo
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
// Copyright 2023 Woodpecker Authors
|
||||||
// Copyright 2019 Laszlo Fogas
|
// Copyright 2019 Laszlo Fogas
|
||||||
//
|
//
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
@ -18,7 +19,7 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/urfave/cli/v2"
|
"github.com/urfave/cli/v3"
|
||||||
|
|
||||||
"go.woodpecker-ci.org/woodpecker/v2/shared/constant"
|
"go.woodpecker-ci.org/woodpecker/v2/shared/constant"
|
||||||
"go.woodpecker-ci.org/woodpecker/v2/shared/logger"
|
"go.woodpecker-ci.org/woodpecker/v2/shared/logger"
|
||||||
@ -26,229 +27,232 @@ import (
|
|||||||
|
|
||||||
var flags = append([]cli.Flag{
|
var flags = append([]cli.Flag{
|
||||||
&cli.BoolFlag{
|
&cli.BoolFlag{
|
||||||
EnvVars: []string{"WOODPECKER_LOG_XORM"},
|
Sources: cli.EnvVars("WOODPECKER_LOG_XORM"),
|
||||||
Name: "log-xorm",
|
Name: "log-xorm",
|
||||||
Usage: "enable xorm logging",
|
Usage: "enable xorm logging",
|
||||||
},
|
},
|
||||||
&cli.BoolFlag{
|
&cli.BoolFlag{
|
||||||
EnvVars: []string{"WOODPECKER_LOG_XORM_SQL"},
|
Sources: cli.EnvVars("WOODPECKER_LOG_XORM_SQL"),
|
||||||
Name: "log-xorm-sql",
|
Name: "log-xorm-sql",
|
||||||
Usage: "enable xorm sql command logging",
|
Usage: "enable xorm sql command logging",
|
||||||
},
|
},
|
||||||
&cli.StringFlag{
|
&cli.StringFlag{
|
||||||
EnvVars: []string{"WOODPECKER_HOST"},
|
Sources: cli.EnvVars("WOODPECKER_HOST"),
|
||||||
Name: "server-host",
|
Name: "server-host",
|
||||||
Usage: "server fully qualified url. Format: <scheme>://<host>[/<prefix path>]",
|
Usage: "server fully qualified url. Format: <scheme>://<host>[/<prefix path>]",
|
||||||
},
|
},
|
||||||
&cli.StringFlag{
|
&cli.StringFlag{
|
||||||
EnvVars: []string{"WOODPECKER_SERVER_ADDR"},
|
Sources: cli.EnvVars("WOODPECKER_SERVER_ADDR"),
|
||||||
Name: "server-addr",
|
Name: "server-addr",
|
||||||
Usage: "server address",
|
Usage: "server address",
|
||||||
Value: ":8000",
|
Value: ":8000",
|
||||||
},
|
},
|
||||||
&cli.StringFlag{
|
&cli.StringFlag{
|
||||||
EnvVars: []string{"WOODPECKER_SERVER_ADDR_TLS"},
|
Sources: cli.EnvVars("WOODPECKER_SERVER_ADDR_TLS"),
|
||||||
Name: "server-addr-tls",
|
Name: "server-addr-tls",
|
||||||
Usage: "port https with tls (:443)",
|
Usage: "port https with tls (:443)",
|
||||||
Value: ":443",
|
Value: ":443",
|
||||||
},
|
},
|
||||||
&cli.StringFlag{
|
&cli.StringFlag{
|
||||||
EnvVars: []string{"WOODPECKER_SERVER_CERT"},
|
Sources: cli.EnvVars("WOODPECKER_SERVER_CERT"),
|
||||||
Name: "server-cert",
|
Name: "server-cert",
|
||||||
Usage: "server ssl cert path",
|
Usage: "server ssl cert path",
|
||||||
},
|
},
|
||||||
&cli.StringFlag{
|
&cli.StringFlag{
|
||||||
EnvVars: []string{"WOODPECKER_SERVER_KEY"},
|
Sources: cli.EnvVars("WOODPECKER_SERVER_KEY"),
|
||||||
Name: "server-key",
|
Name: "server-key",
|
||||||
Usage: "server ssl key path",
|
Usage: "server ssl key path",
|
||||||
},
|
},
|
||||||
&cli.StringFlag{
|
&cli.StringFlag{
|
||||||
EnvVars: []string{"WOODPECKER_CUSTOM_CSS_FILE"},
|
Sources: cli.EnvVars("WOODPECKER_CUSTOM_CSS_FILE"),
|
||||||
Name: "custom-css-file",
|
Name: "custom-css-file",
|
||||||
Usage: "file path for the server to serve a custom .CSS file, used for customizing the UI",
|
Usage: "file path for the server to serve a custom .CSS file, used for customizing the UI",
|
||||||
},
|
},
|
||||||
&cli.StringFlag{
|
&cli.StringFlag{
|
||||||
EnvVars: []string{"WOODPECKER_CUSTOM_JS_FILE"},
|
Sources: cli.EnvVars("WOODPECKER_CUSTOM_JS_FILE"),
|
||||||
Name: "custom-js-file",
|
Name: "custom-js-file",
|
||||||
Usage: "file path for the server to serve a custom .JS file, used for customizing the UI",
|
Usage: "file path for the server to serve a custom .JS file, used for customizing the UI",
|
||||||
},
|
},
|
||||||
&cli.StringFlag{
|
&cli.StringFlag{
|
||||||
EnvVars: []string{"WOODPECKER_LETS_ENCRYPT_EMAIL"},
|
Sources: cli.EnvVars("WOODPECKER_LETS_ENCRYPT_EMAIL"),
|
||||||
Name: "lets-encrypt-email",
|
Name: "lets-encrypt-email",
|
||||||
Usage: "let's encrypt email",
|
Usage: "let's encrypt email",
|
||||||
},
|
},
|
||||||
&cli.BoolFlag{
|
&cli.BoolFlag{
|
||||||
EnvVars: []string{"WOODPECKER_LETS_ENCRYPT"},
|
Sources: cli.EnvVars("WOODPECKER_LETS_ENCRYPT"),
|
||||||
Name: "lets-encrypt",
|
Name: "lets-encrypt",
|
||||||
Usage: "enable let's encrypt",
|
Usage: "enable let's encrypt",
|
||||||
},
|
},
|
||||||
&cli.StringFlag{
|
&cli.StringFlag{
|
||||||
EnvVars: []string{"WOODPECKER_GRPC_ADDR"},
|
Sources: cli.EnvVars("WOODPECKER_GRPC_ADDR"),
|
||||||
Name: "grpc-addr",
|
Name: "grpc-addr",
|
||||||
Usage: "grpc address",
|
Usage: "grpc address",
|
||||||
Value: ":9000",
|
Value: ":9000",
|
||||||
},
|
},
|
||||||
&cli.StringFlag{
|
&cli.StringFlag{
|
||||||
EnvVars: []string{"WOODPECKER_GRPC_SECRET"},
|
Sources: cli.NewValueSourceChain(
|
||||||
|
cli.File(os.Getenv("WOODPECKER_GRPC_SECRET_FILE")),
|
||||||
|
cli.EnvVar("WOODPECKER_GRPC_SECRET")),
|
||||||
Name: "grpc-secret",
|
Name: "grpc-secret",
|
||||||
Usage: "grpc jwt secret",
|
Usage: "grpc jwt secret",
|
||||||
Value: "secret",
|
Value: "secret",
|
||||||
FilePath: os.Getenv("WOODPECKER_GRPC_SECRET_FILE"),
|
|
||||||
},
|
},
|
||||||
&cli.StringFlag{
|
&cli.StringFlag{
|
||||||
EnvVars: []string{"WOODPECKER_METRICS_SERVER_ADDR"},
|
Sources: cli.EnvVars("WOODPECKER_METRICS_SERVER_ADDR"),
|
||||||
Name: "metrics-server-addr",
|
Name: "metrics-server-addr",
|
||||||
Usage: "metrics server address",
|
Usage: "metrics server address",
|
||||||
Value: "",
|
Value: "",
|
||||||
},
|
},
|
||||||
&cli.StringSliceFlag{
|
&cli.StringSliceFlag{
|
||||||
EnvVars: []string{"WOODPECKER_ADMIN"},
|
Sources: cli.EnvVars("WOODPECKER_ADMIN"),
|
||||||
Name: "admin",
|
Name: "admin",
|
||||||
Usage: "list of admin users",
|
Usage: "list of admin users",
|
||||||
},
|
},
|
||||||
&cli.StringSliceFlag{
|
&cli.StringSliceFlag{
|
||||||
EnvVars: []string{"WOODPECKER_ORGS"},
|
Sources: cli.EnvVars("WOODPECKER_ORGS"),
|
||||||
Name: "orgs",
|
Name: "orgs",
|
||||||
Usage: "list of approved organizations",
|
Usage: "list of approved organizations",
|
||||||
},
|
},
|
||||||
&cli.StringSliceFlag{
|
&cli.StringSliceFlag{
|
||||||
EnvVars: []string{"WOODPECKER_REPO_OWNERS"},
|
Sources: cli.EnvVars("WOODPECKER_REPO_OWNERS"),
|
||||||
Name: "repo-owners",
|
Name: "repo-owners",
|
||||||
Usage: "Repositories by those owners will be allowed to be used in woodpecker",
|
Usage: "Repositories by those owners will be allowed to be used in woodpecker",
|
||||||
},
|
},
|
||||||
&cli.BoolFlag{
|
&cli.BoolFlag{
|
||||||
EnvVars: []string{"WOODPECKER_OPEN"},
|
Sources: cli.EnvVars("WOODPECKER_OPEN"),
|
||||||
Name: "open",
|
Name: "open",
|
||||||
Usage: "enable open user registration",
|
Usage: "enable open user registration",
|
||||||
},
|
},
|
||||||
&cli.BoolFlag{
|
&cli.BoolFlag{
|
||||||
EnvVars: []string{"WOODPECKER_AUTHENTICATE_PUBLIC_REPOS"},
|
Sources: cli.EnvVars("WOODPECKER_AUTHENTICATE_PUBLIC_REPOS"),
|
||||||
Name: "authenticate-public-repos",
|
Name: "authenticate-public-repos",
|
||||||
Usage: "Always use authentication to clone repositories even if they are public. Needed if the SCM requires to always authenticate as used by many companies.",
|
Usage: "Always use authentication to clone repositories even if they are public. Needed if the SCM requires to always authenticate as used by many companies.",
|
||||||
},
|
},
|
||||||
&cli.StringSliceFlag{
|
&cli.StringSliceFlag{
|
||||||
EnvVars: []string{"WOODPECKER_DEFAULT_CANCEL_PREVIOUS_PIPELINE_EVENTS"},
|
Sources: cli.EnvVars("WOODPECKER_DEFAULT_CANCEL_PREVIOUS_PIPELINE_EVENTS"),
|
||||||
Name: "default-cancel-previous-pipeline-events",
|
Name: "default-cancel-previous-pipeline-events",
|
||||||
Usage: "List of event names that will be canceled when a new pipeline for the same context (tag, branch) is created.",
|
Usage: "List of event names that will be canceled when a new pipeline for the same context (tag, branch) is created.",
|
||||||
Value: cli.NewStringSlice("push", "pull_request"),
|
Value: []string{"push", "pull_request"},
|
||||||
},
|
},
|
||||||
&cli.StringFlag{
|
&cli.StringFlag{
|
||||||
EnvVars: []string{"WOODPECKER_DEFAULT_CLONE_IMAGE"},
|
Sources: cli.EnvVars("WOODPECKER_DEFAULT_CLONE_IMAGE"),
|
||||||
Name: "default-clone-image",
|
Name: "default-clone-image",
|
||||||
Usage: "The default docker image to be used when cloning the repo",
|
Usage: "The default docker image to be used when cloning the repo",
|
||||||
Value: constant.DefaultCloneImage,
|
Value: constant.DefaultCloneImage,
|
||||||
},
|
},
|
||||||
&cli.Int64Flag{
|
&cli.IntFlag{
|
||||||
EnvVars: []string{"WOODPECKER_DEFAULT_PIPELINE_TIMEOUT"},
|
Sources: cli.EnvVars("WOODPECKER_DEFAULT_PIPELINE_TIMEOUT"),
|
||||||
Name: "default-pipeline-timeout",
|
Name: "default-pipeline-timeout",
|
||||||
Usage: "The default time in minutes for a repo in minutes before a pipeline gets killed",
|
Usage: "The default time in minutes for a repo in minutes before a pipeline gets killed",
|
||||||
Value: 60,
|
Value: 60,
|
||||||
},
|
},
|
||||||
&cli.Int64Flag{
|
&cli.IntFlag{
|
||||||
EnvVars: []string{"WOODPECKER_MAX_PIPELINE_TIMEOUT"},
|
Sources: cli.EnvVars("WOODPECKER_MAX_PIPELINE_TIMEOUT"),
|
||||||
Name: "max-pipeline-timeout",
|
Name: "max-pipeline-timeout",
|
||||||
Usage: "The maximum time in minutes you can set in the repo settings before a pipeline gets killed",
|
Usage: "The maximum time in minutes you can set in the repo settings before a pipeline gets killed",
|
||||||
Value: 120,
|
Value: 120,
|
||||||
},
|
},
|
||||||
&cli.DurationFlag{
|
&cli.DurationFlag{
|
||||||
EnvVars: []string{"WOODPECKER_SESSION_EXPIRES"},
|
Sources: cli.EnvVars("WOODPECKER_SESSION_EXPIRES"),
|
||||||
Name: "session-expires",
|
Name: "session-expires",
|
||||||
Usage: "session expiration time",
|
Usage: "session expiration time",
|
||||||
Value: time.Hour * 72,
|
Value: time.Hour * 72,
|
||||||
},
|
},
|
||||||
&cli.StringSliceFlag{
|
&cli.StringSliceFlag{
|
||||||
EnvVars: []string{"WOODPECKER_ESCALATE"},
|
Sources: cli.EnvVars("WOODPECKER_ESCALATE"),
|
||||||
Name: "escalate",
|
Name: "escalate",
|
||||||
Usage: "images to run in privileged mode",
|
Usage: "images to run in privileged mode",
|
||||||
Value: cli.NewStringSlice(constant.PrivilegedPlugins...),
|
Value: constant.PrivilegedPlugins,
|
||||||
},
|
},
|
||||||
&cli.StringSliceFlag{
|
&cli.StringSliceFlag{
|
||||||
EnvVars: []string{"WOODPECKER_VOLUME"},
|
Sources: cli.EnvVars("WOODPECKER_VOLUME"),
|
||||||
Name: "volume",
|
Name: "volume",
|
||||||
},
|
},
|
||||||
&cli.StringFlag{
|
&cli.StringFlag{
|
||||||
EnvVars: []string{"WOODPECKER_DOCKER_CONFIG"},
|
Sources: cli.EnvVars("WOODPECKER_DOCKER_CONFIG"),
|
||||||
Name: "docker-config",
|
Name: "docker-config",
|
||||||
},
|
},
|
||||||
&cli.StringSliceFlag{
|
&cli.StringSliceFlag{
|
||||||
EnvVars: []string{"WOODPECKER_ENVIRONMENT"},
|
Sources: cli.EnvVars("WOODPECKER_ENVIRONMENT"),
|
||||||
Name: "environment",
|
Name: "environment",
|
||||||
},
|
},
|
||||||
&cli.StringSliceFlag{
|
&cli.StringSliceFlag{
|
||||||
EnvVars: []string{"WOODPECKER_NETWORK"},
|
Sources: cli.EnvVars("WOODPECKER_NETWORK"),
|
||||||
Name: "network",
|
Name: "network",
|
||||||
},
|
},
|
||||||
&cli.StringFlag{
|
&cli.StringFlag{
|
||||||
EnvVars: []string{"WOODPECKER_AGENT_SECRET"},
|
Sources: cli.NewValueSourceChain(
|
||||||
|
cli.File(os.Getenv("WOODPECKER_AGENT_SECRET_FILE")),
|
||||||
|
cli.EnvVar("WOODPECKER_AGENT_SECRET")),
|
||||||
Name: "agent-secret",
|
Name: "agent-secret",
|
||||||
Usage: "server-agent shared password",
|
Usage: "server-agent shared password",
|
||||||
FilePath: os.Getenv("WOODPECKER_AGENT_SECRET_FILE"),
|
|
||||||
},
|
},
|
||||||
&cli.DurationFlag{
|
&cli.DurationFlag{
|
||||||
EnvVars: []string{"WOODPECKER_KEEPALIVE_MIN_TIME"},
|
Sources: cli.EnvVars("WOODPECKER_KEEPALIVE_MIN_TIME"),
|
||||||
Name: "keepalive-min-time",
|
Name: "keepalive-min-time",
|
||||||
Usage: "server-side enforcement policy on the minimum amount of time a client should wait before sending a keepalive ping.",
|
Usage: "server-side enforcement policy on the minimum amount of time a client should wait before sending a keepalive ping.",
|
||||||
},
|
},
|
||||||
&cli.StringFlag{
|
&cli.StringFlag{
|
||||||
EnvVars: []string{"WOODPECKER_CONFIG_SERVICE_ENDPOINT"},
|
Sources: cli.EnvVars("WOODPECKER_CONFIG_SERVICE_ENDPOINT"),
|
||||||
Name: "config-service-endpoint",
|
Name: "config-service-endpoint",
|
||||||
Usage: "url used for calling configuration service endpoint",
|
Usage: "url used for calling configuration service endpoint",
|
||||||
},
|
},
|
||||||
&cli.StringFlag{
|
&cli.StringFlag{
|
||||||
EnvVars: []string{"WOODPECKER_DATABASE_DRIVER"},
|
Sources: cli.EnvVars("WOODPECKER_DATABASE_DRIVER"),
|
||||||
Name: "driver",
|
Name: "driver",
|
||||||
Usage: "database driver",
|
Usage: "database driver",
|
||||||
Value: "sqlite3",
|
Value: "sqlite3",
|
||||||
},
|
},
|
||||||
&cli.StringFlag{
|
&cli.StringFlag{
|
||||||
EnvVars: []string{"WOODPECKER_DATABASE_DATASOURCE"},
|
Sources: cli.NewValueSourceChain(
|
||||||
|
cli.File(os.Getenv("WOODPECKER_DATABASE_DATASOURCE_FILE")),
|
||||||
|
cli.EnvVar("WOODPECKER_DATABASE_DATASOURCE")),
|
||||||
Name: "datasource",
|
Name: "datasource",
|
||||||
Usage: "database driver configuration string",
|
Usage: "database driver configuration string",
|
||||||
Value: datasourceDefaultValue(),
|
Value: datasourceDefaultValue(),
|
||||||
FilePath: os.Getenv("WOODPECKER_DATABASE_DATASOURCE_FILE"),
|
|
||||||
},
|
},
|
||||||
&cli.StringFlag{
|
&cli.StringFlag{
|
||||||
EnvVars: []string{"WOODPECKER_PROMETHEUS_AUTH_TOKEN"},
|
Sources: cli.NewValueSourceChain(
|
||||||
|
cli.File(os.Getenv("WOODPECKER_PROMETHEUS_AUTH_TOKEN_FILE")),
|
||||||
|
cli.EnvVar("WOODPECKER_PROMETHEUS_AUTH_TOKEN")),
|
||||||
Name: "prometheus-auth-token",
|
Name: "prometheus-auth-token",
|
||||||
Usage: "token to secure prometheus metrics endpoint",
|
Usage: "token to secure prometheus metrics endpoint",
|
||||||
Value: "",
|
|
||||||
FilePath: os.Getenv("WOODPECKER_PROMETHEUS_AUTH_TOKEN_FILE"),
|
|
||||||
},
|
},
|
||||||
&cli.StringFlag{
|
&cli.StringFlag{
|
||||||
EnvVars: []string{"WOODPECKER_STATUS_CONTEXT", "WOODPECKER_GITHUB_CONTEXT", "WOODPECKER_GITEA_CONTEXT"},
|
Sources: cli.EnvVars("WOODPECKER_STATUS_CONTEXT", "WOODPECKER_GITHUB_CONTEXT", "WOODPECKER_GITEA_CONTEXT"),
|
||||||
Name: "status-context",
|
Name: "status-context",
|
||||||
Usage: "status context prefix",
|
Usage: "status context prefix",
|
||||||
Value: "ci/woodpecker",
|
Value: "ci/woodpecker",
|
||||||
},
|
},
|
||||||
&cli.StringFlag{
|
&cli.StringFlag{
|
||||||
EnvVars: []string{"WOODPECKER_STATUS_CONTEXT_FORMAT"},
|
Sources: cli.EnvVars("WOODPECKER_STATUS_CONTEXT_FORMAT"),
|
||||||
Name: "status-context-format",
|
Name: "status-context-format",
|
||||||
Usage: "status context format",
|
Usage: "status context format",
|
||||||
Value: "{{ .context }}/{{ .event }}/{{ .workflow }}{{if not (eq .axis_id 0)}}/{{.axis_id}}{{end}}",
|
Value: "{{ .context }}/{{ .event }}/{{ .workflow }}{{if not (eq .axis_id 0)}}/{{.axis_id}}{{end}}",
|
||||||
},
|
},
|
||||||
&cli.BoolFlag{
|
&cli.BoolFlag{
|
||||||
EnvVars: []string{"WOODPECKER_MIGRATIONS_ALLOW_LONG"},
|
Sources: cli.EnvVars("WOODPECKER_MIGRATIONS_ALLOW_LONG"),
|
||||||
Name: "migrations-allow-long",
|
Name: "migrations-allow-long",
|
||||||
Value: false,
|
Value: false,
|
||||||
},
|
},
|
||||||
&cli.BoolFlag{
|
&cli.BoolFlag{
|
||||||
EnvVars: []string{"WOODPECKER_ENABLE_SWAGGER"},
|
Sources: cli.EnvVars("WOODPECKER_ENABLE_SWAGGER"),
|
||||||
Name: "enable-swagger",
|
Name: "enable-swagger",
|
||||||
Value: true,
|
Value: true,
|
||||||
},
|
},
|
||||||
&cli.BoolFlag{
|
&cli.BoolFlag{
|
||||||
EnvVars: []string{"WOODPECKER_DISABLE_VERSION_CHECK"},
|
Sources: cli.EnvVars("WOODPECKER_DISABLE_VERSION_CHECK"),
|
||||||
Usage: "Disable version check in admin web ui.",
|
Usage: "Disable version check in admin web ui.",
|
||||||
Name: "skip-version-check",
|
Name: "skip-version-check",
|
||||||
},
|
},
|
||||||
&cli.StringFlag{
|
&cli.StringFlag{
|
||||||
EnvVars: []string{"WOODPECKER_LOG_STORE"},
|
Sources: cli.EnvVars("WOODPECKER_LOG_STORE"),
|
||||||
Name: "log-store",
|
Name: "log-store",
|
||||||
Usage: "log store to use ('database' or 'file')",
|
Usage: "log store to use ('database' or 'file')",
|
||||||
Value: "database",
|
Value: "database",
|
||||||
},
|
},
|
||||||
&cli.StringFlag{
|
&cli.StringFlag{
|
||||||
EnvVars: []string{"WOODPECKER_LOG_STORE_FILE_PATH"},
|
Sources: cli.EnvVars("WOODPECKER_LOG_STORE_FILE_PATH"),
|
||||||
Name: "log-store-file-path",
|
Name: "log-store-file-path",
|
||||||
Usage: "directory used for file based log storage",
|
Usage: "directory used for file based log storage",
|
||||||
},
|
},
|
||||||
@ -256,17 +260,17 @@ var flags = append([]cli.Flag{
|
|||||||
// backend options for pipeline compiler
|
// backend options for pipeline compiler
|
||||||
//
|
//
|
||||||
&cli.StringFlag{
|
&cli.StringFlag{
|
||||||
EnvVars: []string{"WOODPECKER_BACKEND_NO_PROXY", "NO_PROXY", "no_proxy"},
|
Sources: cli.EnvVars("WOODPECKER_BACKEND_NO_PROXY", "NO_PROXY", "no_proxy"),
|
||||||
Usage: "if set, pass the environment variable down as \"NO_PROXY\" to steps",
|
Usage: "if set, pass the environment variable down as \"NO_PROXY\" to steps",
|
||||||
Name: "backend-no-proxy",
|
Name: "backend-no-proxy",
|
||||||
},
|
},
|
||||||
&cli.StringFlag{
|
&cli.StringFlag{
|
||||||
EnvVars: []string{"WOODPECKER_BACKEND_HTTP_PROXY", "HTTP_PROXY", "http_proxy"},
|
Sources: cli.EnvVars("WOODPECKER_BACKEND_HTTP_PROXY", "HTTP_PROXY", "http_proxy"),
|
||||||
Usage: "if set, pass the environment variable down as \"HTTP_PROXY\" to steps",
|
Usage: "if set, pass the environment variable down as \"HTTP_PROXY\" to steps",
|
||||||
Name: "backend-http-proxy",
|
Name: "backend-http-proxy",
|
||||||
},
|
},
|
||||||
&cli.StringFlag{
|
&cli.StringFlag{
|
||||||
EnvVars: []string{"WOODPECKER_BACKEND_HTTPS_PROXY", "HTTPS_PROXY", "https_proxy"},
|
Sources: cli.EnvVars("WOODPECKER_BACKEND_HTTPS_PROXY", "HTTPS_PROXY", "https_proxy"),
|
||||||
Usage: "if set, pass the environment variable down as \"HTTPS_PROXY\" to steps",
|
Usage: "if set, pass the environment variable down as \"HTTPS_PROXY\" to steps",
|
||||||
Name: "backend-https-proxy",
|
Name: "backend-https-proxy",
|
||||||
},
|
},
|
||||||
@ -274,44 +278,44 @@ var flags = append([]cli.Flag{
|
|||||||
// resource limit parameters
|
// resource limit parameters
|
||||||
//
|
//
|
||||||
&cli.DurationFlag{
|
&cli.DurationFlag{
|
||||||
EnvVars: []string{"WOODPECKER_FORGE_TIMEOUT"},
|
Sources: cli.EnvVars("WOODPECKER_FORGE_TIMEOUT"),
|
||||||
Name: "forge-timeout",
|
Name: "forge-timeout",
|
||||||
Usage: "how many seconds before timeout when fetching the Woodpecker configuration from a Forge",
|
Usage: "how many seconds before timeout when fetching the Woodpecker configuration from a Forge",
|
||||||
Value: time.Second * 3,
|
Value: time.Second * 3,
|
||||||
},
|
},
|
||||||
&cli.UintFlag{
|
&cli.UintFlag{
|
||||||
EnvVars: []string{"WOODPECKER_FORGE_RETRY"},
|
Sources: cli.EnvVars("WOODPECKER_FORGE_RETRY"),
|
||||||
Name: "forge-retry",
|
Name: "forge-retry",
|
||||||
Usage: "How many retries of fetching the Woodpecker configuration from a forge are done before we fail",
|
Usage: "How many retries of fetching the Woodpecker configuration from a forge are done before we fail",
|
||||||
Value: 3,
|
Value: 3,
|
||||||
},
|
},
|
||||||
&cli.Int64Flag{
|
&cli.IntFlag{
|
||||||
EnvVars: []string{"WOODPECKER_LIMIT_MEM_SWAP"},
|
Sources: cli.EnvVars("WOODPECKER_LIMIT_MEM_SWAP"),
|
||||||
Name: "limit-mem-swap",
|
Name: "limit-mem-swap",
|
||||||
Usage: "maximum memory used for swap in bytes",
|
Usage: "maximum memory used for swap in bytes",
|
||||||
},
|
},
|
||||||
&cli.Int64Flag{
|
&cli.IntFlag{
|
||||||
EnvVars: []string{"WOODPECKER_LIMIT_MEM"},
|
Sources: cli.EnvVars("WOODPECKER_LIMIT_MEM"),
|
||||||
Name: "limit-mem",
|
Name: "limit-mem",
|
||||||
Usage: "maximum memory allowed in bytes",
|
Usage: "maximum memory allowed in bytes",
|
||||||
},
|
},
|
||||||
&cli.Int64Flag{
|
&cli.IntFlag{
|
||||||
EnvVars: []string{"WOODPECKER_LIMIT_SHM_SIZE"},
|
Sources: cli.EnvVars("WOODPECKER_LIMIT_SHM_SIZE"),
|
||||||
Name: "limit-shm-size",
|
Name: "limit-shm-size",
|
||||||
Usage: "docker compose /dev/shm allowed in bytes",
|
Usage: "docker compose /dev/shm allowed in bytes",
|
||||||
},
|
},
|
||||||
&cli.Int64Flag{
|
&cli.IntFlag{
|
||||||
EnvVars: []string{"WOODPECKER_LIMIT_CPU_QUOTA"},
|
Sources: cli.EnvVars("WOODPECKER_LIMIT_CPU_QUOTA"),
|
||||||
Name: "limit-cpu-quota",
|
Name: "limit-cpu-quota",
|
||||||
Usage: "impose a cpu quota",
|
Usage: "impose a cpu quota",
|
||||||
},
|
},
|
||||||
&cli.Int64Flag{
|
&cli.IntFlag{
|
||||||
EnvVars: []string{"WOODPECKER_LIMIT_CPU_SHARES"},
|
Sources: cli.EnvVars("WOODPECKER_LIMIT_CPU_SHARES"),
|
||||||
Name: "limit-cpu-shares",
|
Name: "limit-cpu-shares",
|
||||||
Usage: "change the cpu shares",
|
Usage: "change the cpu shares",
|
||||||
},
|
},
|
||||||
&cli.StringFlag{
|
&cli.StringFlag{
|
||||||
EnvVars: []string{"WOODPECKER_LIMIT_CPU_SET"},
|
Sources: cli.EnvVars("WOODPECKER_LIMIT_CPU_SET"),
|
||||||
Name: "limit-cpu-set",
|
Name: "limit-cpu-set",
|
||||||
Usage: "set the cpus allowed to execute containers",
|
Usage: "set the cpus allowed to execute containers",
|
||||||
},
|
},
|
||||||
@ -319,27 +323,62 @@ var flags = append([]cli.Flag{
|
|||||||
&cli.StringFlag{
|
&cli.StringFlag{
|
||||||
Name: "forge-url",
|
Name: "forge-url",
|
||||||
Usage: "url of the forge",
|
Usage: "url of the forge",
|
||||||
EnvVars: []string{"WOODPECKER_FORGE_URL", "WOODPECKER_GITHUB_URL", "WOODPECKER_GITLAB_URL", "WOODPECKER_GITEA_URL", "WOODPECKER_FORGEJO_URL", "WOODPECKER_BITBUCKET_URL", "WOODPECKER_BITBUCKET_DC_URL"},
|
Sources: cli.EnvVars("WOODPECKER_FORGE_URL", "WOODPECKER_GITHUB_URL", "WOODPECKER_GITLAB_URL", "WOODPECKER_GITEA_URL", "WOODPECKER_FORGEJO_URL", "WOODPECKER_BITBUCKET_URL", "WOODPECKER_BITBUCKET_DC_URL"),
|
||||||
},
|
},
|
||||||
&cli.StringFlag{
|
&cli.StringFlag{
|
||||||
|
Sources: cli.NewValueSourceChain(
|
||||||
|
cli.File(getFirstNonEmptyEnvVar(
|
||||||
|
"WOODPECKER_FORGE_CLIENT_FILE",
|
||||||
|
"WOODPECKER_GITHUB_CLIENT_FILE",
|
||||||
|
"WOODPECKER_GITLAB_CLIENT_FILE",
|
||||||
|
"WOODPECKER_GITEA_CLIENT_FILE",
|
||||||
|
"WOODPECKER_FORGEJO_CLIENT_FILE",
|
||||||
|
"WOODPECKER_BITBUCKET_CLIENT_FILE",
|
||||||
|
"WOODPECKER_BITBUCKET_DC_CLIENT_ID_FILE")),
|
||||||
|
cli.EnvVar("WOODPECKER_FORGE_CLIENT"),
|
||||||
|
cli.EnvVar("WOODPECKER_GITHUB_CLIENT"),
|
||||||
|
cli.EnvVar("WOODPECKER_GITLAB_CLIENT"),
|
||||||
|
cli.EnvVar("WOODPECKER_GITEA_CLIENT"),
|
||||||
|
cli.EnvVar("WOODPECKER_FORGEJO_CLIENT"),
|
||||||
|
cli.EnvVar("WOODPECKER_BITBUCKET_CLIENT"),
|
||||||
|
cli.EnvVar("WOODPECKER_BITBUCKET_DC_CLIENT_ID")),
|
||||||
Name: "forge-oauth-client",
|
Name: "forge-oauth-client",
|
||||||
Usage: "oauth2 client id",
|
Usage: "oauth2 client id",
|
||||||
EnvVars: []string{"WOODPECKER_FORGE_CLIENT", "WOODPECKER_GITHUB_CLIENT", "WOODPECKER_GITLAB_CLIENT", "WOODPECKER_GITEA_CLIENT", "WOODPECKER_FORGEJO_CLIENT", "WOODPECKER_BITBUCKET_CLIENT", "WOODPECKER_BITBUCKET_DC_CLIENT_ID"},
|
|
||||||
FilePath: getFirstNonEmptyEnvVar([]string{"WOODPECKER_FORGE_CLIENT_FILE", "WOODPECKER_GITHUB_CLIENT_FILE", "WOODPECKER_GITLAB_CLIENT_FILE", "WOODPECKER_GITEA_CLIENT_FILE", "WOODPECKER_FORGEJO_CLIENT_FILE", "WOODPECKER_BITBUCKET_CLIENT_FILE", "WOODPECKER_BITBUCKET_DC_CLIENT_ID_FILE"}),
|
|
||||||
},
|
},
|
||||||
&cli.StringFlag{
|
&cli.StringFlag{
|
||||||
|
Sources: cli.NewValueSourceChain(
|
||||||
|
cli.File(getFirstNonEmptyEnvVar(
|
||||||
|
"WOODPECKER_FORGE_SECRET_FILE",
|
||||||
|
"WOODPECKER_GITHUB_SECRET_FILE",
|
||||||
|
"WOODPECKER_GITLAB_SECRET_FILE",
|
||||||
|
"WOODPECKER_GITEA_SECRET_FILE",
|
||||||
|
"WOODPECKER_FORGEJO_SECRET_FILE",
|
||||||
|
"WOODPECKER_BITBUCKET_SECRET_FILE",
|
||||||
|
"WOODPECKER_BITBUCKET_DC_CLIENT_SECRET_FILE",
|
||||||
|
)),
|
||||||
|
cli.EnvVar("WOODPECKER_FORGE_SECRET"),
|
||||||
|
cli.EnvVar("WOODPECKER_GITHUB_SECRET"),
|
||||||
|
cli.EnvVar("WOODPECKER_GITLAB_SECRET"),
|
||||||
|
cli.EnvVar("WOODPECKER_GITEA_SECRET"),
|
||||||
|
cli.EnvVar("WOODPECKER_FORGEJO_SECRET"),
|
||||||
|
cli.EnvVar("WOODPECKER_BITBUCKET_SECRET"),
|
||||||
|
cli.EnvVar("WOODPECKER_BITBUCKET_DC_CLIENT_SECRET")),
|
||||||
Name: "forge-oauth-secret",
|
Name: "forge-oauth-secret",
|
||||||
Usage: "oauth2 client secret",
|
Usage: "oauth2 client secret",
|
||||||
EnvVars: []string{"WOODPECKER_FORGE_SECRET", "WOODPECKER_GITHUB_SECRET", "WOODPECKER_GITLAB_SECRET", "WOODPECKER_GITEA_SECRET", "WOODPECKER_FORGEJO_SECRET", "WOODPECKER_BITBUCKET_SECRET", "WOODPECKER_BITBUCKET_DC_CLIENT_SECRET"},
|
|
||||||
FilePath: getFirstNonEmptyEnvVar([]string{"WOODPECKER_FORGE_SECRET_FILE", "WOODPECKER_GITHUB_SECRET_FILE", "WOODPECKER_GITLAB_SECRET_FILE", "WOODPECKER_GITEA_SECRET_FILE", "WOODPECKER_FORGEJO_SECRET_FILE", "WOODPECKER_BITBUCKET_SECRET_FILE", "WOODPECKER_BITBUCKET_DC_CLIENT_SECRET_FILE"}),
|
|
||||||
},
|
},
|
||||||
&cli.BoolFlag{
|
&cli.BoolFlag{
|
||||||
Name: "forge-skip-verify",
|
Name: "forge-skip-verify",
|
||||||
Usage: "skip ssl verification",
|
Usage: "skip ssl verification",
|
||||||
EnvVars: []string{"WOODPECKER_FORGE_SKIP_VERIFY", "WOODPECKER_GITHUB_SKIP_VERIFY", "WOODPECKER_GITLAB_SKIP_VERIFY", "WOODPECKER_GITEA_SKIP_VERIFY", "WOODPECKER_FORGEJO_SKIP_VERIFY", "WOODPECKER_BITBUCKET_SKIP_VERIFY"},
|
Sources: cli.EnvVars(
|
||||||
|
"WOODPECKER_FORGE_SKIP_VERIFY",
|
||||||
|
"WOODPECKER_GITHUB_SKIP_VERIFY",
|
||||||
|
"WOODPECKER_GITLAB_SKIP_VERIFY",
|
||||||
|
"WOODPECKER_GITEA_SKIP_VERIFY",
|
||||||
|
"WOODPECKER_FORGEJO_SKIP_VERIFY",
|
||||||
|
"WOODPECKER_BITBUCKET_SKIP_VERIFY"),
|
||||||
},
|
},
|
||||||
&cli.StringFlag{
|
&cli.StringFlag{
|
||||||
EnvVars: []string{"WOODPECKER_EXPERT_FORGE_OAUTH_HOST", "WOODPECKER_DEV_GITEA_OAUTH_URL"}, // TODO: remove WOODPECKER_DEV_GITEA_OAUTH_URL in next major release
|
Sources: cli.EnvVars("WOODPECKER_EXPERT_FORGE_OAUTH_HOST", "WOODPECKER_DEV_GITEA_OAUTH_URL"), // TODO: remove WOODPECKER_DEV_GITEA_OAUTH_URL in next major release
|
||||||
Name: "forge-oauth-host",
|
Name: "forge-oauth-host",
|
||||||
Usage: "!!!for experts!!! fully qualified public forge url. Use it if your forge url WOODPECKER_FORGE_URL or WOODPECKER_GITEA_URL, ... isn't a public url. Format: <scheme>://<host>[/<prefix path>]",
|
Usage: "!!!for experts!!! fully qualified public forge url. Use it if your forge url WOODPECKER_FORGE_URL or WOODPECKER_GITEA_URL, ... isn't a public url. Format: <scheme>://<host>[/<prefix path>]",
|
||||||
},
|
},
|
||||||
@ -347,7 +386,7 @@ var flags = append([]cli.Flag{
|
|||||||
// Addon
|
// Addon
|
||||||
//
|
//
|
||||||
&cli.StringFlag{
|
&cli.StringFlag{
|
||||||
EnvVars: []string{"WOODPECKER_ADDON_FORGE"},
|
Sources: cli.EnvVars("WOODPECKER_ADDON_FORGE"),
|
||||||
Name: "addon-forge",
|
Name: "addon-forge",
|
||||||
Usage: "path to forge addon executable",
|
Usage: "path to forge addon executable",
|
||||||
},
|
},
|
||||||
@ -355,18 +394,18 @@ var flags = append([]cli.Flag{
|
|||||||
// GitHub
|
// GitHub
|
||||||
//
|
//
|
||||||
&cli.BoolFlag{
|
&cli.BoolFlag{
|
||||||
EnvVars: []string{"WOODPECKER_GITHUB"},
|
Sources: cli.EnvVars("WOODPECKER_GITHUB"),
|
||||||
Name: "github",
|
Name: "github",
|
||||||
Usage: "github driver is enabled",
|
Usage: "github driver is enabled",
|
||||||
},
|
},
|
||||||
&cli.BoolFlag{
|
&cli.BoolFlag{
|
||||||
EnvVars: []string{"WOODPECKER_GITHUB_MERGE_REF"},
|
Sources: cli.EnvVars("WOODPECKER_GITHUB_MERGE_REF"),
|
||||||
Name: "github-merge-ref",
|
Name: "github-merge-ref",
|
||||||
Usage: "github pull requests use merge ref",
|
Usage: "github pull requests use merge ref",
|
||||||
Value: true,
|
Value: true,
|
||||||
},
|
},
|
||||||
&cli.BoolFlag{
|
&cli.BoolFlag{
|
||||||
EnvVars: []string{"WOODPECKER_GITHUB_PUBLIC_ONLY"},
|
Sources: cli.EnvVars("WOODPECKER_GITHUB_PUBLIC_ONLY"),
|
||||||
Name: "github-public-only",
|
Name: "github-public-only",
|
||||||
Usage: "github tokens should only get access to public repos",
|
Usage: "github tokens should only get access to public repos",
|
||||||
Value: false,
|
Value: false,
|
||||||
@ -375,7 +414,7 @@ var flags = append([]cli.Flag{
|
|||||||
// Gitea
|
// Gitea
|
||||||
//
|
//
|
||||||
&cli.BoolFlag{
|
&cli.BoolFlag{
|
||||||
EnvVars: []string{"WOODPECKER_GITEA"},
|
Sources: cli.EnvVars("WOODPECKER_GITEA"),
|
||||||
Name: "gitea",
|
Name: "gitea",
|
||||||
Usage: "gitea driver is enabled",
|
Usage: "gitea driver is enabled",
|
||||||
},
|
},
|
||||||
@ -383,7 +422,7 @@ var flags = append([]cli.Flag{
|
|||||||
// Forgejo
|
// Forgejo
|
||||||
//
|
//
|
||||||
&cli.BoolFlag{
|
&cli.BoolFlag{
|
||||||
EnvVars: []string{"WOODPECKER_FORGEJO"},
|
Sources: cli.EnvVars("WOODPECKER_FORGEJO"),
|
||||||
Name: "forgejo",
|
Name: "forgejo",
|
||||||
Usage: "forgejo driver is enabled",
|
Usage: "forgejo driver is enabled",
|
||||||
},
|
},
|
||||||
@ -391,7 +430,7 @@ var flags = append([]cli.Flag{
|
|||||||
// Bitbucket
|
// Bitbucket
|
||||||
//
|
//
|
||||||
&cli.BoolFlag{
|
&cli.BoolFlag{
|
||||||
EnvVars: []string{"WOODPECKER_BITBUCKET"},
|
Sources: cli.EnvVars("WOODPECKER_BITBUCKET"),
|
||||||
Name: "bitbucket",
|
Name: "bitbucket",
|
||||||
Usage: "bitbucket driver is enabled",
|
Usage: "bitbucket driver is enabled",
|
||||||
},
|
},
|
||||||
@ -399,7 +438,7 @@ var flags = append([]cli.Flag{
|
|||||||
// Gitlab
|
// Gitlab
|
||||||
//
|
//
|
||||||
&cli.BoolFlag{
|
&cli.BoolFlag{
|
||||||
EnvVars: []string{"WOODPECKER_GITLAB"},
|
Sources: cli.EnvVars("WOODPECKER_GITLAB"),
|
||||||
Name: "gitlab",
|
Name: "gitlab",
|
||||||
Usage: "gitlab driver is enabled",
|
Usage: "gitlab driver is enabled",
|
||||||
},
|
},
|
||||||
@ -407,27 +446,29 @@ var flags = append([]cli.Flag{
|
|||||||
// Bitbucket DataCenter/Server (previously Stash)
|
// Bitbucket DataCenter/Server (previously Stash)
|
||||||
//
|
//
|
||||||
&cli.BoolFlag{
|
&cli.BoolFlag{
|
||||||
EnvVars: []string{"WOODPECKER_BITBUCKET_DC"},
|
Sources: cli.EnvVars("WOODPECKER_BITBUCKET_DC"),
|
||||||
Name: "bitbucket-dc",
|
Name: "bitbucket-dc",
|
||||||
Usage: "Bitbucket DataCenter/Server driver is enabled",
|
Usage: "Bitbucket DataCenter/Server driver is enabled",
|
||||||
},
|
},
|
||||||
&cli.StringFlag{
|
&cli.StringFlag{
|
||||||
EnvVars: []string{"WOODPECKER_BITBUCKET_DC_GIT_USERNAME"},
|
Sources: cli.NewValueSourceChain(
|
||||||
|
cli.File(os.Getenv("WOODPECKER_BITBUCKET_DC_GIT_USERNAME_FILE")),
|
||||||
|
cli.EnvVar("WOODPECKER_BITBUCKET_DC_GIT_USERNAME")),
|
||||||
Name: "bitbucket-dc-git-username",
|
Name: "bitbucket-dc-git-username",
|
||||||
Usage: "Bitbucket DataCenter/Server service account username",
|
Usage: "Bitbucket DataCenter/Server service account username",
|
||||||
FilePath: os.Getenv("WOODPECKER_BITBUCKET_DC_GIT_USERNAME_FILE"),
|
|
||||||
},
|
},
|
||||||
&cli.StringFlag{
|
&cli.StringFlag{
|
||||||
EnvVars: []string{"WOODPECKER_BITBUCKET_DC_GIT_PASSWORD"},
|
Sources: cli.NewValueSourceChain(
|
||||||
|
cli.File(os.Getenv("WOODPECKER_BITBUCKET_DC_GIT_PASSWORD_FILE")),
|
||||||
|
cli.EnvVar("WOODPECKER_BITBUCKET_DC_GIT_PASSWORD")),
|
||||||
Name: "bitbucket-dc-git-password",
|
Name: "bitbucket-dc-git-password",
|
||||||
Usage: "Bitbucket DataCenter/Server service account password",
|
Usage: "Bitbucket DataCenter/Server service account password",
|
||||||
FilePath: os.Getenv("WOODPECKER_BITBUCKET_DC_GIT_PASSWORD_FILE"),
|
|
||||||
},
|
},
|
||||||
//
|
//
|
||||||
// development flags
|
// development flags
|
||||||
//
|
//
|
||||||
&cli.StringFlag{
|
&cli.StringFlag{
|
||||||
EnvVars: []string{"WOODPECKER_DEV_WWW_PROXY"},
|
Sources: cli.EnvVars("WOODPECKER_DEV_WWW_PROXY"),
|
||||||
Name: "www-proxy",
|
Name: "www-proxy",
|
||||||
Usage: "serve the website by using a proxy (used for development)",
|
Usage: "serve the website by using a proxy (used for development)",
|
||||||
Hidden: true,
|
Hidden: true,
|
||||||
@ -436,13 +477,13 @@ var flags = append([]cli.Flag{
|
|||||||
// expert flags
|
// expert flags
|
||||||
//
|
//
|
||||||
&cli.StringFlag{
|
&cli.StringFlag{
|
||||||
EnvVars: []string{"WOODPECKER_EXPERT_WEBHOOK_HOST", "WOODPECKER_WEBHOOK_HOST"}, // TODO: remove WOODPECKER_WEBHOOK_HOST in next major release
|
Sources: cli.EnvVars("WOODPECKER_EXPERT_WEBHOOK_HOST", "WOODPECKER_WEBHOOK_HOST"), // TODO: remove WOODPECKER_WEBHOOK_HOST in next major release
|
||||||
Name: "server-webhook-host",
|
Name: "server-webhook-host",
|
||||||
Usage: "!!!for experts!!! fully qualified woodpecker server url called by forge's webhooks. Format: <scheme>://<host>[/<prefix path>]",
|
Usage: "!!!for experts!!! fully qualified woodpecker server url called by forge's webhooks. Format: <scheme>://<host>[/<prefix path>]",
|
||||||
},
|
},
|
||||||
// TODO: remove in next major release
|
// TODO: remove in next major release
|
||||||
&cli.StringFlag{
|
&cli.StringFlag{
|
||||||
EnvVars: []string{"WOODPECKER_DEV_OAUTH_HOST"},
|
Sources: cli.EnvVars("WOODPECKER_DEV_OAUTH_HOST"),
|
||||||
Name: "server-dev-oauth-host-deprecated",
|
Name: "server-dev-oauth-host-deprecated",
|
||||||
Usage: "DEPRECATED: use WOODPECKER_EXPERT_FORGE_OAUTH_HOST instead\nfully qualified url used for oauth redirects. Format: <scheme>://<host>[/<prefix path>]",
|
Usage: "DEPRECATED: use WOODPECKER_EXPERT_FORGE_OAUTH_HOST instead\nfully qualified url used for oauth redirects. Format: <scheme>://<host>[/<prefix path>]",
|
||||||
Value: "",
|
Value: "",
|
||||||
@ -452,18 +493,19 @@ var flags = append([]cli.Flag{
|
|||||||
// secrets encryption in DB
|
// secrets encryption in DB
|
||||||
//
|
//
|
||||||
&cli.StringFlag{
|
&cli.StringFlag{
|
||||||
EnvVars: []string{"WOODPECKER_ENCRYPTION_KEY"},
|
Sources: cli.NewValueSourceChain(
|
||||||
|
cli.File(os.Getenv("WOODPECKER_ENCRYPTION_KEY_FILE")),
|
||||||
|
cli.EnvVar("WOODPECKER_ENCRYPTION_KEY")),
|
||||||
Name: "encryption-raw-key",
|
Name: "encryption-raw-key",
|
||||||
Usage: "Raw encryption key",
|
Usage: "Raw encryption key",
|
||||||
FilePath: os.Getenv("WOODPECKER_ENCRYPTION_KEY_FILE"),
|
|
||||||
},
|
},
|
||||||
&cli.StringFlag{
|
&cli.StringFlag{
|
||||||
EnvVars: []string{"WOODPECKER_ENCRYPTION_TINK_KEYSET_FILE"},
|
Sources: cli.EnvVars("WOODPECKER_ENCRYPTION_TINK_KEYSET_FILE"),
|
||||||
Name: "encryption-tink-keyset",
|
Name: "encryption-tink-keyset",
|
||||||
Usage: "Google tink AEAD-compatible keyset file to encrypt secrets in DB",
|
Usage: "Google tink AEAD-compatible keyset file to encrypt secrets in DB",
|
||||||
},
|
},
|
||||||
&cli.BoolFlag{
|
&cli.BoolFlag{
|
||||||
EnvVars: []string{"WOODPECKER_ENCRYPTION_DISABLE"},
|
Sources: cli.EnvVars("WOODPECKER_ENCRYPTION_DISABLE"),
|
||||||
Name: "encryption-disable-flag",
|
Name: "encryption-disable-flag",
|
||||||
Usage: "Flag to decrypt all encrypted data and disable encryption on server",
|
Usage: "Flag to decrypt all encrypted data and disable encryption on server",
|
||||||
},
|
},
|
||||||
@ -479,7 +521,7 @@ func datasourceDefaultValue() string {
|
|||||||
return "woodpecker.sqlite"
|
return "woodpecker.sqlite"
|
||||||
}
|
}
|
||||||
|
|
||||||
func getFirstNonEmptyEnvVar(envVars []string) string {
|
func getFirstNonEmptyEnvVar(envVars ...string) string {
|
||||||
for _, envVar := range envVars {
|
for _, envVar := range envVars {
|
||||||
val := os.Getenv(envVar)
|
val := os.Getenv(envVar)
|
||||||
if val != "" {
|
if val != "" {
|
||||||
|
@ -20,7 +20,7 @@ import (
|
|||||||
"net"
|
"net"
|
||||||
|
|
||||||
"github.com/rs/zerolog/log"
|
"github.com/rs/zerolog/log"
|
||||||
"github.com/urfave/cli/v2"
|
"github.com/urfave/cli/v3"
|
||||||
"google.golang.org/grpc"
|
"google.golang.org/grpc"
|
||||||
"google.golang.org/grpc/keepalive"
|
"google.golang.org/grpc/keepalive"
|
||||||
|
|
||||||
@ -30,7 +30,7 @@ import (
|
|||||||
"go.woodpecker-ci.org/woodpecker/v2/server/store"
|
"go.woodpecker-ci.org/woodpecker/v2/server/store"
|
||||||
)
|
)
|
||||||
|
|
||||||
func runGrpcServer(ctx context.Context, c *cli.Context, _store store.Store) error {
|
func runGrpcServer(ctx context.Context, c *cli.Command, _store store.Store) error {
|
||||||
lis, err := net.Listen("tcp", c.String("grpc-addr"))
|
lis, err := net.Listen("tcp", c.String("grpc-addr"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal().Err(err).Msg("failed to listen on grpc-addr") //nolint:forbidigo
|
log.Fatal().Err(err).Msg("failed to listen on grpc-addr") //nolint:forbidigo
|
||||||
|
@ -16,20 +16,21 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/rs/zerolog/log"
|
"github.com/rs/zerolog/log"
|
||||||
"github.com/urfave/cli/v2"
|
"github.com/urfave/cli/v3"
|
||||||
)
|
)
|
||||||
|
|
||||||
const pingTimeout = 1 * time.Second
|
const pingTimeout = 1 * time.Second
|
||||||
|
|
||||||
// handles pinging the endpoint and returns an error if the
|
// handles pinging the endpoint and returns an error if the
|
||||||
// server is in an unhealthy state.
|
// server is in an unhealthy state.
|
||||||
func pinger(c *cli.Context) error {
|
func pinger(_ context.Context, c *cli.Command) error {
|
||||||
scheme := "http"
|
scheme := "http"
|
||||||
serverAddr := c.String("server-addr")
|
serverAddr := c.String("server-addr")
|
||||||
if strings.HasPrefix(serverAddr, ":") {
|
if strings.HasPrefix(serverAddr, ":") {
|
||||||
|
@ -15,18 +15,24 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
_ "github.com/joho/godotenv/autoload"
|
_ "github.com/joho/godotenv/autoload"
|
||||||
"github.com/rs/zerolog/log"
|
"github.com/rs/zerolog/log"
|
||||||
"github.com/urfave/cli/v2"
|
"github.com/urfave/cli/v3"
|
||||||
|
|
||||||
_ "go.woodpecker-ci.org/woodpecker/v2/cmd/server/docs"
|
_ "go.woodpecker-ci.org/woodpecker/v2/cmd/server/docs"
|
||||||
|
"go.woodpecker-ci.org/woodpecker/v2/shared/utils"
|
||||||
"go.woodpecker-ci.org/woodpecker/v2/version"
|
"go.woodpecker-ci.org/woodpecker/v2/version"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
app := cli.NewApp()
|
ctx := utils.WithContextSigtermCallback(context.Background(), func() {
|
||||||
|
log.Info().Msg("termination signal is received, shutting down server")
|
||||||
|
})
|
||||||
|
|
||||||
|
app := cli.Command{}
|
||||||
app.Name = "woodpecker-server"
|
app.Name = "woodpecker-server"
|
||||||
app.Version = version.String()
|
app.Version = version.String()
|
||||||
app.Usage = "woodpecker server"
|
app.Usage = "woodpecker server"
|
||||||
@ -42,7 +48,7 @@ func main() {
|
|||||||
|
|
||||||
setupSwaggerStaticConfig()
|
setupSwaggerStaticConfig()
|
||||||
|
|
||||||
if err := app.Run(os.Args); err != nil {
|
if err := app.Run(ctx, os.Args); err != nil {
|
||||||
log.Error().Err(err).Msgf("error running server")
|
log.Error().Err(err).Msgf("error running server")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -30,7 +30,7 @@ import (
|
|||||||
prometheus_http "github.com/prometheus/client_golang/prometheus/promhttp"
|
prometheus_http "github.com/prometheus/client_golang/prometheus/promhttp"
|
||||||
"github.com/rs/zerolog"
|
"github.com/rs/zerolog"
|
||||||
"github.com/rs/zerolog/log"
|
"github.com/rs/zerolog/log"
|
||||||
"github.com/urfave/cli/v2"
|
"github.com/urfave/cli/v3"
|
||||||
"golang.org/x/sync/errgroup"
|
"golang.org/x/sync/errgroup"
|
||||||
|
|
||||||
"go.woodpecker-ci.org/woodpecker/v2/server"
|
"go.woodpecker-ci.org/woodpecker/v2/server"
|
||||||
@ -39,7 +39,6 @@ import (
|
|||||||
"go.woodpecker-ci.org/woodpecker/v2/server/router/middleware"
|
"go.woodpecker-ci.org/woodpecker/v2/server/router/middleware"
|
||||||
"go.woodpecker-ci.org/woodpecker/v2/server/web"
|
"go.woodpecker-ci.org/woodpecker/v2/server/web"
|
||||||
"go.woodpecker-ci.org/woodpecker/v2/shared/logger"
|
"go.woodpecker-ci.org/woodpecker/v2/shared/logger"
|
||||||
"go.woodpecker-ci.org/woodpecker/v2/shared/utils"
|
|
||||||
"go.woodpecker-ci.org/woodpecker/v2/version"
|
"go.woodpecker-ci.org/woodpecker/v2/version"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -53,15 +52,11 @@ var (
|
|||||||
shutdownCtx = context.Background()
|
shutdownCtx = context.Background()
|
||||||
)
|
)
|
||||||
|
|
||||||
func run(c *cli.Context) error {
|
func run(ctx context.Context, c *cli.Command) error {
|
||||||
if err := logger.SetupGlobalLogger(c, true); err != nil {
|
if err := logger.SetupGlobalLogger(ctx, c, true); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx := utils.WithContextSigtermCallback(c.Context, func() {
|
|
||||||
log.Info().Msg("termination signal is received, shutting down server")
|
|
||||||
})
|
|
||||||
|
|
||||||
ctx, ctxCancel := context.WithCancelCause(ctx)
|
ctx, ctxCancel := context.WithCancelCause(ctx)
|
||||||
stopServerFunc = func(err error) {
|
stopServerFunc = func(err error) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -27,7 +27,7 @@ import (
|
|||||||
|
|
||||||
"github.com/gorilla/securecookie"
|
"github.com/gorilla/securecookie"
|
||||||
"github.com/rs/zerolog/log"
|
"github.com/rs/zerolog/log"
|
||||||
"github.com/urfave/cli/v2"
|
"github.com/urfave/cli/v3"
|
||||||
|
|
||||||
"go.woodpecker-ci.org/woodpecker/v2/server"
|
"go.woodpecker-ci.org/woodpecker/v2/server"
|
||||||
"go.woodpecker-ci.org/woodpecker/v2/server/cache"
|
"go.woodpecker-ci.org/woodpecker/v2/server/cache"
|
||||||
@ -51,7 +51,7 @@ const (
|
|||||||
storeInfoRefreshInterval = 10 * time.Second
|
storeInfoRefreshInterval = 10 * time.Second
|
||||||
)
|
)
|
||||||
|
|
||||||
func setupStore(ctx context.Context, c *cli.Context) (store.Store, error) {
|
func setupStore(ctx context.Context, c *cli.Command) (store.Store, error) {
|
||||||
datasource := c.String("datasource")
|
datasource := c.String("datasource")
|
||||||
driver := c.String("driver")
|
driver := c.String("driver")
|
||||||
xorm := store.XORM{
|
xorm := store.XORM{
|
||||||
@ -112,7 +112,7 @@ func setupMembershipService(_ context.Context, _store store.Store) cache.Members
|
|||||||
return cache.NewMembershipService(_store)
|
return cache.NewMembershipService(_store)
|
||||||
}
|
}
|
||||||
|
|
||||||
func setupLogStore(c *cli.Context, s store.Store) (logService.Service, error) {
|
func setupLogStore(c *cli.Command, s store.Store) (logService.Service, error) {
|
||||||
switch c.String("log-store") {
|
switch c.String("log-store") {
|
||||||
case "file":
|
case "file":
|
||||||
return file.NewLogStore(c.String("log-store-file-path"))
|
return file.NewLogStore(c.String("log-store-file-path"))
|
||||||
@ -144,7 +144,7 @@ func setupJWTSecret(_store store.Store) (string, error) {
|
|||||||
return jwtSecret, nil
|
return jwtSecret, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func setupEvilGlobals(ctx context.Context, c *cli.Context, s store.Store) error {
|
func setupEvilGlobals(ctx context.Context, c *cli.Command, s store.Store) error {
|
||||||
// services
|
// services
|
||||||
server.Config.Services.Queue = setupQueue(ctx, s)
|
server.Config.Services.Queue = setupQueue(ctx, s)
|
||||||
server.Config.Services.Logs = logging.New()
|
server.Config.Services.Logs = logging.New()
|
||||||
@ -175,15 +175,15 @@ func setupEvilGlobals(ctx context.Context, c *cli.Context, s store.Store) error
|
|||||||
events = append(events, model.WebhookEvent(v))
|
events = append(events, model.WebhookEvent(v))
|
||||||
}
|
}
|
||||||
server.Config.Pipeline.DefaultCancelPreviousPipelineEvents = events
|
server.Config.Pipeline.DefaultCancelPreviousPipelineEvents = events
|
||||||
server.Config.Pipeline.DefaultTimeout = c.Int64("default-pipeline-timeout")
|
server.Config.Pipeline.DefaultTimeout = c.Int("default-pipeline-timeout")
|
||||||
server.Config.Pipeline.MaxTimeout = c.Int64("max-pipeline-timeout")
|
server.Config.Pipeline.MaxTimeout = c.Int("max-pipeline-timeout")
|
||||||
|
|
||||||
// limits
|
// limits
|
||||||
server.Config.Pipeline.Limits.MemSwapLimit = c.Int64("limit-mem-swap")
|
server.Config.Pipeline.Limits.MemSwapLimit = c.Int("limit-mem-swap")
|
||||||
server.Config.Pipeline.Limits.MemLimit = c.Int64("limit-mem")
|
server.Config.Pipeline.Limits.MemLimit = c.Int("limit-mem")
|
||||||
server.Config.Pipeline.Limits.ShmSize = c.Int64("limit-shm-size")
|
server.Config.Pipeline.Limits.ShmSize = c.Int("limit-shm-size")
|
||||||
server.Config.Pipeline.Limits.CPUQuota = c.Int64("limit-cpu-quota")
|
server.Config.Pipeline.Limits.CPUQuota = c.Int("limit-cpu-quota")
|
||||||
server.Config.Pipeline.Limits.CPUShares = c.Int64("limit-cpu-shares")
|
server.Config.Pipeline.Limits.CPUShares = c.Int("limit-cpu-shares")
|
||||||
server.Config.Pipeline.Limits.CPUSet = c.String("limit-cpu-set")
|
server.Config.Pipeline.Limits.CPUSet = c.String("limit-cpu-set")
|
||||||
|
|
||||||
// backend options for pipeline compiler
|
// backend options for pipeline compiler
|
||||||
|
4
go.mod
4
go.mod
@ -56,7 +56,8 @@ require (
|
|||||||
github.com/swaggo/files v1.0.1
|
github.com/swaggo/files v1.0.1
|
||||||
github.com/swaggo/gin-swagger v1.6.0
|
github.com/swaggo/gin-swagger v1.6.0
|
||||||
github.com/swaggo/swag v1.16.3
|
github.com/swaggo/swag v1.16.3
|
||||||
github.com/urfave/cli/v2 v2.27.2
|
github.com/urfave/cli-docs/v3 v3.0.0-alpha5.0.20240714105325-1da00919bcb4
|
||||||
|
github.com/urfave/cli/v3 v3.0.0-alpha9.0.20240711030030-937cfe918cb1
|
||||||
github.com/xanzy/go-gitlab v0.106.0
|
github.com/xanzy/go-gitlab v0.106.0
|
||||||
github.com/xeipuuv/gojsonschema v1.2.0
|
github.com/xeipuuv/gojsonschema v1.2.0
|
||||||
github.com/zalando/go-keyring v0.2.5
|
github.com/zalando/go-keyring v0.2.5
|
||||||
@ -180,7 +181,6 @@ require (
|
|||||||
github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb // indirect
|
github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb // indirect
|
||||||
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 // indirect
|
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 // indirect
|
||||||
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e // indirect
|
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e // indirect
|
||||||
github.com/xrash/smetrics v0.0.0-20240312152122-5f08fbb34913 // indirect
|
|
||||||
github.com/zeebo/blake3 v0.2.3 // indirect
|
github.com/zeebo/blake3 v0.2.3 // indirect
|
||||||
go.uber.org/zap v1.27.0 // indirect
|
go.uber.org/zap v1.27.0 // indirect
|
||||||
golang.org/x/arch v0.8.0 // indirect
|
golang.org/x/arch v0.8.0 // indirect
|
||||||
|
8
go.sum
8
go.sum
@ -482,8 +482,10 @@ github.com/twitchyliquid64/golang-asm v0.15.1 h1:SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS
|
|||||||
github.com/twitchyliquid64/golang-asm v0.15.1/go.mod h1:a1lVb/DtPvCB8fslRZhAngC2+aY1QWCk3Cedj/Gdt08=
|
github.com/twitchyliquid64/golang-asm v0.15.1/go.mod h1:a1lVb/DtPvCB8fslRZhAngC2+aY1QWCk3Cedj/Gdt08=
|
||||||
github.com/ugorji/go/codec v1.2.12 h1:9LC83zGrHhuUA9l16C9AHXAqEV/2wBQ4nkvumAE65EE=
|
github.com/ugorji/go/codec v1.2.12 h1:9LC83zGrHhuUA9l16C9AHXAqEV/2wBQ4nkvumAE65EE=
|
||||||
github.com/ugorji/go/codec v1.2.12/go.mod h1:UNopzCgEMSXjBc6AOMqYvWC1ktqTAfzJZUZgYf6w6lg=
|
github.com/ugorji/go/codec v1.2.12/go.mod h1:UNopzCgEMSXjBc6AOMqYvWC1ktqTAfzJZUZgYf6w6lg=
|
||||||
github.com/urfave/cli/v2 v2.27.2 h1:6e0H+AkS+zDckwPCUrZkKX38mRaau4nL2uipkJpbkcI=
|
github.com/urfave/cli-docs/v3 v3.0.0-alpha5.0.20240714105325-1da00919bcb4 h1:exFN/ZOxXslYr9t2AjrniP7wPjp/VLLAJhgazj92EBg=
|
||||||
github.com/urfave/cli/v2 v2.27.2/go.mod h1:g0+79LmHHATl7DAcHO99smiR/T7uGLw84w8Y42x+4eM=
|
github.com/urfave/cli-docs/v3 v3.0.0-alpha5.0.20240714105325-1da00919bcb4/go.mod h1:AIqom6Q60U4tiqHp41i7+/AB2XHgi1WvQ7jOFlccmZ4=
|
||||||
|
github.com/urfave/cli/v3 v3.0.0-alpha9.0.20240711030030-937cfe918cb1 h1:oxO/Jem1QPy4lxbDtX8PMiFbL79dNMA6CNAfbC06rn4=
|
||||||
|
github.com/urfave/cli/v3 v3.0.0-alpha9.0.20240711030030-937cfe918cb1/go.mod h1:Z1ItyMma7t6I7zHG9OpbExhHQOSkFf/96n+mAZ9MtVI=
|
||||||
github.com/xanzy/go-gitlab v0.106.0 h1:EDfD03K74cIlQo2EducfiupVrip+Oj02bq9ofw5F8sA=
|
github.com/xanzy/go-gitlab v0.106.0 h1:EDfD03K74cIlQo2EducfiupVrip+Oj02bq9ofw5F8sA=
|
||||||
github.com/xanzy/go-gitlab v0.106.0/go.mod h1:ETg8tcj4OhrB84UEgeE8dSuV/0h4BBL1uOV/qK0vlyI=
|
github.com/xanzy/go-gitlab v0.106.0/go.mod h1:ETg8tcj4OhrB84UEgeE8dSuV/0h4BBL1uOV/qK0vlyI=
|
||||||
github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f/go.mod h1:N2zxlSyiKSe5eX1tZViRH5QA0qijqEDrYZiPEAiq3wU=
|
github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f/go.mod h1:N2zxlSyiKSe5eX1tZViRH5QA0qijqEDrYZiPEAiq3wU=
|
||||||
@ -495,8 +497,6 @@ github.com/xeipuuv/gojsonschema v1.2.0 h1:LhYJRs+L4fBtjZUfuSZIKGeVu0QRy8e5Xi7D17
|
|||||||
github.com/xeipuuv/gojsonschema v1.2.0/go.mod h1:anYRn/JVcOK2ZgGU+IjEV4nwlhoK5sQluxsYJ78Id3Y=
|
github.com/xeipuuv/gojsonschema v1.2.0/go.mod h1:anYRn/JVcOK2ZgGU+IjEV4nwlhoK5sQluxsYJ78Id3Y=
|
||||||
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e h1:JVG44RsyaB9T2KIHavMF/ppJZNG9ZpyihvCd0w101no=
|
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e h1:JVG44RsyaB9T2KIHavMF/ppJZNG9ZpyihvCd0w101no=
|
||||||
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e/go.mod h1:RbqR21r5mrJuqunuUZ/Dhy/avygyECGrLceyNeo4LiM=
|
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e/go.mod h1:RbqR21r5mrJuqunuUZ/Dhy/avygyECGrLceyNeo4LiM=
|
||||||
github.com/xrash/smetrics v0.0.0-20240312152122-5f08fbb34913 h1:+qGGcbkzsfDQNPPe9UDgpxAWQrhbbBXOYJFQDq/dtJw=
|
|
||||||
github.com/xrash/smetrics v0.0.0-20240312152122-5f08fbb34913/go.mod h1:4aEEwZQutDLsQv2Deui4iYQ6DWTxR14g6m8Wv88+Xqk=
|
|
||||||
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
||||||
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
||||||
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
|
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
|
||||||
|
@ -31,7 +31,7 @@ import (
|
|||||||
std_copy "github.com/moby/moby/pkg/stdcopy"
|
std_copy "github.com/moby/moby/pkg/stdcopy"
|
||||||
"github.com/moby/term"
|
"github.com/moby/term"
|
||||||
"github.com/rs/zerolog/log"
|
"github.com/rs/zerolog/log"
|
||||||
"github.com/urfave/cli/v2"
|
"github.com/urfave/cli/v3"
|
||||||
|
|
||||||
backend "go.woodpecker-ci.org/woodpecker/v2/pipeline/backend/types"
|
backend "go.woodpecker-ci.org/woodpecker/v2/pipeline/backend/types"
|
||||||
"go.woodpecker-ci.org/woodpecker/v2/shared/utils"
|
"go.woodpecker-ci.org/woodpecker/v2/shared/utils"
|
||||||
@ -63,7 +63,7 @@ func (e *docker) Name() string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (e *docker) IsAvailable(ctx context.Context) bool {
|
func (e *docker) IsAvailable(ctx context.Context) bool {
|
||||||
if c, ok := ctx.Value(backend.CliContext).(*cli.Context); ok {
|
if c, ok := ctx.Value(backend.CliCommand).(*cli.Command); ok {
|
||||||
if c.IsSet("backend-docker-host") {
|
if c.IsSet("backend-docker-host") {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
@ -101,7 +101,7 @@ func (e *docker) Flags() []cli.Flag {
|
|||||||
|
|
||||||
// Load new client for Docker Backend using environment variables.
|
// Load new client for Docker Backend using environment variables.
|
||||||
func (e *docker) Load(ctx context.Context) (*backend.BackendInfo, error) {
|
func (e *docker) Load(ctx context.Context) (*backend.BackendInfo, error) {
|
||||||
c, ok := ctx.Value(backend.CliContext).(*cli.Context)
|
c, ok := ctx.Value(backend.CliCommand).(*cli.Command)
|
||||||
if !ok {
|
if !ok {
|
||||||
return nil, backend.ErrNoCliContextFound
|
return nil, backend.ErrNoCliContextFound
|
||||||
}
|
}
|
||||||
|
@ -15,44 +15,44 @@
|
|||||||
package docker
|
package docker
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/urfave/cli/v2"
|
"github.com/urfave/cli/v3"
|
||||||
)
|
)
|
||||||
|
|
||||||
var Flags = []cli.Flag{
|
var Flags = []cli.Flag{
|
||||||
&cli.StringFlag{
|
&cli.StringFlag{
|
||||||
EnvVars: []string{"WOODPECKER_BACKEND_DOCKER_HOST", "DOCKER_HOST"},
|
Sources: cli.EnvVars("WOODPECKER_BACKEND_DOCKER_HOST", "DOCKER_HOST"),
|
||||||
Name: "backend-docker-host",
|
Name: "backend-docker-host",
|
||||||
Usage: "path to docker socket or url to the docker server",
|
Usage: "path to docker socket or url to the docker server",
|
||||||
},
|
},
|
||||||
&cli.StringFlag{
|
&cli.StringFlag{
|
||||||
EnvVars: []string{"WOODPECKER_BACKEND_DOCKER_API_VERSION", "DOCKER_API_VERSION"},
|
Sources: cli.EnvVars("WOODPECKER_BACKEND_DOCKER_API_VERSION", "DOCKER_API_VERSION"),
|
||||||
Name: "backend-docker-api-version",
|
Name: "backend-docker-api-version",
|
||||||
Usage: "the version of the API to reach, leave empty for latest.",
|
Usage: "the version of the API to reach, leave empty for latest.",
|
||||||
},
|
},
|
||||||
&cli.StringFlag{
|
&cli.StringFlag{
|
||||||
EnvVars: []string{"WOODPECKER_BACKEND_DOCKER_CERT_PATH", "DOCKER_CERT_PATH"},
|
Sources: cli.EnvVars("WOODPECKER_BACKEND_DOCKER_CERT_PATH", "DOCKER_CERT_PATH"),
|
||||||
Name: "backend-docker-cert",
|
Name: "backend-docker-cert",
|
||||||
Usage: "path to load the TLS certificates for connecting to docker server",
|
Usage: "path to load the TLS certificates for connecting to docker server",
|
||||||
},
|
},
|
||||||
&cli.BoolFlag{
|
&cli.BoolFlag{
|
||||||
EnvVars: []string{"WOODPECKER_BACKEND_DOCKER_TLS_VERIFY", "DOCKER_TLS_VERIFY"},
|
Sources: cli.EnvVars("WOODPECKER_BACKEND_DOCKER_TLS_VERIFY", "DOCKER_TLS_VERIFY"),
|
||||||
Name: "backend-docker-tls-verify",
|
Name: "backend-docker-tls-verify",
|
||||||
Usage: "enable or disable TLS verification for connecting to docker server",
|
Usage: "enable or disable TLS verification for connecting to docker server",
|
||||||
Value: true,
|
Value: true,
|
||||||
},
|
},
|
||||||
&cli.BoolFlag{
|
&cli.BoolFlag{
|
||||||
EnvVars: []string{"WOODPECKER_BACKEND_DOCKER_ENABLE_IPV6"},
|
Sources: cli.EnvVars("WOODPECKER_BACKEND_DOCKER_ENABLE_IPV6"),
|
||||||
Name: "backend-docker-ipv6",
|
Name: "backend-docker-ipv6",
|
||||||
Usage: "backend docker enable IPV6",
|
Usage: "backend docker enable IPV6",
|
||||||
Value: false,
|
Value: false,
|
||||||
},
|
},
|
||||||
&cli.StringFlag{
|
&cli.StringFlag{
|
||||||
EnvVars: []string{"WOODPECKER_BACKEND_DOCKER_NETWORK"},
|
Sources: cli.EnvVars("WOODPECKER_BACKEND_DOCKER_NETWORK"),
|
||||||
Name: "backend-docker-network",
|
Name: "backend-docker-network",
|
||||||
Usage: "backend docker network",
|
Usage: "backend docker network",
|
||||||
},
|
},
|
||||||
&cli.StringFlag{
|
&cli.StringFlag{
|
||||||
EnvVars: []string{"WOODPECKER_BACKEND_DOCKER_VOLUMES"},
|
Sources: cli.EnvVars("WOODPECKER_BACKEND_DOCKER_VOLUMES"),
|
||||||
Name: "backend-docker-volumes",
|
Name: "backend-docker-volumes",
|
||||||
Usage: "backend docker volumes (comma separated)",
|
Usage: "backend docker volumes (comma separated)",
|
||||||
},
|
},
|
||||||
|
@ -27,7 +27,7 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/rs/zerolog/log"
|
"github.com/rs/zerolog/log"
|
||||||
"github.com/urfave/cli/v2"
|
"github.com/urfave/cli/v3"
|
||||||
|
|
||||||
backend "go.woodpecker-ci.org/woodpecker/v2/pipeline/backend/types"
|
backend "go.woodpecker-ci.org/woodpecker/v2/pipeline/backend/types"
|
||||||
)
|
)
|
||||||
|
@ -14,76 +14,78 @@
|
|||||||
|
|
||||||
package kubernetes
|
package kubernetes
|
||||||
|
|
||||||
import "github.com/urfave/cli/v2"
|
import (
|
||||||
|
"github.com/urfave/cli/v3"
|
||||||
|
)
|
||||||
|
|
||||||
var Flags = []cli.Flag{
|
var Flags = []cli.Flag{
|
||||||
&cli.StringFlag{
|
&cli.StringFlag{
|
||||||
EnvVars: []string{"WOODPECKER_BACKEND_K8S_NAMESPACE"},
|
Sources: cli.EnvVars("WOODPECKER_BACKEND_K8S_NAMESPACE"),
|
||||||
Name: "backend-k8s-namespace",
|
Name: "backend-k8s-namespace",
|
||||||
Usage: "backend k8s namespace",
|
Usage: "backend k8s namespace",
|
||||||
Value: "woodpecker",
|
Value: "woodpecker",
|
||||||
},
|
},
|
||||||
&cli.StringFlag{
|
&cli.StringFlag{
|
||||||
EnvVars: []string{"WOODPECKER_BACKEND_K8S_VOLUME_SIZE"},
|
Sources: cli.EnvVars("WOODPECKER_BACKEND_K8S_VOLUME_SIZE"),
|
||||||
Name: "backend-k8s-volume-size",
|
Name: "backend-k8s-volume-size",
|
||||||
Usage: "backend k8s volume size (default 10G)",
|
Usage: "backend k8s volume size (default 10G)",
|
||||||
Value: "10G",
|
Value: "10G",
|
||||||
},
|
},
|
||||||
&cli.StringFlag{
|
&cli.StringFlag{
|
||||||
EnvVars: []string{"WOODPECKER_BACKEND_K8S_STORAGE_CLASS"},
|
Sources: cli.EnvVars("WOODPECKER_BACKEND_K8S_STORAGE_CLASS"),
|
||||||
Name: "backend-k8s-storage-class",
|
Name: "backend-k8s-storage-class",
|
||||||
Usage: "backend k8s storage class",
|
Usage: "backend k8s storage class",
|
||||||
Value: "",
|
Value: "",
|
||||||
},
|
},
|
||||||
&cli.BoolFlag{
|
&cli.BoolFlag{
|
||||||
EnvVars: []string{"WOODPECKER_BACKEND_K8S_STORAGE_RWX"},
|
Sources: cli.EnvVars("WOODPECKER_BACKEND_K8S_STORAGE_RWX"),
|
||||||
Name: "backend-k8s-storage-rwx",
|
Name: "backend-k8s-storage-rwx",
|
||||||
Usage: "backend k8s storage access mode, should ReadWriteMany (RWX) instead of ReadWriteOnce (RWO) be used? (default: true)",
|
Usage: "backend k8s storage access mode, should ReadWriteMany (RWX) instead of ReadWriteOnce (RWO) be used? (default: true)",
|
||||||
Value: true,
|
Value: true,
|
||||||
},
|
},
|
||||||
&cli.StringFlag{
|
&cli.StringFlag{
|
||||||
EnvVars: []string{"WOODPECKER_BACKEND_K8S_POD_LABELS"},
|
Sources: cli.EnvVars("WOODPECKER_BACKEND_K8S_POD_LABELS"),
|
||||||
Name: "backend-k8s-pod-labels",
|
Name: "backend-k8s-pod-labels",
|
||||||
Usage: "backend k8s additional Agent-wide worker pod labels",
|
Usage: "backend k8s additional Agent-wide worker pod labels",
|
||||||
Value: "",
|
Value: "",
|
||||||
},
|
},
|
||||||
&cli.BoolFlag{
|
&cli.BoolFlag{
|
||||||
EnvVars: []string{"WOODPECKER_BACKEND_K8S_POD_LABELS_ALLOW_FROM_STEP"},
|
Sources: cli.EnvVars("WOODPECKER_BACKEND_K8S_POD_LABELS_ALLOW_FROM_STEP"),
|
||||||
Name: "backend-k8s-pod-labels-allow-from-step",
|
Name: "backend-k8s-pod-labels-allow-from-step",
|
||||||
Usage: "whether to allow using labels from step's backend options",
|
Usage: "whether to allow using labels from step's backend options",
|
||||||
Value: false,
|
Value: false,
|
||||||
},
|
},
|
||||||
&cli.StringFlag{
|
&cli.StringFlag{
|
||||||
EnvVars: []string{"WOODPECKER_BACKEND_K8S_POD_ANNOTATIONS"},
|
Sources: cli.EnvVars("WOODPECKER_BACKEND_K8S_POD_ANNOTATIONS"),
|
||||||
Name: "backend-k8s-pod-annotations",
|
Name: "backend-k8s-pod-annotations",
|
||||||
Usage: "backend k8s additional Agent-wide worker pod annotations",
|
Usage: "backend k8s additional Agent-wide worker pod annotations",
|
||||||
Value: "",
|
Value: "",
|
||||||
},
|
},
|
||||||
&cli.StringFlag{
|
&cli.StringFlag{
|
||||||
EnvVars: []string{"WOODPECKER_BACKEND_K8S_POD_NODE_SELECTOR"},
|
Sources: cli.EnvVars("WOODPECKER_BACKEND_K8S_POD_NODE_SELECTOR"),
|
||||||
Name: "backend-k8s-pod-node-selector",
|
Name: "backend-k8s-pod-node-selector",
|
||||||
Usage: "backend k8s Agent-wide worker pod node selector",
|
Usage: "backend k8s Agent-wide worker pod node selector",
|
||||||
Value: "",
|
Value: "",
|
||||||
},
|
},
|
||||||
&cli.BoolFlag{
|
&cli.BoolFlag{
|
||||||
EnvVars: []string{"WOODPECKER_BACKEND_K8S_POD_ANNOTATIONS_ALLOW_FROM_STEP"},
|
Sources: cli.EnvVars("WOODPECKER_BACKEND_K8S_POD_ANNOTATIONS_ALLOW_FROM_STEP"),
|
||||||
Name: "backend-k8s-pod-annotations-allow-from-step",
|
Name: "backend-k8s-pod-annotations-allow-from-step",
|
||||||
Usage: "whether to allow using annotations from step's backend options",
|
Usage: "whether to allow using annotations from step's backend options",
|
||||||
Value: false,
|
Value: false,
|
||||||
},
|
},
|
||||||
&cli.BoolFlag{
|
&cli.BoolFlag{
|
||||||
EnvVars: []string{"WOODPECKER_BACKEND_K8S_SECCTX_NONROOT"}, // cspell:words secctx nonroot
|
Sources: cli.EnvVars("WOODPECKER_BACKEND_K8S_SECCTX_NONROOT"), // cspell:words secctx nonroot
|
||||||
Name: "backend-k8s-secctx-nonroot",
|
Name: "backend-k8s-secctx-nonroot",
|
||||||
Usage: "`run as non root` Kubernetes security context option",
|
Usage: "`run as non root` Kubernetes security context option",
|
||||||
},
|
},
|
||||||
&cli.StringSliceFlag{
|
&cli.StringSliceFlag{
|
||||||
EnvVars: []string{"WOODPECKER_BACKEND_K8S_PULL_SECRET_NAMES"},
|
Sources: cli.EnvVars("WOODPECKER_BACKEND_K8S_PULL_SECRET_NAMES"),
|
||||||
Name: "backend-k8s-pod-image-pull-secret-names",
|
Name: "backend-k8s-pod-image-pull-secret-names",
|
||||||
Usage: "backend k8s pull secret names for private registries",
|
Usage: "backend k8s pull secret names for private registries",
|
||||||
Value: cli.NewStringSlice("regcred"),
|
Value: []string{"regcred"},
|
||||||
},
|
},
|
||||||
&cli.BoolFlag{
|
&cli.BoolFlag{
|
||||||
EnvVars: []string{"WOODPECKER_BACKEND_K8S_ALLOW_NATIVE_SECRETS"},
|
Sources: cli.EnvVars("WOODPECKER_BACKEND_K8S_ALLOW_NATIVE_SECRETS"),
|
||||||
Name: "backend-k8s-allow-native-secrets",
|
Name: "backend-k8s-allow-native-secrets",
|
||||||
Usage: "whether to allow existing Kubernetes secrets to be referenced from steps",
|
Usage: "whether to allow existing Kubernetes secrets to be referenced from steps",
|
||||||
Value: false,
|
Value: false,
|
||||||
|
@ -25,7 +25,7 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/rs/zerolog/log"
|
"github.com/rs/zerolog/log"
|
||||||
"github.com/urfave/cli/v2"
|
"github.com/urfave/cli/v3"
|
||||||
"gopkg.in/yaml.v3"
|
"gopkg.in/yaml.v3"
|
||||||
v1 "k8s.io/api/core/v1"
|
v1 "k8s.io/api/core/v1"
|
||||||
meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
@ -83,7 +83,7 @@ func newDefaultDeleteOptions() meta_v1.DeleteOptions {
|
|||||||
|
|
||||||
func configFromCliContext(ctx context.Context) (*config, error) {
|
func configFromCliContext(ctx context.Context) (*config, error) {
|
||||||
if ctx != nil {
|
if ctx != nil {
|
||||||
if c, ok := ctx.Value(types.CliContext).(*cli.Context); ok {
|
if c, ok := ctx.Value(types.CliCommand).(*cli.Command); ok {
|
||||||
config := config{
|
config := config{
|
||||||
Namespace: c.String("backend-k8s-namespace"),
|
Namespace: c.String("backend-k8s-namespace"),
|
||||||
StorageClass: c.String("backend-k8s-storage-class"),
|
StorageClass: c.String("backend-k8s-storage-class"),
|
||||||
|
@ -17,13 +17,13 @@ package local
|
|||||||
import (
|
import (
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
"github.com/urfave/cli/v2"
|
"github.com/urfave/cli/v3"
|
||||||
)
|
)
|
||||||
|
|
||||||
var Flags = []cli.Flag{
|
var Flags = []cli.Flag{
|
||||||
&cli.StringFlag{
|
&cli.StringFlag{
|
||||||
Name: "backend-local-temp-dir",
|
Name: "backend-local-temp-dir",
|
||||||
EnvVars: []string{"WOODPECKER_BACKEND_LOCAL_TEMP_DIR"},
|
Sources: cli.EnvVars("WOODPECKER_BACKEND_LOCAL_TEMP_DIR"),
|
||||||
Usage: "set a different temp dir to clone workflows into",
|
Usage: "set a different temp dir to clone workflows into",
|
||||||
Value: os.TempDir(),
|
Value: os.TempDir(),
|
||||||
},
|
},
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user