Skip to content
Merged
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
11 changes: 10 additions & 1 deletion src/targets/__tests__/docker.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -239,12 +239,21 @@
expect(isGoogleCloudRegistry('asia.gcr.io')).toBe(true);
});

it('returns true for Artifact Registry (pkg.dev)', () => {
it('returns true for Artifact Registry multi-region (pkg.dev)', () => {
expect(isGoogleCloudRegistry('us-docker.pkg.dev')).toBe(true);
expect(isGoogleCloudRegistry('europe-docker.pkg.dev')).toBe(true);
expect(isGoogleCloudRegistry('asia-docker.pkg.dev')).toBe(true);
});

it('returns true for Artifact Registry regional endpoints (pkg.dev)', () => {
expect(isGoogleCloudRegistry('us-west1-docker.pkg.dev')).toBe(true);
expect(isGoogleCloudRegistry('us-central1-docker.pkg.dev')).toBe(true);
expect(isGoogleCloudRegistry('us-east4-docker.pkg.dev')).toBe(true);
expect(isGoogleCloudRegistry('europe-west1-docker.pkg.dev')).toBe(true);
expect(isGoogleCloudRegistry('asia-east1-docker.pkg.dev')).toBe(true);
expect(isGoogleCloudRegistry('australia-southeast1-docker.pkg.dev')).toBe(true);
});

it('returns false for non-Google registries', () => {
expect(isGoogleCloudRegistry('ghcr.io')).toBe(false);
expect(isGoogleCloudRegistry('docker.io')).toBe(false);
Expand Down Expand Up @@ -354,8 +363,8 @@
new NoneArtifactProvider()
);

expect(target.dockerConfig.target.credentials!.username).toBe('custom-user');

Check warning on line 366 in src/targets/__tests__/docker.test.ts

View workflow job for this annotation

GitHub Actions / Lint fixes

[@typescript-eslint/no-non-null-assertion] Forbidden non-null assertion.
expect(target.dockerConfig.target.credentials!.password).toBe('custom-pass');

Check warning on line 367 in src/targets/__tests__/docker.test.ts

View workflow job for this annotation

GitHub Actions / Lint fixes

[@typescript-eslint/no-non-null-assertion] Forbidden non-null assertion.
});

it('throws if only usernameVar is specified', () => {
Expand Down Expand Up @@ -431,8 +440,8 @@
new NoneArtifactProvider()
);

expect(target.dockerConfig.target.credentials!.username).toBe('ghcr-user');

Check warning on line 443 in src/targets/__tests__/docker.test.ts

View workflow job for this annotation

GitHub Actions / Lint fixes

[@typescript-eslint/no-non-null-assertion] Forbidden non-null assertion.
expect(target.dockerConfig.target.credentials!.password).toBe('ghcr-pass');

Check warning on line 444 in src/targets/__tests__/docker.test.ts

View workflow job for this annotation

GitHub Actions / Lint fixes

[@typescript-eslint/no-non-null-assertion] Forbidden non-null assertion.
});

it('falls back to GHCR defaults (GITHUB_ACTOR/GITHUB_TOKEN) for ghcr.io', () => {
Expand All @@ -448,8 +457,8 @@
new NoneArtifactProvider()
);

expect(target.dockerConfig.target.credentials!.username).toBe('github-actor');

Check warning on line 460 in src/targets/__tests__/docker.test.ts

View workflow job for this annotation

GitHub Actions / Lint fixes

[@typescript-eslint/no-non-null-assertion] Forbidden non-null assertion.
expect(target.dockerConfig.target.credentials!.password).toBe('github-token');

Check warning on line 461 in src/targets/__tests__/docker.test.ts

View workflow job for this annotation

GitHub Actions / Lint fixes

[@typescript-eslint/no-non-null-assertion] Forbidden non-null assertion.
});

it('uses default DOCKER_* env vars for Docker Hub', () => {
Expand All @@ -465,9 +474,9 @@
new NoneArtifactProvider()
);

expect(target.dockerConfig.target.credentials!.username).toBe('dockerhub-user');

Check warning on line 477 in src/targets/__tests__/docker.test.ts

View workflow job for this annotation

GitHub Actions / Lint fixes

[@typescript-eslint/no-non-null-assertion] Forbidden non-null assertion.
expect(target.dockerConfig.target.credentials!.password).toBe('dockerhub-pass');

Check warning on line 478 in src/targets/__tests__/docker.test.ts

View workflow job for this annotation

GitHub Actions / Lint fixes

[@typescript-eslint/no-non-null-assertion] Forbidden non-null assertion.
expect(target.dockerConfig.target.credentials!.registry).toBeUndefined();

Check warning on line 479 in src/targets/__tests__/docker.test.ts

View workflow job for this annotation

GitHub Actions / Lint fixes

[@typescript-eslint/no-non-null-assertion] Forbidden non-null assertion.
});

it('treats docker.io as Docker Hub and uses default credentials', () => {
Expand All @@ -483,7 +492,7 @@
new NoneArtifactProvider()
);

expect(target.dockerConfig.target.credentials!.username).toBe('dockerhub-user');

Check warning on line 495 in src/targets/__tests__/docker.test.ts

View workflow job for this annotation

GitHub Actions / Lint fixes

[@typescript-eslint/no-non-null-assertion] Forbidden non-null assertion.
expect(target.dockerConfig.target.credentials!.password).toBe('dockerhub-pass');
expect(target.dockerConfig.target.credentials!.registry).toBeUndefined();
});
Expand Down
2 changes: 1 addition & 1 deletion src/targets/docker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const GCR_REGISTRY_PATTERNS = [
/^gcr\.io$/,
/^[a-z]+-gcr\.io$/, // us-gcr.io, eu-gcr.io, asia-gcr.io, etc.
/^[a-z]+\.gcr\.io$/, // us.gcr.io, eu.gcr.io, asia.gcr.io, etc.
/^[a-z]+-docker\.pkg\.dev$/, // us-docker.pkg.dev, europe-docker.pkg.dev, etc.
/^[a-z][a-z0-9-]*-docker\.pkg\.dev$/, // us-docker.pkg.dev, us-west1-docker.pkg.dev, europe-west1-docker.pkg.dev, etc.
];

/**
Expand Down