Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IsLocked parameter not coming in cloumn retention_policy in table gcp_storage_bucket closes #501 #502

Merged
merged 2 commits into from
Nov 1, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion gcp/table_gcp_storage_bucket.go
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,8 @@ func tableGcpStorageBucket(_ context.Context) *plugin.Table {
Name: "retention_policy",
Description: "The bucket's retention policy. The retention policy enforces a minimum retention time for all objects contained in the bucket, based on their creation time. Any attempt to overwrite or delete objects younger than the retention period will result in a PERMISSION_DENIED error.",
Type: proto.ColumnType_JSON,
Hydrate: extractRetentionPolicy,
Transform: transform.FromValue(),
},

// standard steampipe columns
Expand Down Expand Up @@ -298,7 +300,6 @@ func getGcpStorageBucket(ctx context.Context, d *plugin.QueryData, h *plugin.Hyd
plugin.Logger(ctx).Trace("getGcpStorageBucket", "Error", err)
return nil, err
}

return req, nil
}

Expand Down Expand Up @@ -336,3 +337,20 @@ func getBucketAka(ctx context.Context, d *plugin.QueryData, h *plugin.HydrateDat
akas := []string{"gcp://storage.googleapis.com/projects/" + project + "/buckets/" + bucket.Name}
return akas, nil
}

func extractRetentionPolicy(ctx context.Context, d *plugin.QueryData, h *plugin.HydrateData) (interface{}, error) {
bucket := h.Item.(*storage.Bucket)

bucketRetentionPolicy := make(map[string]interface{})

if bucket.RetentionPolicy != nil {

bucketRetentionPolicy["is_locked"] = bucket.RetentionPolicy.IsLocked

bucketRetentionPolicy["retention_period"] = bucket.RetentionPolicy.RetentionPeriod

bucketRetentionPolicy["effective_time"] = bucket.RetentionPolicy.EffectiveTime
}

return bucketRetentionPolicy, nil
}