Skip to content

Commit 8f0cc6b

Browse files
merllsvcAPLBot
andauthored
feat: set custom repository and use selectors on argocd applications (#2286)
Co-authored-by: svcAPLBot <[email protected]>
1 parent 3b53e6b commit 8f0cc6b

File tree

3 files changed

+25
-12
lines changed

3 files changed

+25
-12
lines changed

src/cmd/apply-as-apps.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import { getParsedArgs, HelmArguments, helmOptions, setParsedArgs } from 'src/co
1212
import { Argv, CommandModule } from 'yargs'
1313
import { $ } from 'zx'
1414
import { V1ResourceRequirements } from '@kubernetes/client-node'
15+
import { env } from '../common/envalid'
1516

1617
const cmdName = getFilename(__filename)
1718
const dir = '/tmp/otomi'
@@ -44,7 +45,7 @@ const getAppName = (release: HelmRelease): string => {
4445
return `${release.namespace}-${release.name}`
4546
}
4647

47-
const getArgocdAppManifest = (release: HelmRelease, values: Record<string, any>, otomiVersion) => {
48+
const getArgocdAppManifest = (release: HelmRelease, values: Record<string, any>, otomiVersion: string) => {
4849
const name = getAppName(release)
4950
const patch = appPatches[name] || genericPatch
5051
return {
@@ -72,8 +73,8 @@ const getArgocdAppManifest = (release: HelmRelease, values: Record<string, any>,
7273
project: 'default',
7374
source: {
7475
path: release.chart.replace('../', ''),
75-
repoURL: 'https://github.com/linode/apl-core.git',
76-
targetRevision: otomiVersion,
76+
repoURL: env.APPS_REPO_URL,
77+
targetRevision: env.APPS_REVISION || otomiVersion,
7778
helm: {
7879
releaseName: release.name,
7980
values: objectToYaml(values),

src/cmd/apply.ts

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -163,15 +163,19 @@ const apply = async (): Promise<void> => {
163163
}
164164
d.info('Start apply')
165165
const skipCleanup = argv.skipCleanup ? '--skip-cleanup' : ''
166-
await hf(
167-
{
168-
fileOpts: argv.file,
169-
labelOpts: argv.label,
170-
logLevel: logLevelString(),
171-
args: ['apply', '--include-needs', skipCleanup],
172-
},
173-
{ streams: { stdout: d.stream.log, stderr: d.stream.error } },
174-
)
166+
if (argv.tekton) {
167+
await applyAsApps(argv)
168+
} else {
169+
await hf(
170+
{
171+
fileOpts: argv.file,
172+
labelOpts: argv.label,
173+
logLevel: logLevelString(),
174+
args: ['apply', '--include-needs', skipCleanup],
175+
},
176+
{ streams: { stdout: d.stream.log, stderr: d.stream.error } },
177+
)
178+
}
175179
}
176180

177181
export const module: CommandModule = {

src/common/envalid.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,14 @@ export const cliEnvSpec = {
3535
GIT_URL: str({ default: 'gitea-http.gitea.svc.cluster.local' }),
3636
GIT_PORT: str({ default: '3000' }),
3737
GIT_PROTOCOL: str({ default: 'http' }),
38+
APPS_REPO_URL: str({
39+
desc: 'Repository to set for ArgoCD applications',
40+
default: 'https://github.com/linode/apl-core.git',
41+
}),
42+
APPS_REVISION: str({
43+
desc: 'Target revision to set for ArgoCD applications. If not set, uses the current image tag.',
44+
default: undefined,
45+
}),
3846
}
3947

4048
export function cleanEnv<T>(spec: { [K in keyof T]: ValidatorSpec<T[K]> }, options?: CleanOptions<T>) {

0 commit comments

Comments
 (0)