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
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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
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")

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

}

if (*input.InfraNsExists && input.InfraNamespace == nil) || (*input.InfraNsExists && *input.InfraNamespace == "") {
return nil, errors.New("InfraNamespace parameter is required if InfraNsExists is true")
}
Expand Down
Loading