11const Command = require ( '../../Command' ) ;
2-
32const upgradeRoot = require ( '../root/upgrade.cmd' ) ;
4- const { downloadProvider } = require ( '../hybrid/helper' ) ;
5- const { Runner, components } = require ( '../../../../binary' ) ;
3+ const codefreshProvider = require ( './codefresh/upgrade' ) ;
4+ const argocdAgentProvider = require ( './argocd/upgrade' ) ;
5+
6+ const PROVIDERS = {
7+ codefresh : codefreshProvider ,
8+ 'argocd-agent' : argocdAgentProvider ,
9+ } ;
610
711const command = new Command ( {
812 root : false ,
@@ -18,7 +22,7 @@ const command = new Command({
1822 yargs
1923 . positional ( 'provider' , {
2024 describe : 'Gitops provider' ,
21- choices : [ 'argocd-agent' ] ,
25+ choices : Object . keys ( PROVIDERS ) ,
2226 required : true ,
2327 } )
2428 . option ( 'kube-config-path' , {
@@ -41,39 +45,10 @@ const command = new Command({
4145 ) ;
4246 } ,
4347 handler : async ( argv ) => {
44- const {
45- provider,
46- 'kube-config-path' : kubeConfigPath ,
47- 'kube-namespace' : kubeNamespace ,
48- 'kube-context-name' : kubeContextName ,
49- 'in-cluster' : inCluster ,
50- } = argv ;
51-
52- const binLocation = await downloadProvider ( { provider } ) ;
53- const componentRunner = new Runner ( binLocation ) ;
54-
55- const commands = [
56- 'update' ,
57- ] ;
58-
59- if ( kubeConfigPath ) {
60- commands . push ( '--kubeconfig' ) ;
61- commands . push ( kubeConfigPath ) ;
62- }
63- if ( kubeNamespace ) {
64- commands . push ( '--kube-namespace' ) ;
65- commands . push ( kubeNamespace ) ;
66- }
67- if ( kubeContextName ) {
68- commands . push ( '--kube-context-name' ) ;
69- commands . push ( kubeContextName ) ;
70- }
71- if ( inCluster ) {
72- commands . push ( '--in-cluster' ) ;
73- commands . push ( 'true' ) ;
74- }
48+ const { provider } = argv ;
7549
76- await componentRunner . run ( components . gitops [ provider ] , commands ) ;
50+ const providerInstaller = PROVIDERS [ provider ] ;
51+ return providerInstaller . upgrade ( argv ) ;
7752 } ,
7853} ) ;
7954
0 commit comments