Skip to content

Commit f6b2b12

Browse files
committed
f
1 parent 6324bf6 commit f6b2b12

32 files changed

+183
-170
lines changed

api/api.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ func WithHelmClient(hcli helm.Client) Option {
122122

123123
// New creates a new API instance.
124124
func New(cfg types.APIConfig, opts ...Option) (*API, error) {
125-
if cfg.Target == "" {
125+
if cfg.InstallTarget == "" {
126126
return nil, fmt.Errorf("target is required")
127127
}
128128

api/clients.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,13 @@ func (a *API) initClients() error {
2020

2121
// initHelmClient initializes the Helm client based on the installation target
2222
func (a *API) initHelmClient() error {
23-
switch a.cfg.Target {
24-
case types.TargetLinux:
23+
switch a.cfg.InstallTarget {
24+
case types.InstallTargetLinux:
2525
return a.initLinuxHelmClient()
26-
case types.TargetKubernetes:
26+
case types.InstallTargetKubernetes:
2727
return a.initKubernetesHelmClient()
2828
default:
29-
return fmt.Errorf("unsupported install target: %s", a.cfg.Target)
29+
return fmt.Errorf("unsupported install target: %s", a.cfg.InstallTarget)
3030
}
3131
}
3232

api/controllers/app/controller.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import (
1414
"github.com/replicatedhq/embedded-cluster/api/internal/store"
1515
"github.com/replicatedhq/embedded-cluster/api/pkg/logger"
1616
"github.com/replicatedhq/embedded-cluster/api/types"
17+
"github.com/replicatedhq/embedded-cluster/pkg/helm"
1718
"github.com/replicatedhq/embedded-cluster/pkg/release"
1819
kotsv1beta1 "github.com/replicatedhq/kotskinds/apis/kots/v1beta1"
1920
"github.com/sirupsen/logrus"
@@ -46,6 +47,7 @@ type AppController struct {
4647
logger logrus.FieldLogger
4748
license []byte
4849
releaseData *release.ReleaseData
50+
hcli helm.Client
4951
store store.Store
5052
configValues types.AppConfigValues
5153
clusterID string
@@ -109,6 +111,12 @@ func WithReleaseData(releaseData *release.ReleaseData) AppControllerOption {
109111
}
110112
}
111113

114+
func WithHelmClient(hcli helm.Client) AppControllerOption {
115+
return func(c *AppController) {
116+
c.hcli = hcli
117+
}
118+
}
119+
112120
func WithConfigValues(configValues types.AppConfigValues) AppControllerOption {
113121
return func(c *AppController) {
114122
c.configValues = configValues
@@ -202,6 +210,7 @@ func NewAppController(opts ...AppControllerOption) (*AppController, error) {
202210
appreleasemanager.WithLicense(license),
203211
appreleasemanager.WithIsAirgap(controller.airgapBundle != ""),
204212
appreleasemanager.WithPrivateCACertConfigMapName(controller.privateCACertConfigMapName),
213+
appreleasemanager.WithHelmClient(controller.hcli),
205214
)
206215
if err != nil {
207216
return nil, fmt.Errorf("create app release manager: %w", err)

api/controllers/kubernetes/upgrade/controller.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ func NewUpgradeController(opts ...UpgradeControllerOption) (*UpgradeController,
133133
appcontroller.WithConfigValues(controller.configValues),
134134
appcontroller.WithAirgapBundle(controller.airgapBundle),
135135
appcontroller.WithPrivateCACertConfigMapName(""), // Private CA ConfigMap functionality not yet implemented for Kubernetes installations
136+
appcontroller.WithHelmClient(controller.hcli),
136137
)
137138
if err != nil {
138139
return nil, fmt.Errorf("create app controller: %w", err)

api/controllers/linux/install/controller.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,7 @@ func NewInstallController(opts ...InstallControllerOption) (*InstallController,
274274
appcontroller.WithClusterID(controller.clusterID),
275275
appcontroller.WithAirgapBundle(controller.airgapBundle),
276276
appcontroller.WithPrivateCACertConfigMapName(adminconsole.PrivateCASConfigMapName), // Linux installations use the ConfigMap
277+
appcontroller.WithHelmClient(controller.hcli),
277278
)
278279
if err != nil {
279280
return nil, fmt.Errorf("create app controller: %w", err)

api/controllers/linux/upgrade/controller.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,7 @@ func NewUpgradeController(opts ...UpgradeControllerOption) (*UpgradeController,
268268
appcontroller.WithClusterID(controller.clusterID),
269269
appcontroller.WithAirgapBundle(controller.airgapBundle),
270270
appcontroller.WithPrivateCACertConfigMapName(adminconsole.PrivateCASConfigMapName), // Linux upgrades use the ConfigMap
271+
appcontroller.WithHelmClient(controller.hcli),
271272
)
272273
if err != nil {
273274
return nil, fmt.Errorf("create app controller: %w", err)

api/handlers.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,14 +50,15 @@ func (a *API) initHandlers() error {
5050
}
5151
a.handlers.health = healthHandler
5252

53-
if a.cfg.Target == types.TargetLinux {
53+
if a.cfg.InstallTarget == types.InstallTargetLinux {
5454
// Linux handler
5555
linuxHandler, err := linuxhandler.New(
5656
a.cfg,
5757
linuxhandler.WithLogger(a.logger),
5858
linuxhandler.WithMetricsReporter(a.metricsReporter),
5959
linuxhandler.WithInstallController(a.linuxInstallController),
6060
linuxhandler.WithUpgradeController(a.linuxUpgradeController),
61+
linuxhandler.WithHelmClient(a.hcli),
6162
)
6263
if err != nil {
6364
return fmt.Errorf("new linux handler: %w", err)
@@ -70,6 +71,7 @@ func (a *API) initHandlers() error {
7071
kuberneteshandler.WithLogger(a.logger),
7172
kuberneteshandler.WithInstallController(a.kubernetesInstallController),
7273
kuberneteshandler.WithUpgradeController(a.kubernetesUpgradeController),
74+
kuberneteshandler.WithHelmClient(a.hcli),
7375
)
7476
if err != nil {
7577
return fmt.Errorf("new kubernetes handler: %w", err)

api/integration/app/install/config_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1051,7 +1051,7 @@ func TestAppInstallSuite(t *testing.T) {
10511051
)
10521052
require.NoError(t, err)
10531053
// Create the API with the install controller
1054-
return integration.NewAPIWithReleaseData(t, types.ModeInstall, types.TargetLinux,
1054+
return integration.NewAPIWithReleaseData(t, types.ModeInstall, types.InstallTargetLinux,
10551055
api.WithLinuxInstallController(controller),
10561056
api.WithAuthController(auth.NewStaticAuthController("TOKEN")),
10571057
api.WithLogger(logger.NewDiscardLogger()),
@@ -1071,7 +1071,7 @@ func TestAppInstallSuite(t *testing.T) {
10711071
)
10721072
require.NoError(t, err)
10731073
// Create the API with the install controller
1074-
return integration.NewAPIWithReleaseData(t, types.ModeInstall, types.TargetKubernetes,
1074+
return integration.NewAPIWithReleaseData(t, types.ModeInstall, types.InstallTargetKubernetes,
10751075
api.WithKubernetesInstallController(controller),
10761076
api.WithAuthController(auth.NewStaticAuthController("TOKEN")),
10771077
api.WithLogger(logger.NewDiscardLogger()),

api/integration/app/upgrade/apppreflight_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -448,13 +448,13 @@ func TestAppPreflightSuite(t *testing.T) {
448448

449449
// Create the API with runtime config in the API config
450450
apiInstance, err := api.New(types.APIConfig{
451-
Password: "password",
451+
InstallTarget: types.InstallTargetLinux,
452+
Password: "password",
452453
LinuxConfig: types.LinuxConfig{
453454
RuntimeConfig: rc,
454455
},
455456
ReleaseData: rd,
456457
Mode: types.ModeUpgrade,
457-
Target: types.TargetLinux,
458458
},
459459
api.WithLinuxUpgradeController(controller),
460460
api.WithAuthController(auth.NewStaticAuthController("TOKEN")),
@@ -487,14 +487,14 @@ func TestAppPreflightSuite(t *testing.T) {
487487

488488
// Create the API with kubernetes config in the API config
489489
apiInstance, err := api.New(types.APIConfig{
490-
Password: "password",
490+
InstallTarget: types.InstallTargetKubernetes,
491+
Password: "password",
491492
KubernetesConfig: types.KubernetesConfig{
492493
RESTClientGetter: &genericclioptions.ConfigFlags{},
493494
Installation: mockInstallation,
494495
},
495496
ReleaseData: rd,
496497
Mode: types.ModeUpgrade,
497-
Target: types.TargetKubernetes,
498498
},
499499
api.WithKubernetesUpgradeController(controller),
500500
api.WithAuthController(auth.NewStaticAuthController("TOKEN")),

api/integration/app/upgrade/config_test.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -363,10 +363,10 @@ func TestAppConfigSuite(t *testing.T) {
363363
require.NoError(t, err)
364364

365365
apiInstance, err := api.New(types.APIConfig{
366-
Password: "password",
367-
ReleaseData: releaseData,
368-
Mode: types.ModeUpgrade,
369-
Target: types.TargetLinux,
366+
InstallTarget: types.InstallTargetLinux,
367+
Password: "password",
368+
ReleaseData: releaseData,
369+
Mode: types.ModeUpgrade,
370370
},
371371
api.WithLinuxUpgradeController(controller),
372372
api.WithAuthController(auth.NewStaticAuthController("TOKEN")),
@@ -393,10 +393,10 @@ func TestAppConfigSuite(t *testing.T) {
393393
require.NoError(t, err)
394394

395395
apiInstance, err := api.New(types.APIConfig{
396-
Password: "password",
397-
ReleaseData: releaseData,
398-
Mode: types.ModeUpgrade,
399-
Target: types.TargetKubernetes,
396+
InstallTarget: types.InstallTargetKubernetes,
397+
Password: "password",
398+
ReleaseData: releaseData,
399+
Mode: types.ModeUpgrade,
400400
},
401401
api.WithKubernetesUpgradeController(controller),
402402
api.WithAuthController(auth.NewStaticAuthController("TOKEN")),

0 commit comments

Comments
 (0)