mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2025-02-04 18:21:06 +02:00
Merge pull request #118 from imduffy15/global-envs
Add support for a global env from a server flag
This commit is contained in:
commit
1444b06a7e
@ -133,6 +133,10 @@ var flags = []cli.Flag{
|
|||||||
EnvVar: "DRONE_VOLUME",
|
EnvVar: "DRONE_VOLUME",
|
||||||
Name: "volume",
|
Name: "volume",
|
||||||
},
|
},
|
||||||
|
cli.StringSliceFlag{
|
||||||
|
EnvVar: "DRONE_ENVIRONMENT",
|
||||||
|
Name: "environment",
|
||||||
|
},
|
||||||
cli.StringSliceFlag{
|
cli.StringSliceFlag{
|
||||||
EnvVar: "DRONE_NETWORK",
|
EnvVar: "DRONE_NETWORK",
|
||||||
Name: "network",
|
Name: "network",
|
||||||
|
@ -21,6 +21,7 @@ import (
|
|||||||
"github.com/dimfeld/httptreemux"
|
"github.com/dimfeld/httptreemux"
|
||||||
"github.com/laszlocph/woodpecker/cncd/queue"
|
"github.com/laszlocph/woodpecker/cncd/queue"
|
||||||
"github.com/laszlocph/woodpecker/model"
|
"github.com/laszlocph/woodpecker/model"
|
||||||
|
"github.com/laszlocph/woodpecker/plugins/environments"
|
||||||
"github.com/laszlocph/woodpecker/plugins/registry"
|
"github.com/laszlocph/woodpecker/plugins/registry"
|
||||||
"github.com/laszlocph/woodpecker/plugins/secrets"
|
"github.com/laszlocph/woodpecker/plugins/secrets"
|
||||||
"github.com/laszlocph/woodpecker/remote"
|
"github.com/laszlocph/woodpecker/remote"
|
||||||
@ -63,7 +64,7 @@ func setupRegistryService(c *cli.Context, s store.Store) model.RegistryService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func setupEnvironService(c *cli.Context, s store.Store) model.EnvironService {
|
func setupEnvironService(c *cli.Context, s store.Store) model.EnvironService {
|
||||||
return nil
|
return environments.Filesystem(c.StringSlice("environment"))
|
||||||
}
|
}
|
||||||
|
|
||||||
func setupPubsub(c *cli.Context) {}
|
func setupPubsub(c *cli.Context) {}
|
||||||
|
25
plugins/environments/filesystem.go
Normal file
25
plugins/environments/filesystem.go
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
package environments
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/laszlocph/woodpecker/model"
|
||||||
|
"strings"
|
||||||
|
)
|
||||||
|
|
||||||
|
type builtin struct {
|
||||||
|
globals []*model.Environ
|
||||||
|
}
|
||||||
|
|
||||||
|
// New returns a new local registry service.
|
||||||
|
func Filesystem(params []string) model.EnvironService {
|
||||||
|
var globals []*model.Environ
|
||||||
|
|
||||||
|
for _, item := range params {
|
||||||
|
kvpair := strings.SplitN(item, ":", 2)
|
||||||
|
globals = append(globals, &model.Environ{Name: kvpair[0], Value: kvpair[1]})
|
||||||
|
}
|
||||||
|
return &builtin{globals}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (b *builtin) EnvironList(repo *model.Repo) ([]*model.Environ, error) {
|
||||||
|
return b.globals, nil
|
||||||
|
}
|
1
plugins/environments/filesystem_test.go
Normal file
1
plugins/environments/filesystem_test.go
Normal file
@ -0,0 +1 @@
|
|||||||
|
package environments
|
Loading…
x
Reference in New Issue
Block a user