Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ testdata:
-v \
-f testdata/input-parent.hujson \
-d testdata/departments/ \
-o testdata/output-file-to-compare-to.hujson \
-allow=acls,autoApprovers,grants,groups,ipsets,ssh,tests,sshTests
-allow=acls,autoApprovers,grants,groups,ipsets,ssh,tests,sshTests \
-o testdata/output-file-to-compare-to.hujson
6 changes: 5 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
module github.com/tailscale-dev/tailscale-acl-combiner

go 1.21
go 1.23

toolchain go1.23.10

require github.com/creachadair/jtree v0.0.0-20231211041502-6ba355703cad

require github.com/tailscale/hujson v0.0.0-20250605163823-992244df8c5a

require (
go4.org/mem v0.0.0-20220726221520-4f986261bf13 // indirect
golang.org/x/exp v0.0.0-20230728194245-b0cb94b80691 // indirect
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ github.com/creachadair/jtree v0.0.0-20231211041502-6ba355703cad h1:2MMMgC7ORRjJH
github.com/creachadair/jtree v0.0.0-20231211041502-6ba355703cad/go.mod h1:WP8iLZIRvdwzYE3ahHTQVJa3AvAjQLnSUHl/IfXPzeQ=
github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/tailscale/hujson v0.0.0-20221223112325-20486734a56a h1:SJy1Pu0eH1C29XwJucQo73FrleVK6t4kYz4NVhp34Yw=
github.com/tailscale/hujson v0.0.0-20221223112325-20486734a56a/go.mod h1:DFSS3NAGHthKo1gTlmEcSBiZrRJXi28rLNd/1udP1c8=
github.com/tailscale/hujson v0.0.0-20250605163823-992244df8c5a h1:a6TNDN9CgG+cYjaeN8l2mc4kSz2iMiCDQxPEyltUV/I=
github.com/tailscale/hujson v0.0.0-20250605163823-992244df8c5a/go.mod h1:EbW0wDK/qEUYI0A5bqq0C2kF8JTQwWONmGDBbzsxxHo=
go4.org/mem v0.0.0-20220726221520-4f986261bf13 h1:CbZeCBZ0aZj8EfVgnqQcYZgf0lpZ3H9rmp5nkDTAst8=
go4.org/mem v0.0.0-20220726221520-4f986261bf13/go.mod h1:reUoABIJ9ikfM5sgtSF3Wushcza7+WeD01VB9Lirh3g=
golang.org/x/exp v0.0.0-20230728194245-b0cb94b80691 h1:/yRP+0AN7mf5DkD3BAI6TOFnd51gEoDEb8o35jIFtgw=
Expand Down
24 changes: 14 additions & 10 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (

"github.com/creachadair/jtree/ast"
"github.com/creachadair/jtree/jwcc"
"github.com/tailscale/hujson"
)

var (
Expand Down Expand Up @@ -304,6 +305,17 @@ func gatherChildren(path string) ([]*ParsedDocument, error) {
}

func outputFile(doc *jwcc.Object) error {
var sb strings.Builder
err := jwcc.Format(&sb, doc)
if err != nil {
return err
}

formatted, err := hujson.Format([]byte(sb.String()))
if err != nil {
return err
}

if *outFile != "" {
f, err := os.Create(*outFile)
if err != nil {
Expand All @@ -312,18 +324,10 @@ func outputFile(doc *jwcc.Object) error {
defer f.Close()

w := bufio.NewWriter(f)
err = jwcc.Format(w, doc)
if err != nil {
return err
}
w.WriteString("\n")
w.Write(formatted)
w.Flush()
} else {
err := jwcc.Format(os.Stdout, doc)
if err != nil {
return err
}
fmt.Printf("\n")
fmt.Print(string(formatted))
}
return nil
}
Expand Down
Loading