11package cli
22
33import (
4+ "bytes"
45 "crypto/tls"
6+ "encoding/json"
57 "fmt"
68 "io/ioutil"
79 "net/http"
@@ -22,6 +24,7 @@ import (
2224 "github.com/replicatedhq/troubleshoot/pkg/client/troubleshootclientset/scheme"
2325 troubleshootclientsetscheme "github.com/replicatedhq/troubleshoot/pkg/client/troubleshootclientset/scheme"
2426 "github.com/replicatedhq/troubleshoot/pkg/collect"
27+ "github.com/replicatedhq/troubleshoot/pkg/redact"
2528 "github.com/spf13/viper"
2629 spin "github.com/tj/go-spin"
2730)
@@ -370,6 +373,33 @@ func uploadSupportBundle(r *troubleshootv1beta1.ResultRequest, archivePath strin
370373 return fmt .Errorf ("unexpected status code %d" , resp .StatusCode )
371374 }
372375
376+ // send redaction report
377+ if r .RedactURI != "" {
378+ type PutSupportBundleRedactions struct {
379+ Redactions redact.RedactionList `json:"redactions"`
380+ }
381+
382+ redactBytes , err := json .Marshal (PutSupportBundleRedactions {Redactions : redact .GetRedactionList ()})
383+ if err != nil {
384+ return errors .Wrap (err , "get redaction report" )
385+ }
386+
387+ req , err := http .NewRequest ("PUT" , r .RedactURI , bytes .NewReader (redactBytes ))
388+ if err != nil {
389+ return errors .Wrap (err , "create redaction report request" )
390+ }
391+ req .ContentLength = int64 (len (redactBytes ))
392+
393+ resp , err := httpClient .Do (req )
394+ if err != nil {
395+ return errors .Wrap (err , "execute redaction request" )
396+ }
397+
398+ if resp .StatusCode >= 300 {
399+ return fmt .Errorf ("unexpected redaction status code %d" , resp .StatusCode )
400+ }
401+ }
402+
373403 return nil
374404}
375405
0 commit comments