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

chore:[Devops-299]Asset governance flag #2265

Closed
wants to merge 1 commit into from

Conversation

rnithinpaladin
Copy link
Collaborator

@rnithinpaladin rnithinpaladin commented Jun 14, 2024

Description

Asset governance feature flag

Please include a summary of the changes and the related issues. Please also include relevant motivation and context. List
any dependencies that are required for this change.

Problem

Solution

Fixes # (issue if any)

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Chore (no code changes)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also
list any relevant details for your test configuration

  • Test A
  • Test B

Checklist:

  • My code follows the style guidelines of this project
  • My commit message/PR follows the contribution guidelines of this project
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

Other Information:

List any documentation updates that are needed for the Wiki

Summary by CodeRabbit

  • New Features

    • Introduced an Asset Governance feature flag to enable or disable asset governance functionality across the application.
    • Configuration updates to reflect the new Asset Governance settings in the UI.
  • Settings

    • Added ASSET_GOVERNANCE_FEATURE_FLAG with a default value of False for enhanced governance control.

Copy link

coderabbitai bot commented Jun 14, 2024

Walkthrough

The recent changes revolve around introducing an asset governance feature to PacBot. A flag (asset_governance_enabled) was added across various scripts and configurations to control this feature. New environment variables and configuration updates ensure that both the UI and backend respect this feature flag. The database schema and settings were also adjusted to accommodate this feature.

Changes

Files/Paths Change Summary
installer/files/scripts/build_pacbot.py Added asset_governance_enabled flag and updated UI configuration logic accordingly.
installer/resources/pacbot_app/build_ui_and_api.py Introduced ENV_ASSET_GOVERNANCE_FEATURE_FLAG to provisioners dictionary.
installer/resources/pacbot_app/files/DB.sql Added @ASSET_GOVERNANCE_FEATURE_FLAG and updated pac_config_properties table changes.
installer/resources/pacbot_app/import_db.py Added ASSET_GOVERNANCE_FEATURE_FLAG to environment variables dictionary.
installer/settings/default.local.py Introduced ASSET_GOVERNANCE_FEATURE_FLAG with default False.
webapp/src/config/configurations.ts Added assetGovernanceFeatureFlag to CONFIGURATIONS object with a default value of false.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant WebApp
    participant API
    participant BuildPacBot
    participant DB

    User ->> WebApp: Access PacBot UI
    WebApp ->> API: Request Asset Governance Status
    API ->> BuildPacBot: Check Asset Governance Flag
    BuildPacBot ->> DB: Retrieve Asset Governance Flag
    DB -->> BuildPacBot: Return Flag Status
    BuildPacBot -->> API: Asset Governance Flag Status
    API -->> WebApp: Asset Governance Flag Status
    WebApp -->> User: Display UI Based on Flag
Loading

Poem

In the world of PacBot's might,
Asset governance takes flight.
Flags are set, and features gleam,
Bringing order to the dream.
Configs updated, scripts in line,
PacBot governance, truly fine. 🐇✨


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

⚠️ DELETE statement found in the changes of SQL files. Requesting review from @santhosh and @Arun.

Copy link

sonarcloud bot commented Jun 14, 2024

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
No data about Duplication

See analysis details on SonarCloud

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Outside diff range and nitpick comments (8)
installer/resources/pacbot_app/build_ui_and_api.py (3)

Line range hint 17-17: Consider using Python's newer string formatting methods.

- raise Exception("Pacbot CodeBase, %s,  is Not Found!" % pom_file)
+ raise Exception(f"Pacbot CodeBase, {pom_file}, is Not Found!")

Line range hint 59-59: Improve exception handling by specifying the cause of the exception.

- raise Exception("Not able to create directory to store API Jars and UI code")
+ raise Exception("Not able to create directory to store API Jars and UI code") from OE

Line range hint 67-67: Avoid redefining methods that do the same thing; consider removing one of the duplicate pre_generate_terraform methods.

- def pre_generate_terraform(self):
-     # To support latest terraform version
-     PyTerraform.change_tf_extension_to_tf_json()
installer/files/scripts/build_pacbot.py (4)

Line range hint 9-9: Remove unnecessary inheritance from object in Python 3.

- class Buildpacbot(object):
+ class Buildpacbot:

Line range hint 77-77: Rename unused loop variables to _.

- for (dirpath, dirnames, file_names) in os.walk(local_folder_path):
+ for (_dirpath, _dirnames, file_names) in os.walk(local_folder, path):

Also applies to: 77-77


Line range hint 81-81: Use Python's newer string formatting methods for better readability and performance.

- "Email template files are not found in %s" % str(local_folder_path)
+ f"Email template files are not found in {str(local_folder_path)}"

Also applies to: 89-89, 113-113, 115-115, 138-138, 157-157, 159-159, 172-172, 174-174, 193-193, 257-257, 259-259, 265-265


Line range hint 112-115: Combine similar if branches to simplify the code.

- if "AD_AUTHENTICATION: false" in line:
-     lines[idx] = lines[idx].replace("AD_AUTHENTICATION: false", "AD_AUTHENTICATION: true")
- if "qualysEnabled: false" in line:
-     lines[idx] = lines[idx].replace("qualysEnabled: false", f"qualysEnabled: {self.enable_vulnerability_feature}")
+ if "AD_AUTHENTICATION: false" in line or "qualysEnabled: false" in line:
+     lines[idx] = lines[idx].replace("AD_AUTHENTICATION: false", "AD_AUTHENTICATION: true").replace("qualysEnabled: false", f"qualysEnabled: {self.enable_vulnerability_feature}")
installer/resources/pacbot_app/import_db.py (1)

Line range hint 3-3: Remove unused imports to clean up the code.

- from core.terraform.utils import get_terraform_provider_file
- from resources.pacbot_app.cloudwatch_log_groups.UiCloudWatchLogGroup import UiCloudWatchLogGroup
- from resources.pacbot_app.cloudwatch_log_groups.ApiCloudWatchLogGroup import ApiCloudWatchLogGroup
- from resources.pacbot_app.ecr.APIEcrRepository import APIEcrRepository
- from resources.pacbot_app.ecr.UIEcrRepository import UIEcrRepository
- from resources.pacbot_app.cloudwatch_log_groups import UiCloudWatchLogGroup, ApiCloudWatchLogGroup
- from resources.data.aws_info import AwsRegion
- from resources.iam.ecs_role.ECSRole import ECSRole
- from resources.notification.function.SendNotificationFunction import SendNotificationFunction

Also applies to: 8-8, 8-8, 9-9, 9-9, 10-10, 12-12, 13-13, 23-23

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 4767c87 and 6eead7b.

Files selected for processing (6)
  • installer/files/scripts/build_pacbot.py (3 hunks)
  • installer/resources/pacbot_app/build_ui_and_api.py (1 hunks)
  • installer/resources/pacbot_app/files/DB.sql (2 hunks)
  • installer/resources/pacbot_app/import_db.py (1 hunks)
  • installer/settings/default.local.py (1 hunks)
  • webapp/src/config/configurations.ts (1 hunks)
Files skipped from review due to trivial changes (2)
  • installer/settings/default.local.py
  • webapp/src/config/configurations.ts
Additional context used
Ruff
installer/resources/pacbot_app/build_ui_and_api.py

17-17: Use format specifiers instead of percent format (UP031)

Replace with format specifiers


59-59: Within an except clause, raise exceptions with raise ... from err or raise ... from None to distinguish them from errors in exception handling (B904)


67-67: Redefinition of unused pre_generate_terraform from line 14 (F811)

installer/files/scripts/build_pacbot.py

9-9: Class Buildpacbot inherits from object (UP004)

Remove object inheritance


77-77: Loop control variable dirpath not used within loop body (B007)

Rename unused dirpath to _dirpath


77-77: Loop control variable dirnames not used within loop body (B007)

Rename unused dirnames to _dirnames


81-81: Use format specifiers instead of percent format (UP031)

Replace with format specifiers


89-89: Use format specifiers instead of percent format (UP031)

Replace with format specifiers


112-115: Combine if branches using logical or operator (SIM114)

Combine if branches


113-113: Use format specifiers instead of percent format (UP031)

Replace with format specifiers


115-115: Use format specifiers instead of percent format (UP031)

Replace with format specifiers


138-138: Use format specifiers instead of percent format (UP031)

Replace with format specifiers


157-157: Use format specifiers instead of percent format (UP031)

Replace with format specifiers


159-159: Use format specifiers instead of percent format (UP031)

Replace with format specifiers


172-172: Use format specifiers instead of percent format (UP031)

Replace with format specifiers


174-174: Use format specifiers instead of percent format (UP031)

Replace with format specifiers


181-181: Unnecessary open mode parameters (UP015)

Remove open mode parameters


193-193: Use format specifiers instead of percent format (UP031)

Replace with format specifiers


208-209: Use a single if statement instead of nested if statements (SIM102)

Combine if statements using and


257-257: Use format specifiers instead of percent format (UP031)

Replace with format specifiers


259-259: Use format specifiers instead of percent format (UP031)

Replace with format specifiers


265-265: Use format specifiers instead of percent format (UP031)

Replace with format specifiers

installer/resources/pacbot_app/import_db.py

3-3: core.terraform.utils.get_terraform_provider_file imported but unused (F401)

Remove unused import: core.terraform.utils.get_terraform_provider_file


8-8: resources.pacbot_app.cloudwatch_log_groups.UiCloudWatchLogGroup imported but unused (F401)

Remove unused import


8-8: resources.pacbot_app.cloudwatch_log_groups.ApiCloudWatchLogGroup imported but unused (F401)

Remove unused import


9-9: resources.pacbot_app.ecr.APIEcrRepository imported but unused (F401)

Remove unused import


9-9: resources.pacbot_app.ecr.UIEcrRepository imported but unused (F401)

Remove unused import


10-10: Redefinition of unused AwsRegion from line 7 (F811)

Remove definition: AwsRegion


12-12: Redefinition of unused ESDomain from line 6 (F811)

Remove definition: ESDomain


13-13: resources.iam.ecs_role.ECSRole imported but unused (F401)

Remove unused import: resources.iam.ecs_role.ECSRole


23-23: resources.notification.function.SendNotificationFunction imported but unused (F401)

Remove unused import: resources.notification.function.SendNotificationFunction


44-44: Use format specifiers instead of percent format (UP031)

Replace with format specifiers


61-61: Local variable db_user_name is assigned to but never used (F841)

Remove assignment to unused variable db_user_name


62-62: Local variable db_password is assigned to but never used (F841)

Remove assignment to unused variable db_password


63-63: Local variable db_host is assigned to but never used (F841)

Remove assignment to unused variable db_host


222-223: Use format specifiers instead of percent format (UP031)

Replace with format specifiers


228-229: Use format specifiers instead of percent format (UP031)

Replace with format specifiers


234-235: Use format specifiers instead of percent format (UP031)

Replace with format specifiers


244-245: Use format specifiers instead of percent format (UP031)

Replace with format specifiers


251-252: Use format specifiers instead of percent format (UP031)

Replace with format specifiers


257-258: Use format specifiers instead of percent format (UP031)

Replace with format specifiers

Additional comments not posted (7)
installer/resources/pacbot_app/build_ui_and_api.py (1)

45-45: Ensure the new environment variable is correctly integrated and documented.

This change integrates the ENV_ASSET_GOVERNANCE_FEATURE_FLAG into the environment setup for local executions, aligning with the PR's objectives to manage asset-related functionalities.

installer/files/scripts/build_pacbot.py (2)

230-233: Ensure the dynamic setting of assetGovernanceEnabled is correctly implemented.

The assetGovernanceEnabled configuration is properly updated based on the asset_governance_enabled attribute.


295-295: Verify that the environment variable is correctly fetched and used.

Verification successful

The ASSET_GOVERNANCE_FEATURE_FLAG environment variable is correctly fetched and used in the script. The references found in the codebase indicate that this variable is consistently used across multiple files.

  • installer/settings/default.local.py: Defines the flag with a default value.
  • installer/resources/pacbot_app/build_ui_and_api.py: Passes the flag to the environment settings.
  • installer/resources/pacbot_app/import_db.py: Uses the flag in the import database script.
  • installer/files/scripts/build_pacbot.py: Fetches the flag from the environment.
Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify the correct usage of `ASSET_GOVERNANCE_FEATURE_FLAG` environment variable.

# Test: Search for the environment variable usage. Expect: Correct usage in the script.
rg --type python $'ASSET_GOVERNANCE_FEATURE_FLAG'

Length of output: 79



Script:

#!/bin/bash
# Description: Verify the correct usage of `ASSET_GOVERNANCE_FEATURE_FLAG` environment variable.

# Test: Search for the environment variable usage. Expect: Correct usage in the script.
rg --type py $'ASSET_GOVERNANCE_FEATURE_FLAG'

Length of output: 522

installer/resources/pacbot_app/import_db.py (1)

188-189: Ensure the new environment variable ASSET_GOVERNANCE_FEATURE_FLAG is correctly integrated and documented.

The integration of the ASSET_GOVERNANCE_FEATURE_FLAG into the environment setup for database operations aligns with the PR's objectives to manage asset-related functionalities.

installer/resources/pacbot_app/files/DB.sql (3)

128-128: The creation of the OmniSearch_Config table appears unrelated to the feature flag implementation. Please clarify if this is intentional.


128-128: Ensure that the ASSET_GOVERNANCE_FEATURE_FLAG variable is properly used in subsequent SQL queries.


3366-3368: Ensure that the insert operation for aws.eventbridge.bus.details with the ASSET_GOVERNANCE_FEATURE_FLAG is correctly implemented and has the intended effect.

Verification successful

The insert operation for aws.eventbridge.bus.details with the ASSET_GOVERNANCE_FEATURE_FLAG is correctly implemented and has the intended effect.

  • installer/resources/pacbot_app/files/DB.sql: The variable ASSET_GOVERNANCE_FEATURE_FLAG is defined and used correctly in the insert statement.
Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify the correctness of the insert operation involving `ASSET_GOVERNANCE_FEATURE_FLAG`.

# Test: Search for the insert operation and verify its correctness.
rg --type sql $'INSERT IGNORE INTO pac_config_properties' | grep 'ASSET_GOVERNANCE_FEATURE_FLAG'

Length of output: 421



Script:

#!/bin/bash
# Description: Verify the definition and usage of the `ASSET_GOVERNANCE_FEATURE_FLAG` variable in the SQL files.

# Test: Search for the definition of `ASSET_GOVERNANCE_FEATURE_FLAG`.
rg --type sql 'ASSET_GOVERNANCE_FEATURE_FLAG'

Length of output: 484

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant