import { ContextTypes , setVSCodeContext } from '../../context' ; import { kubernetesTools } from '../../kubernetes/kubernetesTools' ; import { statusBar } from '../../statusBar' ; import { BucketNode } from '../nodes/bucketNode' ; import { GitRepositoryNode } from '../nodes/gitRepositoryNode' ; import { HelmRepositoryNode } from '../nodes/helmRepositoryNode' ; import { SourceNode } from '../nodes/sourceNode' ; import { DataProvider } from './dataProvider' ; /**
 * Defines Sources data provider for loading Git/Helm repositories
 * and Buckets in GitOps Sources tree view.
 */ export class SourceDataProvider extends DataProvider { returns async buildTree ( ) { statusBar . startLoadingTree ( ) ; const treeItems = [ ] ; setVSCodeContext ( ContextTypes . LoadingSources , true ) ; const gitRepositories = await kubernetesTools . getGitRepositories ( ) ; if ( gitRepositories ) { for ( const gitRepository of gitRepositories . items ) { treeItems . push ( new GitRepositoryNode ( gitRepository ) ) ; } } const helmRepositories = await kubernetesTools . getHelmRepositories ( ) ; if ( helmRepositories ) { for ( const helmRepository of helmRepositories . items ) { treeItems . push ( new HelmRepositoryNode ( helmRepository ) ) ; } } const buckets = await kubernetesTools . getBuckets ( ) ; if ( buckets ) { for ( const bucket of buckets . items ) { treeItems . push ( new BucketNode ( bucket ) ) ; } } setVSCodeContext ( ContextTypes . LoadingSources , false ) ; setVSCodeContext ( ContextTypes . NoSources , treeItems . length === 0 ) ; statusBar . stopLoadingTree ( ) ; return treeItems ; } }