fix: address onboarding review feedback

This commit is contained in:
Thomas Camlong authored and ajnart committed 2026-08-14 01:20:27 +02:00
1 parent 07770e862c
commit d89bf25e21
72 files changed
+7783 -280

No files matched your search

+1 -1
View File
@@ -1,3 +1,3 @@
export { listDiscoveredContainersAsync } from "./list-discovered-containers";
export { parseContainerLabels, type ParseContainerLabelsOptions } from "./parse-container-labels";
export { createDockerSourceId, parseContainerLabels, type ParseContainerLabelsOptions } from "./parse-container-labels";
export type { DiscoveredService, DockerDiscoveryHostResult, DockerDiscoveryResult } from "./types";
@@ -51,7 +51,7 @@ describe("parseContainerLabels", () => {
"remote:2375",
),
).toMatchObject({
sourceId: "docker:remote:2375:container-1",
sourceId: "docker:remote%3A2375:container-1",
name: "Jellyfin",
group: "Media",
href: "http://jellyfin:8096",
@@ -59,6 +59,21 @@ describe("parseContainerLabels", () => {
});
});
it("keeps host and service identifiers unambiguous", () => {
const first = parseContainerLabels(
container({ "homarr.name": "Service", "homarr.href": "http://service", "homarr.id": "service" }),
"remote:2375",
);
const second = parseContainerLabels(
container({ "homarr.name": "Service", "homarr.href": "http://service", "homarr.id": "2375:service" }),
"remote",
);
expect(first?.sourceId).toBe("docker:remote%3A2375:service");
expect(second?.sourceId).toBe("docker:remote:2375%3Aservice");
expect(first?.sourceId).not.toBe(second?.sourceId);
});
it("keeps a labeled service without a group for root placement", () => {
expect(
parseContainerLabels(
@@ -31,6 +31,9 @@ const parseIntegrationKind = (value: string | undefined): IntegrationKind | unde
const parseWidgetKind = (value: string | undefined): WidgetKind | undefined =>
value && widgetKindSet.has(value) ? (value as WidgetKind) : undefined;
export const createDockerSourceId = (host: string, externalId: string) =>
`docker:${encodeURIComponent(host)}:${encodeURIComponent(externalId)}`;
export const parseContainerLabels = (
container: Pick<ContainerInfo, "Id" | "Labels">,
host: string,
@@ -48,7 +51,7 @@ export const parseContainerLabels = (
const externalId = readLabel(labels, dockerLabels.id) ?? container.Id;
return {
sourceId: `docker:${host}:${externalId}`,
sourceId: createDockerSourceId(host, externalId),
containerId: container.Id,
host,
group,