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

verifying EnvironmentID before creating infrastructure #4484

Merged
merged 5 commits into from
Apr 5, 2024

Conversation

Dhanush0369
Copy link
Contributor

@Dhanush0369 Dhanush0369 commented Mar 4, 2024

Proposed changes

Fixes #4463
Summarize your changes here to communicate with the maintainers and make sure to put the link of that issue

Types of changes

What types of changes does your code introduce to Litmus? Put an x in the boxes that apply

  • New feature (non-breaking change which adds functionality)
  • [ x] Bugfix (non-breaking change which fixes an issue)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation Update (if none of the other choices applies)

Checklist

Put an x in the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your code.

  • I have read the CONTRIBUTING doc
  • I have signed the commit for DCO to be passed.
  • Lint and unit tests pass locally with my changes
  • I have added tests that prove my fix is effective or that my feature works (if appropriate)
  • I have added necessary documentation (if appropriate)

Dependency

  • Please add the links to the dependent PR need to be merged before this (if any).

Special notes for your reviewer:

graphql_pic

Signed-off-by: Dhanush0369 <dhanush789245@gmail.com>
Copy link
Member

@vanshBhatia-A4k9 vanshBhatia-A4k9 left a comment

Choose a reason for hiding this comment

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

LGTM.
@Saranya-jena can you PTAL.

@Dhanush0369
Copy link
Contributor Author

Dhanush0369 commented Mar 7, 2024

@Saranya-jena shall I close this pr and make another pr. It seems I have merged using the wrong method.

Edit: The method is correct, the wrong method was about the merge commit.

@prithvi1307
Copy link
Contributor

Sure @Dhanush0369 please open another PR if you deem this wrong

@@ -86,6 +86,11 @@ func (in *infraService) RegisterInfra(c context.Context, projectID string, input
return nil, errors.New("infra already exists in this project with the same name")
}

// Check if EnvironmentID is valid
if _, err := in.envOperator.GetEnvironmentDetails(c, input.EnvironmentID, projectID); err != nil {
return nil, errors.New("Invalid EnvironmentID")
Copy link
Contributor

Choose a reason for hiding this comment

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

@Dhanush0369 have you tested these changes?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, I have attached the graphql playground pic

Copy link
Member

@namkyu1999 namkyu1999 left a comment

Choose a reason for hiding this comment

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

LGTM 🚀

@@ -86,6 +86,11 @@ func (in *infraService) RegisterInfra(c context.Context, projectID string, input
return nil, errors.New("infra already exists in this project with the same name")
}

// Check if EnvironmentID is valid
if _, err := in.envOperator.GetEnvironmentDetails(c, input.EnvironmentID, projectID); err != nil {
return nil, errors.New("Invalid EnvironmentID")
Copy link
Contributor

Choose a reason for hiding this comment

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

Invalid EnvironmentID - > environment does not exist.

Comment on lines +90 to +91
if _, err := in.envOperator.GetEnvironmentDetails(c, input.EnvironmentID, projectID); err != nil {
return nil, errors.New("Invalid EnvironmentID")
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
if _, err := in.envOperator.GetEnvironmentDetails(c, input.EnvironmentID, projectID); err != nil {
return nil, errors.New("Invalid EnvironmentID")
if env, err := in.envOperator.GetEnvironmentDetails(c, input.EnvironmentID, projectID); err != nil || env.EnvironmentID == "" {
return nil, errors.New("Invalid EnvironmentID")

@Saranya-jena Saranya-jena merged commit c1467b7 into litmuschaos:master Apr 5, 2024
18 checks passed
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.

registerInfra API allows registering Infra even with invalid environmentID
6 participants