cmd: don't set remotesourcecreate api-url flag as required

check it later since for github it could not be provided and will default to
"https://api.github.com"
This commit is contained in:
Simone Gotti 2019-07-05 10:16:37 +02:00
parent f861e2a647
commit 9d71f32368
1 changed files with 5 additions and 4 deletions

View File

@ -55,7 +55,7 @@ func init() {
flags.StringVarP(&remoteSourceCreateOpts.name, "name", "n", "", "remotesource name")
flags.StringVar(&remoteSourceCreateOpts.rsType, "type", "", "remotesource type")
flags.StringVar(&remoteSourceCreateOpts.authType, "auth-type", "", "remote source auth type")
flags.StringVar(&remoteSourceCreateOpts.apiURL, "api-url", "", "remotesource api url")
flags.StringVar(&remoteSourceCreateOpts.apiURL, "api-url", "", `remotesource api url (when type is "github" defaults to "https://api.github.com")`)
flags.BoolVarP(&remoteSourceCreateOpts.skipVerify, "skip-verify", "", false, "skip remote source api tls certificate verification")
flags.StringVar(&remoteSourceCreateOpts.oauth2ClientID, "clientid", "", "remotesource oauth2 client id")
flags.StringVar(&remoteSourceCreateOpts.oauth2ClientSecret, "secret", "", "remotesource oauth2 secret")
@ -71,9 +71,6 @@ func init() {
if err := cmdRemoteSourceCreate.MarkFlagRequired("auth-type"); err != nil {
log.Fatal(err)
}
if err := cmdRemoteSourceCreate.MarkFlagRequired("api-url"); err != nil {
log.Fatal(err)
}
cmdRemoteSource.AddCommand(cmdRemoteSourceCreate)
}
@ -87,6 +84,10 @@ func remoteSourceCreate(cmd *cobra.Command, args []string) error {
remoteSourceCreateOpts.sshHostKey = github.GitHubSSHHostKey
}
if remoteSourceCreateOpts.apiURL == "" {
return errors.Errorf(`required flag "api-url" not set`)
}
req := &api.CreateRemoteSourceRequest{
Name: remoteSourceCreateOpts.name,
Type: remoteSourceCreateOpts.rsType,