func AddCommentToBug()

in entryMaker/bugs/bugs.go [144:173]


func AddCommentToBug(bugNum int, conf *config.OneCRLConfig, comment string) error {
	commentUrl := fmt.Sprintf("%s/rest/bug/%d", conf.BugzillaBase, bugNum)
	commentObject := Comment{}
	commentObject.ApiKey = conf.BugzillaAPIKey
	commentObject.Comment.Body = comment
	commentObject.Comment.IsPrivate = false
	commentObject.Comment.IsMarkdown = false

	if "yes" == conf.OneCRLVerbose {
		fmt.Printf("Attempting to marshal %v\n", commentObject)
	}

	commentMarshalled, err := json.Marshal(commentObject)
	if "yes" == conf.OneCRLVerbose {
		fmt.Printf("PUTing %s to %s\n", commentMarshalled, commentUrl)
	}

	commentReq, err := http.NewRequest("PUT", commentUrl, bytes.NewBuffer(commentMarshalled))
	commentReq.Header.Set("Content-Type", "application/json")
	commentReq.Header.Set("User-Agent", userAgent)
	commentClient := &http.Client{}
	commentResp, err := commentClient.Do(commentReq)
	if err != nil {
		return err
	}
	if "yes" == conf.OneCRLVerbose {
		fmt.Printf("comment response %v\n", commentResp)
	}
	return nil
}