Skip to content

Commit

Permalink
Updated for drone 1.2.1
Browse files Browse the repository at this point in the history
  • Loading branch information
sdbondi committed Jun 20, 2019
1 parent d71ad08 commit c29f3e1
Show file tree
Hide file tree
Showing 795 changed files with 93,839 additions and 42,977 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
drone-secrets

.idea/
74 changes: 58 additions & 16 deletions Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 3 additions & 13 deletions apply/apply.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,6 @@ var Command = cli.Command{
},
}

var defaultSecretEvents = []string{
drone.EventPush,
drone.EventTag,
drone.EventDeploy,
}

func run(c *cli.Context) error {
manifest, err := mfst.Load(c.String("manifest"))
if err != nil {
Expand Down Expand Up @@ -81,17 +75,13 @@ func ensureSecretsForRepo(client drone.Client, manifestSecret *mfst.SecretDef, r
return err
}

if len(secret.Events) == 0 {
secret.Events = defaultSecretEvents
}

if strings.HasPrefix(secret.Value, "@") {
path := strings.TrimPrefix(secret.Value, "@")
if strings.HasPrefix(secret.Data, "@") {
path := strings.TrimPrefix(secret.Data, "@")
out, err := ioutil.ReadFile(path)
if err != nil {
return err
}
secret.Value = string(out)
secret.Data = string(out)
}

_, serr := client.Secret(owner, name, secret.Name)
Expand Down
10 changes: 0 additions & 10 deletions examples/manifest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,12 @@
# Comma delimited or list accepted (for value images and events keys)
- name: SLACK_WEBHOOK
value: abcde
events: push,tag
images:
- plugins/slack
- plugins/slack:*

# Setting value to a list
# List types are converted to a comma delimited string
- name: PLUGINS_ENVIRONMENT_VARIABLES
events:
- push
- tag
value:
- PORT=1234
- SECRET_TOKEN=abcd1234
# Same as:
# value: PORT=1234,SECRET_TOKEN=abcde1234,...
images:
- plugins/ecs
- plugins/ecs:*
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"github.com/urfave/cli"
)

const version string = "0.0.5"
const version string = "0.1.0"

func main() {
app := cli.NewApp()
Expand Down
33 changes: 4 additions & 29 deletions manifest/types.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package manifest

import (
"fmt"
"strings"

"github.com/drone/drone-go/drone"
Expand All @@ -10,8 +9,7 @@ import (
type Secret struct {
Name string `yaml:name`
Value StringArray `yaml:value`
Images StringArray `yaml:images`
Events StringArray `yaml:events`
EnablePullRequests bool `yaml:enable_pull_requests`
}

type SecretDef struct {
Expand Down Expand Up @@ -42,39 +40,16 @@ func (a *StringArray) UnmarshalYAML(unmarshal func(interface{}) error) error {
return nil
}

func toDroneEvent(event string) (string, error) {
switch event {
case "pr", "pull-request", "pull":
return drone.EventPull, nil
case "push":
return drone.EventPush, nil
case "tag":
return drone.EventTag, nil
case "deployment":
return drone.EventDeploy, nil

default:
return "", fmt.Errorf("manifest: Invalid event type '%s'", event)
}
}

func (inst *Secret) ToDroneSecret() (*drone.Secret, error) {
converted := &drone.Secret{}
converted.Name = inst.Name

if len(inst.Value) != 0 {
converted.Value = strings.Join(inst.Value, ",")
converted.Data = strings.Join(inst.Value, ",")
}
converted.Images = inst.Images

for _, evt := range inst.Events {
convertedEvt, err := toDroneEvent(evt)
if err != nil {
return converted, err
}

converted.Events = append(converted.Events, convertedEvt)
}
converted.PullRequestPush = inst.EnablePullRequests;
converted.PullRequest = inst.EnablePullRequests;

return converted, nil
}
6 changes: 6 additions & 0 deletions vendor/github.com/drone/drone-go/NOTICE

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit c29f3e1

Please sign in to comment.