Skip to content

Commit

Permalink
Ensure cli exec has by default not the same prefix (#4132)
Browse files Browse the repository at this point in the history
  • Loading branch information
6543 authored Sep 24, 2024
1 parent b59533a commit 1a6c8df
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 11 deletions.
10 changes: 6 additions & 4 deletions cli/exec/exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
"strings"

"github.com/drone/envsubst"
"github.com/oklog/ulid/v2"
"github.com/rs/zerolog/log"
"github.com/urfave/cli/v3"

Expand Down Expand Up @@ -170,6 +171,9 @@ func execWithAxis(ctx context.Context, c *cli.Command, file, repoPath string, ax
return err
}

// emulate server behavior https://github.com/woodpecker-ci/woodpecker/blob/eebaa10d104cbc3fa7ce4c0e344b0b7978405135/server/pipeline/stepbuilder/stepBuilder.go#L289-L295
prefix := "wp_" + ulid.Make().String()

// configure volumes for local execution
volumes := c.StringSlice("volumes")
if c.Bool("local") {
Expand All @@ -184,7 +188,7 @@ func execWithAxis(ctx context.Context, c *cli.Command, file, repoPath string, ax
workspacePath = c.String("workspace-path")
}

volumes = append(volumes, c.String("prefix")+"_default:"+workspaceBase)
volumes = append(volumes, prefix+"_default:"+workspaceBase)
volumes = append(volumes, repoPath+":"+path.Join(workspaceBase, workspacePath))
}

Expand Down Expand Up @@ -221,9 +225,7 @@ func execWithAxis(ctx context.Context, c *cli.Command, file, repoPath string, ax
compiler.WithNetworks(
c.StringSlice("network")...,
),
compiler.WithPrefix(
c.String("prefix"),
),
compiler.WithPrefix(prefix),
compiler.WithProxy(compiler.ProxyOptions{
NoProxy: c.String("backend-no-proxy"),
HTTPProxy: c.String("backend-http-proxy"),
Expand Down
7 changes: 0 additions & 7 deletions cli/exec/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,6 @@ var flags = []cli.Flag{
Name: "network",
Usage: "external networks",
},
&cli.StringFlag{
Sources: cli.EnvVars("WOODPECKER_PREFIX"),
Name: "prefix",
Value: "woodpecker",
Usage: "prefix used for containers, volumes, networks, ... created by woodpecker",
Hidden: true,
},
&cli.StringSliceFlag{
Sources: cli.EnvVars("WOODPECKER_PLUGINS_PRIVILEGED"),
Name: "plugins-privileged",
Expand Down

0 comments on commit 1a6c8df

Please sign in to comment.