Skip to content

feat: set custom repository and use selectors on argocd applications #2286

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jun 30, 2025
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
7 changes: 4 additions & 3 deletions src/cmd/apply-as-apps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { getParsedArgs, HelmArguments, helmOptions, setParsedArgs } from 'src/co
import { Argv, CommandModule } from 'yargs'
import { $ } from 'zx'
import { V1ResourceRequirements } from '@kubernetes/client-node'
import { env } from '../common/envalid'

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

const getArgocdAppManifest = (release: HelmRelease, values: Record<string, any>, otomiVersion) => {
const getArgocdAppManifest = (release: HelmRelease, values: Record<string, any>, otomiVersion: string) => {
const name = getAppName(release)
const patch = appPatches[name] || genericPatch
return {
Expand Down Expand Up @@ -72,8 +73,8 @@ const getArgocdAppManifest = (release: HelmRelease, values: Record<string, any>,
project: 'default',
source: {
path: release.chart.replace('../', ''),
repoURL: 'https://github.com/linode/apl-core.git',
targetRevision: otomiVersion,
repoURL: env.APPS_REPO_URL,
targetRevision: env.APPS_REVISION || otomiVersion,
helm: {
releaseName: release.name,
values: objectToYaml(values),
Expand Down
22 changes: 13 additions & 9 deletions src/cmd/apply.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,15 +163,19 @@ const apply = async (): Promise<void> => {
}
d.info('Start apply')
const skipCleanup = argv.skipCleanup ? '--skip-cleanup' : ''
await hf(
{
fileOpts: argv.file,
labelOpts: argv.label,
logLevel: logLevelString(),
args: ['apply', '--include-needs', skipCleanup],
},
{ streams: { stdout: d.stream.log, stderr: d.stream.error } },
)
if (argv.tekton) {
await applyAsApps(argv)
} else {
await hf(
{
fileOpts: argv.file,
labelOpts: argv.label,
logLevel: logLevelString(),
args: ['apply', '--include-needs', skipCleanup],
},
{ streams: { stdout: d.stream.log, stderr: d.stream.error } },
)
}
}

export const module: CommandModule = {
Expand Down
8 changes: 8 additions & 0 deletions src/common/envalid.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,14 @@ export const cliEnvSpec = {
GIT_URL: str({ default: 'gitea-http.gitea.svc.cluster.local' }),
GIT_PORT: str({ default: '3000' }),
GIT_PROTOCOL: str({ default: 'http' }),
APPS_REPO_URL: str({
desc: 'Repository to set for ArgoCD applications',
default: 'https://github.com/linode/apl-core.git',
}),
APPS_REVISION: str({
desc: 'Target revision to set for ArgoCD applications. If not set, uses the current image tag.',
default: undefined,
}),
}

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