예제 #1
0
func buildEntitlementJson(flags *EntitlementFlags, create bool) string {
	m := map[string]string{
		"access":        flags.Access,
		"download_keys": cliutils.BuildListString(flags.Keys),
		"path":          flags.Path,
	}
	return cliutils.MapToJson(m)
}
예제 #2
0
func CreatePackageJson(packageName string, flags *PackageFlags) string {
	m := map[string]string{
		"name":                      packageName,
		"desc":                      flags.Desc,
		"labels":                    cliutils.BuildListString(flags.Labels),
		"licenses":                  cliutils.BuildListString(flags.Licenses),
		"custom_licenses":           cliutils.BuildListString(flags.CustomLicenses),
		"vcs_url":                   flags.VcsUrl,
		"website_url":               flags.WebsiteUrl,
		"issue_tracker_url":         flags.IssueTrackerUrl,
		"github_repo":               flags.GithubRepo,
		"github_release_notes_file": flags.GithubReleaseNotesFile,
		"public_download_numbers":   flags.PublicDownloadNumbers,
		"public_stats":              flags.PublicStats,
	}

	return cliutils.MapToJson(m)
}
예제 #3
0
func BuildAccessKeyJson(flags *AccessKeyFlags, create bool) string {
	var existenceCheck string
	var whiteCidrs string
	var blackCidrs string
	if flags.ExistenceCheckUrl != "" {
		existenceCheck = "\"existence_check\": {" +
			"\"url\": \"" + flags.ExistenceCheckUrl + "\"," +
			"\"cache_for_secs\": \"" + strconv.Itoa(flags.ExistenceCheckCache) + "\"" +
			"}"
	}
	if flags.WhiteCidrs != "" {
		whiteCidrs = "\"white_cidrs\": " + cliutils.BuildListString(flags.WhiteCidrs)
	}
	if flags.BlackCidrs != "" {
		blackCidrs = "\"black_cidrs\": " + cliutils.BuildListString(flags.BlackCidrs)
	}
	data := "{"
	if create {
		data += "\"id\": \"" + flags.Id + "\","
	}
	if flags.Password != "" {
		data += "\"password\": \"" + flags.Password + "\","
	}
	data += "\"expiry\": \"" + flags.Expiry + "\""

	if existenceCheck != "" {
		data += "," + existenceCheck
	}
	if whiteCidrs != "" {
		data += "," + whiteCidrs
	}
	if blackCidrs != "" {
		data += "," + blackCidrs
	}
	data += "}"

	return data
}