本文整理汇总了Golang中github.com/jfrogdev/jfrog-cli-go/utils/cliutils.IndentJson函数的典型用法代码示例。如果您正苦于以下问题:Golang IndentJson函数的具体用法?Golang IndentJson怎么用?Golang IndentJson使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了IndentJson函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: GpgSignFile
func GpgSignFile(pathDetails *utils.PathDetails, passphrase string, bintrayDetails *config.BintrayDetails) error {
if bintrayDetails.User == "" {
bintrayDetails.User = pathDetails.Subject
}
url := bintrayDetails.ApiUrl + "gpg/" + pathDetails.Subject + "/" +
pathDetails.Repo + "/" + pathDetails.Path
var data string
if passphrase != "" {
data = "{ \"passphrase\": \"" + passphrase + "\" }"
}
log.Info("GPG signing file...")
httpClientsDetails := utils.GetBintrayHttpClientDetails(bintrayDetails)
resp, body, err := ioutils.SendPost(url, []byte(data), httpClientsDetails)
if err != nil {
return err
}
if resp.StatusCode != 200 {
return cliutils.CheckError(errors.New("Bintray response: " + resp.Status + "\n" + cliutils.IndentJson(body)))
}
log.Debug("Bintray response:", resp.Status)
log.Info("GPG signed file", pathDetails.Path, ", details:")
fmt.Println(cliutils.IndentJson(body))
return nil
}
示例2: ShowVersion
func ShowVersion(versionDetails *utils.VersionDetails, bintrayDetails *config.BintrayDetails) error {
if bintrayDetails.User == "" {
bintrayDetails.User = versionDetails.Subject
}
version := versionDetails.Version
if versionDetails.Version == "" {
versionDetails.Version = "_latest"
version = "latest"
}
url := bintrayDetails.ApiUrl + "packages/" + versionDetails.Subject + "/" +
versionDetails.Repo + "/" + versionDetails.Package + "/versions/" + versionDetails.Version
log.Info("Getting version details...")
httpClientsDetails := utils.GetBintrayHttpClientDetails(bintrayDetails)
resp, body, _, _ := ioutils.SendGet(url, true, httpClientsDetails)
if resp.StatusCode != 200 {
return cliutils.CheckError(errors.New("Bintray response: " + resp.Status + "\n" + cliutils.IndentJson(body)))
}
log.Debug("Bintray response:", resp.Status)
log.Info("Version", version, "details:")
fmt.Println(cliutils.IndentJson(body))
return nil
}
示例3: ShowAccessKey
func ShowAccessKey(flags *AccessKeyFlags, org string) (err error) {
url := GetAccessKeyPath(flags.BintrayDetails, flags.Id, org)
httpClientsDetails := utils.GetBintrayHttpClientDetails(flags.BintrayDetails)
log.Info("Getting access key...")
resp, body, _, _ := ioutils.SendGet(url, true, httpClientsDetails)
if resp.StatusCode != 200 {
return cliutils.CheckError(errors.New("Bintray response: " + resp.Status + "\n" + cliutils.IndentJson(body)))
}
log.Debug("Bintray response:", resp.Status)
log.Info("Access keys details:")
fmt.Println(cliutils.IndentJson(body))
return
}
示例4: CreateVersion
func CreateVersion(versionDetails *utils.VersionDetails, flags *utils.VersionFlags) error {
log.Info("Creating version...")
resp, body, err := doCreateVersion(versionDetails, flags, flags.BintrayDetails)
if err != nil {
return err
}
if resp.StatusCode != 201 {
return cliutils.CheckError(errors.New("Bintray response: " + resp.Status + "\n" + cliutils.IndentJson(body)))
}
log.Debug("Bintray response:", resp.Status)
log.Info("Created version", versionDetails.Version+", details:")
fmt.Println(cliutils.IndentJson(body))
return nil
}
示例5: ShowAccessKeys
func ShowAccessKeys(bintrayDetails *config.BintrayDetails, org string) error {
path := GetAccessKeysPath(bintrayDetails, org)
httpClientsDetails := utils.GetBintrayHttpClientDetails(bintrayDetails)
log.Info("Getting access keys...")
resp, body, _, _ := ioutils.SendGet(path, true, httpClientsDetails)
if resp.StatusCode != 200 {
return cliutils.CheckError(errors.New("Bintray response: " + resp.Status + "\n" + cliutils.IndentJson(body)))
}
log.Debug("Bintray response:", resp.Status)
log.Info("Access keys details:")
fmt.Println(cliutils.IndentJson(body))
return nil
}
示例6: CreatePackage
func CreatePackage(packageDetails *utils.VersionDetails, flags *utils.PackageFlags) error {
log.Info("Creating package...")
resp, body, err := DoCreatePackage(packageDetails, flags)
if err != nil {
return err
}
if resp.StatusCode != 201 {
return cliutils.CheckError(errors.New("Bintray response: " + resp.Status + "\n" + cliutils.IndentJson(body)))
}
log.Debug("Bintray response:", resp.Status)
log.Info("Created package", packageDetails.Package+", details:")
fmt.Println(cliutils.IndentJson(body))
return nil
}
示例7: moveFile
func moveFile(sourcePath, destPath string, flags *MoveFlags, moveType MoveType) (bool, error) {
message := moveMsgs[moveType].MovingMsg + " artifact: " + sourcePath + " to: " + destPath
if flags.DryRun == true {
log.Info("[Dry run] ", message)
return true, nil
}
log.Info(message)
moveUrl := flags.ArtDetails.Url
restApi := "api/" + string(moveType) + "/" + sourcePath
requestFullUrl, err := BuildArtifactoryUrl(moveUrl, restApi, map[string]string{"to": destPath})
if err != nil {
return false, err
}
httpClientsDetails := GetArtifactoryHttpClientDetails(flags.ArtDetails)
resp, body, err := ioutils.SendPost(requestFullUrl, nil, httpClientsDetails)
if err != nil {
return false, err
}
if resp.StatusCode != 200 {
log.Error("Artifactory response: " + resp.Status + "\n" + cliutils.IndentJson(body))
}
log.Debug("Artifactory response:", resp.Status)
return resp.StatusCode == 200, nil
}
示例8: searchCmd
func searchCmd(c *cli.Context) {
if c.NArg() > 0 && c.IsSet("spec") {
cliutils.Exit(cliutils.ExitCodeError, "No arguments should be sent when the spec option is used. "+cliutils.GetDocumentationMessage())
}
if !(c.NArg() == 1 || (c.NArg() == 0 && c.IsSet("spec"))) {
cliutils.Exit(cliutils.ExitCodeError, "Wrong number of arguments. "+cliutils.GetDocumentationMessage())
}
var searchSpec *utils.SpecFiles
if c.IsSet("spec") {
var err error
searchSpec, err = getSearchSpec(c)
cliutils.ExitOnErr(err)
} else {
searchSpec = createDefaultSearchSpec(c)
}
flags, err := createSearchFlags(c)
cliutils.ExitOnErr(err)
SearchResult, err := commands.Search(searchSpec, flags)
cliutils.ExitOnErr(err)
result, err := json.Marshal(SearchResult)
cliutils.ExitOnErr(err)
fmt.Println(string(cliutils.IndentJson(result)))
}
示例9: BuildPublish
func BuildPublish(buildName, buildNumber string, flags *utils.BuildInfoFlags) error {
err := utils.PreCommandSetup(flags)
if err != nil {
return err
}
buildData, err := utils.ReadBuildInfoFiles(buildName, buildNumber)
if err != nil {
return err
}
if len(buildData) == 0 {
return cliutils.CheckError(fmt.Errorf("Can't find any files related to build name: %q, number: %q", buildName, buildNumber))
}
sort.Sort(buildData)
buildInfo := createNewBuildInfo()
buildInfo.Name = buildName
buildInfo.Number = buildNumber
buildGeneralDetails, err := utils.ReadBuildInfoGeneralDetails(buildName, buildNumber)
if err != nil {
return err
}
buildInfo.Started = buildGeneralDetails.Timestamp.Format("2006-01-02T15:04:05.000-0700")
artifactsSet, dependenciesSet, env, err := prepareBuildInfoData(buildData, createIncludeFilter(flags), createExcludeFilter(flags))
if err != nil {
return err
}
if len(env) != 0 {
buildInfo.Propertires = env
}
module := createModule(buildName, artifactsSet, dependenciesSet)
buildInfo.Modules = append(buildInfo.Modules, module)
marshaledBuildInfo, err := json.Marshal(buildInfo)
if cliutils.CheckError(err) != nil {
return err
}
if flags.IsDryRun() {
fmt.Println(cliutils.IndentJson(marshaledBuildInfo))
return nil
}
httpClientsDetails := utils.GetArtifactoryHttpClientDetails(flags.ArtDetails)
utils.SetContentType("application/vnd.org.jfrog.artifactory+json", &httpClientsDetails.Headers)
log.Info("Deploying build info...")
resp, body, err := utils.PublishBuildInfo(flags.ArtDetails.Url, marshaledBuildInfo, httpClientsDetails)
if err != nil {
return err
}
if resp.StatusCode != 204 {
return cliutils.CheckError(errors.New("Artifactory response: " + resp.Status + "\n" + cliutils.IndentJson(body)))
}
log.Debug("Artifactory response:", resp.Status)
log.Info("Build info successfully deployed. Browse it in Artifactory under " + flags.ArtDetails.Url + "webapp/builds/" + buildName + "/" + buildNumber)
if err = utils.RemoveBuildDir(buildName, buildNumber); err != nil {
return err
}
return nil
}
示例10: UpdateAccessKey
func UpdateAccessKey(flags *AccessKeyFlags, org string) error {
data := BuildAccessKeyJson(flags, false)
url := GetAccessKeyPath(flags.BintrayDetails, flags.Id, org)
httpClientsDetails := utils.GetBintrayHttpClientDetails(flags.BintrayDetails)
log.Info("Updating access key...")
resp, body, err := ioutils.SendPatch(url, []byte(data), httpClientsDetails)
if err != nil {
return err
}
if resp.StatusCode != 200 {
return cliutils.CheckError(errors.New("Bintray response: " + resp.Status + "\n" + cliutils.IndentJson(body)))
}
log.Debug("Bintray response:", resp.Status)
log.Info("Updated access key, details:")
fmt.Println(cliutils.IndentJson(body))
return nil
}
示例11: LogsList
func LogsList(packageDetails *utils.VersionDetails, details *config.BintrayDetails) error {
if details.User == "" {
details.User = packageDetails.Subject
}
path := details.ApiUrl + "packages/" + packageDetails.Subject + "/" +
packageDetails.Repo + "/" + packageDetails.Package + "/logs/"
httpClientsDetails := utils.GetBintrayHttpClientDetails(details)
log.Info("Getting logs...")
resp, body, _, _ := ioutils.SendGet(path, true, httpClientsDetails)
if resp.StatusCode != 200 {
return cliutils.CheckError(errors.New("Bintray response: " + resp.Status + "\n" + cliutils.IndentJson(body)))
}
log.Debug("Bintray response:", resp.Status)
log.Info("Log details:")
fmt.Println(cliutils.IndentJson(body))
return nil
}
示例12: ShowPackage
func ShowPackage(packageDetails *utils.VersionDetails, bintrayDetails *config.BintrayDetails) (err error) {
if bintrayDetails.User == "" {
bintrayDetails.User = packageDetails.Subject
}
url := bintrayDetails.ApiUrl + "packages/" + packageDetails.Subject + "/" +
packageDetails.Repo + "/" + packageDetails.Package
log.Info("Getting package details...")
httpClientsDetails := utils.GetBintrayHttpClientDetails(bintrayDetails)
resp, body, _, _ := ioutils.SendGet(url, true, httpClientsDetails)
if resp.StatusCode != 200 {
return cliutils.CheckError(errors.New("Bintray response: " + resp.Status + "\n" + cliutils.IndentJson(body)))
}
log.Debug("Bintray response:", resp.Status)
log.Info("Package", packageDetails.Package, "details:")
fmt.Println(cliutils.IndentJson(body))
return
}
示例13: ShowEntitlement
func ShowEntitlement(flags *EntitlementFlags, details *utils.VersionDetails) error {
url := BuildEntitlementUrl(flags.BintrayDetails, details, flags.Id)
if flags.BintrayDetails.User == "" {
flags.BintrayDetails.User = details.Subject
}
httpClientsDetails := utils.GetBintrayHttpClientDetails(flags.BintrayDetails)
log.Info("Getting entitlement...")
resp, body, _, err := ioutils.SendGet(url, true, httpClientsDetails)
if err != nil {
return err
}
if resp.StatusCode != 200 {
return cliutils.CheckError(errors.New("Bintray response: " + resp.Status + "\n" + cliutils.IndentJson(body)))
}
log.Debug("Bintray response:", resp.Status)
log.Info("Entitlement details:")
fmt.Println(cliutils.IndentJson(body))
return nil
}
示例14: UpdateEntitlement
func UpdateEntitlement(flags *EntitlementFlags, details *utils.VersionDetails) error {
path := BuildEntitlementUrl(flags.BintrayDetails, details, flags.Id)
if flags.BintrayDetails.User == "" {
flags.BintrayDetails.User = details.Subject
}
data := buildEntitlementJson(flags, true)
httpClientsDetails := utils.GetBintrayHttpClientDetails(flags.BintrayDetails)
log.Info("Updating entitlement...")
resp, body, err := ioutils.SendPatch(path, []byte(data), httpClientsDetails)
if err != nil {
return err
}
if resp.StatusCode != 200 {
return cliutils.CheckError(errors.New("Bintray response: " + resp.Status + "\n" + cliutils.IndentJson(body)))
}
log.Debug("Bintray response:", resp.Status)
log.Info("Updated entitlement, details:")
fmt.Println(cliutils.IndentJson(body))
return err
}
示例15: PublishVersion
func PublishVersion(versionDetails *utils.VersionDetails, bintrayDetails *config.BintrayDetails) error {
if bintrayDetails.User == "" {
bintrayDetails.User = versionDetails.Subject
}
url := bintrayDetails.ApiUrl + "content/" + versionDetails.Subject + "/" +
versionDetails.Repo + "/" + versionDetails.Package + "/" +
versionDetails.Version + "/publish"
log.Info("Publishing version...")
httpClientsDetails := utils.GetBintrayHttpClientDetails(bintrayDetails)
resp, body, err := ioutils.SendPost(url, nil, httpClientsDetails)
if err != nil {
return err
}
if resp.StatusCode != 200 {
return cliutils.CheckError(errors.New("Bintray response: " + resp.Status + "\n" + cliutils.IndentJson(body)))
}
log.Debug("Bintray response:", resp.Status)
log.Info("Published version", versionDetails.Version+", details:")
fmt.Println(cliutils.IndentJson(body))
return nil
}