mirror of
https://gitea.com/gitea/runner.git
synced 2026-08-29 23:37:45 +00:00
enhance: improve config, comment out values in example file (#1145)
`config.example.yaml` now has every value commented out, as gitea's `app.example.ini` does, so it documents each option with its default instead of imposing it. Copying it no longer pins values the runner would otherwise pick, and a changed default reaches configs that never named the option. `config init` writes the file to configure: a header comment and no option, so every option keeps its default. It refuses to overwrite an existing config without `--force`, and writes `config.yaml` in the working directory when `-c` is absent. `config set`, `add` and `remove` keep such a file readable. Comments go back to the indentation they were written at, which the encoder drops for a comment block that has no key below it, and a file of only comments keeps its text instead of being emptied by the first edit. Also rewrote the config docs sections for clarity. Reviewed-on: https://gitea.com/gitea/runner/pulls/1145 Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com> Reviewed-by: bircni <bircni@icloud.com> Co-authored-by: silverwind <me@silverwind.io>
This commit is contained in:
@@ -348,12 +348,23 @@ cache:
|
||||
assert.Contains(t, err.Error(), "contains no secret")
|
||||
}
|
||||
|
||||
// The shipped example must parse, and every key in it must be one the config knows.
|
||||
func TestLoadDefault_ExampleConfigParses(t *testing.T) {
|
||||
// The shipped configs must parse, hold no key the config does not know, and leave
|
||||
// every option at its default, as all of their values are commented out.
|
||||
func TestLoadDefault_ShippedConfigsChangeNothing(t *testing.T) {
|
||||
hook := test.NewGlobal()
|
||||
defer hook.Reset()
|
||||
|
||||
_, err := LoadDefault("config.example.yaml")
|
||||
defaults, err := LoadDefault("")
|
||||
require.NoError(t, err)
|
||||
|
||||
dir := t.TempDir()
|
||||
for name, content := range map[string][]byte{"config.example.yaml": Example, "minimal.yaml": []byte(Minimal)} {
|
||||
file := filepath.Join(dir, name)
|
||||
require.NoError(t, os.WriteFile(file, content, 0o600))
|
||||
|
||||
cfg, err := LoadDefault(file)
|
||||
require.NoError(t, err, name)
|
||||
assert.Equal(t, defaults, cfg, name)
|
||||
}
|
||||
assert.Empty(t, hook.AllEntries())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user