Skip to content

Commit 6973cd1

Browse files
committed
fix: add new errors
1 parent bc6be5f commit 6973cd1

File tree

3 files changed

+9
-8
lines changed

3 files changed

+9
-8
lines changed

config/shared/errors/errors.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,8 @@ var (
8585
ErrInvalidProxy = errors.New("proxies must be http(s)")
8686
ErrInsecureProxy = errors.New("insecure plaintext HTTP proxy specified for HTTPS resources")
8787
ErrPathConflictsSystemd = errors.New("path conflicts with systemd unit or dropin")
88-
ErrPathConflictsParentDir = errors.New("path conflicts with parent directory of another file, link, or directory")
88+
ErrPathAlreadyExists = errors.New("path already exists")
89+
ErrMisslabeledDir = errors.New("parent directory path matches configured file, check path, and ensure parent directory is configured")
8990

9091
// Systemd section errors
9192
ErrInvalidSystemdExt = errors.New("invalid systemd unit extension")

config/v3_5_experimental/types/config.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -81,17 +81,17 @@ func (cfg Config) validateParents(c path.ContextPath) report.Report {
8181
r := report.Report{}
8282

8383
for i, f := range cfg.Storage.Files {
84-
r = handlePathConflict(f.Path, "files", i, c, r, errors.ErrPathConflictsParentDir)
84+
r = handlePathConflict(f.Path, "files", i, c, r, errors.ErrPathAlreadyExists)
8585
addPathAndEntry(f.Path, "files", &entries)
8686
}
8787

8888
for i, d := range cfg.Storage.Directories {
89-
r = handlePathConflict(d.Path, "directories", i, c, r, errors.ErrPathConflictsParentDir)
89+
r = handlePathConflict(d.Path, "directories", i, c, r, errors.ErrPathAlreadyExists)
9090
addPathAndEntry(d.Path, "directories", &entries)
9191
}
9292

9393
for i, l := range cfg.Storage.Links {
94-
r = handlePathConflict(l.Path, "links", i, c, r, errors.ErrPathConflictsParentDir)
94+
r = handlePathConflict(l.Path, "links", i, c, r, errors.ErrPathAlreadyExists)
9595
addPathAndEntry(l.Path, "links", &entries)
9696
}
9797

@@ -102,7 +102,7 @@ func (cfg Config) validateParents(c path.ContextPath) report.Report {
102102
for i, entry := range entries {
103103
if i > 0 && isWithin(entry.Path, entries[i-1].Path) {
104104
if entries[i-1].Field != "directories" {
105-
r.AddOnError(c.Append("storage", entry.Field, i, "path"), errors.ErrPathConflictsParentDir)
105+
r.AddOnError(c.Append("storage", entry.Field, i, "path"), errors.ErrMisslabeledDir)
106106
return r
107107
}
108108
}

config/v3_5_experimental/types/config_test.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ func TestConfigValidation(t *testing.T) {
194194
},
195195
},
196196
},
197-
out: errors.ErrPathConflictsParentDir,
197+
out: errors.ErrMisslabeledDir,
198198
at: path.New("json", "storage", "files", 1, "path"),
199199
},
200200

@@ -210,7 +210,7 @@ func TestConfigValidation(t *testing.T) {
210210
},
211211
},
212212
},
213-
out: errors.ErrPathConflictsParentDir,
213+
out: errors.ErrMisslabeledDir,
214214
at: path.New("json", "storage", "links", 1, "path"),
215215
},
216216

@@ -226,7 +226,7 @@ func TestConfigValidation(t *testing.T) {
226226
},
227227
},
228228
},
229-
out: errors.ErrPathConflictsParentDir,
229+
out: errors.ErrMisslabeledDir,
230230
at: path.New("json", "storage", "directories", 1, "path"),
231231
},
232232

0 commit comments

Comments
 (0)