mirror of
https://github.com/goreleaser/goreleaser.git
synced 2025-03-17 20:47:50 +02:00
feat: snap restart-condition (#1837)
* feat: snap restart-condition Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com> * docs: restart-condition Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com>
This commit is contained in:
parent
f41ac3cf9e
commit
2d8823b8cf
@ -49,10 +49,11 @@ type Metadata struct {
|
||||
|
||||
// AppMetadata for the binaries that will be in the snap package.
|
||||
type AppMetadata struct {
|
||||
Command string
|
||||
Plugs []string `yaml:",omitempty"`
|
||||
Daemon string `yaml:",omitempty"`
|
||||
Completer string `yaml:",omitempty"`
|
||||
Command string
|
||||
Plugs []string `yaml:",omitempty"`
|
||||
Daemon string `yaml:",omitempty"`
|
||||
Completer string `yaml:",omitempty"`
|
||||
RestartCondition string `yaml:"restart-condition,omitempty"`
|
||||
}
|
||||
|
||||
const defaultNameTemplate = "{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}{{ if .Mips }}_{{ .Mips }}{{ end }}"
|
||||
@ -255,8 +256,9 @@ func create(ctx *context.Context, snap config.Snapcraft, arch string, binaries [
|
||||
command,
|
||||
config.Args,
|
||||
}, " ")),
|
||||
Plugs: config.Plugs,
|
||||
Daemon: config.Daemon,
|
||||
Plugs: config.Plugs,
|
||||
Daemon: config.Daemon,
|
||||
RestartCondition: config.RestartCondition,
|
||||
}
|
||||
|
||||
if config.Completer != "" {
|
||||
|
@ -202,9 +202,10 @@ func TestRunPipeMetadata(t *testing.T) {
|
||||
Description: "test description",
|
||||
Apps: map[string]config.SnapcraftAppMetadata{
|
||||
"mybin": {
|
||||
Plugs: []string{"home", "network", "personal-files"},
|
||||
Daemon: "simple",
|
||||
Args: "--foo --bar",
|
||||
Plugs: []string{"home", "network", "personal-files"},
|
||||
Daemon: "simple",
|
||||
Args: "--foo --bar",
|
||||
RestartCondition: "always",
|
||||
},
|
||||
},
|
||||
Plugs: map[string]interface{}{
|
||||
@ -231,7 +232,8 @@ func TestRunPipeMetadata(t *testing.T) {
|
||||
require.Equal(t, []string{"home", "network", "personal-files"}, metadata.Apps["mybin"].Plugs)
|
||||
require.Equal(t, "simple", metadata.Apps["mybin"].Daemon)
|
||||
require.Equal(t, "mybin --foo --bar", metadata.Apps["mybin"].Command)
|
||||
require.Equal(t, map[interface{}]interface{}(map[interface{}]interface{}{"read": []interface{}{"$HOME/test"}}), metadata.Plugs["personal-files"])
|
||||
require.Equal(t, map[interface{}]interface{}{"read": []interface{}{"$HOME/test"}}, metadata.Plugs["personal-files"])
|
||||
require.Equal(t, "always", metadata.Apps["mybin"].RestartCondition)
|
||||
}
|
||||
|
||||
func TestNoSnapcraftInPath(t *testing.T) {
|
||||
|
@ -353,11 +353,12 @@ type Sign struct {
|
||||
|
||||
// SnapcraftAppMetadata for the binaries that will be in the snap package.
|
||||
type SnapcraftAppMetadata struct {
|
||||
Plugs []string
|
||||
Daemon string
|
||||
Args string
|
||||
Completer string `yaml:",omitempty"`
|
||||
Command string `yaml:"command"`
|
||||
Plugs []string
|
||||
Daemon string
|
||||
Args string
|
||||
Completer string `yaml:",omitempty"`
|
||||
Command string `yaml:"command"`
|
||||
RestartCondition string `yaml:"restart_condition,omitempty"`
|
||||
}
|
||||
|
||||
// Snapcraft config.
|
||||
|
@ -128,6 +128,11 @@ snapcrafts:
|
||||
# Defaults is the app name.
|
||||
command: bin/drumroll.wrapper
|
||||
|
||||
# Restart condition of the snap.
|
||||
# Defaults to empty.
|
||||
# https://snapcraft.io/docs/snapcraft-yaml-reference
|
||||
restart_condition: "always"
|
||||
|
||||
# Allows plugs to be configured. Plugs like system-files and personal-files
|
||||
# require this.
|
||||
# Default is empty.
|
||||
|
Loading…
x
Reference in New Issue
Block a user