1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2025-07-15 01:34:21 +02:00

fix: pluralize blob in the config file (#1095)

* fix: pluralize blob in the config file

Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com>

* test: added tests

Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com>
This commit is contained in:
Carlos Alexandro Becker
2019-08-02 16:17:38 -03:00
committed by GitHub
parent 7871c58ac2
commit 844f95a2d0
5 changed files with 55 additions and 13 deletions

View File

@ -5,6 +5,7 @@ import (
"fmt"
"strings"
"github.com/goreleaser/goreleaser/internal/deprecate"
"github.com/goreleaser/goreleaser/internal/pipe"
"github.com/goreleaser/goreleaser/internal/semerrgroup"
"github.com/goreleaser/goreleaser/internal/tmpl"
@ -21,6 +22,10 @@ func (Pipe) String() string {
// Default sets the pipe defaults
func (Pipe) Default(ctx *context.Context) error {
if len(ctx.Config.Blob) > 0 {
deprecate.Notice("blob")
ctx.Config.Blobs = append(ctx.Config.Blobs, ctx.Config.Blob...)
}
for i := range ctx.Config.Blobs {
blob := &ctx.Config.Blobs[i]

View File

@ -7,6 +7,8 @@ import (
"strings"
"testing"
"github.com/stretchr/testify/require"
"github.com/goreleaser/goreleaser/internal/artifact"
"github.com/goreleaser/goreleaser/internal/testlib"
"github.com/goreleaser/goreleaser/pkg/config"
@ -15,7 +17,7 @@ import (
)
func TestDescription(t *testing.T) {
assert.NotEmpty(t, Pipe{}.String())
require.NotEmpty(t, Pipe{}.String())
}
func TestNoBlob(t *testing.T) {
@ -60,8 +62,13 @@ func TestDefaultsNoProvider(t *testing.T) {
}
func TestDefaults(t *testing.T) {
var assert = assert.New(t)
var ctx = context.New(config.Project{
Blob: []config.Blob{
{
Bucket: "foobar",
Provider: "gcs",
},
},
Blobs: []config.Blob{
{
Bucket: "foo",
@ -70,13 +77,20 @@ func TestDefaults(t *testing.T) {
},
},
})
assert.NoError(Pipe{}.Default(ctx))
assert.Equal([]config.Blob{{
require.NoError(t, Pipe{}.Default(ctx))
require.Equal(t, []config.Blob{
{
Bucket: "foo",
Provider: "azblob",
Folder: "{{ .ProjectName }}/{{ .Tag }}",
IDs: []string{"foo", "bar"},
}}, ctx.Config.Blobs)
},
{
Bucket: "foobar",
Provider: "gcs",
Folder: "{{ .ProjectName }}/{{ .Tag }}",
},
}, ctx.Config.Blobs)
}
func TestDefaultsWithProvider(t *testing.T) {

View File

@ -354,7 +354,8 @@ type Project struct {
Artifactories []Put `yaml:",omitempty"`
Puts []Put `yaml:",omitempty"`
S3 []S3 `yaml:"s3,omitempty"`
Blobs []Blob `yaml:"blob,omitempty"`
Blob []Blob `yaml:"blob,omitempty"` // TODO: remove this
Blobs []Blob `yaml:"blobs,omitempty"`
Changelog Changelog `yaml:",omitempty"`
Dist string `yaml:",omitempty"`
Sign Sign `yaml:",omitempty"` // TODO: remove this

View File

@ -7,7 +7,7 @@ series: customization
```yaml
# .goreleaser.yml
blob:
blobs:
# You can have multiple blob configs
-
# Template for the cloud provider name

View File

@ -34,6 +34,28 @@ to this:
-->
### blob
> since 2019-08-02
Blob was deprecated in favor of its plural form.
It was already accepting multiple inputs, but its pluralized now so its more
clear.
Change this:
```yaml
blob:
# etc
```
to this:
```yaml
blobs:
# etc
```
### sign
> since 2019-07-20
@ -95,7 +117,7 @@ s3:
to this:
```yaml
blob:
blobs:
-
provider: s3
# etc