Skip to content

Commit

Permalink
feat: new views for notification group by
Browse files Browse the repository at this point in the history
  • Loading branch information
adityathebe authored and moshloop committed Feb 12, 2025
1 parent f7c5d51 commit e13e6b7
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 0 deletions.
3 changes: 3 additions & 0 deletions rbac/objects.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@ var dbResourceObjMap = map[string]string{
"config_statuses": policy.ObjectDatabasePublic,
"config_summary": policy.ObjectCatalog,
"config_tags": policy.ObjectDatabasePublic,
"config_tags_labels_keys": policy.ObjectDatabasePublic,
"component_labels_keys": policy.ObjectDatabasePublic,
"checks_labels_keys": policy.ObjectDatabasePublic,
"config_types": policy.ObjectDatabasePublic,
"configs": policy.ObjectCatalog,
"connections_list": policy.ObjectDatabasePublic,
Expand Down
5 changes: 5 additions & 0 deletions views/004_check_views.sql
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,8 @@ GROUP BY
ORDER BY
key,
value;

-- checks_labels_keys
DROP VIEW IF EXISTS checks_labels_keys;
CREATE OR REPLACE VIEW checks_labels_keys AS
SELECT DISTINCT 'label:' || jsonb_object_keys(labels) AS "key" FROM checks;
5 changes: 5 additions & 0 deletions views/005_component_views.sql
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,11 @@ CREATE OR REPLACE VIEW component_labels AS
key,
value;

-- component_labels_keys
DROP VIEW IF EXISTS component_labels_keys;
CREATE OR REPLACE VIEW component_labels_keys AS
SELECT DISTINCT 'label:' || jsonb_object_keys(labels) AS "key" FROM components;

DROP VIEW IF EXISTS components_with_logs;
CREATE OR REPLACE VIEW components_with_logs AS
SELECT
Expand Down
7 changes: 7 additions & 0 deletions views/006_config_views.sql
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,13 @@ CREATE OR REPLACE VIEW config_labels AS
FROM config_items w JOIN json_each_text(labels::json) d ON true where deleted_at is null GROUP BY d.key, d.value ORDER BY key, value;


-- config_tags_labels_keys
DROP VIEW IF EXISTS config_tags_labels_keys;
CREATE OR REPLACE VIEW config_tags_labels_keys AS
SELECT DISTINCT 'tag:' || jsonb_object_keys(tags) AS "key" FROM config_items
UNION
SELECT DISTINCT 'label:' || jsonb_object_keys(labels) AS "key" FROM config_items;

-- config_type_summary
DROP VIEW IF EXISTS config_summary;
CREATE VIEW config_summary AS
Expand Down
3 changes: 3 additions & 0 deletions views/034_rls_enable.sql
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,8 @@ ALTER VIEW catalog_changes SET (security_invoker = true);
ALTER VIEW check_summary_by_config SET (security_invoker = true);
ALTER VIEW check_summary_for_config SET (security_invoker = true);
ALTER VIEW checks_by_config SET (security_invoker = true);
ALTER VIEW checks_labels_keys SET (security_invoker = true);
ALTER VIEW component_labels_keys SET (security_invoker = true);
ALTER VIEW config_analysis_analyzers SET (security_invoker = true);
ALTER VIEW config_analysis_by_severity SET (security_invoker = true);
ALTER VIEW config_analysis_items SET (security_invoker = true);
Expand All @@ -132,6 +134,7 @@ ALTER VIEW config_scrapers_with_status SET (security_invoker = true);
ALTER VIEW config_statuses SET (security_invoker = true);
ALTER VIEW config_summary SET (security_invoker = true);
ALTER VIEW config_tags SET (security_invoker = true);
ALTER VIEW config_tags_labels_keys SET (security_invoker = true);
ALTER VIEW config_types SET (security_invoker = true);
ALTER VIEW configs SET (security_invoker = true);
ALTER VIEW incidents_by_config SET (security_invoker = true);

0 comments on commit e13e6b7

Please sign in to comment.