From b7fb4682c64e99fe9079e422d1079b4929be8e8b Mon Sep 17 00:00:00 2001 From: Thibault Le Ouay Date: Thu, 17 Jul 2025 14:46:06 +0200 Subject: [PATCH] full cli --- internal/monitors/monitor_export.go | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/internal/monitors/monitor_export.go b/internal/monitors/monitor_export.go index 27f03b6..0503aa5 100644 --- a/internal/monitors/monitor_export.go +++ b/internal/monitors/monitor_export.go @@ -38,6 +38,7 @@ func ExportMonitor(httpClient *http.Client, apiKey string, path string) error { } t := map[string]config.Monitor{} + lock := make(map[string]config.Lock,len(monitors)) file, err := os.OpenFile(path, os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0600) if err != nil { @@ -128,6 +129,34 @@ func ExportMonitor(httpClient *http.Client, apiKey string, path string) error { if err != nil { return err } + + // + for id, monitor := range t { + i, _ := strconv.Atoi(id) + lock[id] = config.Lock{ + ID: i, + Monitor: monitor, + } + } + + lockFile, err := os.OpenFile("openstatus.lock", os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0600) + if err != nil { + return cli.Exit("Failed to apply change", 1) + + } + defer lockFile.Close() + + y, err = yaml.Marshal(&lock) + if err != nil { + return cli.Exit("Failed to apply change", 1) + } + + _, err = lockFile.Write(y) + if err != nil { + return cli.Exit("Failed to apply change", 1) + } + + return nil } -- knotmirror 0.0.1