cmd: remotesource create don't force github defaults

Use default public github api only if no api-url is provided.
Use default public github ssh host key only if the public github api url is
provided and no ssh host key is provided.
This commit is contained in:
Simone Gotti 2020-02-10 09:52:27 +01:00
parent 3b09cfd6a6
commit 75541ad730
1 changed files with 8 additions and 2 deletions

View File

@ -83,10 +83,16 @@ func init() {
func remoteSourceCreate(cmd *cobra.Command, args []string) error { func remoteSourceCreate(cmd *cobra.Command, args []string) error {
gwclient := gwclient.NewClient(gatewayURL, token) gwclient := gwclient.NewClient(gatewayURL, token)
flags := cmd.Flags()
// for github remote source type, set defaults for github.com // for github remote source type, set defaults for github.com
if remoteSourceCreateOpts.rsType == "github" { if remoteSourceCreateOpts.rsType == "github" {
remoteSourceCreateOpts.apiURL = github.GitHubAPIURL if !flags.Changed("api-url") {
remoteSourceCreateOpts.sshHostKey = github.GitHubSSHHostKey remoteSourceCreateOpts.apiURL = github.GitHubAPIURL
}
if remoteSourceCreateOpts.apiURL == github.GitHubAPIURL && !flags.Changed("ssh-host-key") {
remoteSourceCreateOpts.sshHostKey = github.GitHubSSHHostKey
}
} }
if remoteSourceCreateOpts.apiURL == "" { if remoteSourceCreateOpts.apiURL == "" {