Skip to content

Commit

Permalink
Merge pull request #1472 from cloud-pi-native/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
ArnaudTA authored Nov 22, 2024
2 parents 12870be + 9565b1f commit e14ee65
Show file tree
Hide file tree
Showing 36 changed files with 2,689 additions and 575 deletions.
22 changes: 15 additions & 7 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ on:
NAMESPACE:
required: true
type: string
MULTI_ARCH:
BUILD_AMD64:
required: true
type: boolean
BUILD_ARM64:
required: true
type: boolean
TAG:
Expand Down Expand Up @@ -45,11 +48,16 @@ on:
required: true
type: string
default: cloud-pi-native/console
MULTI_ARCH:
description: Build for both amd64 and arm64
BUILD_AMD64:
description: Build for amd64
required: true
type: boolean
default: false
default: true
BUILD_ARM64:
description: Build for arm64
required: true
type: boolean
default: true
USE_QEMU:
description: Use QEMU emulator for arm64
required: true
Expand Down Expand Up @@ -88,7 +96,7 @@ jobs:
- matrix
strategy:
matrix:
runners: ${{ inputs.MULTI_ARCH && !inputs.USE_QEMU && fromJson('["ubuntu-latest", "ARM64"]') || fromJson('["ubuntu-latest"]') }}
runners: ${{ (inputs.BUILD_AMD64 && inputs.BUILD_ARM64 && !inputs.USE_QEMU && fromJson('["ubuntu-latest", "ARM64"]')) || (inputs.BUILD_ARM64 && !inputs.USE_QEMU && fromJson('["ARM64"]')) || fromJson('["ubuntu-latest"]') }}
images: ${{ fromJSON(needs.matrix.outputs.build-matrix) }}
steps:
- name: Checks-out repository
Expand Down Expand Up @@ -129,7 +137,7 @@ jobs:
context: ${{ matrix.images.build.context }}
file: ${{ matrix.images.build.dockerfile }}
provenance: false
platforms: ${{ inputs.MULTI_ARCH && inputs.USE_QEMU && 'linux/amd64,linux/arm64' || (contains(runner.arch, 'ARM') && 'linux/arm64' || 'linux/amd64') }}
platforms: ${{ (inputs.BUILD_AMD64 && inputs.BUILD_ARM64 && inputs.USE_QEMU && 'linux/amd64,linux/arm64') || (inputs.BUILD_ARM64 && 'linux/arm64') || (inputs.BUILD_AMD64 && 'linux/amd64') }}
outputs: type=image,name=${{ inputs.REGISTRY }}/${{ inputs.NAMESPACE }}/${{ matrix.images.name }},push-by-digest=true,name-canonical=true,push=true
build-args: |
APP_VERSION=${{ inputs.TAG || steps.short-sha.outputs.SHORT_SHA }}
Expand All @@ -155,7 +163,7 @@ jobs:
- name: Upload digest
uses: actions/upload-artifact@v4
with:
name: digests-${{ matrix.images.name }}-${{ inputs.MULTI_ARCH && inputs.USE_QEMU && 'multiarch' || (contains(runner.arch, 'ARM') && 'arm64' || 'amd64') }}
name: digests-${{ matrix.images.name }}-${{ (inputs.BUILD_AMD64 && inputs.BUILD_ARM64 && inputs.USE_QEMU && 'multiarch') || (inputs.BUILD_ARM64 && 'arm64') || (inputs.BUILD_AMD64 && 'amd64') }}
path: /tmp/digests/${{ matrix.images.name }}/*
if-no-files-found: error
retention-days: 1
Expand Down
48 changes: 26 additions & 22 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ on:
env:
REGISTRY: ghcr.io
NAMESPACE: "${{ github.repository }}"
MULTI_ARCH: true
BUILD_AMD64: true
BUILD_ARM64: true
USE_QEMU: false
NODE_VERSION: 22.10.0
PNPM_VERSION: 9.10.0
Expand All @@ -19,7 +20,8 @@ jobs:
outputs:
REGISTRY: ${{ env.REGISTRY }}
NAMESPACE: ${{ env.NAMESPACE }}
MULTI_ARCH: ${{ env.MULTI_ARCH }}
BUILD_AMD64: ${{ env.BUILD_AMD64 }}
BUILD_ARM64: ${{ env.BUILD_ARM64 }}
USE_QEMU: ${{ env.USE_QEMU }}
NODE_VERSION: ${{ env.NODE_VERSION }}
PNPM_VERSION: ${{ env.PNPM_VERSION }}
Expand All @@ -30,7 +32,7 @@ jobs:
release:
uses: ./.github/workflows/release.yml

build:
build-amd64:
uses: ./.github/workflows/build.yml
if: ${{ needs.release.outputs.release-created == 'true' }}
needs:
Expand All @@ -43,8 +45,26 @@ jobs:
MAJOR_TAG: ${{ needs.release.outputs.major-tag }}
MINOR_TAG: ${{ needs.release.outputs.minor-tag }}
PATCH_TAG: ${{ needs.release.outputs.patch-tag }}
MULTI_ARCH: ${{ needs.expose-vars.outputs.MULTI_ARCH == 'false' }}
USE_QEMU: ${{ needs.expose-vars.outputs.USE_QEMU == 'false' }}
BUILD_AMD64: ${{ needs.expose-vars.outputs.BUILD_AMD64 == 'true' }}
BUILD_ARM64: false
USE_QEMU: ${{ needs.expose-vars.outputs.USE_QEMU == 'true' }}

build-arm64:
uses: ./.github/workflows/build.yml
if: ${{ needs.release.outputs.release-created == 'true' }}
needs:
- expose-vars
- release
with:
REGISTRY: ${{ needs.expose-vars.outputs.REGISTRY }}
NAMESPACE: ${{ needs.expose-vars.outputs.NAMESPACE }}
TAG: ${{ needs.release.outputs.major-tag }}.${{ needs.release.outputs.minor-tag }}.${{ needs.release.outputs.patch-tag }}
MAJOR_TAG: ${{ needs.release.outputs.major-tag }}
MINOR_TAG: ${{ needs.release.outputs.minor-tag }}
PATCH_TAG: ${{ needs.release.outputs.patch-tag }}
BUILD_AMD64: false
BUILD_ARM64: ${{ needs.expose-vars.outputs.BUILD_ARM64 == 'true' }}
USE_QEMU: ${{ needs.expose-vars.outputs.USE_QEMU == 'true' }}

npm-publish:
uses: ./.github/workflows/npm.yml
Expand All @@ -67,26 +87,10 @@ jobs:
needs:
- expose-vars
- release
- build-amd64
steps:
- name: Trigger helm-charts update
env:
GH_TOKEN: ${{ secrets.HELM_CHART_TOKEN }}
run: |
gh workflow --repo cloud-pi-native/helm-charts run update-chart.yaml -f APP_VERSION=${{ needs.release.outputs.major-tag }}.${{ needs.release.outputs.minor-tag }}.${{ needs.release.outputs.patch-tag }} -f CHART_NAME=dso-console
build-arm:
uses: ./.github/workflows/build.yml
if: ${{ needs.release.outputs.release-created == 'true' }}
needs:
- expose-vars
- release
- build
with:
REGISTRY: ${{ needs.expose-vars.outputs.REGISTRY }}
NAMESPACE: ${{ needs.expose-vars.outputs.NAMESPACE }}
TAG: ${{ needs.release.outputs.major-tag }}.${{ needs.release.outputs.minor-tag }}.${{ needs.release.outputs.patch-tag }}
MAJOR_TAG: ${{ needs.release.outputs.major-tag }}
MINOR_TAG: ${{ needs.release.outputs.minor-tag }}
PATCH_TAG: ${{ needs.release.outputs.patch-tag }}
MULTI_ARCH: ${{ needs.expose-vars.outputs.MULTI_ARCH == 'true' }}
USE_QEMU: ${{ needs.expose-vars.outputs.USE_QEMU == 'true' }}
9 changes: 6 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ env:
PNPM_VERSION: 9.10.0
REGISTRY: ghcr.io
NAMESPACE: "${{ github.repository }}"
MULTI_ARCH: false
BUILD_AMD64: true
BUILD_ARM64: false
USE_QEMU: false

jobs:
Expand Down Expand Up @@ -52,7 +53,8 @@ jobs:
PNPM_VERSION: ${{ env.PNPM_VERSION }}
REGISTRY: ${{ env.REGISTRY }}
NAMESPACE: ${{ env.NAMESPACE }}
MULTI_ARCH: ${{ env.MULTI_ARCH }}
BUILD_AMD64: ${{ env.BUILD_AMD64 }}
BUILD_ARM64: ${{ env.BUILD_ARM64 }}
USE_QEMU: ${{ env.USE_QEMU }}
steps:
- name: Exposing env vars
Expand Down Expand Up @@ -115,7 +117,8 @@ jobs:
REGISTRY: ${{ needs.expose-vars.outputs.REGISTRY }}
NAMESPACE: ${{ needs.expose-vars.outputs.NAMESPACE }}
TAG: pr-${{ github.event.pull_request.number || github.event.number }}
MULTI_ARCH: ${{ needs.expose-vars.outputs.MULTI_ARCH == 'true' }}
BUILD_AMD64: ${{ needs.expose-vars.outputs.BUILD_AMD64 == 'true' }}
BUILD_ARM64: ${{ needs.expose-vars.outputs.BUILD_ARM64 == 'true' }}
USE_QEMU: ${{ needs.expose-vars.outputs.USE_QEMU == 'true' }}
PR_NUMBER: ${{ github.event.pull_request.number || github.event.number }}
secrets:
Expand Down
4 changes: 3 additions & 1 deletion apps/client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,11 @@
"unplugin-auto-import": "^0.17.8",
"unplugin-vue-components": "^0.27.2",
"vite": "^5.3.2",
"vite-plugin-pwa": "^0.21.0",
"vitest": "^1.6.0",
"vue-eslint-parser": "^9.4.3",
"vue-tsc": "^2.0.22"
"vue-tsc": "^2.0.22",
"workbox-window": "^7.3.0"
},
"publishConfig": {
"registry": "https://registry.npmjs.org/",
Expand Down
2 changes: 2 additions & 0 deletions apps/client/src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { useSystemSettingsStore } from './stores/system-settings.js'
import { useProjectStore } from './stores/project.js'
import { useUserStore } from './stores/user.js'
import { useAdminRoleStore } from './stores/admin-role.js'
import ReloadPrompt from './components/ReloadPrompt.vue'
import { useServiceStore } from '@/stores/services-monitor.js'
const keycloak = getKeycloak()
Expand Down Expand Up @@ -102,6 +103,7 @@ watch(userStore, async () => {
</div>
</template>
</DsfrFooter>
<ReloadPrompt />
</template>

<style>
Expand Down
16 changes: 10 additions & 6 deletions apps/client/src/components/ClusterForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,28 @@ import { computed, onBeforeMount, ref, watch } from 'vue'
import type {
ClusterAssociatedEnvironments,
ClusterDetails,
SharedZodError,
Stage,
Zone,
} from '@cpn-console/shared'
import {
ClusterDetailsSchema,
ClusterPrivacy,
KubeconfigSchema,
inClusterLabel,
} from '@cpn-console/shared'
// @ts-ignore 'js-yaml' missing types
import { load } from 'js-yaml'
// @ts-ignore 'vue3-json-viewer' missing types
import { JsonViewer } from 'vue3-json-viewer'
import type { ProjectWithOrganization } from '../stores/project.js'
import type { Project } from '../utils/project-utils.js'
import ChoiceSelector from './ChoiceSelector.vue'
import { useSnackbarStore } from '@/stores/snackbar.js'
import { toCodeComponent } from '@/utils/func.js'
const props = withDefaults(defineProps<{
isNewCluster: boolean
cluster: ClusterDetails
allProjects: ProjectWithOrganization[]
allProjects: Project[]
allStages: Stage[]
allZones: Zone[]
associatedEnvironments: ClusterAssociatedEnvironments
Expand Down Expand Up @@ -75,16 +75,16 @@ if (!localCluster.value.zoneId && props.allZones.length) {
localCluster.value.zoneId = props.allZones[0].id
}
const errorSchema = computed<SharedZodError | undefined>(() => {
const schema = computed(() => {
let schemaValidation
if (localCluster.value.id) {
schemaValidation = ClusterDetailsSchema.safeParse(localCluster.value)
} else {
schemaValidation = ClusterDetailsSchema.omit({ id: true }).partial().safeParse(localCluster.value)
}
return schemaValidation.success ? undefined : schemaValidation.error
return schemaValidation
})
const isClusterValid = computed(() => !errorSchema.value)
const isClusterValid = computed(() => schema.value.success)
const chosenZoneDescription = computed(() => props.allZones.find(zone => zone.id === localCluster.value.zoneId)?.description)
function updateKubeconfig(files: FileList) {
Expand Down Expand Up @@ -251,6 +251,7 @@ const isConnectionDetailsShown = ref(true)
:error="kConfigError"
hint="Uploadez le Kubeconfig du cluster."
class="fr-mb-2w"
:disabled="localCluster.label === inClusterLabel"
@change="updateKubeconfig($event)"
/>
<DsfrSelect
Expand All @@ -259,6 +260,7 @@ const isConnectionDetailsShown = ref(true)
select-id="selectedContextSelect"
label="Context"
description="Nous n'avons pas trouvé de current-context dans votre kubeconfig. Veuillez choisir un contexte."
:disabled="localCluster.label === inClusterLabel"
:options="contexts"
/>
<JsonViewer
Expand All @@ -283,13 +285,15 @@ const isConnectionDetailsShown = ref(true)
:required="true"
:error-message="localCluster.kubeconfig.cluster.tlsServerName && !KubeconfigSchema.pick({ cluster: true }).safeParse({ cluster: { tlsServerName: localCluster.kubeconfig.cluster.tlsServerName } }).success ? 'Le nom du serveur TLS est obligatoire' : undefined"
hint="La valeur est extraite du kubeconfig téléversé."
:disabled="localCluster.label === inClusterLabel"
/>
<DsfrCheckbox
id="clusterSkipTLSVerifyCbx"
v-model="localCluster.kubeconfig.cluster.skipTLSVerify"
label="Ignorer le certificat TLS du server (risques potentiels de sécurité !)"
hint="Ignorer le certificat TLS présenté pour contacter l'API server Kubernetes"
name="isClusterSkipTlsVerify"
:disabled="localCluster.label === inClusterLabel"
/>
</template>
<h4
Expand Down
2 changes: 1 addition & 1 deletion apps/client/src/components/DsoSnackbar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ watch(routePath, () => {

<style scoped>
.dso-snackbar {
@apply fixed bottom-4 z-1 mx-4;
@apply fixed bottom-4 z-1000 mx-4;
background-color: var(--background-default-grey);
}
Expand Down
46 changes: 46 additions & 0 deletions apps/client/src/components/ReloadPrompt.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<script setup lang="ts">
// @ts-ignore
import { useRegisterSW } from 'virtual:pwa-register/vue'
const { offlineReady, needRefresh, updateServiceWorker } = useRegisterSW()
async function close() {
offlineReady.value = false
needRefresh.value = false
}
</script>

<template>
<div
v-if="offlineReady || needRefresh"
class="w-full flex justify-center"
>
<DsfrAlert
data-testid="snackbar"
type="info"
class="dso-snackbar max-w-300"
small
:closed="false"
closeable
@close="close()"
>
<span v-if="offlineReady">
App ready to work offline
</span>
<span v-else>
Une nouvelle version de l'application est disponible.
</span>
<DsfrButton v-if="needRefresh" @click="updateServiceWorker()">
Mettre à jour
</DsfrButton>
</DsfrAlert>
</div>
</template>

<style scoped>
.dso-snackbar {
@apply fixed bottom-4 z-1 mx-4;
background-color: var(--background-default-grey);
}
</style>
15 changes: 15 additions & 0 deletions apps/client/src/env.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/// <reference types="vite-plugin-pwa/vue" />
/// <reference types="vite-plugin-pwa/client" />

declare module 'virtual:pwa-register/vue' {
import type { Ref } from 'vue'
import type { RegisterSWOptions } from 'vite-plugin-pwa/types'

export type { RegisterSWOptions }

export function useRegisterSW(options?: RegisterSWOptions): {
needRefresh: Ref<boolean>
offlineReady: Ref<boolean>
updateServiceWorker: (reloadPage?: boolean) => Promise<void>
}
}
4 changes: 2 additions & 2 deletions apps/client/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ import 'vue3-json-viewer/dist/index.css'
import JsonViewer from 'vue3-json-viewer'
// @ts-ignore '@gouvminint/vue-dsfr' missing types
import { DsfrSelect, DsfrTag, VIcon } from '@gouvminint/vue-dsfr'
import { keycloakInit } from './utils/keycloak/keycloak'
import { keycloakInit } from './utils/keycloak/keycloak.js'

import App from './App.vue'
import router from './router/index'
import router from './router/index.js'

import 'virtual:uno.css'
import 'virtual:unocss-devtools'
Expand Down
Loading

0 comments on commit e14ee65

Please sign in to comment.