Skip to content

Commit 1204741

Browse files
committed
f
1 parent 23cf52e commit 1204741

7 files changed

Lines changed: 16 additions & 179 deletions

File tree

api/controllers/app/install.go

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -73,12 +73,6 @@ func (c *AppController) InstallApp(ctx context.Context, opts InstallAppOptions)
7373
return fmt.Errorf("get app config values for app install: %w", err)
7474
}
7575

76-
// Get KOTS config values for KOTS CLI install
77-
kotsConfigValues, err := c.appConfigManager.GetKotsadmConfigValues()
78-
if err != nil {
79-
return fmt.Errorf("get kotsadm config values for app install: %w", err)
80-
}
81-
8276
// Extract installable Helm charts from release manager
8377
installableCharts, err := c.appReleaseManager.ExtractInstallableHelmCharts(ctx, appConfigValues, opts.ProxySpec, opts.RegistrySettings)
8478
if err != nil {
@@ -118,7 +112,7 @@ func (c *AppController) InstallApp(ctx context.Context, opts InstallAppOptions)
118112
}
119113

120114
// Install the app with installable charts
121-
err = c.appInstallManager.Install(ctx, installableCharts, kotsConfigValues, opts.RegistrySettings, opts.HostCABundlePath)
115+
err = c.appInstallManager.Install(ctx, installableCharts, opts.RegistrySettings, opts.HostCABundlePath)
122116
if err != nil {
123117
return fmt.Errorf("install app: %w", err)
124118
}

api/controllers/app/tests/test_suite.go

Lines changed: 4 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -509,23 +509,15 @@ func (s *AppControllerTestSuite) TestInstallApp() {
509509
appConfigValues := types.AppConfigValues{
510510
"test-key": types.AppConfigValue{Value: "test-value"},
511511
}
512-
kotsConfigValues := kotsv1beta1.ConfigValues{
513-
Spec: kotsv1beta1.ConfigValuesSpec{
514-
Values: map[string]kotsv1beta1.ConfigValue{
515-
"test-key": {Value: "test-value"},
516-
},
517-
},
518-
}
519512
mock.InOrder(
520513
acm.On("GetConfigValues").Return(appConfigValues, nil),
521-
acm.On("GetKotsadmConfigValues").Return(kotsConfigValues, nil),
522514
arm.On("ExtractInstallableHelmCharts", mock.Anything, appConfigValues, mock.AnythingOfType("*v1beta1.ProxySpec"), mock.AnythingOfType("*types.RegistrySettings")).Return(expectedCharts, nil),
523515

524516
store.AppInstallMockStore.On("SetStatus", mock.MatchedBy(func(status types.Status) bool {
525517
return status.State == types.StateRunning
526518
})).Return(nil),
527519

528-
aim.On("Install", mock.Anything, expectedCharts, kotsConfigValues).Return(nil),
520+
aim.On("Install", mock.Anything, expectedCharts, mock.AnythingOfType("*types.RegistrySettings"), mock.AnythingOfType("string")).Return(nil),
529521

530522
store.AppInstallMockStore.On("SetStatus", mock.MatchedBy(func(status types.Status) bool {
531523
return status.State == types.StateSucceeded
@@ -542,23 +534,15 @@ func (s *AppControllerTestSuite) TestInstallApp() {
542534
appConfigValues := types.AppConfigValues{
543535
"test-key": types.AppConfigValue{Value: "test-value"},
544536
}
545-
kotsConfigValues := kotsv1beta1.ConfigValues{
546-
Spec: kotsv1beta1.ConfigValuesSpec{
547-
Values: map[string]kotsv1beta1.ConfigValue{
548-
"test-key": {Value: "test-value"},
549-
},
550-
},
551-
}
552537
mock.InOrder(
553538
acm.On("GetConfigValues").Return(appConfigValues, nil),
554-
acm.On("GetKotsadmConfigValues").Return(kotsConfigValues, nil),
555539
arm.On("ExtractInstallableHelmCharts", mock.Anything, appConfigValues, mock.AnythingOfType("*v1beta1.ProxySpec"), mock.AnythingOfType("*types.RegistrySettings")).Return([]types.InstallableHelmChart{}, nil),
556540

557541
store.AppInstallMockStore.On("SetStatus", mock.MatchedBy(func(status types.Status) bool {
558542
return status.State == types.StateRunning
559543
})).Return(nil),
560544

561-
aim.On("Install", mock.Anything, []types.InstallableHelmChart{}, kotsConfigValues).Return(nil),
545+
aim.On("Install", mock.Anything, []types.InstallableHelmChart{}, mock.AnythingOfType("*types.RegistrySettings"), mock.AnythingOfType("string")).Return(nil),
562546

563547
store.AppInstallMockStore.On("SetStatus", mock.MatchedBy(func(status types.Status) bool {
564548
return status.State == types.StateSucceeded
@@ -575,23 +559,15 @@ func (s *AppControllerTestSuite) TestInstallApp() {
575559
appConfigValues := types.AppConfigValues{
576560
"test-key": types.AppConfigValue{Value: "test-value"},
577561
}
578-
kotsConfigValues := kotsv1beta1.ConfigValues{
579-
Spec: kotsv1beta1.ConfigValuesSpec{
580-
Values: map[string]kotsv1beta1.ConfigValue{
581-
"test-key": {Value: "test-value"},
582-
},
583-
},
584-
}
585562
mock.InOrder(
586563
acm.On("GetConfigValues").Return(appConfigValues, nil),
587-
acm.On("GetKotsadmConfigValues").Return(kotsConfigValues, nil),
588564
arm.On("ExtractInstallableHelmCharts", mock.Anything, appConfigValues, mock.AnythingOfType("*v1beta1.ProxySpec"), mock.AnythingOfType("*types.RegistrySettings")).Return([]types.InstallableHelmChart{}, nil),
589565

590566
store.AppInstallMockStore.On("SetStatus", mock.MatchedBy(func(status types.Status) bool {
591567
return status.State == types.StateRunning
592568
})).Return(nil),
593569

594-
aim.On("Install", mock.Anything, []types.InstallableHelmChart{}, kotsConfigValues).Return(errors.New("install error")),
570+
aim.On("Install", mock.Anything, []types.InstallableHelmChart{}, mock.AnythingOfType("*types.RegistrySettings"), mock.AnythingOfType("string")).Return(errors.New("install error")),
595571

596572
store.AppInstallMockStore.On("SetStatus", mock.MatchedBy(func(status types.Status) bool {
597573
return status.State == types.StateFailed && strings.Contains(status.Description, "install error")
@@ -620,13 +596,6 @@ func (s *AppControllerTestSuite) TestInstallApp() {
620596
appConfigValues := types.AppConfigValues{
621597
"test-key": types.AppConfigValue{Value: "test-value"},
622598
}
623-
kotsConfigValues := kotsv1beta1.ConfigValues{
624-
Spec: kotsv1beta1.ConfigValuesSpec{
625-
Values: map[string]kotsv1beta1.ConfigValue{
626-
"test-key": {Value: "test-value"},
627-
},
628-
},
629-
}
630599
mock.InOrder(
631600
// Mock GetAppPreflightOutput to return non-strict failures (can be bypassed)
632601
apm.On("GetAppPreflightOutput", mock.Anything).Return(&types.PreflightsOutput{
@@ -640,14 +609,13 @@ func (s *AppControllerTestSuite) TestInstallApp() {
640609
}, nil),
641610

642611
acm.On("GetConfigValues").Return(appConfigValues, nil),
643-
acm.On("GetKotsadmConfigValues").Return(kotsConfigValues, nil),
644612
arm.On("ExtractInstallableHelmCharts", mock.Anything, appConfigValues, mock.AnythingOfType("*v1beta1.ProxySpec"), mock.AnythingOfType("*types.RegistrySettings")).Return([]types.InstallableHelmChart{}, nil),
645613

646614
store.AppInstallMockStore.On("SetStatus", mock.MatchedBy(func(status types.Status) bool {
647615
return status.State == types.StateRunning
648616
})).Return(nil),
649617

650-
aim.On("Install", mock.Anything, []types.InstallableHelmChart{}, kotsConfigValues).Return(nil),
618+
aim.On("Install", mock.Anything, []types.InstallableHelmChart{}, mock.AnythingOfType("*types.RegistrySettings"), mock.AnythingOfType("string")).Return(nil),
651619

652620
store.AppInstallMockStore.On("SetStatus", mock.MatchedBy(func(status types.Status) bool {
653621
return status.State == types.StateSucceeded

api/internal/managers/app/install/install.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,10 @@ import (
99
"github.com/replicatedhq/embedded-cluster/api/types"
1010
"github.com/replicatedhq/embedded-cluster/pkg/helm"
1111
"github.com/replicatedhq/embedded-cluster/pkg/runtimeconfig"
12-
kotsv1beta1 "github.com/replicatedhq/kotskinds/apis/kots/v1beta1"
1312
)
1413

15-
// Install installs the app with the provided config values
16-
func (m *appInstallManager) Install(ctx context.Context, installableCharts []types.InstallableHelmChart, configValues kotsv1beta1.ConfigValues, registrySettings *types.RegistrySettings, hostCABundlePath string) error {
14+
// Install installs the app with the provided Helm charts
15+
func (m *appInstallManager) Install(ctx context.Context, installableCharts []types.InstallableHelmChart, registrySettings *types.RegistrySettings, hostCABundlePath string) error {
1716
if err := m.setupClients(); err != nil {
1817
return fmt.Errorf("setup clients: %w", err)
1918
}

api/internal/managers/app/install/install_test.go

Lines changed: 5 additions & 93 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,12 @@ import (
77
"context"
88
"errors"
99
"fmt"
10-
"os"
1110
"testing"
1211
"time"
1312

1413
appinstallstore "github.com/replicatedhq/embedded-cluster/api/internal/store/app/install"
1514
"github.com/replicatedhq/embedded-cluster/api/pkg/logger"
1615
"github.com/replicatedhq/embedded-cluster/api/types"
17-
"github.com/replicatedhq/embedded-cluster/cmd/installer/kotscli"
1816
"github.com/replicatedhq/embedded-cluster/pkg/helm"
1917
"github.com/replicatedhq/embedded-cluster/pkg/release"
2018
kotsv1beta1 "github.com/replicatedhq/kotskinds/apis/kots/v1beta1"
@@ -130,97 +128,23 @@ func TestAppInstallManager_Install(t *testing.T) {
130128
databaseCall,
131129
)
132130

133-
configValues := kotsv1beta1.ConfigValues{
134-
Spec: kotsv1beta1.ConfigValuesSpec{
135-
Values: map[string]kotsv1beta1.ConfigValue{
136-
"key1": {
137-
Value: "value1",
138-
},
139-
"key2": {
140-
Value: "value2",
141-
},
142-
},
143-
},
144-
}
145-
146-
// Create mock installer with detailed verification
147-
mockKotsCLI := &kotscli.MockKotsCLI{}
148-
mockKotsCLI.On("Install", mock.MatchedBy(func(opts kotscli.InstallOptions) bool {
149-
// Verify basic install options
150-
if opts.AppSlug != "test-app" {
151-
t.Logf("AppSlug mismatch: expected 'test-app', got '%s'", opts.AppSlug)
152-
return false
153-
}
154-
if opts.License == nil {
155-
t.Logf("License is nil")
156-
return false
157-
}
158-
if opts.Namespace != "test-app" {
159-
t.Logf("Namespace mismatch: expected 'test-app', got '%s'", opts.Namespace)
160-
return false
161-
}
162-
if opts.ClusterID != "test-cluster" {
163-
t.Logf("ClusterID mismatch: expected 'test-cluster', got '%s'", opts.ClusterID)
164-
return false
165-
}
166-
if opts.AirgapBundle != "test-airgap.tar.gz" {
167-
t.Logf("AirgapBundle mismatch: expected 'test-airgap.tar.gz', got '%s'", opts.AirgapBundle)
168-
return false
169-
}
170-
if opts.ReplicatedAppEndpoint == "" {
171-
t.Logf("ReplicatedAppEndpoint is empty")
172-
return false
173-
}
174-
if opts.ConfigValuesFile == "" {
175-
t.Logf("ConfigValuesFile is empty")
176-
return false
177-
}
178-
if !opts.DisableImagePush {
179-
t.Logf("DisableImagePush is false")
180-
return false
181-
}
182-
183-
// Verify config values file content
184-
b, err := os.ReadFile(opts.ConfigValuesFile)
185-
if err != nil {
186-
t.Logf("Failed to read config values file: %v", err)
187-
return false
188-
}
189-
var cv kotsv1beta1.ConfigValues
190-
if err := kyaml.Unmarshal(b, &cv); err != nil {
191-
t.Logf("Failed to unmarshal config values: %v", err)
192-
return false
193-
}
194-
if cv.Spec.Values["key1"].Value != "value1" {
195-
t.Logf("Config value key1 mismatch: expected 'value1', got '%s'", cv.Spec.Values["key1"].Value)
196-
return false
197-
}
198-
if cv.Spec.Values["key2"].Value != "value2" {
199-
t.Logf("Config value key2 mismatch: expected 'value2', got '%s'", cv.Spec.Values["key2"].Value)
200-
return false
201-
}
202-
return true
203-
})).Return(nil)
204-
205131
// Create manager
206132
manager, err := NewAppInstallManager(
207133
WithClusterID("test-cluster"),
208134
WithAirgapBundle("test-airgap.tar.gz"),
209135
WithReleaseData(releaseData),
210136
WithLicense(licenseBytes),
211137
WithHelmClient(mockHelmClient),
212-
WithKotsCLI(mockKotsCLI),
213138
WithLogger(logger.NewDiscardLogger()),
214139
WithKubeClient(fakeKcli),
215140
)
216141
require.NoError(t, err)
217142

218143
// Run installation with InstallableHelmCharts
219-
err = manager.Install(context.Background(), installableCharts, configValues, nil, "")
144+
err = manager.Install(context.Background(), installableCharts, nil, "")
220145
require.NoError(t, err)
221146

222147
mockHelmClient.AssertExpectations(t)
223-
mockKotsCLI.AssertExpectations(t)
224148
})
225149

226150
t.Run("Install updates status correctly", func(t *testing.T) {
@@ -234,10 +158,6 @@ func TestAppInstallManager_Install(t *testing.T) {
234158
return opts.ChartPath != "" && opts.ReleaseName == "prometheus" && opts.Namespace == "monitoring"
235159
})).Return("Release \"prometheus\" has been installed.", nil)
236160

237-
// Create mock KOTS CLI
238-
mockKotsCLI := &kotscli.MockKotsCLI{}
239-
mockKotsCLI.On("Install", mock.Anything).Return(nil)
240-
241161
// Create manager with initialized store
242162
store := appinstallstore.NewMemoryStore(appinstallstore.WithAppInstall(types.AppInstall{
243163
Status: types.Status{State: types.StatePending},
@@ -247,7 +167,6 @@ func TestAppInstallManager_Install(t *testing.T) {
247167
WithReleaseData(releaseData),
248168
WithLicense(licenseBytes),
249169
WithHelmClient(mockHelmClient),
250-
WithKotsCLI(mockKotsCLI),
251170
WithLogger(logger.NewDiscardLogger()),
252171
WithAppInstallStore(store),
253172
WithKubeClient(fakeKcli),
@@ -260,7 +179,7 @@ func TestAppInstallManager_Install(t *testing.T) {
260179
assert.Equal(t, types.StatePending, appInstall.Status.State)
261180

262181
// Run installation
263-
err = manager.Install(t.Context(), installableCharts, kotsv1beta1.ConfigValues{}, nil, "")
182+
err = manager.Install(t.Context(), installableCharts, nil, "")
264183
require.NoError(t, err)
265184

266185
// Verify components status
@@ -269,7 +188,6 @@ func TestAppInstallManager_Install(t *testing.T) {
269188
assert.NotEmpty(t, appInstall.Components)
270189

271190
mockHelmClient.AssertExpectations(t)
272-
mockKotsCLI.AssertExpectations(t)
273191
})
274192

275193
t.Run("Install handles errors correctly", func(t *testing.T) {
@@ -299,7 +217,7 @@ func TestAppInstallManager_Install(t *testing.T) {
299217
require.NoError(t, err)
300218

301219
// Run installation (should fail)
302-
err = manager.Install(t.Context(), installableCharts, kotsv1beta1.ConfigValues{}, nil, "")
220+
err = manager.Install(t.Context(), installableCharts, nil, "")
303221
assert.Error(t, err)
304222

305223
mockHelmClient.AssertExpectations(t)
@@ -445,10 +363,6 @@ func TestComponentStatusTracking(t *testing.T) {
445363
return opts.ReleaseName == "nginx" && opts.Namespace == "web"
446364
})).Return("Release \"nginx\" has been installed.", nil).Once()
447365

448-
// Create mock KOTS CLI
449-
mockKotsCLI := &kotscli.MockKotsCLI{}
450-
mockKotsCLI.On("Install", mock.Anything).Return(nil)
451-
452366
// Create manager with in-memory store
453367
appInstallStore := appinstallstore.NewMemoryStore(appinstallstore.WithAppInstall(types.AppInstall{
454368
Status: types.Status{State: types.StatePending},
@@ -459,13 +373,12 @@ func TestComponentStatusTracking(t *testing.T) {
459373
WithLicense(licenseBytes),
460374
WithClusterID("test-cluster"),
461375
WithHelmClient(mockHelmClient),
462-
WithKotsCLI(mockKotsCLI),
463376
WithKubeClient(fakeKcli),
464377
)
465378
require.NoError(t, err)
466379

467380
// Install the charts
468-
err = manager.Install(t.Context(), installableCharts, kotsv1beta1.ConfigValues{}, nil, "")
381+
err = manager.Install(t.Context(), installableCharts, nil, "")
469382
require.NoError(t, err)
470383

471384
// Verify that components were registered and have correct status
@@ -483,7 +396,6 @@ func TestComponentStatusTracking(t *testing.T) {
483396
assert.Equal(t, types.StateSucceeded, appInstall.Components[1].Status.State)
484397

485398
mockHelmClient.AssertExpectations(t)
486-
mockKotsCLI.AssertExpectations(t)
487399
})
488400

489401
t.Run("Component failure is tracked correctly", func(t *testing.T) {
@@ -513,7 +425,7 @@ func TestComponentStatusTracking(t *testing.T) {
513425
require.NoError(t, err)
514426

515427
// Install the charts (should fail)
516-
err = manager.Install(t.Context(), installableCharts, kotsv1beta1.ConfigValues{}, nil, "")
428+
err = manager.Install(t.Context(), installableCharts, nil, "")
517429
require.Error(t, err)
518430

519431
// Verify that component failure is tracked

api/internal/managers/app/install/manager.go

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,8 @@ import (
66
appinstallstore "github.com/replicatedhq/embedded-cluster/api/internal/store/app/install"
77
"github.com/replicatedhq/embedded-cluster/api/pkg/logger"
88
"github.com/replicatedhq/embedded-cluster/api/types"
9-
kotscli "github.com/replicatedhq/embedded-cluster/cmd/installer/kotscli"
109
"github.com/replicatedhq/embedded-cluster/pkg/helm"
1110
"github.com/replicatedhq/embedded-cluster/pkg/release"
12-
kotsv1beta1 "github.com/replicatedhq/kotskinds/apis/kots/v1beta1"
1311
"github.com/sirupsen/logrus"
1412
helmcli "helm.sh/helm/v3/pkg/cli"
1513
"k8s.io/client-go/metadata"
@@ -20,8 +18,8 @@ var _ AppInstallManager = &appInstallManager{}
2018

2119
// AppInstallManager provides methods for managing app installation
2220
type AppInstallManager interface {
23-
// Install installs the app with the provided config values
24-
Install(ctx context.Context, installableCharts []types.InstallableHelmChart, configValues kotsv1beta1.ConfigValues, registrySettings *types.RegistrySettings, hostCABundlePath string) error
21+
// Install installs the app with the provided Helm charts
22+
Install(ctx context.Context, installableCharts []types.InstallableHelmChart, registrySettings *types.RegistrySettings, hostCABundlePath string) error
2523
}
2624

2725
// appInstallManager is an implementation of the AppInstallManager interface
@@ -31,7 +29,6 @@ type appInstallManager struct {
3129
license []byte
3230
clusterID string
3331
airgapBundle string
34-
kotsCLI kotscli.KotsCLI
3532
hcli helm.Client
3633
kcli client.Client
3734
mcli metadata.Interface
@@ -83,12 +80,6 @@ func WithHelmClient(hcli helm.Client) AppInstallManagerOption {
8380
}
8481
}
8582

86-
func WithKotsCLI(kotsCLI kotscli.KotsCLI) AppInstallManagerOption {
87-
return func(m *appInstallManager) {
88-
m.kotsCLI = kotsCLI
89-
}
90-
}
91-
9283
func WithKubeClient(kcli client.Client) AppInstallManagerOption {
9384
return func(m *appInstallManager) {
9485
m.kcli = kcli

0 commit comments

Comments
 (0)