func Config(details, defaultDetails *config.BintrayDetails, interactive bool) (*config.BintrayDetails, error) { if details == nil { details = new(config.BintrayDetails) } if interactive { if defaultDetails == nil { var err error defaultDetails, err = config.ReadBintrayConf() if err != nil { return nil, err } } if details.User == "" { ioutils.ScanFromConsole("User", &details.User, defaultDetails.User) } if details.Key == "" { print("Key: ") byteKey, err := terminal.ReadPassword(int(syscall.Stdin)) err = cliutils.CheckError(err) if err != nil { return nil, err } details.Key = string(byteKey) if details.Key == "" { details.Key = defaultDetails.Key } } if details.DefPackageLicenses == "" { ioutils.ScanFromConsole("\nDefault package licenses", &details.DefPackageLicenses, defaultDetails.DefPackageLicenses) } } config.SaveBintrayConf(details) return details, nil }
func ShowConfig() error { details, err := config.ReadBintrayConf() if err != nil { return err } if details.User != "" { fmt.Println("User: "******"" { fmt.Println("Key: ***") } if details.DefPackageLicenses != "" { fmt.Println("Default package license: " + details.DefPackageLicenses) } return nil }
func promptPackageNotExist(versionDetails *utils.VersionDetails) error { msg := "It looks like package '" + versionDetails.Package + "' does not exist in the '" + versionDetails.Repo + "' repository.\n" + "You can create the package by running the package-create command. For example:\n" + "jfrog bt pc " + versionDetails.Subject + "/" + versionDetails.Repo + "/" + versionDetails.Package + " --vcs-url=https://github.com/example" conf, err := config.ReadBintrayConf() if err != nil { return err } if conf.DefPackageLicenses == "" { msg += " --licenses=Apache-2.0-example" } err = cliutils.CheckError(errors.New(msg)) return err }
func initBintrayCredentials() { if bintrayConfig != nil { return } var err error bintrayConfig, err = config.ReadBintrayConf() if cliutils.CheckError(err) != nil { os.Exit(1) } if *tests.BtUser != "" { bintrayConfig.User = *tests.BtUser } if *tests.BtKey != "" { bintrayConfig.Key = *tests.BtKey } if bintrayConfig.User == "" || bintrayConfig.Key == "" { log.Error("To test Bintray credentials must be configured.") os.Exit(1) } apiUrl := os.Getenv("JFROG_CLI_BINTRAY_API_URL") if apiUrl == "" { apiUrl = "https://bintray.com/api/v1/" } downloadServerUrl := os.Getenv("JFROG_CLI_BINTRAY_DOWNLOAD_URL") if downloadServerUrl == "" { downloadServerUrl = "https://dl.bintray.com/" } apiUrl = cliutils.AddTrailingSlashIfNeeded(apiUrl) downloadServerUrl = cliutils.AddTrailingSlashIfNeeded(downloadServerUrl) bintrayConfig.ApiUrl = apiUrl bintrayConfig.DownloadServerUrl = downloadServerUrl }
func GetConfig() (*config.BintrayDetails, error) { return config.ReadBintrayConf() }