Skip to content

Commit

Permalink
fix: 🐛 fix not updated argocd cluster and not using insecure in config
Browse files Browse the repository at this point in the history
  • Loading branch information
ArnaudTA committed Sep 28, 2023
1 parent 58aa348 commit 69e7a9a
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 1 deletion.
3 changes: 3 additions & 0 deletions apps/server/src/plugins/core/argo/cluster.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ export const createCluster: StepCall<CreateClusterExecArgs> = async (payload) =>
}
}

export const updateCluster = createCluster

export const deleteCluster: StepCall<DeleteClusterExecArgs> = async (payload) => {
try {
const secretName = payload.args.secretName
Expand Down Expand Up @@ -55,6 +57,7 @@ const convertConfig = (cluster: ClusterModel) => ({
...cluster.user?.keyData && { keyData: cluster.user?.keyData },
...cluster.user?.certData && { certData: cluster.user?.certData },
...cluster.cluster?.caData && { caData: cluster.cluster?.caData },
...cluster.cluster?.skipTLSVerify && { insecure: cluster.cluster.skipTLSVerify },
serverName: cluster.cluster.tlsServerName,
},
})
Expand Down
3 changes: 2 additions & 1 deletion apps/server/src/plugins/core/argo/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { KubeConfig, CoreV1Api, CustomObjectsApi, PatchUtils } from '@kubernetes
import { addCluster, deleteEnv, deleteRepo, newEnv, newRepo, removeCluster } from './index.js'
import { kubeconfigPath, kubeconfigCtx } from '@/utils/env.js'
import type { RegisterFn } from '@/plugins/index.js'
import { createCluster, deleteCluster } from './cluster.js'
import { createCluster, deleteCluster, updateCluster } from './cluster.js'
import { infos } from './infos.js'
export const patchOptions = { headers: { 'Content-type': PatchUtils.PATCH_FORMAT_JSON_PATCH } }
export const argoNamespace = process.env.ARGO_NAMESPACE
Expand Down Expand Up @@ -35,6 +35,7 @@ export const init = (register: RegisterFn) => {
// clusters
createCluster: { main: createCluster },
deleteCluster: { main: deleteCluster },
updateCluster: { main: updateCluster },
},
infos,
)
Expand Down
2 changes: 2 additions & 0 deletions apps/server/src/plugins/hooks/cluster.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ import { type Hook, createHook } from './hook.js'
import type { ClusterMix } from '@/types/index.js'

export type CreateClusterExecArgs = ClusterMix
export type UpdateClusterExecArgs = ClusterMix
export type CreateClusterValidateArgs = ClusterMix
export type DeleteClusterExecArgs = Pick<ClusterMix, 'secretName'>

export const createCluster: Hook<CreateClusterExecArgs, CreateClusterValidateArgs> = createHook()
export const updateCluster: Hook<CreateClusterExecArgs, CreateClusterValidateArgs> = createHook()
export const deleteCluster: Hook<DeleteClusterExecArgs, void> = createHook()
2 changes: 2 additions & 0 deletions apps/server/src/resources/cluster/admin/business.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ export const updateClusterBusiness = async (data: UpdateClusterDto['body'], clus
delete clusterData.cluster
const cluster = await updateCluster(clusterId, clusterData, kubeConfig)

await hooks.updateCluster.execute({ ...cluster, user: { ...kubeConfig.user }, cluster: { ...kubeConfig.cluster } })

if (data.projectsId) {
for (const projectId of data.projectsId) {
await addClusterToProjectWithIds(clusterId, projectId)
Expand Down

0 comments on commit 69e7a9a

Please sign in to comment.