mirror of
https://github.com/goreleaser/goreleaser.git
synced 2025-03-19 20:57:53 +02:00
feat: add args to snapcraft commands
This commit is contained in:
parent
d41703227c
commit
0c67099381
@ -206,6 +206,7 @@ type Sign struct {
|
|||||||
type SnapcraftAppMetadata struct {
|
type SnapcraftAppMetadata struct {
|
||||||
Plugs []string
|
Plugs []string
|
||||||
Daemon string
|
Daemon string
|
||||||
|
Args string
|
||||||
}
|
}
|
||||||
|
|
||||||
// Snapcraft config
|
// Snapcraft config
|
||||||
|
@ -8,6 +8,7 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"github.com/apex/log"
|
"github.com/apex/log"
|
||||||
"golang.org/x/sync/errgroup"
|
"golang.org/x/sync/errgroup"
|
||||||
@ -153,6 +154,10 @@ func create(ctx *context.Context, arch string, binaries []artifact.Artifact) err
|
|||||||
if configAppMetadata, ok := ctx.Config.Snapcraft.Apps[binary.Name]; ok {
|
if configAppMetadata, ok := ctx.Config.Snapcraft.Apps[binary.Name]; ok {
|
||||||
appMetadata.Plugs = configAppMetadata.Plugs
|
appMetadata.Plugs = configAppMetadata.Plugs
|
||||||
appMetadata.Daemon = configAppMetadata.Daemon
|
appMetadata.Daemon = configAppMetadata.Daemon
|
||||||
|
appMetadata.Command = strings.Join([]string{
|
||||||
|
appMetadata.Command,
|
||||||
|
configAppMetadata.Args,
|
||||||
|
}, " ")
|
||||||
}
|
}
|
||||||
metadata.Apps[binary.Name] = appMetadata
|
metadata.Apps[binary.Name] = appMetadata
|
||||||
|
|
||||||
|
@ -107,7 +107,7 @@ func TestRunPipeWithName(t *testing.T) {
|
|||||||
assert.Equal(t, metadata.Name, "testsnapname")
|
assert.Equal(t, metadata.Name, "testsnapname")
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestRunPipeWithPlugsAndDaemon(t *testing.T) {
|
func TestRunPipeMetadata(t *testing.T) {
|
||||||
folder, err := ioutil.TempDir("", "archivetest")
|
folder, err := ioutil.TempDir("", "archivetest")
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
var dist = filepath.Join(folder, "dist")
|
var dist = filepath.Join(folder, "dist")
|
||||||
@ -124,6 +124,7 @@ func TestRunPipeWithPlugsAndDaemon(t *testing.T) {
|
|||||||
"mybin": {
|
"mybin": {
|
||||||
Plugs: []string{"home", "network"},
|
Plugs: []string{"home", "network"},
|
||||||
Daemon: "simple",
|
Daemon: "simple",
|
||||||
|
Args: "--foo --bar",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -138,6 +139,7 @@ func TestRunPipeWithPlugsAndDaemon(t *testing.T) {
|
|||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
assert.Equal(t, metadata.Apps["mybin"].Plugs, []string{"home", "network"})
|
assert.Equal(t, metadata.Apps["mybin"].Plugs, []string{"home", "network"})
|
||||||
assert.Equal(t, metadata.Apps["mybin"].Daemon, "simple")
|
assert.Equal(t, metadata.Apps["mybin"].Daemon, "simple")
|
||||||
|
assert.Equal(t, metadata.Apps["mybin"].Command, "mybin --foo --bar")
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestNoSnapcraftInPath(t *testing.T) {
|
func TestNoSnapcraftInPath(t *testing.T) {
|
||||||
|
@ -239,6 +239,10 @@ snapcraft:
|
|||||||
# If you want your app to be autostarted and to always run in the
|
# If you want your app to be autostarted and to always run in the
|
||||||
# background, you can make it a simple daemon.
|
# background, you can make it a simple daemon.
|
||||||
daemon: simple
|
daemon: simple
|
||||||
|
|
||||||
|
# If you any to pass args to your binary, you can add them with the
|
||||||
|
# args option.
|
||||||
|
args: --foo
|
||||||
```
|
```
|
||||||
|
|
||||||
Note that GoReleaser will not install `snapcraft` nor any of its dependencies
|
Note that GoReleaser will not install `snapcraft` nor any of its dependencies
|
||||||
|
Loading…
x
Reference in New Issue
Block a user