Skip to content

Commit f72e05c

Browse files
committed
Merge remote-tracking branch 'origin/main' into evansmungai/sc-123579/take-airgap-bundle-size-into-account-when
2 parents 30e78de + 8fa788b commit f72e05c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+1836
-1929
lines changed

api/README.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,14 @@ The root directory contains the main API setup files and request handlers.
1212
#### `/controllers`
1313
Contains the business logic for different API endpoints. Each controller package focuses on a specific domain of functionality or workflow (e.g., authentication, console, install, upgrade, join, etc.) and implements the core business logic for that domain or workflow. Controllers can utilize multiple managers with each manager handling a specific subdomain of functionality.
1414

15+
#### `/internal`
16+
Contains shared utilities and helper packages that provide common functionality used across different parts of the API. This includes both general-purpose utilities and domain-specific helpers.
17+
1518
#### `/internal/managers`
16-
Each manager is responsible for a specific subdomain of functionality and provides a clean, thread-safe interface for controllers to interact with. For example, the Preflight Manager manages system requirement checks and validation.
19+
Each manager is responsible for a specific subdomain of functionality and provides a clean interface for controllers to interact with. For example, the Preflight Manager manages system requirement checks and validation.
20+
21+
#### `/internal/statemachine`
22+
The statemachine is used by controllers to capture workflow state and enforce valid transitions.
1723

1824
#### `/types`
1925
Defines the core data structures and types used throughout the API. This includes:
@@ -30,7 +36,7 @@ Contains Swagger-generated API documentation. This includes:
3036
- API operation descriptions
3137

3238
#### `/pkg`
33-
Contains shared utilities and helper packages that provide common functionality used across different parts of the API. This includes both general-purpose utilities and domain-specific helpers.
39+
Contains helper packages that can be used by packages external to the API.
3440

3541
#### `/client`
3642
Provides a client library for interacting with the API. The client package implements a clean interface for making API calls and handling responses, making it easy to integrate with the API from other parts of the system.

api/api.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ type API struct {
4949
rc runtimeconfig.RuntimeConfig
5050
releaseData *release.ReleaseData
5151
tlsConfig types.TLSConfig
52-
licenseFile string
52+
license []byte
5353
airgapBundle string
5454
airgapInfo *kotsv1beta1.Airgap
5555
configValues string
@@ -115,9 +115,9 @@ func WithTLSConfig(tlsConfig types.TLSConfig) APIOption {
115115
}
116116
}
117117

118-
func WithLicenseFile(licenseFile string) APIOption {
118+
func WithLicense(license []byte) APIOption {
119119
return func(a *API) {
120-
a.licenseFile = licenseFile
120+
a.license = license
121121
}
122122
}
123123

@@ -196,7 +196,7 @@ func New(password string, opts ...APIOption) (*API, error) {
196196
install.WithReleaseData(api.releaseData),
197197
install.WithPassword(password),
198198
install.WithTLSConfig(api.tlsConfig),
199-
install.WithLicenseFile(api.licenseFile),
199+
install.WithLicense(api.license),
200200
install.WithAirgapBundle(api.airgapBundle),
201201
install.WithAirgapInfo(api.airgapInfo),
202202
install.WithConfigValues(api.configValues),

api/controllers/install/controller.go

Lines changed: 25 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"github.com/replicatedhq/embedded-cluster/api/internal/managers/infra"
88
"github.com/replicatedhq/embedded-cluster/api/internal/managers/installation"
99
"github.com/replicatedhq/embedded-cluster/api/internal/managers/preflight"
10+
"github.com/replicatedhq/embedded-cluster/api/internal/statemachine"
1011
"github.com/replicatedhq/embedded-cluster/api/internal/store"
1112
"github.com/replicatedhq/embedded-cluster/api/pkg/logger"
1213
"github.com/replicatedhq/embedded-cluster/api/pkg/utils"
@@ -41,25 +42,27 @@ type RunHostPreflightsOptions struct {
4142
var _ Controller = (*InstallController)(nil)
4243

4344
type InstallController struct {
44-
install types.Install
45-
store store.Store
4645
installationManager installation.InstallationManager
4746
hostPreflightManager preflight.HostPreflightManager
4847
infraManager infra.InfraManager
49-
rc runtimeconfig.RuntimeConfig
50-
logger logrus.FieldLogger
5148
hostUtils hostutils.HostUtilsInterface
5249
netUtils utils.NetUtils
5350
metricsReporter metrics.ReporterInterface
5451
releaseData *release.ReleaseData
5552
password string
5653
tlsConfig types.TLSConfig
57-
licenseFile string
54+
license []byte
5855
airgapBundle string
5956
airgapInfo *kotsv1beta1.Airgap
6057
configValues string
6158
endUserConfig *ecv1beta1.Config
62-
mu sync.RWMutex
59+
60+
install types.Install
61+
store store.Store
62+
rc runtimeconfig.RuntimeConfig
63+
stateMachine statemachine.Interface
64+
logger logrus.FieldLogger
65+
mu sync.RWMutex
6366
}
6467

6568
type InstallControllerOption func(*InstallController)
@@ -112,9 +115,9 @@ func WithTLSConfig(tlsConfig types.TLSConfig) InstallControllerOption {
112115
}
113116
}
114117

115-
func WithLicenseFile(licenseFile string) InstallControllerOption {
118+
func WithLicense(license []byte) InstallControllerOption {
116119
return func(c *InstallController) {
117-
c.licenseFile = licenseFile
120+
c.license = license
118121
}
119122
}
120123

@@ -160,19 +163,22 @@ func WithInfraManager(infraManager infra.InfraManager) InstallControllerOption {
160163
}
161164
}
162165

163-
func NewInstallController(opts ...InstallControllerOption) (*InstallController, error) {
164-
controller := &InstallController{}
165-
166-
for _, opt := range opts {
167-
opt(controller)
166+
func WithStateMachine(stateMachine statemachine.Interface) InstallControllerOption {
167+
return func(c *InstallController) {
168+
c.stateMachine = stateMachine
168169
}
170+
}
169171

170-
if controller.rc == nil {
171-
controller.rc = runtimeconfig.New(nil)
172+
func NewInstallController(opts ...InstallControllerOption) (*InstallController, error) {
173+
controller := &InstallController{
174+
store: store.NewMemoryStore(),
175+
rc: runtimeconfig.New(nil),
176+
logger: logger.NewDiscardLogger(),
177+
stateMachine: NewStateMachine(),
172178
}
173179

174-
if controller.logger == nil {
175-
controller.logger = logger.NewDiscardLogger()
180+
for _, opt := range opts {
181+
opt(controller)
176182
}
177183

178184
if controller.hostUtils == nil {
@@ -185,15 +191,11 @@ func NewInstallController(opts ...InstallControllerOption) (*InstallController,
185191
controller.netUtils = utils.NewNetUtils()
186192
}
187193

188-
if controller.store == nil {
189-
controller.store = store.NewMemoryStore()
190-
}
191-
192194
if controller.installationManager == nil {
193195
controller.installationManager = installation.NewInstallationManager(
194196
installation.WithLogger(controller.logger),
195197
installation.WithInstallationStore(controller.store.InstallationStore()),
196-
installation.WithLicenseFile(controller.licenseFile),
198+
installation.WithLicense(controller.license),
197199
installation.WithAirgapBundle(controller.airgapBundle),
198200
installation.WithHostUtils(controller.hostUtils),
199201
installation.WithNetUtils(controller.netUtils),
@@ -215,7 +217,7 @@ func NewInstallController(opts ...InstallControllerOption) (*InstallController,
215217
infra.WithInfraStore(controller.store.InfraStore()),
216218
infra.WithPassword(controller.password),
217219
infra.WithTLSConfig(controller.tlsConfig),
218-
infra.WithLicenseFile(controller.licenseFile),
220+
infra.WithLicense(controller.license),
219221
infra.WithAirgapBundle(controller.airgapBundle),
220222
infra.WithConfigValues(controller.configValues),
221223
infra.WithReleaseData(controller.releaseData),

0 commit comments

Comments
 (0)