Repository: palantir/policy-bot (go)

Issue:
Increase max nesting depth
I was wondering if it would be possible to increase the max nesting depth of ors/ands to 6-7? I have a complex use case that requires just a little bit more nesting than is currently supported :)

Pull request description:
Increase max rule nesting depth to 10
Fixes #168.

Patch:
diff --git a/policy/approval/parse.go b/policy/approval/parse.go
index b13a2ce..a7b8f46 100644
--- a/policy/approval/parse.go
+++ b/policy/approval/parse.go
@@ -46,7 +46,7 @@ func (p Policy) Parse(rules map[string]*Rule) (common.Evaluator, error) {
 }
 
 func parsePolicyR(policy interface{}, rules map[string]*Rule, depth int) (common.Evaluator, error) {
-	if depth > 5 {
+	if depth > 10 {
 		return nil, errors.New("reached maximum recursive depth while processing policy")
 	}
 


Test patch:
diff --git a/policy/approval/parse_test.go b/policy/approval/parse_test.go
index 86a162d..ce33147 100644
--- a/policy/approval/parse_test.go
+++ b/policy/approval/parse_test.go
@@ -192,13 +192,18 @@ func TestParsePolicyError_multikey(t *testing.T) {
 }
 
 func TestParsePolicyError_recursiveDepth(t *testing.T) {
-	// Recursive depth 5 is allowed
+	// Recursive depth 10 is allowed
 	policy := `
 - or:
-   - or:
+  - or:
+    - or:
       - or:
-         - or:
-            - rule1
+        - or:
+          - or:
+            - or:
+              - or:
+                - or:
+                  - rule1
 `
 
 	rules := `
@@ -208,14 +213,19 @@ func TestParsePolicyError_recursiveDepth(t *testing.T) {
 	_, err := loadAndParsePolicy(t, policy, rules)
 	require.NoError(t, err)
 
-	// Recursive depth 6 is not allowed
+	// Recursive depth 11 is not allowed
 	policy = `
 - or:
-   - or:
+  - or:
+    - or:
       - or:
-         - or:
+        - or:
+          - or:
             - or:
-               - rule1
+              - or:
+                - or:
+                  - or:
+                    - rule1
 `
 
 	_, err = loadAndParsePolicy(t, policy, rules)