1
0
mirror of https://github.com/woodpecker-ci/woodpecker.git synced 2025-02-04 18:21:06 +02:00

re-add @ syntax to load from file

This commit is contained in:
Brad Rydzewski 2017-04-20 23:00:55 +02:00
parent 232a4fab82
commit d508807e20
4 changed files with 44 additions and 0 deletions

View File

@ -1,6 +1,9 @@
package main
import (
"io/ioutil"
"strings"
"github.com/drone/drone/model"
"github.com/urfave/cli"
)
@ -53,6 +56,14 @@ func registryCreate(c *cli.Context) error {
Username: username,
Password: password,
}
if strings.HasPrefix(registry.Password, "@") {
path := strings.TrimPrefix(registry.Password, "@")
out, err := ioutil.ReadFile(path)
if err != nil {
return err
}
registry.Password = string(out)
}
_, err = client.RegistryCreate(owner, name, registry)
if err != nil {
return err

View File

@ -1,6 +1,9 @@
package main
import (
"io/ioutil"
"strings"
"github.com/drone/drone/model"
"github.com/urfave/cli"
)
@ -53,6 +56,14 @@ func registryUpdate(c *cli.Context) error {
Username: username,
Password: password,
}
if strings.HasPrefix(registry.Password, "@") {
path := strings.TrimPrefix(registry.Password, "@")
out, err := ioutil.ReadFile(path)
if err != nil {
return err
}
registry.Password = string(out)
}
_, err = client.RegistryUpdate(owner, name, registry)
if err != nil {
return err

View File

@ -1,6 +1,9 @@
package main
import (
"io/ioutil"
"strings"
"github.com/drone/drone/model"
"github.com/urfave/cli"
)
@ -55,6 +58,14 @@ func secretCreate(c *cli.Context) error {
if len(secret.Events) == 0 {
secret.Events = defaultSecretEvents
}
if strings.HasPrefix(secret.Value, "@") {
path := strings.TrimPrefix(secret.Value, "@")
out, err := ioutil.ReadFile(path)
if err != nil {
return err
}
secret.Value = string(out)
}
_, err = client.SecretCreate(owner, name, secret)
return err
}

View File

@ -1,6 +1,9 @@
package main
import (
"io/ioutil"
"strings"
"github.com/drone/drone/model"
"github.com/urfave/cli"
)
@ -52,6 +55,14 @@ func secretUpdate(c *cli.Context) error {
Images: c.StringSlice("image"),
Events: c.StringSlice("events"),
}
if strings.HasPrefix(secret.Value, "@") {
path := strings.TrimPrefix(secret.Value, "@")
out, err := ioutil.ReadFile(path)
if err != nil {
return err
}
secret.Value = string(out)
}
_, err = client.SecretUpdate(owner, name, secret)
return err
}