|
|
@ -17,13 +17,15 @@ import (
|
|
|
|
"log"
|
|
|
|
"log"
|
|
|
|
"net/http"
|
|
|
|
"net/http"
|
|
|
|
"os"
|
|
|
|
"os"
|
|
|
|
|
|
|
|
"regexp"
|
|
|
|
"strings"
|
|
|
|
"strings"
|
|
|
|
"time"
|
|
|
|
"time"
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
var (
|
|
|
|
var (
|
|
|
|
policyFname = flag.String("policy-file", "./policy.hujson", "filename for policy file")
|
|
|
|
policyFname = flag.String("policy-file", "./policy.hujson", "filename for policy file")
|
|
|
|
timeout = flag.Duration("timeout", 5*time.Minute, "timeout for the entire CI run")
|
|
|
|
timeout = flag.Duration("timeout", 5*time.Minute, "timeout for the entire CI run")
|
|
|
|
|
|
|
|
githubSyntax = flag.Bool("github-syntax", true, "use GitHub Action error syntax (https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#setting-an-error-message)")
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
func main() {
|
|
|
@ -177,13 +179,15 @@ func testNewACLs(ctx context.Context, tailnet, apiKey, policyFname string) error
|
|
|
|
return err
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if len(ate.Data) != 0 {
|
|
|
|
if len(ate.Message) != 0 || len(ate.Data) != 0 {
|
|
|
|
return ate
|
|
|
|
return ate
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return nil
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var lineColMessageSplit = regexp.MustCompile(`^line ([0-9]+), column ([0-9]+): (.*)$`)
|
|
|
|
|
|
|
|
|
|
|
|
type ACLTestError struct {
|
|
|
|
type ACLTestError struct {
|
|
|
|
Message string `json:"message"`
|
|
|
|
Message string `json:"message"`
|
|
|
|
Data []ACLTestErrorDetail `json:"data"`
|
|
|
|
Data []ACLTestErrorDetail `json:"data"`
|
|
|
@ -192,7 +196,17 @@ type ACLTestError struct {
|
|
|
|
func (ate ACLTestError) Error() string {
|
|
|
|
func (ate ACLTestError) Error() string {
|
|
|
|
var sb strings.Builder
|
|
|
|
var sb strings.Builder
|
|
|
|
|
|
|
|
|
|
|
|
fmt.Fprintln(&sb, ate.Message)
|
|
|
|
if *githubSyntax && lineColMessageSplit.MatchString(ate.Message) {
|
|
|
|
|
|
|
|
sp := lineColMessageSplit.FindStringSubmatch(ate.Message)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
line := sp[1]
|
|
|
|
|
|
|
|
col := sp[2]
|
|
|
|
|
|
|
|
msg := sp[3]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fmt.Fprintf(&sb, "::error file=%s,line=%s,col=%s::%s", *policyFname, line, col, msg)
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
fmt.Fprintln(&sb, ate.Message)
|
|
|
|
|
|
|
|
}
|
|
|
|
fmt.Fprintln(&sb)
|
|
|
|
fmt.Fprintln(&sb)
|
|
|
|
|
|
|
|
|
|
|
|
for _, data := range ate.Data {
|
|
|
|
for _, data := range ate.Data {
|
|
|
|