예제 #1
0
func createBintrayDetails(c *cli.Context, includeConfig bool) (*config.BintrayDetails, error) {
	if includeConfig {
		bintrayDetails, err := offerConfig(c)
		if err != nil {
			return nil, err
		}
		if bintrayDetails != nil {
			return bintrayDetails, nil
		}
	}
	user := c.String("user")
	key := c.String("key")
	defaultPackageLicenses := c.String("licenses")
	if includeConfig && (user == "" || key == "" || defaultPackageLicenses == "") {
		confDetails, err := commands.GetConfig()
		if err != nil {
			return nil, err
		}
		if user == "" {
			user = confDetails.User
		}
		if key == "" {
			key = confDetails.Key
		}
		if key == "" {
			cliutils.Exit(cliutils.ExitCodeError, "Please set your Bintray API key using the config command or send it as the --key option.")
		}
		if defaultPackageLicenses == "" {
			defaultPackageLicenses = confDetails.DefPackageLicenses
		}
	}
	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)
	return &config.BintrayDetails{
		ApiUrl:             apiUrl,
		DownloadServerUrl:  downloadServerUrl,
		User:               user,
		Key:                key,
		DefPackageLicenses: defaultPackageLicenses}, nil
}
예제 #2
0
func createPackageFlags(c *cli.Context) (*utils.PackageFlags, error) {
	var publicDownloadNumbers string
	var publicStats string
	if c.String("pub-dn") != "" {
		publicDownloadNumbers = c.String("pub-dn")
		publicDownloadNumbers = strings.ToLower(publicDownloadNumbers)
		if publicDownloadNumbers != "true" && publicDownloadNumbers != "false" {
			cliutils.Exit(cliutils.ExitCodeError, "The --pub-dn option should have a boolean value.")
		}
	}
	if c.String("pub-stats") != "" {
		publicStats = c.String("pub-stats")
		publicStats = strings.ToLower(publicStats)
		if publicStats != "true" && publicStats != "false" {
			cliutils.Exit(cliutils.ExitCodeError, "The --pub-stats option should have a boolean value.")
		}
	}
	licenses := c.String("licenses")
	if licenses == "" {
		confDetails, err := commands.GetConfig()
		if err != nil {
			return nil, err
		}
		licenses = confDetails.DefPackageLicenses
	}
	details, err := createBintrayDetails(c, true)
	if err != nil {
		return nil, err
	}
	return &utils.PackageFlags{
		BintrayDetails:         details,
		Desc:                   c.String("desc"),
		Labels:                 c.String("labels"),
		Licenses:               licenses,
		CustomLicenses:         c.String("cust-licenses"),
		VcsUrl:                 c.String("vcs-url"),
		WebsiteUrl:             c.String("website-url"),
		IssueTrackerUrl:        c.String("issuetracker-url"),
		GithubRepo:             c.String("github-repo"),
		GithubReleaseNotesFile: c.String("github-rel-notes"),
		PublicDownloadNumbers:  publicDownloadNumbers,
		PublicStats:            publicStats}, nil
}