Workaround test

This commit is contained in:
2023-11-12 16:51:32 +01:00
parent da8571c718
commit 02b85c7603
7 changed files with 32 additions and 67 deletions

View File

@@ -2,6 +2,7 @@ package main
import (
"codeberg.org/woodpecker-plugins/plugin-docker-buildx/plugin"
"github.com/thegeeklab/drone-plugin-lib/v2/drone"
"github.com/urfave/cli/v2"
)
@@ -189,11 +190,11 @@ func settingsFlags(settings *plugin.Settings) []cli.Flag {
Usage: "sets the build target to use",
Destination: &settings.Build.Target,
},
&cli.StringSliceFlag{
Name: "cache-from",
EnvVars: []string{"PLUGIN_CACHE_FROM"},
Usage: "sets images to consider as cache sources",
Destination: &settings.Build.CacheFrom,
&cli.GenericFlag{
Name: "cache-from",
EnvVars: []string{"PLUGIN_CACHE_FROM"},
Usage: "images to consider as cache sources",
Value: &drone.StringSliceFlag{},
},
&cli.StringSliceFlag{
Name: "cache-to",

View File

@@ -1,14 +1,16 @@
package main
import (
"fmt"
"os"
"codeberg.org/woodpecker-plugins/plugin-docker-buildx/plugin"
"github.com/joho/godotenv"
"github.com/sirupsen/logrus"
"github.com/urfave/cli/v2"
"github.com/drone-plugins/drone-plugin-lib/errors"
"github.com/drone-plugins/drone-plugin-lib/urfave"
"github.com/thegeeklab/drone-plugin-lib/v2/drone"
"github.com/thegeeklab/drone-plugin-lib/v2/urfave"
)
var version = "unknown"
@@ -19,7 +21,7 @@ func main() {
if _, err := os.Stat("/run/drone/env"); err == nil {
godotenv.Overload("/run/drone/env")
}
if envFile, set := os.LookupEnv("PLUGIN_ENV_FILE"); set {
godotenv.Overload(envFile)
}
@@ -33,7 +35,7 @@ func main() {
}
if err := app.Run(os.Args); err != nil {
errors.HandleExit(err)
logrus.Fatal(err)
}
}
@@ -41,6 +43,13 @@ func run(settings *plugin.Settings) cli.ActionFunc {
return func(ctx *cli.Context) error {
urfave.LoggingFromContext(ctx)
cacheFrom, ok := ctx.Generic("cache-from").(*drone.StringSliceFlag)
if !ok {
return fmt.Errorf("failed to read cache-from input")
}
settings.Build.CacheFrom = cacheFrom.Get()
plugin := plugin.New(
*settings,
urfave.PipelineFromContext(ctx),
@@ -48,19 +57,11 @@ func run(settings *plugin.Settings) cli.ActionFunc {
)
if err := plugin.Validate(); err != nil {
if e, ok := err.(errors.ExitCoder); ok {
return e
}
return errors.ExitMessagef("validation failed: %w", err)
return fmt.Errorf("validation failed: %w", err)
}
if err := plugin.Execute(); err != nil {
if e, ok := err.(errors.ExitCoder); ok {
return e
}
return errors.ExitMessagef("execution failed: %w", err)
return fmt.Errorf("execution failed: %w", err)
}
return nil