Skip to content

Commit

Permalink
fix: Use requirements gitServer as default for import, create env
Browse files Browse the repository at this point in the history
`opts.AddGitRepoOptionsArguments` defaults `--git-provider-url` to
`https://github.com`, no matter what the actual default should be for
the cluster. This makes sense for some of the cases where it's used
(i.e., `jx install`, `jx create cluster`, `jx create terraform`, etc),
but not for others (`jx import` (and therefore `jx create
quickstart`), `jx edit env`, and `jx create env`). In those cases, we
should default it to the `gitServer` in the team settings.

Except we don't actually set that with `jx boot`! It just stays on
`https://github.com`. So we also need to set that from the requirements.

fixes #6579

Signed-off-by: Andrew Bayer <[email protected]>
  • Loading branch information
abayer authored and jenkins-x-bot committed Jan 23, 2020
1 parent a74467a commit 4462cfd
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
2 changes: 1 addition & 1 deletion pkg/cmd/create/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@ func (options *InstallOptions) AddInstallFlags(cmd *cobra.Command, includesInit
cmd.Flags().BoolVar(&options.SkipAuthSecretsMerge, opts.OptionSkipAuthSecMerge, false, "Skips merging the secrets from local files with the secrets from Kubernetes cluster")

bindInstallConfigToFlags(cmd)
opts.AddGitRepoOptionsArguments(cmd, &options.GitRepositoryOptions)
opts.AddGitRepoOptionsArgumentsWithGithubDefault(cmd, &options.GitRepositoryOptions)
options.HelmValuesConfig.AddExposeControllerValues(cmd, true)
options.AdminSecretsService.AddAdminSecretsValues(cmd)
options.InitOptions.AddInitFlags(cmd)
Expand Down
14 changes: 12 additions & 2 deletions pkg/cmd/opts/git.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,9 +145,19 @@ func (o *CommonOptions) DiscoverGitURL(gitConf string) (string, error) {
return url, nil
}

// AddGitRepoOptionsArguments adds common git flags to the given cobra command
// AddGitRepoOptionsArgumentsWithGithubDefault adds common git flags with a default provider URL of github.com to the given cobra command
func AddGitRepoOptionsArgumentsWithGithubDefault(cmd *cobra.Command, repositoryOptions *gits.GitRepositoryOptions) {
AddGitRepoOptionsArgumentsWithDefaultProviderURL(cmd, repositoryOptions, "https://github.com")
}

// AddGitRepoOptionsArguments adds common git flags with no default provider URL to the given cobra command
func AddGitRepoOptionsArguments(cmd *cobra.Command, repositoryOptions *gits.GitRepositoryOptions) {
cmd.Flags().StringVarP(&repositoryOptions.ServerURL, "git-provider-url", "", "https://github.com", "The Git server URL to create new Git repositories inside")
AddGitRepoOptionsArgumentsWithDefaultProviderURL(cmd, repositoryOptions, "")
}

// AddGitRepoOptionsArgumentsWithDefaultProviderURL adds common git flags with the given default provider URL to the given cobra command
func AddGitRepoOptionsArgumentsWithDefaultProviderURL(cmd *cobra.Command, repositoryOptions *gits.GitRepositoryOptions, defaultProviderURL string) {
cmd.Flags().StringVarP(&repositoryOptions.ServerURL, "git-provider-url", "", defaultProviderURL, "The Git server URL to create new Git repositories inside")
cmd.Flags().StringVarP(&repositoryOptions.ServerKind, "git-provider-kind", "", "",
"Kind of Git server. If not specified, kind of server will be autodetected from Git provider URL. Possible values: bitbucketcloud, bitbucketserver, gitea, gitlab, github, fakegit")
cmd.Flags().StringVarP(&repositoryOptions.Username, "git-username", "", "", "The Git username to use for creating new Git repositories")
Expand Down
2 changes: 2 additions & 0 deletions pkg/cmd/step/verify/step_verify_environments.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,8 @@ func (o *StepVerifyEnvironmentsOptions) storeRequirementsInTeamSettings(requirem
return errors.Wrap(err, "there was a problem marshalling the requirements file to include it in the TeamSettings")
}
env.Spec.TeamSettings.BootRequirements = string(reqBytes)
// Also set the gitServer from the requirements.
env.Spec.TeamSettings.GitServer = requirements.Cluster.GitServer
return nil
})
if err != nil {
Expand Down

0 comments on commit 4462cfd

Please sign in to comment.