From 75541ad730b536d12418ea436ec06f85610718eb Mon Sep 17 00:00:00 2001 From: Simone Gotti Date: Mon, 10 Feb 2020 09:52:27 +0100 Subject: [PATCH] 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. --- cmd/agola/cmd/remotesourcecreate.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/cmd/agola/cmd/remotesourcecreate.go b/cmd/agola/cmd/remotesourcecreate.go index d18e3bb..f68f0fc 100644 --- a/cmd/agola/cmd/remotesourcecreate.go +++ b/cmd/agola/cmd/remotesourcecreate.go @@ -83,10 +83,16 @@ func init() { func remoteSourceCreate(cmd *cobra.Command, args []string) error { gwclient := gwclient.NewClient(gatewayURL, token) + flags := cmd.Flags() + // for github remote source type, set defaults for github.com if remoteSourceCreateOpts.rsType == "github" { - remoteSourceCreateOpts.apiURL = github.GitHubAPIURL - remoteSourceCreateOpts.sshHostKey = github.GitHubSSHHostKey + if !flags.Changed("api-url") { + remoteSourceCreateOpts.apiURL = github.GitHubAPIURL + } + if remoteSourceCreateOpts.apiURL == github.GitHubAPIURL && !flags.Changed("ssh-host-key") { + remoteSourceCreateOpts.sshHostKey = github.GitHubSSHHostKey + } } if remoteSourceCreateOpts.apiURL == "" {