import { commands , Disposable , ExtensionContext , window } from 'vscode' ; import { copyResourceName } from './commands/copyResourceName' ; import { createGitRepository } from './commands/createGitRepository' ; import { createKustomization } from './commands/createKustomization' ; import { deleteSource } from './commands/deleteSource' ; import { fluxDisableGitOps , fluxEnableGitOps } from './commands/enableDisableGitOps' ; import { fluxCheck } from './commands/fluxCheck' ; import { checkFluxPrerequisites } from './commands/fluxCheckPrerequisites' ; import { fluxReconcileRepository } from './commands/fluxReconcileRepository' ; import { fluxReconcileSourceCommand } from './commands/fluxReconcileSource' ; import { fluxReconcileWorkload } from './commands/fluxReconcileWorkload' ; import { installFluxCli } from './commands/installFluxCli' ; import { openCreateSourceWebview } from './commands/openCreateSourceWebview' ; import { openResource } from './commands/openResource' ; import { pullGitRepository } from './commands/pullGitRepository' ; import { resume } from './commands/resume' ; import { setClusterProvider } from './commands/setClusterProvider' ; import { setCurrentKubernetesContext } from './commands/setCurrentKubernetesContext' ; import { showInstalledVersions } from './commands/showInstalledVersions' ; import { showLogs } from './commands/showLogs' ; import { showWorkloadsHelpMessage } from './commands/showWorkloadsHelpMessage' ; import { suspend } from './commands/suspend' ; import { trace } from './commands/trace' ; import { showOutputChannel } from './output' ; import { telemetry } from './telemetry' ; import { refreshAllTreeViews , refreshSourcesTreeView , refreshWorkloadsTreeView } from './views/treeViews' ; /**
 * Command ids registered by this extension
 * or default vscode commands.
 */ export const enum CommandId { /**
     * Opens the provided resource in the editor. Can be a text or binary file, or an http(s) URL.
     */ VSCodeOpen = 'vscode.open' , see https VSCodeSetContext = 'setContext' , SetCurrentKubernetesContext = 'gitops.kubectl.setCurrentContext' , Suspend = 'gitops.suspend' , Resume = 'gitops.resume' , FluxCheck = 'gitops.flux.check' , FluxCheckPrerequisites = 'gitops.flux.checkPrerequisites' , FluxEnableGitOps = 'gitops.flux.install' , FluxDisableGitOps = 'gitops.flux.uninstall' , FluxReconcileSource = 'gitops.flux.reconcileSource' , FluxReconcileRepository = 'gitops.flux.reconcileRepository' , FluxReconcileWorkload = 'gitops.flux.reconcileWorkload' , FluxTrace = 'gitops.flux.trace' , SetClusterProvider = 'gitops.setClusterProvider' , RefreshAllTreeViews = 'gitops.views.refreshAllTreeViews' , RefreshSourcesTreeView = 'gitops.views.refreshSourceTreeView' , RefreshWorkloadsTreeView = 'gitops.views.refreshWorkloadTreeView' , PullGitRepository = 'gitops.views.pullGitRepository' , CreateGitRepository = 'gitops.views.createGitRepository' , CreateKustomization = 'gitops.createKustomization' , ShowWorkloadsHelpMessage = 'gitops.views.showWorkloadsHelpMessage' , DeleteSource = 'gitops.views.deleteSource' , CopyResourceName = 'gitops.copyResourceName' , EditorOpenResource = 'gitops.editor.openResource' , ShowLogs = 'gitops.editor.showLogs' , OpenCreateSourceWebview = 'gitops.editor.createSource' , ShowOutputChannel = 'gitops.output.show' , ShowInstalledVersions = 'gitops.showInstalledVersions' , InstallFluxCli = 'gitops.installFluxCli' } let _context ; param context export function registerCommands ( context ) { _context = context ; registerCommand ( CommandId . SetCurrentKubernetesContext , setCurrentKubernetesContext ) ; registerCommand ( CommandId . Suspend , suspend ) ; registerCommand ( CommandId . Resume , resume ) ; registerCommand ( CommandId . CreateKustomization , createKustomization ) ; registerCommand ( CommandId . FluxCheck , fluxCheck ) ; registerCommand ( CommandId . FluxCheckPrerequisites , checkFluxPrerequisites ) ; registerCommand ( CommandId . FluxReconcileSource , fluxReconcileSourceCommand ) ; registerCommand ( CommandId . FluxReconcileRepository , fluxReconcileRepository ) ; registerCommand ( CommandId . FluxReconcileWorkload , fluxReconcileWorkload ) ; registerCommand ( CommandId . FluxEnableGitOps , fluxEnableGitOps ) ; registerCommand ( CommandId . FluxDisableGitOps , fluxDisableGitOps ) ; registerCommand ( CommandId . FluxTrace , trace ) ; registerCommand ( CommandId . SetClusterProvider , setClusterProvider ) ; registerCommand ( CommandId . RefreshAllTreeViews , refreshAllTreeViews ) ; registerCommand ( CommandId . RefreshSourcesTreeView , refreshSourcesTreeView ) ; registerCommand ( CommandId . RefreshWorkloadsTreeView , refreshWorkloadsTreeView ) ; registerCommand ( CommandId . PullGitRepository , pullGitRepository ) ; registerCommand ( CommandId . CreateGitRepository , createGitRepository ) ; registerCommand ( CommandId . ShowWorkloadsHelpMessage , showWorkloadsHelpMessage ) ; registerCommand ( CommandId . DeleteSource , deleteSource ) ; registerCommand ( CommandId . CopyResourceName , copyResourceName ) ; registerCommand ( CommandId . EditorOpenResource , openResource ) ; registerCommand ( CommandId . ShowLogs , showLogs ) ; registerCommand ( CommandId . OpenCreateSourceWebview , openCreateSourceWebview ) ; registerCommand ( CommandId . ShowOutputChannel , showOutputChannel ) ; registerCommand ( CommandId . ShowInstalledVersions , showInstalledVersions ) ; registerCommand ( CommandId . InstallFluxCli , installFluxCli ) ; } param commandId param callback param thisArg function registerCommand ( commandId , callback , thisArg ? ) { const command = commands . registerCommand ( commandId , async ( ... args ) => { try { await callback ( ... args ) ; } catch ( e ) { telemetry . sendError ( 'UNCAUGHT_EXCEPTION' , e as Error ) ; window . showErrorMessage ( String ( e ) ) ; console . error ( e ) ; } } , thisArg ) ; _context . subscriptions . push ( command ) ; }