Skip to content

Commit

Permalink
Merge branch 'master' into reverse-proxy-command-log
Browse files Browse the repository at this point in the history
  • Loading branch information
mohammed90 authored Jan 21, 2024
2 parents a049f93 + dba556f commit 99c3690
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 10 deletions.
5 changes: 5 additions & 0 deletions caddyconfig/caddyfile/lexer.go
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,11 @@ func (l *lexer) finalizeHeredoc(val []rune, marker string) ([]rune, error) {
// iterate over each line and strip the whitespace from the front
var out string
for lineNum, lineText := range lines[:len(lines)-1] {
if lineText == "" {
out += "\n"
continue
}

// find an exact match for the padding
index := strings.Index(lineText, paddingToStrip)

Expand Down
42 changes: 42 additions & 0 deletions caddyconfig/caddyfile/lexer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,48 @@ EOF same-line-arg
expectErr: true,
errorMessage: "mismatched leading whitespace in heredoc <<EOF on line #2 [ content], expected whitespace [\t\t] to match the closing marker",
},
{
input: []byte(`heredoc <<EOF
The next line is a blank line
The previous line is a blank line
EOF`),
expected: []Token{
{Line: 1, Text: "heredoc"},
{Line: 1, Text: "The next line is a blank line\n\nThe previous line is a blank line"},
},
},
{
input: []byte(`heredoc <<EOF
One tab indented heredoc with blank next line
One tab indented heredoc with blank previous line
EOF`),
expected: []Token{
{Line: 1, Text: "heredoc"},
{Line: 1, Text: "One tab indented heredoc with blank next line\n\nOne tab indented heredoc with blank previous line"},
},
},
{
input: []byte(`heredoc <<EOF
The next line is a blank line with one tab
The previous line is a blank line with one tab
EOF`),
expected: []Token{
{Line: 1, Text: "heredoc"},
{Line: 1, Text: "The next line is a blank line with one tab\n\t\nThe previous line is a blank line with one tab"},
},
},
{
input: []byte(`heredoc <<EOF
The next line is a blank line with one tab less than the correct indentation
The previous line is a blank line with one tab less than the correct indentation
EOF`),
expectErr: true,
errorMessage: "mismatched leading whitespace in heredoc <<EOF on line #3 [\t], expected whitespace [\t\t] to match the closing marker",
},
}

for i, testCase := range testCases {
Expand Down
10 changes: 0 additions & 10 deletions cmd/caddy/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,22 +29,12 @@
package main

import (
"go.uber.org/automaxprocs/maxprocs"
"go.uber.org/zap"

caddycmd "github.com/caddyserver/caddy/v2/cmd"

"github.com/caddyserver/caddy/v2"
// plug in Caddy modules here
_ "github.com/caddyserver/caddy/v2/modules/standard"
)

func main() {
undo, err := maxprocs.Set()
defer undo()
if err != nil {
caddy.Log().Warn("failed to set GOMAXPROCS", zap.Error(err))
}

caddycmd.Main()
}
7 changes: 7 additions & 0 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import (

"github.com/caddyserver/certmagic"
"github.com/spf13/pflag"
"go.uber.org/automaxprocs/maxprocs"
"go.uber.org/zap"

"github.com/caddyserver/caddy/v2"
Expand Down Expand Up @@ -64,6 +65,12 @@ func Main() {
os.Exit(caddy.ExitCodeFailedStartup)
}

undo, err := maxprocs.Set()
defer undo()
if err != nil {
caddy.Log().Warn("failed to set GOMAXPROCS", zap.Error(err))
}

if err := rootCmd.Execute(); err != nil {
var exitError *exitError
if errors.As(err, &exitError) {
Expand Down

0 comments on commit 99c3690

Please sign in to comment.