Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

Echo response from endpoint on submission

This commit removes the Puppet reporter specific postResponse
expectation.
  • Loading branch information...
johnmccabe committed May 23, 2018
1 parent 4a93e2c commit 5c421b1748a120dbab61c4090ce8ba05f6680e9f
Showing with 4 additions and 15 deletions.
  1. +4 −15 storage/storage.go
@@ -4,13 +4,13 @@ import (
"bytes"
"encoding/json"
"fmt"
"io/ioutil"
"net/http"
"os"
"time"

"github.com/puppetlabs/lumogon/logging"
"github.com/puppetlabs/lumogon/types"
"github.com/puppetlabs/lumogon/utils"
"github.com/puppetlabs/lumogon/version"
)

@@ -88,11 +88,6 @@ func outputResult(report types.Report) error {
// storeResult stores the harvested result, posting a JSON-marshalled
// version of the report to the consumerURL.
func storeResult(report types.Report, consumerURL string) error {
var postResponse struct {
Token string
URL string
}

logging.Debug("[Storage] Storing report")
jsonStr, err := formatReport(report, false) // unindented report
if err != nil {
@@ -110,17 +105,11 @@ func storeResult(report types.Report, consumerURL string) error {
os.Exit(1)
}

err = json.NewDecoder(resp.Body).Decode(&postResponse)
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
errorMsg := fmt.Sprintf("[Storage] Unable to decode JSON response from server [%s], exiting.", err)
logging.Debug(errorMsg)
os.Exit(1)
return err
}

// output an appropriate report URL
// TODO Move user interface outside of StorageFunction (return values, handle in sched)
finalURL := utils.FormatReportURL(postResponse.URL, postResponse.Token)
fmt.Fprintf(os.Stdout, "\n%s\n", finalURL)
fmt.Fprintf(os.Stdout, "\n%s\n", string(body))

logging.Debug("[Storage] Report stored")
return nil

0 comments on commit 5c421b1

Please sign in to comment.
You can’t perform that action at this time.