Skip to content

Commit

Permalink
Change wizard's questions, defaults
Browse files Browse the repository at this point in the history
This removes a few of the questions.

I removed the path, because I couldn't decide which path it should
be - cluster, "current", or workload? If you change it, what happens
to all the other ones, do they adjust "automatically" or not?

For ssh-hostname and token-auth, it just looked like extra work to
figure out how it works.

For teams, I'm unsure how to test them, so leaving that as out of scope.

On the other hand, it does add a question for your PAT. Because if we
don't ask for a PAT, then flux will, and I don't want it to, so now we
ask for it.

Meanwhile, for defaults, I've added defaults everywhere, and removed
the old isRequired because everything we ask is really required.

For defaults, I've made the code highly opportunistic - if it guesses
wrong, that's OK, you can just change it, so let's guess
everything. As a result, I've removed any text that mentions the
default - the default is now whatever we guessed.

For booleans, you almost by definition have a default (because the
absence of it being true means it's false) - I'm sure my defaults
aren't the best ones, but that's OK, because you can change them (for
what it's worth, "private" only affects repository creation, so it's
only if it's a brand new repo that's important).
  • Loading branch information
Robin Sonefors committed Oct 12, 2022
1 parent 81eabfa commit ab18697
Show file tree
Hide file tree
Showing 3 changed files with 121 additions and 146 deletions.
27 changes: 4 additions & 23 deletions cmd/gitops/beta/run/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -583,27 +583,10 @@ func runCommandWithoutSession(cmd *cobra.Command, args []string) error {
// run the bootstrap wizard
log.Actionf("Starting bootstrap wizard ...")

log.Waitingf("Press Ctrl+C to stop bootstrap wizard ...")

remoteURL, err := bootstrap.ParseRemoteURL(repo)
if err != nil {
log.Failuref("Error parsing remote URL: %v", err.Error())
}

var gitProvider bootstrap.GitProvider

if remoteURL == "" {
gitProvider, err = bootstrap.SelectGitProvider(log)
if err != nil {
log.Failuref("Error selecting git provider: %v", err.Error())
}
} else {
urlParts := bootstrap.GetURLParts(remoteURL)
host := bootstrap.GetHost(repo)
gitProvider := bootstrap.ParseGitProvider(host)

if len(urlParts) > 0 {
gitProvider = bootstrap.ParseGitProvider(urlParts[0])
}
}
log.Waitingf("Press Ctrl+C to stop bootstrap wizard ...")

if gitProvider == bootstrap.GitProviderUnknown {
gitProvider, err = bootstrap.SelectGitProvider(log)
Expand All @@ -612,10 +595,8 @@ func runCommandWithoutSession(cmd *cobra.Command, args []string) error {
}
}

path := filepath.Join(paths.TargetDir, "clusters", "my-cluster")
path = "./" + path
wizard, err := bootstrap.NewBootstrapWizard(log, gitProvider, repo)

wizard, err := bootstrap.NewBootstrapWizard(log, remoteURL, gitProvider, repo, path)
if err != nil {
return fmt.Errorf("error creating bootstrap wizard: %v", err.Error())
}
Expand Down
Loading

0 comments on commit ab18697

Please sign in to comment.