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

[BUG] TYPE as required parameter for resource cloudfoundry_service_instance #65

Closed
1 task done
lechnerc77 opened this issue Apr 3, 2024 · 2 comments
Closed
1 task done
Assignees
Labels
bug Something isn't working

Comments

@lechnerc77
Copy link
Member

Is there an existing issue for this?

  • I have searched the existing issues

What version of the Terraform provider are you using?

main-branch

What version of the Terraform CLI are you using?

1.7.3

What CF API version are you using?

3.153

What type of issue are you facing

bug report

Describe the bug

The resource cloudfoundry_service_instance requires the input of the field type. This gives users a hard time to setup services and is also not compatible to the existing provider

Expected Behavior

The field type should be an optional field with a default value

Steps To Reproduce

See documentation of the resource

Your Terraform Configuration

n/a

Roles

n/a

Add screenshots to help explain your problem

n/a

Additional context

n/a

@lechnerc77 lechnerc77 added the bug Something isn't working label Apr 3, 2024
@KesavanKing KesavanKing self-assigned this Apr 4, 2024
@KesavanKing
Copy link
Member

Cloudfoundry community provider maintains separate resources for user-provided-service and managed service instance.
But we thought of having as one respecting to V3 API structure.

If we make type as optional and set managed as default , then we can't perform validate config for parameters specific to each service instance types.

if config.Type.ValueString() == userProvidedServiceInstance && !config.ServicePlan.IsNull() {
resp.Diagnostics.AddAttributeError(
path.Root("service_plan"),
"Conflicting attribute service instance",
"Service plan is not allowed for user-provided service instance",
)
return
}
if config.Type.ValueString() == managedSerivceInstance && config.ServicePlan.IsNull() {
resp.Diagnostics.AddAttributeError(
path.Root("service_plan"),
"Missing attribute service instance",
"Service plan is required for managed service instance",
)
return
}
// If Service Instance is of type managed only parameters is allowed to pass
if !config.Parameters.IsNull() && config.Type.ValueString() != "managed" {
resp.Diagnostics.AddAttributeError(
path.Root("type"),
"Parameters can only passed to service instance of type managed",
"Parameters json object can only be passed to managed serivce instance",
)
return
}

Or else we have to implement separate resources for instance types , managed and user-provided.
@lechnerc77 What's your thoughts on this?

@lechnerc77
Copy link
Member Author

@KesavanKing : Thanks for the details. I was not aware of that. I think you can then stick to the solution as is then. I would for now not add (artificial) resources. I will close this issue then.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants