From 51649ab4c687bfcb20a31f2daf53622f87378b48 Mon Sep 17 00:00:00 2001 From: Eoin McAfee Date: Wed, 18 Aug 2021 15:15:32 +0100 Subject: [PATCH 1/3] Update the way namespace is sent to the drone server. --- drone/template/template_add.go | 16 +++++++++------- drone/template/template_set.go | 13 ++++++++++--- 2 files changed, 19 insertions(+), 10 deletions(-) diff --git a/drone/template/template_add.go b/drone/template/template_add.go index 8231a1e5..f19250ce 100644 --- a/drone/template/template_add.go +++ b/drone/template/template_add.go @@ -36,16 +36,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"), "@") { @@ -56,6 +58,6 @@ func templateCreate(c *cli.Context) error { } template.Data = string(out) } - _, err = client.TemplateCreate(template) + _, err = client.TemplateCreate(namespace, template) return err } diff --git a/drone/template/template_set.go b/drone/template/template_set.go index 2109df01..f66c0b7d 100644 --- a/drone/template/template_set.go +++ b/drone/template/template_set.go @@ -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" ) @@ -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"), "@") @@ -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 } From 347c903783f3b20e756192caec73da996521b7ca Mon Sep 17 00:00:00 2001 From: Eoin McAfee Date: Thu, 19 Aug 2021 15:08:41 +0100 Subject: [PATCH 2/3] update drone-go version --- drone/template/template_add.go | 1 + 1 file changed, 1 insertion(+) diff --git a/drone/template/template_add.go b/drone/template/template_add.go index f19250ce..f4f20b5c 100644 --- a/drone/template/template_add.go +++ b/drone/template/template_add.go @@ -7,6 +7,7 @@ import ( "github.com/drone/drone-cli/drone/internal" "github.com/drone/drone-go/drone" + "github.com/urfave/cli" ) From 3ddf66bec977f569a6d2db1c960c2d9de98b8d25 Mon Sep 17 00:00:00 2001 From: Eoin McAfee Date: Thu, 19 Aug 2021 15:12:42 +0100 Subject: [PATCH 3/3] bump drone-go library --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 6cab666a..dbd05cc2 100644 --- a/go.mod +++ b/go.mod @@ -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 diff --git a/go.sum b/go.sum index c874081a..0b3c2daf 100644 --- a/go.sum +++ b/go.sum @@ -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=