Skip to content

Commit 027d79b

Browse files
authored
address review comments
1 parent 4293b61 commit 027d79b

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

cmd/main.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,18 +119,18 @@ func isCaddyfile(configFile, adapterName string) (bool, error) {
119119
baseConfig := strings.ToLower(filepath.Base(configFile))
120120
baseConfigExt := filepath.Ext(baseConfig)
121121
startsOrEndsInCaddyfile := strings.HasPrefix(baseConfig, "caddyfile") || strings.HasSuffix(baseConfig, ".caddyfile")
122-
notCaddyfileNorJSON := (baseConfigExt != "" && baseConfigExt != ".caddyfile" && baseConfigExt != ".json")
122+
extNotCaddyfileOrJSON := (baseConfigExt != "" && baseConfigExt != ".caddyfile" && baseConfigExt != ".json")
123123

124124
if baseConfigExt == ".json" {
125125
return false, nil
126126
}
127127

128128
// If the adapter is not specified,
129-
// the config file does not starts with "caddyfile",
129+
// the config file starts with "caddyfile",
130130
// the config file has an extension,
131131
// and isn't a JSON file (e.g. Caddyfile.yaml),
132132
// then we don't know what the config format is.
133-
if adapterName == "" && startsOrEndsInCaddyfile && notCaddyfileNorJSON {
133+
if adapterName == "" && startsOrEndsInCaddyfile && extNotCaddyfileOrJSON {
134134
return false, fmt.Errorf("ambiguous config file format; please specify adapter (use --adapter)")
135135
}
136136

cmd/main_test.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,15 @@ func Test_isCaddyfile(t *testing.T) {
180180
want bool
181181
wantErr bool
182182
}{
183+
{
184+
name: "bare Caddyfile without adapter",
185+
args: args{
186+
configFile: "Caddyfile",
187+
adapterName: "",
188+
},
189+
want: true,
190+
wantErr: false,
191+
},
183192
{
184193
name: "local Caddyfile without adapter",
185194
args: args{

0 commit comments

Comments
 (0)