mirror of
https://github.com/crazy-max/diun.git
synced 2025-12-28 16:06:32 +01:00
fix defaults not handled by yaml configuration
This commit is contained in:
@@ -3,7 +3,6 @@ package model
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/crazy-max/diun/v4/pkg/registry"
|
||||
"github.com/crazy-max/diun/v4/pkg/utl"
|
||||
)
|
||||
|
||||
@@ -16,7 +15,7 @@ type Watch struct {
|
||||
RunOnStartup *bool `yaml:"runOnStartup,omitempty" json:"runOnStartup,omitempty" validate:"required"`
|
||||
CompareDigest *bool `yaml:"compareDigest,omitempty" json:"compareDigest,omitempty" validate:"required"`
|
||||
Healthchecks *Healthchecks `yaml:"healthchecks,omitempty" json:"healthchecks,omitempty"`
|
||||
ImageDefaults *Image `yaml:"defaults,omitempty" json:"defaults,omitempty"`
|
||||
ImageDefaults *ImageDefaults `yaml:"imageDefaults,omitempty" json:"imageDefaults,omitempty"`
|
||||
}
|
||||
|
||||
// GetDefaults gets the default values
|
||||
@@ -33,8 +32,4 @@ func (s *Watch) SetDefaults() {
|
||||
s.FirstCheckNotif = utl.NewFalse()
|
||||
s.RunOnStartup = utl.NewTrue()
|
||||
s.CompareDigest = utl.NewTrue()
|
||||
s.ImageDefaults = &Image{
|
||||
NotifyOn: NotifyOnDefaults,
|
||||
SortTags: registry.SortTagReverse,
|
||||
}
|
||||
}
|
||||
|
||||
31
internal/model/watch_imagedefaults.go
Normal file
31
internal/model/watch_imagedefaults.go
Normal file
@@ -0,0 +1,31 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"github.com/crazy-max/diun/v4/pkg/registry"
|
||||
"github.com/crazy-max/diun/v4/pkg/utl"
|
||||
)
|
||||
|
||||
// ImageDefaults holds data necessary for image defaults configuration
|
||||
type ImageDefaults struct {
|
||||
WatchRepo *bool `yaml:"watchRepo,omitempty" json:"watchRepo,omitempty"`
|
||||
NotifyOn []NotifyOn `yaml:"notifyOn,omitempty" json:"notifyOn,omitempty"`
|
||||
MaxTags int `yaml:"maxTags,omitempty" json:"maxTags,omitempty"`
|
||||
SortTags registry.SortTag `yaml:"sortTags,omitempty" json:"sortTags,omitempty"`
|
||||
IncludeTags []string `yaml:"includeTags,omitempty" json:"includeTags,omitempty"`
|
||||
ExcludeTags []string `yaml:"excludeTags,omitempty" json:"excludeTags,omitempty"`
|
||||
Metadata map[string]string `yaml:"metadata,omitempty" json:"metadata,omitempty"`
|
||||
}
|
||||
|
||||
// GetDefaults gets the default values
|
||||
func (s *ImageDefaults) GetDefaults() *Watch {
|
||||
n := &Watch{}
|
||||
n.SetDefaults()
|
||||
return n
|
||||
}
|
||||
|
||||
// SetDefaults sets the default values
|
||||
func (s *ImageDefaults) SetDefaults() {
|
||||
s.WatchRepo = utl.NewFalse()
|
||||
s.NotifyOn = NotifyOnDefaults
|
||||
s.SortTags = registry.SortTagReverse
|
||||
}
|
||||
Reference in New Issue
Block a user