Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,5 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
warning, and `task deps` and `task icon` no longer print spurious warnings.
- `task deps` on Debian/Ubuntu installs the Wayland headers that current Fyne
needs to build.
- Empty or comment-only files in a config directory, such as Docker bind-mount
placeholders, no longer show up as unmanaged services.
2 changes: 2 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,8 @@ func listServices(target string, isFile bool) ([]Service, error) {
doc, err := readDoc(filepath.Join(target, n))
if err != nil {
log.Print(err)
} else if len(doc) == 0 {
continue // empty or comment-only, e.g. a bind-mount placeholder; unreadable files still get a row
}
svcs := extract(doc, n)
if len(svcs) == 0 {
Expand Down
27 changes: 27 additions & 0 deletions main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,3 +107,30 @@ func TestDisabledRoundTrip(t *testing.T) {
t.Fatalf("re-enable: %+v", got)
}
}

// Empty files (bind-mount placeholders) are hidden, but a broken file must stay visible:
// Traefik rejects the whole directory over it.
func TestListServicesDirectory(t *testing.T) {
dir := t.TempDir()
for name, body := range map[string]string{
"placeholder.yaml": "# mount point only\n",
"empty.yml": "",
"broken.yml": "http: [\n",
"tls.yml": "tls:\n certificates: []\n",
} {
if err := os.WriteFile(filepath.Join(dir, name), []byte(body), 0o600); err != nil {
t.Fatal(err)
}
}
got, err := listServices(dir, false)
if err != nil {
t.Fatal(err)
}
var names []string
for _, s := range got {
names = append(names, s.Name)
}
if want := []string{"broken", "tls"}; !reflect.DeepEqual(names, want) {
t.Fatalf("listed %v, want %v", names, want)
}
}