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

Design changes prog4 #2

Merged
merged 10 commits into from
Apr 28, 2023
Merged

Design changes prog4 #2

merged 10 commits into from
Apr 28, 2023

Conversation

nandinimundra00
Copy link
Owner

What this PR does / why we need it:

To modularise the GenerateProvisioningRequest API by incorporating DRY principles and removing unwieldy conditional checks.

Which issue(s) this PR fixes (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close the issue(s) when PR gets merged):
Fixes #

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 and test output

Special notes for your reviewer:

Please confirm that if this PR changes any image versions, then that's the sole change this PR makes.

Release note:


secret.yaml Outdated Show resolved Hide resolved
Comment on lines 132 to 140
// Setting action arguments based on database type
dbTypeActionArgs := GetActionArgumentsByDatabaseType(dbSpec.Instance.Type)
if dbTypeActionArgs != nil {
req.ActionArguments = append(req.ActionArguments, dbTypeActionArgs.GetActionArguments(dbSpec)...)
} else {
var errStatement string
err = errors.New("Invalid Database Type")
errStatement = "Invalid Database Type: supported values: mysql, postgres, mongodb"
log.Error(err, errStatement)
Copy link

Choose a reason for hiding this comment

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

Would it make sense to return th error from the function GetActionArgumentsByDatabaseType() instead?
Thinking about extensibility with the current code - if we add another DB engine / type in the future then we might have to change code at two places: GetActionArgumentsByDatabaseType and this code block (error statement). Returning an error from the default case and checking the return values of the GetActionArgumentsByDatabaseType() call might be a cleaner approach.

Something like:

dbTypeActionArgs, err := GetActionArgumentsByDatabaseType(dbSpec.Instance.Type)
if err != nil {
    log.Error(err, "Error occurred while getting dbTypeActionArgs", "database type", dbSpec.Instance.Type)
    return
}

What do you think?

Copy link
Owner Author

Choose a reason for hiding this comment

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

Hi Manav,

Updated the same PR with your suggested changes.

Copy link

@manavrajvanshi manavrajvanshi left a comment

Choose a reason for hiding this comment

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

Changes look good to me! Unit test covers the scenarios too.
Left a comment about an idea, let me know what you guys think about it.
Thanks!

@ajithkvp ajithkvp merged commit 4fea618 into main Apr 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants