Skip to content

Commit

Permalink
Merge pull request #10 from uselagoon/single-quoted-arguments
Browse files Browse the repository at this point in the history
Handle single-quoted annotation arguments
  • Loading branch information
smlx authored Nov 1, 2021
2 parents 3783890 + ff5be58 commit 480f641
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 2 deletions.
8 changes: 8 additions & 0 deletions internal/lagoonyml/lint_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,14 @@ func TestLint(t *testing.T) {
input: "testdata/valid.3.lagoon.yml",
valid: true,
},
"single quoted arguments": {
input: "testdata/valid.4.lagoon.yml",
valid: true,
},
"add_header ... always": {
input: "testdata/valid.5.lagoon.yml",
valid: true,
},
"invalid.0.lagoon.yml": {
input: "testdata/invalid.0.lagoon.yml",
valid: false,
Expand Down
4 changes: 2 additions & 2 deletions internal/lagoonyml/routeannotation.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ const (
// annotations.
var validSnippets = regexp.MustCompile(
`^(rewrite +[^; ]+ +[^; ]+( (last|break|redirect|permanent))?;|` +
`add_header +([^; ]+|"[^"]+")+ +([^; ]+|"[^"]+");|` +
`add_header +([^; ]+|"[^"]+"|'[^']+') +([^; ]+|"[^"]+"|'[^']+')( always)?;|` +
`set_real_ip_from +[^; ]+;|` +
`more_set_headers +(-s +"[^"]+"|-t +"[^"]+"|"[^"]+")+;|` +
`more_set_headers +(-s +("[^"]+"|'[^']+')|-t +("[^"]+"|'[^']+')|("[^"]+"|'[^']+'))+;|` +
` )+$`)

// validate returns true if the annotations are valid, and false otherwise.
Expand Down
21 changes: 21 additions & 0 deletions internal/lagoonyml/testdata/valid.4.lagoon.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
environments:
main:
monitoring_urls:
- "https://www.example.com"
- "https://www.example.com/special_page"
routes:
- nginx:
- example.com
- "www.example.com":
tls-acme: 'true'
insecure: Redirect
hsts: max-age=31536000
- "example.com":
annotations:
nginx.ingress.kubernetes.io/server-snippet: |
set_real_ip_from 1.2.3.4/32;
- "dev.example.com":
annotations:
nginx.ingress.kubernetes.io/server-snippet: |
set_real_ip_from 1.2.3.4/32;
add_header 'Permissions-Policy' 'geolocation=(), microphone=()';
9 changes: 9 additions & 0 deletions internal/lagoonyml/testdata/valid.5.lagoon.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
environments:
main:
routes:
- nginx:
- "dev.example.com":
annotations:
nginx.ingress.kubernetes.io/server-snippet: |
set_real_ip_from 1.2.3.4/32;
add_header 'Permissions-Policy' 'geolocation=(), microphone=()' always;

0 comments on commit 480f641

Please sign in to comment.