Skip to content

Commit dcb73a1

Browse files
committed
fix: 🐛 add retro compatibility for 8.24.2
1 parent ff3011d commit dcb73a1

File tree

4 files changed

+44
-20
lines changed

4 files changed

+44
-20
lines changed

files/logo.png

1.16 KB
Loading

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@cpn-console/observability-plugin",
33
"type": "module",
4-
"version": "0.1.3",
4+
"version": "0.1.2-patch-1",
55
"description": "Loki plugin for DSO console",
66
"exports": {
77
".": {

src/infos.ts

Lines changed: 39 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -8,24 +8,45 @@ const imageData = Buffer.from((readFileSync(join(import.meta.dirname, '../files/
88

99
const infos = {
1010
name: 'observability',
11-
to: ({ project }) => [
12-
{
13-
to: `${getConfig().grafanaUrl}/prod-${compressUUID(project.id)}`,
14-
description: 'Production',
15-
},
16-
{
17-
to: `${getConfig().grafanaUrl}/prod-${project.slug}`,
18-
description: 'Production ancien',
19-
},
20-
{
21-
to: `${getConfig().grafanaUrl}/hprod-${compressUUID(project.id)}`,
22-
description: 'Hors production',
23-
},
24-
{
25-
to: `${getConfig().grafanaUrl}/hprod-${project.slug}`,
26-
description: 'Hors production ancien',
27-
},
28-
],
11+
// @ts-ignore retro compatibility
12+
to: ({ project, projectId, organization }) => {
13+
let isInfV9 = false
14+
const params = {
15+
id: '',
16+
slug: '',
17+
}
18+
const grafanaUrl = getConfig().grafanaUrl
19+
if (typeof project === 'string' && typeof organization === 'string') {
20+
params.id = projectId
21+
params.slug = `${organization}-${project}`
22+
isInfV9 = true
23+
} else {
24+
params.id = project.id
25+
params.slug = project.slug
26+
}
27+
return [
28+
{
29+
to: `${grafanaUrl}/prod-${compressUUID(String(params.id))}`,
30+
title: isInfV9 ? 'Production' : undefined,
31+
description: 'Production',
32+
},
33+
{
34+
to: `${grafanaUrl}/prod-${params.slug}`,
35+
title: isInfV9 ? 'Production ancien' : undefined,
36+
description: 'Production ancien',
37+
},
38+
{
39+
to: `${grafanaUrl}/hprod-${compressUUID(String(params.id))}`,
40+
title: isInfV9 ? 'Hors production' : undefined,
41+
description: 'Hors production',
42+
},
43+
{
44+
to: `${grafanaUrl}/hprod-${params.slug}`,
45+
title: isInfV9 ? 'Hors production ancien' : undefined,
46+
description: 'Hors production ancien',
47+
},
48+
]
49+
},
2950
title: 'Grafana',
3051
imgSrc: `data:image/png;base64,${imageData}`,
3152
description: 'Grafana est un outil de métrique et de logs',

src/yaml.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ const valuesPath = 'helm/values.yaml'
2020
const valuesBranch = 'main'
2121

2222
interface ProjectLoki {
23+
project: string
2324
name: string
2425
groups: string[]
2526
uuid: string
@@ -116,9 +117,10 @@ export async function upsertGitlabConfig(project: Project, gitlabApi: GitlabInte
116117
for (const tenant of yamlFile.global.tenants) {
117118
if (tenant.uuid !== project.id) continue
118119
if (tenant.name in tenants) {
119-
if (tenant.groups.toString() !== tenants[tenant.name].toString()) {
120+
if (tenant.groups.toString() !== tenants[tenant.name].toString() || tenant.project !== project.slug) {
120121
needUpdates = true
121122
tenant.groups = structuredClone(tenants[tenant.name])
123+
tenant.project = project.slug
122124
}
123125
notFoundTenants = notFoundTenants.filter(notFoundTenant => notFoundTenant !== tenant.name)
124126
} else {
@@ -131,6 +133,7 @@ export async function upsertGitlabConfig(project: Project, gitlabApi: GitlabInte
131133
groups: structuredClone(tenants[notFoundTenant]),
132134
name: notFoundTenant,
133135
uuid: project.id,
136+
project: project.slug,
134137
}))
135138

136139
yamlFile = {

0 commit comments

Comments
 (0)