Skip to content

Commit e83185d

Browse files
authored
Fix processing config values in EC automated installs (#5268)
1 parent 615c262 commit e83185d

File tree

3 files changed

+14
-19
lines changed

3 files changed

+14
-19
lines changed

pkg/airgap/airgap.go

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import (
1313
"github.com/replicatedhq/kots/pkg/airgap/types"
1414
"github.com/replicatedhq/kots/pkg/archives"
1515
kotsadmtypes "github.com/replicatedhq/kots/pkg/kotsadm/types"
16-
kotsadmconfig "github.com/replicatedhq/kots/pkg/kotsadmconfig"
1716
identity "github.com/replicatedhq/kots/pkg/kotsadmidentity"
1817
"github.com/replicatedhq/kots/pkg/kotsutil"
1918
"github.com/replicatedhq/kots/pkg/logger"
@@ -42,6 +41,7 @@ type CreateAirgapAppOpts struct {
4241
RegistryPassword string
4342
RegistryIsReadOnly bool
4443
IsAutomated bool
44+
ConfigValues string
4545
SkipPreflights bool
4646
SkipCompatibilityCheck bool
4747
}
@@ -161,18 +161,14 @@ func CreateAppFromAirgap(opts CreateAirgapAppOpts) (finalError error) {
161161

162162
appNamespace := util.AppNamespace()
163163

164-
configValues, err := kotsadmconfig.ReadConfigValuesFromInClusterSecret()
165-
if err != nil {
166-
return errors.Wrap(err, "failed to read config values from in cluster")
167-
}
168164
configFile := ""
169-
if configValues != "" {
165+
if opts.ConfigValues != "" {
170166
tmpFile, err := ioutil.TempFile("", "kots")
171167
if err != nil {
172168
return errors.Wrap(err, "failed to create temp file for config values")
173169
}
174170
defer os.RemoveAll(tmpFile.Name())
175-
if err := ioutil.WriteFile(tmpFile.Name(), []byte(configValues), 0644); err != nil {
171+
if err := ioutil.WriteFile(tmpFile.Name(), []byte(opts.ConfigValues), 0644); err != nil {
176172
return errors.Wrap(err, "failed to write config values to temp file")
177173
}
178174

pkg/automation/automation.go

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -256,13 +256,14 @@ func installLicenseSecret(clientset *kubernetes.Clientset, licenseSecret corev1.
256256
}
257257
appSlug = a.Slug
258258

259-
// in embedded cluster, the installation is considered automated if a config values file has been provided by the user.
259+
configValues, err := kotsadmconfig.ReadConfigValuesFromInClusterSecret()
260+
if err != nil {
261+
return errors.Wrap(err, "failed to read config values from in cluster")
262+
}
263+
260264
isAutomated := true
261265
if util.IsEmbeddedCluster() {
262-
configValues, err := kotsadmconfig.ReadConfigValuesFromInClusterSecret()
263-
if err != nil {
264-
return errors.Wrap(err, "failed to read config values from in cluster")
265-
}
266+
// in embedded cluster, the installation is considered automated if a config values file has been provided by the user.
266267
isAutomated = configValues != ""
267268
}
268269

@@ -317,6 +318,7 @@ func installLicenseSecret(clientset *kubernetes.Clientset, licenseSecret corev1.
317318
RegistryPassword: registryConfig.Password,
318319
RegistryIsReadOnly: instParams.RegistryIsReadOnly,
319320
IsAutomated: isAutomated,
321+
ConfigValues: configValues,
320322
SkipPreflights: instParams.SkipPreflights,
321323
SkipCompatibilityCheck: instParams.SkipCompatibilityCheck,
322324
}
@@ -336,6 +338,7 @@ func installLicenseSecret(clientset *kubernetes.Clientset, licenseSecret corev1.
336338
},
337339
UpstreamURI: upstreamURI,
338340
IsAutomated: isAutomated,
341+
ConfigValues: configValues,
339342
SkipPreflights: instParams.SkipPreflights,
340343
SkipCompatibilityCheck: instParams.SkipCompatibilityCheck,
341344
}

pkg/online/online.go

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import (
99

1010
"github.com/pkg/errors"
1111
apptypes "github.com/replicatedhq/kots/pkg/app/types"
12-
kotsadmconfig "github.com/replicatedhq/kots/pkg/kotsadmconfig"
1312
identity "github.com/replicatedhq/kots/pkg/kotsadmidentity"
1413
"github.com/replicatedhq/kots/pkg/kotsutil"
1514
"github.com/replicatedhq/kots/pkg/logger"
@@ -32,6 +31,7 @@ type CreateOnlineAppOpts struct {
3231
PendingApp *types.PendingApp
3332
UpstreamURI string
3433
IsAutomated bool
34+
ConfigValues string
3535
SkipPreflights bool
3636
SkipCompatibilityCheck bool
3737
}
@@ -111,18 +111,14 @@ func CreateAppFromOnline(opts CreateOnlineAppOpts) (_ *kotsutil.KotsKinds, final
111111

112112
appNamespace := util.AppNamespace()
113113

114-
configValues, err := kotsadmconfig.ReadConfigValuesFromInClusterSecret()
115-
if err != nil {
116-
return nil, errors.Wrap(err, "failed to read config values from in cluster")
117-
}
118114
configFile := ""
119-
if configValues != "" {
115+
if opts.ConfigValues != "" {
120116
tmpFile, err := ioutil.TempFile("", "kots")
121117
if err != nil {
122118
return nil, errors.Wrap(err, "failed to create temp file for config values")
123119
}
124120
defer os.RemoveAll(tmpFile.Name())
125-
if err := ioutil.WriteFile(tmpFile.Name(), []byte(configValues), 0644); err != nil {
121+
if err := ioutil.WriteFile(tmpFile.Name(), []byte(opts.ConfigValues), 0644); err != nil {
126122
return nil, errors.Wrap(err, "failed to write config values to temp file")
127123
}
128124

0 commit comments

Comments
 (0)