diff options
| author | Xe Iaso <xe@tailscale.com> | 2022-09-01 13:38:32 -0400 |
|---|---|---|
| committer | Denton Gentry <dgentry@tailscale.com> | 2022-09-01 14:57:46 -0700 |
| commit | b14e31831a1d444dbbdf482a98a2c45b0f57e8ae (patch) | |
| tree | 32a0ac85a1a5d72590c32c34e2bff34cf149b5f4 /cmd | |
| parent | 0b00b7a135b635fadd8a9a38567562798873ab82 (diff) | |
| download | tailscale-gitops-1.30.0.tar.xz tailscale-gitops-1.30.0.zip | |
cmd/gitops-pusher: standardize hujson before posting to validate (#5525)gitops-1.30.0
Apparently the validate route doesn't check content-types or handle
hujson with comments correctly. This patch makes gitops-pusher convert
the hujson to normal json.
Signed-off-by: Xe <xe@tailscale.com>
Signed-off-by: Xe <xe@tailscale.com>
(cherry picked from commit 3564fd61b5f51ef8ad709740b802bc7e0ec719aa)
Diffstat (limited to 'cmd')
| -rw-r--r-- | cmd/gitops-pusher/gitops-pusher.go | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/cmd/gitops-pusher/gitops-pusher.go b/cmd/gitops-pusher/gitops-pusher.go index ebdd69eaa..ca81fdd38 100644 --- a/cmd/gitops-pusher/gitops-pusher.go +++ b/cmd/gitops-pusher/gitops-pusher.go @@ -8,6 +8,7 @@ package main import ( + "bytes" "context" "crypto/sha256" "encoding/json" @@ -264,13 +265,16 @@ func applyNewACL(ctx context.Context, tailnet, apiKey, policyFname, oldEtag stri } func testNewACLs(ctx context.Context, tailnet, apiKey, policyFname string) error { - fin, err := os.Open(policyFname) + data, err := os.ReadFile(policyFname) + if err != nil { + return err + } + data, err = hujson.Standardize(data) if err != nil { return err } - defer fin.Close() - req, err := http.NewRequestWithContext(ctx, http.MethodPost, fmt.Sprintf("https://api.tailscale.com/api/v2/tailnet/%s/acl/validate", tailnet), fin) + req, err := http.NewRequestWithContext(ctx, http.MethodPost, fmt.Sprintf("https://api.tailscale.com/api/v2/tailnet/%s/acl/validate", tailnet), bytes.NewBuffer(data)) if err != nil { return err } |
