Implement tool to validate archive

This commit is contained in:
Jan Eitzinger
2023-03-31 11:25:12 +02:00
parent 68a839bf1c
commit eb2e2cb1d2
4 changed files with 37 additions and 6 deletions

View File

@@ -4,6 +4,32 @@
// license that can be found in the LICENSE file.
package main
func main() {
import (
"encoding/json"
"flag"
"fmt"
"log"
"github.com/ClusterCockpit/cc-backend/internal/config"
"github.com/ClusterCockpit/cc-backend/pkg/archive"
)
func main() {
var srcPath, flagConfigFile string
flag.StringVar(&srcPath, "s", "./var/job-archive", "Specify the source job archive path. Default is ./var/job-archive")
flag.StringVar(&flagConfigFile, "config", "./config.json", "Specify alternative path to `config.json`")
flag.Parse()
archiveCfg := fmt.Sprintf("{\"kind\": \"file\",\"path\": \"%s\"}", srcPath)
config.Init(flagConfigFile)
if err := archive.Init(json.RawMessage(archiveCfg)); err != nil {
log.Fatal(err)
}
ar := archive.GetHandle()
for jobMeta := range ar.Iter() {
fmt.Printf("Validate %s - %d\n", jobMeta.Cluster, jobMeta.JobID)
}
}

View File

@@ -180,6 +180,7 @@ func main() {
flag.StringVar(&srcPath, "s", "./var/job-archive", "Specify the source job archive path. Default is ./var/job-archive")
flag.StringVar(&dstPath, "d", "./var/job-archive-new", "Specify the destination job archive path. Default is ./var/job-archive-new")
flag.Parse()
if _, err := os.Stat(filepath.Join(srcPath, "version.txt")); !errors.Is(err, os.ErrNotExist) {
log.Fatal("Archive version exists!")