-
Notifications
You must be signed in to change notification settings - Fork 673
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
Added input to ibm container data source in order to skip listing bounded services #2051
Added input to ibm container data source in order to skip listing bounded services #2051
Conversation
607555e
to
645cf11
Compare
"bounded_services_namespace_id": { | ||
Description: "Name of the Kubernetes namespace where the service is bounded to.", | ||
Type: schema.TypeString, | ||
Default: "", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If its optional then by default value will be ""..
Remove Default=""
@@ -352,7 +359,8 @@ func dataSourceIBMContainerClusterRead(d *schema.ResourceData, meta interface{}) | |||
for i, worker := range workerFields { | |||
workers[i] = worker.ID | |||
} | |||
servicesBoundToCluster, err := csAPI.ListServicesBoundToCluster(name, "", targetEnv) | |||
boundedServicesNamespaceID := d.Get("bounded_services_namespace_id").(string) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since its an optional fields use d.GetOk
var namespaceID string
if nID, ok := d.GetOk("bounded_services_namespace_id"); ok {
namespaceID = nID.(string)
}
servicesBoundToCluster, err := csAPI.ListServicesBoundToCluster(name, namespaceID, targetEnv)
if err != nil {
return fmt.Errorf("Error retrieving services bound to cluster: %s", err)
}
Add the attribute to documentaion files also under https://github.com/IBM-Cloud/terraform-provider-ibm/blob/master/website/docs/d/container_cluster.html.markdown |
4fbf2b0
to
e8fdb47
Compare
e8fdb47
to
d2c52e4
Compare
Hi @hkantare , Kind regards, |
Hi |
d2c52e4
to
3703100
Compare
Alright, thank you. |
Hi there,
a lot of services are bound to our Kubernetes cluster. Everytime we run the Terraform scripts the ibm_container_cluster data source is executed which fetches all bounded services. In our case this leads to a very long execution time as the API does not respond very fast when there are more than 100 services bound to the cluster (actually it even results in timeout exceptions).
As we do not even need the information about all bounded services I would like to introduce the possibility to add an additional variable to filter for specific namespaces.
This should improve the overall performance of the data source and also the reliability.
The default value still remains as an empty string, so the changes should be backwards compatible.
In case of any questions, don't hesitate to contact me.