mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-12-24 10:07:21 +02:00
Add support for a global env from a server flag
This commit is contained in:
parent
6ee3adc72c
commit
070f6ea49c
@ -133,6 +133,10 @@ var flags = []cli.Flag{
|
||||
EnvVar: "DRONE_VOLUME",
|
||||
Name: "volume",
|
||||
},
|
||||
cli.StringSliceFlag{
|
||||
EnvVar: "DRONE_ENVIRONMENT",
|
||||
Name: "environment",
|
||||
},
|
||||
cli.StringSliceFlag{
|
||||
EnvVar: "DRONE_NETWORK",
|
||||
Name: "network",
|
||||
|
@ -21,6 +21,7 @@ import (
|
||||
"github.com/dimfeld/httptreemux"
|
||||
"github.com/laszlocph/woodpecker/cncd/queue"
|
||||
"github.com/laszlocph/woodpecker/model"
|
||||
"github.com/laszlocph/woodpecker/plugins/environments"
|
||||
"github.com/laszlocph/woodpecker/plugins/registry"
|
||||
"github.com/laszlocph/woodpecker/plugins/secrets"
|
||||
"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 {
|
||||
return nil
|
||||
return environments.Filesystem(c.StringSlice("environment"))
|
||||
}
|
||||
|
||||
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…
Reference in New Issue
Block a user