You've already forked goreleaser
mirror of
https://github.com/goreleaser/goreleaser.git
synced 2025-11-25 22:41:44 +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:
committed by
GitHub
parent
f41ac3cf9e
commit
2d8823b8cf
@@ -49,10 +49,11 @@ type Metadata struct {
|
|||||||
|
|
||||||
// AppMetadata for the binaries that will be in the snap package.
|
// AppMetadata for the binaries that will be in the snap package.
|
||||||
type AppMetadata struct {
|
type AppMetadata struct {
|
||||||
Command string
|
Command string
|
||||||
Plugs []string `yaml:",omitempty"`
|
Plugs []string `yaml:",omitempty"`
|
||||||
Daemon string `yaml:",omitempty"`
|
Daemon string `yaml:",omitempty"`
|
||||||
Completer 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 }}"
|
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,
|
command,
|
||||||
config.Args,
|
config.Args,
|
||||||
}, " ")),
|
}, " ")),
|
||||||
Plugs: config.Plugs,
|
Plugs: config.Plugs,
|
||||||
Daemon: config.Daemon,
|
Daemon: config.Daemon,
|
||||||
|
RestartCondition: config.RestartCondition,
|
||||||
}
|
}
|
||||||
|
|
||||||
if config.Completer != "" {
|
if config.Completer != "" {
|
||||||
|
|||||||
@@ -202,9 +202,10 @@ func TestRunPipeMetadata(t *testing.T) {
|
|||||||
Description: "test description",
|
Description: "test description",
|
||||||
Apps: map[string]config.SnapcraftAppMetadata{
|
Apps: map[string]config.SnapcraftAppMetadata{
|
||||||
"mybin": {
|
"mybin": {
|
||||||
Plugs: []string{"home", "network", "personal-files"},
|
Plugs: []string{"home", "network", "personal-files"},
|
||||||
Daemon: "simple",
|
Daemon: "simple",
|
||||||
Args: "--foo --bar",
|
Args: "--foo --bar",
|
||||||
|
RestartCondition: "always",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Plugs: map[string]interface{}{
|
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, []string{"home", "network", "personal-files"}, metadata.Apps["mybin"].Plugs)
|
||||||
require.Equal(t, "simple", metadata.Apps["mybin"].Daemon)
|
require.Equal(t, "simple", metadata.Apps["mybin"].Daemon)
|
||||||
require.Equal(t, "mybin --foo --bar", metadata.Apps["mybin"].Command)
|
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) {
|
func TestNoSnapcraftInPath(t *testing.T) {
|
||||||
|
|||||||
@@ -353,11 +353,12 @@ type Sign struct {
|
|||||||
|
|
||||||
// SnapcraftAppMetadata for the binaries that will be in the snap package.
|
// SnapcraftAppMetadata for the binaries that will be in the snap package.
|
||||||
type SnapcraftAppMetadata struct {
|
type SnapcraftAppMetadata struct {
|
||||||
Plugs []string
|
Plugs []string
|
||||||
Daemon string
|
Daemon string
|
||||||
Args string
|
Args string
|
||||||
Completer string `yaml:",omitempty"`
|
Completer string `yaml:",omitempty"`
|
||||||
Command string `yaml:"command"`
|
Command string `yaml:"command"`
|
||||||
|
RestartCondition string `yaml:"restart_condition,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Snapcraft config.
|
// Snapcraft config.
|
||||||
|
|||||||
@@ -128,6 +128,11 @@ snapcrafts:
|
|||||||
# Defaults is the app name.
|
# Defaults is the app name.
|
||||||
command: bin/drumroll.wrapper
|
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
|
# Allows plugs to be configured. Plugs like system-files and personal-files
|
||||||
# require this.
|
# require this.
|
||||||
# Default is empty.
|
# Default is empty.
|
||||||
|
|||||||
Reference in New Issue
Block a user