Skip to content

Commit 30e78de

Browse files
committed
Pass airgap info to the api
Signed-off-by: Evans Mungai <evans@replicated.com>
1 parent fc96cf4 commit 30e78de

File tree

5 files changed

+25
-9
lines changed

5 files changed

+25
-9
lines changed

api/api.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import (
1919
"github.com/replicatedhq/embedded-cluster/pkg/metrics"
2020
"github.com/replicatedhq/embedded-cluster/pkg/release"
2121
"github.com/replicatedhq/embedded-cluster/pkg/runtimeconfig"
22+
kotsv1beta1 "github.com/replicatedhq/kotskinds/apis/kots/v1beta1"
2223
"github.com/sirupsen/logrus"
2324
httpSwagger "github.com/swaggo/http-swagger/v2"
2425
)
@@ -50,6 +51,7 @@ type API struct {
5051
tlsConfig types.TLSConfig
5152
licenseFile string
5253
airgapBundle string
54+
airgapInfo *kotsv1beta1.Airgap
5355
configValues string
5456
endUserConfig *ecv1beta1.Config
5557
logger logrus.FieldLogger
@@ -125,6 +127,12 @@ func WithAirgapBundle(airgapBundle string) APIOption {
125127
}
126128
}
127129

130+
func WithAirgapInfo(airgapInfo *kotsv1beta1.Airgap) APIOption {
131+
return func(a *API) {
132+
a.airgapInfo = airgapInfo
133+
}
134+
}
135+
128136
func WithConfigValues(configValues string) APIOption {
129137
return func(a *API) {
130138
a.configValues = configValues
@@ -190,6 +198,7 @@ func New(password string, opts ...APIOption) (*API, error) {
190198
install.WithTLSConfig(api.tlsConfig),
191199
install.WithLicenseFile(api.licenseFile),
192200
install.WithAirgapBundle(api.airgapBundle),
201+
install.WithAirgapInfo(api.airgapInfo),
193202
install.WithConfigValues(api.configValues),
194203
install.WithEndUserConfig(api.endUserConfig),
195204
)

api/controllers/install/controller.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import (
1616
"github.com/replicatedhq/embedded-cluster/pkg/metrics"
1717
"github.com/replicatedhq/embedded-cluster/pkg/release"
1818
"github.com/replicatedhq/embedded-cluster/pkg/runtimeconfig"
19+
kotsv1beta1 "github.com/replicatedhq/kotskinds/apis/kots/v1beta1"
1920
"github.com/sirupsen/logrus"
2021
)
2122

@@ -55,6 +56,7 @@ type InstallController struct {
5556
tlsConfig types.TLSConfig
5657
licenseFile string
5758
airgapBundle string
59+
airgapInfo *kotsv1beta1.Airgap
5860
configValues string
5961
endUserConfig *ecv1beta1.Config
6062
mu sync.RWMutex
@@ -122,6 +124,12 @@ func WithAirgapBundle(airgapBundle string) InstallControllerOption {
122124
}
123125
}
124126

127+
func WithAirgapInfo(airgapInfo *kotsv1beta1.Airgap) InstallControllerOption {
128+
return func(c *InstallController) {
129+
c.airgapInfo = airgapInfo
130+
}
131+
}
132+
125133
func WithConfigValues(configValues string) InstallControllerOption {
126134
return func(c *InstallController) {
127135
c.configValues = configValues

api/controllers/install/hostpreflight.go

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import (
88
"github.com/replicatedhq/embedded-cluster/api/pkg/utils"
99
"github.com/replicatedhq/embedded-cluster/api/types"
1010
"github.com/replicatedhq/embedded-cluster/pkg-new/preflights"
11-
"github.com/replicatedhq/embedded-cluster/pkg/airgap"
1211
"github.com/replicatedhq/embedded-cluster/pkg/netutils"
1312
)
1413

@@ -18,12 +17,8 @@ func (c *InstallController) RunHostPreflights(ctx context.Context, opts RunHostP
1817

1918
// Calculate airgap storage space requirement (2x uncompressed size for controller nodes)
2019
var controllerAirgapStorageSpace string
21-
if c.airgapBundle != "" {
22-
airgapInfo, err := airgap.AirgapInfoFromPath(c.airgapBundle)
23-
if err != nil {
24-
return fmt.Errorf("failed to get airgap info: %w", err)
25-
}
26-
controllerAirgapStorageSpace = preflights.CalculateAirgapStorageSpace(airgapInfo.Spec.UncompressedSize, true)
20+
if c.airgapInfo != nil {
21+
controllerAirgapStorageSpace = preflights.CalculateAirgapStorageSpace(c.airgapInfo.Spec.UncompressedSize, true)
2722
}
2823

2924
// Prepare host preflights

cmd/installer/cli/api.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import (
2424
"github.com/replicatedhq/embedded-cluster/pkg/release"
2525
"github.com/replicatedhq/embedded-cluster/pkg/runtimeconfig"
2626
"github.com/replicatedhq/embedded-cluster/web"
27+
kotsv1beta1 "github.com/replicatedhq/kotskinds/apis/kots/v1beta1"
2728
"github.com/sirupsen/logrus"
2829
)
2930

@@ -37,6 +38,7 @@ type apiConfig struct {
3738
ManagerPort int
3839
LicenseFile string
3940
AirgapBundle string
41+
AirgapInfo *kotsv1beta1.Airgap
4042
ConfigValues string
4143
ReleaseData *release.ReleaseData
4244
EndUserConfig *ecv1beta1.Config
@@ -89,6 +91,7 @@ func serveAPI(ctx context.Context, listener net.Listener, cert tls.Certificate,
8991
api.WithTLSConfig(config.TLSConfig),
9092
api.WithLicenseFile(config.LicenseFile),
9193
api.WithAirgapBundle(config.AirgapBundle),
94+
api.WithAirgapInfo(config.AirgapInfo),
9295
api.WithConfigValues(config.ConfigValues),
9396
api.WithEndUserConfig(config.EndUserConfig),
9497
)

cmd/installer/cli/install.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ func InstallCmd(ctx context.Context, name string) *cobra.Command {
112112
}
113113

114114
if flags.enableManagerExperience {
115-
return runManagerExperienceInstall(ctx, flags, rc)
115+
return runManagerExperienceInstall(ctx, flags, rc, airgapInfo)
116116
}
117117

118118
_ = rc.SetEnv()
@@ -359,7 +359,7 @@ func cidrConfigFromCmd(cmd *cobra.Command) (*newconfig.CIDRConfig, error) {
359359
return cidrCfg, nil
360360
}
361361

362-
func runManagerExperienceInstall(ctx context.Context, flags InstallCmdFlags, rc runtimeconfig.RuntimeConfig) (finalErr error) {
362+
func runManagerExperienceInstall(ctx context.Context, flags InstallCmdFlags, rc runtimeconfig.RuntimeConfig, airgapInfo *kotsv1beta1.Airgap) (finalErr error) {
363363
// this is necessary because the api listens on all interfaces,
364364
// and we only know the interface to use when the user selects it in the ui
365365
ipAddresses, err := netutils.ListAllValidIPAddresses()
@@ -428,6 +428,7 @@ func runManagerExperienceInstall(ctx context.Context, flags InstallCmdFlags, rc
428428
ManagerPort: flags.managerPort,
429429
LicenseFile: flags.licenseFile,
430430
AirgapBundle: flags.airgapBundle,
431+
AirgapInfo: airgapInfo,
431432
ConfigValues: flags.configValues,
432433
ReleaseData: release.GetReleaseData(),
433434
EndUserConfig: eucfg,

0 commit comments

Comments
 (0)