fix: unambiguous repo key names, clearer config and key names, and a newer lazysecrets's files no longer stop an older one
This commit is contained in:
1 parent
e28328ef82
commit
ed8ac04b35
16 files changed
+189
-58
No files matched your search
@@ -82,10 +82,10 @@ type Updates struct {
|
||||
AutoCheck *bool `yaml:"autoCheck"`
|
||||
// AutoCheckInterval defaults to 24h.
|
||||
AutoCheckInterval *time.Duration `yaml:"autoCheckInterval"`
|
||||
// UpdateSources are the repositories updates come from, tried in
|
||||
// Sources are the repositories updates come from, tried in
|
||||
// order: on GitHub, or a Gitea or Forgejo server. Defaults to GitHub,
|
||||
// then git.kebcloud.no (update.DefaultServers).
|
||||
UpdateSources []string `yaml:"updateSources"`
|
||||
Sources []string `yaml:"sources"`
|
||||
}
|
||||
|
||||
type LinkHandler struct {
|
||||
@@ -268,9 +268,9 @@ func (c Config) validate(path string) error {
|
||||
if d := c.Updates.AutoCheckInterval; d != nil && *d <= 0 {
|
||||
return fmt.Errorf("%s: updates.autoCheckInterval: %s is not positive (autoCheck: false turns it off)", path, *d)
|
||||
}
|
||||
for i, r := range c.Updates.UpdateSources {
|
||||
for i, r := range c.Updates.Sources {
|
||||
if _, err := update.API(r); err != nil || !strings.HasPrefix(r, "https://") {
|
||||
return fmt.Errorf("%s: updates.updateSources[%d]: %q is not an https:// repository address, like %s", path, i, r, update.GitHubRepo)
|
||||
return fmt.Errorf("%s: updates.sources[%d]: %q is not an https:// repository address, like %s", path, i, r, update.GitHubRepo)
|
||||
}
|
||||
}
|
||||
if k := c.Sharing.Key; k != "" {
|
||||
@@ -284,6 +284,16 @@ func (c Config) validate(path string) error {
|
||||
if n := c.Sharing.KeyRules.MinClasses; n < 0 || n > 4 {
|
||||
return fmt.Errorf("%s: sharing.keyRules.minClasses: %d is not between 1 and 4", path, n)
|
||||
}
|
||||
for name, d := range map[string]time.Duration{
|
||||
"providers.timeout": c.Providers.Timeout,
|
||||
"providers.azure.timeout": c.Providers.Azure.Timeout,
|
||||
"providers.databricks.timeout": c.Providers.Databricks.Timeout,
|
||||
"providers.repos.timeout": c.Providers.Repos.Timeout,
|
||||
} {
|
||||
if d < 0 {
|
||||
return fmt.Errorf("%s: %s: %s is negative", path, name, d)
|
||||
}
|
||||
}
|
||||
for i, v := range c.Providers.Azure.Vaults {
|
||||
if !strings.HasPrefix(v, "https://") {
|
||||
return fmt.Errorf("%s: providers.azure.vaults[%d]: %q is not an https:// vault URL", path, i, v)
|
||||
|
||||
@@ -75,9 +75,10 @@ func TestLoadRejectsMistakes(t *testing.T) {
|
||||
"old layout": "azure:\n vaults: [https://kv.vault.azure.net/]\n",
|
||||
"flat keys": "icons: false\n",
|
||||
"duration": "providers:\n timeout: soon\n",
|
||||
"negative": "providers:\n repos:\n timeout: -1s\n",
|
||||
"view": "ui:\n sourcesView: tree\n",
|
||||
"sources": "updates:\n updateSources: [git.example.com/team/lazysecrets]\n",
|
||||
"http": "updates:\n updateSources: [http://git.example.com/team/lazysecrets]\n",
|
||||
"sources": "updates:\n sources: [git.example.com/team/lazysecrets]\n",
|
||||
"http": "updates:\n sources: [http://git.example.com/team/lazysecrets]\n",
|
||||
"interval": "updates:\n autoCheckInterval: 0s\n",
|
||||
"share key": "sharing:\n key: https://kv.vault.azure.net/\n",
|
||||
"workspace": "sharing:\n key: \"{{secrets/team/env-share}}\"\n",
|
||||
@@ -131,8 +132,8 @@ theme:
|
||||
}
|
||||
|
||||
func TestUpdates(t *testing.T) {
|
||||
c, err := Load(write(t, "updates:\n autoCheck: false\n autoCheckInterval: 168h\n updateSources: [https://git.example.com/team/lazysecrets]\n"))
|
||||
if err != nil || On(c.Updates.AutoCheck) || *c.Updates.AutoCheckInterval != 7*24*time.Hour || len(c.Updates.UpdateSources) != 1 {
|
||||
c, err := Load(write(t, "updates:\n autoCheck: false\n autoCheckInterval: 168h\n sources: [https://git.example.com/team/lazysecrets]\n"))
|
||||
if err != nil || On(c.Updates.AutoCheck) || *c.Updates.AutoCheckInterval != 7*24*time.Hour || len(c.Updates.Sources) != 1 {
|
||||
t.Errorf("updates = %+v, %v", c.Updates, err)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user