1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2024-12-27 01:33:39 +02:00

refactor: pointer to artifact (#1110)

Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com>
This commit is contained in:
Carlos Alexandro Becker 2019-08-12 17:44:48 -03:00 committed by GitHub
parent 9c675218ad
commit b477ffa095
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
32 changed files with 149 additions and 149 deletions

View File

@ -122,26 +122,26 @@ func (a Artifact) Checksum(algorithm string) (string, error) {
// Artifacts is a list of artifacts
type Artifacts struct {
items []Artifact
items []*Artifact
lock *sync.Mutex
}
// New return a new list of artifacts
func New() Artifacts {
return Artifacts{
items: []Artifact{},
items: []*Artifact{},
lock: &sync.Mutex{},
}
}
// List return the actual list of artifacts
func (artifacts Artifacts) List() []Artifact {
func (artifacts Artifacts) List() []*Artifact {
return artifacts.items
}
// GroupByPlatform groups the artifacts by their platform
func (artifacts Artifacts) GroupByPlatform() map[string][]Artifact {
var result = map[string][]Artifact{}
func (artifacts Artifacts) GroupByPlatform() map[string][]*Artifact {
var result = map[string][]*Artifact{}
for _, a := range artifacts.items {
plat := a.Goos + a.Goarch + a.Goarm
result[plat] = append(result[plat], a)
@ -150,7 +150,7 @@ func (artifacts Artifacts) GroupByPlatform() map[string][]Artifact {
}
// Add safely adds a new artifact to an artifact list
func (artifacts *Artifacts) Add(a Artifact) {
func (artifacts *Artifacts) Add(a *Artifact) {
artifacts.lock.Lock()
defer artifacts.lock.Unlock()
log.WithFields(log.Fields{
@ -163,32 +163,32 @@ func (artifacts *Artifacts) Add(a Artifact) {
// Filter defines an artifact filter which can be used within the Filter
// function
type Filter func(a Artifact) bool
type Filter func(a *Artifact) bool
// ByGoos is a predefined filter that filters by the given goos
func ByGoos(s string) Filter {
return func(a Artifact) bool {
return func(a *Artifact) bool {
return a.Goos == s
}
}
// ByGoarch is a predefined filter that filters by the given goarch
func ByGoarch(s string) Filter {
return func(a Artifact) bool {
return func(a *Artifact) bool {
return a.Goarch == s
}
}
// ByGoarm is a predefined filter that filters by the given goarm
func ByGoarm(s string) Filter {
return func(a Artifact) bool {
return func(a *Artifact) bool {
return a.Goarm == s
}
}
// ByType is a predefined filter that filters by the given type
func ByType(t Type) Filter {
return func(a Artifact) bool {
return func(a *Artifact) bool {
return a.Type == t
}
}
@ -198,7 +198,7 @@ func ByFormats(formats ...string) Filter {
var filters = make([]Filter, 0, len(formats))
for _, format := range formats {
format := format
filters = append(filters, func(a Artifact) bool {
filters = append(filters, func(a *Artifact) bool {
return a.ExtraOr("Format", "") == format
})
}
@ -210,7 +210,7 @@ func ByIDs(ids ...string) Filter {
var filters = make([]Filter, 0, len(ids))
for _, id := range ids {
id := id
filters = append(filters, func(a Artifact) bool {
filters = append(filters, func(a *Artifact) bool {
return a.ExtraOr("ID", "") == id
})
}
@ -219,7 +219,7 @@ func ByIDs(ids ...string) Filter {
// Or performs an OR between all given filters
func Or(filters ...Filter) Filter {
return func(a Artifact) bool {
return func(a *Artifact) bool {
for _, f := range filters {
if f(a) {
return true
@ -231,7 +231,7 @@ func Or(filters ...Filter) Filter {
// And performs an AND between all given filters
func And(filters ...Filter) Filter {
return func(a Artifact) bool {
return func(a *Artifact) bool {
for _, f := range filters {
if !f(a) {
return false

View File

@ -17,7 +17,7 @@ var _ fmt.Stringer = Type(0)
func TestAdd(t *testing.T) {
var g errgroup.Group
var artifacts = New()
for _, a := range []Artifact{
for _, a := range []*Artifact{
{
Name: "foo",
Type: UploadableArchive,
@ -46,7 +46,7 @@ func TestAdd(t *testing.T) {
}
func TestFilter(t *testing.T) {
var data = []Artifact{
var data = []*Artifact{
{
Name: "foo",
Goos: "linux",
@ -89,7 +89,7 @@ func TestFilter(t *testing.T) {
assert.Len(t, artifacts.Filter(
And(
ByType(Checksum),
func(a Artifact) bool {
func(a *Artifact) bool {
return a.Name == "checkzumm"
},
),
@ -107,7 +107,7 @@ func TestFilter(t *testing.T) {
}
func TestGroupByPlatform(t *testing.T) {
var data = []Artifact{
var data = []*Artifact{
{
Name: "foo",
Goos: "linux",
@ -187,7 +187,7 @@ func TestInvalidAlgorithm(t *testing.T) {
}
func TestExtraOr(t *testing.T) {
var a = Artifact{
var a = &Artifact{
Extra: map[string]interface{}{
"Foo": "foo",
},
@ -197,7 +197,7 @@ func TestExtraOr(t *testing.T) {
}
func TestByIDs(t *testing.T) {
var data = []Artifact{
var data = []*Artifact{
{
Name: "foo",
Extra: map[string]interface{}{
@ -234,7 +234,7 @@ func TestByIDs(t *testing.T) {
}
func TestByFormats(t *testing.T) {
var data = []Artifact{
var data = []*Artifact{
{
Name: "foo",
Extra: map[string]interface{}{

View File

@ -100,7 +100,7 @@ func (*Builder) Build(ctx *context.Context, build config.Build, options api.Opti
if err := run(ctx, cmd, env); err != nil {
return errors.Wrapf(err, "failed to build for %s", options.Target)
}
ctx.Artifacts.Add(artifact.Artifact{
ctx.Artifacts.Add(&artifact.Artifact{
Type: artifact.Binary,
Path: options.Path,
Name: options.Name,

View File

@ -115,7 +115,7 @@ func TestBuild(t *testing.T) {
})
assert.NoError(t, err)
}
assert.ElementsMatch(t, ctx.Artifacts.List(), []artifact.Artifact{
assert.ElementsMatch(t, ctx.Artifacts.List(), []*artifact.Artifact{
{
Name: "foo",
Path: filepath.Join(folder, "dist", "linux_amd64", "foo"),

View File

@ -179,7 +179,7 @@ func uploadWithFilter(ctx *context.Context, put *config.Put, filter artifact.Fil
}
// uploadAsset uploads file to target and logs all actions
func uploadAsset(ctx *context.Context, put *config.Put, artifact artifact.Artifact, kind string, check ResponseChecker) error {
func uploadAsset(ctx *context.Context, put *config.Put, artifact *artifact.Artifact, kind string, check ResponseChecker) error {
envBase := fmt.Sprintf("%s_%s_", strings.ToUpper(kind), strings.ToUpper(put.Name))
username := put.Username
if username == "" {
@ -197,7 +197,7 @@ func uploadAsset(ctx *context.Context, put *config.Put, artifact artifact.Artifa
}
// Handle the artifact
asset, err := assetOpen(kind, &artifact)
asset, err := assetOpen(kind, artifact)
if err != nil {
return err
}
@ -335,7 +335,7 @@ type targetData struct {
// resolveTargetTemplate returns the resolved target template with replaced variables
// Those variables can be replaced by the given context, goos, goarch, goarm and more
// TODO: replace this with our internal template pkg
func resolveTargetTemplate(ctx *context.Context, put *config.Put, artifact artifact.Artifact) (string, error) {
func resolveTargetTemplate(ctx *context.Context, put *config.Put, artifact *artifact.Artifact) (string, error) {
data := targetData{
Version: ctx.Version,
Tag: ctx.Git.CurrentTag,

View File

@ -226,7 +226,7 @@ func TestUpload(t *testing.T) {
} {
var file = filepath.Join(folder, "a."+a.ext)
require.NoError(t, ioutil.WriteFile(file, []byte("lorem ipsum"), 0644))
ctx.Artifacts.Add(artifact.Artifact{
ctx.Artifacts.Add(&artifact.Artifact{
Name: "a." + a.ext,
Path: file,
Type: a.typ,

View File

@ -110,7 +110,7 @@ func (Pipe) Run(ctx *context.Context) error {
return g.Wait()
}
func create(ctx *context.Context, archive config.Archive, binaries []artifact.Artifact) error {
func create(ctx *context.Context, archive config.Archive, binaries []*artifact.Artifact) error {
var format = packageFormat(archive, binaries[0].Goos)
folder, err := tmpl.New(ctx).
WithArtifact(binaries[0], archive.Replacements).
@ -159,7 +159,7 @@ func create(ctx *context.Context, archive config.Archive, binaries []artifact.Ar
return fmt.Errorf("failed to add %s -> %s to the archive: %s", binary.Path, binary.Name, err.Error())
}
}
ctx.Artifacts.Add(artifact.Artifact{
ctx.Artifacts.Add(&artifact.Artifact{
Type: artifact.UploadableArchive,
Name: folder + "." + format,
Path: archivePath,
@ -186,7 +186,7 @@ func wrapFolder(a config.Archive) string {
}
}
func skip(ctx *context.Context, archive config.Archive, binaries []artifact.Artifact) error {
func skip(ctx *context.Context, archive config.Archive, binaries []*artifact.Artifact) error {
for _, binary := range binaries {
log.WithField("binary", binary.Name).Info("skip archiving")
name, err := tmpl.New(ctx).
@ -195,7 +195,7 @@ func skip(ctx *context.Context, archive config.Archive, binaries []artifact.Arti
if err != nil {
return err
}
ctx.Artifacts.Add(artifact.Artifact{
ctx.Artifacts.Add(&artifact.Artifact{
Type: artifact.UploadableBinary,
Name: name + binary.ExtraOr("Ext", "").(string),
Path: binary.Path,
@ -203,7 +203,7 @@ func skip(ctx *context.Context, archive config.Archive, binaries []artifact.Arti
Goarch: binary.Goarch,
Goarm: binary.Goarm,
Extra: map[string]interface{}{
"Builds": []artifact.Artifact{binary},
"Builds": []*artifact.Artifact{binary},
"ID": archive.ID,
"Format": archive.Format,
},

View File

@ -63,7 +63,7 @@ func TestRunPipe(t *testing.T) {
},
},
)
var darwinBuild = artifact.Artifact{
var darwinBuild = &artifact.Artifact{
Goos: "darwin",
Goarch: "amd64",
Name: "mybin",
@ -74,7 +74,7 @@ func TestRunPipe(t *testing.T) {
"ID": "default",
},
}
var windowsBuild = artifact.Artifact{
var windowsBuild = &artifact.Artifact{
Goos: "windows",
Goarch: "amd64",
Name: "mybin.exe",
@ -102,8 +102,8 @@ func TestRunPipe(t *testing.T) {
require.Equal(tt, "foobar_0.0.1_darwin_amd64."+format, darwin.Name)
require.Equal(tt, "foobar_0.0.1_windows_amd64.zip", windows.Name)
require.Equal(t, []artifact.Artifact{darwinBuild}, darwin.Extra["Builds"].([]artifact.Artifact))
require.Equal(t, []artifact.Artifact{windowsBuild}, windows.Extra["Builds"].([]artifact.Artifact))
require.Equal(t, []*artifact.Artifact{darwinBuild}, darwin.Extra["Builds"].([]*artifact.Artifact))
require.Equal(t, []*artifact.Artifact{windowsBuild}, windows.Extra["Builds"].([]*artifact.Artifact))
if format == "tar.gz" {
// Check archive contents
@ -195,7 +195,7 @@ func TestRunPipeBinary(t *testing.T) {
)
ctx.Version = "0.0.1"
ctx.Git.CurrentTag = "v0.0.1"
ctx.Artifacts.Add(artifact.Artifact{
ctx.Artifacts.Add(&artifact.Artifact{
Goos: "darwin",
Goarch: "amd64",
Name: "mybin",
@ -206,7 +206,7 @@ func TestRunPipeBinary(t *testing.T) {
"ID": "default",
},
})
ctx.Artifacts.Add(artifact.Artifact{
ctx.Artifacts.Add(&artifact.Artifact{
Goos: "windows",
Goarch: "amd64",
Name: "mybin.exe",
@ -241,7 +241,7 @@ func TestRunPipeDistRemoved(t *testing.T) {
},
)
ctx.Git.CurrentTag = "v0.0.1"
ctx.Artifacts.Add(artifact.Artifact{
ctx.Artifacts.Add(&artifact.Artifact{
Goos: "windows",
Goarch: "amd64",
Name: "mybin.exe",
@ -280,7 +280,7 @@ func TestRunPipeInvalidGlob(t *testing.T) {
},
)
ctx.Git.CurrentTag = "v0.0.1"
ctx.Artifacts.Add(artifact.Artifact{
ctx.Artifacts.Add(&artifact.Artifact{
Goos: "darwin",
Goarch: "amd64",
Name: "mybin",
@ -315,7 +315,7 @@ func TestRunPipeInvalidNameTemplate(t *testing.T) {
},
)
ctx.Git.CurrentTag = "v0.0.1"
ctx.Artifacts.Add(artifact.Artifact{
ctx.Artifacts.Add(&artifact.Artifact{
Goos: "darwin",
Goarch: "amd64",
Name: "mybin",
@ -351,7 +351,7 @@ func TestRunPipeInvalidWrapInDirectoryTemplate(t *testing.T) {
},
)
ctx.Git.CurrentTag = "v0.0.1"
ctx.Artifacts.Add(artifact.Artifact{
ctx.Artifacts.Add(&artifact.Artifact{
Goos: "darwin",
Goarch: "amd64",
Name: "mybin",
@ -395,7 +395,7 @@ func TestRunPipeWrap(t *testing.T) {
},
)
ctx.Git.CurrentTag = "v0.0.1"
ctx.Artifacts.Add(artifact.Artifact{
ctx.Artifacts.Add(&artifact.Artifact{
Goos: "darwin",
Goarch: "amd64",
Name: "mybin",
@ -531,7 +531,7 @@ func TestBinaryOverride(t *testing.T) {
},
)
ctx.Git.CurrentTag = "v0.0.1"
ctx.Artifacts.Add(artifact.Artifact{
ctx.Artifacts.Add(&artifact.Artifact{
Goos: "darwin",
Goarch: "amd64",
Name: "mybin",
@ -542,7 +542,7 @@ func TestBinaryOverride(t *testing.T) {
"ID": "default",
},
})
ctx.Artifacts.Add(artifact.Artifact{
ctx.Artifacts.Add(&artifact.Artifact{
Goos: "windows",
Goarch: "amd64",
Name: "mybin.exe",
@ -599,7 +599,7 @@ func TestRunPipeSameArchiveFilename(t *testing.T) {
},
},
)
ctx.Artifacts.Add(artifact.Artifact{
ctx.Artifacts.Add(&artifact.Artifact{
Goos: "darwin",
Goarch: "amd64",
Name: "mybin",
@ -610,7 +610,7 @@ func TestRunPipeSameArchiveFilename(t *testing.T) {
"ID": "default",
},
})
ctx.Artifacts.Add(artifact.Artifact{
ctx.Artifacts.Add(&artifact.Artifact{
Goos: "windows",
Goarch: "amd64",
Name: "mybin.exe",

View File

@ -194,7 +194,7 @@ func TestRunPipe_ModeBinary(t *testing.T) {
"ARTIFACTORY_PRODUCTION-EU_SECRET": "productionuser-apikey",
}
for _, goos := range []string{"linux", "darwin"} {
ctx.Artifacts.Add(artifact.Artifact{
ctx.Artifacts.Add(&artifact.Artifact{
Name: "mybin",
Path: binPath,
Goarch: "amd64",
@ -233,12 +233,12 @@ func TestRunPipe_ModeArchive(t *testing.T) {
"ARTIFACTORY_PRODUCTION_SECRET": "deployuser-secret",
}
ctx.Version = "1.0.0"
ctx.Artifacts.Add(artifact.Artifact{
ctx.Artifacts.Add(&artifact.Artifact{
Type: artifact.UploadableArchive,
Name: "bin.tar.gz",
Path: tarfile.Name(),
})
ctx.Artifacts.Add(artifact.Artifact{
ctx.Artifacts.Add(&artifact.Artifact{
Type: artifact.LinuxPackage,
Name: "bin.deb",
Path: debfile.Name(),
@ -329,7 +329,7 @@ func TestRunPipe_ArtifactoryDown(t *testing.T) {
ctx.Env = map[string]string{
"ARTIFACTORY_PRODUCTION_SECRET": "deployuser-secret",
}
ctx.Artifacts.Add(artifact.Artifact{
ctx.Artifacts.Add(&artifact.Artifact{
Type: artifact.UploadableArchive,
Name: "bin.tar.gz",
Path: tarfile.Name(),
@ -361,7 +361,7 @@ func TestRunPipe_TargetTemplateError(t *testing.T) {
ctx.Env = map[string]string{
"ARTIFACTORY_PRODUCTION_SECRET": "deployuser-secret",
}
ctx.Artifacts.Add(artifact.Artifact{
ctx.Artifacts.Add(&artifact.Artifact{
Name: "mybin",
Path: binPath,
Goarch: "amd64",
@ -417,7 +417,7 @@ func TestRunPipe_BadCredentials(t *testing.T) {
ctx.Env = map[string]string{
"ARTIFACTORY_PRODUCTION_SECRET": "deployuser-secret",
}
ctx.Artifacts.Add(artifact.Artifact{
ctx.Artifacts.Add(&artifact.Artifact{
Name: "mybin",
Path: binPath,
Goarch: "amd64",
@ -474,7 +474,7 @@ func TestRunPipe_UnparsableErrorResponse(t *testing.T) {
ctx.Env = map[string]string{
"ARTIFACTORY_PRODUCTION_SECRET": "deployuser-secret",
}
ctx.Artifacts.Add(artifact.Artifact{
ctx.Artifacts.Add(&artifact.Artifact{
Name: "mybin",
Path: binPath,
Goarch: "amd64",
@ -528,7 +528,7 @@ func TestRunPipe_UnparsableResponse(t *testing.T) {
ctx.Env = map[string]string{
"ARTIFACTORY_PRODUCTION_SECRET": "deployuser-secret",
}
ctx.Artifacts.Add(artifact.Artifact{
ctx.Artifacts.Add(&artifact.Artifact{
Name: "mybin",
Path: binPath,
Goarch: "amd64",
@ -555,7 +555,7 @@ func TestRunPipe_FileNotFound(t *testing.T) {
ctx.Env = map[string]string{
"ARTIFACTORY_PRODUCTION_SECRET": "deployuser-secret",
}
ctx.Artifacts.Add(artifact.Artifact{
ctx.Artifacts.Add(&artifact.Artifact{
Name: "mybin",
Path: "archivetest/dist/mybin/mybin",
Goarch: "amd64",
@ -592,7 +592,7 @@ func TestRunPipe_UnparsableTarget(t *testing.T) {
ctx.Env = map[string]string{
"ARTIFACTORY_PRODUCTION_SECRET": "deployuser-secret",
}
ctx.Artifacts.Add(artifact.Artifact{
ctx.Artifacts.Add(&artifact.Artifact{
Name: "mybin",
Path: binPath,
Goarch: "amd64",
@ -647,7 +647,7 @@ func TestRunPipe_DirUpload(t *testing.T) {
ctx.Env = map[string]string{
"ARTIFACTORY_PRODUCTION_SECRET": "deployuser-secret",
}
ctx.Artifacts.Add(artifact.Artifact{
ctx.Artifacts.Add(&artifact.Artifact{
Name: "mybin",
Path: filepath.Dir(binPath),
Goarch: "amd64",

View File

@ -137,12 +137,12 @@ func TestPipe_Publish(t *testing.T) {
})
azblobctx.Git = context.GitInfo{CurrentTag: "v1.0.0"}
azblobctx.Artifacts.Add(artifact.Artifact{
azblobctx.Artifacts.Add(&artifact.Artifact{
Type: artifact.UploadableArchive,
Name: "bin.tar.gz",
Path: tgzpath,
})
azblobctx.Artifacts.Add(artifact.Artifact{
azblobctx.Artifacts.Add(&artifact.Artifact{
Type: artifact.LinuxPackage,
Name: "bin.deb",
Path: debpath,
@ -162,12 +162,12 @@ func TestPipe_Publish(t *testing.T) {
gsctx.Git = context.GitInfo{CurrentTag: "v1.0.0"}
gsctx.Artifacts.Add(artifact.Artifact{
gsctx.Artifacts.Add(&artifact.Artifact{
Type: artifact.UploadableArchive,
Name: "bin.tar.gz",
Path: tgzpath,
})
gsctx.Artifacts.Add(artifact.Artifact{
gsctx.Artifacts.Add(&artifact.Artifact{
Type: artifact.LinuxPackage,
Name: "bin.deb",
Path: debpath,
@ -185,12 +185,12 @@ func TestPipe_Publish(t *testing.T) {
},
})
s3ctx.Git = context.GitInfo{CurrentTag: "v1.0.0"}
s3ctx.Artifacts.Add(artifact.Artifact{
s3ctx.Artifacts.Add(&artifact.Artifact{
Type: artifact.UploadableArchive,
Name: "bin.tar.gz",
Path: tgzpath,
})
s3ctx.Artifacts.Add(artifact.Artifact{
s3ctx.Artifacts.Add(&artifact.Artifact{
Type: artifact.LinuxPackage,
Name: "bin.deb",
Path: debpath,

View File

@ -178,7 +178,7 @@ func ghFormulaPath(folder, filename string) string {
return path.Join(folder, filename)
}
func buildFormula(ctx *context.Context, brew config.Homebrew, artifacts []artifact.Artifact) (string, error) {
func buildFormula(ctx *context.Context, brew config.Homebrew, artifacts []*artifact.Artifact) (string, error) {
data, err := dataFor(ctx, brew, artifacts)
if err != nil {
return "", err
@ -198,7 +198,7 @@ func doBuildFormula(ctx *context.Context, data templateData) (string, error) {
return tmpl.New(ctx).Apply(out.String())
}
func dataFor(ctx *context.Context, cfg config.Homebrew, artifacts []artifact.Artifact) (templateData, error) {
func dataFor(ctx *context.Context, cfg config.Homebrew, artifacts []*artifact.Artifact) (templateData, error) {
var result = templateData{
Name: formulaNameFor(cfg.Name),
Desc: cfg.Description,

View File

@ -163,7 +163,7 @@ func TestRunPipe(t *testing.T) {
},
}
fn(ctx)
ctx.Artifacts.Add(artifact.Artifact{
ctx.Artifacts.Add(&artifact.Artifact{
Name: "bar_bin.tar.gz",
Path: "doesnt matter",
Goos: "darwin",
@ -175,7 +175,7 @@ func TestRunPipe(t *testing.T) {
},
})
var path = filepath.Join(folder, "bin.tar.gz")
ctx.Artifacts.Add(artifact.Artifact{
ctx.Artifacts.Add(&artifact.Artifact{
Name: "bin.tar.gz",
Path: path,
Goos: "darwin",
@ -244,7 +244,7 @@ func TestRunPipeMultipleDarwin64Build(t *testing.T) {
f, err := ioutil.TempFile("", "")
assert.NoError(t, err)
defer f.Close()
ctx.Artifacts.Add(artifact.Artifact{
ctx.Artifacts.Add(&artifact.Artifact{
Name: "bin1",
Path: f.Name(),
Goos: "darwin",
@ -255,7 +255,7 @@ func TestRunPipeMultipleDarwin64Build(t *testing.T) {
"Format": "tar.gz",
},
})
ctx.Artifacts.Add(artifact.Artifact{
ctx.Artifacts.Add(&artifact.Artifact{
Name: "bin2",
Path: f.Name(),
Goos: "darwin",
@ -293,7 +293,7 @@ func TestRunPipeBinaryRelease(t *testing.T) {
},
},
)
ctx.Artifacts.Add(artifact.Artifact{
ctx.Artifacts.Add(&artifact.Artifact{
Name: "bin",
Path: "doesnt mather",
Goos: "darwin",
@ -325,7 +325,7 @@ func TestRunPipeNoUpload(t *testing.T) {
var path = filepath.Join(folder, "whatever.tar.gz")
_, err = os.Create(path)
assert.NoError(t, err)
ctx.Artifacts.Add(artifact.Artifact{
ctx.Artifacts.Add(&artifact.Artifact{
Name: "bin",
Path: path,
Goos: "darwin",

View File

@ -17,7 +17,7 @@ import (
"github.com/stretchr/testify/assert"
)
var fakeArtifact = artifact.Artifact{
var fakeArtifact = &artifact.Artifact{
Name: "fake",
}
@ -101,7 +101,7 @@ func TestRunPipe(t *testing.T) {
var ctx = context.New(config)
ctx.Git.CurrentTag = "2.4.5"
assert.NoError(t, Pipe{}.Run(ctx))
assert.Equal(t, ctx.Artifacts.List(), []artifact.Artifact{fakeArtifact})
assert.Equal(t, ctx.Artifacts.List(), []*artifact.Artifact{fakeArtifact})
}
func TestRunFullPipe(t *testing.T) {
@ -129,7 +129,7 @@ func TestRunFullPipe(t *testing.T) {
var ctx = context.New(config)
ctx.Git.CurrentTag = "2.4.5"
assert.NoError(t, Pipe{}.Run(ctx))
assert.Equal(t, ctx.Artifacts.List(), []artifact.Artifact{fakeArtifact})
assert.Equal(t, ctx.Artifacts.List(), []*artifact.Artifact{fakeArtifact})
assert.FileExists(t, post)
assert.FileExists(t, pre)
assert.FileExists(t, filepath.Join(folder, "build1_whatever", "testing"))

View File

@ -62,7 +62,7 @@ func (Pipe) Run(ctx *context.Context) (err error) {
return checksums(ctx.Config.Checksum.Algorithm, file, artifact)
})
}
ctx.Artifacts.Add(artifact.Artifact{
ctx.Artifacts.Add(&artifact.Artifact{
Type: artifact.Checksum,
Path: file.Name(),
Name: filename,
@ -70,7 +70,7 @@ func (Pipe) Run(ctx *context.Context) (err error) {
return g.Wait()
}
func checksums(algorithm string, w io.Writer, artifact artifact.Artifact) error {
func checksums(algorithm string, w io.Writer, artifact *artifact.Artifact) error {
log.WithField("file", artifact.Name).Info("checksumming")
sha, err := artifact.Checksum(algorithm)
if err != nil {

View File

@ -35,12 +35,12 @@ func TestPipe(t *testing.T) {
)
ctx.Git.CurrentTag = "1.2.3"
ctx.Env = map[string]string{"FOO": "bar"}
ctx.Artifacts.Add(artifact.Artifact{
ctx.Artifacts.Add(&artifact.Artifact{
Name: binary,
Path: file,
Type: artifact.UploadableBinary,
})
ctx.Artifacts.Add(artifact.Artifact{
ctx.Artifacts.Add(&artifact.Artifact{
Name: binary + ".tar.gz",
Path: file,
Type: artifact.UploadableArchive,
@ -69,7 +69,7 @@ func TestPipeFileNotExist(t *testing.T) {
},
)
ctx.Git.CurrentTag = "1.2.3"
ctx.Artifacts.Add(artifact.Artifact{
ctx.Artifacts.Add(&artifact.Artifact{
Name: "nope",
Path: "/nope",
Type: artifact.UploadableBinary,
@ -97,7 +97,7 @@ func TestPipeInvalidNameTemplate(t *testing.T) {
},
)
ctx.Git.CurrentTag = "1.2.3"
ctx.Artifacts.Add(artifact.Artifact{
ctx.Artifacts.Add(&artifact.Artifact{
Name: "whatever",
Type: artifact.UploadableBinary,
})
@ -122,7 +122,7 @@ func TestPipeCouldNotOpenChecksumsTxt(t *testing.T) {
},
)
ctx.Git.CurrentTag = "1.2.3"
ctx.Artifacts.Add(artifact.Artifact{
ctx.Artifacts.Add(&artifact.Artifact{
Name: "whatever",
Type: artifact.UploadableBinary,
})

View File

@ -99,7 +99,7 @@ func doRun(ctx *context.Context) error {
artifact.ByGoarch(docker.Goarch),
artifact.ByGoarm(docker.Goarm),
artifact.ByType(artifact.Binary),
func(a artifact.Artifact) bool {
func(a *artifact.Artifact) bool {
for _, bin := range binaryNames {
if a.ExtraOr("Binary", "").(string) == bin {
return true
@ -125,7 +125,7 @@ func doRun(ctx *context.Context) error {
return g.Wait()
}
func process(ctx *context.Context, docker config.Docker, bins []artifact.Artifact) error {
func process(ctx *context.Context, docker config.Docker, bins []*artifact.Artifact) error {
tmp, err := ioutil.TempDir(ctx.Config.Dist, "goreleaserdocker")
if err != nil {
return errors.Wrap(err, "failed to create temporary dir")
@ -176,7 +176,7 @@ func process(ctx *context.Context, docker config.Docker, bins []artifact.Artifac
return pipe.Skip("prerelease detected with 'auto' push, skipping docker publish")
}
for _, img := range images {
ctx.Artifacts.Add(artifact.Artifact{
ctx.Artifacts.Add(&artifact.Artifact{
Type: artifact.PublishableDockerImage,
Name: img,
Path: img,
@ -262,7 +262,7 @@ func buildCommand(images, flags []string) []string {
return base
}
func dockerPush(ctx *context.Context, image artifact.Artifact) error {
func dockerPush(ctx *context.Context, image *artifact.Artifact) error {
log.WithField("image", image.Name).Info("pushing docker image")
/* #nosec */
var cmd = exec.CommandContext(ctx, "docker", "push", image.Name)

View File

@ -545,7 +545,7 @@ func TestRunPipe(t *testing.T) {
for _, os := range []string{"linux", "darwin"} {
for _, arch := range []string{"amd64", "386"} {
for _, bin := range []string{"mybin", "anotherbin"} {
ctx.Artifacts.Add(artifact.Artifact{
ctx.Artifacts.Add(&artifact.Artifact{
Name: bin,
Path: filepath.Join(dist, "mybin", bin),
Goarch: arch,

View File

@ -118,7 +118,7 @@ func mergeOverrides(fpm config.NFPM, format string) (*config.NFPMOverridables, e
return &overrided, nil
}
func create(ctx *context.Context, fpm config.NFPM, format, arch string, binaries []artifact.Artifact) error {
func create(ctx *context.Context, fpm config.NFPM, format, arch string, binaries []*artifact.Artifact) error {
overrided, err := mergeOverrides(fpm, format)
if err != nil {
return err
@ -195,7 +195,7 @@ func create(ctx *context.Context, fpm config.NFPM, format, arch string, binaries
if err := w.Close(); err != nil {
return errors.Wrap(err, "could not close package file")
}
ctx.Artifacts.Add(artifact.Artifact{
ctx.Artifacts.Add(&artifact.Artifact{
Type: artifact.LinuxPackage,
Name: name + "." + format,
Path: path,

View File

@ -50,7 +50,7 @@ func TestRunPipeInvalidFormat(t *testing.T) {
}
for _, goos := range []string{"linux", "darwin"} {
for _, goarch := range []string{"amd64", "386"} {
ctx.Artifacts.Add(artifact.Artifact{
ctx.Artifacts.Add(&artifact.Artifact{
Name: "mybin",
Path: "whatever",
Goarch: goarch,
@ -118,7 +118,7 @@ func TestRunPipe(t *testing.T) {
ctx.Git = context.GitInfo{CurrentTag: "v1.0.0"}
for _, goos := range []string{"linux", "darwin"} {
for _, goarch := range []string{"amd64", "386"} {
ctx.Artifacts.Add(artifact.Artifact{
ctx.Artifacts.Add(&artifact.Artifact{
Name: "mybin",
Path: binPath,
Goarch: goarch,
@ -153,7 +153,7 @@ func TestInvalidNameTemplate(t *testing.T) {
},
},
}
ctx.Artifacts.Add(artifact.Artifact{
ctx.Artifacts.Add(&artifact.Artifact{
Name: "mybin",
Goos: "linux",
Goarch: "amd64",
@ -178,7 +178,7 @@ func TestNoBuildsFound(t *testing.T) {
},
},
}
ctx.Artifacts.Add(artifact.Artifact{
ctx.Artifacts.Add(&artifact.Artifact{
Name: "mybin",
Goos: "linux",
Goarch: "amd64",
@ -214,7 +214,7 @@ func TestCreateFileDoesntExist(t *testing.T) {
ctx.Git = context.GitInfo{
CurrentTag: "v1.2.3",
}
ctx.Artifacts.Add(artifact.Artifact{
ctx.Artifacts.Add(&artifact.Artifact{
Name: "mybin",
Path: filepath.Join(dist, "mybin", "mybin"),
Goos: "linux",
@ -244,7 +244,7 @@ func TestInvalidConfig(t *testing.T) {
})
ctx.Git.CurrentTag = "v1.2.3"
ctx.Version = "v1.2.3"
ctx.Artifacts.Add(artifact.Artifact{
ctx.Artifacts.Add(&artifact.Artifact{
Name: "mybin",
Path: filepath.Join(dist, "mybin", "mybin"),
Goos: "linux",

View File

@ -126,7 +126,7 @@ func TestRunPipe_ModeBinary(t *testing.T) {
"PUT_PRODUCTION-EU_SECRET": "productionuser-apikey",
}
for _, goos := range []string{"linux", "darwin"} {
ctx.Artifacts.Add(artifact.Artifact{
ctx.Artifacts.Add(&artifact.Artifact{
Name: "mybin",
Path: binPath,
Goarch: "amd64",
@ -165,12 +165,12 @@ func TestRunPipe_ModeArchive(t *testing.T) {
"PUT_PRODUCTION_SECRET": "deployuser-secret",
}
ctx.Version = "1.0.0"
ctx.Artifacts.Add(artifact.Artifact{
ctx.Artifacts.Add(&artifact.Artifact{
Type: artifact.UploadableArchive,
Name: "bin.tar.gz",
Path: tarfile.Name(),
})
ctx.Artifacts.Add(artifact.Artifact{
ctx.Artifacts.Add(&artifact.Artifact{
Type: artifact.LinuxPackage,
Name: "bin.deb",
Path: debfile.Name(),
@ -227,7 +227,7 @@ func TestRunPipe_ArtifactoryDown(t *testing.T) {
ctx.Env = map[string]string{
"PUT_PRODUCTION_SECRET": "deployuser-secret",
}
ctx.Artifacts.Add(artifact.Artifact{
ctx.Artifacts.Add(&artifact.Artifact{
Type: artifact.UploadableArchive,
Name: "bin.tar.gz",
Path: tarfile.Name(),
@ -259,7 +259,7 @@ func TestRunPipe_TargetTemplateError(t *testing.T) {
ctx.Env = map[string]string{
"PUT_PRODUCTION_SECRET": "deployuser-secret",
}
ctx.Artifacts.Add(artifact.Artifact{
ctx.Artifacts.Add(&artifact.Artifact{
Name: "mybin",
Path: binPath,
Goarch: "amd64",
@ -310,7 +310,7 @@ func TestRunPipe_BadCredentials(t *testing.T) {
ctx.Env = map[string]string{
"PUT_PRODUCTION_SECRET": "deployuser-secret",
}
ctx.Artifacts.Add(artifact.Artifact{
ctx.Artifacts.Add(&artifact.Artifact{
Name: "mybin",
Path: binPath,
Goarch: "amd64",
@ -339,7 +339,7 @@ func TestRunPipe_FileNotFound(t *testing.T) {
ctx.Env = map[string]string{
"PUT_PRODUCTION_SECRET": "deployuser-secret",
}
ctx.Artifacts.Add(artifact.Artifact{
ctx.Artifacts.Add(&artifact.Artifact{
Name: "mybin",
Path: "archivetest/dist/mybin/mybin",
Goarch: "amd64",
@ -376,7 +376,7 @@ func TestRunPipe_UnparsableTarget(t *testing.T) {
ctx.Env = map[string]string{
"PUT_PRODUCTION_SECRET": "deployuser-secret",
}
ctx.Artifacts.Add(artifact.Artifact{
ctx.Artifacts.Add(&artifact.Artifact{
Name: "mybin",
Path: binPath,
Goarch: "amd64",
@ -431,7 +431,7 @@ func TestRunPipe_DirUpload(t *testing.T) {
ctx.Env = map[string]string{
"PUT_PRODUCTION_SECRET": "deployuser-secret",
}
ctx.Artifacts.Add(artifact.Artifact{
ctx.Artifacts.Add(&artifact.Artifact{
Name: "mybin",
Path: filepath.Dir(binPath),
Goarch: "amd64",

View File

@ -22,7 +22,7 @@ func TestDescribeBody(t *testing.T) {
"goreleaser/goreleaser:latest",
"goreleaser/godownloader:v0.1.0",
} {
ctx.Artifacts.Add(artifact.Artifact{
ctx.Artifacts.Add(&artifact.Artifact{
Name: d,
Type: artifact.DockerImage,
})

View File

@ -135,7 +135,7 @@ func doPublish(ctx *context.Context, client client.Client) error {
return g.Wait()
}
func upload(ctx *context.Context, client client.Client, releaseID string, artifact artifact.Artifact) error {
func upload(ctx *context.Context, client client.Client, releaseID string, artifact *artifact.Artifact) error {
file, err := os.Open(artifact.Path)
if err != nil {
return err

View File

@ -37,12 +37,12 @@ func TestRunPipe(t *testing.T) {
}
var ctx = context.New(config)
ctx.Git = context.GitInfo{CurrentTag: "v1.0.0"}
ctx.Artifacts.Add(artifact.Artifact{
ctx.Artifacts.Add(&artifact.Artifact{
Type: artifact.UploadableArchive,
Name: "bin.tar.gz",
Path: tarfile.Name(),
})
ctx.Artifacts.Add(artifact.Artifact{
ctx.Artifacts.Add(&artifact.Artifact{
Type: artifact.LinuxPackage,
Name: "bin.deb",
Path: debfile.Name(),
@ -85,7 +85,7 @@ func TestRunPipeWithFileThatDontExist(t *testing.T) {
}
var ctx = context.New(config)
ctx.Git = context.GitInfo{CurrentTag: "v1.0.0"}
ctx.Artifacts.Add(artifact.Artifact{
ctx.Artifacts.Add(&artifact.Artifact{
Type: artifact.UploadableArchive,
Name: "bin.tar.gz",
Path: "/nope/nope/nope",
@ -111,7 +111,7 @@ func TestRunPipeUploadFailure(t *testing.T) {
}
var ctx = context.New(config)
ctx.Git = context.GitInfo{CurrentTag: "v1.0.0"}
ctx.Artifacts.Add(artifact.Artifact{
ctx.Artifacts.Add(&artifact.Artifact{
Type: artifact.UploadableArchive,
Name: "bin.tar.gz",
Path: tarfile.Name(),
@ -139,7 +139,7 @@ func TestRunPipeUploadRetry(t *testing.T) {
}
var ctx = context.New(config)
ctx.Git = context.GitInfo{CurrentTag: "v1.0.0"}
ctx.Artifacts.Add(artifact.Artifact{
ctx.Artifacts.Add(&artifact.Artifact{
Type: artifact.UploadableArchive,
Name: "bin.tar.gz",
Path: tarfile.Name(),

View File

@ -77,7 +77,7 @@ func TestUpload(t *testing.T) {
},
})
ctx.Git = context.GitInfo{CurrentTag: "v1.0.0"}
ctx.Artifacts.Add(artifact.Artifact{
ctx.Artifacts.Add(&artifact.Artifact{
Type: artifact.UploadableArchive,
Name: "bin.tar.gz",
Path: tgzpath,
@ -85,7 +85,7 @@ func TestUpload(t *testing.T) {
"ID": "foo",
},
})
ctx.Artifacts.Add(artifact.Artifact{
ctx.Artifacts.Add(&artifact.Artifact{
Type: artifact.LinuxPackage,
Name: "bin.deb",
Path: debpath,
@ -123,12 +123,12 @@ func TestUploadCustomBucketID(t *testing.T) {
},
})
ctx.Git = context.GitInfo{CurrentTag: "v1.0.0"}
ctx.Artifacts.Add(artifact.Artifact{
ctx.Artifacts.Add(&artifact.Artifact{
Type: artifact.UploadableArchive,
Name: "bin.tar.gz",
Path: tgzpath,
})
ctx.Artifacts.Add(artifact.Artifact{
ctx.Artifacts.Add(&artifact.Artifact{
Type: artifact.LinuxPackage,
Name: "bin.deb",
Path: debpath,
@ -162,12 +162,12 @@ func TestUploadInvalidCustomBucketID(t *testing.T) {
},
})
ctx.Git = context.GitInfo{CurrentTag: "v1.0.0"}
ctx.Artifacts.Add(artifact.Artifact{
ctx.Artifacts.Add(&artifact.Artifact{
Type: artifact.UploadableArchive,
Name: "bin.tar.gz",
Path: tgzpath,
})
ctx.Artifacts.Add(artifact.Artifact{
ctx.Artifacts.Add(&artifact.Artifact{
Type: artifact.LinuxPackage,
Name: "bin.deb",
Path: debpath,

View File

@ -120,7 +120,7 @@ type Resource struct {
Hash string `json:"hash"` // the archive checksum
}
func buildManifest(ctx *context.Context, artifacts []artifact.Artifact) (bytes.Buffer, error) {
func buildManifest(ctx *context.Context, artifacts []*artifact.Artifact) (bytes.Buffer, error) {
var result bytes.Buffer
var manifest = Manifest{
Version: ctx.Version,
@ -164,10 +164,10 @@ func buildManifest(ctx *context.Context, artifacts []artifact.Artifact) (bytes.B
return result, err
}
func binaries(a artifact.Artifact) []string {
func binaries(a *artifact.Artifact) []string {
// nolint: prealloc
var bins []string
for _, b := range a.ExtraOr("Builds", []artifact.Artifact{}).([]artifact.Artifact) {
for _, b := range a.ExtraOr("Builds", []*artifact.Artifact{}).([]*artifact.Artifact) {
bins = append(bins, b.ExtraOr("Binary", "").(string)+".exe")
}
return bins

View File

@ -81,7 +81,7 @@ func Test_doRun(t *testing.T) {
tests := []struct {
name string
args args
artifacts []artifact.Artifact
artifacts []*artifact.Artifact
assertError errChecker
}{
{
@ -120,7 +120,7 @@ func Test_doRun(t *testing.T) {
},
&DummyClient{},
},
[]artifact.Artifact{
[]*artifact.Artifact{
{Name: "foo_1.0.1_windows_amd64.tar.gz", Goos: "windows", Goarch: "amd64", Path: file},
{Name: "foo_1.0.1_windows_386.tar.gz", Goos: "windows", Goarch: "386", Path: file},
},
@ -163,7 +163,7 @@ func Test_doRun(t *testing.T) {
},
&DummyClient{},
},
[]artifact.Artifact{
[]*artifact.Artifact{
{Name: "foo_1.0.1_windows_amd64.tar.gz", Goos: "windows", Goarch: "amd64", Path: file},
{Name: "foo_1.0.1_windows_386.tar.gz", Goos: "windows", Goarch: "386", Path: file},
},
@ -205,7 +205,7 @@ func Test_doRun(t *testing.T) {
},
&DummyClient{},
},
[]artifact.Artifact{
[]*artifact.Artifact{
{Name: "foo_1.0.1_linux_amd64.tar.gz", Goos: "linux", Goarch: "amd64"},
{Name: "foo_1.0.1_linux_386.tar.gz", Goos: "linux", Goarch: "386"},
},
@ -239,7 +239,7 @@ func Test_doRun(t *testing.T) {
},
&DummyClient{},
},
[]artifact.Artifact{
[]*artifact.Artifact{
{Name: "foo_1.0.1_windows_amd64.tar.gz", Goos: "windows", Goarch: "amd64"},
{Name: "foo_1.0.1_windows_386.tar.gz", Goos: "windows", Goarch: "386"},
},
@ -282,7 +282,7 @@ func Test_doRun(t *testing.T) {
},
&DummyClient{},
},
[]artifact.Artifact{
[]*artifact.Artifact{
{Name: "foo_1.0.1_windows_amd64.tar.gz", Goos: "windows", Goarch: "amd64", Path: file},
{Name: "foo_1.0.1_windows_386.tar.gz", Goos: "windows", Goarch: "386", Path: file},
},
@ -321,7 +321,7 @@ func Test_doRun(t *testing.T) {
},
&DummyClient{},
},
[]artifact.Artifact{
[]*artifact.Artifact{
{Name: "foo_1.0.1_windows_amd64.tar.gz", Goos: "windows", Goarch: "amd64", Path: file},
{Name: "foo_1.0.1_windows_386.tar.gz", Goos: "windows", Goarch: "386", Path: file},
},
@ -360,7 +360,7 @@ func Test_doRun(t *testing.T) {
},
&DummyClient{},
},
[]artifact.Artifact{
[]*artifact.Artifact{
{Name: "foo_1.0.1_windows_amd64.tar.gz", Goos: "windows", Goarch: "amd64"},
{Name: "foo_1.0.1_windows_386.tar.gz", Goos: "windows", Goarch: "386"},
},
@ -403,7 +403,7 @@ func Test_doRun(t *testing.T) {
},
&DummyClient{},
},
[]artifact.Artifact{
[]*artifact.Artifact{
{Name: "foo_1.0.1_windows_amd64.tar.gz", Goos: "windows", Goarch: "amd64", Path: file},
{Name: "foo_1.0.1_windows_386.tar.gz", Goos: "windows", Goarch: "386", Path: file},
},
@ -513,14 +513,14 @@ func Test_buildManifest(t *testing.T) {
var ctx = tt.ctx
err := Pipe{}.Default(ctx)
require.NoError(t, err)
out, err := buildManifest(ctx, []artifact.Artifact{
out, err := buildManifest(ctx, []*artifact.Artifact{
{
Name: "foo_1.0.1_windows_amd64.tar.gz",
Goos: "windows",
Goarch: "amd64",
Path: file,
Extra: map[string]interface{}{
"Builds": []artifact.Artifact{
"Builds": []*artifact.Artifact{
{
Extra: map[string]interface{}{
"Binary": "foo",
@ -540,7 +540,7 @@ func Test_buildManifest(t *testing.T) {
Goarch: "386",
Path: file,
Extra: map[string]interface{}{
"Builds": []artifact.Artifact{
"Builds": []*artifact.Artifact{
{
Extra: map[string]interface{}{
"Binary": "foo",

View File

@ -84,18 +84,18 @@ func (Pipe) Run(ctx *context.Context) error {
return g.Wait()
}
func sign(ctx *context.Context, cfg config.Sign, artifacts []artifact.Artifact) error {
func sign(ctx *context.Context, cfg config.Sign, artifacts []*artifact.Artifact) error {
for _, a := range artifacts {
artifact, err := signone(ctx, cfg, a)
if err != nil {
return err
}
ctx.Artifacts.Add(*artifact)
ctx.Artifacts.Add(artifact)
}
return nil
}
func signone(ctx *context.Context, cfg config.Sign, a artifact.Artifact) (*artifact.Artifact, error) {
func signone(ctx *context.Context, cfg config.Sign, a *artifact.Artifact) (*artifact.Artifact, error) {
env := ctx.Env
env["artifact"] = a.Path
env["signature"] = expand(cfg.Signature, env)

View File

@ -172,27 +172,27 @@ func testSign(t *testing.T, ctx *context.Context, signaturePaths []string, signa
}
assert.NoError(t, ioutil.WriteFile(filepath.Join(tmpdir, "linux_amd64", "artifact4"), []byte("foo"), 0644))
artifacts = append(artifacts, "linux_amd64/artifact4")
ctx.Artifacts.Add(artifact.Artifact{
ctx.Artifacts.Add(&artifact.Artifact{
Name: "artifact1",
Path: filepath.Join(tmpdir, "artifact1"),
Type: artifact.UploadableArchive,
})
ctx.Artifacts.Add(artifact.Artifact{
ctx.Artifacts.Add(&artifact.Artifact{
Name: "artifact2",
Path: filepath.Join(tmpdir, "artifact2"),
Type: artifact.UploadableArchive,
})
ctx.Artifacts.Add(artifact.Artifact{
ctx.Artifacts.Add(&artifact.Artifact{
Name: "artifact3_1.0.0_linux_amd64",
Path: filepath.Join(tmpdir, "artifact3"),
Type: artifact.UploadableBinary,
})
ctx.Artifacts.Add(artifact.Artifact{
ctx.Artifacts.Add(&artifact.Artifact{
Name: "checksum",
Path: filepath.Join(tmpdir, "checksum"),
Type: artifact.Checksum,
})
ctx.Artifacts.Add(artifact.Artifact{
ctx.Artifacts.Add(&artifact.Artifact{
Name: "artifact4_1.0.0_linux_amd64",
Path: filepath.Join(tmpdir, "linux_amd64", "artifact4"),
Type: artifact.UploadableBinary,

View File

@ -149,7 +149,7 @@ func (Pipe) Publish(ctx *context.Context) error {
return g.Wait()
}
func create(ctx *context.Context, snap config.Snapcraft, arch string, binaries []artifact.Artifact) error {
func create(ctx *context.Context, snap config.Snapcraft, arch string, binaries []*artifact.Artifact) error {
var log = log.WithField("arch", arch)
folder, err := tmpl.New(ctx).
WithArtifact(binaries[0], snap.Replacements).
@ -266,7 +266,7 @@ func create(ctx *context.Context, snap config.Snapcraft, arch string, binaries [
if !snap.Publish {
return nil
}
ctx.Artifacts.Add(artifact.Artifact{
ctx.Artifacts.Add(&artifact.Artifact{
Type: artifact.PublishableSnapcraft,
Name: folder + ".snap",
Path: snapFile,
@ -279,7 +279,7 @@ func create(ctx *context.Context, snap config.Snapcraft, arch string, binaries [
const reviewWaitMsg = `Waiting for previous upload(s) to complete their review process.`
func push(ctx *context.Context, snap artifact.Artifact) error {
func push(ctx *context.Context, snap *artifact.Artifact) error {
var log = log.WithField("snap", snap.Name)
log.Info("pushing snap")
// TODO: customize --release based on snap.Grade?

View File

@ -334,7 +334,7 @@ func TestDefault(t *testing.T) {
func TestPublish(t *testing.T) {
var ctx = context.New(config.Project{})
ctx.Artifacts.Add(artifact.Artifact{
ctx.Artifacts.Add(&artifact.Artifact{
Name: "mybin",
Path: "nope.snap",
Goarch: "amd64",
@ -375,7 +375,7 @@ func addBinaries(t *testing.T, ctx *context.Context, name, dist, dest string) {
var binPath = filepath.Join(dist, folder, name)
_, err := os.Create(binPath)
assert.NoError(t, err)
ctx.Artifacts.Add(artifact.Artifact{
ctx.Artifacts.Add(&artifact.Artifact{
Name: dest,
Path: binPath,
Goarch: goarch,

View File

@ -82,7 +82,7 @@ func (t *Template) WithEnv(e map[string]string) *Template {
}
// WithArtifact populates fields from the artifact and replacements
func (t *Template) WithArtifact(a artifact.Artifact, replacements map[string]string) *Template {
func (t *Template) WithArtifact(a *artifact.Artifact, replacements map[string]string) *Template {
var bin = a.Extra[binary]
if bin == nil {
bin = t.fields[projectName]

View File

@ -45,7 +45,7 @@ func TestWithArtifact(t *testing.T) {
t.Run(expect, func(tt *testing.T) {
tt.Parallel()
result, err := New(ctx).WithArtifact(
artifact.Artifact{
&artifact.Artifact{
Name: "not-this-binary",
Goarch: "amd64",
Goos: "linux",
@ -64,7 +64,7 @@ func TestWithArtifact(t *testing.T) {
t.Run("artifact without binary name", func(tt *testing.T) {
tt.Parallel()
result, err := New(ctx).WithArtifact(
artifact.Artifact{
&artifact.Artifact{
Name: "another-binary",
Goarch: "amd64",
Goos: "linux",