summaryrefslogtreecommitdiff
path: root/caddyconfig/caddyfile
diff options
context:
space:
mode:
Diffstat (limited to 'caddyconfig/caddyfile')
-rw-r--r--caddyconfig/caddyfile/parse.go14
-rw-r--r--caddyconfig/caddyfile/parse_test.go5
2 files changed, 4 insertions, 15 deletions
diff --git a/caddyconfig/caddyfile/parse.go b/caddyconfig/caddyfile/parse.go
index 2c2da0f..82c515b 100644
--- a/caddyconfig/caddyfile/parse.go
+++ b/caddyconfig/caddyfile/parse.go
@@ -61,20 +61,12 @@ func Parse(filename string, input []byte) ([]ServerBlock, error) {
// It returns all the tokens from the input, unstructured
// and in order. It may mutate input as it expands env vars.
func allTokens(filename string, input []byte) ([]Token, error) {
- inputCopy, err := replaceEnvVars(input)
- if err != nil {
- return nil, err
- }
- tokens, err := Tokenize(inputCopy, filename)
- if err != nil {
- return nil, err
- }
- return tokens, nil
+ return Tokenize(replaceEnvVars(input), filename)
}
// replaceEnvVars replaces all occurrences of environment variables.
// It mutates the underlying array and returns the updated slice.
-func replaceEnvVars(input []byte) ([]byte, error) {
+func replaceEnvVars(input []byte) []byte {
var offset int
for {
begin := bytes.Index(input[offset:], spanOpen)
@@ -115,7 +107,7 @@ func replaceEnvVars(input []byte) ([]byte, error) {
// continue at the end of the replacement
offset = begin + len(envVarBytes)
}
- return input, nil
+ return input
}
type parser struct {
diff --git a/caddyconfig/caddyfile/parse_test.go b/caddyconfig/caddyfile/parse_test.go
index c3f6fa6..e3eff56 100644
--- a/caddyconfig/caddyfile/parse_test.go
+++ b/caddyconfig/caddyfile/parse_test.go
@@ -604,10 +604,7 @@ func TestEnvironmentReplacement(t *testing.T) {
expect: "}{$",
},
} {
- actual, err := replaceEnvVars([]byte(test.input))
- if err != nil {
- t.Fatal(err)
- }
+ actual := replaceEnvVars([]byte(test.input))
if !bytes.Equal(actual, []byte(test.expect)) {
t.Errorf("Test %d: Expected: '%s' but got '%s'", i, test.expect, actual)
}