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
8 changes: 6 additions & 2 deletions plugins/argocd/src/functions.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ import { faker } from '@faker-js/faker'
import { beforeEach, describe, expect, it, vi } from 'vitest'
import { stringify } from 'yaml'
import { deleteProject, upsertProject } from './functions.js'
import {
DEFAULT_DSO_ENV_CHART_VERSION,
DEFAULT_DSO_NS_CHART_VERSION,
} from './infos.js'

vi.mock('./utils.js', () => ({
generateAppProjectName: vi.fn(() => 'app-project-name'),
Expand Down Expand Up @@ -130,8 +134,8 @@ describe('argocd functions', () => {
cluster: 'in-cluster',
namespace: 'argocd',
project: 'app-project-name',
envChartVersion: 'dso-env-1.6.0',
nsChartVersion: 'dso-ns-1.1.5',
envChartVersion: DEFAULT_DSO_ENV_CHART_VERSION,
nsChartVersion: DEFAULT_DSO_NS_CHART_VERSION,
},
environment: {
valueFileRepository: infraProjectUrl,
Expand Down
18 changes: 11 additions & 7 deletions plugins/argocd/src/functions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,21 @@ function splitExtraRepositories(repos?: string): string[] {
return repos ? repos.split(',').map(repo => repo.trim()) : []
}

const DSO_NS_CHART_VERSION = process.env.DSO_NS_CHART_VERSION ?? DEFAULT_DSO_NS_CHART_VERSION
const DSO_ENV_CHART_VERSION
= process.env.DSO_ENV_CHART_VERSION ?? DEFAULT_DSO_ENV_CHART_VERSION

function getValueFilePath(p: Project, c: ClusterObject, e: Environment): string {
return `${p.name}/${c.label}/${e.name}/values.yaml`
}

export const upsertProject: StepCall<Project> = async (payload) => {
const project = payload.args
const gitlabApi = payload.apis.gitlab as unknown as GitlabProjectApi
const keycloakApi = payload.apis.keycloak as any
const vaultApi = payload.apis.vault as unknown as VaultProjectApi
const {
gitlab: gitlabApi,
keycloak: keycloakApi,
vault: vaultApi,
} = payload.apis

try {
const infraRepositories = project.repositories.filter(
Expand Down Expand Up @@ -123,8 +129,6 @@ async function ensureInfraEnvValues(
const projectDevopsGroupSuffix = config.argocd?.projectDevopsGroupPathSuffix ?? DEFAULT_PROJECT_DEVOPS_GROUP_PATH_SUFFIX
const projectDevelopperGroupSuffix = config.argocd?.projectDevelopperGroupPathSuffix ?? DEFAULT_PROJECT_DEVELOPER_GROUP_PATH_SUFFIX
const projectReadonlyGroupSuffix = config.argocd?.projectReadonlyGroupPathSuffix ?? DEFAULT_PROJECT_READONLY_GROUP_PATH_SUFFIX
const dsoEnvChartVersion = config.argocd?.dsoEnvChartVersion ?? DEFAULT_DSO_ENV_CHART_VERSION
const dsoNsChartVersion = config.argocd?.dsoNsChartVersion ?? DEFAULT_DSO_NS_CHART_VERSION
const cluster = getCluster(project, environment)
const infraProject = await gitlabApi.getProjectById(repoId)
const valueFilePath = getValueFilePath(project, cluster, environment)
Expand Down Expand Up @@ -162,8 +166,8 @@ async function ensureInfraEnvValues(
cluster: inClusterLabel,
namespace: getConfig().namespace,
project: appProjectName,
envChartVersion: dsoEnvChartVersion,
nsChartVersion: dsoNsChartVersion,
envChartVersion: DSO_ENV_CHART_VERSION,
nsChartVersion: DSO_NS_CHART_VERSION,
},
environment: {
valueFileRepository: infraProject.http_url_to_repo,
Expand Down
23 changes: 1 addition & 22 deletions plugins/argocd/src/infos.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export const DEFAULT_PROJECT_ADMIN_GROUP_PATH_SUFFIX = '/console/admin'
export const DEFAULT_PROJECT_DEVOPS_GROUP_PATH_SUFFIX = '/console/devops'
export const DEFAULT_PROJECT_DEVELOPER_GROUP_PATH_SUFFIX = '/console/developer'
export const DEFAULT_PROJECT_READONLY_GROUP_PATH_SUFFIX = '/console/readonly'

export const DEFAULT_DSO_ENV_CHART_VERSION = 'dso-env-1.6.0'
export const DEFAULT_DSO_NS_CHART_VERSION = 'dso-ns-1.1.5'
Comment thread
KepoParis marked this conversation as resolved.

Expand Down Expand Up @@ -92,28 +93,6 @@ const infos = {
title: 'Project Readonly Group Path Suffix',
value: DEFAULT_PROJECT_READONLY_GROUP_PATH_SUFFIX,
description: 'Suffixe du chemin du groupe lecture seule de projet',
}, {
key: 'dsoEnvChartVersion',
kind: 'text',
permissions: {
admin: { read: true, write: true },
user: { read: false, write: false },
},
title: 'DSO Env Chart Version',
value: DEFAULT_DSO_ENV_CHART_VERSION,
description: 'Version du chart Helm dso-env',
placeholder: DEFAULT_DSO_ENV_CHART_VERSION,
}, {
key: 'dsoNsChartVersion',
kind: 'text',
permissions: {
admin: { read: true, write: true },
user: { read: false, write: false },
},
title: 'DSO Namespace Chart Version',
value: DEFAULT_DSO_NS_CHART_VERSION,
description: 'Version du chart Helm dso-ns',
placeholder: DEFAULT_DSO_NS_CHART_VERSION,
}],
project: [{
key: 'extraRepositories',
Expand Down
Loading