From f13db59a89e06a123dab82c768494ad24c4272f0 Mon Sep 17 00:00:00 2001 From: vmelikyan Date: Wed, 10 Sep 2025 13:29:20 -0700 Subject: [PATCH] Remove hardcoded 0env.com --- src/server/db/migrations/001_seed.ts | 4 ++-- src/server/db/migrations/003_add_build_defaults.ts | 2 +- src/server/lib/__tests__/utils.test.ts | 14 +++++++++----- src/server/lib/nativeBuild/engines.ts | 2 +- src/server/services/deploy.ts | 2 +- 5 files changed, 14 insertions(+), 10 deletions(-) diff --git a/src/server/db/migrations/001_seed.ts b/src/server/db/migrations/001_seed.ts index 5ad87c57..0a526cc4 100644 --- a/src/server/db/migrations/001_seed.ts +++ b/src/server/db/migrations/001_seed.ts @@ -444,8 +444,8 @@ export async function up(knex: Knex): Promise { INSERT INTO global_config (key, config, "createdAt", "updatedAt", "deletedAt", description) VALUES ('redis', '{"version":"3.7.2","args":"--force --timeout 60m0s --wait","action":"install","chart":{"name":"redis","repoUrl":"https://charts.bitnami.com/bitnami","version":"20.3.0","values":["replica.replicaCount=0","replica.persistence.enabled=false","auth.enabled=false","master.resourcesPreset=none","master.readinessProbe.timeoutSeconds=20","master.readinessProbe.periodSeconds=15","master.livenessProbe.timeoutSeconds=20","master.livenessProbe.periodSeconds=15"],"valueFiles":[]},"label":"master.persistence.labels","tolerations":"master.tolerations","affinity":"master.affinity","nodeSelector":"master.nodeSelector"}', now(), now(), null, 'Redis bitnami helm chart configuration default values.'); INSERT INTO global_config (key, config, "createdAt", "updatedAt", "deletedAt", description) VALUES ('elasticsearch', '{"version":"3.7.2","args":"--force --timeout 15m0s --wait","action":"install","chart":{"name":"elasticsearch","repoUrl":"https://charts.bitnami.com/bitnami","version":"19.10.9","values":["master.replicaCount=1","ingress.enabled=true","data.replicaCount=0","coordinating.replicaCount=0","ingest.enabled=false","master.readinessProbe.timeoutSeconds=20","master.livenessProbe.timeoutSeconds=20","master.startupProbe.timeoutSeconds=20"],"valueFiles":[]},"tolerations":"master.tolerations","affinity":"master.affinity","nodeSelector":"nodeSelector"}', now(), now(), null, 'Elasticsearch bitnami helm chart configuration default values.'); INSERT INTO global_config (key, config, "createdAt", "updatedAt", "deletedAt", description) VALUES ('publicChart', '{"block":false}', now(), now(), null, 'Potential Danger: If set to true lifecycle.yaml will allow any public helm chart to be deployed. Otherwise only charts defined in global_config will be allowed.'); - INSERT INTO global_config (key, config, "createdAt", "updatedAt", "deletedAt", description) VALUES ('lifecycleDefaults', '{"defaultUUID":"dev-0","defaultPublicUrl":"dev-0.app.0env.com","cfStepType":"helm:1.1.12","ecrDomain":"${ - IS_DEV ? '10.96.188.230:5000' : 'distribution.0env.com' + INSERT INTO global_config (key, config, "createdAt", "updatedAt", "deletedAt", description) VALUES ('lifecycleDefaults', '{"defaultUUID":"dev-0","defaultPublicUrl":"dev-0.app.example.com","cfStepType":"helm:1.1.12","ecrDomain":"${ + IS_DEV ? '10.96.188.230:5000' : process.env.DISTRIBUTION_HOST || 'distribution.example.com' }","ecrRegistry":"default","buildPipeline":"","deployCluster":"lifecycle-gke","helmDeployPipeline":"replace_me"}', now(), now(), null, 'Default values for lifecycle'); INSERT INTO global_config (key, config, "createdAt", "updatedAt", "deletedAt", description) VALUES ('helmDefaults', '{"version":"3.12.0","nativeHelm":{"enabled":true,"defaultArgs":"--wait --reset-values --timeout 30m","defaultHelmVersion":"3.12.0"}}', now(), now(), null, 'Default configuration for helm deployments.'); INSERT INTO global_config (key, config, "createdAt", "updatedAt", "deletedAt", description) VALUES ('socat-tunneller', '{"version":"3.7.2","args":"--force --timeout 60m0s --wait","action":"install","chart":{"name":"isotoma/socat-tunneller","repoUrl":" https://isotoma.github.io/charts","version":"0.2.0","values":[],"valueFiles":[]},"label":"podAnnotations","tolerations":"tolerations","affinity":"affinity","nodeSelector":"nodeSelector"}', now(), now(), null, 'soca-tunneller configuration for db-tunnels with helm'); diff --git a/src/server/db/migrations/003_add_build_defaults.ts b/src/server/db/migrations/003_add_build_defaults.ts index bb48e9f3..570e0e4e 100644 --- a/src/server/db/migrations/003_add_build_defaults.ts +++ b/src/server/db/migrations/003_add_build_defaults.ts @@ -18,7 +18,7 @@ import { Knex } from 'knex'; export async function up(knex: Knex): Promise { const IS_DEV = process.env.APP_ENV === 'dev'; - const cacheRegistry = IS_DEV ? '10.96.188.230:5000' : 'distribution.0env.com'; + const cacheRegistry = IS_DEV ? '10.96.188.230:5000' : process.env.DISTRIBUTION_HOST || 'distribution.example.com'; const existingConfig = await knex('global_config').where('key', 'buildDefaults').first(); diff --git a/src/server/lib/__tests__/utils.test.ts b/src/server/lib/__tests__/utils.test.ts index 967bd1c7..cc934628 100644 --- a/src/server/lib/__tests__/utils.test.ts +++ b/src/server/lib/__tests__/utils.test.ts @@ -145,7 +145,7 @@ describe('constructEcrRepoPath', () => { }); test('appends service name for internal registries', () => { - const result = constructEcrRepoPath('my-repo/my-service/lfc', 'service-name', 'distribution.0env.com'); + const result = constructEcrRepoPath('my-repo/my-service/lfc', 'service-name', 'distribution.example.com'); expect(result).toBe('my-repo/my-service/lfc/service-name'); }); @@ -155,12 +155,16 @@ describe('constructEcrRepoPath', () => { }); test('does not append service name if already present at the end', () => { - const result = constructEcrRepoPath('my-repo/my-service/lfc/service-name', 'service-name', 'distribution.0env.com'); + const result = constructEcrRepoPath( + 'my-repo/my-service/lfc/service-name', + 'service-name', + 'distribution.example.com' + ); expect(result).toBe('my-repo/my-service/lfc/service-name'); }); test('appends service name even if it exists elsewhere in the path', () => { - const result = constructEcrRepoPath('service-name/repo', 'service-name', 'distribution.0env.com'); + const result = constructEcrRepoPath('service-name/repo', 'service-name', 'distribution.example.com'); expect(result).toBe('service-name/repo/service-name'); }); @@ -180,12 +184,12 @@ describe('constructEcrRepoPath', () => { }); test('handles service name with special characters', () => { - const result = constructEcrRepoPath('my-repo', 'my-service-v2.1', 'distribution.0env.com'); + const result = constructEcrRepoPath('my-repo', 'my-service-v2.1', 'distribution.example.com'); expect(result).toBe('my-repo/my-service-v2.1'); }); test('handles base repo with trailing slash', () => { - const result = constructEcrRepoPath('my-repo/', 'my-service', 'distribution.0env.com'); + const result = constructEcrRepoPath('my-repo/', 'my-service', 'distribution.example.com'); expect(result).toBe('my-repo//my-service'); }); }); diff --git a/src/server/lib/nativeBuild/engines.ts b/src/server/lib/nativeBuild/engines.ts index b16b11e7..f21e033d 100644 --- a/src/server/lib/nativeBuild/engines.ts +++ b/src/server/lib/nativeBuild/engines.ts @@ -235,7 +235,7 @@ export async function buildWithEngine( const jobTimeout = options.jobTimeout || buildDefaults.jobTimeout || 2100; const resources = options.resources || buildDefaults.resources?.[engineName] || DEFAULT_BUILD_RESOURCES[engineName]; - let cacheRegistry = options.cacheRegistry || buildDefaults.cacheRegistry || 'distribution.0env.com'; + let cacheRegistry = options.cacheRegistry || buildDefaults.cacheRegistry; if (engineName === 'buildkit' && buildDefaults.buildkit?.endpoint) { cacheRegistry = options.ecrDomain; } diff --git a/src/server/services/deploy.ts b/src/server/services/deploy.ts index cb730574..3a1f7bac 100644 --- a/src/server/services/deploy.ts +++ b/src/server/services/deploy.ts @@ -956,7 +956,7 @@ export default class DeployService extends BaseService { namespace: deploy.build.namespace, buildId: String(deploy.build.id), deployUuid: deploy.uuid, // Use the full deploy UUID which includes service name - cacheRegistry: buildDefaults?.cacheRegistry || 'distribution.0env.com', + cacheRegistry: buildDefaults?.cacheRegistry, }; if (!initDockerfilePath) {