Skip to content

Commit 255f9dc

Browse files
feat: warn if online installation is attempted on air gap (#1475)
* feat: warn if online installation is attempted on air gap vendor portal informs us (through the embedded channel release struct) if the binary was downloaded with or without an airgap bundle. if the binary was downloaded with an airgap bundle, we should warn the user we must warn the users if they attempt to install the binary without passing in the airgap bundle flag. * Update pkg/cmd/install.go Co-authored-by: Andrew Lavery <[email protected]> * Update pkg/cmd/join.go Co-authored-by: Andrew Lavery <[email protected]> * Update pkg/cmd/restore.go Co-authored-by: Andrew Lavery <[email protected]> --------- Co-authored-by: Andrew Lavery <[email protected]>
1 parent 088bf8d commit 255f9dc

File tree

4 files changed

+33
-0
lines changed

4 files changed

+33
-0
lines changed

pkg/cmd/install.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -769,6 +769,17 @@ func installCommand() *cli.Command {
769769
logrus.Infof("\n sudo ./%s reset\n", binName)
770770
return ErrNothingElseToAdd
771771
}
772+
773+
if channelRelease, err := release.GetChannelRelease(); err != nil {
774+
return fmt.Errorf("unable to read channel release data: %w", err)
775+
} else if channelRelease != nil && channelRelease.Airgap && c.String("airgap-bundle") == "" && !c.Bool("no-prompt") {
776+
logrus.Infof("You downloaded an air gap bundle but are performing an online installation.")
777+
logrus.Infof("To do an air gap installation, pass the air gap bundle with --airgap-bundle.")
778+
if !prompts.New().Confirm("Do you want to proceed with an online installation?", false) {
779+
return ErrNothingElseToAdd
780+
}
781+
}
782+
772783
metrics.ReportApplyStarted(c)
773784
logrus.Debugf("configuring network manager")
774785
if err := configureNetworkManager(c, provider); err != nil {

pkg/cmd/join.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import (
3131
"github.com/replicatedhq/embedded-cluster/pkg/metrics"
3232
"github.com/replicatedhq/embedded-cluster/pkg/netutils"
3333
"github.com/replicatedhq/embedded-cluster/pkg/prompts"
34+
"github.com/replicatedhq/embedded-cluster/pkg/release"
3435
"github.com/replicatedhq/embedded-cluster/pkg/spinner"
3536
"github.com/replicatedhq/embedded-cluster/pkg/versions"
3637
)
@@ -185,6 +186,16 @@ var joinCommand = &cli.Command{
185186
return fmt.Errorf("usage: %s join <url> <token>", binName)
186187
}
187188

189+
if channelRelease, err := release.GetChannelRelease(); err != nil {
190+
return fmt.Errorf("unable to read channel release data: %w", err)
191+
} else if channelRelease != nil && channelRelease.Airgap && c.String("airgap-bundle") == "" && !c.Bool("no-prompt") {
192+
logrus.Infof("You downloaded an air gap bundle but are performing an online join.")
193+
logrus.Infof("To do an air gap join, pass the air gap bundle with --airgap-bundle.")
194+
if !prompts.New().Confirm("Do you want to proceed with an online join?", false) {
195+
return ErrNothingElseToAdd
196+
}
197+
}
198+
188199
logrus.Debugf("fetching join token remotely")
189200
jcmd, err := getJoinToken(c.Context, c.Args().Get(0), c.Args().Get(1))
190201
if err != nil {

pkg/cmd/restore.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -959,6 +959,16 @@ func restoreCommand() *cli.Command {
959959
return fmt.Errorf("unable to write runtime config: %w", err)
960960
}
961961

962+
if channelRelease, err := release.GetChannelRelease(); err != nil {
963+
return fmt.Errorf("unable to read channel release data: %w", err)
964+
} else if channelRelease != nil && channelRelease.Airgap && c.String("airgap-bundle") == "" && !c.Bool("no-prompt") {
965+
logrus.Infof("You downloaded an air gap bundle but are performing an online restore.")
966+
logrus.Infof("To do an air gap restore, pass the air gap bundle with --airgap-bundle.")
967+
if !prompts.New().Confirm("Do you want to proceed with an online restore?", false) {
968+
return ErrNothingElseToAdd
969+
}
970+
}
971+
962972
proxy, err := getProxySpecFromFlags(c)
963973
if err != nil {
964974
return fmt.Errorf("unable to get proxy spec from flags: %w", err)

pkg/release/release.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@ type ChannelRelease struct {
155155
ChannelID string `yaml:"channelID"`
156156
ChannelSlug string `yaml:"channelSlug"`
157157
AppSlug string `yaml:"appSlug"`
158+
Airgap bool `yaml:"airgap"`
158159
}
159160

160161
// GetChannelRelease reads the embedded channel release object. If no channel release

0 commit comments

Comments
 (0)