本文整理汇总了Golang中github.com/jfrogdev/jfrog-cli-go/utils/cliutils/log.Debug函数的典型用法代码示例。如果您正苦于以下问题:Golang Debug函数的具体用法?Golang Debug怎么用?Golang Debug使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Debug函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: parseStream
func (sm *StreamManager) parseStream(streamDecoder *json.Decoder, streamEncoder *json.Encoder) error {
for {
var decodedJson map[string]interface{}
if e := streamDecoder.Decode(&decodedJson); e != nil {
log.Debug(e)
return e
}
if _, ok := sm.IncludeFilter[decodedJson["type"].(string)]; ok || len(sm.IncludeFilter) == 0 {
if e := streamEncoder.Encode(&decodedJson); e != nil {
log.Debug(e)
return e
}
}
}
}
示例2: downloadFile
func downloadFile(downloadFileDetails *DownloadFileDetails, logMsgPrefix string, flags *DownloadFlags) error {
httpClientsDetails := utils.GetArtifactoryHttpClientDetails(flags.ArtDetails)
bulkDownload := flags.SplitCount == 0 || flags.MinSplitSize < 0 || flags.MinSplitSize*1000 > downloadFileDetails.Size
if !bulkDownload {
acceptRange, err := isFileAcceptRange(downloadFileDetails, flags)
if err != nil {
return err
}
bulkDownload = !acceptRange
}
if bulkDownload {
resp, err := ioutils.DownloadFile(downloadFileDetails.DownloadPath, downloadFileDetails.LocalPath, downloadFileDetails.LocalFileName, httpClientsDetails)
if err != nil {
return err
}
log.Debug(logMsgPrefix, "Artifactory response:", resp.Status)
} else {
concurrentDownloadFlags := ioutils.ConcurrentDownloadFlags{
DownloadPath: downloadFileDetails.DownloadPath,
FileName: downloadFileDetails.LocalFileName,
LocalPath: downloadFileDetails.LocalPath,
FileSize: downloadFileDetails.Size,
SplitCount: flags.SplitCount}
ioutils.DownloadFileConcurrently(concurrentDownloadFlags, logMsgPrefix, httpClientsDetails)
}
return nil
}
示例3: 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
}
示例4: 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
}
示例5: 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
}
示例6: DeleteFiles
func DeleteFiles(resultItems []utils.AqlSearchResultItem, flags *DeleteFlags) error {
for _, v := range resultItems {
fileUrl, err := utils.BuildArtifactoryUrl(flags.ArtDetails.Url, v.GetFullUrl(), make(map[string]string))
if err != nil {
return err
}
if flags.DryRun {
log.Info("[Dry run] Deleting:", v.GetFullUrl())
continue
}
log.Info("Deleting:", v.GetFullUrl())
httpClientsDetails := utils.GetArtifactoryHttpClientDetails(flags.ArtDetails)
resp, body, err := ioutils.SendDelete(fileUrl, nil, 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)
}
return nil
}
示例7: AqlSearch
func AqlSearch(aqlQuery string, flags AqlSearchFlag) ([]AqlSearchResultItem, error) {
aqlUrl := flags.GetArtifactoryDetails().Url + "api/search/aql"
log.Debug("Searching Artifactory using AQL query:", aqlQuery)
httpClientsDetails := GetArtifactoryHttpClientDetails(flags.GetArtifactoryDetails())
resp, json, err := ioutils.SendPost(aqlUrl, []byte(aqlQuery), httpClientsDetails)
if err != nil {
return nil, err
}
if resp.StatusCode != 200 {
return nil, cliutils.CheckError(errors.New("Artifactory response: " + resp.Status + "\n" + cliutils.IndentJson(json)))
}
log.Debug("Artifactory response: ", resp.Status)
resultItems, err := parseAqlSearchResponse(json)
return resultItems, err
}
示例8: 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
}
示例9: BuildDistribute
func BuildDistribute(buildName, buildNumber, targetRepo string, flags *BuildDistributionFlags) error {
err := utils.PreCommandSetup(flags)
if err != nil {
return err
}
dryRun := ""
if flags.DryRun == true {
dryRun = "[Dry run] "
}
message := "Destributing build..."
log.Info(dryRun + message)
distributeUrl := flags.ArtDetails.Url
restApi := path.Join("api/build/distribute/", buildName, buildNumber)
requestFullUrl, err := utils.BuildArtifactoryUrl(distributeUrl, restApi, make(map[string]string))
if err != nil {
return err
}
data := BuildDistributionConfig{
SourceRepos: strings.Split(flags.SourceRepos, ","),
TargetRepo: targetRepo,
Publish: flags.Publish,
OverrideExistingFiles: flags.OverrideExistingFiles,
GpgPassphrase: flags.GpgPassphrase,
Async: flags.Async,
DryRun: flags.DryRun}
requestContent, err := json.Marshal(data)
if err != nil {
return cliutils.CheckError(errors.New("Failed to execute request. " + cliutils.GetDocumentationMessage()))
}
httpClientsDetails := utils.GetArtifactoryHttpClientDetails(flags.ArtDetails)
utils.SetContentType("application/json", &httpClientsDetails.Headers)
resp, body, err := ioutils.SendPost(requestFullUrl, requestContent, httpClientsDetails)
if err != nil {
return err
}
if resp.StatusCode != 200 {
return cliutils.CheckError(errors.New("Artifactory response: " + resp.Status + "\n" + cliutils.IndentJson(body)))
}
log.Debug("Artifactory response:", resp.Status)
if flags.Async && !flags.DryRun {
log.Info("Asynchronously distributed build", buildName, "#"+buildNumber, "to:", targetRepo, "repository, logs are avalable in Artifactory.")
return nil
}
log.Info(dryRun+"Distributed build", buildName, "#"+buildNumber, "to:", targetRepo, "repository.")
return nil
}
示例10: downloadAqlResult
func downloadAqlResult(dependecies []DownloadData, flags *DownloadFlags) (buildDependencies [][]utils.DependenciesBuildInfo, err error) {
size := len(dependecies)
buildDependencies = make([][]utils.DependenciesBuildInfo, flags.Threads)
var wg sync.WaitGroup
for i := 0; i < flags.Threads; i++ {
wg.Add(1)
go func(threadId int) {
logMsgPrefix := cliutils.GetLogMsgPrefix(threadId, flags.DryRun)
for j := threadId; j < size && err == nil; j += flags.Threads {
downloadPath, e := utils.BuildArtifactoryUrl(flags.ArtDetails.Url, dependecies[j].Dependency.GetFullUrl(), make(map[string]string))
if e != nil {
err = e
break
}
log.Info(logMsgPrefix+"Downloading", dependecies[j].Dependency.GetFullUrl())
if flags.DryRun {
continue
}
regexpPattern := cliutils.PathToRegExp(dependecies[j].DownloadPath)
placeHolderTarget, e := cliutils.ReformatRegexp(regexpPattern, dependecies[j].Dependency.GetFullUrl(), dependecies[j].Target)
if e != nil {
err = e
break
}
localPath, localFileName := ioutils.GetLocalPathAndFile(dependecies[j].Dependency.Name, dependecies[j].Dependency.Path, placeHolderTarget, dependecies[j].Flat)
shouldDownload, e := shouldDownloadFile(path.Join(localPath, dependecies[j].Dependency.Name), dependecies[j].Dependency.Actual_Md5, dependecies[j].Dependency.Actual_Sha1)
if e != nil {
err = e
break
}
dependency := createBuildDependencyItem(dependecies[j].Dependency)
if !shouldDownload {
buildDependencies[threadId] = append(buildDependencies[threadId], dependency)
log.Debug(logMsgPrefix, "File already exists locally.")
continue
}
downloadFileDetails := createDownloadFileDetails(downloadPath, localPath, localFileName, nil, dependecies[j].Dependency.Size)
e = downloadFile(downloadFileDetails, logMsgPrefix, flags)
if e != nil {
err = e
break
}
buildDependencies[threadId] = append(buildDependencies[threadId], dependency)
}
wg.Done()
}(i)
}
wg.Wait()
logDownloadTotals(buildDependencies)
return
}
示例11: 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
}
示例12: 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
}
示例13: 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
}
示例14: 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
}
示例15: handleStream
func (sm *StreamManager) handleStream(ioReader io.Reader, writer io.Writer, lastServerInteraction *time.Time) {
bodyReader := bufio.NewReader(ioReader)
pReader, pWriter := io.Pipe()
defer pWriter.Close()
go func() {
defer pReader.Close()
for {
line, _, err := bodyReader.ReadLine()
if err != nil {
log.Debug(err)
break
}
*lastServerInteraction = time.Now()
_, err = pWriter.Write(line)
if err != nil {
log.Debug(err)
break
}
}
}()
streamDecoder := json.NewDecoder(pReader)
streamEncoder := json.NewEncoder(writer)
sm.parseStream(streamDecoder, streamEncoder)
}