Extracted agent status to consistent volume (#628)

This commit is contained in:
RoyUP9
2022-01-12 16:03:50 +02:00
committed by GitHub
parent 68c4ee9a4f
commit 26a9c31d1e
12 changed files with 173 additions and 104 deletions

View File

@@ -2,7 +2,9 @@ package utils
import (
"context"
"encoding/json"
"fmt"
"io/ioutil"
"net/http"
"net/url"
"os"
@@ -59,3 +61,27 @@ func SetHostname(address, newHostname string) string {
return replacedUrl.String()
}
func ReadJsonFile(filePath string, value interface{}) error {
if content, err := ioutil.ReadFile(filePath); err != nil {
return err
} else {
if err = json.Unmarshal(content, value); err != nil {
return err
}
}
return nil
}
func SaveJsonFile(filePath string, value interface{}) error {
if data, err := json.Marshal(value); err != nil {
return err
} else {
if err = ioutil.WriteFile(filePath, data, 0644); err != nil {
return err
}
}
return nil
}