Skip to content
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
143 commits
Select commit Hold shift + click to select a range
aa2c05e
feat: use argcd manifest-generate-paths for monorepos
j-zimnowoda Feb 24, 2026
bf01db6
Merge branch 'main' into APL-1491-2
svcAPLBot Feb 25, 2026
99edd7e
Merge branch 'main' into APL-1491-2
svcAPLBot Feb 25, 2026
346317c
Merge branch 'main' into APL-1491-2
svcAPLBot Feb 25, 2026
5c2c69b
Merge branch 'main' into APL-1491-2
svcAPLBot Feb 25, 2026
0cea38c
Merge branch 'main' into APL-1491-2
svcAPLBot Feb 25, 2026
5b51c55
Merge branch 'main' into APL-1491-2
svcAPLBot Feb 25, 2026
69aac0e
Merge branch 'main' into APL-1491-2
svcAPLBot Feb 25, 2026
1680231
Merge branch 'main' into APL-1491-2
svcAPLBot Feb 25, 2026
f2a7389
Merge branch 'main' into APL-1491-2
svcAPLBot Feb 27, 2026
4233451
Merge branch 'main' into APL-1491-2
svcAPLBot Feb 27, 2026
f883af0
Merge branch 'main' into APL-1491-2
svcAPLBot Feb 27, 2026
211bd25
Merge branch 'main' into APL-1491-2
svcAPLBot Feb 27, 2026
59a664f
Merge branch 'main' into APL-1491-2
svcAPLBot Feb 27, 2026
32ab03f
Merge branch 'main' into APL-1491-2
svcAPLBot Mar 2, 2026
7785927
Merge branch 'main' into APL-1491-2
svcAPLBot Mar 2, 2026
e2f5ac6
Merge branch 'main' into APL-1491-2
svcAPLBot Mar 3, 2026
0c6c41d
Merge branch 'main' into APL-1491-2
svcAPLBot Mar 3, 2026
b31713d
Merge branch 'main' into APL-1491-2
svcAPLBot Mar 4, 2026
7db0d5e
Merge branch 'main' into APL-1491-2
svcAPLBot Mar 4, 2026
eba430f
Merge branch 'main' into APL-1491-2
svcAPLBot Mar 4, 2026
780bfba
Merge branch 'main' into APL-1491-2
svcAPLBot Mar 4, 2026
9d65724
Merge branch 'main' into APL-1491-2
svcAPLBot Mar 5, 2026
049bfd1
Merge branch 'main' into APL-1491-2
svcAPLBot Mar 9, 2026
a1d8008
Merge branch 'main' into APL-1491-2
svcAPLBot Mar 9, 2026
dd0448a
Merge branch 'main' into APL-1491-2
svcAPLBot Mar 10, 2026
9160b43
Merge branch 'main' into APL-1491-2
svcAPLBot Mar 10, 2026
f46d05e
Merge branch 'main' into APL-1491-2
svcAPLBot Mar 10, 2026
04b1f77
Merge branch 'main' into APL-1491-2
svcAPLBot Mar 10, 2026
5165499
Merge branch 'main' into APL-1491-2
svcAPLBot Mar 10, 2026
fc44df2
Merge branch 'main' into APL-1491-2
svcAPLBot Mar 10, 2026
01929ca
Merge branch 'main' into APL-1491-2
svcAPLBot Mar 10, 2026
53ffb2d
Merge branch 'main' into APL-1491-2
svcAPLBot Mar 10, 2026
72b1ce9
Merge branch 'main' into APL-1491-2
svcAPLBot Mar 10, 2026
81e4f8c
Merge branch 'main' into APL-1491-2
svcAPLBot Mar 10, 2026
657011a
Merge branch 'main' into APL-1491-2
svcAPLBot Mar 10, 2026
fe0e456
Merge branch 'main' into APL-1491-2
svcAPLBot Mar 11, 2026
496f19a
Merge branch 'main' into APL-1491-2
svcAPLBot Mar 11, 2026
eb8ef78
Merge branch 'main' into APL-1491-2
svcAPLBot Mar 11, 2026
c7e2e38
Merge branch 'main' into APL-1491-2
svcAPLBot Mar 11, 2026
62c6274
Merge branch 'main' into APL-1491-2
svcAPLBot Mar 11, 2026
1fbf7c1
Merge branch 'main' into APL-1491-2
svcAPLBot Mar 11, 2026
fae0496
Merge branch 'main' into APL-1491-2
svcAPLBot Mar 12, 2026
0e2fdfc
Merge branch 'main' into APL-1491-2
svcAPLBot Mar 12, 2026
ee44ae4
Merge branch 'main' into APL-1491-2
svcAPLBot Mar 12, 2026
57dc5f5
Merge branch 'main' into APL-1491-2
svcAPLBot Mar 12, 2026
c4633ce
Merge branch 'main' into APL-1491-2
svcAPLBot Mar 12, 2026
0c75585
Merge branch 'main' into APL-1491-2
svcAPLBot Mar 13, 2026
1a1c60a
Merge branch 'main' into APL-1491-2
svcAPLBot Mar 13, 2026
b68f411
Merge branch 'main' into APL-1491-2
svcAPLBot Mar 13, 2026
2d7aa9f
Merge branch 'main' into APL-1491-2
svcAPLBot Mar 13, 2026
72c92a0
Merge branch 'main' into APL-1491-2
svcAPLBot Mar 16, 2026
f8047b1
Merge branch 'main' into APL-1491-2
svcAPLBot Mar 16, 2026
04e8dc5
Merge branch 'main' into APL-1491-2
svcAPLBot Mar 17, 2026
2a6dc13
Merge branch 'main' into APL-1491-2
svcAPLBot Mar 18, 2026
4950148
Merge branch 'main' into APL-1491-2
svcAPLBot Mar 19, 2026
ad55cee
Merge branch 'main' into APL-1491-2
svcAPLBot Mar 20, 2026
e87761e
Merge branch 'main' into APL-1491-2
svcAPLBot Mar 20, 2026
5986f4a
Merge branch 'main' into APL-1491-2
svcAPLBot Mar 20, 2026
3fdfd82
Merge branch 'main' into APL-1491-2
svcAPLBot Mar 20, 2026
82f55e9
Merge branch 'main' into APL-1491-2
svcAPLBot Mar 20, 2026
bb34dd0
Merge branch 'main' into APL-1491-2
svcAPLBot Mar 20, 2026
2fe8e58
Merge branch 'main' into APL-1491-2
svcAPLBot Mar 23, 2026
93934df
Merge branch 'main' into APL-1491-2
svcAPLBot Mar 23, 2026
f198fca
Merge branch 'main' into APL-1491-2
svcAPLBot Mar 23, 2026
fe011f8
Merge branch 'main' into APL-1491-2
svcAPLBot Mar 23, 2026
448a491
Merge branch 'main' into APL-1491-2
svcAPLBot Mar 23, 2026
3b0f880
Merge branch 'main' into APL-1491-2
svcAPLBot Mar 30, 2026
c3ba0d4
Merge branch 'main' into APL-1491-2
svcAPLBot Mar 30, 2026
379346c
Merge branch 'main' into APL-1491-2
svcAPLBot Mar 30, 2026
dd22928
Merge branch 'main' into APL-1491-2
svcAPLBot Mar 30, 2026
77f144f
Merge branch 'main' into APL-1491-2
svcAPLBot Mar 30, 2026
e1e1e95
Merge branch 'main' into APL-1491-2
svcAPLBot Mar 31, 2026
eaab31e
Merge branch 'main' into APL-1491-2
svcAPLBot Mar 31, 2026
b502aae
Merge branch 'main' into APL-1491-2
svcAPLBot Apr 1, 2026
07a0b09
Merge branch 'main' into APL-1491-2
svcAPLBot Apr 1, 2026
7adf888
Merge branch 'main' into APL-1491-2
svcAPLBot Apr 1, 2026
1ad00fb
Merge branch 'main' into APL-1491-2
svcAPLBot Apr 1, 2026
be44045
Merge branch 'main' into APL-1491-2
svcAPLBot Apr 1, 2026
7ec2f7b
Merge branch 'main' into APL-1491-2
svcAPLBot Apr 2, 2026
88d2848
Merge branch 'main' into APL-1491-2
svcAPLBot Apr 7, 2026
10d9ce0
Merge branch 'main' into APL-1491-2
svcAPLBot Apr 8, 2026
b9ca385
Merge branch 'main' into APL-1491-2
svcAPLBot Apr 8, 2026
5f13774
Merge branch 'main' into APL-1491-2
svcAPLBot Apr 8, 2026
e32ceda
Merge branch 'main' into APL-1491-2
svcAPLBot Apr 8, 2026
a5eabdd
Merge branch 'main' into APL-1491-2
svcAPLBot Apr 8, 2026
7f0aa12
Merge branch 'main' into APL-1491-2
svcAPLBot Apr 8, 2026
749ca91
Merge branch 'main' into APL-1491-2
svcAPLBot Apr 9, 2026
0a1fd7d
Merge branch 'main' into APL-1491-2
svcAPLBot Apr 9, 2026
d3683e9
Merge branch 'main' into APL-1491-2
svcAPLBot Apr 9, 2026
eb1eced
Merge branch 'main' into APL-1491-2
svcAPLBot Apr 9, 2026
815e622
Merge branch 'main' into APL-1491-2
svcAPLBot Apr 9, 2026
5829c4a
Merge branch 'main' into APL-1491-2
svcAPLBot Apr 9, 2026
41922de
Merge branch 'main' into APL-1491-2
svcAPLBot Apr 9, 2026
29c4e66
Merge branch 'main' into APL-1491-2
svcAPLBot Apr 9, 2026
4c9ce58
Merge branch 'main' into APL-1491-2
svcAPLBot Apr 9, 2026
f2a0a9d
Merge branch 'main' into APL-1491-2
svcAPLBot Apr 9, 2026
3e6e127
Merge branch 'main' into APL-1491-2
svcAPLBot Apr 9, 2026
ae978a0
Merge branch 'main' into APL-1491-2
svcAPLBot Apr 10, 2026
d3714e5
Merge branch 'main' into APL-1491-2
svcAPLBot Apr 10, 2026
0bc23b8
Merge branch 'main' into APL-1491-2
svcAPLBot Apr 10, 2026
54712bb
Merge branch 'main' into APL-1491-2
svcAPLBot Apr 13, 2026
473d724
Merge branch 'main' into APL-1491-2
svcAPLBot Apr 13, 2026
91433b0
Merge branch 'main' into APL-1491-2
svcAPLBot Apr 13, 2026
80d203c
Merge branch 'main' into APL-1491-2
svcAPLBot Apr 13, 2026
49f7362
Merge branch 'main' into APL-1491-2
svcAPLBot Apr 13, 2026
006d003
Merge branch 'main' into APL-1491-2
svcAPLBot Apr 13, 2026
8adce5a
Merge branch 'main' into APL-1491-2
svcAPLBot Apr 13, 2026
a9c5dca
Merge branch 'main' into APL-1491-2
svcAPLBot Apr 14, 2026
789bdb3
Merge branch 'main' into APL-1491-2
svcAPLBot Apr 14, 2026
c04f1e2
Merge branch 'main' into APL-1491-2
svcAPLBot Apr 14, 2026
f61ca1f
Merge branch 'main' into APL-1491-2
svcAPLBot Apr 14, 2026
bcc614a
Merge branch 'main' into APL-1491-2
svcAPLBot Apr 14, 2026
f5ba59b
Merge branch 'main' into APL-1491-2
svcAPLBot Apr 14, 2026
30bf979
Merge branch 'main' into APL-1491-2
svcAPLBot Apr 15, 2026
3f1cfc9
Merge branch 'main' into APL-1491-2
svcAPLBot Apr 16, 2026
310c07a
Merge branch 'main' into APL-1491-2
svcAPLBot Apr 16, 2026
74e6370
Merge branch 'main' into APL-1491-2
svcAPLBot Apr 16, 2026
44aa046
Merge branch 'main' into APL-1491-2
svcAPLBot Apr 16, 2026
c2e6a6b
Merge branch 'main' into APL-1491-2
svcAPLBot Apr 16, 2026
69c2ab2
Merge branch 'main' into APL-1491-2
svcAPLBot Apr 17, 2026
0b5c90b
Merge branch 'main' into APL-1491-2
svcAPLBot Apr 17, 2026
ca22e42
Merge branch 'main' into APL-1491-2
svcAPLBot Apr 20, 2026
8da432e
Merge branch 'main' into APL-1491-2
svcAPLBot Apr 20, 2026
f906618
Merge branch 'main' into APL-1491-2
svcAPLBot Apr 20, 2026
fef97ff
Merge branch 'main' into APL-1491-2
svcAPLBot Apr 20, 2026
b177546
Merge branch 'main' into APL-1491-2
svcAPLBot Apr 21, 2026
3d209ae
Merge branch 'main' into APL-1491-2
svcAPLBot Apr 21, 2026
6bd2354
Merge branch 'main' into APL-1491-2
svcAPLBot Apr 21, 2026
cd42950
Merge branch 'main' into APL-1491-2
svcAPLBot Apr 21, 2026
128e820
Merge branch 'main' into APL-1491-2
svcAPLBot Apr 21, 2026
d7cf2c6
Merge branch 'main' into APL-1491-2
svcAPLBot Apr 21, 2026
534fa06
Merge branch 'main' into APL-1491-2
svcAPLBot Apr 21, 2026
029d435
Merge branch 'main' into APL-1491-2
svcAPLBot Apr 22, 2026
0c867ee
Merge branch 'main' into APL-1491-2
svcAPLBot Apr 23, 2026
edc0bf2
Merge branch 'main' into APL-1491-2
svcAPLBot Apr 23, 2026
6d80d77
Merge branch 'main' into APL-1491-2
svcAPLBot Apr 23, 2026
f22bffe
Merge branch 'main' into APL-1491-2
svcAPLBot Apr 23, 2026
3e8375d
Merge branch 'main' into APL-1491-2
svcAPLBot Apr 23, 2026
1e75cbc
Merge branch 'main' into APL-1491-2
svcAPLBot Apr 24, 2026
5e54aa9
Merge branch 'main' into APL-1491-2
svcAPLBot Apr 24, 2026
d1dbcaf
Merge branch 'main' into APL-1491-2
svcAPLBot Apr 24, 2026
a8ab2aa
Merge branch 'main' into APL-1491-2
svcAPLBot Apr 24, 2026
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
53 changes: 44 additions & 9 deletions src/cmd/apply-as-apps.test.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
import { statSync } from 'fs'
import { glob } from 'glob'
import { ARGOCD_APP_PARAMS } from '../common/constants'
import { env } from '../common/envalid'
import {
applyGitOpsApps,
getApplications,
applyArgocdApp,
addGitOpsApps,
removeGitOpsApps,
applyArgocdApp,
applyGitOpsApps,
ArgocdAppManifest,
calculateGitOpsAppsDiff,
getApplications,
getArgocdGitopsManifest,
ArgocdAppManifest,
getPathsFromSpec,
removeGitOpsApps,
} from './apply-as-apps'
import { glob } from 'glob'
import { env } from '../common/envalid'
import { statSync } from 'fs'
import { ARGOCD_APP_PARAMS } from '../common/constants'

jest.mock('glob')
jest.mock('fs', () => ({
Expand Down Expand Up @@ -81,6 +82,7 @@ describe('getArgocdGitopsManifest', () => {
},
annotations: {
'argocd.argoproj.io/compare-options': 'ServerSideDiff=true,IncludeMutationWebhook=true',
'argocd.argoproj.io/manifest-generate-paths': '/env/manifests/global',
},
finalizers: ['resources-finalizer.argocd.argoproj.io'],
},
Expand Down Expand Up @@ -124,6 +126,7 @@ describe('getArgocdGitopsManifest', () => {
},
annotations: {
'argocd.argoproj.io/compare-options': 'ServerSideDiff=true,IncludeMutationWebhook=true',
'argocd.argoproj.io/manifest-generate-paths': '/env/manifests/ns/my-namespace',
},
finalizers: ['resources-finalizer.argocd.argoproj.io'],
},
Expand Down Expand Up @@ -152,6 +155,38 @@ describe('getArgocdGitopsManifest', () => {
})
})

describe('getPathsFromSpec', () => {
it('should normalize source.path by prepending slash when missing', () => {
const paths = getPathsFromSpec({ source: { path: 'charts/my-app' } })
expect(paths).toBe('/charts/my-app')
})

it('should keep source.path unchanged when it already starts with slash', () => {
const paths = getPathsFromSpec({ source: { path: '/charts/my-app' } })
expect(paths).toBe('/charts/my-app')
})

it('should return normalized semicolon-separated paths for sources', () => {
const paths = getPathsFromSpec({
sources: [{ path: 'env/manifests/global' }, { path: '/env/manifests/ns/team-a' }],
})
expect(paths).toBe('/env/manifests/global;/env/manifests/ns/team-a')
})

it('should ignore non-string and empty source paths', () => {
const paths = getPathsFromSpec({
sources: [{ path: 'env/manifests/global' }, { path: '' }, { path: 123 }, { path: null }, {}],
})
expect(paths).toBe('/env/manifests/global')
})

it('should return undefined when no valid path exists', () => {
expect(getPathsFromSpec({})).toBeUndefined()
expect(getPathsFromSpec({ source: { path: 123 } })).toBeUndefined()
expect(getPathsFromSpec({ sources: [{ path: '' }, { path: null }] })).toBeUndefined()
})
})

describe('applyArgoCdApp', () => {
const mockManifest: ArgocdAppManifest = {
apiVersion: 'argoproj.io/v1alpha1',
Expand Down
39 changes: 33 additions & 6 deletions src/cmd/apply-as-apps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
setHeaderOptions,
V1ResourceRequirements,
} from '@kubernetes/client-node'
import { existsSync, statSync, mkdirSync, rmSync } from 'fs'
import { glob } from 'glob'
import { existsSync, mkdirSync, rmSync, statSync } from 'fs'
import { readFile } from 'fs/promises'
import { glob } from 'glob'
import { appPatches, genericPatch } from 'src/applicationPatches.json'
import { cleanupHandler, prepareEnvironment } from 'src/common/cli'
import { logLevelString, terminal } from 'src/common/debug'
Expand Down Expand Up @@ -93,7 +93,35 @@
return `${release.namespace}-${release.name}`
}

const normalizeArgoSourcePath = (path: string): string => {
if (!path) return path
return path.startsWith('/') ? path : `/${path}`
}

export const getPathsFromSpec = (spec: Record<string, any>): string | undefined => {
if (typeof spec?.source?.path === 'string' && spec.source.path.length > 0) {
return normalizeArgoSourcePath(spec.source.path)
}
if (spec?.sources && Array.isArray(spec.sources)) {
const normalizedPaths = spec.sources
.map((source: { path?: string }) => source?.path)
.filter((path): path is string => typeof path === 'string' && path.length > 0)
.map((path: string) => normalizeArgoSourcePath(path))
return normalizedPaths.length > 0 ? normalizedPaths.join(';') : undefined
}

return undefined
}

const getArgoCdAppManifest = (name: string, appLabel: string, spec: Record<string, any>): ArgocdAppManifest => {
const annotations = {
'argocd.argoproj.io/compare-options': 'ServerSideDiff=true,IncludeMutationWebhook=true',
}
const paths = getPathsFromSpec(spec)
if (paths) {
annotations['argocd.argoproj.io/manifest-generate-paths'] = paths
}

return {
apiVersion: 'argoproj.io/v1alpha1',
kind: 'Application',
Expand All @@ -103,9 +131,7 @@
'otomi.io/app': appLabel,
},
namespace: 'argocd',
annotations: {
'argocd.argoproj.io/compare-options': 'ServerSideDiff=true,IncludeMutationWebhook=true',
},
annotations,
finalizers: ['resources-finalizer.argocd.argoproj.io'],
},
spec,
Expand All @@ -119,12 +145,13 @@
): ArgocdAppManifest => {
const name = getAppName(release)
const patch = (appPatches[name] || genericPatch) as Record<string, any>
const chartPath = release.chart.replace('../', '')

Check failure

Code scanning / CodeQL

Incomplete string escaping or encoding High

This replaces only the first occurrence of '../'.

Copilot Autofix

AI 25 days ago

Use a global replacement so all ../ occurrences are removed, not just the first.

Best minimal fix in src/cmd/apply-as-apps.ts (line 147 region): replace

  • release.chart.replace('../', '')

with

  • release.chart.replace(/\.\.\//g, '')

This keeps existing functionality (strip parent-directory markers) while making it complete for repeated segments. No new imports, methods, or dependencies are required.

Suggested changeset 1
src/cmd/apply-as-apps.ts

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/src/cmd/apply-as-apps.ts b/src/cmd/apply-as-apps.ts
--- a/src/cmd/apply-as-apps.ts
+++ b/src/cmd/apply-as-apps.ts
@@ -144,7 +144,7 @@
 ): ArgocdAppManifest => {
   const name = getAppName(release)
   const patch = (appPatches[name] || genericPatch) as Record<string, any>
-  const chartPath = release.chart.replace('../', '')
+  const chartPath = release.chart.replace(/\.\.\//g, '')
   return getArgoCdAppManifest(name, ARGOCD_APP_DEFAULT_LABEL, {
     syncPolicy: ARGOCD_APP_DEFAULT_SYNC_POLICY,
     project: 'default',
EOF
@@ -144,7 +144,7 @@
): ArgocdAppManifest => {
const name = getAppName(release)
const patch = (appPatches[name] || genericPatch) as Record<string, any>
const chartPath = release.chart.replace('../', '')
const chartPath = release.chart.replace(/\.\.\//g, '')
return getArgoCdAppManifest(name, ARGOCD_APP_DEFAULT_LABEL, {
syncPolicy: ARGOCD_APP_DEFAULT_SYNC_POLICY,
project: 'default',
Copilot is powered by AI and may make mistakes. Always verify output.
return getArgoCdAppManifest(name, ARGOCD_APP_DEFAULT_LABEL, {
syncPolicy: ARGOCD_APP_DEFAULT_SYNC_POLICY,
project: 'default',
revisionHistoryLimit: 2,
source: {
path: release.chart.replace('../', ''),
path: chartPath,
repoURL: env.APPS_REPO_URL,
targetRevision: env.APPS_REVISION || otomiVersion,
helm: {
Expand Down
Loading