本文整理汇总了Golang中github.com/jfrogdev/jfrog-cli-go/utils/cliutils.IndentJson函数的典型用法代码示例。如果您正苦于以下问题:Golang IndentJson函数的具体用法?Golang IndentJson怎么用?Golang IndentJson使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了IndentJson函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: SignVersion
func SignVersion(urlSigningDetails *utils.PathDetails, flags *UrlSigningFlags) error {
if flags.BintrayDetails.User == "" {
flags.BintrayDetails.User = urlSigningDetails.Subject
}
path := urlSigningDetails.Subject + "/" + urlSigningDetails.Repo + "/" + urlSigningDetails.Path
url := flags.BintrayDetails.ApiUrl + "signed_url/" + path
data := builJson(flags)
log.Info("Signing URL...")
httpClientsDetails := utils.GetBintrayHttpClientDetails(flags.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("Signed URL", path+", details:")
fmt.Println(cliutils.IndentJson(body))
return nil
}
开发者ID:JFrogDev,项目名称:jfrog-cli-go,代码行数:24,代码来源:urlsign.go
示例17: DeleteAccessKey
func DeleteAccessKey(flags *AccessKeyFlags, org string) error {
url := GetAccessKeyPath(flags.BintrayDetails, flags.Id, org)
httpClientsDetails := utils.GetBintrayHttpClientDetails(flags.BintrayDetails)
log.Info("Deleting access key...")
resp, body, err := ioutils.SendDelete(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("Deleted access key.")
return nil
}
开发者ID:JFrogDev,项目名称:jfrog-cli-go,代码行数:16,代码来源:accesskeys.go
示例18: uploadFile
func uploadFile(artifact cliutils.Artifact, url, logMsgPrefix string, bintrayDetails *config.BintrayDetails) (bool, error) {
log.Info(logMsgPrefix+"Uploading artifact:", artifact.LocalPath)
f, err := os.Open(artifact.LocalPath)
err = cliutils.CheckError(err)
if err != nil {
return false, err
}
defer f.Close()
httpClientsDetails := utils.GetBintrayHttpClientDetails(bintrayDetails)
resp, body, err := ioutils.UploadFile(f, url, httpClientsDetails)
if err != nil {
return false, err
}
log.Debug(logMsgPrefix+"Bintray response:", resp.Status)
if resp.StatusCode != 201 && resp.StatusCode != 200 {
log.Error(logMsgPrefix + "Bintray response: " + resp.Status + "\n" + cliutils.IndentJson(body))
}
return resp.StatusCode == 201 || resp.StatusCode == 200, nil
}
开发者ID:JFrogDev,项目名称:jfrog-cli-go,代码行数:21,代码来源:upload.go
示例19: DeleteVersion
func DeleteVersion(versionDetails *utils.VersionDetails, bintrayDetails *config.BintrayDetails) error {
if bintrayDetails.User == "" {
bintrayDetails.User = versionDetails.Subject
}
url := bintrayDetails.ApiUrl + "packages/" + versionDetails.Subject + "/" +
versionDetails.Repo + "/" + versionDetails.Package + "/versions/" + versionDetails.Version
log.Info("Deleting version...")
httpClientsDetails := utils.GetBintrayHttpClientDetails(bintrayDetails)
resp, body, err := ioutils.SendDelete(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("Deleted version", versionDetails.Version+".")
return nil
}
开发者ID:JFrogDev,项目名称:jfrog-cli-go,代码行数:21,代码来源:versiondelete.go
示例20: createVersionIfNeeded
func createVersionIfNeeded(versionDetails *utils.VersionDetails, uploadFlags *UploadFlags) error {
log.Info("Verifying version", versionDetails.Version, "exists...")
resp, err := utils.HeadVersion(versionDetails, uploadFlags.BintrayDetails)
if err != nil {
return err
}
if resp.StatusCode == 404 {
log.Info("Creating version...")
resp, body, err := DoCreateVersion(versionDetails, uploadFlags.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+".")
} else if resp.StatusCode != 200 {
err = cliutils.CheckError(errors.New("Bintray response: " + resp.Status))
}
return err
}
开发者ID:JFrogDev,项目名称:jfrog-cli-go,代码行数:22,代码来源:upload.go
注:本文中的github.com/jfrogdev/jfrog-cli-go/utils/cliutils.IndentJson函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论