Skip to content

Commit

Permalink
chore: implement PutVulnerabilityReport in saas.Client
Browse files Browse the repository at this point in the history
  • Loading branch information
matheusfm committed Jan 12, 2024
1 parent 5162018 commit 3917d89
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions internal/saas/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ import (
"net/http"
"net/url"
"path"

"github.com/undistro/zora/api/zora/v1alpha1"
)

const (
Expand All @@ -42,6 +44,7 @@ type Client interface {
DeleteCluster(ctx context.Context, namespace, name string) error
PutClusterScan(ctx context.Context, namespace, name string, pluginStatus map[string]*PluginStatus) error
DeleteClusterScan(ctx context.Context, namespace, name string) error
PutVulnerabilityReport(ctx context.Context, namespace, name string, vulnReport v1alpha1.VulnerabilityReport) error
}

type client struct {
Expand Down Expand Up @@ -120,6 +123,26 @@ func (r *client) PutClusterScan(ctx context.Context, namespace, name string, plu
return validateStatus(res)
}

func (r *client) PutVulnerabilityReport(ctx context.Context, namespace, name string, vulnReport v1alpha1.VulnerabilityReport) error {
u := r.clusterURL(namespace, name, "vulnerabilityreports")
b, err := json.Marshal(vulnReport)
if err != nil {
return err
}
req, err := http.NewRequestWithContext(ctx, http.MethodPut, u, bytes.NewReader(b))
if err != nil {
return err
}
req.Header.Set("content-type", "application/json")
req.Header.Set(versionHeader, r.version)
res, err := r.client.Do(req)
if err != nil {
return err
}
defer res.Body.Close()
return validateStatus(res)
}

func (r *client) DeleteClusterScan(ctx context.Context, namespace, name string) error {
u := r.clusterURL(namespace, name, "scan")
req, err := http.NewRequestWithContext(ctx, http.MethodDelete, u, nil)
Expand Down

0 comments on commit 3917d89

Please sign in to comment.