Extend config schema

This commit is contained in:
Jan Eitzinger 2023-05-09 09:34:03 +02:00
parent 09d30d0ead
commit 72f178a088
2 changed files with 28 additions and 7 deletions

View File

@ -32,6 +32,8 @@ type ArchiveBackend interface {
CleanUp() error CleanUp() error
// Compress() error
Iter(loadMetricData bool) <-chan JobContainer Iter(loadMetricData bool) <-chan JobContainer
} }
@ -46,21 +48,31 @@ var useArchive bool
func Init(rawConfig json.RawMessage, disableArchive bool) error { func Init(rawConfig json.RawMessage, disableArchive bool) error {
useArchive = !disableArchive useArchive = !disableArchive
var kind struct {
Kind string `json:"kind"` type retention struct {
Age int `json:"age"`
Policy string `json:"policy"`
Location string `json:"location"`
} }
if err := json.Unmarshal(rawConfig, &kind); err != nil {
var cfg struct {
Kind string `json:"kind"`
Compression int `json:"compression"`
Retention retention `json:"retention"`
}
if err := json.Unmarshal(rawConfig, &cfg); err != nil {
log.Warn("Error while unmarshaling raw config json") log.Warn("Error while unmarshaling raw config json")
return err return err
} }
switch kind.Kind { switch cfg.Kind {
case "file": case "file":
ar = &FsArchive{} ar = &FsArchive{}
// case "s3": // case "s3":
// ar = &S3Archive{} // ar = &S3Archive{}
default: default:
return fmt.Errorf("ARCHIVE/ARCHIVE > unkown archive backend '%s''", kind.Kind) return fmt.Errorf("ARCHIVE/ARCHIVE > unkown archive backend '%s''", cfg.Kind)
} }
version, err := ar.Init(rawConfig) version, err := ar.Init(rawConfig)
@ -69,6 +81,11 @@ func Init(rawConfig json.RawMessage, disableArchive bool) error {
return err return err
} }
log.Infof("Load archive version %d", version) log.Infof("Load archive version %d", version)
switch cfg. {
case condition:
}
return initClusterConfig() return initClusterConfig()
} }

View File

@ -56,6 +56,10 @@
"description": "Path to job archive for file backend", "description": "Path to job archive for file backend",
"type": "string" "type": "string"
}, },
"compression": {
"description": "Setup automatic compression for jobs older than number of days",
"type": "integer"
},
"retention": { "retention": {
"description": "Configuration keys for retention", "description": "Configuration keys for retention",
"type": "object", "type": "object",
@ -69,11 +73,11 @@
"move" "move"
] ]
}, },
"time": { "age": {
"description": "Act on jobs with startTime older than time", "description": "Act on jobs with startTime older than age (in days)",
"type": "integer" "type": "integer"
}, },
"directory": { "location": {
"description": "The target directory for retention. Only applicable for retention move.", "description": "The target directory for retention. Only applicable for retention move.",
"type": "string" "type": "string"
} }