compose generated from a container now captures network config and resource limits

This commit is contained in:
Jarek Krochmalski committed 2026-08-27 07:34:37 +02:00
1 parent bd42cfaa1b
commit 909e9934d3
11 files changed
+831 -39

No files matched your search

+59 -1
View File
@@ -3,7 +3,10 @@
* forge families semver supports (GitHub, Gitea/Forgejo, GHCR).
*/
import { describe, it, expect } from 'bun:test';
import { resolveReleaseSource } from '../src/lib/server/semver/release-source';
import {
resolveReleaseSource,
resolveReleaseSourceCandidates
} from '../src/lib/server/semver/release-source';
describe('resolveReleaseSource', () => {
it('resolves a GitHub source label to the GitHub releases API', () => {
@@ -60,3 +63,58 @@ describe('resolveReleaseSource', () => {
expect(resolveReleaseSource('ghcr.io/something:1')).toBeNull();
});
});
describe('resolveReleaseSourceCandidates', () => {
it('returns the single confident source (no guesses) when a source label exists', () => {
const cands = resolveReleaseSourceCandidates('whatever:1', {
'org.opencontainers.image.source': 'https://github.com/traefik/traefik'
});
expect(cands).toHaveLength(1);
expect(cands[0].slug).toBe('traefik/traefik');
expect(cands[0].needsValidation).toBeUndefined();
});
it('guesses a GitHub repo from a Docker Hub image name (grafana/grafana)', () => {
const cands = resolveReleaseSourceCandidates('grafana/grafana:11.0.0');
expect(cands).toHaveLength(1);
expect(cands[0].kind).toBe('github');
expect(cands[0].slug).toBe('grafana/grafana');
expect(cands[0].needsValidation).toBe(true);
expect(cands[0].apiBase).toBe('https://api.github.com/repos/grafana/grafana/releases');
});
it('drops a registry host segment before guessing (registry.io/org/app -> org/app)', () => {
const cands = resolveReleaseSourceCandidates('registry.example.com/acme/app:2.1');
expect(cands[0].slug).toBe('acme/app');
expect(cands[0].needsValidation).toBe(true);
});
it('does NOT guess a slug for a single-name official image (nginx)', () => {
expect(resolveReleaseSourceCandidates('nginx:1.25')).toHaveLength(0);
});
it('harvests a github URL from a non-source label', () => {
const cands = resolveReleaseSourceCandidates('nginx:1.25', {
'org.opencontainers.image.url': 'https://github.com/acme/proxy'
});
expect(cands.some((c) => c.slug === 'acme/proxy' && c.needsValidation)).toBe(true);
});
it('dedupes the image-name guess and a matching label URL', () => {
const cands = resolveReleaseSourceCandidates('grafana/grafana:11', {
'org.opencontainers.image.documentation': 'https://github.com/grafana/grafana/blob/main/README.md'
});
expect(cands.filter((c) => c.slug === 'grafana/grafana')).toHaveLength(1);
});
it('ignores the source label key when harvesting other labels', () => {
// A source label host that is not github/ghcr yields a confident gitea source,
// so candidates is just that one - no guessing happens.
const cands = resolveReleaseSourceCandidates('x:1', {
'org.opencontainers.image.source': 'https://git.example.com/team/app'
});
expect(cands).toHaveLength(1);
expect(cands[0].kind).toBe('gitea');
expect(cands[0].needsValidation).toBeUndefined();
});
});