Added table and migrations for instance level GCP config
What does this MR do and why?
This MR does following:
- Creates a table
audit_events_instance_google_cloud_logging_configurations
for storing Google cloud logging configurations for streaming instance level audit events. - Creates a model for the table.
- Created a concern for containing common code for existing
AuditEvents:: GoogleCloudLoggingConfiguration
model and new model. - Please note that the test cases can be refactored to use shared_examples but I am not taking refactoring of test cases of existing model in this MR, but will be a part of #423052 (closed). This is to ensure that the refactoring in actual code does not break anything existing.
Database migration
up
main: == [advisory_lock_connection] object_id: 224700, pg_backend_pid: 64412
main: == 20230823132142 CreateInstanceGoogleCloudLoggingConfigurations: migrating ===
main: -- create_table(:audit_events_instance_google_cloud_logging_configurations)
main: -- quote_column_name(:google_project_id_name)
main: -> 0.0000s
main: -- quote_column_name(:client_email)
main: -> 0.0000s
main: -- quote_column_name(:log_id_name)
main: -> 0.0000s
main: -- quote_column_name(:name)
main: -> 0.0000s
main: -> 0.0266s
main: == 20230823132142 CreateInstanceGoogleCloudLoggingConfigurations: migrated (0.1705s)
main: == [advisory_lock_connection] object_id: 224700, pg_backend_pid: 64412
down
RAILS_ENV=development bin/rails db:migrate:down:main VERSION=20230823132142
main: == [advisory_lock_connection] object_id: 266080, pg_backend_pid: 63962
main: == 20230823132142 CreateInstanceGoogleCloudLoggingConfigurations: reverting ===
main: -- drop_table(:audit_events_instance_google_cloud_logging_configurations)
main: -> 0.0022s
main: == 20230823132142 CreateInstanceGoogleCloudLoggingConfigurations: reverted (0.0081s)
main: == [advisory_lock_connection] object_id: 266080, pg_backend_pid: 63962
How to set up and validate locally
- Open rails console.
- Run
AuditEvents::Instance::GoogleCloudLoggingConfiguration.create!(google_project_id_name: "project-name", client_email: "abcd@rt.com", log_id_name: "some_log_name", name: "First destination", private_key: "random_private_key")
in console to create a new configuration. - The configuration should get listed, for checking run
AuditEvents::Instance::GoogleCloudLoggingConfiguration.last
.
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.
Related to #423036 (closed)
Edited by Hitesh Raghuvanshi