當前位置: 首頁>>代碼示例>>Golang>>正文


Golang cliutils.IndentJson函數代碼示例

本文整理匯總了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
}
開發者ID:JFrogDev,項目名稱:jfrog-cli-go,代碼行數:27,代碼來源:gpgsignfile.go

示例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
}
開發者ID:JFrogDev,項目名稱:jfrog-cli-go,代碼行數:26,代碼來源:versionshow.go

示例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
}
開發者ID:JFrogDev,項目名稱:jfrog-cli-go,代碼行數:14,代碼來源:accesskeys.go

示例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
}
開發者ID:JFrogDev,項目名稱:jfrog-cli-go,代碼行數:14,代碼來源:versioncreate.go

示例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
}
開發者ID:JFrogDev,項目名稱:jfrog-cli-go,代碼行數:14,代碼來源:accesskeys.go

示例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
}
開發者ID:JFrogDev,項目名稱:jfrog-cli-go,代碼行數:15,代碼來源:packagecreate.go

示例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
}
開發者ID:JFrogDev,項目名稱:jfrog-cli-go,代碼行數:28,代碼來源:moveutils.go

示例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)))
}
開發者ID:JFrogDev,項目名稱:jfrog-cli-go,代碼行數:26,代碼來源:cli.go

示例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
}
開發者ID:JFrogDev,項目名稱:jfrog-cli-go,代碼行數:58,代碼來源:buildpublish.go

示例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
}
開發者ID:JFrogDev,項目名稱:jfrog-cli-go,代碼行數:18,代碼來源:accesskeys.go

示例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
}
開發者ID:JFrogDev,項目名稱:jfrog-cli-go,代碼行數:19,代碼來源:logs.go

示例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
}
開發者ID:JFrogDev,項目名稱:jfrog-cli-go,代碼行數:19,代碼來源:packageshow.go

示例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
}
開發者ID:JFrogDev,項目名稱:jfrog-cli-go,代碼行數:20,代碼來源:show.go

示例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
}
開發者ID:JFrogDev,項目名稱:jfrog-cli-go,代碼行數:21,代碼來源:update.go

示例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
}
開發者ID:JFrogDev,項目名稱:jfrog-cli-go,代碼行數:23,代碼來源:versionpublish.go


注:本文中的github.com/jfrogdev/jfrog-cli-go/utils/cliutils.IndentJson函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。