Skip to content

Commit 949292b

Browse files
authored
feat: use LICENSE_TOKEN from env (#3541)
1 parent 9d6daac commit 949292b

File tree

3 files changed

+14
-2
lines changed

3 files changed

+14
-2
lines changed

pkg/cli/start/docker.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,12 @@ func (l *LoftStarter) runLoftInDocker(ctx context.Context, name string) (string,
263263
args = append(args, "--env", "ADMIN_EMAIL="+l.Email)
264264
}
265265

266+
// if we have LICENSE_TOKEN environment variable set, we use it to install the platform
267+
if os.Getenv("LICENSE_TOKEN") != "" {
268+
l.Log.Infof("Found LICENSE_TOKEN in environment, will use it to install the platform")
269+
args = append(args, "--env", "LICENSE_TOKEN="+os.Getenv("LICENSE_TOKEN"))
270+
}
271+
266272
// mount the vCluster platform lib
267273
args = append(args, "-v", "vcluster-platform:/var/lib/loft")
268274

@@ -283,7 +289,8 @@ func (l *LoftStarter) runLoftInDocker(ctx context.Context, name string) (string,
283289
args = append(args, "ghcr.io/loft-sh/vcluster-platform:latest")
284290
}
285291

286-
l.Log.Infof("Start vCluster platform via 'docker %s'", strings.Join(args, " "))
292+
l.Log.Debugf("Start vCluster platform via 'docker %s'", strings.Join(args, " "))
293+
l.Log.Infof("Starting vCluster platform...")
287294
runCmd := l.buildDockerCmd(ctx, args...)
288295
runCmd.Stdout = os.Stdout
289296
runCmd.Stderr = os.Stderr

pkg/cli/start/upgrade.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@ func (l *LoftStarter) upgradeLoft(ctx context.Context) error {
3939
if l.Email != "" {
4040
extraArgs = append(extraArgs, "--set", "admin.email="+l.Email)
4141
}
42+
if os.Getenv("LICENSE_TOKEN") != "" {
43+
l.Log.Infof("Found LICENSE_TOKEN in environment, will use it to install the platform")
44+
extraArgs = append(extraArgs, "--set", "env.LICENSE_TOKEN="+os.Getenv("LICENSE_TOKEN"))
45+
}
4246

4347
// Do not use --reuse-values if --reset flag is provided because this should be a new install and it will cause issues with `helm template`
4448
if !l.Reset && l.ReuseValues {

pkg/platform/clihelper/clihelper.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -731,7 +731,8 @@ func UpgradeLoft(ctx context.Context, kubeClient kubernetes.Interface, chartName
731731
args = append(args, extraArgs...)
732732

733733
log.WriteString(logrus.InfoLevel, "\n")
734-
log.Infof("Executing command: helm %s\n", strings.Join(args, " "))
734+
log.Debugf("Executing command: helm %s\n", strings.Join(args, " "))
735+
log.Infof("Starting vCluster platform...")
735736
log.Info("Waiting for helm command, this can take up to several minutes...")
736737
helmCmd := exec.Command("helm", args...)
737738
if chartRepo != "" {

0 commit comments

Comments
 (0)