Skip to content

Added table and migrations for instance level GCP config

Hitesh Raghuvanshi requested to merge 423036-add-table-instance-gcp into master

What does this MR do and why?

This MR does following:

  1. Creates a table audit_events_instance_google_cloud_logging_configurations for storing Google cloud logging configurations for streaming instance level audit events.
  2. Creates a model for the table.
  3. Created a concern for containing common code for existing AuditEvents:: GoogleCloudLoggingConfiguration model and new model.
  4. 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

  1. Open rails console.
  2. 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.
  3. 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.

Related to #423036 (closed)

Edited by Hitesh Raghuvanshi

Merge request reports

Loading