Skip to content

Commit e4def7c

Browse files
committed
feat: ✨ new values schema
It breaks everything
1 parent 54a40fb commit e4def7c

File tree

6 files changed

+266
-89
lines changed

6 files changed

+266
-89
lines changed

.vscode/extensions.json

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{
2+
"recommendations": [
3+
// Cross-editor config
4+
"editorconfig.editorconfig",
5+
// Git
6+
"mhutchie.git-graph",
7+
"eamodio.gitlens",
8+
// Node / npm
9+
"christian-kohler.npm-intellisense",
10+
// JavaScript
11+
"dbaeumer.vscode-eslint",
12+
// Vue.js
13+
"vue.volar",
14+
"vue.vscode-typescript-vue-plugin",
15+
// Vitejs
16+
"antfu.vite",
17+
"antfu.browse-lite",
18+
// CSS
19+
"csstools.postcss",
20+
"stylelint.vscode-stylelint",
21+
// YAML
22+
"redhat.vscode-yaml",
23+
// Makdown
24+
"yzhang.markdown-all-in-one",
25+
// Kubernetes
26+
"ms-kubernetes-tools.vscode-kubernetes-tools"
27+
]
28+
}

.vscode/launch.json

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
// Utilisez IntelliSense pour en savoir plus sur les attributs possibles.
3+
// Pointez pour afficher la description des attributs existants.
4+
// Pour plus d'informations, visitez : https://go.microsoft.com/fwlink/?linkid=830387
5+
"version": "0.2.0",
6+
"configurations": [
7+
{
8+
"name": "Attach to Remote",
9+
"type": "node",
10+
"request": "attach",
11+
"port": 9229,
12+
"address": "127.0.0.1",
13+
"restart": true,
14+
"localRoot": "${workspaceFolder}/apps/server",
15+
"remoteRoot": "/app/apps/server",
16+
"skipFiles": [
17+
"<node_internals>/**",
18+
"${workspaceFolder}/node_modules/**/*.js"
19+
]
20+
}
21+
]
22+
}

.vscode/settings.json

Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
{
2+
// visuals
3+
"window.autoDetectColorScheme": true,
4+
"editor.fontLigatures": "'ss01', 'ss02', 'ss03', 'ss06', 'zero'",
5+
"editor.cursorBlinking": "phase",
6+
"editor.suggestSelection": "first",
7+
"editor.wordWrap": "on",
8+
"editor.bracketPairColorization.enabled": true,
9+
"editor.tabSize": 2,
10+
"search.exclude": {
11+
"**/.git": true,
12+
"**/.nuxt": true,
13+
"**/.pnpm": true,
14+
"**/.yarn": true,
15+
"**/.turbo": true,
16+
"**/dist/**": true,
17+
"**/out/**": true,
18+
"**/logs": true,
19+
"**/node_modules": true,
20+
"**/package-lock.json": true,
21+
"**/pnpm-lock.yaml": true,
22+
"**/yarn.lock": true
23+
},
24+
// general
25+
"editor.unicodeHighlight.invisibleCharacters": false,
26+
"workbench.startupEditor": "none",
27+
// git
28+
"git.autofetch": true,
29+
"git.untrackedChanges": "separate",
30+
// github
31+
"githubPullRequests.pullBranch": "never",
32+
// eslint
33+
"editor.codeActionsOnSave": {
34+
"source.fixAll.eslint": "explicit"
35+
},
36+
"eslint.validate": [
37+
"javascript",
38+
"javascriptreact",
39+
"typescript",
40+
"typescriptreact",
41+
"vue",
42+
"html",
43+
"markdown",
44+
"json",
45+
"jsonc",
46+
"yaml",
47+
"github-actions-workflow",
48+
"toml",
49+
"xml",
50+
"gql",
51+
"graphql",
52+
"astro",
53+
"svelte",
54+
"css",
55+
"less",
56+
"scss",
57+
"pcss",
58+
"postcss"
59+
],
60+
// stylelint
61+
"css.validate": true,
62+
"less.validate": true,
63+
"scss.validate": true,
64+
"files.associations": {
65+
"*.css": "css"
66+
},
67+
// languages
68+
"[javascript]": {
69+
"editor.defaultFormatter": "dbaeumer.vscode-eslint"
70+
},
71+
"javascript.preferences.quoteStyle": "single",
72+
"javascript.preferences.importModuleSpecifierEnding": "js",
73+
"javascript.suggest.completeJSDocs": true,
74+
"javascript.suggest.jsdoc.generateReturns": true,
75+
"[typescript]": {
76+
"editor.defaultFormatter": "dbaeumer.vscode-eslint"
77+
},
78+
"typescript.preferences.quoteStyle": "single",
79+
"typescript.preferences.importModuleSpecifierEnding": "js",
80+
"typescript.suggest.completeJSDocs": true,
81+
"typescript.suggest.jsdoc.generateReturns": true,
82+
"[vue]": {
83+
"editor.defaultFormatter": "dbaeumer.vscode-eslint"
84+
},
85+
"[css]": {
86+
"editor.defaultFormatter": "stylelint.vscode-stylelint"
87+
},
88+
"[html]": {
89+
"editor.defaultFormatter": "dbaeumer.vscode-eslint"
90+
},
91+
"[markdown]": {
92+
"editor.quickSuggestions": {
93+
"other": true,
94+
"comments": true,
95+
"strings": true
96+
},
97+
"editor.formatOnSave": true,
98+
"editor.formatOnPaste": true,
99+
"editor.defaultFormatter": "yzhang.markdown-all-in-one"
100+
},
101+
// conventional commits
102+
"conventionalCommits.showNewVersionNotes": false,
103+
// kubernetes
104+
"vs-kubernetes": {
105+
"vs-kubernetes.crd-code-completion": "enabled"
106+
},
107+
"vscode-kubernetes.log-viewer.follow": true,
108+
"vscode-kubernetes.log-viewer.timestamp": false,
109+
"vscode-kubernetes.log-viewer.since": -1,
110+
"vscode-kubernetes.log-viewer.tail": -1,
111+
"vscode-kubernetes.log-viewer.destination": "Webview",
112+
"vscode-kubernetes.log-viewer.wrap": true,
113+
// sonarqube
114+
"sonarlint.connectedMode.project": {
115+
"connectionId": "https://sonarqube.fabrique-numerique.fr",
116+
"projectKey": "cloud-pi-native_console_AYsa46O31ebDtzs-pYyZ"
117+
},
118+
"prisma-smart-formatter.typescript.defaultFormatter": "dbaeumer.vscode-eslint",
119+
"prisma-smart-formatter.prisma.defaultFormatter": "Prisma.prisma"
120+
}

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.2-patch-1",
4+
"version": "1.0.0",
55
"description": "Loki plugin for DSO console",
66
"exports": {
77
".": {

src/function.ts

Lines changed: 30 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ import { parseError, specificallyDisabled } from '@cpn-console/hooks'
55
import { compressUUID, removeTrailingSlash, requiredEnv } from '@cpn-console/shared'
66
import { Gitlab } from '@gitbeaker/rest'
77
import { deleteKeycloakGroup, ensureKeycloakGroups } from './keycloak.js'
8-
import { isNewNsName, type TenantKeycloakMapper } from './utils.js'
9-
import { deleteGitlabYamlConfig, upsertGitlabConfig } from './yaml.js'
8+
import { isNewNsName } from './utils.js'
9+
import { deleteGitlabYamlConfig, type ProjectLoki, type Type, upsertGitlabConfig } from './yaml.js'
1010

1111
const okSkipped: PluginResult = {
1212
status: {
@@ -78,32 +78,46 @@ export const upsertProject: StepCall<Project> = async (payload) => {
7878

7979
const compressedUUID = compressUUID(project.id)
8080

81-
const tenantsToCreate: TenantKeycloakMapper = {}
81+
const projectValue: ProjectLoki = {
82+
projectName: project.slug,
83+
envs: {
84+
hprod: {
85+
groups: [],
86+
tenants: {},
87+
},
88+
prod: {
89+
groups: [],
90+
tenants: {},
91+
},
92+
},
93+
}
8294

8395
for (const environment of payload.args.environments) {
8496
if (!environment.apis.kubernetes) {
8597
throw new Error(`no kubernetes apis on environment ${environment.name}`)
8698
}
8799
const name = isNewNsName(await environment.apis.kubernetes.getNsName()) ? compressedUUID : project.slug
88-
if (environment.stage === 'prod') {
89-
tenantsToCreate[`prod-${name}`] = {
90-
groups: tenantRbacProd,
91-
name,
92-
type: 'prod',
93-
}
94-
} else {
95-
tenantsToCreate[`hprod-${name}`] = {
96-
groups: tenantRbacHProd,
97-
name,
98-
type: 'hprod',
99-
}
100+
const env: Type = environment.stage === 'prod' ? 'prod' : 'hprod'
101+
const groups = environment.stage === 'prod' ? tenantRbacProd : tenantRbacHProd
102+
projectValue.envs[env] = {
103+
groups,
104+
tenants: {
105+
[`${env}-${name}`]: {},
106+
},
100107
}
101108
}
102109

110+
if (projectValue.envs.hprod && !Object.values(projectValue.envs.hprod?.tenants).length) {
111+
delete projectValue.envs.hprod
112+
}
113+
if (projectValue.envs.prod && !Object.values(projectValue.envs.prod?.tenants).length) {
114+
delete projectValue.envs.prod
115+
}
116+
103117
const listPerms = getListPrems(project.environments)
104118

105119
// Upsert or delete Gitlab config based on prod/non-prod environment
106-
const yamlResult = await upsertGitlabConfig(project, gitlabApi, tenantsToCreate)
120+
const yamlResult = await upsertGitlabConfig(project, gitlabApi, projectValue)
107121
await ensureKeycloakGroups(listPerms, keycloakApi)
108122

109123
return {

0 commit comments

Comments
 (0)