cmd/gitops-pusher: format HuJSON, enabling exact ACL matches (#5061)

Signed-off-by: Xe <xe@tailscale.com>
This commit is contained in:
Xe Iaso
2022-07-15 11:09:44 -04:00
committed by GitHub
parent 16c85d0dc5
commit 004f0ca3e0
3 changed files with 12 additions and 5 deletions

View File

@@ -13,13 +13,14 @@ import (
"encoding/json"
"flag"
"fmt"
"io"
"log"
"net/http"
"os"
"regexp"
"strings"
"time"
"github.com/tailscale/hujson"
)
var (
@@ -94,14 +95,18 @@ func main() {
}
func sumFile(fname string) (string, error) {
fin, err := os.Open(fname)
data, err := os.ReadFile(fname)
if err != nil {
return "", err
}
formatted, err := hujson.Format(data)
if err != nil {
return "", err
}
defer fin.Close()
h := sha256.New()
_, err = io.Copy(h, fin)
_, err = h.Write(formatted)
if err != nil {
return "", err
}