import { window } from 'vscode' ; import { azureTools , isAzureProvider } from '../azure/azureTools' ; import { fluxTools } from '../flux/fluxTools' ; import { checkIfOpenedFolderGitRepositorySourceExists } from '../git/checkIfOpenedFolderGitRepositorySourceExists' ; import { ClusterProvider } from '../kubernetes/kubernetesTypes' ; import { telemetry , TelemetryEventNames } from '../telemetry' ; import { ClusterContextNode } from '../views/nodes/clusterContextNode' ; import { getCurrentClusterInfo , refreshAllTreeViews } from '../views/treeViews' ; param clusterNode param enableGitOps async function enableDisableGitOps ( clusterNode , enableGitOps ) { if ( ! clusterNode ) { const currentClusterInfo = await getCurrentClusterInfo ( ) ; if ( ! currentClusterInfo ) { return ; } clusterNode = currentClusterInfo . clusterNode ; } const clusterProvider = await clusterNode . getClusterProvider ( ) ; if ( clusterProvider === ClusterProvider . Unknown ) { return ; } const enableGitOpsButton = enableGitOps ? 'Enable' : 'Disable' ; const confirmationMessage = `Do you want to ${ enableGitOps ? 'enable' : 'disable' } GitOps on the "${ clusterNode . clusterName }" cluster?` ; const confirm = await window . showWarningMessage ( confirmationMessage , { modal : true , } , enableGitOpsButton ) ; if ( confirm !== enableGitOpsButton ) { return ; } if ( enableGitOps ) { telemetry . send ( TelemetryEventNames . EnableGitOps , { clusterProvider , } ) ; } else { telemetry . send ( TelemetryEventNames . DisableGitOps , { clusterProvider , } ) ; } if ( isAzureProvider ( clusterProvider ) ) { if ( enableGitOps ) { await azureTools . enableGitOps ( clusterNode , clusterProvider ) ; } else { await azureTools . disableGitOps ( clusterNode , clusterProvider ) ; } } else { const context = clusterNode . contextName ; if ( enableGitOps ) { await fluxTools . install ( context ) ; } else { await fluxTools . uninstall ( context ) ; } } if ( ! enableGitOps ) { checkIfOpenedFolderGitRepositorySourceExists ( ) ; } refreshAllTreeViews ( ) ; } param clusterNode export async function fluxEnableGitOps ( clusterNode ) { return await enableDisableGitOps ( clusterNode , true ) ; } param clusterNode export async function fluxDisableGitOps ( clusterNode ) { return await enableDisableGitOps ( clusterNode , false ) ; }