@@ -62,18 +62,22 @@ type HTTPClient interface {
62
62
// BrowserLauncher primarily for testing purposes.
63
63
type BrowserLauncher func (url string ) error
64
64
65
+ // ChartLocator primarily for testing purposes.
66
+ type ChartLocator func (repoName , repoUrl string ) string
67
+
65
68
// Command is the local command, responsible for installing, uninstalling, or other local actions.
66
69
type Command struct {
67
- provider k8s.Provider
68
- cluster k8s.Cluster
69
- http HTTPClient
70
- helm helm.Client
71
- k8s k8s.Client
72
- portHTTP int
73
- spinner * pterm.SpinnerPrinter
74
- tel telemetry.Client
75
- launcher BrowserLauncher
76
- userHome string
70
+ provider k8s.Provider
71
+ cluster k8s.Cluster
72
+ http HTTPClient
73
+ helm helm.Client
74
+ k8s k8s.Client
75
+ portHTTP int
76
+ spinner * pterm.SpinnerPrinter
77
+ tel telemetry.Client
78
+ launcher BrowserLauncher
79
+ locateChart ChartLocator
80
+ userHome string
77
81
}
78
82
79
83
// Option for configuring the Command, primarily exists for testing
@@ -114,6 +118,12 @@ func WithBrowserLauncher(launcher BrowserLauncher) Option {
114
118
}
115
119
}
116
120
121
+ func WithChartLocator (locator ChartLocator ) Option {
122
+ return func (c * Command ) {
123
+ c .locateChart = locator
124
+ }
125
+ }
126
+
117
127
// WithUserHome define the user's home directory.
118
128
func WithUserHome (home string ) Option {
119
129
return func (c * Command ) {
@@ -140,6 +150,10 @@ func New(provider k8s.Provider, opts ...Option) (*Command, error) {
140
150
opt (c )
141
151
}
142
152
153
+ if c .locateChart == nil {
154
+ c .locateChart = locateLatestAirbyteChart
155
+ }
156
+
143
157
// determine userhome if not defined
144
158
if c .userHome == "" {
145
159
c .userHome = paths .UserHome
@@ -698,11 +712,13 @@ func (c *Command) handleChart(
698
712
return fmt .Errorf ("unable to add %s chart repo: %w" , req .name , err )
699
713
}
700
714
701
- c .spinner .UpdateText (fmt .Sprintf ("Fetching %s Helm Chart" , req .chartName ))
702
- helmChart , _ , err := c .helm .GetChart (req .chartName , & action.ChartPathOptions {Version : req .chartVersion })
715
+ c .spinner .UpdateText (fmt .Sprintf ("Fetching %s Helm Chart with version" , req .chartName ))
716
+
717
+ chartLoc := c .locateChart (req .chartName , req .chartVersion )
718
+
719
+ helmChart , _ , err := c .helm .GetChart (chartLoc , & action.ChartPathOptions {Version : req .chartVersion })
703
720
if err != nil {
704
- pterm .Error .Printfln ("Unable to fetch %s Helm Chart" , req .chartName )
705
- return fmt .Errorf ("unable to fetch chart %s: %w" , req .chartName , err )
721
+ return fmt .Errorf ("unable to fetch helm chart %q: %w" , req .chartName , err )
706
722
}
707
723
708
724
c .tel .Attr (fmt .Sprintf ("helm_%s_chart_version" , req .name ), helmChart .Metadata .Version )
@@ -741,7 +757,7 @@ func (c *Command) handleChart(
741
757
))
742
758
helmRelease , err := c .helm .InstallOrUpgradeChart (ctx , & helmclient.ChartSpec {
743
759
ReleaseName : req .chartRelease ,
744
- ChartName : req . chartName ,
760
+ ChartName : chartLoc ,
745
761
CreateNamespace : true ,
746
762
Namespace : req .namespace ,
747
763
Wait : true ,
0 commit comments