mirror of
https://github.com/goreleaser/goreleaser.git
synced 2025-01-24 04:16:27 +02:00
Merge branch 'master' into support-github-enterprise
This commit is contained in:
commit
1cd2e5e625
@ -15,6 +15,7 @@ checksum:
|
||||
name_template: '{{ .ProjectName }}_checksums.txt'
|
||||
dockers:
|
||||
- image: goreleaser/goreleaser
|
||||
latest: true
|
||||
archive:
|
||||
name_template: '{{ .ProjectName }}_{{ .Os }}_{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}'
|
||||
replacements:
|
||||
|
@ -1,7 +1,7 @@
|
||||
dist: trusty
|
||||
sudo: required
|
||||
language: go
|
||||
go: 1.8.3
|
||||
go: 1.9
|
||||
services:
|
||||
- docker
|
||||
install:
|
||||
|
15
Makefile
15
Makefile
@ -25,20 +25,7 @@ fmt:
|
||||
|
||||
# Run all the linters
|
||||
lint:
|
||||
gometalinter --vendor --disable-all \
|
||||
--enable=deadcode \
|
||||
--enable=ineffassign \
|
||||
--enable=gosimple \
|
||||
--enable=staticcheck \
|
||||
--enable=gofmt \
|
||||
--enable=goimports \
|
||||
--enable=dupl \
|
||||
--enable=misspell \
|
||||
--enable=errcheck \
|
||||
--enable=vet \
|
||||
--enable=vetshadow \
|
||||
--deadline=10m \
|
||||
./...
|
||||
gometalinter --vendor ./...
|
||||
|
||||
# Run all the tests and code checks
|
||||
ci: test lint
|
||||
|
@ -24,7 +24,7 @@ func calculate(hash hash.Hash, path string) (result string, err error) {
|
||||
return doCalculate(hash, file)
|
||||
}
|
||||
|
||||
func doCalculate(hash hash.Hash, file *os.File) (result string, err error) {
|
||||
func doCalculate(hash hash.Hash, file io.Reader) (result string, err error) {
|
||||
_, err = io.Copy(hash, file)
|
||||
if err != nil {
|
||||
return
|
||||
|
@ -170,6 +170,7 @@ type Docker struct {
|
||||
Goarm string `yaml:",omitempty"`
|
||||
Image string `yaml:",omitempty"`
|
||||
Dockerfile string `yaml:",omitempty"`
|
||||
Latest bool `yaml:",omitempty"`
|
||||
|
||||
// Capture all undefined fields and should be empty after loading
|
||||
XXX map[string]interface{} `yaml:",inline"`
|
||||
|
@ -35,6 +35,7 @@ type Context struct {
|
||||
Git GitInfo
|
||||
Binaries map[string]map[string][]Binary
|
||||
Artifacts []string
|
||||
Dockers []string
|
||||
ReleaseNotes string
|
||||
Version string
|
||||
Validate bool
|
||||
@ -45,6 +46,7 @@ type Context struct {
|
||||
}
|
||||
|
||||
var artifactsLock sync.Mutex
|
||||
var dockersLock sync.Mutex
|
||||
var binariesLock sync.Mutex
|
||||
|
||||
// AddArtifact adds a file to upload list
|
||||
@ -56,6 +58,14 @@ func (ctx *Context) AddArtifact(file string) {
|
||||
log.WithField("artifact", file).Info("new release artifact")
|
||||
}
|
||||
|
||||
// AddDocker adds a docker image to the docker images list
|
||||
func (ctx *Context) AddDocker(image string) {
|
||||
dockersLock.Lock()
|
||||
defer dockersLock.Unlock()
|
||||
ctx.Dockers = append(ctx.Dockers, image)
|
||||
log.WithField("image", image).Info("new docker image")
|
||||
}
|
||||
|
||||
// AddBinary adds a built binary to the current context
|
||||
func (ctx *Context) AddBinary(platform, folder, name, path string) {
|
||||
binariesLock.Lock()
|
||||
|
@ -8,19 +8,24 @@ import (
|
||||
"golang.org/x/sync/errgroup"
|
||||
)
|
||||
|
||||
func TestMultipleArtifactAdds(t *testing.T) {
|
||||
func TestMultipleAdds(t *testing.T) {
|
||||
var assert = assert.New(t)
|
||||
var list = []string{
|
||||
var artifacts = []string{
|
||||
"dist/a",
|
||||
"dist/b",
|
||||
"dist/c",
|
||||
"dist/d",
|
||||
}
|
||||
var dockerfiles = []string{
|
||||
"a/b:1.0.0",
|
||||
"c/d:2.0.0",
|
||||
"e/f:3.0.0",
|
||||
}
|
||||
var ctx = New(config.Project{
|
||||
Dist: "dist",
|
||||
})
|
||||
var g errgroup.Group
|
||||
for _, f := range list {
|
||||
for _, f := range artifacts {
|
||||
f := f
|
||||
g.Go(func() error {
|
||||
ctx.AddArtifact(f)
|
||||
@ -28,8 +33,18 @@ func TestMultipleArtifactAdds(t *testing.T) {
|
||||
})
|
||||
}
|
||||
assert.NoError(g.Wait())
|
||||
assert.Len(ctx.Artifacts, len(list))
|
||||
for _, d := range dockerfiles {
|
||||
d := d
|
||||
g.Go(func() error {
|
||||
ctx.AddDocker(d)
|
||||
return nil
|
||||
})
|
||||
}
|
||||
assert.NoError(g.Wait())
|
||||
assert.Len(ctx.Artifacts, len(artifacts))
|
||||
assert.Contains(ctx.Artifacts, "a", "b", "c", "d")
|
||||
assert.Len(ctx.Dockers, len(dockerfiles))
|
||||
assert.Contains(ctx.Dockers, "a/b:1.0.0", "c/d:2.0.0", "e/f:3.0.0")
|
||||
}
|
||||
|
||||
func TestMultipleBinaryAdds(t *testing.T) {
|
||||
|
@ -50,6 +50,8 @@ dockers:
|
||||
image: myuser/myimage
|
||||
# Path to the Dockerfile (from the project root)
|
||||
dockerfile: Dockerfile
|
||||
# Also tag and push myuser/myimage:latest
|
||||
latest: true
|
||||
```
|
||||
|
||||
These settings should allow you to generate multiple docker images, using
|
||||
|
@ -35,8 +35,8 @@ var pipes = []pipeline.Pipe{
|
||||
fpm.Pipe{}, // archive via fpm (deb, rpm, etc)
|
||||
snapcraft.Pipe{}, // archive via snapcraft (snap)
|
||||
checksums.Pipe{}, // checksums of the files
|
||||
release.Pipe{}, // release to github
|
||||
docker.Pipe{}, // create and push docker images
|
||||
release.Pipe{}, // release to github
|
||||
brew.Pipe{}, // push to brew tap
|
||||
}
|
||||
|
||||
|
@ -116,9 +116,6 @@ func TestNameDefaultTemplate(t *testing.T) {
|
||||
},
|
||||
Version: "1.2.3",
|
||||
}
|
||||
type buildTarget struct {
|
||||
goos, goarch, goarm string
|
||||
}
|
||||
for key, target := range map[string]buildtarget.Target{
|
||||
"test_1.2.3_darwin_amd64": buildtarget.New("darwin", "amd64", ""),
|
||||
"test_1.2.3_linux_arm64": buildtarget.New("linux", "arm64", ""),
|
||||
|
@ -57,26 +57,31 @@ func (Pipe) Run(ctx *context.Context) error {
|
||||
}
|
||||
ctx.Config.Brew.Install = strings.Join(installs, "\n")
|
||||
}
|
||||
if len(ctx.Config.Dockers) == 1 {
|
||||
if ctx.Config.Dockers[0].Goos == "" {
|
||||
ctx.Config.Dockers[0].Goos = "linux"
|
||||
}
|
||||
if ctx.Config.Dockers[0].Goarch == "" {
|
||||
ctx.Config.Dockers[0].Goarch = "amd64"
|
||||
}
|
||||
if ctx.Config.Dockers[0].Binary == "" {
|
||||
ctx.Config.Dockers[0].Binary = ctx.Config.Builds[0].Binary
|
||||
}
|
||||
if ctx.Config.Dockers[0].Dockerfile == "" {
|
||||
ctx.Config.Dockers[0].Dockerfile = "Dockerfile"
|
||||
}
|
||||
}
|
||||
|
||||
err := setArchiveDefaults(ctx)
|
||||
setDockerDefaults(ctx)
|
||||
log.WithField("config", ctx.Config).Debug("defaults set")
|
||||
return err
|
||||
}
|
||||
|
||||
func setDockerDefaults(ctx *context.Context) {
|
||||
if len(ctx.Config.Dockers) != 1 {
|
||||
return
|
||||
}
|
||||
if ctx.Config.Dockers[0].Goos == "" {
|
||||
ctx.Config.Dockers[0].Goos = "linux"
|
||||
}
|
||||
if ctx.Config.Dockers[0].Goarch == "" {
|
||||
ctx.Config.Dockers[0].Goarch = "amd64"
|
||||
}
|
||||
if ctx.Config.Dockers[0].Binary == "" {
|
||||
ctx.Config.Dockers[0].Binary = ctx.Config.Builds[0].Binary
|
||||
}
|
||||
if ctx.Config.Dockers[0].Dockerfile == "" {
|
||||
ctx.Config.Dockers[0].Dockerfile = "Dockerfile"
|
||||
}
|
||||
}
|
||||
|
||||
func isBrewBuild(build config.Build) bool {
|
||||
for _, ignore := range build.Ignore {
|
||||
if ignore.Goos == "darwin" && ignore.Goarch == "amd64" {
|
||||
|
@ -36,6 +36,10 @@ func (Pipe) Run(ctx *context.Context) error {
|
||||
if err != nil {
|
||||
return ErrNoDocker
|
||||
}
|
||||
return doRun(ctx)
|
||||
}
|
||||
|
||||
func doRun(ctx *context.Context) error {
|
||||
for _, docker := range ctx.Config.Dockers {
|
||||
var imagePlatform = docker.Goos + docker.Goarch + docker.Goarm
|
||||
for platform, groups := range ctx.Binaries {
|
||||
@ -47,7 +51,7 @@ func (Pipe) Run(ctx *context.Context) error {
|
||||
if binary.Name != docker.Binary {
|
||||
continue
|
||||
}
|
||||
var err = doRun(ctx, folder, docker, binary)
|
||||
var err = process(ctx, folder, docker, binary)
|
||||
if err != nil && !pipeline.IsSkip(err) {
|
||||
return err
|
||||
}
|
||||
@ -58,10 +62,11 @@ func (Pipe) Run(ctx *context.Context) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func doRun(ctx *context.Context, folder string, docker config.Docker, binary context.Binary) error {
|
||||
func process(ctx *context.Context, folder string, docker config.Docker, binary context.Binary) error {
|
||||
var root = filepath.Join(ctx.Config.Dist, folder)
|
||||
var dockerfile = filepath.Join(root, filepath.Base(docker.Dockerfile))
|
||||
var image = fmt.Sprintf("%s:%s", docker.Image, ctx.Git.CurrentTag)
|
||||
var image = fmt.Sprintf("%s:%s", docker.Image, ctx.Version)
|
||||
var latest = fmt.Sprintf("%s:latest", docker.Image)
|
||||
|
||||
if err := os.Link(docker.Dockerfile, dockerfile); err != nil {
|
||||
return errors.Wrap(err, "failed to link dockerfile")
|
||||
@ -69,8 +74,13 @@ func doRun(ctx *context.Context, folder string, docker config.Docker, binary con
|
||||
if err := dockerBuild(root, dockerfile, image); err != nil {
|
||||
return err
|
||||
}
|
||||
if docker.Latest {
|
||||
if err := dockerTag(image, latest); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: improve this so it can log into to stdout
|
||||
// TODO: improve this so it can log it to stdout
|
||||
if !ctx.Publish {
|
||||
return pipeline.Skip("--skip-publish is set")
|
||||
}
|
||||
@ -80,7 +90,14 @@ func doRun(ctx *context.Context, folder string, docker config.Docker, binary con
|
||||
if err := dockerPush(image); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
ctx.AddDocker(image)
|
||||
if !docker.Latest {
|
||||
return nil
|
||||
}
|
||||
if err := dockerTag(image, latest); err != nil {
|
||||
return err
|
||||
}
|
||||
return dockerPush(latest)
|
||||
}
|
||||
|
||||
func dockerBuild(root, dockerfile, image string) error {
|
||||
@ -95,6 +112,18 @@ func dockerBuild(root, dockerfile, image string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func dockerTag(image, tag string) error {
|
||||
log.WithField("image", image).WithField("tag", tag).Info("tagging docker image")
|
||||
var cmd = exec.Command("docker", "tag", image, tag)
|
||||
log.WithField("cmd", cmd).Debug("executing")
|
||||
out, err := cmd.CombinedOutput()
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "failed to tag docker image: \n%s", string(out))
|
||||
}
|
||||
log.Debugf("docker tag output: \n%s", string(out))
|
||||
return nil
|
||||
}
|
||||
|
||||
func dockerPush(image string) error {
|
||||
log.WithField("image", image).Info("pushing docker image")
|
||||
var cmd = exec.Command("docker", "push", image)
|
||||
|
@ -24,12 +24,16 @@ func TestRunPipe(t *testing.T) {
|
||||
var binPath = filepath.Join(dist, "mybin", "mybin")
|
||||
_, err = os.Create(binPath)
|
||||
assert.NoError(err)
|
||||
var images = []string{
|
||||
"goreleaser/test_run_pipe:1.0.0",
|
||||
"goreleaser/test_run_pipe:latest",
|
||||
}
|
||||
// this might fail as the image doesnt exist yet, so lets ignore the error
|
||||
_ = exec.Command("docker", "rmi", "goreleaser/test_run_pipe:v1.0.0").Run()
|
||||
for _, img := range images {
|
||||
_ = exec.Command("docker", "rmi", img).Run()
|
||||
}
|
||||
var ctx = &context.Context{
|
||||
Git: context.GitInfo{
|
||||
CurrentTag: "v1.0.0",
|
||||
},
|
||||
Version: "1.0.0",
|
||||
Publish: true,
|
||||
Config: config.Project{
|
||||
ProjectName: "mybin",
|
||||
@ -41,6 +45,7 @@ func TestRunPipe(t *testing.T) {
|
||||
Goarch: "amd64",
|
||||
Dockerfile: "testdata/Dockerfile",
|
||||
Binary: "mybin",
|
||||
Latest: true,
|
||||
},
|
||||
{
|
||||
Image: "goreleaser/test_run_pipe_nope",
|
||||
@ -56,15 +61,17 @@ func TestRunPipe(t *testing.T) {
|
||||
ctx.AddBinary(plat, "mybin", "mybin", binPath)
|
||||
}
|
||||
assert.NoError(Pipe{}.Run(ctx))
|
||||
|
||||
// this might should not fail as the image should have been created when
|
||||
// the step ran
|
||||
assert.NoError(
|
||||
exec.Command("docker", "rmi", "goreleaser/test_run_pipe:v1.0.0").Run(),
|
||||
)
|
||||
for _, img := range images {
|
||||
assert.NoError(exec.Command("docker", "rmi", img).Run())
|
||||
}
|
||||
|
||||
// the test_run_pipe_nope image should not have been created, so deleting
|
||||
// it should fail
|
||||
assert.Error(
|
||||
exec.Command("docker", "rmi", "goreleaser/test_run_pipe_nope:v1.0.0").Run(),
|
||||
exec.Command("docker", "rmi", "goreleaser/test_run_pipe_nope:1.0.0").Run(),
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -35,7 +35,10 @@ func (Pipe) Run(ctx *context.Context) error {
|
||||
if err != nil {
|
||||
return ErrNoFPM
|
||||
}
|
||||
return doRun(ctx)
|
||||
}
|
||||
|
||||
func doRun(ctx *context.Context) error {
|
||||
var g errgroup.Group
|
||||
for _, format := range ctx.Config.FPM.Formats {
|
||||
for platform, groups := range ctx.Binaries {
|
||||
@ -61,6 +64,41 @@ func create(ctx *context.Context, format, folder, arch string, binaries []contex
|
||||
var log = log.WithField("format", format).WithField("arch", arch)
|
||||
log.WithField("file", file).Info("creating fpm archive")
|
||||
|
||||
var options = basicOptions(ctx, format, arch, file)
|
||||
|
||||
for _, binary := range binaries {
|
||||
// This basically tells fpm to put the binary in the /usr/local/bin
|
||||
// binary=/usr/local/bin/binary
|
||||
log.WithField("path", binary.Path).
|
||||
WithField("name", binary.Name).
|
||||
Debug("added binary to fpm package")
|
||||
options = append(options, fmt.Sprintf(
|
||||
"%s=%s",
|
||||
binary.Path,
|
||||
filepath.Join("/usr/local/bin", binary.Name),
|
||||
))
|
||||
}
|
||||
|
||||
for src, dest := range ctx.Config.FPM.Files {
|
||||
log.WithField("src", src).
|
||||
WithField("dest", dest).
|
||||
Debug("added an extra file to the fpm package")
|
||||
options = append(options, fmt.Sprintf(
|
||||
"%s=%s",
|
||||
src,
|
||||
dest,
|
||||
))
|
||||
}
|
||||
|
||||
log.WithField("args", options).Debug("creating fpm package")
|
||||
if out, err := exec.Command("fpm", options...).CombinedOutput(); err != nil {
|
||||
return errors.New(string(out))
|
||||
}
|
||||
ctx.AddArtifact(file)
|
||||
return nil
|
||||
}
|
||||
|
||||
func basicOptions(ctx *context.Context, format, arch, file string) []string {
|
||||
var options = []string{
|
||||
"--input-type", "dir",
|
||||
"--output-type", format,
|
||||
@ -97,35 +135,5 @@ func create(ctx *context.Context, format, folder, arch string, binaries []contex
|
||||
if format == "rpm" {
|
||||
options = append(options, "--rpm-os", "linux")
|
||||
}
|
||||
|
||||
for _, binary := range binaries {
|
||||
// This basically tells fpm to put the binary in the /usr/local/bin
|
||||
// binary=/usr/local/bin/binary
|
||||
log.WithField("path", binary.Path).
|
||||
WithField("name", binary.Name).
|
||||
Debug("added binary to fpm package")
|
||||
options = append(options, fmt.Sprintf(
|
||||
"%s=%s",
|
||||
binary.Path,
|
||||
filepath.Join("/usr/local/bin", binary.Name),
|
||||
))
|
||||
}
|
||||
|
||||
for src, dest := range ctx.Config.FPM.Files {
|
||||
log.WithField("src", src).
|
||||
WithField("dest", dest).
|
||||
Debug("added an extra file to the fpm package")
|
||||
options = append(options, fmt.Sprintf(
|
||||
"%s=%s",
|
||||
src,
|
||||
dest,
|
||||
))
|
||||
}
|
||||
|
||||
log.WithField("args", options).Debug("creating fpm package")
|
||||
if out, err := exec.Command("fpm", options...).CombinedOutput(); err != nil {
|
||||
return errors.New(string(out))
|
||||
}
|
||||
ctx.AddArtifact(file)
|
||||
return nil
|
||||
return options
|
||||
}
|
||||
|
@ -10,23 +10,36 @@ import (
|
||||
|
||||
const bodyTemplate = `{{ .ReleaseNotes }}
|
||||
|
||||
{{- if .DockerImages }}
|
||||
|
||||
Docker images:
|
||||
{{ range $element := .DockerImages }}
|
||||
- {{ . -}}
|
||||
{{ end -}}
|
||||
{{- end }}
|
||||
|
||||
---
|
||||
Automated with [GoReleaser](https://github.com/goreleaser)
|
||||
Built with {{ .GoVersion }}
|
||||
`
|
||||
Built with {{ .GoVersion }}`
|
||||
|
||||
func describeBody(ctx *context.Context) (bytes.Buffer, error) {
|
||||
var out bytes.Buffer
|
||||
bts, err := exec.Command("go", "version").CombinedOutput()
|
||||
if err != nil {
|
||||
return out, err
|
||||
return bytes.Buffer{}, err
|
||||
}
|
||||
return describeBodyVersion(ctx, string(bts))
|
||||
}
|
||||
|
||||
func describeBodyVersion(ctx *context.Context, version string) (bytes.Buffer, error) {
|
||||
var out bytes.Buffer
|
||||
var template = template.Must(template.New("release").Parse(bodyTemplate))
|
||||
err = template.Execute(&out, struct {
|
||||
err := template.Execute(&out, struct {
|
||||
ReleaseNotes, GoVersion string
|
||||
DockerImages []string
|
||||
}{
|
||||
ReleaseNotes: ctx.ReleaseNotes,
|
||||
GoVersion: string(bts),
|
||||
GoVersion: version,
|
||||
DockerImages: ctx.Dockers,
|
||||
})
|
||||
return out, err
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package release
|
||||
|
||||
import (
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"testing"
|
||||
|
||||
@ -13,12 +14,35 @@ func TestDescribeBody(t *testing.T) {
|
||||
var changelog = "\nfeature1: description\nfeature2: other description"
|
||||
var ctx = &context.Context{
|
||||
ReleaseNotes: changelog,
|
||||
Dockers: []string{
|
||||
"goreleaser/goreleaser:0.40.0",
|
||||
"goreleaser/godownloader:0.1.0",
|
||||
},
|
||||
}
|
||||
out, err := describeBody(ctx)
|
||||
out, err := describeBodyVersion(ctx, "go version go1.9 darwin/amd64")
|
||||
assert.NoError(err)
|
||||
assert.Contains(out.String(), changelog)
|
||||
assert.Contains(out.String(), "Automated with [GoReleaser]")
|
||||
assert.Contains(out.String(), "Built with go version go1.")
|
||||
|
||||
bts, err := ioutil.ReadFile("testdata/release1.txt")
|
||||
assert.NoError(err)
|
||||
ioutil.WriteFile("testdata/release1.txt", out.Bytes(), 0755)
|
||||
|
||||
assert.Equal(string(bts), out.String())
|
||||
}
|
||||
|
||||
func TestDescribeBodyNoDockerImages(t *testing.T) {
|
||||
var assert = assert.New(t)
|
||||
var changelog = "\nfeature1: description\nfeature2: other description"
|
||||
var ctx = &context.Context{
|
||||
ReleaseNotes: changelog,
|
||||
}
|
||||
out, err := describeBodyVersion(ctx, "go version go1.9 darwin/amd64")
|
||||
assert.NoError(err)
|
||||
|
||||
bts, err := ioutil.ReadFile("testdata/release2.txt")
|
||||
assert.NoError(err)
|
||||
ioutil.WriteFile("testdata/release2.txt", out.Bytes(), 0755)
|
||||
|
||||
assert.Equal(string(bts), out.String())
|
||||
}
|
||||
|
||||
func TestDontEscapeHTML(t *testing.T) {
|
||||
|
12
pipeline/release/testdata/release1.txt
vendored
Normal file
12
pipeline/release/testdata/release1.txt
vendored
Normal file
@ -0,0 +1,12 @@
|
||||
|
||||
feature1: description
|
||||
feature2: other description
|
||||
|
||||
Docker images:
|
||||
|
||||
- goreleaser/goreleaser:0.40.0
|
||||
- goreleaser/godownloader:0.1.0
|
||||
|
||||
---
|
||||
Automated with [GoReleaser](https://github.com/goreleaser)
|
||||
Built with go version go1.9 darwin/amd64
|
7
pipeline/release/testdata/release2.txt
vendored
Executable file
7
pipeline/release/testdata/release2.txt
vendored
Executable file
@ -0,0 +1,7 @@
|
||||
|
||||
feature1: description
|
||||
feature2: other description
|
||||
|
||||
---
|
||||
Automated with [GoReleaser](https://github.com/goreleaser)
|
||||
Built with go version go1.9 darwin/amd64
|
@ -27,8 +27,8 @@ var ErrNoDescription = errors.New("no description provided for snapcraft")
|
||||
// ErrNoSummary is shown when no summary provided
|
||||
var ErrNoSummary = errors.New("no summary provided for snapcraft")
|
||||
|
||||
// SnapcraftMetadata to generate the snap package
|
||||
type SnapcraftMetadata struct {
|
||||
// Metadata to generate the snap package
|
||||
type Metadata struct {
|
||||
Name string
|
||||
Version string
|
||||
Summary string
|
||||
@ -99,7 +99,7 @@ func create(ctx *context.Context, folder, arch string, binaries []context.Binary
|
||||
var file = filepath.Join(primeDir, "meta", "snap.yaml")
|
||||
log.WithField("file", file).Debug("creating snap metadata")
|
||||
|
||||
var metadata = &SnapcraftMetadata{
|
||||
var metadata = &Metadata{
|
||||
Version: ctx.Version,
|
||||
Summary: ctx.Config.Snapcraft.Summary,
|
||||
Description: ctx.Config.Snapcraft.Description,
|
||||
|
@ -85,10 +85,10 @@ func TestRunPipeWithName(t *testing.T) {
|
||||
assert.NoError(Pipe{}.Run(ctx))
|
||||
yamlFile, err := ioutil.ReadFile(filepath.Join(dist, "testprojectname_linuxamd64", "prime", "meta", "snap.yaml"))
|
||||
assert.NoError(err)
|
||||
var snapcraftMetadata SnapcraftMetadata
|
||||
err = yaml.Unmarshal(yamlFile, &snapcraftMetadata)
|
||||
var metadata Metadata
|
||||
err = yaml.Unmarshal(yamlFile, &metadata)
|
||||
assert.NoError(err)
|
||||
assert.Equal(snapcraftMetadata.Name, "testsnapname")
|
||||
assert.Equal(metadata.Name, "testsnapname")
|
||||
}
|
||||
|
||||
func TestRunPipeWithPlugsAndDaemon(t *testing.T) {
|
||||
@ -119,11 +119,11 @@ func TestRunPipeWithPlugsAndDaemon(t *testing.T) {
|
||||
assert.NoError(Pipe{}.Run(ctx))
|
||||
yamlFile, err := ioutil.ReadFile(filepath.Join(dist, "mybin_linuxamd64", "prime", "meta", "snap.yaml"))
|
||||
assert.NoError(err)
|
||||
var snapcraftMetadata SnapcraftMetadata
|
||||
err = yaml.Unmarshal(yamlFile, &snapcraftMetadata)
|
||||
var metadata Metadata
|
||||
err = yaml.Unmarshal(yamlFile, &metadata)
|
||||
assert.NoError(err)
|
||||
assert.Equal(snapcraftMetadata.Apps["mybin"].Plugs, []string{"home", "network"})
|
||||
assert.Equal(snapcraftMetadata.Apps["mybin"].Daemon, "simple")
|
||||
assert.Equal(metadata.Apps["mybin"].Plugs, []string{"home", "network"})
|
||||
assert.Equal(metadata.Apps["mybin"].Daemon, "simple")
|
||||
}
|
||||
|
||||
func TestNoSnapcraftInPath(t *testing.T) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user