Skip to content

Commit 907cc48

Browse files
Add cluster name and description to CyberArk Discovery and Context snapshot
- Add ClusterName and ClusterDescription fields to Snapshot struct - Populate these fields from Options in PostDataReadingsWithOptions Signed-off-by: Richard Wall <[email protected]>
1 parent 0ae6dbd commit 907cc48

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

internal/cyberark/dataupload/dataupload.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,10 @@ type Snapshot struct {
5151
AgentVersion string `json:"agent_version"`
5252
// ClusterID is the unique ID of the Kubernetes cluster which this snapshot was taken from.
5353
ClusterID string `json:"cluster_id"`
54+
// ClusterName is the name of the Kubernetes cluster which this snapshot was taken from.
55+
ClusterName string `json:"cluster_name"`
56+
// ClusterDescription is an optional description of the Kubernetes cluster which this snapshot was taken from.
57+
ClusterDescription string `json:"cluster_description,omitempty"`
5458
// K8SVersion is the version of Kubernetes which the cluster is running.
5559
K8SVersion string `json:"k8s_version"`
5660
// Secrets is a list of Secret resources in the cluster. Not all Secret

pkg/client/client_cyberark.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,18 +52,20 @@ func NewCyberArk(httpClient *http.Client) (*CyberArkClient, error) {
5252
// It initializes a data upload client with the configured HTTP client and credentials,
5353
// then uploads a snapshot.
5454
// The supplied Options are not used by this publisher.
55-
func (o *CyberArkClient) PostDataReadingsWithOptions(ctx context.Context, readings []*api.DataReading, _ Options) error {
55+
func (o *CyberArkClient) PostDataReadingsWithOptions(ctx context.Context, readings []*api.DataReading, opts Options) error {
5656
log := klog.FromContext(ctx)
57-
var snapshot dataupload.Snapshot
57+
snapshot := dataupload.Snapshot{
58+
ClusterName: opts.ClusterName,
59+
ClusterDescription: opts.ClusterDescription,
60+
AgentVersion: version.PreflightVersion,
61+
}
5862
if err := convertDataReadings(defaultExtractorFunctions, readings, &snapshot); err != nil {
5963
return fmt.Errorf("while converting data readings: %s", err)
6064
}
6165

6266
// Minimize the snapshot to reduce size and improve privacy
6367
minimizeSnapshot(log.V(logs.Debug), &snapshot)
6468

65-
snapshot.AgentVersion = version.PreflightVersion
66-
6769
cfg, err := o.configLoader()
6870
if err != nil {
6971
return err

0 commit comments

Comments
 (0)