Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Defect/permission template #191

Merged
merged 4 commits into from
Aug 19, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 10 additions & 7 deletions drone/template/template_add.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (

"github.com/drone/drone-cli/drone/internal"
"github.com/drone/drone-go/drone"

"github.com/urfave/cli"
)

Expand Down Expand Up @@ -36,16 +37,18 @@ func templateCreate(c *cli.Context) error {
if err != nil {
return err
}

namespace := c.String("namespace")
if namespace == "" {
return errors.New("missing namespace")
}

template := &drone.Template{
Namespace: c.String("namespace"),
Name: c.String("name"),
Name: c.String("name"),
}

if template.Name == "" {
return errors.New("Missing template name")
}
if template.Namespace == "" {
return errors.New("Missing namespace")
return errors.New("missing template name")
}

if strings.HasPrefix(c.String("data"), "@") {
Expand All @@ -56,6 +59,6 @@ func templateCreate(c *cli.Context) error {
}
template.Data = string(out)
}
_, err = client.TemplateCreate(template)
_, err = client.TemplateCreate(namespace, template)
return err
}
13 changes: 10 additions & 3 deletions drone/template/template_set.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
package template

import (
"errors"
"io/ioutil"
"strings"

"github.com/drone/drone-cli/drone/internal"
"github.com/drone/drone-go/drone"

"github.com/urfave/cli"
)

Expand Down Expand Up @@ -35,9 +37,14 @@ func templateUpdate(c *cli.Context) error {
if err != nil {
return err
}

namespace := c.String("namespace")
if namespace == "" {
return errors.New("missing namespace")
}

template := &drone.Template{
Name: c.String("name"),
Namespace: c.String("namespace"),
Name: c.String("name"),
}
if strings.HasPrefix(c.String("data"), "@") {
path := strings.TrimPrefix(c.String("data"), "@")
Expand All @@ -47,6 +54,6 @@ func templateUpdate(c *cli.Context) error {
}
template.Data = string(out)
}
_, err = client.TemplateUpdate(template.Namespace, template.Name, template)
_, err = client.TemplateUpdate(namespace, template.Name, template)
return err
}
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ replace github.com/docker/docker => github.com/docker/engine v17.12.0-ce-rc1.0.2

require (
github.com/docker/go-units v0.3.3
github.com/drone/drone-go v1.6.1-0.20210601150845-c0e5325523a6
github.com/drone/drone-go v1.6.1
github.com/drone/drone-runtime v1.1.1-0.20200623162453-61e33e2cab5d
github.com/drone/drone-yaml v0.0.0-20190729072335-70fa398b3560
github.com/drone/envsubst v1.0.1
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ github.com/docker/go-connections v0.3.0 h1:3lOnM9cSzgGwx8VfK/NGOW5fLQ0GjIlCkaktF
github.com/docker/go-connections v0.3.0/go.mod h1:Gbd7IOopHjR8Iph03tsViu4nIes5XhDvyHbTtUxmeec=
github.com/docker/go-units v0.3.3 h1:Xk8S3Xj5sLGlG5g67hJmYMmUgXv5N4PhkjJHHqrwnTk=
github.com/docker/go-units v0.3.3/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk=
github.com/drone/drone-go v1.6.1-0.20210601150845-c0e5325523a6 h1:mLEgDgep0et7hQCm76xH3xkuMAQb92JYT+0HKQk/loM=
github.com/drone/drone-go v1.6.1-0.20210601150845-c0e5325523a6/go.mod h1:fxCf9jAnXDZV1yDr0ckTuWd1intvcQwfJmTRpTZ1mXg=
github.com/drone/drone-go v1.6.1 h1:6GRwCxu6K3vUWVUfRvqGhROzjkRE7OsV5UwxGW9sVfk=
github.com/drone/drone-go v1.6.1/go.mod h1:fxCf9jAnXDZV1yDr0ckTuWd1intvcQwfJmTRpTZ1mXg=
github.com/drone/drone-runtime v1.0.7-0.20190729070836-38f28a11afe8/go.mod h1:+osgwGADc/nyl40J0fdsf8Z09bgcBZXvXXnLOY48zYs=
github.com/drone/drone-runtime v1.1.1-0.20200623162453-61e33e2cab5d h1:P5HI/Y9hARTZ3F3EKs0kYijhjXZWQRQHYn1neTi0pWM=
github.com/drone/drone-runtime v1.1.1-0.20200623162453-61e33e2cab5d/go.mod h1:4/2QToW5+HGD0y1sTw7X35W1f7YINS14UfDY4isggT8=
Expand Down