Skip to content

Commit

Permalink
feat: warn if online installation is attempted on air gap (#1475)
Browse files Browse the repository at this point in the history
* 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 <laverya@umich.edu>

* Update pkg/cmd/join.go

Co-authored-by: Andrew Lavery <laverya@umich.edu>

* Update pkg/cmd/restore.go

Co-authored-by: Andrew Lavery <laverya@umich.edu>

---------

Co-authored-by: Andrew Lavery <laverya@umich.edu>
  • Loading branch information
ricardomaraschini and laverya authored Nov 12, 2024
1 parent 088bf8d commit 255f9dc
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 0 deletions.
11 changes: 11 additions & 0 deletions pkg/cmd/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -769,6 +769,17 @@ func installCommand() *cli.Command {
logrus.Infof("\n sudo ./%s reset\n", binName)
return ErrNothingElseToAdd
}

if channelRelease, err := release.GetChannelRelease(); err != nil {
return fmt.Errorf("unable to read channel release data: %w", err)
} else if channelRelease != nil && channelRelease.Airgap && c.String("airgap-bundle") == "" && !c.Bool("no-prompt") {
logrus.Infof("You downloaded an air gap bundle but are performing an online installation.")
logrus.Infof("To do an air gap installation, pass the air gap bundle with --airgap-bundle.")
if !prompts.New().Confirm("Do you want to proceed with an online installation?", false) {
return ErrNothingElseToAdd
}
}

metrics.ReportApplyStarted(c)
logrus.Debugf("configuring network manager")
if err := configureNetworkManager(c, provider); err != nil {
Expand Down
11 changes: 11 additions & 0 deletions pkg/cmd/join.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import (
"github.com/replicatedhq/embedded-cluster/pkg/metrics"
"github.com/replicatedhq/embedded-cluster/pkg/netutils"
"github.com/replicatedhq/embedded-cluster/pkg/prompts"
"github.com/replicatedhq/embedded-cluster/pkg/release"
"github.com/replicatedhq/embedded-cluster/pkg/spinner"
"github.com/replicatedhq/embedded-cluster/pkg/versions"
)
Expand Down Expand Up @@ -185,6 +186,16 @@ var joinCommand = &cli.Command{
return fmt.Errorf("usage: %s join <url> <token>", binName)
}

if channelRelease, err := release.GetChannelRelease(); err != nil {
return fmt.Errorf("unable to read channel release data: %w", err)
} else if channelRelease != nil && channelRelease.Airgap && c.String("airgap-bundle") == "" && !c.Bool("no-prompt") {
logrus.Infof("You downloaded an air gap bundle but are performing an online join.")
logrus.Infof("To do an air gap join, pass the air gap bundle with --airgap-bundle.")
if !prompts.New().Confirm("Do you want to proceed with an online join?", false) {
return ErrNothingElseToAdd
}
}

logrus.Debugf("fetching join token remotely")
jcmd, err := getJoinToken(c.Context, c.Args().Get(0), c.Args().Get(1))
if err != nil {
Expand Down
10 changes: 10 additions & 0 deletions pkg/cmd/restore.go
Original file line number Diff line number Diff line change
Expand Up @@ -959,6 +959,16 @@ func restoreCommand() *cli.Command {
return fmt.Errorf("unable to write runtime config: %w", err)
}

if channelRelease, err := release.GetChannelRelease(); err != nil {
return fmt.Errorf("unable to read channel release data: %w", err)
} else if channelRelease != nil && channelRelease.Airgap && c.String("airgap-bundle") == "" && !c.Bool("no-prompt") {
logrus.Infof("You downloaded an air gap bundle but are performing an online restore.")
logrus.Infof("To do an air gap restore, pass the air gap bundle with --airgap-bundle.")
if !prompts.New().Confirm("Do you want to proceed with an online restore?", false) {
return ErrNothingElseToAdd
}
}

proxy, err := getProxySpecFromFlags(c)
if err != nil {
return fmt.Errorf("unable to get proxy spec from flags: %w", err)
Expand Down
1 change: 1 addition & 0 deletions pkg/release/release.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ type ChannelRelease struct {
ChannelID string `yaml:"channelID"`
ChannelSlug string `yaml:"channelSlug"`
AppSlug string `yaml:"appSlug"`
Airgap bool `yaml:"airgap"`
}

// GetChannelRelease reads the embedded channel release object. If no channel release
Expand Down

0 comments on commit 255f9dc

Please sign in to comment.