Skip to content

Commit

Permalink
added fucntions for PQA-1848
Browse files Browse the repository at this point in the history
  • Loading branch information
MGamya committed May 31, 2024
1 parent a69f2f6 commit e8811d6
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions client/cluster.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
package client

import (
"bytes"
"fmt"
"io"
"os"
"strings"

clientV1 "github.com/spectrocloud/palette-api-go/client/v1"
Expand Down Expand Up @@ -247,3 +250,42 @@ func clusterNameEqFilter(name string) *models.V1SearchFilterItem {
Type: models.V1SearchFilterPropertyTypeString,
}
}

func (h *V1Client) GetLogFetcherStatus(uid string,logFetcherUid *string) (*models.V1ClusterLogFetcher,error) {
params2 := clientV1.NewV1ClusterFeatureLogFetcherGetParamsWithContext(h.ctx).WithUID(uid).WithRequestID(logFetcherUid)
resp2, err := h.Client.V1ClusterFeatureLogFetcherGet(params2)
if err != nil {
return nil, err
}
return resp2.Payload, nil
}

func (h *V1Client) InitiateDownloadOfClusterLogs(uid string,V1ClusterLogFetcherRequestObj *models.V1ClusterLogFetcherRequest) (*string, error) {
//param := clientV1.V1ClusterFeatureLogFetcherCreateParams
fmt.Println("new console log test")
params := clientV1.NewV1ClusterFeatureLogFetcherCreateParamsWithContext(h.ctx).WithUID(uid).WithBody(V1ClusterLogFetcherRequestObj)

resp, err := h.Client.V1ClusterFeatureLogFetcherCreate(params)
if err != nil {
return nil,err
}
return resp.GetPayload().UID,nil

}

func (h *V1Client) DownloadLogs(uid string,logFetcherUid string) (io.Writer,error){

filename := "logs-"+uid+".zip"
params1 := clientV1.NewV1ClusterFeatureLogFetcherLogDownloadParamsWithContext(h.ctx).WithUID(logFetcherUid).WithFileName(&filename)
var buf bytes.Buffer
writer := io.Writer(&buf)
resp1,err1 := h.Client.V1ClusterFeatureLogFetcherLogDownload(params1,writer)
logfile := resp1.GetPayload()
if err1 != nil {
return nil,err1
}
file_location := "/tmp/"+filename
fo, _ := os.Create(file_location)
buf.WriteTo(fo)

Check failure on line 289 in client/cluster.go

View workflow job for this annotation

GitHub Actions / build-with-coverage

Error return value of `buf.WriteTo` is not checked (errcheck)
return logfile,nil
}

0 comments on commit e8811d6

Please sign in to comment.