diff --git a/examples/ibm-mqcloud/README.md b/examples/ibm-mqcloud/README.md new file mode 100644 index 0000000000..ae8ef2a8dd --- /dev/null +++ b/examples/ibm-mqcloud/README.md @@ -0,0 +1,175 @@ +# Example for MqcloudV1 + +This example illustrates how to use the MqcloudV1 + +The following types of resources are supported: + +* mqcloud_queue_manager +* mqcloud_application +* mqcloud_user +* mqcloud_keystore_certificate +* mqcloud_truststore_certificate + +## Usage + +To run this example, execute the following commands: + +```bash +$ terraform init +$ terraform plan +$ terraform apply +``` + +Run `terraform destroy` when you don't need these resources. + + +## MqcloudV1 resources + +mqcloud_queue_manager resource: + +```hcl +resource "mqcloud_queue_manager" "mqcloud_queue_manager_instance" { + service_instance_guid = var.mqcloud_queue_manager_service_instance_guid + name = var.mqcloud_queue_manager_name + display_name = var.mqcloud_queue_manager_display_name + location = var.mqcloud_queue_manager_location + size = var.mqcloud_queue_manager_size + version = var.mqcloud_queue_manager_version +} +``` +mqcloud_application resource: + +```hcl +resource "mqcloud_application" "mqcloud_application_instance" { + service_instance_guid = var.mqcloud_application_service_instance_guid + name = var.mqcloud_application_name +} +``` +mqcloud_user resource: + +```hcl +resource "mqcloud_user" "mqcloud_user_instance" { + service_instance_guid = var.mqcloud_user_service_instance_guid + name = var.mqcloud_user_name + email = var.mqcloud_user_email +} +``` +mqcloud_keystore_certificate resource: + +```hcl +resource "mqcloud_keystore_certificate" "mqcloud_keystore_certificate_instance" { + service_instance_guid = var.mqcloud_keystore_certificate_service_instance_guid + queue_manager_id = var.mqcloud_keystore_certificate_queue_manager_id + label = var.mqcloud_keystore_certificate_label +} +``` +mqcloud_truststore_certificate resource: + +```hcl +resource "mqcloud_truststore_certificate" "mqcloud_truststore_certificate_instance" { + service_instance_guid = var.mqcloud_truststore_certificate_service_instance_guid + queue_manager_id = var.mqcloud_truststore_certificate_queue_manager_id + label = var.mqcloud_truststore_certificate_label +} +``` + +## MqcloudV1 data sources + +mqcloud_queue_manager data source: + +```hcl +data "mqcloud_queue_manager" "mqcloud_queue_manager_instance" { + service_instance_guid = var.mqcloud_queue_manager_service_instance_guid + name = var.mqcloud_queue_manager_name +} +``` +mqcloud_queue_manager_status data source: + +```hcl +data "mqcloud_queue_manager_status" "mqcloud_queue_manager_status_instance" { + service_instance_guid = var.mqcloud_queue_manager_status_service_instance_guid + queue_manager_id = var.mqcloud_queue_manager_status_queue_manager_id +} +``` +mqcloud_application data source: + +```hcl +data "mqcloud_application" "mqcloud_application_instance" { + service_instance_guid = var.mqcloud_application_service_instance_guid + name = var.mqcloud_application_name +} +``` +mqcloud_user data source: + +```hcl +data "mqcloud_user" "mqcloud_user_instance" { + service_instance_guid = var.mqcloud_user_service_instance_guid + name = var.mqcloud_user_name +} +``` +mqcloud_truststore_certificate data source: + +```hcl +data "mqcloud_truststore_certificate" "mqcloud_truststore_certificate_instance" { + service_instance_guid = var.mqcloud_truststore_certificate_service_instance_guid + queue_manager_id = var.mqcloud_truststore_certificate_queue_manager_id + label = var.mqcloud_truststore_certificate_label +} +``` +mqcloud_keystore_certificate data source: + +```hcl +data "mqcloud_keystore_certificate" "mqcloud_keystore_certificate_instance" { + service_instance_guid = var.mqcloud_keystore_certificate_service_instance_guid + queue_manager_id = var.mqcloud_keystore_certificate_queue_manager_id + label = var.mqcloud_keystore_certificate_label +} +``` + +## Assumptions + +1. TODO + +## Notes + +1. TODO + +## Requirements + +| Name | Version | +|------|---------| +| terraform | ~> 0.12 | + +## Providers + +| Name | Version | +|------|---------| +| ibm | 1.13.1 | + +## Inputs + +| Name | Description | Type | Required | +|------|-------------|------|---------| +| ibmcloud\_api\_key | IBM Cloud API key | `string` | true | +| service_instance_guid | The GUID that uniquely identifies the MQ on Cloud service instance. | `string` | true | +| name | A queue manager name conforming to MQ restrictions. | `string` | true | +| display_name | A displayable name for the queue manager - limited only in length. | `string` | false | +| location | The locations in which the queue manager could be deployed. | `string` | true | +| size | The queue manager sizes of deployment available. Deployment of lite queue managers for aws_us_east_1 and aws_eu_west_1 locations is not available. | `string` | true | +| version | The MQ version of the queue manager. | `string` | false | +| name | The name of the application - conforming to MQ rules. | `string` | true | +| name | The shortname of the user that will be used as the IBM MQ administrator in interactions with a queue manager for this service instance. | `string` | true | +| email | The email of the user. | `string` | true | +| queue_manager_id | The id of the queue manager to retrieve its full details. | `string` | true | +| label | Certificate label in queue manager store. | `string` | true | + +## Outputs + +| Name | Description | +|------|-------------| +| mqcloud_queue_manager | mqcloud_queue_manager object | +| mqcloud_queue_manager_status | mqcloud_queue_manager_status object | +| mqcloud_application | mqcloud_application object | +| mqcloud_user | mqcloud_user object | +| mqcloud_truststore_certificate | mqcloud_truststore_certificate object | +| mqcloud_keystore_certificate | mqcloud_keystore_certificate object | diff --git a/examples/ibm-mqcloud/main.tf b/examples/ibm-mqcloud/main.tf new file mode 100644 index 0000000000..b89e08c72a --- /dev/null +++ b/examples/ibm-mqcloud/main.tf @@ -0,0 +1,103 @@ +provider "ibm" { + ibmcloud_api_key = var.ibmcloud_api_key +} + +// Provision mqcloud_queue_manager resource instance +resource "ibm_mqcloud_queue_manager" "mqcloud_queue_manager_instance" { + service_instance_guid = var.mqcloud_queue_manager_service_instance_guid + name = var.mqcloud_queue_manager_name + display_name = var.mqcloud_queue_manager_display_name + location = var.mqcloud_queue_manager_location + size = var.mqcloud_queue_manager_size + version = var.mqcloud_queue_manager_version +} + +// Provision mqcloud_application resource instance +resource "ibm_mqcloud_application" "mqcloud_application_instance" { + service_instance_guid = var.mqcloud_application_service_instance_guid + name = var.mqcloud_application_name +} + +// Provision mqcloud_user resource instance +resource "ibm_mqcloud_user" "mqcloud_user_instance" { + service_instance_guid = var.mqcloud_user_service_instance_guid + name = var.mqcloud_user_name + email = var.mqcloud_user_email +} + +// Provision mqcloud_keystore_certificate resource instance +resource "ibm_mqcloud_keystore_certificate" "mqcloud_keystore_certificate_instance" { + service_instance_guid = var.mqcloud_keystore_certificate_service_instance_guid + queue_manager_id = var.mqcloud_keystore_certificate_queue_manager_id + label = var.mqcloud_keystore_certificate_label +} + +// Provision mqcloud_truststore_certificate resource instance +resource "ibm_mqcloud_truststore_certificate" "mqcloud_truststore_certificate_instance" { + service_instance_guid = var.mqcloud_truststore_certificate_service_instance_guid + queue_manager_id = var.mqcloud_truststore_certificate_queue_manager_id + label = var.mqcloud_truststore_certificate_label +} + +// Data source is not linked to a resource instance +// Uncomment if an existing data source instance exists +/* +// Create mqcloud_queue_manager data source +data "ibm_mqcloud_queue_manager" "mqcloud_queue_manager_instance" { + service_instance_guid = var.mqcloud_queue_manager_service_instance_guid + + name = var.mqcloud_queue_manager_name +} +*/ + +// Data source is not linked to a resource instance +// Uncomment if an existing data source instance exists +/* +// Create mqcloud_queue_manager_status data source +data "ibm_mqcloud_queue_manager_status" "mqcloud_queue_manager_status_instance" { + service_instance_guid = var.mqcloud_queue_manager_status_service_instance_guid + queue_manager_id = var.mqcloud_queue_manager_status_queue_manager_id +} +*/ + +// Data source is not linked to a resource instance +// Uncomment if an existing data source instance exists +/* +// Create mqcloud_application data source +data "ibm_mqcloud_application" "mqcloud_application_instance" { + service_instance_guid = var.mqcloud_application_service_instance_guid + name = var.mqcloud_application_name +} +*/ + +// Data source is not linked to a resource instance +// Uncomment if an existing data source instance exists +/* +// Create mqcloud_user data source +data "ibm_mqcloud_user" "mqcloud_user_instance" { + service_instance_guid = var.mqcloud_user_service_instance_guid + name = var.mqcloud_user_name +} +*/ + +// Data source is not linked to a resource instance +// Uncomment if an existing data source instance exists +/* +// Create mqcloud_truststore_certificate data source +data "ibm_mqcloud_truststore_certificate" "mqcloud_truststore_certificate_instance" { + service_instance_guid = var.mqcloud_truststore_certificate_service_instance_guid + queue_manager_id = var.mqcloud_truststore_certificate_queue_manager_id + label = var.mqcloud_truststore_certificate_label +} +*/ + +// Data source is not linked to a resource instance +// Uncomment if an existing data source instance exists +/* +// Create mqcloud_keystore_certificate data source +data "ibm_mqcloud_keystore_certificate" "mqcloud_keystore_certificate_instance" { + service_instance_guid = var.mqcloud_keystore_certificate_service_instance_guid + queue_manager_id = var.mqcloud_keystore_certificate_queue_manager_id + label = var.mqcloud_keystore_certificate_label +} +*/ diff --git a/examples/ibm-mqcloud/outputs.tf b/examples/ibm-mqcloud/outputs.tf new file mode 100644 index 0000000000..ebd87da85e --- /dev/null +++ b/examples/ibm-mqcloud/outputs.tf @@ -0,0 +1,30 @@ +// This output allows mqcloud_queue_manager data to be referenced by other resources and the terraform CLI +// Modify this output if only certain data should be exposed +output "ibm_mqcloud_queue_manager" { + value = ibm_mqcloud_queue_manager.mqcloud_queue_manager_instance + description = "mqcloud_queue_manager resource instance" +} +// This output allows mqcloud_application data to be referenced by other resources and the terraform CLI +// Modify this output if only certain data should be exposed +output "ibm_mqcloud_application" { + value = ibm_mqcloud_application.mqcloud_application_instance + description = "mqcloud_application resource instance" +} +// This output allows mqcloud_user data to be referenced by other resources and the terraform CLI +// Modify this output if only certain data should be exposed +output "ibm_mqcloud_user" { + value = ibm_mqcloud_user.mqcloud_user_instance + description = "mqcloud_user resource instance" +} +// This output allows mqcloud_keystore_certificate data to be referenced by other resources and the terraform CLI +// Modify this output if only certain data should be exposed +output "ibm_mqcloud_keystore_certificate" { + value = ibm_mqcloud_keystore_certificate.mqcloud_keystore_certificate_instance + description = "mqcloud_keystore_certificate resource instance" +} +// This output allows mqcloud_truststore_certificate data to be referenced by other resources and the terraform CLI +// Modify this output if only certain data should be exposed +output "ibm_mqcloud_truststore_certificate" { + value = ibm_mqcloud_truststore_certificate.mqcloud_truststore_certificate_instance + description = "mqcloud_truststore_certificate resource instance" +} diff --git a/examples/ibm-mqcloud/variables.tf b/examples/ibm-mqcloud/variables.tf new file mode 100644 index 0000000000..dba4d0fff0 --- /dev/null +++ b/examples/ibm-mqcloud/variables.tf @@ -0,0 +1,203 @@ +variable "ibmcloud_api_key" { + description = "IBM Cloud API key" + type = string +} + +// Resource arguments for mqcloud_queue_manager +variable "mqcloud_queue_manager_service_instance_guid" { + description = "The GUID that uniquely identifies the MQ on Cloud service instance." + type = string + default = "Service Instance ID" +} +variable "mqcloud_queue_manager_name" { + description = "A queue manager name conforming to MQ restrictions." + type = string + default = "testqm" +} +variable "mqcloud_queue_manager_display_name" { + description = "A displayable name for the queue manager - limited only in length." + type = string + default = "A test queue manager" +} +variable "mqcloud_queue_manager_location" { + description = "The locations in which the queue manager could be deployed." + type = string + default = "reserved-eu-fr-cluster-f884" +} +variable "mqcloud_queue_manager_size" { + description = "The queue manager sizes of deployment available. Deployment of lite queue managers for aws_us_east_1 and aws_eu_west_1 locations is not available." + type = string + default = "lite" +} +variable "mqcloud_queue_manager_version" { + description = "The MQ version of the queue manager." + type = string + default = "9.3.2_2" +} + +// Resource arguments for mqcloud_application +variable "mqcloud_application_service_instance_guid" { + description = "The GUID that uniquely identifies the MQ on Cloud service instance." + type = string + default = "Service Instance ID" +} +variable "mqcloud_application_name" { + description = "The name of the application - conforming to MQ rules." + type = string + default = "test-app" +} + +// Resource arguments for mqcloud_user +variable "mqcloud_user_service_instance_guid" { + description = "The GUID that uniquely identifies the MQ on Cloud service instance." + type = string + default = "Service Instance ID" +} + +// Data source arguments for mqcloud_application +variable "mqcloud_application_service_instance_guid" { + description = "The GUID that uniquely identifies the MQ on Cloud service instance." + type = string + default = "Service Instance ID" +} +variable "mqcloud_user_name" { + description = "The shortname of the user that will be used as the IBM MQ administrator in interactions with a queue manager for this service instance." + type = string + default = "name" +} + +variable "mqcloud_application_name" { + description = "The name of the application - conforming to MQ rules." + type = string + default = "name" +} +variable "mqcloud_user_name" { + description = "The shortname of the user that will be used as the IBM MQ administrator in interactions with a queue manager for this service instance." + type = string + default = "t0scie98o57a" +} +variable "mqcloud_user_email" { + description = "The email of the user." + type = string + default = "user@example.com" +} + +// Resource arguments for mqcloud_keystore_certificate +variable "mqcloud_keystore_certificate_service_instance_guid" { + description = "The GUID that uniquely identifies the MQ on Cloud service instance." + type = string + default = "Service Instance ID" +} +variable "mqcloud_keystore_certificate_queue_manager_id" { + description = "The id of the queue manager to retrieve its full details." + type = string + default = "Queue Manager ID" +} +variable "mqcloud_keystore_certificate_label" { + description = "Certificate label in queue manager store." + type = string + default = "label" +} + +// Resource arguments for mqcloud_truststore_certificate +variable "mqcloud_truststore_certificate_service_instance_guid" { + description = "The GUID that uniquely identifies the MQ on Cloud service instance." + type = string + default = "Service Instance ID" +} +variable "mqcloud_truststore_certificate_queue_manager_id" { + description = "The id of the queue manager to retrieve its full details." + type = string + default = "Queue Manager ID" +} + +variable "mqcloud_truststore_certificate_label" { + description = "Certificate label in queue manager store." + type = string + default = "label" +} + +// Data source arguments for mqcloud_queue_manager +variable "mqcloud_queue_manager_service_instance_guid" { + description = "The GUID that uniquely identifies the MQ on Cloud service instance." + type = string + default = "Service Instance ID" +} + +variable "mqcloud_queue_manager_name" { + description = "A queue manager name conforming to MQ restrictions." + type = string + default = "name" +} + +// Data source arguments for mqcloud_queue_manager_status +variable "mqcloud_queue_manager_status_service_instance_guid" { + description = "The GUID that uniquely identifies the MQ on Cloud service instance." + type = string + default = "Service Instance ID" +} +variable "mqcloud_queue_manager_status_queue_manager_id" { + description = "The id of the queue manager to retrieve its full details." + type = string + default = "Queue Manager ID" +} + +// Data source arguments for mqcloud_application +variable "mqcloud_application_service_instance_guid" { + description = "The GUID that uniquely identifies the MQ on Cloud service instance." + type = string + default = "Service Instance ID" +} + +variable "mqcloud_application_name" { + description = "The name of the application - conforming to MQ rules." + type = string + default = "name" +} + +// Data source arguments for mqcloud_user +variable "mqcloud_user_service_instance_guid" { + description = "The GUID that uniquely identifies the MQ on Cloud service instance." + type = string + default = "Service Instance ID" +} + +variable "mqcloud_user_name" { + description = "The shortname of the user that will be used as the IBM MQ administrator in interactions with a queue manager for this service instance." + type = string + default = "name" +} + +// Data source arguments for mqcloud_truststore_certificate +variable "mqcloud_truststore_certificate_service_instance_guid" { + description = "The GUID that uniquely identifies the MQ on Cloud service instance." + type = string + default = "Service Instance ID" +} +variable "mqcloud_truststore_certificate_queue_manager_id" { + description = "The id of the queue manager to retrieve its full details." + type = string + default = "Queue Manager ID" +} +variable "mqcloud_truststore_certificate_label" { + description = "Certificate label in queue manager store." + type = string + default = "label" +} + +// Data source arguments for mqcloud_keystore_certificate +variable "mqcloud_keystore_certificate_service_instance_guid" { + description = "The GUID that uniquely identifies the MQ on Cloud service instance." + type = string + default = "Service Instance ID" +} +variable "mqcloud_keystore_certificate_queue_manager_id" { + description = "The id of the queue manager to retrieve its full details." + type = string + default = "Queue Manager ID" +} +variable "mqcloud_keystore_certificate_label" { + description = "Certificate label in queue manager store." + type = string + default = "label" +} diff --git a/examples/ibm-mqcloud/versions.tf b/examples/ibm-mqcloud/versions.tf new file mode 100644 index 0000000000..54c9d03e8d --- /dev/null +++ b/examples/ibm-mqcloud/versions.tf @@ -0,0 +1,9 @@ +terraform { + required_version = ">= 1.0" + required_providers { + ibm = { + source = "IBM-Cloud/ibm" + version = "1.52.0-beta0" + } + } +} diff --git a/go.mod b/go.mod index 55322cd7a7..f7c431a96b 100644 --- a/go.mod +++ b/go.mod @@ -44,7 +44,7 @@ require ( github.com/google/uuid v1.3.0 github.com/hashicorp/go-uuid v1.0.3 github.com/hashicorp/go-version v1.6.0 - github.com/hashicorp/terraform-plugin-sdk/v2 v2.24.0 + github.com/hashicorp/terraform-plugin-sdk/v2 v2.29.0 github.com/jinzhu/copier v0.3.2 github.com/minsikl/netscaler-nitro-go v0.0.0-20170827154432-5b14ce3643e3 github.com/mitchellh/go-homedir v1.1.0 @@ -53,7 +53,7 @@ require ( github.com/pkg/errors v0.9.1 github.com/rook/rook v1.11.4 github.com/softlayer/softlayer-go v1.0.3 - golang.org/x/crypto v0.14.0 + golang.org/x/crypto v0.16.0 gopkg.in/yaml.v3 v3.0.1 gotest.tools v2.2.0+incompatible k8s.io/api v0.26.3 @@ -62,6 +62,7 @@ require ( ) require ( + github.com/IBM/mqcloud-go-sdk v0.0.0-20231207105140-14d858932788 github.com/IBM/sarama v1.41.2 k8s.io/utils v0.0.0-20230313181309-38a27ef9d749 sigs.k8s.io/controller-runtime v0.14.1 @@ -72,15 +73,17 @@ require ( cloud.google.com/go/monitoring v1.13.0 // indirect github.com/Logicalis/asn1 v0.0.0-20190312173541-d60463189a56 // indirect github.com/PromonLogicalis/asn1 v0.0.0-20190312173541-d60463189a56 // indirect + github.com/ProtonMail/go-crypto v0.0.0-20230828082145-3c4c8a2d2371 // indirect github.com/agext/levenshtein v1.2.2 // indirect github.com/andres-erbsen/clock v0.0.0-20160526145045-9e14626cd129 // indirect github.com/apex/log v1.9.0 // indirect - github.com/apparentlymart/go-textseg/v13 v13.0.0 // indirect + github.com/apparentlymart/go-textseg/v15 v15.0.0 // indirect github.com/armon/go-metrics v0.4.1 // indirect github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2 // indirect github.com/beorn7/perks v1.0.1 // indirect github.com/cenkalti/backoff/v3 v3.2.2 // indirect github.com/cespare/xxhash/v2 v2.2.0 // indirect + github.com/cloudflare/circl v1.3.3 // indirect github.com/cloudfoundry/jibber_jabber v0.0.0-20151120183258-bcc4c8345a21 // indirect github.com/coreos/go-systemd v0.0.0-20191104093116-d3cd4ed1dbcf // indirect github.com/coreos/pkg v0.0.0-20220810130054-c7d1c02cb6cf // indirect @@ -111,7 +114,7 @@ require ( github.com/go-ozzo/ozzo-validation/v4 v4.3.0 // indirect github.com/go-playground/locales v0.14.1 // indirect github.com/go-playground/universal-translator v0.18.1 // indirect - github.com/go-playground/validator/v10 v10.15.5 // indirect + github.com/go-playground/validator/v10 v10.16.0 // indirect github.com/gogo/protobuf v1.3.2 // indirect github.com/golang/protobuf v1.5.3 // indirect github.com/golang/snappy v0.0.4 // indirect @@ -125,30 +128,30 @@ require ( github.com/hashicorp/go-hclog v1.5.0 // indirect github.com/hashicorp/go-immutable-radix v1.3.1 // indirect github.com/hashicorp/go-multierror v1.1.1 // indirect - github.com/hashicorp/go-plugin v1.5.0 // indirect + github.com/hashicorp/go-plugin v1.5.1 // indirect github.com/hashicorp/go-retryablehttp v0.7.4 // indirect github.com/hashicorp/go-rootcerts v1.0.2 // indirect github.com/hashicorp/go-secure-stdlib/parseutil v0.1.7 // indirect github.com/hashicorp/go-secure-stdlib/strutil v0.1.2 // indirect github.com/hashicorp/go-sockaddr v1.0.2 // indirect github.com/hashicorp/golang-lru v0.5.4 // indirect - github.com/hashicorp/hc-install v0.4.0 // indirect + github.com/hashicorp/hc-install v0.6.1 // indirect github.com/hashicorp/hcl v1.0.1-vault-5 // indirect - github.com/hashicorp/hcl/v2 v2.14.1 // indirect + github.com/hashicorp/hcl/v2 v2.19.1 // indirect github.com/hashicorp/logutils v1.0.0 // indirect - github.com/hashicorp/terraform-exec v0.17.3 // indirect - github.com/hashicorp/terraform-json v0.14.0 // indirect - github.com/hashicorp/terraform-plugin-go v0.14.0 // indirect - github.com/hashicorp/terraform-plugin-log v0.7.0 // indirect - github.com/hashicorp/terraform-registry-address v0.0.0-20220623143253-7d51757b572c // indirect - github.com/hashicorp/terraform-svchost v0.0.0-20200729002733-f050f53b9734 // indirect + github.com/hashicorp/terraform-exec v0.19.0 // indirect + github.com/hashicorp/terraform-json v0.17.1 // indirect + github.com/hashicorp/terraform-plugin-go v0.19.0 // indirect + github.com/hashicorp/terraform-plugin-log v0.9.0 // indirect + github.com/hashicorp/terraform-registry-address v0.2.2 // indirect + github.com/hashicorp/terraform-svchost v0.1.1 // indirect github.com/hashicorp/vault v1.13.7 // indirect github.com/hashicorp/vault/api v1.9.2 // indirect github.com/hashicorp/vault/api/auth/approle v0.3.0 // indirect github.com/hashicorp/vault/sdk v0.10.0 // indirect github.com/hashicorp/yamux v0.1.1 // indirect github.com/hokaccha/go-prettyjson v0.0.0-20170213120834-e6b9231a2b1c // indirect - github.com/imdario/mergo v0.3.13 // indirect + github.com/imdario/mergo v0.3.15 // indirect github.com/jarcoal/httpmock v1.0.7 // indirect github.com/jcmturner/aescts/v2 v2.0.0 // indirect github.com/jcmturner/dnsutils/v2 v2.0.0 // indirect @@ -196,19 +199,22 @@ require ( github.com/stretchr/objx v0.5.0 // indirect github.com/stretchr/testify v1.8.4 // indirect github.com/vmihailenco/msgpack v4.0.4+incompatible // indirect - github.com/vmihailenco/msgpack/v4 v4.3.12 // indirect - github.com/vmihailenco/tagparser v0.1.1 // indirect - github.com/zclconf/go-cty v1.11.0 // indirect + github.com/vmihailenco/msgpack/v5 v5.3.5 // indirect + github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect + github.com/zclconf/go-cty v1.14.1 // indirect go.mongodb.org/mongo-driver v1.12.1 // indirect go.opentelemetry.io/otel v1.14.0 // indirect go.opentelemetry.io/otel/trace v1.14.0 // indirect go.uber.org/ratelimit v0.2.0 // indirect - golang.org/x/net v0.17.0 // indirect + golang.org/x/mod v0.14.0 // indirect + golang.org/x/net v0.19.0 // indirect golang.org/x/oauth2 v0.7.0 // indirect - golang.org/x/sys v0.13.0 // indirect - golang.org/x/term v0.13.0 // indirect - golang.org/x/text v0.13.0 // indirect + golang.org/x/sync v0.5.0 // indirect + golang.org/x/sys v0.15.0 // indirect + golang.org/x/term v0.15.0 // indirect + golang.org/x/text v0.14.0 // indirect golang.org/x/time v0.3.0 // indirect + golang.org/x/tools v0.16.0 // indirect gomodules.xyz/jsonpatch/v2 v2.2.0 // indirect google.golang.org/appengine v1.6.7 // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20230525234030-28d5490b6b19 // indirect diff --git a/go.sum b/go.sum index 30e5ffdf8e..8df8dccea4 100644 --- a/go.sum +++ b/go.sum @@ -48,6 +48,7 @@ cloud.google.com/go/storage v1.6.0/go.mod h1:N7U0C8pVQ/+NIKOBQyamJIeKQKkZ+mxpohl cloud.google.com/go/storage v1.8.0/go.mod h1:Wv1Oy7z6Yz3DshWRJFhqM/UCfaWIRTdp0RXyy7KQOVs= cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9ullr3+Kg0= code.cloudfoundry.org/gofileutils v0.0.0-20170111115228-4d0c80011a0f/go.mod h1:sk5LnIjB/nIEU7yP5sDQExVm62wu0pBh3yrElngUisI= +dario.cat/mergo v1.0.0 h1:AGCNq9Evsj31mOgNPcLyXc+4PNABt905YmuqPYYpBWk= dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= git.apache.org/thrift.git v0.12.0/go.mod h1:fPE2ZNJGynbRyZ4dJvy6G277gSllfV2HJqblrnkyeyg= github.com/Azure/azure-sdk-for-go v36.2.0+incompatible/go.mod h1:9XXNKU+eRnpl9moKnB4QOLf1HestfXbmab5FXxiDBjc= @@ -155,6 +156,8 @@ github.com/IBM/ibm-hpcs-uko-sdk v0.0.20-beta/go.mod h1:MLVNHMYoKsvovJZ4v1gQCpIYt github.com/IBM/keyprotect-go-client v0.5.1/go.mod h1:5TwDM/4FRJq1ZOlwQL1xFahLWQ3TveR88VmL1u3njyI= github.com/IBM/keyprotect-go-client v0.12.2 h1:Cjxcqin9Pl0xz3MnxdiVd4v/eIa79xL3hQpSbwOr/DQ= github.com/IBM/keyprotect-go-client v0.12.2/go.mod h1:yr8h2noNgU8vcbs+vhqoXp3Lmv73PI0zAc6VMgFvWwM= +github.com/IBM/mqcloud-go-sdk v0.0.0-20231207105140-14d858932788 h1:cIT0YSzqMGqxM3OJQx1gp4gtYYy9U35O0tVdcFHOgwc= +github.com/IBM/mqcloud-go-sdk v0.0.0-20231207105140-14d858932788/go.mod h1:R4NBbDMygpHiFywUnOdV0UfBZap4HcHa3QXLlACr9TU= github.com/IBM/networking-go-sdk v0.42.2 h1:caqjx4jyFHi10Vlf3skHvlL6K3YJRVstsmCBmvdyqkA= github.com/IBM/networking-go-sdk v0.42.2/go.mod h1:lTUZwtUkMANMnrLHFIgRhHrkBfwASY/Iho1fabaPHxo= github.com/IBM/platform-services-go-sdk v0.54.0 h1:WjHWm9ZAJvlq07E1WXXtEe+d/B0sazWD6cEWVT7EMLU= @@ -186,8 +189,6 @@ github.com/Masterminds/semver/v3 v3.1.1 h1:hLg3sBzpNErnxhQtUy/mmLR2I9foDujNK030I github.com/Masterminds/sprig v2.22.0+incompatible h1:z4yfnGrZ7netVz+0EDJ0Wi+5VZCSYp4Z0m2dk6cEM60= github.com/Masterminds/sprig/v3 v3.2.1 h1:n6EPaDyLSvCEa3frruQvAiHuNp2dhBlMSmkEr+HuzGc= github.com/Microsoft/go-winio v0.4.13/go.mod h1:qXqCSQ3Xa7+6tgxaGTIe4Kpcdsi+P8jBhyzoq1bpyYA= -github.com/Microsoft/go-winio v0.4.14/go.mod h1:qXqCSQ3Xa7+6tgxaGTIe4Kpcdsi+P8jBhyzoq1bpyYA= -github.com/Microsoft/go-winio v0.4.16/go.mod h1:XB6nPKklQyQ7GC9LdcBEcBl8PF76WugXOPRXwdLnMv0= github.com/Microsoft/go-winio v0.6.1 h1:9/kr64B9VUZrLm5YYwbGtUJnMgqWVOdUAXu6Migciow= github.com/NYTimes/gziphandler v0.0.0-20170623195520-56545f4a5d46/go.mod h1:3wb06e3pkSAbeQ52E9H9iFoQsEEwGN64994WTCIhntQ= github.com/NYTimes/gziphandler v1.1.1 h1:ZUDjpQae29j0ryrS0u/B8HZfJBtBQHjqw2rQ2cqUQ3I= @@ -196,8 +197,8 @@ github.com/Nvveen/Gotty v0.0.0-20120604004816-cd527374f1e5/go.mod h1:lmUJ/7eu/Q8 github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU= github.com/PromonLogicalis/asn1 v0.0.0-20190312173541-d60463189a56 h1:zL3Ph7RCZadAPb7QV0gMIDmjuZHFawNhoPZ5erh6TRw= github.com/PromonLogicalis/asn1 v0.0.0-20190312173541-d60463189a56/go.mod h1:nE9BGpMlMfM9Z3U+P+mWtcHNDwHcGctalMx1VTkODAY= -github.com/ProtonMail/go-crypto v0.0.0-20210428141323-04723f9f07d7/go.mod h1:z4/9nQmJSSwwds7ejkxaJwO37dru3geImFUdJlaLzQo= -github.com/ProtonMail/go-crypto v0.0.0-20230626094100-7e9e0395ebec h1:vV3RryLxt42+ZIVOFbYJCH1jsZNTNmj2NYru5zfx+4E= +github.com/ProtonMail/go-crypto v0.0.0-20230828082145-3c4c8a2d2371 h1:kkhsdkhsCvIsutKu5zLMgWtgh9YxGCNAw8Ad8hjwfYg= +github.com/ProtonMail/go-crypto v0.0.0-20230828082145-3c4c8a2d2371/go.mod h1:EjAoLdwvbIOoOQr3ihjnSoLZRtE8azugULFRteWMNc0= github.com/PuerkitoBio/purell v1.0.0/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0= github.com/PuerkitoBio/purell v1.1.0/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0= github.com/PuerkitoBio/purell v1.1.1/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0= @@ -211,8 +212,7 @@ github.com/Shopify/sarama v1.19.0/go.mod h1:FVkBWblsNy7DGZRfXLU0O9RCGt5g3g3yEuWX github.com/Shopify/toxiproxy v2.1.4+incompatible/go.mod h1:OXgGpZ6Cli1/URJOF1DMxUHB2q5Ap20/P/eIdh4G0pI= github.com/StackExchange/wmi v0.0.0-20180116203802-5d049714c4a6/go.mod h1:3eOhrUMpNV+6aFIbp5/iudMxNCF27Vw2OZgy4xEx0Fg= github.com/abdullin/seq v0.0.0-20160510034733-d5467c17e7af/go.mod h1:5Jv4cbFiHJMsVxt52+i0Ha45fjshj6wxYr1r19tB9bw= -github.com/acomagu/bufpipe v1.0.3 h1:fxAGrHZTgQ9w5QqVItgzwj235/uYZYgbXitB+dLupOk= -github.com/acomagu/bufpipe v1.0.3/go.mod h1:mxdxdup/WdsKVreO5GpW4+M/1CE2sMG4jeGJ2sYmHc4= +github.com/acomagu/bufpipe v1.0.4 h1:e3H4WUzM3npvo5uv95QuJM3cQspFNtFBzvJ2oNjKIDQ= github.com/agext/levenshtein v1.2.2 h1:0S/Yg6LYmFJ5stwQeRp6EeOcCbj7xiqQSdNelsXvaqE= github.com/agext/levenshtein v1.2.2/go.mod h1:JEDfjyjHDjOF/1e4FlBE/PkbqA9OfWu2ki2W0IB5558= github.com/agnivade/levenshtein v1.0.1/go.mod h1:CURSv5d9Uaml+FovSIICkLbAUZ9S4RqaHDIsdSBg7lM= @@ -232,7 +232,6 @@ github.com/aliyun/aliyun-oss-go-sdk v0.0.0-20190307165228-86c17b95fcd5/go.mod h1 github.com/andres-erbsen/clock v0.0.0-20160526145045-9e14626cd129 h1:MzBOUgng9orim59UnfUTLRjMpd09C5uEVQ6RPGeCaVI= github.com/andres-erbsen/clock v0.0.0-20160526145045-9e14626cd129/go.mod h1:rFgpPQZYZ8vdbc+48xibu8ALc3yeyd64IhHS+PU6Yyg= github.com/andreyvit/diff v0.0.0-20170406064948-c7f18ee00883/go.mod h1:rCTlJbsFo29Kk6CurOXKm700vrz8f0KW0JNfpkRJY/8= -github.com/anmitsu/go-shlex v0.0.0-20161002113705-648efa622239/go.mod h1:2FmKhYUyUczH0OGQWaF5ceTx0UBShxjsH6f8oGKYe2c= github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY= github.com/apache/openwhisk-client-go v0.0.0-20200201143223-a804fb82d105 h1:k1wP1gZMrNJeXTz6a+3010NKC/ZvSffk07BzrLmYrmc= github.com/apache/openwhisk-client-go v0.0.0-20200201143223-a804fb82d105/go.mod h1:jLLKYP7+1+LFlIJW1n9U1gqeveLM1HIwa4ZHNOFxjPw= @@ -244,11 +243,9 @@ github.com/aphistic/golf v0.0.0-20180712155816-02c07f170c5a/go.mod h1:3NqKYiepwy github.com/aphistic/sweet v0.2.0/go.mod h1:fWDlIh/isSE9n6EPsRmC0det+whmX6dJid3stzu0Xys= github.com/apparentlymart/go-cidr v1.1.0 h1:2mAhrMoF+nhXqxTzSZMUzDHkLjmIHC+Zzn4tdgBZjnU= github.com/apparentlymart/go-cidr v1.1.0/go.mod h1:EBcsNrHc3zQeuaeCeCtQruQm+n9/YjEn/vI25Lg7Gwc= -github.com/apparentlymart/go-dump v0.0.0-20190214190832-042adf3cf4a0 h1:MzVXffFUye+ZcSR6opIgz9Co7WcDx6ZcY+RjfFHoA0I= -github.com/apparentlymart/go-textseg v1.0.0/go.mod h1:z96Txxhf3xSFMPmb5X/1W05FF/Nj9VFpLOpjS5yuumk= github.com/apparentlymart/go-textseg/v12 v12.0.0/go.mod h1:S/4uRK2UtaQttw1GenVJEynmyUenKwP++x/+DdGV/Ec= -github.com/apparentlymart/go-textseg/v13 v13.0.0 h1:Y+KvPE1NYz0xl601PVImeQfFyEy6iT90AvPUL1NNfNw= -github.com/apparentlymart/go-textseg/v13 v13.0.0/go.mod h1:ZK2fH7c4NqDTLtiYLvIkEghdlcqw7yxLeM89kiTRPUo= +github.com/apparentlymart/go-textseg/v15 v15.0.0 h1:uYvfpb3DyLSCGWnctWKGj857c6ew1u1fNQOlOtuGxQY= +github.com/apparentlymart/go-textseg/v15 v15.0.0/go.mod h1:K8XmNZdhEBkdlyDdvbmmsvpAG721bKi0joRfFdHIWJ4= github.com/apple/foundationdb/bindings/go v0.0.0-20190411004307-cd5c9d91fad2/go.mod h1:OMVSB21p9+xQUIqlGizHPZfjK+SHws1ht+ZytVDoz9U= github.com/armon/circbuf v0.0.0-20150827004946-bbbad097214e/go.mod h1:3U/XgcO3hCbHZ8TKRvWD2dDTCfh9M9ya+I9JpbB7O8o= github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8= @@ -264,7 +261,6 @@ github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj github.com/armon/go-radix v1.0.0 h1:F4z6KzEeeQIMeLFa97iZU6vupzoecKdU5TX24SNppXI= github.com/armon/go-radix v1.0.0/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8= github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5 h1:0CwZNZbxp69SHPdPJAN/hZIm0C4OItdklCFmMRWYpio= -github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5/go.mod h1:wHh0iHkYZB8zMSxRWpUBQtwG5a7fFgvEO+odwuTv2gs= github.com/asaskevich/govalidator v0.0.0-20180720115003-f9ffefc3facf/go.mod h1:lB+ZfQJz7igIIfQNfa7Ml4HSf2uFQQRzpGGRXenZAgY= github.com/asaskevich/govalidator v0.0.0-20190424111038-f61b66f89f4a/go.mod h1:lB+ZfQJz7igIIfQNfa7Ml4HSf2uFQQRzpGGRXenZAgY= github.com/asaskevich/govalidator v0.0.0-20200108200545-475eaeb16496/go.mod h1:oGkLhpf+kjZl6xBf758TQhh5XrAeiJv/7FRz/2spLIg= @@ -297,6 +293,7 @@ github.com/boombuler/barcode v1.0.1 h1:NDBbPmhS+EqABEs5Kg3n/5ZNjy73Pz7SIV+KCeqyX github.com/briankassouf/jose v0.9.2-0.20180619214549-d2569464773f/go.mod h1:HQhVmdUf7dBNwIIdBTivnCDxcf6IZY3/zrb+uKSJz6Y= github.com/bufbuild/protocompile v0.4.0 h1:LbFKd2XowZvQ/kajzguUp2DC9UEIQhIq77fZZlaQsNA= github.com/buger/jsonparser v1.1.1/go.mod h1:6RYKKt7H4d4+iWqouImQ9R2FZql3VbhNgx27UK13J/0= +github.com/bwesterb/go-ristretto v1.2.3/go.mod h1:fUIoIZaG73pV5biE2Blr2xEzDoMj7NFEuV9ekS419A0= github.com/cenkalti/backoff v2.2.1+incompatible h1:tNowT99t7UNflLxfYYSlKYsBpXdEet03Pg2g16Swow4= github.com/cenkalti/backoff v2.2.1+incompatible/go.mod h1:90ReRw6GdpyfrHakVjL/QHaoyV4aDUVVkXQJJJ3NXXM= github.com/cenkalti/backoff/v3 v3.0.0/go.mod h1:cIeZDE3IrqwwJl6VUwCN6trj1oXrTS4rc0ij+ULvLYs= @@ -320,6 +317,7 @@ github.com/circonus-labs/circonusllhist v0.1.3 h1:TJH+oke8D16535+jHExHj4nQvzlZrj github.com/circonus-labs/circonusllhist v0.1.3/go.mod h1:kMXHVDlOchFAehlya5ePtbp5jckzBHf4XRpQvBOLI+I= github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= github.com/cloudflare/circl v1.3.3 h1:fE/Qz0QdIGqeWfnwq0RE0R7MI51s0M2E4Ga9kq5AEMs= +github.com/cloudflare/circl v1.3.3/go.mod h1:5XYMA4rFBvNIrhs50XuiBJ15vF2pZn4nnUKZrLbUZFA= github.com/cloudfoundry-community/go-cfclient v0.0.0-20190201205600-f136f9222381/go.mod h1:e5+USP2j8Le2M0Jo3qKPFnNhuo1wueU4nWHCXBOfQ14= github.com/cloudfoundry/jibber_jabber v0.0.0-20151120183258-bcc4c8345a21 h1:tuijfIjZyjZaHq9xDUh0tNitwXshJpbLkqMOJv4H3do= github.com/cloudfoundry/jibber_jabber v0.0.0-20151120183258-bcc4c8345a21/go.mod h1:po7NpZ/QiTKzBKyrsEAxwnTamCoh8uDk/egRpQ7siIc= @@ -356,6 +354,7 @@ github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:ma github.com/cpuguy83/go-md2man/v2 v2.0.0/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= github.com/creack/pty v1.1.7/go.mod h1:lj5s0c3V2DBrqTV7llrYr5NG6My20zk30Fl46Y7DoTY= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= +github.com/cyphar/filepath-securejoin v0.2.4 h1:Ugdm7cg7i6ZK6x3xDF1oEu1nfkyfH53EtKeQYTC3kyg= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM= @@ -405,8 +404,7 @@ github.com/emicklei/go-restful v0.0.0-20170410110728-ff4f55a20633/go.mod h1:otzb github.com/emicklei/go-restful v2.9.5+incompatible/go.mod h1:otzb+WCGbkyDHkqmQmT5YD2WR4BBwUdeQoFo8l/7tVs= github.com/emicklei/go-restful/v3 v3.10.0 h1:X4gma4HM7hFm6WMeAsTfqA0GOfdNoCzBIkHGoRLGXuM= github.com/emicklei/go-restful/v3 v3.10.0/go.mod h1:6n3XBCmQQb25CM2LCACGz8ukIrRry+4bhvbpWn3mrbc= -github.com/emirpasic/gods v1.12.0 h1:QAUIPSaCu4G+POclxeqb3F+WPpdKqFGlw36+yOzGlrg= -github.com/emirpasic/gods v1.12.0/go.mod h1:YfzfFFoVP/catgzJb4IKIqXjX78Ha8FMSDh3ymbK86o= +github.com/emirpasic/gods v1.18.1 h1:FXtiHYKDGKCW2KzwZKx0iC0PQmdlorYgdFG9jPXJ1Bc= github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= @@ -432,7 +430,6 @@ github.com/fatih/color v1.15.0 h1:kOqh6YHBtK8aywxGerMG2Eq3H6Qgoqeo13Bk2Mv/nBs= github.com/fatih/color v1.15.0/go.mod h1:0h5ZqXfHYED7Bhv2ZJamyIOUej9KtShiJESRwBDUSsw= github.com/fatih/structs v1.1.0/go.mod h1:9NiDSp5zOcgEDl+j00MP/WkGVPOlPRLejGD8Ga6PJ7M= github.com/flowstack/go-jsonschema v0.1.1/go.mod h1:yL7fNggx1o8rm9RlgXv7hTBWxdBM0rVwpMwimd3F3N0= -github.com/flynn/go-shlex v0.0.0-20150515145356-3f9db97f8568/go.mod h1:xEzjJPgXI435gkrCt3MPfRiAkVrwSbHsst4LCFVfpJc= github.com/form3tech-oss/jwt-go v3.2.2+incompatible/go.mod h1:pbq4aXjuKjdthFRnoDwaVPLA+WlJuPGy+QneDUgJi2k= github.com/form3tech-oss/jwt-go v3.2.3+incompatible/go.mod h1:pbq4aXjuKjdthFRnoDwaVPLA+WlJuPGy+QneDUgJi2k= github.com/fortytw2/leaktest v1.3.0 h1:u8491cBMTQ8ft8aeV+adlcytMZylmA5nnwwkRZjI8vw= @@ -456,19 +453,13 @@ github.com/ghodss/yaml v0.0.0-20150909031657-73d445a93680/go.mod h1:4dBDuWmgqj2H github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= github.com/ghodss/yaml v1.0.1-0.20190212211648-25d852aebe32 h1:Mn26/9ZMNWSw9C9ERFA1PUxfmGpolnw2v0bKOREu5ew= github.com/ghodss/yaml v1.0.1-0.20190212211648-25d852aebe32/go.mod h1:GIjDIg/heH5DOkXY3YJ/wNhfHsQHoXGjl8G8amsYQ1I= -github.com/gliderlabs/ssh v0.2.2/go.mod h1:U7qILu1NlMHj9FlMhZLlkCdDnU1DBEAqr0aevW3Awn0= github.com/globalsign/mgo v0.0.0-20180905125535-1ca0a4f7cbcb/go.mod h1:xkRDCp4j0OGD1HRkm4kmhM+pmpv3AKq5SU7GMg4oO/Q= github.com/globalsign/mgo v0.0.0-20181015135952-eeefdecb41b8/go.mod h1:xkRDCp4j0OGD1HRkm4kmhM+pmpv3AKq5SU7GMg4oO/Q= github.com/go-asn1-ber/asn1-ber v1.3.1/go.mod h1:hEBeB/ic+5LoWskz+yKT7vGhhPYkProFKoKdwZRWMe0= github.com/go-errors/errors v1.0.1/go.mod h1:f4zRHt4oKfwPJE5k8C9vpYG+aDHdBFUsgrm6/TyX73Q= -github.com/go-git/gcfg v1.5.0 h1:Q5ViNfGF8zFgyJWPqYwA7qGFoMTEiBmdlkcfRmpIMa4= -github.com/go-git/gcfg v1.5.0/go.mod h1:5m20vg6GwYabIxaOonVkTdrILxQMpEShl1xiMF4ua+E= -github.com/go-git/go-billy/v5 v5.2.0/go.mod h1:pmpqyWchKfYfrkb/UVH4otLvyi/5gJlGI4Hb3ZqZ3W0= -github.com/go-git/go-billy/v5 v5.3.1 h1:CPiOUAzKtMRvolEKw+bG1PLRpT7D3LIs3/3ey4Aiu34= -github.com/go-git/go-billy/v5 v5.3.1/go.mod h1:pmpqyWchKfYfrkb/UVH4otLvyi/5gJlGI4Hb3ZqZ3W0= -github.com/go-git/go-git-fixtures/v4 v4.2.1/go.mod h1:K8zd3kDUAykwTdDCr+I0per6Y6vMiRR/nnVTBtavnB0= -github.com/go-git/go-git/v5 v5.4.2 h1:BXyZu9t0VkbiHtqrsvdq39UDhGJTl1h55VW6CSC4aY4= -github.com/go-git/go-git/v5 v5.4.2/go.mod h1:gQ1kArt6d+n+BGd+/B/I74HwRTLhth2+zti4ihgckDc= +github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 h1:+zs/tPmkDkHx3U66DAb0lQFJrpS6731Oaa12ikc+DiI= +github.com/go-git/go-billy/v5 v5.5.0 h1:yEY4yhzCDuMGSv83oGxiBotRzhwhNr8VZyphhiu+mTU= +github.com/go-git/go-git/v5 v5.9.0 h1:cD9SFA7sHVRdJ7AYck1ZaAa/yeuBvGPxwXDL8cxrObY= github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= @@ -596,8 +587,8 @@ github.com/go-playground/universal-translator v0.17.0/go.mod h1:UkSxE5sNxxRwHyU+ github.com/go-playground/universal-translator v0.18.0/go.mod h1:UvRDBj+xPUEGrFYl+lu/H90nyDXpg0fqeB/AQUGNTVA= github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJnYK9S473LQFuzCbDbfSFY= github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY= -github.com/go-playground/validator/v10 v10.15.5 h1:LEBecTWb/1j5TNY1YYG2RcOUN3R7NLylN+x8TTueE24= -github.com/go-playground/validator/v10 v10.15.5/go.mod h1:9iXMNT7sEkjXb0I+enO7QXmzG6QCsPWY4zveKFVRSyU= +github.com/go-playground/validator/v10 v10.16.0 h1:x+plE831WK4vaKHO/jpgUGsvLKIqRRkz6M78GuJAfGE= +github.com/go-playground/validator/v10 v10.16.0/go.mod h1:9iXMNT7sEkjXb0I+enO7QXmzG6QCsPWY4zveKFVRSyU= github.com/go-sql-driver/mysql v1.4.1/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w= github.com/go-sql-driver/mysql v1.5.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg= github.com/go-sql-driver/mysql v1.6.0 h1:BCTh4TKNUYmOmMUcQ3IipzF5prigylS7XXjEkfCHuOE= @@ -845,8 +836,8 @@ github.com/hashicorp/go-multierror v1.1.1/go.mod h1:iw975J/qwKPdAO1clOe2L8331t/9 github.com/hashicorp/go-plugin v1.0.0/go.mod h1:++UyYGoz3o5w9ZzAdZxtQKrWWP+iqPBn3cQptSMzBuY= github.com/hashicorp/go-plugin v1.0.1/go.mod h1:++UyYGoz3o5w9ZzAdZxtQKrWWP+iqPBn3cQptSMzBuY= github.com/hashicorp/go-plugin v1.4.3/go.mod h1:5fGEH17QVwTTcR0zV7yhDPLLmFX9YSZ38b18Udy6vYQ= -github.com/hashicorp/go-plugin v1.5.0 h1:g6Lj3USwF5LaB8HlvCxPjN2X4nFE08ko2BJNVpl7TIE= -github.com/hashicorp/go-plugin v1.5.0/go.mod h1:w1sAEES3g3PuV/RzUrgow20W2uErMly84hhD3um1WL4= +github.com/hashicorp/go-plugin v1.5.1 h1:oGm7cWBaYIp3lJpx1RUEfLWophprE2EV/KUeqBYo+6k= +github.com/hashicorp/go-plugin v1.5.1/go.mod h1:w1sAEES3g3PuV/RzUrgow20W2uErMly84hhD3um1WL4= github.com/hashicorp/go-raftchunking v0.6.3-0.20191002164813-7e9e8525653a h1:FmnBDwGwlTgugDGbVxwV8UavqSMACbGrUpfc98yFLR4= github.com/hashicorp/go-raftchunking v0.6.3-0.20191002164813-7e9e8525653a/go.mod h1:xbXnmKqX9/+RhPkJ4zrEx4738HacP72aaUPlT2RZ4sU= github.com/hashicorp/go-retryablehttp v0.5.3/go.mod h1:9B5zBasrRhHXnJnui7y6sL7es7NDiJgTc6Er0maI1Xs= @@ -891,7 +882,6 @@ github.com/hashicorp/go-uuid v1.0.3 h1:2gKiV6YVmrJ1i2CKKa9obLvRieoRGviZFL26PcT/C github.com/hashicorp/go-uuid v1.0.3/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= github.com/hashicorp/go-version v1.1.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= github.com/hashicorp/go-version v1.2.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= -github.com/hashicorp/go-version v1.5.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= github.com/hashicorp/go-version v1.6.0 h1:feTTfFNnjP967rlCxM/I9g701jU+RN74YKx2mOkIeek= github.com/hashicorp/go-version v1.6.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= github.com/hashicorp/go.net v0.0.1/go.mod h1:hjKkEWcCURg++eb33jQU7oqQcI9XDCnUzHA0oac0k90= @@ -901,13 +891,13 @@ github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ github.com/hashicorp/golang-lru v0.5.3/go.mod h1:iADmTwqILo4mZ8BN3D2Q6+9jd8WM5uGBxy+E8yxSoD4= github.com/hashicorp/golang-lru v0.5.4 h1:YDjusn29QI/Das2iO9M0BHnIbxPeyuCHsjMW+lJfyTc= github.com/hashicorp/golang-lru v0.5.4/go.mod h1:iADmTwqILo4mZ8BN3D2Q6+9jd8WM5uGBxy+E8yxSoD4= -github.com/hashicorp/hc-install v0.4.0 h1:cZkRFr1WVa0Ty6x5fTvL1TuO1flul231rWkGH92oYYk= -github.com/hashicorp/hc-install v0.4.0/go.mod h1:5d155H8EC5ewegao9A4PUTMNPZaq+TbOzkJJZ4vrXeI= +github.com/hashicorp/hc-install v0.6.1 h1:IGxShH7AVhPaSuSJpKtVi/EFORNjO+OYVJJrAtGG2mY= +github.com/hashicorp/hc-install v0.6.1/go.mod h1:0fW3jpg+wraYSnFDJ6Rlie3RvLf1bIqVIkzoon4KoVE= github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ= github.com/hashicorp/hcl v1.0.1-vault-5 h1:kI3hhbbyzr4dldA8UdTb7ZlVVlI2DACdCfz31RPDgJM= github.com/hashicorp/hcl v1.0.1-vault-5/go.mod h1:XYhtn6ijBSAj6n4YqAaf7RBPS4I06AItNorpy+MoQNM= -github.com/hashicorp/hcl/v2 v2.14.1 h1:x0BpjfZ+CYdbiz+8yZTQ+gdLO7IXvOut7Da+XJayx34= -github.com/hashicorp/hcl/v2 v2.14.1/go.mod h1:e4z5nxYlWNPdDSNYX+ph14EvWYMFm3eP0zIUqPc2jr0= +github.com/hashicorp/hcl/v2 v2.19.1 h1://i05Jqznmb2EXqa39Nsvyan2o5XyMowW5fnCKW5RPI= +github.com/hashicorp/hcl/v2 v2.19.1/go.mod h1:ThLC89FV4p9MPW804KVbe/cEXoQ8NZEh+JtMeeGErHE= github.com/hashicorp/hcp-sdk-go v0.23.0 h1:3WarkQSK0VzxJaH6psHIGQagag3ujL+NjWagZZHpiZM= github.com/hashicorp/logutils v1.0.0 h1:dLEQVugN8vlakKOUE3ihGLTZJRB4j+M2cdTm/ORI65Y= github.com/hashicorp/logutils v1.0.0/go.mod h1:QIAnNjmIWmVIIkWDTG1z5v++HQmx9WQRO+LraFDTW64= @@ -927,20 +917,20 @@ github.com/hashicorp/raft-snapshot v1.0.2-0.20190827162939-8117efcc5aab/go.mod h github.com/hashicorp/raft-snapshot v1.0.4 h1:EuDuayAJPdiDmVk1ygTDnG2zDzrs0/6/yBuma1IYSow= github.com/hashicorp/serf v0.8.2/go.mod h1:6hOLApaqBFA1NXqRQAsxw9QxuDEvNxSQRwA/JwenrHc= github.com/hashicorp/serf v0.8.3/go.mod h1:UpNcs7fFbpKIyZaUuSW6EPiH+eZC7OuyFD+wc1oal+k= -github.com/hashicorp/terraform-exec v0.17.3 h1:MX14Kvnka/oWGmIkyuyvL6POx25ZmKrjlaclkx3eErU= -github.com/hashicorp/terraform-exec v0.17.3/go.mod h1:+NELG0EqQekJzhvikkeQsOAZpsw0cv/03rbeQJqscAI= -github.com/hashicorp/terraform-json v0.14.0 h1:sh9iZ1Y8IFJLx+xQiKHGud6/TSUCM0N8e17dKDpqV7s= -github.com/hashicorp/terraform-json v0.14.0/go.mod h1:5A9HIWPkk4e5aeeXIBbkcOvaZbIYnAIkEyqP2pNSckM= -github.com/hashicorp/terraform-plugin-go v0.14.0 h1:ttnSlS8bz3ZPYbMb84DpcPhY4F5DsQtcAS7cHo8uvP4= -github.com/hashicorp/terraform-plugin-go v0.14.0/go.mod h1:2nNCBeRLaenyQEi78xrGrs9hMbulveqG/zDMQSvVJTE= -github.com/hashicorp/terraform-plugin-log v0.7.0 h1:SDxJUyT8TwN4l5b5/VkiTIaQgY6R+Y2BQ0sRZftGKQs= -github.com/hashicorp/terraform-plugin-log v0.7.0/go.mod h1:p4R1jWBXRTvL4odmEkFfDdhUjHf9zcs/BCoNHAc7IK4= -github.com/hashicorp/terraform-plugin-sdk/v2 v2.24.0 h1:FtCLTiTcykdsURXPt/ku7fYXm3y19nbzbZcUxHx9RbI= -github.com/hashicorp/terraform-plugin-sdk/v2 v2.24.0/go.mod h1:80wf5oad1tW+oLnbXS4UTYmDCrl7BuN1Q+IA91X1a4Y= -github.com/hashicorp/terraform-registry-address v0.0.0-20220623143253-7d51757b572c h1:D8aRO6+mTqHfLsK/BC3j5OAoogv1WLRWzY1AaTo3rBg= -github.com/hashicorp/terraform-registry-address v0.0.0-20220623143253-7d51757b572c/go.mod h1:Wn3Na71knbXc1G8Lh+yu/dQWWJeFQEpDeJMtWMtlmNI= -github.com/hashicorp/terraform-svchost v0.0.0-20200729002733-f050f53b9734 h1:HKLsbzeOsfXmKNpr3GiT18XAblV0BjCbzL8KQAMZGa0= -github.com/hashicorp/terraform-svchost v0.0.0-20200729002733-f050f53b9734/go.mod h1:kNDNcF7sN4DocDLBkQYz73HGKwN1ANB1blq4lIYLYvg= +github.com/hashicorp/terraform-exec v0.19.0 h1:FpqZ6n50Tk95mItTSS9BjeOVUb4eg81SpgVtZNNtFSM= +github.com/hashicorp/terraform-exec v0.19.0/go.mod h1:tbxUpe3JKruE9Cuf65mycSIT8KiNPZ0FkuTE3H4urQg= +github.com/hashicorp/terraform-json v0.17.1 h1:eMfvh/uWggKmY7Pmb3T85u86E2EQg6EQHgyRwf3RkyA= +github.com/hashicorp/terraform-json v0.17.1/go.mod h1:Huy6zt6euxaY9knPAFKjUITn8QxUFIe9VuSzb4zn/0o= +github.com/hashicorp/terraform-plugin-go v0.19.0 h1:BuZx/6Cp+lkmiG0cOBk6Zps0Cb2tmqQpDM3iAtnhDQU= +github.com/hashicorp/terraform-plugin-go v0.19.0/go.mod h1:EhRSkEPNoylLQntYsk5KrDHTZJh9HQoumZXbOGOXmec= +github.com/hashicorp/terraform-plugin-log v0.9.0 h1:i7hOA+vdAItN1/7UrfBqBwvYPQ9TFvymaRGZED3FCV0= +github.com/hashicorp/terraform-plugin-log v0.9.0/go.mod h1:rKL8egZQ/eXSyDqzLUuwUYLVdlYeamldAHSxjUFADow= +github.com/hashicorp/terraform-plugin-sdk/v2 v2.29.0 h1:wcOKYwPI9IorAJEBLzgclh3xVolO7ZorYd6U1vnok14= +github.com/hashicorp/terraform-plugin-sdk/v2 v2.29.0/go.mod h1:qH/34G25Ugdj5FcM95cSoXzUgIbgfhVLXCcEcYaMwq8= +github.com/hashicorp/terraform-registry-address v0.2.2 h1:lPQBg403El8PPicg/qONZJDC6YlgCVbWDtNmmZKtBno= +github.com/hashicorp/terraform-registry-address v0.2.2/go.mod h1:LtwNbCihUoUZ3RYriyS2wF/lGPB6gF9ICLRtuDk7hSo= +github.com/hashicorp/terraform-svchost v0.1.1 h1:EZZimZ1GxdqFRinZ1tpJwVxxt49xc/S52uzrw4x0jKQ= +github.com/hashicorp/terraform-svchost v0.1.1/go.mod h1:mNsjQfZyf/Jhz35v6/0LWcv26+X7JPS+buii2c9/ctc= github.com/hashicorp/vault v1.4.2/go.mod h1:500fLOj7p92Ys4X265LizqF78MzmHJUf1jV1zNJt060= github.com/hashicorp/vault v1.13.7 h1:4s/RullYWwTtWW7HzOKSR3SNzv4V2cgNo4ImvArnXpU= github.com/hashicorp/vault v1.13.7/go.mod h1:KgEsayEcTM6N6fSun+4OqofsiwmD8rN6TUPRqESLBJQ= @@ -1003,9 +993,8 @@ github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1: github.com/imdario/mergo v0.3.5/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA= github.com/imdario/mergo v0.3.6/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA= github.com/imdario/mergo v0.3.8/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA= -github.com/imdario/mergo v0.3.12/go.mod h1:jmQim1M+e3UYxmgPu/WyfjB3N3VflVyUjjjwH0dnCYA= -github.com/imdario/mergo v0.3.13 h1:lFzP57bqS/wsqKssCGmtLAb8A0wKjLGrve2q3PPVcBk= -github.com/imdario/mergo v0.3.13/go.mod h1:4lJ1jqUDcsbIECGy0RUJAXNIhg+6ocWgb1ALK2O4oXg= +github.com/imdario/mergo v0.3.15 h1:M8XP7IuFNsqUx6VPK2P9OSmsYsI/YFaGil0uD21V3dM= +github.com/imdario/mergo v0.3.15/go.mod h1:WBLT9ZmE3lPoWsEzCh9LPo3TiwVN+ZKEjmz+hD27ysY= github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= github.com/influxdata/influxdb v0.0.0-20190411212539-d24b7ba8c4c4/go.mod h1:qZna6X/4elxqT3yI9iZYdZrWWdeFOOprn86kgg4+IzY= github.com/jackc/fake v0.0.0-20150926172116-812a484cc733/go.mod h1:WrMFNQdiFJ80sQsxDoMokWK1W5TQtxBFNpzWTD84ibQ= @@ -1014,7 +1003,6 @@ github.com/jarcoal/httpmock v1.0.5/go.mod h1:ATjnClrvW/3tijVmpL/va5Z3aAyGvqU3gCT github.com/jarcoal/httpmock v1.0.7 h1:d1a2VFpSdm5gtjhCPWsQHSnx8+5V3ms5431YwvmkuNk= github.com/jarcoal/httpmock v1.0.7/go.mod h1:ATjnClrvW/3tijVmpL/va5Z3aAyGvqU3gCT8nX0Txik= github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 h1:BQSFePA1RWJOlocH6Fxy8MmwDt+yVQYULKfN0RoTN8A= -github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99/go.mod h1:1lJo3i6rXxKeerYnT8Nvf0QmHCRC1n8sfWVwXF2Frvo= github.com/jcmturner/aescts v1.0.1/go.mod h1:k9gJoDUf1GH5r2IBtBjwjDCoLELYxOcEhitdP8RL7qQ= github.com/jcmturner/aescts/v2 v2.0.0 h1:9YKLH6ey7H4eDBXW8khjYslgyqG2xZikXP0EQFKrle8= github.com/jcmturner/aescts/v2 v2.0.0/go.mod h1:AiaICIRyfYg35RUkr8yESTqvSy7csK90qZ5xfvvsoNs= @@ -1038,7 +1026,6 @@ github.com/jefferai/isbadcipher v0.0.0-20190226160619-51d2077c035f/go.mod h1:3J2 github.com/jefferai/jsonx v1.0.0 h1:Xoz0ZbmkpBvED5W9W1B5B/zc3Oiq7oXqiW7iRV3B6EI= github.com/jefferai/jsonx v1.0.0/go.mod h1:OGmqmi2tTeI/PS+qQfBDToLHHJIy/RMp24fPo8vFvoQ= github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI= -github.com/jessevdk/go-flags v1.5.0/go.mod h1:Fw0T6WPc1dYxT4mKEZRfG5kJhaTDP9pj1c2EWnYs/m4= github.com/jhump/protoreflect v1.6.0/go.mod h1:eaTn3RZAmMBcV0fifFvlm6VHNz3wSkYyXYWUh7ymB74= github.com/jhump/protoreflect v1.15.1 h1:HUMERORf3I3ZdX05WaQ6MIpd/NJ434hTp5YiKgfCL6c= github.com/jinzhu/copier v0.3.2 h1:QdBOCbaouLDYaIPFfi1bKv5F5tPpeTwXe4sD0jqtz5w= @@ -1077,8 +1064,7 @@ github.com/karrick/godirwalk v1.8.0/go.mod h1:H5KPZjojv4lE+QYImBI8xVtrBRgYrIVsaR github.com/karrick/godirwalk v1.10.3/go.mod h1:RoGL9dQei4vP9ilrpETWE8CLOZ1kiN0LhBygSwrAsHA= github.com/kelseyhightower/envconfig v1.3.0/go.mod h1:cccZRl6mQpaq41TPp5QxidR+Sa3axMbJDNb//FQX6Gg= github.com/kelseyhightower/envconfig v1.4.0 h1:Im6hONhd3pLkfDFsbRgu68RDNkGF1r3dvMUtDTo2cv8= -github.com/kevinburke/ssh_config v0.0.0-20201106050909-4977a11b4351 h1:DowS9hvgyYSX4TO5NpyC606/Z4SxnNYbT+WX27or6Ck= -github.com/kevinburke/ssh_config v0.0.0-20201106050909-4977a11b4351/go.mod h1:CT57kijsi8u/K/BOFA39wgDQJ9CxiF4nAY/ojJ6r6mM= +github.com/kevinburke/ssh_config v1.2.0 h1:x584FjTGwHzMwvHx18PXxbBVzfnxogHaAReU4gf13a4= github.com/keybase/go-crypto v0.0.0-20190403132359-d65b6b94177f/go.mod h1:ghbZscTyKdM07+Fw3KSi0hcJm+AlEUWj8QLlPtijN/M= github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q= github.com/kisielk/errcheck v1.2.0/go.mod h1:/BMXB+zMLi60iA8Vv6Ksmxu/1UDYcXs4uQLJ+jE2L00= @@ -1107,7 +1093,6 @@ github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/kube-object-storage/lib-bucket-provisioner v0.0.0-20221122204822-d1a8c34382f1 h1:dQEHhTfi+bSIOSViQrKY9PqJvZenD6tFz+3lPzux58o= github.com/kube-object-storage/lib-bucket-provisioner v0.0.0-20221122204822-d1a8c34382f1/go.mod h1:my+EVjOJLeQ9lUR9uVkxRvNNkhO2saSGIgzV8GZT9HY= github.com/kubernetes-csi/external-snapshotter/client/v4 v4.0.0/go.mod h1:YBCo4DoEeDndqvAn6eeu0vWM7QdXmHEeI9cFWplmBys= -github.com/kylelemons/godebug v0.0.0-20170820004349-d65d576e9348/go.mod h1:B69LEHPfb2qLo0BaaOLcbitczOKLWTsrBG9LczfCD4k= github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= github.com/leodido/go-urn v1.2.0/go.mod h1:+8+nEpDfqqsY+g338gtMEUOtuK+4dEMhiQEgxpxOKII= github.com/leodido/go-urn v1.2.1/go.mod h1:zt4jvISO2HfUBqxjfIshjdMTYS56ZS/qv49ictyFfxY= @@ -1136,7 +1121,6 @@ github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJ github.com/markbates/oncer v0.0.0-20181203154359-bf2de49a0be2/go.mod h1:Ld9puTsIW75CHf65OeIOkyKbteujpZVXDpWK6YGZbxE= github.com/markbates/safe v1.0.1/go.mod h1:nAqgmRi7cY2nqMc92/bSEeQA+R4OheNU2T1kNSCBdG0= github.com/martini-contrib/render v0.0.0-20150707142108-ec18f8345a11/go.mod h1:Ah2dBMoxZEqk118as2T4u4fjfXarE0pPnMJaArZQZsI= -github.com/matryer/is v1.2.0/go.mod h1:2fLPjFQM9rhQ15aVEtbuwhJinnOqrmgXPNdZsdwlWXA= github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU= github.com/mattn/go-colorable v0.1.1/go.mod h1:FuOcm+DKB9mbwrcAfNl7/TZVBZ6rcnceauSikq3lYCQ= github.com/mattn/go-colorable v0.1.2/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE= @@ -1228,7 +1212,6 @@ github.com/nicksnyder/go-i18n v1.10.0 h1:5AzlPKvXBH4qBzmZ09Ua9Gipyruv6uApMcrNZdo github.com/nicksnyder/go-i18n v1.10.0/go.mod h1:HrK7VCrbOvQoUAQ7Vpy7i87N7JZZZ7R2xBGjv0j365Q= github.com/nicolai86/scaleway-sdk v1.10.2-0.20180628010248-798f60e20bb2 h1:BQ1HW7hr4IVovMwWg0E0PYcyW8CzqDcVmaew9cujU4s= github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno= -github.com/nsf/jsondiff v0.0.0-20200515183724-f29ed568f4ce h1:RPclfga2SEJmgMmz2k+Mg7cowZ8yv4Trqw9UsJby758= github.com/nwaples/rardecode v1.0.0/go.mod h1:5DzqNKiOdpKKBH87u8VlvAnPZMXcGRhxWkRpHbbfGS0= github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A= github.com/nxadm/tail v1.4.8/go.mod h1:+ncqLTQzXmGhMZNUePPaPqPvBxHAIsmXswZKocGu+AU= @@ -1303,8 +1286,8 @@ github.com/onsi/gomega v1.27.6/go.mod h1:PIQNjfQwkP3aQAH7lf7j87O/5FiNr+ZR8+ipb+q github.com/onsi/gomega v1.27.7/go.mod h1:1p8OOlwo2iUUDsHnOrjE5UKYJ+e3W8eQ3qSlRahPmr4= github.com/onsi/gomega v1.27.8/go.mod h1:2J8vzI/s+2shY9XHRApDkdgPo1TKT7P2u6fXeJKFnNQ= github.com/onsi/gomega v1.27.10/go.mod h1:RsS8tutOdbdgzbPtzzATp12yT7kM5I5aElG3evPbQ0M= -github.com/onsi/gomega v1.29.0 h1:KIA/t2t5UBzoirT4H9tsML45GEbo3ouUnBHsCfD2tVg= github.com/onsi/gomega v1.29.0/go.mod h1:9sxs+SwGrKI0+PWe4Fxa9tFQQBG5xSsSbMXOI8PPpoQ= +github.com/onsi/gomega v1.30.0 h1:hvMK7xYz4D3HapigLTeGdId/NcfQx1VHMJc60ew99+8= github.com/opencontainers/go-digest v1.0.0-rc1/go.mod h1:cMLVZDEM3+U2I4VmLI6N8jQYUd2OVphdqWwCJHrFt2s= github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U= github.com/opencontainers/image-spec v1.0.1/go.mod h1:BtxoFyWECRxE4U/7sNtV5W15zMzWCbyJoFRP3s7yZA0= @@ -1352,6 +1335,7 @@ github.com/pierrec/lz4 v2.6.1+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi github.com/pierrec/lz4/v4 v4.1.18 h1:xaKrnTkyoqfh1YItXl56+6KJNVYWlEEPuAQW9xsplYQ= github.com/pierrec/lz4/v4 v4.1.18/go.mod h1:gZWDp/Ze/IJXGXf23ltt2EXimqmTUXEy0GFuRQyBid4= github.com/pires/go-proxyproto v0.6.1 h1:EBupykFmo22SDjv4fQVQd2J9NOoLPmyZA/15ldOGkPw= +github.com/pjbgf/sha1cd v0.3.0 h1:4D5XXmUUBUl/xQ6IjCkEAbqXskkq/4O7LmGn0AqMDs4= github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= @@ -1444,9 +1428,7 @@ github.com/samuel/go-zookeeper v0.0.0-20180130194729-c4fab1ac1bec/go.mod h1:gi+0 github.com/sasha-s/go-deadlock v0.2.0 h1:lMqc+fUb7RrFS3gQLtoQsJ7/6TV/pAIFvBsqX73DK8Y= github.com/satori/go.uuid v1.2.0/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdhQKdks0= github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc= -github.com/sebdah/goldie v1.0.0/go.mod h1:jXP4hmWywNEwZzhMuv2ccnqTSFpuq8iyQhtQdkkZBH4= github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo= -github.com/sergi/go-diff v1.1.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM= github.com/sergi/go-diff v1.2.0 h1:XU+rvMAioB0UC3q1MFrIQy4Vo5/4VsRDQQXHsEya6xQ= github.com/sethvargo/go-limiter v0.7.2 h1:FgC4N7RMpV5gMrUdda15FaFTkQ/L4fEqM7seXMs4oO8= github.com/shirou/gopsutil v2.19.9+incompatible h1:IrPVlK4nfwW10DF7pW+7YJKws9NkgNzWozwwWv9FsgY= @@ -1463,6 +1445,7 @@ github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6Mwd github.com/sirupsen/logrus v1.6.0/go.mod h1:7uNnSEd1DgxDLC74fIahvMZmmYsHGZGEOFrfsX/uA88= github.com/sirupsen/logrus v1.9.0 h1:trlNQbNUG3OdDrDil03MCb1H2o9nJ1x4/5LYw7byDE0= github.com/sirupsen/logrus v1.9.0/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ= +github.com/skeema/knownhosts v1.2.0 h1:h9r9cf0+u7wSE+M183ZtMGgOJKiL96brpaz5ekfJCpM= github.com/smartystreets/assertions v0.0.0-20180725160413-e900ae048470/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc= github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc= github.com/smartystreets/assertions v1.0.0/go.mod h1:kHHU4qYBaI3q23Pp3VPrmWhuIUrLW/7eUrw0BU5VaoM= @@ -1537,13 +1520,12 @@ github.com/vektah/gqlparser v1.1.2/go.mod h1:1ycwN7Ij5njmMkPPAOaRFY4rET2Enx7IkVv github.com/vmihailenco/msgpack v3.3.3+incompatible/go.mod h1:fy3FlTQTDXWkZ7Bh6AcGMlsjHatGryHQYUTf1ShIgkk= github.com/vmihailenco/msgpack v4.0.4+incompatible h1:dSLoQfGFAo3F6OoNhwUmLwVgaUXK79GlxNBwueZn0xI= github.com/vmihailenco/msgpack v4.0.4+incompatible/go.mod h1:fy3FlTQTDXWkZ7Bh6AcGMlsjHatGryHQYUTf1ShIgkk= -github.com/vmihailenco/msgpack/v4 v4.3.12 h1:07s4sz9IReOgdikxLTKNbBdqDMLsjPKXwvCazn8G65U= -github.com/vmihailenco/msgpack/v4 v4.3.12/go.mod h1:gborTTJjAo/GWTqqRjrLCn9pgNN+NXzzngzBKDPIqw4= -github.com/vmihailenco/tagparser v0.1.1 h1:quXMXlA39OCbd2wAdTsGDlK9RkOk6Wuw+x37wVyIuWY= -github.com/vmihailenco/tagparser v0.1.1/go.mod h1:OeAg3pn3UbLjkWt+rN9oFYB6u/cQgqMEUPoW2WPyhdI= +github.com/vmihailenco/msgpack/v5 v5.3.5 h1:5gO0H1iULLWGhs2H5tbAHIZTV8/cYafcFOr9znI5mJU= +github.com/vmihailenco/msgpack/v5 v5.3.5/go.mod h1:7xyJ9e+0+9SaZT0Wt1RGleJXzli6Q/V5KbhBonMG9jc= +github.com/vmihailenco/tagparser/v2 v2.0.0 h1:y09buUbR+b5aycVFQs/g70pqKVZNBmxwAhO7/IwNM9g= +github.com/vmihailenco/tagparser/v2 v2.0.0/go.mod h1:Wri+At7QHww0WTrCBeu4J6bNtoV6mEfg5OIWRZA9qds= github.com/vmware/govmomi v0.18.0 h1:f7QxSmP7meCtoAmiKZogvVbLInT+CZx6Px6K5rYsJZo= -github.com/xanzy/ssh-agent v0.3.0 h1:wUMzuKtKilRgBAD1sUb8gOwwRr2FGoBVumcjoOACClI= -github.com/xanzy/ssh-agent v0.3.0/go.mod h1:3s9xbODqPuuhK9JV1R321M/FlMZSBvE5aY6eAcqrDh0= +github.com/xanzy/ssh-agent v0.3.3 h1:+/15pJfg/RsTxqYcX6fHqOXZwwMP+2VyYWJeWM2qQFM= github.com/xdg-go/pbkdf2 v1.0.0/go.mod h1:jrpuAogTd400dnrH08LKmI/xc1MbPOebTwRqcT5RDeI= github.com/xdg-go/scram v1.0.2/go.mod h1:1WAq6h33pAW+iRreB34OORO2Nf7qel3VV3fjBj+hCSs= github.com/xdg-go/scram v1.1.1/go.mod h1:RaEWvsqvNKKvBPvcKeFjrG2cJqOkHTiyTpzz23ni57g= @@ -1569,12 +1551,8 @@ github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1 github.com/yuin/goldmark v1.4.1/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= github.com/yusufpapurcu/wmi v1.2.2 h1:KBNDSne4vP5mbSWnJbO+51IMOXJB67QiYCSBrubbPRg= -github.com/zclconf/go-cty v1.1.0/go.mod h1:xnAOWiHeOqg2nWS62VtQ7pbOu17FtxJNW8RLEih+O3s= -github.com/zclconf/go-cty v1.2.0/go.mod h1:hOPWgoHbaTUnI5k4D2ld+GRpFJSCe6bCM7m1q/N4PQ8= -github.com/zclconf/go-cty v1.10.0/go.mod h1:vVKLxnk3puL4qRAv72AO+W99LUD4da90g3uUAzyuvAk= -github.com/zclconf/go-cty v1.11.0 h1:726SxLdi2SDnjY+BStqB9J1hNp4+2WlzyXLuimibIe0= -github.com/zclconf/go-cty v1.11.0/go.mod h1:s9IfD1LK5ccNMSWCVFCE2rJfHiZgi7JijgeWIMfhLvA= -github.com/zclconf/go-cty-debug v0.0.0-20191215020915-b22d67c1ba0b/go.mod h1:ZRKQfBXbGkpdV6QMzT3rU1kSTAnfu1dO8dPKjYprgj8= +github.com/zclconf/go-cty v1.14.1 h1:t9fyA35fwjjUMcmL5hLER+e/rEPqrbCK1/OSE4SI9KA= +github.com/zclconf/go-cty v1.14.1/go.mod h1:VvMs5i0vgZdhYawQNq5kePSpLAoz8u1xvZgrPIxfnZE= go.etcd.io/bbolt v1.3.2/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU= go.etcd.io/bbolt v1.3.3/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU= go.etcd.io/bbolt v1.3.5/go.mod h1:G5EMThwa9y8QZGBClrRx5EY+Yw9kAhnjy3bSjsnlVTQ= @@ -1629,7 +1607,6 @@ golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnf golang.org/x/crypto v0.0.0-20181029021203-45a5f77698d3/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20181203042331-505ab145d0a9/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20190211182817-74369b46fc67/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= -golang.org/x/crypto v0.0.0-20190219172222-a4c6cb3142f2/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20190320223903-b7391e95e576/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20190325154230-a5d413f7728c/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= @@ -1654,19 +1631,19 @@ golang.org/x/crypto v0.0.0-20200323165209-0ec3e9974c59/go.mod h1:LzIPMQfyMNhhGPh golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20201002170205-7f63de1d35b0/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20201208171446-5f87f3452ae9/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I= -golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4= -golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4= -golang.org/x/crypto v0.0.0-20210616213533-5ff15b29337e/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20210817164053-32db794688a5/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/crypto v0.1.0/go.mod h1:RecgLatLF4+eUMCP1PoPZQb+cVrJcOPbHkTkbkB9sbw= +golang.org/x/crypto v0.3.1-0.20221117191849-2c476679df9a/go.mod h1:hebNnKkNXi2UzZN1eVRvBB7co0a+JxK6XbPiWVs/3J4= golang.org/x/crypto v0.6.0/go.mod h1:OFC/31mSvZgRz0V1QTNCzfAI1aIRzbiufJtkMIlEp58= +golang.org/x/crypto v0.7.0/go.mod h1:pYwdfH91IfpZVANVyUOhSIPZaFoJGxTFbZhFTx+dXZU= golang.org/x/crypto v0.11.0/go.mod h1:xgJhtzW8F9jGdVFWZESrid1U1bjeNy4zgy5cRr/CIio= golang.org/x/crypto v0.12.0/go.mod h1:NF0Gs7EO5K4qLn+Ylc+fih8BSTeIjAP05siRnAh98yw= -golang.org/x/crypto v0.14.0 h1:wBqGXzWJW6m1XrIKlAH0Hs1JJ7+9KBwnIO8v66Q9cHc= golang.org/x/crypto v0.14.0/go.mod h1:MVFd36DqK4CsrnJYDkBA3VC4m2GkXAM0PvzMCn4JQf4= +golang.org/x/crypto v0.16.0 h1:mMMrFzRSCF0GvB7Ne27XVtVAaXLrPmgPC7/v0tkwHaY= +golang.org/x/crypto v0.16.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= @@ -1710,12 +1687,12 @@ golang.org/x/mod v0.7.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= golang.org/x/mod v0.9.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= golang.org/x/mod v0.10.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= -golang.org/x/mod v0.12.0 h1:rmsUpXtvNzj340zd98LZ4KntptpfRHwpFOHG188oHXc= golang.org/x/mod v0.12.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= +golang.org/x/mod v0.14.0 h1:dGoOF9QVLYng8IHTm7BAyWqCqSheQ5pYWGhzW00YJr0= +golang.org/x/mod v0.14.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= golang.org/x/net v0.0.0-20170114055629-f2499483f923/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180530234432-1e491301e022/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20180811021610-c39426892332/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20181005035420-146acd28ed58/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -1741,7 +1718,6 @@ golang.org/x/net v0.0.0-20190724013045-ca1201d0de80/go.mod h1:z5CRVTTTmAJ677TzLL golang.org/x/net v0.0.0-20190813141303-74dc4d7220e7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190827160401-ba9fcec4b297/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20191004110552-13f9640d40b9/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20191009170851-d66e71096ffb/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20191209160850-c0dbc17a3553/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200114155413-6afb5195e5aa/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200202094626-16171245cfb2/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= @@ -1767,7 +1743,6 @@ golang.org/x/net v0.0.0-20201224014010-6772e930b67b/go.mod h1:m0MpNAwzfU5UDzcl9v golang.org/x/net v0.0.0-20210119194325-5f4716e94777/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20210316092652-d523dce5a7f4/go.mod h1:RBQZq4jEuRlivfhVLdyRGr576XBO4/greRjx4P4O3yc= -golang.org/x/net v0.0.0-20210326060303-6b1517762897/go.mod h1:uSPa2vr4CLtc/ILN5odXGNXS6mhrKVzTaCXzk9m6W3k= golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= golang.org/x/net v0.0.0-20210421230115-4e50805a0758/go.mod h1:72T/g9IO56b78aLF+1Kcs5dz7/ng1VjMUvfKvpfy+jM= golang.org/x/net v0.0.0-20210428140749-89ef3d95e781/go.mod h1:OJAsFXCWl8Ukc7SiCT/9KSuxbyM7479/AVlXFRxuMCk= @@ -1791,8 +1766,9 @@ golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc= golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg= golang.org/x/net v0.12.0/go.mod h1:zEVYFnQC7m/vmpQFELhcD1EWkZlX69l4oqgmer6hfKA= golang.org/x/net v0.14.0/go.mod h1:PpSgVXXLK0OxS0F31C1/tv6XNguvCrnXIDrFMspZIUI= -golang.org/x/net v0.17.0 h1:pVaXccu2ozPjCXewfr1S7xza/zcXTity9cCdXQYSjIM= golang.org/x/net v0.17.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE= +golang.org/x/net v0.19.0 h1:zTwKpTd2XuCqf8huc7Fo2iSy+4RHPd10s4KzeTnVr1c= +golang.org/x/net v0.19.0/go.mod h1:CfAk/cbD4CthTvqiEl8NpboMuiuOYsAr/7NOjZJtv1U= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20181203162652-d668ce993890/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190130055435-99b60b757ec1/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= @@ -1828,8 +1804,9 @@ golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.2.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.3.0 h1:ftCYgMx6zT/asHUrPw8BLLscYtGznsLAnjq5RH9P66E= golang.org/x/sync v0.3.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y= +golang.org/x/sync v0.5.0 h1:60k92dhOjHxJkrqnwsfl8KuaHbn/5dl0lUPUklKo3qE= +golang.org/x/sync v0.5.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sys v0.0.0-20170830134202-bb24a47a89ea/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -1862,7 +1839,6 @@ golang.org/x/sys v0.0.0-20190712062909-fae7ac547cb7/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190826190057-c7b8b68b1456/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190904154756-749cb33beabd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191001151750-bb3f8db39f24/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191008105621-543471e840be/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -1905,11 +1881,9 @@ golang.org/x/sys v0.0.0-20210220050731-9a76102bfb43/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20210305230114-8fe3ee5dd75b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210315160823-c6e025ad8005/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210320140829-1e4c9ba3b0c4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210324051608-47abb6519492/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210420072515-93ed5bcd2bfe/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210502180810-71e4cd670f79/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210603081109-ebe580a85c40/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= @@ -1938,8 +1912,9 @@ golang.org/x/sys v0.9.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.10.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.13.0 h1:Af8nKPmuFypiUBjVoU9V20FiaFXOcuZI21p0ycVYYGE= golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.15.0 h1:h48lPFYpsTvQJZF4EKyI4aLHaev3CxivZmv7yZig9pc= +golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210615171337-6886f2dfbf5b/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= @@ -1953,8 +1928,9 @@ golang.org/x/term v0.6.0/go.mod h1:m6U89DPEgQRMq3DNkDClhWw02AUbt2daBVO4cn4Hv9U= golang.org/x/term v0.8.0/go.mod h1:xPskH00ivmX89bAKVGSKKtLOWNx2+17Eiy94tnKShWo= golang.org/x/term v0.10.0/go.mod h1:lpqdcUyK/oCiQxvxVrppt5ggO2KCZ5QblwqPnfZ6d5o= golang.org/x/term v0.11.0/go.mod h1:zC9APTIj3jG3FdV/Ons+XE1riIZXG4aZ4GTHiPZJPIU= -golang.org/x/term v0.13.0 h1:bb+I9cTfFazGW51MZqBVmZy7+JEJMouUHTUSKVQLBek= golang.org/x/term v0.13.0/go.mod h1:LTmsnFJwVN6bCy1rVCoS+qHT1HhALEFxKncY3WNNh4U= +golang.org/x/term v0.15.0 h1:y/Oo/a/q3IXu26lQgl04j/gjuBDOBlx7X6Om1j2CPW4= +golang.org/x/term v0.15.0/go.mod h1:BDl952bC7+uMoWR75FIrCDx79TPU9oHkTZ9yRbYOrX0= golang.org/x/text v0.0.0-20160726164857-2910a502d2bf/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= @@ -1975,8 +1951,9 @@ golang.org/x/text v0.8.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= golang.org/x/text v0.11.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= golang.org/x/text v0.12.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= -golang.org/x/text v0.13.0 h1:ablQoSUd0tRdKxZewP80B+BaqeKJuVhuRxj/dkrun3k= golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= +golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= +golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= @@ -2065,8 +2042,9 @@ golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU= golang.org/x/tools v0.7.0/go.mod h1:4pg6aUX35JBAogB10C9AtvVL+qowtN4pT3CGSQex14s= golang.org/x/tools v0.9.1/go.mod h1:owI94Op576fPu3cIGQeHs3joujW/2Oc6MtlxbF5dfNc= golang.org/x/tools v0.9.3/go.mod h1:owI94Op576fPu3cIGQeHs3joujW/2Oc6MtlxbF5dfNc= -golang.org/x/tools v0.12.0 h1:YW6HUoUmYBpwSgyaGaZq1fHjrBjX1rlpZ54T6mu2kss= golang.org/x/tools v0.12.0/go.mod h1:Sc0INKfu04TlqNoRA1hgpFZbhYXHPr4V5DzpSBTPqQM= +golang.org/x/tools v0.16.0 h1:GO788SKMRunPIBCXiQyo2AaexLstOrVhuAL5YwsckQM= +golang.org/x/tools v0.16.0/go.mod h1:kYVVN6I1mBNoB1OX+noeBjbRk4IUEPa7JJ+TJMEooJ0= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= @@ -2253,7 +2231,6 @@ gopkg.in/square/go-jose.v2 v2.6.0 h1:NGk74WTnPKBNUhNzQX7PYcTLUjoq7mzKk2OKbvwk2iI gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= gopkg.in/warnings.v0 v0.1.2 h1:wFXVbFY8DY5/xOe1ECiWdKCzZlxgshcYVNkBHstARME= -gopkg.in/warnings.v0 v0.1.2/go.mod h1:jksf8JmL6Qr/oQM2OXTHunEvvTAsrWBLb6OOjuVWRNI= gopkg.in/yaml.v2 v2.0.0-20170812160011-eb3733d160e7/go.mod h1:JAlM8MvJe8wmxCU4Bli9HhUf9+ttbYbLASfIpnQbh74= gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= @@ -2268,7 +2245,6 @@ gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C gopkg.in/yaml.v3 v3.0.0-20200605160147-a5ece683394c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -gopkg.in/yaml.v3 v3.0.0/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gotest.tools v2.2.0+incompatible h1:VsBPFP1AI068pPrMxtb/S8Zkgf9xEmTLJjfM+P5UIEo= diff --git a/ibm/acctest/acctest.go b/ibm/acctest/acctest.go index bee8b7cb2b..4e563d0cb8 100644 --- a/ibm/acctest/acctest.go +++ b/ibm/acctest/acctest.go @@ -122,6 +122,14 @@ var ( HpcsInstanceID string ) +// MQ on Cloud +var ( + MqcloudInstanceID string + MqcloudQueueManagerID string + MqcloudKSCertFilePath string + MqcloudTSCertFilePath string +) + // Secrets Manager var ( SecretsManagerInstanceID string @@ -1562,6 +1570,24 @@ func init() { if SatelliteSSHPubKey == "" { fmt.Println("[WARN] Set the environment variable IBM_SATELLITE_SSH_PUB_KEY with a ssh public key or ibm_satellite_* tests may fail") } + + MqcloudInstanceID = os.Getenv("IBM_MQCLOUD_INSTANCE_ID") + if MqcloudInstanceID == "" { + fmt.Println("[INFO] Set the environment variable IBM_MQCLOUD_INSTANCE_ID for ibm_mqcloud_queue_manager resource or datasource else tests will fail if this is not set correctly") + } + + MqcloudQueueManagerID = os.Getenv("IBM_MQCLOUD_QUEUEMANAGER_ID") + if MqcloudQueueManagerID == "" { + fmt.Println("[INFO] Set the environment variable IBM_MQCLOUD_QUEUEMANAGER_ID for ibm_mqcloud_queue_manager resource or datasource else tests will fail if this is not set correctly") + } + MqcloudKSCertFilePath = os.Getenv("IBM_MQCLOUD_KS_CERT_PATH") + if MqcloudKSCertFilePath == "" { + fmt.Println("[INFO] Set the environment variable IBM_MQCLOUD_KS_CERT_PATH for ibm_mqcloud_keystore_certificate resource or datasource else tests will fail if this is not set correctly") + } + MqcloudTSCertFilePath = os.Getenv("IBM_MQCLOUD_TS_CERT_PATH") + if MqcloudTSCertFilePath == "" { + fmt.Println("[INFO] Set the environment variable IBM_MQCLOUD_TS_CERT_PATH for ibm_mqcloud_truststore_certificate resource or datasource else tests will fail if this is not set correctly") + } } var ( @@ -1773,6 +1799,22 @@ func TestAccPreCheckSatelliteSSH(t *testing.T) { } } +func TestAccPreCheckMqcloud(t *testing.T) { + TestAccPreCheck(t) + if MqcloudInstanceID == "" { + t.Fatal("IBM_MQCLOUD_INSTANCE_ID must be set for acceptance tests") + } + if MqcloudQueueManagerID == "" { + t.Fatal("IBM_MQCLOUD_QUEUEMANAGER_ID must be set for acceptance tests") + } + if MqcloudTSCertFilePath == "" { + t.Fatal("IBM_MQCLOUD_TS_CERT_PATH must be set for acceptance tests") + } + if MqcloudKSCertFilePath == "" { + t.Fatal("IBM_MQCLOUD_KS_CERT_PATH must be set for acceptance tests") + } +} + func TestAccProviderFactories() map[string]func() (*schema.Provider, error) { return map[string]func() (*schema.Provider, error){ ProviderName: func() (*schema.Provider, error) { return provider.Provider(), nil }, diff --git a/ibm/conns/config.go b/ibm/conns/config.go index ff89bd307f..fd99350034 100644 --- a/ibm/conns/config.go +++ b/ibm/conns/config.go @@ -29,6 +29,7 @@ import ( "github.com/IBM/go-sdk-core/v5/core" cosconfig "github.com/IBM/ibm-cos-sdk-go-config/resourceconfigurationv1" kp "github.com/IBM/keyprotect-go-client" + "github.com/IBM/mqcloud-go-sdk/mqcloudv1" cisalertsv1 "github.com/IBM/networking-go-sdk/alertsv1" cisoriginpull "github.com/IBM/networking-go-sdk/authenticatedoriginpullapiv1" cisbotanalyticsv1 "github.com/IBM/networking-go-sdk/botanalyticsv1" @@ -299,6 +300,7 @@ type ClientSession interface { CodeEngineV2() (*codeengine.CodeEngineV2, error) ProjectV1() (*project.ProjectV1, error) UsageReportsV4() (*usagereportsv4.UsageReportsV4, error) + MqcloudV1() (*mqcloudv1.MqcloudV1, error) } type clientSession struct { @@ -624,6 +626,9 @@ type clientSession struct { // Usage Reports options usageReportsClient *usagereportsv4.UsageReportsV4 usageReportsClientErr error + + mqcloudClient *mqcloudv1.MqcloudV1 + mqcloudClientErr error } // Usage Reports @@ -1203,6 +1208,13 @@ func (session clientSession) ProjectV1() (*project.ProjectV1, error) { return session.projectClient, session.projectClientErr } +// MQ on Cloud +func (session clientSession) MqcloudV1() (*mqcloudv1.MqcloudV1, error) { + sessionMqcloudClient := session.mqcloudClient + sessionMqcloudClient.EnableRetries(0, 0) + return session.mqcloudClient, session.mqcloudClientErr +} + // ClientSession configures and returns a fully initialized ClientSession func (c *Config) ClientSession() (interface{}, error) { sess, err := newSession(c) @@ -1296,6 +1308,7 @@ func (c *Config) ClientSession() (interface{}, error) { session.cdToolchainClientErr = errEmptyBluemixCredentials session.codeEngineClientErr = errEmptyBluemixCredentials session.projectClientErr = errEmptyBluemixCredentials + session.mqcloudClientErr = errEmptyBluemixCredentials return session, nil } @@ -3245,6 +3258,33 @@ func (c *Config) ClientSession() (interface{}, error) { session.cdTektonPipelineClientErr = fmt.Errorf("Error occurred while configuring CD Tekton Pipeline service: %q", err) } + // MQ Cloud Service Configuration + mqCloudURL := ContructEndpoint(fmt.Sprintf("api.%s.mq2", c.Region), cloudEndpoint) + if c.Visibility == "private" || c.Visibility == "public-and-private" { + mqCloudURL = ContructEndpoint(fmt.Sprintf("api.private.%s.mq2", c.Region), cloudEndpoint) + } + if fileMap != nil && c.Visibility != "public-and-private" { + mqCloudURL = fileFallBack(fileMap, c.Visibility, "IBMCLOUD_MQCLOUD_CONFIG_ENDPOINT", c.Region, mqCloudURL) + } + + mqcloudClientOptions := &mqcloudv1.MqcloudV1Options{ + Authenticator: authenticator, + URL: EnvFallBack([]string{"IBMCLOUD_MQCLOUD_CONFIG_ENDPOINT"}, mqCloudURL), + } + + // Construct the service client for MQ Cloud. + session.mqcloudClient, err = mqcloudv1.NewMqcloudV1(mqcloudClientOptions) + if err != nil { + session.mqcloudClientErr = fmt.Errorf("Error occurred while configuring MQ Cloud service: %q", err) + } else { + // Enable retries for API calls + session.mqcloudClient.Service.EnableRetries(c.RetryCount, c.RetryDelay) + // Add custom header for analytics + session.mqcloudClient.SetDefaultHeaders(gohttp.Header{ + "X-Original-User-Agent": {fmt.Sprintf("terraform-provider-ibm/%s", version.Version)}, + }) + } + // Construct the service options. codeEngineEndpoint := ContructEndpoint(fmt.Sprintf("api.%s.codeengine", c.Region), cloudEndpoint+"/v2") if c.Visibility == "private" || c.Visibility == "public-and-private" { diff --git a/ibm/provider/provider.go b/ibm/provider/provider.go index 9a0e61277b..c00464a12b 100644 --- a/ibm/provider/provider.go +++ b/ibm/provider/provider.go @@ -39,6 +39,7 @@ import ( "github.com/IBM-Cloud/terraform-provider-ibm/ibm/service/kms" "github.com/IBM-Cloud/terraform-provider-ibm/ibm/service/kubernetes" "github.com/IBM-Cloud/terraform-provider-ibm/ibm/service/metricsrouter" + "github.com/IBM-Cloud/terraform-provider-ibm/ibm/service/mqcloud" "github.com/IBM-Cloud/terraform-provider-ibm/ibm/service/power" "github.com/IBM-Cloud/terraform-provider-ibm/ibm/service/project" "github.com/IBM-Cloud/terraform-provider-ibm/ibm/service/pushnotification" @@ -743,6 +744,14 @@ func Provider() *schema.Provider { "ibm_metrics_router_targets": metricsrouter.DataSourceIBMMetricsRouterTargets(), "ibm_metrics_router_routes": metricsrouter.DataSourceIBMMetricsRouterRoutes(), + // MQ on Cloud + "ibm_mqcloud_queue_manager": mqcloud.DataSourceIbmMqcloudQueueManager(), + "ibm_mqcloud_queue_manager_status": mqcloud.DataSourceIbmMqcloudQueueManagerStatus(), + "ibm_mqcloud_application": mqcloud.DataSourceIbmMqcloudApplication(), + "ibm_mqcloud_user": mqcloud.DataSourceIbmMqcloudUser(), + "ibm_mqcloud_truststore_certificate": mqcloud.DataSourceIbmMqcloudTruststoreCertificate(), + "ibm_mqcloud_keystore_certificate": mqcloud.DataSourceIbmMqcloudKeystoreCertificate(), + // Security and Complaince Center(soon to be deprecated) "ibm_scc_account_location": scc.DataSourceIBMSccAccountLocation(), "ibm_scc_account_locations": scc.DataSourceIBMSccAccountLocations(), @@ -1276,6 +1285,13 @@ func Provider() *schema.Provider { "ibm_metrics_router_route": metricsrouter.ResourceIBMMetricsRouterRoute(), "ibm_metrics_router_settings": metricsrouter.ResourceIBMMetricsRouterSettings(), + // MQ on Cloud + "ibm_mqcloud_queue_manager": mqcloud.ResourceIbmMqcloudQueueManager(), + "ibm_mqcloud_application": mqcloud.ResourceIbmMqcloudApplication(), + "ibm_mqcloud_user": mqcloud.ResourceIbmMqcloudUser(), + "ibm_mqcloud_keystore_certificate": mqcloud.ResourceIbmMqcloudKeystoreCertificate(), + "ibm_mqcloud_truststore_certificate": mqcloud.ResourceIbmMqcloudTruststoreCertificate(), + // Security and Compliance Center(soon to be deprecated) "ibm_scc_account_settings": scc.ResourceIBMSccAccountSettings(), "ibm_scc_rule_attachment": scc.ResourceIBMSccRuleAttachment(), @@ -1461,6 +1477,13 @@ func Validator() validate.ValidatorDict { "ibm_hpcs_key_template": hpcs.ResourceIbmKeyTemplateValidator(), "ibm_hpcs_vault": hpcs.ResourceIbmVaultValidator(), + // MQ on Cloud + "ibm_mqcloud_queue_manager": mqcloud.ResourceIbmMqcloudQueueManagerValidator(), + "ibm_mqcloud_application": mqcloud.ResourceIbmMqcloudApplicationValidator(), + "ibm_mqcloud_user": mqcloud.ResourceIbmMqcloudUserValidator(), + "ibm_mqcloud_keystore_certificate": mqcloud.ResourceIbmMqcloudKeystoreCertificateValidator(), + "ibm_mqcloud_truststore_certificate": mqcloud.ResourceIbmMqcloudTruststoreCertificateValidator(), + "ibm_is_backup_policy": vpc.ResourceIBMIsBackupPolicyValidator(), "ibm_is_backup_policy_plan": vpc.ResourceIBMIsBackupPolicyPlanValidator(), diff --git a/ibm/service/mqcloud/README.md b/ibm/service/mqcloud/README.md new file mode 100644 index 0000000000..c95818ac94 --- /dev/null +++ b/ibm/service/mqcloud/README.md @@ -0,0 +1,11 @@ +# Terraform IBM Provider + +This area is primarily for IBM provider contributors and maintainers. For information on _using_ Terraform and the IBM provider, see the links below. + + +## Handy Links +* [Find out about contributing](../../../CONTRIBUTING.md) to the IBM provider! +* IBM Provider Docs: [Home](https://registry.terraform.io/providers/IBM-Cloud/ibm/latest/docs) +* IBM Provider Docs: [One of the resources](https://registry.terraform.io/providers/IBM-Cloud/ibm/latest/docs/resources/mqcloud_queue_manager) +* IBM API Docs: [IBM API Docs for ]() +* IBM SDK: [IBM SDK for ](https://github.com/IBM/appconfiguration-go-admin-sdk/tree/master/mqcloudv1) diff --git a/ibm/service/mqcloud/data_source_ibm_mqcloud_application.go b/ibm/service/mqcloud/data_source_ibm_mqcloud_application.go new file mode 100644 index 0000000000..9cef9c4831 --- /dev/null +++ b/ibm/service/mqcloud/data_source_ibm_mqcloud_application.go @@ -0,0 +1,167 @@ +// Copyright IBM Corp. 2023 All Rights Reserved. +// Licensed under the Mozilla Public License v2.0 + +package mqcloud + +import ( + "context" + "fmt" + + "time" + + "github.com/IBM/mqcloud-go-sdk/mqcloudv1" + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + + "github.com/IBM-Cloud/terraform-provider-ibm/ibm/conns" +) + +func DataSourceIbmMqcloudApplication() *schema.Resource { + return &schema.Resource{ + ReadContext: dataSourceIbmMqcloudApplicationRead, + + Schema: map[string]*schema.Schema{ + "service_instance_guid": { + Type: schema.TypeString, + Required: true, + Description: "The GUID that uniquely identifies the MQ on Cloud service instance.", + }, + "name": { + Type: schema.TypeString, + Optional: true, + Description: "The name of the application - conforming to MQ rules.", + }, + "applications": { + Type: schema.TypeList, + Computed: true, + Description: "List of applications.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "id": { + Type: schema.TypeString, + Computed: true, + Description: "The ID of the application which was allocated on creation, and can be used for delete calls.", + }, + "name": { + Type: schema.TypeString, + Computed: true, + Description: "The name of the application - conforming to MQ rules.", + }, + "create_api_key_uri": { + Type: schema.TypeString, + Computed: true, + Description: "The URI to create a new apikey for the application.", + }, + "href": { + Type: schema.TypeString, + Computed: true, + Description: "The URL for this application.", + }, + }, + }, + }, + }, + } +} + +func dataSourceIbmMqcloudApplicationRead(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { + mqcloudClient, err := meta.(conns.ClientSession).MqcloudV1() + if err != nil { + return diag.FromErr(err) + } + + err = checkSIPlan(d, meta) + if err != nil { + return diag.FromErr(fmt.Errorf("Read Application failed %s", err)) + } + + serviceInstanceGuid := d.Get("service_instance_guid").(string) + + // Support for pagination + offset := int64(0) + limit := int64(25) + allItems := []mqcloudv1.ApplicationDetails{} + + for { + listApplicationsOptions := &mqcloudv1.ListApplicationsOptions{ + ServiceInstanceGuid: &serviceInstanceGuid, + Limit: &limit, + Offset: &offset, + } + + result, response, err := mqcloudClient.ListApplicationsWithContext(context, listApplicationsOptions) + if err != nil { + return diag.FromErr(fmt.Errorf("[ERROR] Error Getting Applications %s\n%s", err, response)) + } + if result == nil { + return diag.FromErr(fmt.Errorf("List Applications returned nil")) + } + + allItems = append(allItems, result.Applications...) + + // Check if the number of returned records is less than the limit + if int64(len(result.Applications)) < limit { + break + } + + offset += limit + } + + // Use the provided filter argument and construct a new list with only the requested resource(s) + var matchApplications []mqcloudv1.ApplicationDetails + var name string + var suppliedFilter bool + + if v, ok := d.GetOk("name"); ok { + name = v.(string) + suppliedFilter = true + for _, data := range allItems { + if *data.Name == name { + matchApplications = append(matchApplications, data) + } + } + } else { + matchApplications = allItems + } + + allItems = matchApplications + + if suppliedFilter { + if len(allItems) == 0 { + return diag.FromErr(fmt.Errorf("No Applications found with name %s", name)) + } + d.SetId(name) + } else { + d.SetId(dataSourceIbmMqcloudApplicationID(d)) + } + + mapSlice := []map[string]interface{}{} + for _, modelItem := range allItems { + modelItem := modelItem + modelMap, err := dataSourceIbmMqcloudApplicationApplicationDetailsToMap(&modelItem) + if err != nil { + return diag.FromErr(err) + } + mapSlice = append(mapSlice, modelMap) + } + + if err = d.Set("applications", mapSlice); err != nil { + return diag.FromErr(fmt.Errorf("Error setting applications %s", err)) + } + + return nil +} + +// dataSourceIbmMqcloudApplicationID returns a reasonable ID for the list. +func dataSourceIbmMqcloudApplicationID(d *schema.ResourceData) string { + return time.Now().UTC().String() +} + +func dataSourceIbmMqcloudApplicationApplicationDetailsToMap(model *mqcloudv1.ApplicationDetails) (map[string]interface{}, error) { + modelMap := make(map[string]interface{}) + modelMap["id"] = model.ID + modelMap["name"] = model.Name + modelMap["create_api_key_uri"] = model.CreateApiKeyURI + modelMap["href"] = model.Href + return modelMap, nil +} diff --git a/ibm/service/mqcloud/data_source_ibm_mqcloud_application_test.go b/ibm/service/mqcloud/data_source_ibm_mqcloud_application_test.go new file mode 100644 index 0000000000..1c9f1d7347 --- /dev/null +++ b/ibm/service/mqcloud/data_source_ibm_mqcloud_application_test.go @@ -0,0 +1,87 @@ +// Copyright IBM Corp. 2023 All Rights Reserved. +// Licensed under the Mozilla Public License v2.0 + +package mqcloud_test + +import ( + "fmt" + "testing" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + + acc "github.com/IBM-Cloud/terraform-provider-ibm/ibm/acctest" +) + +func TestAccIbmMqcloudApplicationDataSourceBasic(t *testing.T) { + applicationDetailsServiceInstanceGuid := acc.MqcloudInstanceID + applicationDetailsName := "appdsbasic" + + resource.Test(t, resource.TestCase{ + PreCheck: func() { acc.TestAccPreCheckMqcloud(t) }, + Providers: acc.TestAccProviders, + Steps: []resource.TestStep{ + { + Config: testAccCheckIbmMqcloudApplicationDataSourceConfigBasic(applicationDetailsServiceInstanceGuid, applicationDetailsName), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttrSet("data.ibm_mqcloud_application.mqcloud_application_instance", "id"), + resource.TestCheckResourceAttrSet("data.ibm_mqcloud_application.mqcloud_application_instance", "service_instance_guid"), + resource.TestCheckResourceAttrSet("data.ibm_mqcloud_application.mqcloud_application_instance", "applications.#"), + resource.TestCheckResourceAttr("data.ibm_mqcloud_application.mqcloud_application_instance", "applications.0.name", applicationDetailsName), + ), + }, + }, + }) +} + +func TestAccIbmMqcloudApplicationDataSourceAllArgs(t *testing.T) { + applicationDetailsServiceInstanceGuid := acc.MqcloudInstanceID + applicationDetailsName := "appdsargs" + + resource.Test(t, resource.TestCase{ + PreCheck: func() { acc.TestAccPreCheckMqcloud(t) }, + Providers: acc.TestAccProviders, + Steps: []resource.TestStep{ + { + Config: testAccCheckIbmMqcloudApplicationDataSourceConfig(applicationDetailsServiceInstanceGuid, applicationDetailsName), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttrSet("data.ibm_mqcloud_application.mqcloud_application_instance", "id"), + resource.TestCheckResourceAttrSet("data.ibm_mqcloud_application.mqcloud_application_instance", "service_instance_guid"), + resource.TestCheckResourceAttrSet("data.ibm_mqcloud_application.mqcloud_application_instance", "name"), + resource.TestCheckResourceAttrSet("data.ibm_mqcloud_application.mqcloud_application_instance", "applications.#"), + resource.TestCheckResourceAttrSet("data.ibm_mqcloud_application.mqcloud_application_instance", "applications.0.id"), + resource.TestCheckResourceAttr("data.ibm_mqcloud_application.mqcloud_application_instance", "applications.0.name", applicationDetailsName), + resource.TestCheckResourceAttrSet("data.ibm_mqcloud_application.mqcloud_application_instance", "applications.0.create_api_key_uri"), + resource.TestCheckResourceAttrSet("data.ibm_mqcloud_application.mqcloud_application_instance", "applications.0.href"), + ), + }, + }, + }) +} + +func testAccCheckIbmMqcloudApplicationDataSourceConfigBasic(applicationDetailsServiceInstanceGuid string, applicationDetailsName string) string { + return fmt.Sprintf(` + resource "ibm_mqcloud_application" "mqcloud_application_instance" { + service_instance_guid = "%s" + name = "%s" + } + + data "ibm_mqcloud_application" "mqcloud_application_instance" { + service_instance_guid = ibm_mqcloud_application.mqcloud_application_instance.service_instance_guid + name = ibm_mqcloud_application.mqcloud_application_instance.name + } + `, applicationDetailsServiceInstanceGuid, applicationDetailsName) +} + +func testAccCheckIbmMqcloudApplicationDataSourceConfig(applicationDetailsServiceInstanceGuid string, applicationDetailsName string) string { + return fmt.Sprintf(` + resource "ibm_mqcloud_application" "mqcloud_application_instance" { + service_instance_guid = "%s" + name = "%s" + } + + data "ibm_mqcloud_application" "mqcloud_application_instance" { + service_instance_guid = ibm_mqcloud_application.mqcloud_application_instance.service_instance_guid + name = ibm_mqcloud_application.mqcloud_application_instance.name + } + `, applicationDetailsServiceInstanceGuid, applicationDetailsName) +} diff --git a/ibm/service/mqcloud/data_source_ibm_mqcloud_keystore_certificate.go b/ibm/service/mqcloud/data_source_ibm_mqcloud_keystore_certificate.go new file mode 100644 index 0000000000..0f27f37fa3 --- /dev/null +++ b/ibm/service/mqcloud/data_source_ibm_mqcloud_keystore_certificate.go @@ -0,0 +1,223 @@ +// Copyright IBM Corp. 2023 All Rights Reserved. +// Licensed under the Mozilla Public License v2.0 + +package mqcloud + +import ( + "context" + "fmt" + "log" + "time" + + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + + "github.com/IBM-Cloud/terraform-provider-ibm/ibm/conns" + "github.com/IBM-Cloud/terraform-provider-ibm/ibm/flex" + "github.com/IBM/mqcloud-go-sdk/mqcloudv1" +) + +func DataSourceIbmMqcloudKeystoreCertificate() *schema.Resource { + return &schema.Resource{ + ReadContext: dataSourceIbmMqcloudKeystoreCertificateRead, + + Schema: map[string]*schema.Schema{ + "service_instance_guid": { + Type: schema.TypeString, + Required: true, + Description: "The GUID that uniquely identifies the MQ on Cloud service instance.", + }, + "queue_manager_id": { + Type: schema.TypeString, + Required: true, + Description: "The id of the queue manager to retrieve its full details.", + }, + "label": { + Type: schema.TypeString, + Optional: true, + Description: "Certificate label in queue manager store.", + }, + "total_count": { + Type: schema.TypeInt, + Computed: true, + Description: "The total count of key store certificates.", + }, + "key_store": { + Type: schema.TypeList, + Computed: true, + Description: "The list of key store certificates.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "id": { + Type: schema.TypeString, + Computed: true, + Description: "ID of the certificate.", + }, + "label": { + Type: schema.TypeString, + Computed: true, + Description: "Certificate label in queue manager store.", + }, + "certificate_type": { + Type: schema.TypeString, + Computed: true, + Description: "The type of certificate.", + }, + "fingerprint_sha256": { + Type: schema.TypeString, + Computed: true, + Description: "Fingerprint SHA256.", + }, + "subject_dn": { + Type: schema.TypeString, + Computed: true, + Description: "Subject's Distinguished Name.", + }, + "subject_cn": { + Type: schema.TypeString, + Computed: true, + Description: "Subject's Common Name.", + }, + "issuer_dn": { + Type: schema.TypeString, + Computed: true, + Description: "Issuer's Distinguished Name.", + }, + "issuer_cn": { + Type: schema.TypeString, + Computed: true, + Description: "Issuer's Common Name.", + }, + "issued": { + Type: schema.TypeString, + Computed: true, + Description: "Date certificate was issued.", + }, + "expiry": { + Type: schema.TypeString, + Computed: true, + Description: "Expiry date for the certificate.", + }, + "is_default": { + Type: schema.TypeBool, + Computed: true, + Description: "Indicates whether it is the queue manager's default certificate.", + }, + "dns_names_total_count": { + Type: schema.TypeInt, + Computed: true, + Description: "The total count of dns names.", + }, + "dns_names": { + Type: schema.TypeList, + Computed: true, + Description: "The list of DNS names.", + Elem: &schema.Schema{ + Type: schema.TypeString, + }, + }, + "href": { + Type: schema.TypeString, + Computed: true, + Description: "The URL for this key store certificate.", + }, + }, + }, + }, + }, + } +} + +func dataSourceIbmMqcloudKeystoreCertificateRead(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { + mqcloudClient, err := meta.(conns.ClientSession).MqcloudV1() + if err != nil { + return diag.FromErr(err) + } + err = checkSIPlan(d, meta) + if err != nil { + return diag.FromErr(fmt.Errorf("Read Keystore Certificate failed %s", err)) + } + + listKeyStoreCertificatesOptions := &mqcloudv1.ListKeyStoreCertificatesOptions{} + + listKeyStoreCertificatesOptions.SetServiceInstanceGuid(d.Get("service_instance_guid").(string)) + listKeyStoreCertificatesOptions.SetQueueManagerID(d.Get("queue_manager_id").(string)) + + keyStoreCertificateDetailsCollection, response, err := mqcloudClient.ListKeyStoreCertificatesWithContext(context, listKeyStoreCertificatesOptions) + if err != nil { + log.Printf("[DEBUG] ListKeyStoreCertificatesWithContext failed %s\n%s", err, response) + return diag.FromErr(fmt.Errorf("ListKeyStoreCertificatesWithContext failed %s\n%s", err, response)) + } + + // Use the provided filter argument and construct a new list with only the requested resource(s) + var matchKeyStore []mqcloudv1.KeyStoreCertificateDetails + var label string + var suppliedFilter bool + + if v, ok := d.GetOk("label"); ok { + label = v.(string) + suppliedFilter = true + for _, data := range keyStoreCertificateDetailsCollection.KeyStore { + if *data.Label == label { + matchKeyStore = append(matchKeyStore, data) + } + } + } else { + matchKeyStore = keyStoreCertificateDetailsCollection.KeyStore + } + keyStoreCertificateDetailsCollection.KeyStore = matchKeyStore + + if suppliedFilter { + if len(keyStoreCertificateDetailsCollection.KeyStore) == 0 { + return diag.FromErr(fmt.Errorf("no KeyStore found with label %s", label)) + } + d.SetId(label) + } else { + d.SetId(dataSourceIbmMqcloudKeystoreCertificateID(d)) + } + + if err = d.Set("total_count", flex.IntValue(keyStoreCertificateDetailsCollection.TotalCount)); err != nil { + return diag.FromErr(fmt.Errorf("Error setting total_count: %s", err)) + } + + keyStore := []map[string]interface{}{} + if keyStoreCertificateDetailsCollection.KeyStore != nil { + for _, modelItem := range keyStoreCertificateDetailsCollection.KeyStore { + modelItem := modelItem + modelMap, err := dataSourceIbmMqcloudKeystoreCertificateKeyStoreCertificateDetailsToMap(&modelItem) + if err != nil { + return diag.FromErr(err) + } + keyStore = append(keyStore, modelMap) + } + } + if err = d.Set("key_store", keyStore); err != nil { + return diag.FromErr(fmt.Errorf("Error setting key_store %s", err)) + } + + return nil +} + +// dataSourceIbmMqcloudKeystoreCertificateID returns a reasonable ID for the list. +func dataSourceIbmMqcloudKeystoreCertificateID(d *schema.ResourceData) string { + return time.Now().UTC().String() +} + +func dataSourceIbmMqcloudKeystoreCertificateKeyStoreCertificateDetailsToMap(model *mqcloudv1.KeyStoreCertificateDetails) (map[string]interface{}, error) { + modelMap := make(map[string]interface{}) + modelMap["id"] = model.ID + modelMap["label"] = model.Label + modelMap["certificate_type"] = model.CertificateType + modelMap["fingerprint_sha256"] = model.FingerprintSha256 + modelMap["subject_dn"] = model.SubjectDn + modelMap["subject_cn"] = model.SubjectCn + modelMap["issuer_dn"] = model.IssuerDn + modelMap["issuer_cn"] = model.IssuerCn + modelMap["issued"] = model.Issued.String() + modelMap["expiry"] = model.Expiry.String() + modelMap["is_default"] = model.IsDefault + modelMap["dns_names_total_count"] = flex.IntValue(model.DnsNamesTotalCount) + modelMap["dns_names"] = model.DnsNames + modelMap["href"] = model.Href + return modelMap, nil +} diff --git a/ibm/service/mqcloud/data_source_ibm_mqcloud_keystore_certificate_test.go b/ibm/service/mqcloud/data_source_ibm_mqcloud_keystore_certificate_test.go new file mode 100644 index 0000000000..9f0b3218e6 --- /dev/null +++ b/ibm/service/mqcloud/data_source_ibm_mqcloud_keystore_certificate_test.go @@ -0,0 +1,107 @@ +// Copyright IBM Corp. 2023 All Rights Reserved. +// Licensed under the Mozilla Public License v2.0 + +package mqcloud_test + +import ( + "fmt" + "testing" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + + acc "github.com/IBM-Cloud/terraform-provider-ibm/ibm/acctest" +) + +func TestAccIbmMqcloudKeystoreCertificateDataSourceBasic(t *testing.T) { + keyStoreCertificateDetailsServiceInstanceGuid := acc.MqcloudInstanceID + keyStoreCertificateDetailsQueueManagerID := acc.MqcloudQueueManagerID + keyStoreCertificateDetailsLabel := fmt.Sprintf("tf_label_%d", acctest.RandIntRange(10, 100)) + keyStoreCertificateDetailsCertificateFile := acc.MqcloudKSCertFilePath + + resource.Test(t, resource.TestCase{ + PreCheck: func() { acc.TestAccPreCheckMqcloud(t) }, + Providers: acc.TestAccProviders, + Steps: []resource.TestStep{ + { + Config: testAccCheckIbmMqcloudKeystoreCertificateDataSourceConfigBasic(keyStoreCertificateDetailsServiceInstanceGuid, keyStoreCertificateDetailsQueueManagerID, keyStoreCertificateDetailsLabel, keyStoreCertificateDetailsCertificateFile), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttrSet("data.ibm_mqcloud_keystore_certificate.mqcloud_keystore_certificate_instance", "service_instance_guid"), + resource.TestCheckResourceAttrSet("data.ibm_mqcloud_keystore_certificate.mqcloud_keystore_certificate_instance", "queue_manager_id"), + resource.TestCheckResourceAttrSet("data.ibm_mqcloud_keystore_certificate.mqcloud_keystore_certificate_instance", "key_store.#"), + resource.TestCheckResourceAttr("data.ibm_mqcloud_keystore_certificate.mqcloud_keystore_certificate_instance", "key_store.0.label", keyStoreCertificateDetailsLabel), + ), + }, + }, + }) +} + +func TestAccIbmMqcloudKeystoreCertificateDataSourceAllArgs(t *testing.T) { + keyStoreCertificateDetailsServiceInstanceGuid := acc.MqcloudInstanceID + keyStoreCertificateDetailsQueueManagerID := acc.MqcloudQueueManagerID + keyStoreCertificateDetailsLabel := fmt.Sprintf("tf_label_%d", acctest.RandIntRange(10, 100)) + keyStoreCertificateDetailsCertificateFile := acc.MqcloudKSCertFilePath + + resource.Test(t, resource.TestCase{ + PreCheck: func() { acc.TestAccPreCheckMqcloud(t) }, + Providers: acc.TestAccProviders, + Steps: []resource.TestStep{ + { + Config: testAccCheckIbmMqcloudKeystoreCertificateDataSourceConfig(keyStoreCertificateDetailsServiceInstanceGuid, keyStoreCertificateDetailsQueueManagerID, keyStoreCertificateDetailsLabel, keyStoreCertificateDetailsCertificateFile), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttrSet("data.ibm_mqcloud_keystore_certificate.mqcloud_keystore_certificate_instance", "service_instance_guid"), + resource.TestCheckResourceAttrSet("data.ibm_mqcloud_keystore_certificate.mqcloud_keystore_certificate_instance", "queue_manager_id"), + resource.TestCheckResourceAttrSet("data.ibm_mqcloud_keystore_certificate.mqcloud_keystore_certificate_instance", "label"), + resource.TestCheckResourceAttrSet("data.ibm_mqcloud_keystore_certificate.mqcloud_keystore_certificate_instance", "total_count"), + resource.TestCheckResourceAttrSet("data.ibm_mqcloud_keystore_certificate.mqcloud_keystore_certificate_instance", "key_store.#"), + resource.TestCheckResourceAttr("data.ibm_mqcloud_keystore_certificate.mqcloud_keystore_certificate_instance", "key_store.0.label", keyStoreCertificateDetailsLabel), + resource.TestCheckResourceAttrSet("data.ibm_mqcloud_keystore_certificate.mqcloud_keystore_certificate_instance", "key_store.0.certificate_type"), + resource.TestCheckResourceAttrSet("data.ibm_mqcloud_keystore_certificate.mqcloud_keystore_certificate_instance", "key_store.0.fingerprint_sha256"), + resource.TestCheckResourceAttrSet("data.ibm_mqcloud_keystore_certificate.mqcloud_keystore_certificate_instance", "key_store.0.subject_dn"), + resource.TestCheckResourceAttrSet("data.ibm_mqcloud_keystore_certificate.mqcloud_keystore_certificate_instance", "key_store.0.subject_cn"), + resource.TestCheckResourceAttrSet("data.ibm_mqcloud_keystore_certificate.mqcloud_keystore_certificate_instance", "key_store.0.issuer_dn"), + resource.TestCheckResourceAttrSet("data.ibm_mqcloud_keystore_certificate.mqcloud_keystore_certificate_instance", "key_store.0.issuer_cn"), + resource.TestCheckResourceAttrSet("data.ibm_mqcloud_keystore_certificate.mqcloud_keystore_certificate_instance", "key_store.0.issued"), + resource.TestCheckResourceAttrSet("data.ibm_mqcloud_keystore_certificate.mqcloud_keystore_certificate_instance", "key_store.0.expiry"), + resource.TestCheckResourceAttrSet("data.ibm_mqcloud_keystore_certificate.mqcloud_keystore_certificate_instance", "key_store.0.is_default"), + resource.TestCheckResourceAttrSet("data.ibm_mqcloud_keystore_certificate.mqcloud_keystore_certificate_instance", "key_store.0.dns_names_total_count"), + resource.TestCheckResourceAttrSet("data.ibm_mqcloud_keystore_certificate.mqcloud_keystore_certificate_instance", "key_store.0.href"), + ), + }, + }, + }) +} + +func testAccCheckIbmMqcloudKeystoreCertificateDataSourceConfigBasic(keyStoreCertificateDetailsServiceInstanceGuid string, keyStoreCertificateDetailsQueueManagerID string, keyStoreCertificateDetailsLabel string, keyStoreCertificateDetailsCertificateFile string) string { + return fmt.Sprintf(` + resource "ibm_mqcloud_keystore_certificate" "mqcloud_keystore_certificate_instance" { + service_instance_guid = "%s" + queue_manager_id = "%s" + label = "%s" + certificate_file = "%s" + } + + data "ibm_mqcloud_keystore_certificate" "mqcloud_keystore_certificate_instance" { + service_instance_guid = ibm_mqcloud_keystore_certificate.mqcloud_keystore_certificate_instance.service_instance_guid + queue_manager_id = ibm_mqcloud_keystore_certificate.mqcloud_keystore_certificate_instance.queue_manager_id + label = ibm_mqcloud_keystore_certificate.mqcloud_keystore_certificate_instance.label + } + `, keyStoreCertificateDetailsServiceInstanceGuid, keyStoreCertificateDetailsQueueManagerID, keyStoreCertificateDetailsLabel, keyStoreCertificateDetailsCertificateFile) +} + +func testAccCheckIbmMqcloudKeystoreCertificateDataSourceConfig(keyStoreCertificateDetailsServiceInstanceGuid string, keyStoreCertificateDetailsQueueManagerID string, keyStoreCertificateDetailsLabel string, keyStoreCertificateDetailsCertificateFile string) string { + return fmt.Sprintf(` + resource "ibm_mqcloud_keystore_certificate" "mqcloud_keystore_certificate_instance" { + service_instance_guid = "%s" + queue_manager_id = "%s" + label = "%s" + certificate_file = "%s" + } + + data "ibm_mqcloud_keystore_certificate" "mqcloud_keystore_certificate_instance" { + service_instance_guid = ibm_mqcloud_keystore_certificate.mqcloud_keystore_certificate_instance.service_instance_guid + queue_manager_id = ibm_mqcloud_keystore_certificate.mqcloud_keystore_certificate_instance.queue_manager_id + label = ibm_mqcloud_keystore_certificate.mqcloud_keystore_certificate_instance.label + } + `, keyStoreCertificateDetailsServiceInstanceGuid, keyStoreCertificateDetailsQueueManagerID, keyStoreCertificateDetailsLabel, keyStoreCertificateDetailsCertificateFile) +} diff --git a/ibm/service/mqcloud/data_source_ibm_mqcloud_queue_manager.go b/ibm/service/mqcloud/data_source_ibm_mqcloud_queue_manager.go new file mode 100644 index 0000000000..42774e4bce --- /dev/null +++ b/ibm/service/mqcloud/data_source_ibm_mqcloud_queue_manager.go @@ -0,0 +1,232 @@ +// Copyright IBM Corp. 2023 All Rights Reserved. +// Licensed under the Mozilla Public License v2.0 + +package mqcloud + +import ( + "context" + "fmt" + "time" + + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + + "github.com/IBM-Cloud/terraform-provider-ibm/ibm/conns" + "github.com/IBM/mqcloud-go-sdk/mqcloudv1" +) + +func DataSourceIbmMqcloudQueueManager() *schema.Resource { + return &schema.Resource{ + ReadContext: dataSourceIbmMqcloudQueueManagerRead, + + Schema: map[string]*schema.Schema{ + "service_instance_guid": { + Type: schema.TypeString, + Required: true, + Description: "The GUID that uniquely identifies the MQ on Cloud service instance.", + }, + "name": { + Type: schema.TypeString, + Optional: true, + Description: "A queue manager name conforming to MQ restrictions.", + }, + "queue_managers": { + Type: schema.TypeList, + Computed: true, + Description: "List of queue managers.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "id": { + Type: schema.TypeString, + Computed: true, + Description: "The ID of the queue manager which was allocated on creation, and can be used for delete calls.", + }, + "name": { + Type: schema.TypeString, + Computed: true, + Description: "A queue manager name conforming to MQ restrictions.", + }, + "display_name": { + Type: schema.TypeString, + Computed: true, + Description: "A displayable name for the queue manager - limited only in length.", + }, + "location": { + Type: schema.TypeString, + Computed: true, + Description: "The locations in which the queue manager could be deployed.", + }, + "size": { + Type: schema.TypeString, + Computed: true, + Description: "The queue manager sizes of deployment available. Deployment of lite queue managers for aws_us_east_1 and aws_eu_west_1 locations is not available.", + }, + "status_uri": { + Type: schema.TypeString, + Computed: true, + Description: "A reference uri to get deployment status of the queue manager.", + }, + "version": { + Type: schema.TypeString, + Computed: true, + Description: "The MQ version of the queue manager.", + }, + "web_console_url": { + Type: schema.TypeString, + Computed: true, + Description: "The url through which to access the web console for this queue manager.", + }, + "rest_api_endpoint_url": { + Type: schema.TypeString, + Computed: true, + Description: "The url through which to access REST APIs for this queue manager.", + }, + "administrator_api_endpoint_url": { + Type: schema.TypeString, + Computed: true, + Description: "The url through which to access the Admin REST APIs for this queue manager.", + }, + "connection_info_uri": { + Type: schema.TypeString, + Computed: true, + Description: "The uri through which the CDDT for this queue manager can be obtained.", + }, + "date_created": { + Type: schema.TypeString, + Computed: true, + Description: "RFC3339 formatted UTC date for when the queue manager was created.", + }, + "upgrade_available": { + Type: schema.TypeBool, + Computed: true, + Description: "Describes whether an upgrade is available for this queue manager.", + }, + "available_upgrade_versions_uri": { + Type: schema.TypeString, + Computed: true, + Description: "The uri through which the available versions to upgrade to can be found for this queue manager.", + }, + "href": { + Type: schema.TypeString, + Computed: true, + Description: "The URL for this queue manager.", + }, + }, + }, + }, + }, + } +} + +func dataSourceIbmMqcloudQueueManagerRead(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { + mqcloudClient, err := meta.(conns.ClientSession).MqcloudV1() + if err != nil { + return diag.FromErr(err) + } + + err = checkSIPlan(d, meta) + if err != nil { + return diag.FromErr(fmt.Errorf("Read Queue Manager failed %s", err)) + } + + serviceInstanceGuid := d.Get("service_instance_guid").(string) + + // Support for pagination + offset := int64(0) + limit := int64(25) + allItems := []mqcloudv1.QueueManagerDetails{} + + for { + listQueueManagersOptions := &mqcloudv1.ListQueueManagersOptions{ + ServiceInstanceGuid: &serviceInstanceGuid, + Limit: &limit, + Offset: &offset, + } + + result, response, err := mqcloudClient.ListQueueManagersWithContext(context, listQueueManagersOptions) + if err != nil { + return diag.FromErr(fmt.Errorf("[ERROR] Error Getting QueueManagers %s\n%s", err, response)) + } + if result == nil { + return diag.FromErr(fmt.Errorf("List QueueManagers returned nil")) + } + + allItems = append(allItems, result.QueueManagers...) + + // Check if the number of returned records is less than the limit + if int64(len(result.QueueManagers)) < limit { + break + } + + offset += limit + } + + // Use the provided filter argument and construct a new list with only the requested resource(s) + var matchQueueManagers []mqcloudv1.QueueManagerDetails + var name string + var suppliedFilter bool + + if v, ok := d.GetOk("name"); ok { + name = v.(string) + suppliedFilter = true + for _, data := range allItems { + if *data.Name == name { + matchQueueManagers = append(matchQueueManagers, data) + } + } + } else { + matchQueueManagers = allItems + } + + allItems = matchQueueManagers + + if suppliedFilter { + if len(allItems) == 0 { + return diag.FromErr(fmt.Errorf("No Queue Managers found with name %s", name)) + } + d.SetId(name) + } else { + d.SetId(dataSourceIbmMqcloudQueueManagerID(d)) + } + + mapSlice := []map[string]interface{}{} + for _, modelItem := range allItems { + modelItem := modelItem + modelMap, err := dataSourceIbmMqcloudQueueManagerQueueManagerDetailsToMap(&modelItem) + if err != nil { + return diag.FromErr(err) + } + mapSlice = append(mapSlice, modelMap) + } + + if err = d.Set("queue_managers", mapSlice); err != nil { + return diag.FromErr(fmt.Errorf("Error setting queue_managers %s", err)) + } + + return nil +} + +// dataSourceIbmMqcloudQueueManagerID returns a reasonable ID for the list. +func dataSourceIbmMqcloudQueueManagerID(d *schema.ResourceData) string { + return time.Now().UTC().String() +} + +func dataSourceIbmMqcloudQueueManagerQueueManagerDetailsToMap(model *mqcloudv1.QueueManagerDetails) (map[string]interface{}, error) { + modelMap := make(map[string]interface{}) + modelMap["id"] = model.ID + modelMap["name"] = model.Name + modelMap["display_name"] = model.DisplayName + modelMap["location"] = model.Location + modelMap["size"] = model.Size + modelMap["status_uri"] = model.StatusURI + modelMap["version"] = model.Version + modelMap["web_console_url"] = model.WebConsoleURL + modelMap["rest_api_endpoint_url"] = model.RestApiEndpointURL + modelMap["administrator_api_endpoint_url"] = model.AdministratorApiEndpointURL + modelMap["connection_info_uri"] = model.ConnectionInfoURI + modelMap["date_created"] = model.DateCreated.String() + modelMap["upgrade_available"] = model.UpgradeAvailable + modelMap["available_upgrade_versions_uri"] = model.AvailableUpgradeVersionsURI + modelMap["href"] = model.Href + return modelMap, nil +} diff --git a/ibm/service/mqcloud/data_source_ibm_mqcloud_queue_manager_status.go b/ibm/service/mqcloud/data_source_ibm_mqcloud_queue_manager_status.go new file mode 100644 index 0000000000..835949afed --- /dev/null +++ b/ibm/service/mqcloud/data_source_ibm_mqcloud_queue_manager_status.go @@ -0,0 +1,77 @@ +// Copyright IBM Corp. 2023 All Rights Reserved. +// Licensed under the Mozilla Public License v2.0 + +package mqcloud + +import ( + "context" + "fmt" + "log" + "time" + + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + + "github.com/IBM-Cloud/terraform-provider-ibm/ibm/conns" + "github.com/IBM/mqcloud-go-sdk/mqcloudv1" +) + +func DataSourceIbmMqcloudQueueManagerStatus() *schema.Resource { + return &schema.Resource{ + ReadContext: dataSourceIbmMqcloudQueueManagerStatusRead, + + Schema: map[string]*schema.Schema{ + "service_instance_guid": { + Type: schema.TypeString, + Required: true, + Description: "The GUID that uniquely identifies the MQ on Cloud service instance.", + }, + "queue_manager_id": { + Type: schema.TypeString, + Required: true, + Description: "The id of the queue manager to retrieve its full details.", + }, + "status": { + Type: schema.TypeString, + Computed: true, + Description: "The deploying and failed states are not queue manager states, they are states which can occur when the request to deploy has been fired, or with that request has failed without producing a queue manager to have any state. The other states map to the queue manager states. State \"ending\" is either quiesing or ending immediately. State \"ended\" is either ended normally or endedimmediately. The others map one to one with queue manager states.", + }, + }, + } +} + +func dataSourceIbmMqcloudQueueManagerStatusRead(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { + mqcloudClient, err := meta.(conns.ClientSession).MqcloudV1() + if err != nil { + return diag.FromErr(err) + } + + err = checkSIPlan(d, meta) + if err != nil { + return diag.FromErr(fmt.Errorf("Read Queue Manager Status failed %s", err)) + } + + getQueueManagerStatusOptions := &mqcloudv1.GetQueueManagerStatusOptions{} + + getQueueManagerStatusOptions.SetServiceInstanceGuid(d.Get("service_instance_guid").(string)) + getQueueManagerStatusOptions.SetQueueManagerID(d.Get("queue_manager_id").(string)) + + queueManagerStatus, response, err := mqcloudClient.GetQueueManagerStatusWithContext(context, getQueueManagerStatusOptions) + if err != nil { + log.Printf("[DEBUG] GetQueueManagerStatusWithContext failed %s\n%s", err, response) + return diag.FromErr(fmt.Errorf("GetQueueManagerStatusWithContext failed %s\n%s", err, response)) + } + + d.SetId(dataSourceIbmMqcloudQueueManagerStatusID(d)) + + if err = d.Set("status", queueManagerStatus.Status); err != nil { + return diag.FromErr(fmt.Errorf("Error setting status: %s", err)) + } + + return nil +} + +// dataSourceIbmMqcloudQueueManagerStatusID returns a reasonable ID for the list. +func dataSourceIbmMqcloudQueueManagerStatusID(d *schema.ResourceData) string { + return time.Now().UTC().String() +} diff --git a/ibm/service/mqcloud/data_source_ibm_mqcloud_queue_manager_status_test.go b/ibm/service/mqcloud/data_source_ibm_mqcloud_queue_manager_status_test.go new file mode 100644 index 0000000000..c09b3d5ba6 --- /dev/null +++ b/ibm/service/mqcloud/data_source_ibm_mqcloud_queue_manager_status_test.go @@ -0,0 +1,44 @@ +// Copyright IBM Corp. 2023 All Rights Reserved. +// Licensed under the Mozilla Public License v2.0 + +package mqcloud_test + +import ( + "fmt" + "testing" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + + acc "github.com/IBM-Cloud/terraform-provider-ibm/ibm/acctest" +) + +func TestAccIbmMqcloudQueueManagerStatusDataSourceBasic(t *testing.T) { + t.Parallel() + service_instance_guid := acc.MqcloudInstanceID + queue_manager_id := acc.MqcloudQueueManagerID + + resource.Test(t, resource.TestCase{ + PreCheck: func() { acc.TestAccPreCheckMqcloud(t) }, + Providers: acc.TestAccProviders, + Steps: []resource.TestStep{ + { + Config: testAccCheckIbmMqcloudQueueManagerStatusDataSourceConfigBasic(service_instance_guid, queue_manager_id), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttrSet("data.ibm_mqcloud_queue_manager_status.mqcloud_queue_manager_status_instance", "id"), + resource.TestCheckResourceAttrSet("data.ibm_mqcloud_queue_manager_status.mqcloud_queue_manager_status_instance", "service_instance_guid"), + resource.TestCheckResourceAttrSet("data.ibm_mqcloud_queue_manager_status.mqcloud_queue_manager_status_instance", "queue_manager_id"), + resource.TestCheckResourceAttrSet("data.ibm_mqcloud_queue_manager_status.mqcloud_queue_manager_status_instance", "status"), + ), + }, + }, + }) +} + +func testAccCheckIbmMqcloudQueueManagerStatusDataSourceConfigBasic(service_instance_guid string, queue_manager_id string) string { + return fmt.Sprintf(` + data "ibm_mqcloud_queue_manager_status" "mqcloud_queue_manager_status_instance" { + service_instance_guid = "%s" + queue_manager_id = "%s" + } + `, service_instance_guid, queue_manager_id) +} diff --git a/ibm/service/mqcloud/data_source_ibm_mqcloud_queue_manager_test.go b/ibm/service/mqcloud/data_source_ibm_mqcloud_queue_manager_test.go new file mode 100644 index 0000000000..69f9690370 --- /dev/null +++ b/ibm/service/mqcloud/data_source_ibm_mqcloud_queue_manager_test.go @@ -0,0 +1,114 @@ +// Copyright IBM Corp. 2023 All Rights Reserved. +// Licensed under the Mozilla Public License v2.0 + +package mqcloud_test + +import ( + "fmt" + "testing" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + + acc "github.com/IBM-Cloud/terraform-provider-ibm/ibm/acctest" +) + +func TestAccIbmMqcloudQueueManagerDataSourceBasic(t *testing.T) { + t.Parallel() + queueManagerDetailsServiceInstanceGuid := acc.MqcloudInstanceID + queueManagerDetailsName := "queue_manager_ds_basic" + queueManagerDetailsLocation := "ibmcloud_eu_de" + queueManagerDetailsSize := "small" + + resource.Test(t, resource.TestCase{ + PreCheck: func() { acc.TestAccPreCheckMqcloud(t) }, + Providers: acc.TestAccProviders, + Steps: []resource.TestStep{ + { + Config: testAccCheckIbmMqcloudQueueManagerDataSourceConfigBasic(queueManagerDetailsServiceInstanceGuid, queueManagerDetailsName, queueManagerDetailsLocation, queueManagerDetailsSize), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttrSet("data.ibm_mqcloud_queue_manager.mqcloud_queue_manager_instance", "id"), + resource.TestCheckResourceAttrSet("data.ibm_mqcloud_queue_manager.mqcloud_queue_manager_instance", "service_instance_guid"), + resource.TestCheckResourceAttrSet("data.ibm_mqcloud_queue_manager.mqcloud_queue_manager_instance", "queue_managers.#"), + resource.TestCheckResourceAttr("data.ibm_mqcloud_queue_manager.mqcloud_queue_manager_instance", "queue_managers.0.name", queueManagerDetailsName), + resource.TestCheckResourceAttr("data.ibm_mqcloud_queue_manager.mqcloud_queue_manager_instance", "queue_managers.0.location", queueManagerDetailsLocation), + resource.TestCheckResourceAttr("data.ibm_mqcloud_queue_manager.mqcloud_queue_manager_instance", "queue_managers.0.size", queueManagerDetailsSize), + ), + }, + }, + }) +} + +func TestAccIbmMqcloudQueueManagerDataSourceAllArgs(t *testing.T) { + t.Parallel() + queueManagerDetailsServiceInstanceGuid := acc.MqcloudInstanceID + queueManagerDetailsName := "queue_manager_ds_allargs" + queueManagerDetailsDisplayName := "queue_manager_ds_allargs" + queueManagerDetailsLocation := "ibmcloud_eu_de" + queueManagerDetailsSize := "small" + queueManagerDetailsVersion := "9.3.3_3" + + resource.Test(t, resource.TestCase{ + PreCheck: func() { acc.TestAccPreCheckMqcloud(t) }, + Providers: acc.TestAccProviders, + Steps: []resource.TestStep{ + { + Config: testAccCheckIbmMqcloudQueueManagerDataSourceConfig(queueManagerDetailsServiceInstanceGuid, queueManagerDetailsName, queueManagerDetailsDisplayName, queueManagerDetailsLocation, queueManagerDetailsSize, queueManagerDetailsVersion), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttrSet("data.ibm_mqcloud_queue_manager.mqcloud_queue_manager_instance", "id"), + resource.TestCheckResourceAttrSet("data.ibm_mqcloud_queue_manager.mqcloud_queue_manager_instance", "service_instance_guid"), + resource.TestCheckResourceAttrSet("data.ibm_mqcloud_queue_manager.mqcloud_queue_manager_instance", "name"), + resource.TestCheckResourceAttrSet("data.ibm_mqcloud_queue_manager.mqcloud_queue_manager_instance", "queue_managers.#"), + resource.TestCheckResourceAttrSet("data.ibm_mqcloud_queue_manager.mqcloud_queue_manager_instance", "queue_managers.0.id"), + resource.TestCheckResourceAttr("data.ibm_mqcloud_queue_manager.mqcloud_queue_manager_instance", "queue_managers.0.name", queueManagerDetailsName), + resource.TestCheckResourceAttr("data.ibm_mqcloud_queue_manager.mqcloud_queue_manager_instance", "queue_managers.0.display_name", queueManagerDetailsDisplayName), + resource.TestCheckResourceAttr("data.ibm_mqcloud_queue_manager.mqcloud_queue_manager_instance", "queue_managers.0.location", queueManagerDetailsLocation), + resource.TestCheckResourceAttr("data.ibm_mqcloud_queue_manager.mqcloud_queue_manager_instance", "queue_managers.0.size", queueManagerDetailsSize), + resource.TestCheckResourceAttrSet("data.ibm_mqcloud_queue_manager.mqcloud_queue_manager_instance", "queue_managers.0.status_uri"), + resource.TestCheckResourceAttr("data.ibm_mqcloud_queue_manager.mqcloud_queue_manager_instance", "queue_managers.0.version", queueManagerDetailsVersion), + resource.TestCheckResourceAttrSet("data.ibm_mqcloud_queue_manager.mqcloud_queue_manager_instance", "queue_managers.0.web_console_url"), + resource.TestCheckResourceAttrSet("data.ibm_mqcloud_queue_manager.mqcloud_queue_manager_instance", "queue_managers.0.rest_api_endpoint_url"), + resource.TestCheckResourceAttrSet("data.ibm_mqcloud_queue_manager.mqcloud_queue_manager_instance", "queue_managers.0.administrator_api_endpoint_url"), + resource.TestCheckResourceAttrSet("data.ibm_mqcloud_queue_manager.mqcloud_queue_manager_instance", "queue_managers.0.connection_info_uri"), + resource.TestCheckResourceAttrSet("data.ibm_mqcloud_queue_manager.mqcloud_queue_manager_instance", "queue_managers.0.date_created"), + resource.TestCheckResourceAttrSet("data.ibm_mqcloud_queue_manager.mqcloud_queue_manager_instance", "queue_managers.0.upgrade_available"), + resource.TestCheckResourceAttrSet("data.ibm_mqcloud_queue_manager.mqcloud_queue_manager_instance", "queue_managers.0.available_upgrade_versions_uri"), + resource.TestCheckResourceAttrSet("data.ibm_mqcloud_queue_manager.mqcloud_queue_manager_instance", "queue_managers.0.href"), + ), + }, + }, + }) +} + +func testAccCheckIbmMqcloudQueueManagerDataSourceConfigBasic(queueManagerDetailsServiceInstanceGuid string, queueManagerDetailsName string, queueManagerDetailsLocation string, queueManagerDetailsSize string) string { + return fmt.Sprintf(` + resource "ibm_mqcloud_queue_manager" "mqcloud_queue_manager_instance" { + service_instance_guid = "%s" + name = "%s" + location = "%s" + size = "%s" + } + + data "ibm_mqcloud_queue_manager" "mqcloud_queue_manager_instance" { + service_instance_guid = ibm_mqcloud_queue_manager.mqcloud_queue_manager_instance.service_instance_guid + name = ibm_mqcloud_queue_manager.mqcloud_queue_manager_instance.name + } + `, queueManagerDetailsServiceInstanceGuid, queueManagerDetailsName, queueManagerDetailsLocation, queueManagerDetailsSize) +} + +func testAccCheckIbmMqcloudQueueManagerDataSourceConfig(queueManagerDetailsServiceInstanceGuid string, queueManagerDetailsName string, queueManagerDetailsDisplayName string, queueManagerDetailsLocation string, queueManagerDetailsSize string, queueManagerDetailsVersion string) string { + return fmt.Sprintf(` + resource "ibm_mqcloud_queue_manager" "mqcloud_queue_manager_instance" { + service_instance_guid = "%s" + name = "%s" + display_name = "%s" + location = "%s" + size = "%s" + version = "%s" + } + + data "ibm_mqcloud_queue_manager" "mqcloud_queue_manager_instance" { + service_instance_guid = ibm_mqcloud_queue_manager.mqcloud_queue_manager_instance.service_instance_guid + name = ibm_mqcloud_queue_manager.mqcloud_queue_manager_instance.name + } + `, queueManagerDetailsServiceInstanceGuid, queueManagerDetailsName, queueManagerDetailsDisplayName, queueManagerDetailsLocation, queueManagerDetailsSize, queueManagerDetailsVersion) +} diff --git a/ibm/service/mqcloud/data_source_ibm_mqcloud_truststore_certificate.go b/ibm/service/mqcloud/data_source_ibm_mqcloud_truststore_certificate.go new file mode 100644 index 0000000000..265c2cb8b1 --- /dev/null +++ b/ibm/service/mqcloud/data_source_ibm_mqcloud_truststore_certificate.go @@ -0,0 +1,208 @@ +// Copyright IBM Corp. 2023 All Rights Reserved. +// Licensed under the Mozilla Public License v2.0 + +package mqcloud + +import ( + "context" + "fmt" + "log" + "time" + + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + + "github.com/IBM-Cloud/terraform-provider-ibm/ibm/conns" + "github.com/IBM-Cloud/terraform-provider-ibm/ibm/flex" + "github.com/IBM/mqcloud-go-sdk/mqcloudv1" +) + +func DataSourceIbmMqcloudTruststoreCertificate() *schema.Resource { + return &schema.Resource{ + ReadContext: dataSourceIbmMqcloudTruststoreCertificateRead, + + Schema: map[string]*schema.Schema{ + "service_instance_guid": { + Type: schema.TypeString, + Required: true, + Description: "The GUID that uniquely identifies the MQ on Cloud service instance.", + }, + "queue_manager_id": { + Type: schema.TypeString, + Required: true, + Description: "The id of the queue manager to retrieve its full details.", + }, + "label": { + Type: schema.TypeString, + Optional: true, + Description: "Certificate label in queue manager store.", + }, + "total_count": { + Type: schema.TypeInt, + Computed: true, + Description: "The total count of trust store certificates.", + }, + "trust_store": { + Type: schema.TypeList, + Computed: true, + Description: "The list of trust store certificates.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "id": { + Type: schema.TypeString, + Computed: true, + Description: "Id of the certificate.", + }, + "label": { + Type: schema.TypeString, + Computed: true, + Description: "Certificate label in queue manager store.", + }, + "certificate_type": { + Type: schema.TypeString, + Computed: true, + Description: "The type of certificate.", + }, + "fingerprint_sha256": { + Type: schema.TypeString, + Computed: true, + Description: "Fingerprint SHA256.", + }, + "subject_dn": { + Type: schema.TypeString, + Computed: true, + Description: "Subject's Distinguished Name.", + }, + "subject_cn": { + Type: schema.TypeString, + Computed: true, + Description: "Subject's Common Name.", + }, + "issuer_dn": { + Type: schema.TypeString, + Computed: true, + Description: "Issuer's Distinguished Name.", + }, + "issuer_cn": { + Type: schema.TypeString, + Computed: true, + Description: "Issuer's Common Name.", + }, + "issued": { + Type: schema.TypeString, + Computed: true, + Description: "The Date the certificate was issued.", + }, + "expiry": { + Type: schema.TypeString, + Computed: true, + Description: "Expiry date for the certificate.", + }, + "trusted": { + Type: schema.TypeBool, + Computed: true, + Description: "Indicates whether a certificate is trusted.", + }, + "href": { + Type: schema.TypeString, + Computed: true, + Description: "The URL for this trust store certificate.", + }, + }, + }, + }, + }, + } +} + +func dataSourceIbmMqcloudTruststoreCertificateRead(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { + mqcloudClient, err := meta.(conns.ClientSession).MqcloudV1() + if err != nil { + return diag.FromErr(err) + } + err = checkSIPlan(d, meta) + if err != nil { + return diag.FromErr(fmt.Errorf("Read Truststore Certificate failed %s", err)) + } + + listTrustStoreCertificatesOptions := &mqcloudv1.ListTrustStoreCertificatesOptions{} + + listTrustStoreCertificatesOptions.SetServiceInstanceGuid(d.Get("service_instance_guid").(string)) + listTrustStoreCertificatesOptions.SetQueueManagerID(d.Get("queue_manager_id").(string)) + + trustStoreCertificateDetailsCollection, response, err := mqcloudClient.ListTrustStoreCertificatesWithContext(context, listTrustStoreCertificatesOptions) + if err != nil { + log.Printf("[DEBUG] ListTrustStoreCertificatesWithContext failed %s\n%s", err, response) + return diag.FromErr(fmt.Errorf("ListTrustStoreCertificatesWithContext failed %s\n%s", err, response)) + } + + // Use the provided filter argument and construct a new list with only the requested resource(s) + var matchTrustStore []mqcloudv1.TrustStoreCertificateDetails + var label string + var suppliedFilter bool + + if v, ok := d.GetOk("label"); ok { + label = v.(string) + suppliedFilter = true + for _, data := range trustStoreCertificateDetailsCollection.TrustStore { + if *data.Label == label { + matchTrustStore = append(matchTrustStore, data) + } + } + } else { + matchTrustStore = trustStoreCertificateDetailsCollection.TrustStore + } + trustStoreCertificateDetailsCollection.TrustStore = matchTrustStore + + if suppliedFilter { + if len(trustStoreCertificateDetailsCollection.TrustStore) == 0 { + return diag.FromErr(fmt.Errorf("no TrustStore found with label %s", label)) + } + d.SetId(label) + } else { + d.SetId(dataSourceIbmMqcloudTruststoreCertificateID(d)) + } + + if err = d.Set("total_count", flex.IntValue(trustStoreCertificateDetailsCollection.TotalCount)); err != nil { + return diag.FromErr(fmt.Errorf("Error setting total_count: %s", err)) + } + + trustStore := []map[string]interface{}{} + if trustStoreCertificateDetailsCollection.TrustStore != nil { + for _, modelItem := range trustStoreCertificateDetailsCollection.TrustStore { + modelItem := modelItem + modelMap, err := dataSourceIbmMqcloudTruststoreCertificateTrustStoreCertificateDetailsToMap(&modelItem) + if err != nil { + return diag.FromErr(err) + } + trustStore = append(trustStore, modelMap) + } + } + if err = d.Set("trust_store", trustStore); err != nil { + return diag.FromErr(fmt.Errorf("Error setting trust_store %s", err)) + } + + return nil +} + +// dataSourceIbmMqcloudTruststoreCertificateID returns a reasonable ID for the list. +func dataSourceIbmMqcloudTruststoreCertificateID(d *schema.ResourceData) string { + return time.Now().UTC().String() +} + +func dataSourceIbmMqcloudTruststoreCertificateTrustStoreCertificateDetailsToMap(model *mqcloudv1.TrustStoreCertificateDetails) (map[string]interface{}, error) { + modelMap := make(map[string]interface{}) + modelMap["id"] = model.ID + modelMap["label"] = model.Label + modelMap["certificate_type"] = model.CertificateType + modelMap["fingerprint_sha256"] = model.FingerprintSha256 + modelMap["subject_dn"] = model.SubjectDn + modelMap["subject_cn"] = model.SubjectCn + modelMap["issuer_dn"] = model.IssuerDn + modelMap["issuer_cn"] = model.IssuerCn + modelMap["issued"] = model.Issued.String() + modelMap["expiry"] = model.Expiry.String() + modelMap["trusted"] = model.Trusted + modelMap["href"] = model.Href + return modelMap, nil +} diff --git a/ibm/service/mqcloud/data_source_ibm_mqcloud_truststore_certificate_test.go b/ibm/service/mqcloud/data_source_ibm_mqcloud_truststore_certificate_test.go new file mode 100644 index 0000000000..a4c50e196f --- /dev/null +++ b/ibm/service/mqcloud/data_source_ibm_mqcloud_truststore_certificate_test.go @@ -0,0 +1,106 @@ +// Copyright IBM Corp. 2023 All Rights Reserved. +// Licensed under the Mozilla Public License v2.0 + +package mqcloud_test + +import ( + "fmt" + "testing" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + + acc "github.com/IBM-Cloud/terraform-provider-ibm/ibm/acctest" +) + +func TestAccIbmMqcloudTruststoreCertificateDataSourceBasic(t *testing.T) { + trustStoreCertificateDetailsServiceInstanceGuid := acc.MqcloudInstanceID + trustStoreCertificateDetailsQueueManagerID := acc.MqcloudQueueManagerID + trustStoreCertificateDetailsLabel := fmt.Sprintf("tf_label_%d", acctest.RandIntRange(10, 100)) + trustStoreCertificateDetailsCertificateFile := acc.MqcloudTSCertFilePath + + resource.Test(t, resource.TestCase{ + PreCheck: func() { acc.TestAccPreCheckMqcloud(t) }, + Providers: acc.TestAccProviders, + Steps: []resource.TestStep{ + { + Config: testAccCheckIbmMqcloudTruststoreCertificateDataSourceConfigBasic(trustStoreCertificateDetailsServiceInstanceGuid, trustStoreCertificateDetailsQueueManagerID, trustStoreCertificateDetailsLabel, trustStoreCertificateDetailsCertificateFile), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttrSet("data.ibm_mqcloud_truststore_certificate.mqcloud_truststore_certificate_instance", "service_instance_guid"), + resource.TestCheckResourceAttrSet("data.ibm_mqcloud_truststore_certificate.mqcloud_truststore_certificate_instance", "queue_manager_id"), + resource.TestCheckResourceAttrSet("data.ibm_mqcloud_truststore_certificate.mqcloud_truststore_certificate_instance", "trust_store.#"), + resource.TestCheckResourceAttr("data.ibm_mqcloud_truststore_certificate.mqcloud_truststore_certificate_instance", "trust_store.0.label", trustStoreCertificateDetailsLabel), + ), + }, + }, + }) +} + +func TestAccIbmMqcloudTruststoreCertificateDataSourceAllArgs(t *testing.T) { + trustStoreCertificateDetailsServiceInstanceGuid := acc.MqcloudInstanceID + trustStoreCertificateDetailsQueueManagerID := acc.MqcloudQueueManagerID + trustStoreCertificateDetailsLabel := fmt.Sprintf("tf_label_%d", acctest.RandIntRange(10, 100)) + trustStoreCertificateDetailsCertificateFile := acc.MqcloudTSCertFilePath + + resource.Test(t, resource.TestCase{ + PreCheck: func() { acc.TestAccPreCheckMqcloud(t) }, + Providers: acc.TestAccProviders, + Steps: []resource.TestStep{ + { + Config: testAccCheckIbmMqcloudTruststoreCertificateDataSourceConfig(trustStoreCertificateDetailsServiceInstanceGuid, trustStoreCertificateDetailsQueueManagerID, trustStoreCertificateDetailsLabel, trustStoreCertificateDetailsCertificateFile), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttrSet("data.ibm_mqcloud_truststore_certificate.mqcloud_truststore_certificate_instance", "service_instance_guid"), + resource.TestCheckResourceAttrSet("data.ibm_mqcloud_truststore_certificate.mqcloud_truststore_certificate_instance", "queue_manager_id"), + resource.TestCheckResourceAttrSet("data.ibm_mqcloud_truststore_certificate.mqcloud_truststore_certificate_instance", "label"), + resource.TestCheckResourceAttrSet("data.ibm_mqcloud_truststore_certificate.mqcloud_truststore_certificate_instance", "total_count"), + resource.TestCheckResourceAttrSet("data.ibm_mqcloud_truststore_certificate.mqcloud_truststore_certificate_instance", "trust_store.#"), + resource.TestCheckResourceAttr("data.ibm_mqcloud_truststore_certificate.mqcloud_truststore_certificate_instance", "trust_store.0.label", trustStoreCertificateDetailsLabel), + resource.TestCheckResourceAttrSet("data.ibm_mqcloud_truststore_certificate.mqcloud_truststore_certificate_instance", "trust_store.0.certificate_type"), + resource.TestCheckResourceAttrSet("data.ibm_mqcloud_truststore_certificate.mqcloud_truststore_certificate_instance", "trust_store.0.fingerprint_sha256"), + resource.TestCheckResourceAttrSet("data.ibm_mqcloud_truststore_certificate.mqcloud_truststore_certificate_instance", "trust_store.0.subject_dn"), + resource.TestCheckResourceAttrSet("data.ibm_mqcloud_truststore_certificate.mqcloud_truststore_certificate_instance", "trust_store.0.subject_cn"), + resource.TestCheckResourceAttrSet("data.ibm_mqcloud_truststore_certificate.mqcloud_truststore_certificate_instance", "trust_store.0.issuer_dn"), + resource.TestCheckResourceAttrSet("data.ibm_mqcloud_truststore_certificate.mqcloud_truststore_certificate_instance", "trust_store.0.issuer_cn"), + resource.TestCheckResourceAttrSet("data.ibm_mqcloud_truststore_certificate.mqcloud_truststore_certificate_instance", "trust_store.0.issued"), + resource.TestCheckResourceAttrSet("data.ibm_mqcloud_truststore_certificate.mqcloud_truststore_certificate_instance", "trust_store.0.expiry"), + resource.TestCheckResourceAttrSet("data.ibm_mqcloud_truststore_certificate.mqcloud_truststore_certificate_instance", "trust_store.0.trusted"), + resource.TestCheckResourceAttrSet("data.ibm_mqcloud_truststore_certificate.mqcloud_truststore_certificate_instance", "trust_store.0.href"), + ), + }, + }, + }) +} + +func testAccCheckIbmMqcloudTruststoreCertificateDataSourceConfigBasic(trustStoreCertificateDetailsServiceInstanceGuid string, trustStoreCertificateDetailsQueueManagerID string, trustStoreCertificateDetailsLabel string, trustStoreCertificateDetailsCertificateFile string) string { + return fmt.Sprintf(` + resource "ibm_mqcloud_truststore_certificate" "mqcloud_truststore_certificate_instance" { + service_instance_guid = "%s" + queue_manager_id = "%s" + label = "%s" + certificate_file = "%s" + } + + data "ibm_mqcloud_truststore_certificate" "mqcloud_truststore_certificate_instance" { + service_instance_guid = ibm_mqcloud_truststore_certificate.mqcloud_truststore_certificate_instance.service_instance_guid + queue_manager_id = ibm_mqcloud_truststore_certificate.mqcloud_truststore_certificate_instance.queue_manager_id + label = ibm_mqcloud_truststore_certificate.mqcloud_truststore_certificate_instance.label + } + `, trustStoreCertificateDetailsServiceInstanceGuid, trustStoreCertificateDetailsQueueManagerID, trustStoreCertificateDetailsLabel, trustStoreCertificateDetailsCertificateFile) +} + +func testAccCheckIbmMqcloudTruststoreCertificateDataSourceConfig(trustStoreCertificateDetailsServiceInstanceGuid string, trustStoreCertificateDetailsQueueManagerID string, trustStoreCertificateDetailsLabel string, trustStoreCertificateDetailsCertificateFile string) string { + return fmt.Sprintf(` + resource "ibm_mqcloud_truststore_certificate" "mqcloud_truststore_certificate_instance" { + service_instance_guid = "%s" + queue_manager_id = "%s" + label = "%s" + certificate_file = "%s" + } + + data "ibm_mqcloud_truststore_certificate" "mqcloud_truststore_certificate_instance" { + service_instance_guid = ibm_mqcloud_truststore_certificate.mqcloud_truststore_certificate_instance.service_instance_guid + queue_manager_id = ibm_mqcloud_truststore_certificate.mqcloud_truststore_certificate_instance.queue_manager_id + label = ibm_mqcloud_truststore_certificate.mqcloud_truststore_certificate_instance.label + } + `, trustStoreCertificateDetailsServiceInstanceGuid, trustStoreCertificateDetailsQueueManagerID, trustStoreCertificateDetailsLabel, trustStoreCertificateDetailsCertificateFile) +} diff --git a/ibm/service/mqcloud/data_source_ibm_mqcloud_user.go b/ibm/service/mqcloud/data_source_ibm_mqcloud_user.go new file mode 100644 index 0000000000..259aefa17d --- /dev/null +++ b/ibm/service/mqcloud/data_source_ibm_mqcloud_user.go @@ -0,0 +1,166 @@ +// Copyright IBM Corp. 2023 All Rights Reserved. +// Licensed under the Mozilla Public License v2.0 + +package mqcloud + +import ( + "context" + "fmt" + "time" + + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + + "github.com/IBM-Cloud/terraform-provider-ibm/ibm/conns" + "github.com/IBM/mqcloud-go-sdk/mqcloudv1" +) + +func DataSourceIbmMqcloudUser() *schema.Resource { + return &schema.Resource{ + ReadContext: dataSourceIbmMqcloudUserRead, + + Schema: map[string]*schema.Schema{ + "service_instance_guid": { + Type: schema.TypeString, + Required: true, + Description: "The GUID that uniquely identifies the MQ on Cloud service instance.", + }, + "name": { + Type: schema.TypeString, + Optional: true, + Description: "The shortname of the user that will be used as the IBM MQ administrator in interactions with a queue manager for this service instance.", + }, + "users": { + Type: schema.TypeList, + Computed: true, + Description: "List of users.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "id": { + Type: schema.TypeString, + Computed: true, + Description: "The ID of the user which was allocated on creation, and can be used for delete calls.", + }, + "name": { + Type: schema.TypeString, + Computed: true, + Description: "The shortname of the user that will be used as the IBM MQ administrator in interactions with a queue manager for this service instance.", + }, + "email": { + Type: schema.TypeString, + Computed: true, + Description: "The email of the user.", + }, + "href": { + Type: schema.TypeString, + Computed: true, + Description: "The URL for the user details.", + }, + }, + }, + }, + }, + } +} + +func dataSourceIbmMqcloudUserRead(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { + mqcloudClient, err := meta.(conns.ClientSession).MqcloudV1() + if err != nil { + return diag.FromErr(err) + } + + err = checkSIPlan(d, meta) + if err != nil { + return diag.FromErr(fmt.Errorf("Read User failed %s", err)) + } + + serviceInstanceGuid := d.Get("service_instance_guid").(string) + + // Support for pagination + offset := int64(0) + limit := int64(25) + allItems := []mqcloudv1.UserDetails{} + + for { + listUsersOptions := &mqcloudv1.ListUsersOptions{ + ServiceInstanceGuid: &serviceInstanceGuid, + Limit: &limit, + Offset: &offset, + } + + result, response, err := mqcloudClient.ListUsersWithContext(context, listUsersOptions) + if err != nil { + return diag.FromErr(fmt.Errorf("[ERROR] Error Getting Users %s\n%s", err, response)) + } + if result == nil { + return diag.FromErr(fmt.Errorf("List Users returned nil")) + } + + allItems = append(allItems, result.Users...) + + // Check if the number of returned records is less than the limit + if int64(len(result.Users)) < limit { + break + } + + offset += limit + } + + // Use the provided filter argument and construct a new list with only the requested resource(s) + var matchUsers []mqcloudv1.UserDetails + var name string + var suppliedFilter bool + + if v, ok := d.GetOk("name"); ok { + name = v.(string) + suppliedFilter = true + for _, data := range allItems { + if *data.Name == name { + matchUsers = append(matchUsers, data) + } + } + } else { + matchUsers = allItems + } + + allItems = matchUsers + + if suppliedFilter { + if len(allItems) == 0 { + return diag.FromErr(fmt.Errorf("No Users found with name %s", name)) + } + d.SetId(name) + } else { + d.SetId(dataSourceIbmMqcloudUserID(d)) + } + + mapSlice := []map[string]interface{}{} + for _, modelItem := range allItems { + modelItem := modelItem + modelMap, err := dataSourceIbmMqcloudUserUserDetailsToMap(&modelItem) + if err != nil { + return diag.FromErr(err) + } + mapSlice = append(mapSlice, modelMap) + } + + if err = d.Set("users", mapSlice); err != nil { + return diag.FromErr(fmt.Errorf("Error setting users %s", err)) + } + + return nil +} + +// dataSourceIbmMqcloudUserID returns a reasonable ID for the list. +func dataSourceIbmMqcloudUserID(d *schema.ResourceData) string { + return time.Now().UTC().String() +} + +func dataSourceIbmMqcloudUserUserDetailsToMap(model *mqcloudv1.UserDetails) (map[string]interface{}, error) { + modelMap := make(map[string]interface{}) + modelMap["id"] = model.ID + modelMap["name"] = model.Name + modelMap["email"] = model.Email + modelMap["href"] = model.Href + return modelMap, nil +} diff --git a/ibm/service/mqcloud/data_source_ibm_mqcloud_user_test.go b/ibm/service/mqcloud/data_source_ibm_mqcloud_user_test.go new file mode 100644 index 0000000000..eb3491817e --- /dev/null +++ b/ibm/service/mqcloud/data_source_ibm_mqcloud_user_test.go @@ -0,0 +1,93 @@ +// Copyright IBM Corp. 2023 All Rights Reserved. +// Licensed under the Mozilla Public License v2.0 + +package mqcloud_test + +import ( + "fmt" + "testing" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + + acc "github.com/IBM-Cloud/terraform-provider-ibm/ibm/acctest" +) + +func TestAccIbmMqcloudUserDataSourceBasic(t *testing.T) { + userDetailsServiceInstanceGuid := acc.MqcloudInstanceID + userDetailsName := fmt.Sprintf("tfname%d", acctest.RandIntRange(10, 100)) + userDetailsEmail := fmt.Sprintf("tfemail%d@ibm.com", acctest.RandIntRange(10, 100)) + + resource.Test(t, resource.TestCase{ + PreCheck: func() { acc.TestAccPreCheckMqcloud(t) }, + Providers: acc.TestAccProviders, + Steps: []resource.TestStep{ + { + Config: testAccCheckIbmMqcloudUserDataSourceConfigBasic(userDetailsServiceInstanceGuid, userDetailsName, userDetailsEmail), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttrSet("data.ibm_mqcloud_user.mqcloud_user_instance", "id"), + resource.TestCheckResourceAttrSet("data.ibm_mqcloud_user.mqcloud_user_instance", "service_instance_guid"), + resource.TestCheckResourceAttrSet("data.ibm_mqcloud_user.mqcloud_user_instance", "users.#"), + resource.TestCheckResourceAttr("data.ibm_mqcloud_user.mqcloud_user_instance", "users.0.name", userDetailsName), + resource.TestCheckResourceAttr("data.ibm_mqcloud_user.mqcloud_user_instance", "users.0.email", userDetailsEmail), + ), + }, + }, + }) +} + +func TestAccIbmMqcloudUserDataSourceAllArgs(t *testing.T) { + userDetailsServiceInstanceGuid := acc.MqcloudInstanceID + userDetailsName := fmt.Sprintf("tfname%d", acctest.RandIntRange(10, 100)) + userDetailsEmail := fmt.Sprintf("tfemail%d@ibm.com", acctest.RandIntRange(10, 100)) + + resource.Test(t, resource.TestCase{ + PreCheck: func() { acc.TestAccPreCheckMqcloud(t) }, + Providers: acc.TestAccProviders, + Steps: []resource.TestStep{ + { + Config: testAccCheckIbmMqcloudUserDataSourceConfig(userDetailsServiceInstanceGuid, userDetailsName, userDetailsEmail), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttrSet("data.ibm_mqcloud_user.mqcloud_user_instance", "id"), + resource.TestCheckResourceAttrSet("data.ibm_mqcloud_user.mqcloud_user_instance", "service_instance_guid"), + resource.TestCheckResourceAttrSet("data.ibm_mqcloud_user.mqcloud_user_instance", "name"), + resource.TestCheckResourceAttrSet("data.ibm_mqcloud_user.mqcloud_user_instance", "users.#"), + resource.TestCheckResourceAttrSet("data.ibm_mqcloud_user.mqcloud_user_instance", "users.0.id"), + resource.TestCheckResourceAttr("data.ibm_mqcloud_user.mqcloud_user_instance", "users.0.name", userDetailsName), + resource.TestCheckResourceAttr("data.ibm_mqcloud_user.mqcloud_user_instance", "users.0.email", userDetailsEmail), + resource.TestCheckResourceAttrSet("data.ibm_mqcloud_user.mqcloud_user_instance", "users.0.href"), + ), + }, + }, + }) +} + +func testAccCheckIbmMqcloudUserDataSourceConfigBasic(userDetailsServiceInstanceGuid string, userDetailsName string, userDetailsEmail string) string { + return fmt.Sprintf(` + resource "ibm_mqcloud_user" "mqcloud_user_instance" { + service_instance_guid = "%s" + name = "%s" + email = "%s" + } + + data "ibm_mqcloud_user" "mqcloud_user_instance" { + service_instance_guid = ibm_mqcloud_user.mqcloud_user_instance.service_instance_guid + name = ibm_mqcloud_user.mqcloud_user_instance.name + } + `, userDetailsServiceInstanceGuid, userDetailsName, userDetailsEmail) +} + +func testAccCheckIbmMqcloudUserDataSourceConfig(userDetailsServiceInstanceGuid string, userDetailsName string, userDetailsEmail string) string { + return fmt.Sprintf(` + resource "ibm_mqcloud_user" "mqcloud_user_instance" { + service_instance_guid = "%s" + name = "%s" + email = "%s" + } + + data "ibm_mqcloud_user" "mqcloud_user_instance" { + service_instance_guid = ibm_mqcloud_user.mqcloud_user_instance.service_instance_guid + name = ibm_mqcloud_user.mqcloud_user_instance.name + } + `, userDetailsServiceInstanceGuid, userDetailsName, userDetailsEmail) +} diff --git a/ibm/service/mqcloud/resource_ibm_mqcloud_application.go b/ibm/service/mqcloud/resource_ibm_mqcloud_application.go new file mode 100644 index 0000000000..6b317ad242 --- /dev/null +++ b/ibm/service/mqcloud/resource_ibm_mqcloud_application.go @@ -0,0 +1,188 @@ +// Copyright IBM Corp. 2023 All Rights Reserved. +// Licensed under the Mozilla Public License v2.0 + +package mqcloud + +import ( + "context" + "fmt" + "log" + + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + + "github.com/IBM-Cloud/terraform-provider-ibm/ibm/conns" + "github.com/IBM-Cloud/terraform-provider-ibm/ibm/flex" + "github.com/IBM-Cloud/terraform-provider-ibm/ibm/validate" + "github.com/IBM/mqcloud-go-sdk/mqcloudv1" +) + +func ResourceIbmMqcloudApplication() *schema.Resource { + return &schema.Resource{ + CreateContext: resourceIbmMqcloudApplicationCreate, + ReadContext: resourceIbmMqcloudApplicationRead, + DeleteContext: resourceIbmMqcloudApplicationDelete, + Importer: &schema.ResourceImporter{}, + + Schema: map[string]*schema.Schema{ + "service_instance_guid": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + ValidateFunc: validate.InvokeValidator("ibm_mqcloud_application", "service_instance_guid"), + Description: "The GUID that uniquely identifies the MQ on Cloud service instance.", + }, + "name": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + ValidateFunc: validate.InvokeValidator("ibm_mqcloud_application", "name"), + Description: "The name of the application - conforming to MQ rules.", + }, + "create_api_key_uri": { + Type: schema.TypeString, + Computed: true, + Description: "The URI to create a new apikey for the application.", + }, + "href": { + Type: schema.TypeString, + Computed: true, + Description: "The URL for this application.", + }, + "application_id": { + Type: schema.TypeString, + Computed: true, + Description: "The ID of the application which was allocated on creation, and can be used for delete calls.", + }, + }, + } +} + +func ResourceIbmMqcloudApplicationValidator() *validate.ResourceValidator { + validateSchema := make([]validate.ValidateSchema, 0) + validateSchema = append(validateSchema, + validate.ValidateSchema{ + Identifier: "service_instance_guid", + ValidateFunctionIdentifier: validate.ValidateRegexpLen, + Type: validate.TypeString, + Required: true, + Regexp: `^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$`, + MinValueLength: 36, + MaxValueLength: 36, + }, + validate.ValidateSchema{ + Identifier: "name", + ValidateFunctionIdentifier: validate.ValidateRegexpLen, + Type: validate.TypeString, + Required: true, + Regexp: `^[a-z][-a-z0-9]*$`, + MinValueLength: 1, + MaxValueLength: 12, + }, + ) + + resourceValidator := validate.ResourceValidator{ResourceName: "ibm_mqcloud_application", Schema: validateSchema} + return &resourceValidator +} + +func resourceIbmMqcloudApplicationCreate(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { + mqcloudClient, err := meta.(conns.ClientSession).MqcloudV1() + if err != nil { + return diag.FromErr(err) + } + err = checkSIPlan(d, meta) + if err != nil { + return diag.FromErr(fmt.Errorf("Create Application failed %s", err)) + } + + createApplicationOptions := &mqcloudv1.CreateApplicationOptions{} + + createApplicationOptions.SetServiceInstanceGuid(d.Get("service_instance_guid").(string)) + createApplicationOptions.SetName(d.Get("name").(string)) + + applicationCreated, response, err := mqcloudClient.CreateApplicationWithContext(context, createApplicationOptions) + if err != nil { + log.Printf("[DEBUG] CreateApplicationWithContext failed %s\n%s", err, response) + return diag.FromErr(fmt.Errorf("CreateApplicationWithContext failed %s\n%s", err, response)) + } + + d.SetId(fmt.Sprintf("%s/%s", *createApplicationOptions.ServiceInstanceGuid, *applicationCreated.ID)) + + return resourceIbmMqcloudApplicationRead(context, d, meta) +} + +func resourceIbmMqcloudApplicationRead(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { + mqcloudClient, err := meta.(conns.ClientSession).MqcloudV1() + if err != nil { + return diag.FromErr(err) + } + + getApplicationOptions := &mqcloudv1.GetApplicationOptions{} + + parts, err := flex.SepIdParts(d.Id(), "/") + if err != nil { + return diag.FromErr(err) + } + + getApplicationOptions.SetServiceInstanceGuid(parts[0]) + getApplicationOptions.SetApplicationID(parts[1]) + + applicationDetails, response, err := mqcloudClient.GetApplicationWithContext(context, getApplicationOptions) + if err != nil { + if response != nil && response.StatusCode == 404 { + d.SetId("") + return nil + } + log.Printf("[DEBUG] GetApplicationWithContext failed %s\n%s", err, response) + return diag.FromErr(fmt.Errorf("GetApplicationWithContext failed %s\n%s", err, response)) + } + + if err = d.Set("name", applicationDetails.Name); err != nil { + return diag.FromErr(fmt.Errorf("Error setting name: %s", err)) + } + if err = d.Set("service_instance_guid", parts[0]); err != nil { + return diag.FromErr(fmt.Errorf("Error setting service instance guid: %s", err)) + } + if err = d.Set("create_api_key_uri", applicationDetails.CreateApiKeyURI); err != nil { + return diag.FromErr(fmt.Errorf("Error setting create_api_key_uri: %s", err)) + } + if err = d.Set("href", applicationDetails.Href); err != nil { + return diag.FromErr(fmt.Errorf("Error setting href: %s", err)) + } + if err = d.Set("application_id", applicationDetails.ID); err != nil { + return diag.FromErr(fmt.Errorf("Error setting application_id: %s", err)) + } + + return nil +} + +func resourceIbmMqcloudApplicationDelete(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { + mqcloudClient, err := meta.(conns.ClientSession).MqcloudV1() + if err != nil { + return diag.FromErr(err) + } + err = checkSIPlan(d, meta) + if err != nil { + return diag.FromErr(fmt.Errorf("Delete Application failed %s", err)) + } + + deleteApplicationOptions := &mqcloudv1.DeleteApplicationOptions{} + + parts, err := flex.SepIdParts(d.Id(), "/") + if err != nil { + return diag.FromErr(err) + } + + deleteApplicationOptions.SetServiceInstanceGuid(parts[0]) + deleteApplicationOptions.SetApplicationID(parts[1]) + + response, err := mqcloudClient.DeleteApplicationWithContext(context, deleteApplicationOptions) + if err != nil { + log.Printf("[DEBUG] DeleteApplicationWithContext failed %s\n%s", err, response) + return diag.FromErr(fmt.Errorf("DeleteApplicationWithContext failed %s\n%s", err, response)) + } + + d.SetId("") + + return nil +} diff --git a/ibm/service/mqcloud/resource_ibm_mqcloud_application_test.go b/ibm/service/mqcloud/resource_ibm_mqcloud_application_test.go new file mode 100644 index 0000000000..b780d789d1 --- /dev/null +++ b/ibm/service/mqcloud/resource_ibm_mqcloud_application_test.go @@ -0,0 +1,150 @@ +// Copyright IBM Corp. 2023 All Rights Reserved. +// Licensed under the Mozilla Public License v2.0 + +package mqcloud_test + +import ( + "fmt" + "testing" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" + + acc "github.com/IBM-Cloud/terraform-provider-ibm/ibm/acctest" + "github.com/IBM-Cloud/terraform-provider-ibm/ibm/conns" + "github.com/IBM-Cloud/terraform-provider-ibm/ibm/flex" + "github.com/IBM/mqcloud-go-sdk/mqcloudv1" +) + +func TestAccIbmMqcloudApplicationBasic(t *testing.T) { + var conf mqcloudv1.ApplicationDetails + serviceInstanceGuid := acc.MqcloudInstanceID + name := "appbasic" + + resource.Test(t, resource.TestCase{ + PreCheck: func() { acc.TestAccPreCheckMqcloud(t) }, + Providers: acc.TestAccProviders, + CheckDestroy: testAccCheckIbmMqcloudApplicationDestroy, + Steps: []resource.TestStep{ + { + Config: testAccCheckIbmMqcloudApplicationConfigBasic(serviceInstanceGuid, name), + Check: resource.ComposeAggregateTestCheckFunc( + testAccCheckIbmMqcloudApplicationExists("ibm_mqcloud_application.mqcloud_application_instance", conf), + resource.TestCheckResourceAttr("ibm_mqcloud_application.mqcloud_application_instance", "service_instance_guid", serviceInstanceGuid), + resource.TestCheckResourceAttr("ibm_mqcloud_application.mqcloud_application_instance", "name", name), + ), + }, + }, + }) +} + +func TestAccIbmMqcloudApplicationAllArgs(t *testing.T) { + var conf mqcloudv1.ApplicationDetails + serviceInstanceGuid := acc.MqcloudInstanceID + name := "appallargs" + + resource.Test(t, resource.TestCase{ + PreCheck: func() { acc.TestAccPreCheckMqcloud(t) }, + Providers: acc.TestAccProviders, + CheckDestroy: testAccCheckIbmMqcloudApplicationDestroy, + Steps: []resource.TestStep{ + { + Config: testAccCheckIbmMqcloudApplicationConfig(serviceInstanceGuid, name), + Check: resource.ComposeAggregateTestCheckFunc( + testAccCheckIbmMqcloudApplicationExists("ibm_mqcloud_application.mqcloud_application_instance", conf), + resource.TestCheckResourceAttr("ibm_mqcloud_application.mqcloud_application_instance", "service_instance_guid", serviceInstanceGuid), + resource.TestCheckResourceAttr("ibm_mqcloud_application.mqcloud_application_instance", "name", name), + ), + }, + { + ResourceName: "ibm_mqcloud_application.mqcloud_application_instance", + ImportState: true, + ImportStateVerify: true, + }, + }, + }) +} + +func testAccCheckIbmMqcloudApplicationConfigBasic(serviceInstanceGuid string, name string) string { + return fmt.Sprintf(` + resource "ibm_mqcloud_application" "mqcloud_application_instance" { + service_instance_guid = "%s" + name = "%s" + } + `, serviceInstanceGuid, name) +} + +func testAccCheckIbmMqcloudApplicationConfig(serviceInstanceGuid string, name string) string { + return fmt.Sprintf(` + + resource "ibm_mqcloud_application" "mqcloud_application_instance" { + service_instance_guid = "%s" + name = "%s" + } + `, serviceInstanceGuid, name) +} + +func testAccCheckIbmMqcloudApplicationExists(n string, obj mqcloudv1.ApplicationDetails) resource.TestCheckFunc { + return func(s *terraform.State) error { + rs, ok := s.RootModule().Resources[n] + if !ok { + return fmt.Errorf("Not found: %s", n) + } + + mqcloudClient, err := acc.TestAccProvider.Meta().(conns.ClientSession).MqcloudV1() + if err != nil { + return err + } + + getApplicationOptions := &mqcloudv1.GetApplicationOptions{} + + parts, err := flex.SepIdParts(rs.Primary.ID, "/") + if err != nil { + return err + } + + getApplicationOptions.SetServiceInstanceGuid(parts[0]) + getApplicationOptions.SetApplicationID(parts[1]) + + applicationDetails, _, err := mqcloudClient.GetApplication(getApplicationOptions) + if err != nil { + return err + } + + obj = *applicationDetails + return nil + } +} + +func testAccCheckIbmMqcloudApplicationDestroy(s *terraform.State) error { + mqcloudClient, err := acc.TestAccProvider.Meta().(conns.ClientSession).MqcloudV1() + if err != nil { + return err + } + for _, rs := range s.RootModule().Resources { + if rs.Type != "ibm_mqcloud_application" { + continue + } + + getApplicationOptions := &mqcloudv1.GetApplicationOptions{} + + parts, err := flex.SepIdParts(rs.Primary.ID, "/") + if err != nil { + return err + } + + getApplicationOptions.SetServiceInstanceGuid(parts[0]) + getApplicationOptions.SetApplicationID(parts[1]) + + // Try to find the key + _, response, err := mqcloudClient.GetApplication(getApplicationOptions) + + if err == nil { + return fmt.Errorf("mqcloud_application still exists: %s", rs.Primary.ID) + } else if response.StatusCode != 404 { + return fmt.Errorf("Error checking for mqcloud_application (%s) has been destroyed: %s", rs.Primary.ID, err) + } + } + + return nil +} diff --git a/ibm/service/mqcloud/resource_ibm_mqcloud_keystore_certificate.go b/ibm/service/mqcloud/resource_ibm_mqcloud_keystore_certificate.go new file mode 100644 index 0000000000..859d0aa5cc --- /dev/null +++ b/ibm/service/mqcloud/resource_ibm_mqcloud_keystore_certificate.go @@ -0,0 +1,314 @@ +// Copyright IBM Corp. 2023 All Rights Reserved. +// Licensed under the Mozilla Public License v2.0 + +package mqcloud + +import ( + "context" + "fmt" + "io" + "log" + "os" + "strings" + + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + + "github.com/IBM-Cloud/terraform-provider-ibm/ibm/conns" + "github.com/IBM-Cloud/terraform-provider-ibm/ibm/flex" + "github.com/IBM-Cloud/terraform-provider-ibm/ibm/validate" + "github.com/IBM/mqcloud-go-sdk/mqcloudv1" +) + +func ResourceIbmMqcloudKeystoreCertificate() *schema.Resource { + return &schema.Resource{ + CreateContext: resourceIbmMqcloudKeystoreCertificateCreate, + ReadContext: resourceIbmMqcloudKeystoreCertificateRead, + DeleteContext: resourceIbmMqcloudKeystoreCertificateDelete, + Importer: &schema.ResourceImporter{}, + + Schema: map[string]*schema.Schema{ + "service_instance_guid": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + ValidateFunc: validate.InvokeValidator("ibm_mqcloud_keystore_certificate", "service_instance_guid"), + Description: "The GUID that uniquely identifies the MQ on Cloud service instance.", + }, + "queue_manager_id": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + ValidateFunc: validate.InvokeValidator("ibm_mqcloud_keystore_certificate", "queue_manager_id"), + Description: "The id of the queue manager to retrieve its full details.", + }, + "label": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + ValidateFunc: validate.InvokeValidator("ibm_mqcloud_keystore_certificate", "label"), + Description: "Certificate label in queue manager store.", + }, + "certificate_type": { + Type: schema.TypeString, + Computed: true, + Description: "The type of certificate.", + }, + "fingerprint_sha256": { + Type: schema.TypeString, + Computed: true, + Description: "Fingerprint SHA256.", + }, + "subject_dn": { + Type: schema.TypeString, + Computed: true, + Description: "Subject's Distinguished Name.", + }, + "subject_cn": { + Type: schema.TypeString, + Computed: true, + Description: "Subject's Common Name.", + }, + "issuer_dn": { + Type: schema.TypeString, + Computed: true, + Description: "Issuer's Distinguished Name.", + }, + "issuer_cn": { + Type: schema.TypeString, + Computed: true, + Description: "Issuer's Common Name.", + }, + "issued": { + Type: schema.TypeString, + Computed: true, + Description: "Date certificate was issued.", + }, + "expiry": { + Type: schema.TypeString, + Computed: true, + Description: "Expiry date for the certificate.", + }, + "is_default": { + Type: schema.TypeBool, + Computed: true, + Description: "Indicates whether it is the queue manager's default certificate.", + }, + "dns_names_total_count": { + Type: schema.TypeInt, + Computed: true, + Description: "The total count of dns names.", + }, + "dns_names": { + Type: schema.TypeList, + Computed: true, + Description: "The list of DNS names.", + Elem: &schema.Schema{Type: schema.TypeString}, + }, + "href": { + Type: schema.TypeString, + Computed: true, + Description: "The URL for this key store certificate.", + }, + "certificate_id": { + Type: schema.TypeString, + Computed: true, + Description: "ID of the certificate.", + }, + "certificate_file": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + Description: "The filename and path of the certificate to be uploaded.", + }, + }, + } +} + +func ResourceIbmMqcloudKeystoreCertificateValidator() *validate.ResourceValidator { + validateSchema := make([]validate.ValidateSchema, 0) + validateSchema = append(validateSchema, + validate.ValidateSchema{ + Identifier: "service_instance_guid", + ValidateFunctionIdentifier: validate.ValidateRegexpLen, + Type: validate.TypeString, + Required: true, + Regexp: `^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$`, + MinValueLength: 36, + MaxValueLength: 36, + }, + validate.ValidateSchema{ + Identifier: "queue_manager_id", + ValidateFunctionIdentifier: validate.ValidateRegexpLen, + Type: validate.TypeString, + Required: true, + Regexp: `^[0-9a-fA-F]{32}$`, + MinValueLength: 32, + MaxValueLength: 32, + }, + validate.ValidateSchema{ + Identifier: "label", + ValidateFunctionIdentifier: validate.ValidateRegexpLen, + Type: validate.TypeString, + Required: true, + Regexp: `^[a-zA-Z0-9_.]*$`, + MinValueLength: 1, + MaxValueLength: 64, + }, + ) + + resourceValidator := validate.ResourceValidator{ResourceName: "ibm_mqcloud_keystore_certificate", Schema: validateSchema} + return &resourceValidator +} + +func resourceIbmMqcloudKeystoreCertificateCreate(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { + mqcloudClient, err := meta.(conns.ClientSession).MqcloudV1() + if err != nil { + return diag.FromErr(err) + } + err = checkSIPlan(d, meta) + if err != nil { + return diag.FromErr(fmt.Errorf("Create Keystore Certificate failed %s", err)) + } + createKeyStorePemCertificateOptions := &mqcloudv1.CreateKeyStorePemCertificateOptions{} + + createKeyStorePemCertificateOptions.SetServiceInstanceGuid(d.Get("service_instance_guid").(string)) + createKeyStorePemCertificateOptions.SetQueueManagerID(d.Get("queue_manager_id").(string)) + createKeyStorePemCertificateOptions.SetLabel(d.Get("label").(string)) + //Custom code to read certs and pass to SDK + certBytes, err := os.ReadFile(d.Get("certificate_file").(string)) // just pass the file name + if err != nil { + fmt.Print(err) + } + certString := string(certBytes) // convert content to a 'string' + rc := io.NopCloser(strings.NewReader(certString)) + // certificateFileModel, err := resourceIbmMqcloudKeystoreCertificateMapToio.ReadCloser(d.Get("certificate_file.0").(map[string]interface{})) + // if err != nil { + // return diag.FromErr(err) + // } + createKeyStorePemCertificateOptions.SetCertificateFile(rc) + + keyStoreCertificateDetails, response, err := mqcloudClient.CreateKeyStorePemCertificateWithContext(context, createKeyStorePemCertificateOptions) + if err != nil { + log.Printf("[DEBUG] CreateKeyStorePemCertificateWithContext failed %s\n%s", err, response) + return diag.FromErr(fmt.Errorf("CreateKeyStorePemCertificateWithContext failed %s\n%s", err, response)) + } + + d.SetId(fmt.Sprintf("%s/%s/%s", *createKeyStorePemCertificateOptions.ServiceInstanceGuid, *createKeyStorePemCertificateOptions.QueueManagerID, *keyStoreCertificateDetails.ID)) + + return resourceIbmMqcloudKeystoreCertificateRead(context, d, meta) +} + +func resourceIbmMqcloudKeystoreCertificateRead(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { + mqcloudClient, err := meta.(conns.ClientSession).MqcloudV1() + if err != nil { + return diag.FromErr(err) + } + + getKeyStoreCertificateOptions := &mqcloudv1.GetKeyStoreCertificateOptions{} + + parts, err := flex.SepIdParts(d.Id(), "/") + if err != nil { + return diag.FromErr(err) + } + + getKeyStoreCertificateOptions.SetServiceInstanceGuid(parts[0]) + getKeyStoreCertificateOptions.SetQueueManagerID(parts[1]) + getKeyStoreCertificateOptions.SetCertificateID(parts[2]) + + keyStoreCertificateDetails, response, err := mqcloudClient.GetKeyStoreCertificateWithContext(context, getKeyStoreCertificateOptions) + if err != nil { + if response != nil && response.StatusCode == 404 { + d.SetId("") + return nil + } + log.Printf("[DEBUG] GetKeyStoreCertificateWithContext failed %s\n%s", err, response) + return diag.FromErr(fmt.Errorf("GetKeyStoreCertificateWithContext failed %s\n%s", err, response)) + } + if err = d.Set("service_instance_guid", parts[0]); err != nil { + return diag.FromErr(fmt.Errorf("Error setting service_instance_guid: %s", err)) + } + if err = d.Set("queue_manager_id", parts[1]); err != nil { + return diag.FromErr(fmt.Errorf("Error setting queue_manager_id: %s", err)) + } + downloadCertificatePath := "./certificates/keystore/" + *keyStoreCertificateDetails.Label + ".pem" + if err = d.Set("certificate_file", downloadCertificatePath); err != nil { + return diag.FromErr(fmt.Errorf("Error setting certificate_file: %s", err)) + } + if err = d.Set("label", keyStoreCertificateDetails.Label); err != nil { + return diag.FromErr(fmt.Errorf("Error setting label: %s", err)) + } + if err = d.Set("certificate_type", keyStoreCertificateDetails.CertificateType); err != nil { + return diag.FromErr(fmt.Errorf("Error setting certificate_type: %s", err)) + } + if err = d.Set("fingerprint_sha256", keyStoreCertificateDetails.FingerprintSha256); err != nil { + return diag.FromErr(fmt.Errorf("Error setting fingerprint_sha256: %s", err)) + } + if err = d.Set("subject_dn", keyStoreCertificateDetails.SubjectDn); err != nil { + return diag.FromErr(fmt.Errorf("Error setting subject_dn: %s", err)) + } + if err = d.Set("subject_cn", keyStoreCertificateDetails.SubjectCn); err != nil { + return diag.FromErr(fmt.Errorf("Error setting subject_cn: %s", err)) + } + if err = d.Set("issuer_dn", keyStoreCertificateDetails.IssuerDn); err != nil { + return diag.FromErr(fmt.Errorf("Error setting issuer_dn: %s", err)) + } + if err = d.Set("issuer_cn", keyStoreCertificateDetails.IssuerCn); err != nil { + return diag.FromErr(fmt.Errorf("Error setting issuer_cn: %s", err)) + } + if err = d.Set("issued", flex.DateTimeToString(keyStoreCertificateDetails.Issued)); err != nil { + return diag.FromErr(fmt.Errorf("Error setting issued: %s", err)) + } + if err = d.Set("expiry", flex.DateTimeToString(keyStoreCertificateDetails.Expiry)); err != nil { + return diag.FromErr(fmt.Errorf("Error setting expiry: %s", err)) + } + if err = d.Set("is_default", keyStoreCertificateDetails.IsDefault); err != nil { + return diag.FromErr(fmt.Errorf("Error setting is_default: %s", err)) + } + if err = d.Set("dns_names_total_count", flex.IntValue(keyStoreCertificateDetails.DnsNamesTotalCount)); err != nil { + return diag.FromErr(fmt.Errorf("Error setting dns_names_total_count: %s", err)) + } + if err = d.Set("dns_names", keyStoreCertificateDetails.DnsNames); err != nil { + return diag.FromErr(fmt.Errorf("Error setting dns_names: %s", err)) + } + if err = d.Set("href", keyStoreCertificateDetails.Href); err != nil { + return diag.FromErr(fmt.Errorf("Error setting href: %s", err)) + } + if err = d.Set("certificate_id", keyStoreCertificateDetails.ID); err != nil { + return diag.FromErr(fmt.Errorf("Error setting certificate_id: %s", err)) + } + + return nil +} + +func resourceIbmMqcloudKeystoreCertificateDelete(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { + mqcloudClient, err := meta.(conns.ClientSession).MqcloudV1() + if err != nil { + return diag.FromErr(err) + } + err = checkSIPlan(d, meta) + if err != nil { + return diag.FromErr(fmt.Errorf("Delete Keystore Certificate failed %s", err)) + } + + deleteKeyStoreCertificateOptions := &mqcloudv1.DeleteKeyStoreCertificateOptions{} + + parts, err := flex.SepIdParts(d.Id(), "/") + if err != nil { + return diag.FromErr(err) + } + + deleteKeyStoreCertificateOptions.SetServiceInstanceGuid(parts[0]) + deleteKeyStoreCertificateOptions.SetQueueManagerID(parts[1]) + deleteKeyStoreCertificateOptions.SetCertificateID(parts[2]) + + response, err := mqcloudClient.DeleteKeyStoreCertificateWithContext(context, deleteKeyStoreCertificateOptions) + if err != nil { + log.Printf("[DEBUG] DeleteKeyStoreCertificateWithContext failed %s\n%s", err, response) + return diag.FromErr(fmt.Errorf("DeleteKeyStoreCertificateWithContext failed %s\n%s", err, response)) + } + + d.SetId("") + + return nil +} diff --git a/ibm/service/mqcloud/resource_ibm_mqcloud_keystore_certificate_test.go b/ibm/service/mqcloud/resource_ibm_mqcloud_keystore_certificate_test.go new file mode 100644 index 0000000000..5041c8ed77 --- /dev/null +++ b/ibm/service/mqcloud/resource_ibm_mqcloud_keystore_certificate_test.go @@ -0,0 +1,163 @@ +// Copyright IBM Corp. 2023 All Rights Reserved. +// Licensed under the Mozilla Public License v2.0 + +package mqcloud_test + +import ( + "fmt" + "testing" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" + + acc "github.com/IBM-Cloud/terraform-provider-ibm/ibm/acctest" + "github.com/IBM-Cloud/terraform-provider-ibm/ibm/conns" + "github.com/IBM-Cloud/terraform-provider-ibm/ibm/flex" + "github.com/IBM/mqcloud-go-sdk/mqcloudv1" +) + +func TestAccIbmMqcloudKeystoreCertificateBasic(t *testing.T) { + var conf mqcloudv1.KeyStoreCertificateDetails + serviceInstanceGuid := acc.MqcloudInstanceID + queueManagerID := acc.MqcloudQueueManagerID + label := fmt.Sprintf("tf_label_%d", acctest.RandIntRange(10, 100)) + certificateFile := acc.MqcloudKSCertFilePath + + resource.Test(t, resource.TestCase{ + PreCheck: func() { acc.TestAccPreCheckMqcloud(t) }, + Providers: acc.TestAccProviders, + CheckDestroy: testAccCheckIbmMqcloudKeystoreCertificateDestroy, + Steps: []resource.TestStep{ + { + Config: testAccCheckIbmMqcloudKeystoreCertificateConfigBasic(serviceInstanceGuid, queueManagerID, label, certificateFile), + Check: resource.ComposeAggregateTestCheckFunc( + testAccCheckIbmMqcloudKeystoreCertificateExists("ibm_mqcloud_keystore_certificate.mqcloud_keystore_certificate_instance", conf), + resource.TestCheckResourceAttr("ibm_mqcloud_keystore_certificate.mqcloud_keystore_certificate_instance", "service_instance_guid", serviceInstanceGuid), + resource.TestCheckResourceAttr("ibm_mqcloud_keystore_certificate.mqcloud_keystore_certificate_instance", "queue_manager_id", queueManagerID), + resource.TestCheckResourceAttr("ibm_mqcloud_keystore_certificate.mqcloud_keystore_certificate_instance", "label", label), + ), + }, + }, + }) +} + +func TestAccIbmMqcloudKeystoreCertificateAllArgs(t *testing.T) { + var conf mqcloudv1.KeyStoreCertificateDetails + serviceInstanceGuid := acc.MqcloudInstanceID + queueManagerID := acc.MqcloudQueueManagerID + label := fmt.Sprintf("tf_label_%d", acctest.RandIntRange(10, 100)) + certificateFile := acc.MqcloudKSCertFilePath + + resource.Test(t, resource.TestCase{ + PreCheck: func() { acc.TestAccPreCheckMqcloud(t) }, + Providers: acc.TestAccProviders, + CheckDestroy: testAccCheckIbmMqcloudKeystoreCertificateDestroy, + Steps: []resource.TestStep{ + { + Config: testAccCheckIbmMqcloudKeystoreCertificateConfig(serviceInstanceGuid, queueManagerID, label, certificateFile), + Check: resource.ComposeAggregateTestCheckFunc( + testAccCheckIbmMqcloudKeystoreCertificateExists("ibm_mqcloud_keystore_certificate.mqcloud_keystore_certificate_instance", conf), + resource.TestCheckResourceAttr("ibm_mqcloud_keystore_certificate.mqcloud_keystore_certificate_instance", "service_instance_guid", serviceInstanceGuid), + resource.TestCheckResourceAttr("ibm_mqcloud_keystore_certificate.mqcloud_keystore_certificate_instance", "queue_manager_id", queueManagerID), + resource.TestCheckResourceAttr("ibm_mqcloud_keystore_certificate.mqcloud_keystore_certificate_instance", "label", label), + ), + }, + { + ResourceName: "ibm_mqcloud_keystore_certificate.mqcloud_keystore_certificate_instance", + ImportState: true, + ImportStateVerify: true, + }, + }, + }) +} + +func testAccCheckIbmMqcloudKeystoreCertificateConfigBasic(serviceInstanceGuid string, queueManagerID string, label string, certificateFile string) string { + return fmt.Sprintf(` + resource "ibm_mqcloud_keystore_certificate" "mqcloud_keystore_certificate_instance" { + service_instance_guid = "%s" + queue_manager_id = "%s" + label = "%s" + certificate_file = "%s" + } + `, serviceInstanceGuid, queueManagerID, label, certificateFile) +} + +func testAccCheckIbmMqcloudKeystoreCertificateConfig(serviceInstanceGuid string, queueManagerID string, label string, certificateFile string) string { + return fmt.Sprintf(` + + resource "ibm_mqcloud_keystore_certificate" "mqcloud_keystore_certificate_instance" { + service_instance_guid = "%s" + queue_manager_id = "%s" + label = "%s" + certificate_file = "%s" + } + `, serviceInstanceGuid, queueManagerID, label, certificateFile) +} + +func testAccCheckIbmMqcloudKeystoreCertificateExists(n string, obj mqcloudv1.KeyStoreCertificateDetails) resource.TestCheckFunc { + return func(s *terraform.State) error { + rs, ok := s.RootModule().Resources[n] + if !ok { + return fmt.Errorf("Not found: %s", n) + } + + mqcloudClient, err := acc.TestAccProvider.Meta().(conns.ClientSession).MqcloudV1() + if err != nil { + return err + } + + getKeyStoreCertificateOptions := &mqcloudv1.GetKeyStoreCertificateOptions{} + + parts, err := flex.SepIdParts(rs.Primary.ID, "/") + if err != nil { + return err + } + + getKeyStoreCertificateOptions.SetServiceInstanceGuid(parts[0]) + getKeyStoreCertificateOptions.SetQueueManagerID(parts[1]) + getKeyStoreCertificateOptions.SetCertificateID(parts[2]) + + keyStoreCertificateDetails, _, err := mqcloudClient.GetKeyStoreCertificate(getKeyStoreCertificateOptions) + if err != nil { + return err + } + + obj = *keyStoreCertificateDetails + return nil + } +} + +func testAccCheckIbmMqcloudKeystoreCertificateDestroy(s *terraform.State) error { + mqcloudClient, err := acc.TestAccProvider.Meta().(conns.ClientSession).MqcloudV1() + if err != nil { + return err + } + for _, rs := range s.RootModule().Resources { + if rs.Type != "ibm_mqcloud_keystore_certificate" { + continue + } + + getKeyStoreCertificateOptions := &mqcloudv1.GetKeyStoreCertificateOptions{} + + parts, err := flex.SepIdParts(rs.Primary.ID, "/") + if err != nil { + return err + } + + getKeyStoreCertificateOptions.SetServiceInstanceGuid(parts[0]) + getKeyStoreCertificateOptions.SetQueueManagerID(parts[1]) + getKeyStoreCertificateOptions.SetCertificateID(parts[2]) + + // Try to find the key + _, response, err := mqcloudClient.GetKeyStoreCertificate(getKeyStoreCertificateOptions) + + if err == nil { + return fmt.Errorf("mqcloud_keystore_certificate still exists: %s", rs.Primary.ID) + } else if response.StatusCode != 404 { + return fmt.Errorf("Error checking for mqcloud_keystore_certificate (%s) has been destroyed: %s", rs.Primary.ID, err) + } + } + + return nil +} diff --git a/ibm/service/mqcloud/resource_ibm_mqcloud_queue_manager.go b/ibm/service/mqcloud/resource_ibm_mqcloud_queue_manager.go new file mode 100644 index 0000000000..a94f6fa5c9 --- /dev/null +++ b/ibm/service/mqcloud/resource_ibm_mqcloud_queue_manager.go @@ -0,0 +1,415 @@ +// Copyright IBM Corp. 2023 All Rights Reserved. +// Licensed under the Mozilla Public License v2.0 + +package mqcloud + +import ( + "context" + "fmt" + "log" + "time" + + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + + "github.com/IBM-Cloud/terraform-provider-ibm/ibm/conns" + "github.com/IBM-Cloud/terraform-provider-ibm/ibm/flex" + "github.com/IBM-Cloud/terraform-provider-ibm/ibm/validate" + "github.com/IBM/go-sdk-core/v5/core" + "github.com/IBM/mqcloud-go-sdk/mqcloudv1" +) + +func ResourceIbmMqcloudQueueManager() *schema.Resource { + return &schema.Resource{ + CreateContext: resourceIbmMqcloudQueueManagerCreate, + ReadContext: resourceIbmMqcloudQueueManagerRead, + UpdateContext: resourceIbmMqcloudQueueManagerUpdate, + DeleteContext: resourceIbmMqcloudQueueManagerDelete, + Importer: &schema.ResourceImporter{}, + + Schema: map[string]*schema.Schema{ + "service_instance_guid": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + ValidateFunc: validate.InvokeValidator("ibm_mqcloud_queue_manager", "service_instance_guid"), + Description: "The GUID that uniquely identifies the MQ on Cloud service instance.", + }, + "name": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + ValidateFunc: validate.InvokeValidator("ibm_mqcloud_queue_manager", "name"), + Description: "A queue manager name conforming to MQ restrictions.", + }, + "display_name": { + Type: schema.TypeString, + Optional: true, + ForceNew: true, + ValidateFunc: validate.InvokeValidator("ibm_mqcloud_queue_manager", "display_name"), + Description: "A displayable name for the queue manager - limited only in length.", + }, + "location": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + ValidateFunc: validate.InvokeValidator("ibm_mqcloud_queue_manager", "location"), + Description: "The locations in which the queue manager could be deployed.", + }, + "size": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + ValidateFunc: validate.InvokeValidator("ibm_mqcloud_queue_manager", "size"), + Description: "The queue manager sizes of deployment available. Deployment of lite queue managers for aws_us_east_1 and aws_eu_west_1 locations is not available.", + }, + "version": { + Type: schema.TypeString, + Optional: true, + Computed: true, + ValidateFunc: validate.InvokeValidator("ibm_mqcloud_queue_manager", "version"), + Description: "The MQ version of the queue manager.", + }, + "status_uri": { + Type: schema.TypeString, + Computed: true, + Description: "A reference uri to get deployment status of the queue manager.", + }, + "web_console_url": { + Type: schema.TypeString, + Computed: true, + Description: "The url through which to access the web console for this queue manager.", + }, + "rest_api_endpoint_url": { + Type: schema.TypeString, + Computed: true, + Description: "The url through which to access REST APIs for this queue manager.", + }, + "administrator_api_endpoint_url": { + Type: schema.TypeString, + Computed: true, + Description: "The url through which to access the Admin REST APIs for this queue manager.", + }, + "connection_info_uri": { + Type: schema.TypeString, + Computed: true, + Description: "The uri through which the CDDT for this queue manager can be obtained.", + }, + "date_created": { + Type: schema.TypeString, + Computed: true, + Description: "RFC3339 formatted UTC date for when the queue manager was created.", + }, + "upgrade_available": { + Type: schema.TypeBool, + Computed: true, + Description: "Describes whether an upgrade is available for this queue manager.", + }, + "available_upgrade_versions_uri": { + Type: schema.TypeString, + Computed: true, + Description: "The uri through which the available versions to upgrade to can be found for this queue manager.", + }, + "href": { + Type: schema.TypeString, + Computed: true, + Description: "The URL for this queue manager.", + }, + "queue_manager_id": { + Type: schema.TypeString, + Computed: true, + Description: "The ID of the queue manager which was allocated on creation, and can be used for delete calls.", + }, + }, + Timeouts: &schema.ResourceTimeout{ + Create: schema.DefaultTimeout(15 * time.Minute), + Delete: schema.DefaultTimeout(5 * time.Minute), + Update: schema.DefaultTimeout(5 * time.Minute), + }, + } +} + +func ResourceIbmMqcloudQueueManagerValidator() *validate.ResourceValidator { + validateSchema := make([]validate.ValidateSchema, 0) + validateSchema = append(validateSchema, + validate.ValidateSchema{ + Identifier: "service_instance_guid", + ValidateFunctionIdentifier: validate.ValidateRegexpLen, + Type: validate.TypeString, + Required: true, + Regexp: `^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$`, + MinValueLength: 36, + MaxValueLength: 36, + }, + validate.ValidateSchema{ + Identifier: "name", + ValidateFunctionIdentifier: validate.ValidateRegexpLen, + Type: validate.TypeString, + Required: true, + Regexp: `^[a-zA-Z0-9_.]*$`, + MinValueLength: 1, + MaxValueLength: 48, + }, + validate.ValidateSchema{ + Identifier: "display_name", + ValidateFunctionIdentifier: validate.ValidateRegexpLen, + Type: validate.TypeString, + Optional: true, + Regexp: `^.*$`, + MinValueLength: 0, + MaxValueLength: 150, + }, + validate.ValidateSchema{ + Identifier: "location", + ValidateFunctionIdentifier: validate.ValidateRegexpLen, + Type: validate.TypeString, + Required: true, + Regexp: `^([^[:ascii:]]|[a-zA-Z0-9-._: ])+$`, + MinValueLength: 2, + MaxValueLength: 150, + }, + validate.ValidateSchema{ + Identifier: "size", + ValidateFunctionIdentifier: validate.ValidateAllowedStringValue, + Type: validate.TypeString, + Required: true, + AllowedValues: "large, lite, medium, small, xsmall", + }, + validate.ValidateSchema{ + Identifier: "version", + ValidateFunctionIdentifier: validate.ValidateRegexpLen, + Type: validate.TypeString, + Optional: true, + Regexp: `^[0-9]+.[0-9]+.[0-9]+_[0-9]+$`, + MinValueLength: 7, + MaxValueLength: 15, + }, + ) + + resourceValidator := validate.ResourceValidator{ResourceName: "ibm_mqcloud_queue_manager", Schema: validateSchema} + return &resourceValidator +} + +func resourceIbmMqcloudQueueManagerCreate(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { + mqcloudClient, err := meta.(conns.ClientSession).MqcloudV1() + if err != nil { + return diag.FromErr(err) + } + + err = checkSIPlan(d, meta) + if err != nil { + return diag.FromErr(fmt.Errorf("Create Queue Manager failed %s", err)) + } + + createQueueManagerOptions := &mqcloudv1.CreateQueueManagerOptions{} + + createQueueManagerOptions.SetServiceInstanceGuid(d.Get("service_instance_guid").(string)) + createQueueManagerOptions.SetName(d.Get("name").(string)) + createQueueManagerOptions.SetLocation(d.Get("location").(string)) + createQueueManagerOptions.SetSize(d.Get("size").(string)) + if _, ok := d.GetOk("display_name"); ok { + createQueueManagerOptions.SetDisplayName(d.Get("display_name").(string)) + } + if _, ok := d.GetOk("version"); ok { + createQueueManagerOptions.SetVersion(d.Get("version").(string)) + } + + queueManagerTaskStatus, response, err := mqcloudClient.CreateQueueManagerWithContext(context, createQueueManagerOptions) + if err != nil { + log.Printf("[DEBUG] CreateQueueManagerWithContext failed %s\n%s", err, response) + return diag.FromErr(fmt.Errorf("CreateQueueManagerWithContext failed %s\n%s", err, response)) + } + + d.SetId(fmt.Sprintf("%s/%s", *createQueueManagerOptions.ServiceInstanceGuid, *queueManagerTaskStatus.QueueManagerID)) + if waitForQmStatus { + _, err = waitForQmStatusUpdate(context, d, meta) + if err != nil { + return diag.FromErr(fmt.Errorf("[ERROR] Error waiting for Queue Manager (%s) to be in running state: %s", *queueManagerTaskStatus.QueueManagerID, err)) + } + } + d.SetId(fmt.Sprintf("%s/%s", *createQueueManagerOptions.ServiceInstanceGuid, *queueManagerTaskStatus.QueueManagerID)) + + return resourceIbmMqcloudQueueManagerRead(context, d, meta) +} + +func resourceIbmMqcloudQueueManagerRead(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { + mqcloudClient, err := meta.(conns.ClientSession).MqcloudV1() + if err != nil { + return diag.FromErr(err) + } + + getQueueManagerOptions := &mqcloudv1.GetQueueManagerOptions{} + + parts, err := flex.SepIdParts(d.Id(), "/") + if err != nil { + return diag.FromErr(err) + } + + getQueueManagerOptions.SetServiceInstanceGuid(parts[0]) + getQueueManagerOptions.SetQueueManagerID(parts[1]) + + var queueManagerDetails *mqcloudv1.QueueManagerDetails + var response *core.DetailedResponse + + err = resource.RetryContext(context, 10*time.Second, func() *resource.RetryError { + queueManagerDetails, response, err = mqcloudClient.GetQueueManagerWithContext(context, getQueueManagerOptions) + if err != nil || response == nil { + if response.StatusCode == 404 { + return resource.RetryableError(err) + } + return resource.NonRetryableError(err) + } + return nil + }) + + if err != nil { + if response != nil && response.StatusCode == 404 { + d.SetId("") + return nil + } + log.Printf("[DEBUG] GetQueueManagerWithContext failed %s\n%s", err, response) + return diag.FromErr(fmt.Errorf("GetQueueManagerWithContext failed %s\n%s", err, response)) + } + + if err = d.Set("service_instance_guid", parts[0]); err != nil { + return diag.FromErr(fmt.Errorf("Error setting service_instance_guid: %s", err)) + } + if err = d.Set("name", queueManagerDetails.Name); err != nil { + return diag.FromErr(fmt.Errorf("Error setting name: %s", err)) + } + if !core.IsNil(queueManagerDetails.DisplayName) { + if err = d.Set("display_name", queueManagerDetails.DisplayName); err != nil { + return diag.FromErr(fmt.Errorf("Error setting display_name: %s", err)) + } + } + if err = d.Set("location", queueManagerDetails.Location); err != nil { + return diag.FromErr(fmt.Errorf("Error setting location: %s", err)) + } + if err = d.Set("size", queueManagerDetails.Size); err != nil { + return diag.FromErr(fmt.Errorf("Error setting size: %s", err)) + } + if !core.IsNil(queueManagerDetails.Version) { + if err = d.Set("version", queueManagerDetails.Version); err != nil { + return diag.FromErr(fmt.Errorf("Error setting version: %s", err)) + } + } + if err = d.Set("status_uri", queueManagerDetails.StatusURI); err != nil { + return diag.FromErr(fmt.Errorf("Error setting status_uri: %s", err)) + } + if err = d.Set("web_console_url", queueManagerDetails.WebConsoleURL); err != nil { + return diag.FromErr(fmt.Errorf("Error setting web_console_url: %s", err)) + } + if err = d.Set("rest_api_endpoint_url", queueManagerDetails.RestApiEndpointURL); err != nil { + return diag.FromErr(fmt.Errorf("Error setting rest_api_endpoint_url: %s", err)) + } + if err = d.Set("administrator_api_endpoint_url", queueManagerDetails.AdministratorApiEndpointURL); err != nil { + return diag.FromErr(fmt.Errorf("Error setting administrator_api_endpoint_url: %s", err)) + } + if err = d.Set("connection_info_uri", queueManagerDetails.ConnectionInfoURI); err != nil { + return diag.FromErr(fmt.Errorf("Error setting connection_info_uri: %s", err)) + } + if err = d.Set("date_created", flex.DateTimeToString(queueManagerDetails.DateCreated)); err != nil { + return diag.FromErr(fmt.Errorf("Error setting date_created: %s", err)) + } + if err = d.Set("upgrade_available", queueManagerDetails.UpgradeAvailable); err != nil { + return diag.FromErr(fmt.Errorf("Error setting upgrade_available: %s", err)) + } + if err = d.Set("available_upgrade_versions_uri", queueManagerDetails.AvailableUpgradeVersionsURI); err != nil { + return diag.FromErr(fmt.Errorf("Error setting available_upgrade_versions_uri: %s", err)) + } + if err = d.Set("href", queueManagerDetails.Href); err != nil { + return diag.FromErr(fmt.Errorf("Error setting href: %s", err)) + } + if err = d.Set("queue_manager_id", queueManagerDetails.ID); err != nil { + return diag.FromErr(fmt.Errorf("Error setting queue_manager_id: %s", err)) + } + + return nil +} + +func resourceIbmMqcloudQueueManagerUpdate(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { + mqcloudClient, err := meta.(conns.ClientSession).MqcloudV1() + if err != nil { + return diag.FromErr(err) + } + + err = checkSIPlan(d, meta) + if err != nil { + return diag.FromErr(fmt.Errorf("Update Queue Manager failed %s", err)) + } + + setQueueManagerVersionOptions := &mqcloudv1.SetQueueManagerVersionOptions{} + + parts, err := flex.SepIdParts(d.Id(), "/") + if err != nil { + return diag.FromErr(err) + } + + setQueueManagerVersionOptions.SetServiceInstanceGuid(parts[0]) + setQueueManagerVersionOptions.SetQueueManagerID(parts[1]) + + hasChange := false + + if d.HasChange("version") { + oldVersion, newVersion := d.GetChange("version") + if IsVersionDowngrade(oldVersion.(string), newVersion.(string)) { + return diag.FromErr(fmt.Errorf("Version downgrade is not allowed")) + } + setQueueManagerVersionOptions.SetVersion(newVersion.(string)) + hasChange = true + } + + if hasChange { + _, response, err := mqcloudClient.SetQueueManagerVersionWithContext(context, setQueueManagerVersionOptions) + if err != nil { + log.Printf("[DEBUG] SetQueueManagerVersionWithContext failed %s\n%s", err, response) + return diag.FromErr(fmt.Errorf("SetQueueManagerVersionWithContext failed %s\n%s", err, response)) + } + if waitForQmStatus { + _, err = waitForQmStatusUpdate(context, d, meta) + if err != nil { + return diag.FromErr(fmt.Errorf("[ERROR] Error waiting for Queue Manager (%s) to be in running state: %s", *setQueueManagerVersionOptions.QueueManagerID, err)) + } + } + } + + return resourceIbmMqcloudQueueManagerRead(context, d, meta) +} + +func resourceIbmMqcloudQueueManagerDelete(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { + mqcloudClient, err := meta.(conns.ClientSession).MqcloudV1() + if err != nil { + return diag.FromErr(err) + } + + err = checkSIPlan(d, meta) + if err != nil { + return diag.FromErr(fmt.Errorf("Delete Queue Manager failed %s", err)) + } + + deleteQueueManagerOptions := &mqcloudv1.DeleteQueueManagerOptions{} + + parts, err := flex.SepIdParts(d.Id(), "/") + if err != nil { + return diag.FromErr(err) + } + + deleteQueueManagerOptions.SetServiceInstanceGuid(parts[0]) + deleteQueueManagerOptions.SetQueueManagerID(parts[1]) + + _, response, err := mqcloudClient.DeleteQueueManagerWithContext(context, deleteQueueManagerOptions) + if err != nil { + log.Printf("[DEBUG] DeleteQueueManagerWithContext failed %s\n%s", err, response) + return diag.FromErr(fmt.Errorf("DeleteQueueManagerWithContext failed %s\n%s", err, response)) + } + if waitForQmStatus { + _, err = waitForQueueManagerToDelete(context, d, meta) + if err != nil { + return diag.FromErr(fmt.Errorf("[ERROR] Error waiting for Queue Manager (%s) to be in running state: %s", *deleteQueueManagerOptions.QueueManagerID, err)) + } + } + d.SetId("") + + return nil +} diff --git a/ibm/service/mqcloud/resource_ibm_mqcloud_queue_manager_test.go b/ibm/service/mqcloud/resource_ibm_mqcloud_queue_manager_test.go new file mode 100644 index 0000000000..a6ccbd7feb --- /dev/null +++ b/ibm/service/mqcloud/resource_ibm_mqcloud_queue_manager_test.go @@ -0,0 +1,182 @@ +// Copyright IBM Corp. 2023 All Rights Reserved. +// Licensed under the Mozilla Public License v2.0 + +package mqcloud_test + +import ( + "fmt" + "testing" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" + + acc "github.com/IBM-Cloud/terraform-provider-ibm/ibm/acctest" + "github.com/IBM-Cloud/terraform-provider-ibm/ibm/conns" + "github.com/IBM-Cloud/terraform-provider-ibm/ibm/flex" + "github.com/IBM/mqcloud-go-sdk/mqcloudv1" +) + +func TestAccIbmMqcloudQueueManagerBasic(t *testing.T) { + t.Parallel() + var conf mqcloudv1.QueueManagerDetails + serviceInstanceGuid := acc.MqcloudInstanceID + name := "queue_manager_basic" + location := "ibmcloud_eu_de" + size := "small" + + resource.Test(t, resource.TestCase{ + PreCheck: func() { acc.TestAccPreCheckMqcloud(t) }, + Providers: acc.TestAccProviders, + CheckDestroy: testAccCheckIbmMqcloudQueueManagerDestroy, + Steps: []resource.TestStep{ + { + Config: testAccCheckIbmMqcloudQueueManagerConfigBasic(serviceInstanceGuid, name, location, size), + Check: resource.ComposeAggregateTestCheckFunc( + testAccCheckIbmMqcloudQueueManagerExists("ibm_mqcloud_queue_manager.mqcloud_queue_manager_instance", conf), + resource.TestCheckResourceAttr("ibm_mqcloud_queue_manager.mqcloud_queue_manager_instance", "service_instance_guid", serviceInstanceGuid), + resource.TestCheckResourceAttr("ibm_mqcloud_queue_manager.mqcloud_queue_manager_instance", "name", name), + resource.TestCheckResourceAttr("ibm_mqcloud_queue_manager.mqcloud_queue_manager_instance", "location", location), + resource.TestCheckResourceAttr("ibm_mqcloud_queue_manager.mqcloud_queue_manager_instance", "size", size), + ), + }, + }, + }) +} + +func TestAccIbmMqcloudQueueManagerAllArgs(t *testing.T) { + t.Parallel() + var conf mqcloudv1.QueueManagerDetails + serviceInstanceGuid := acc.MqcloudInstanceID + name := "queue_manager_allargs" + displayName := "queue_manager_allargs" + location := "ibmcloud_eu_de" + size := "small" + version := "9.3.3_3" + versionUpdate := "9.3.4_1" + + resource.Test(t, resource.TestCase{ + PreCheck: func() { acc.TestAccPreCheckMqcloud(t) }, + Providers: acc.TestAccProviders, + CheckDestroy: testAccCheckIbmMqcloudQueueManagerDestroy, + Steps: []resource.TestStep{ + { + Config: testAccCheckIbmMqcloudQueueManagerConfig(serviceInstanceGuid, name, displayName, location, size, version), + Check: resource.ComposeAggregateTestCheckFunc( + testAccCheckIbmMqcloudQueueManagerExists("ibm_mqcloud_queue_manager.mqcloud_queue_manager_instance", conf), + resource.TestCheckResourceAttr("ibm_mqcloud_queue_manager.mqcloud_queue_manager_instance", "service_instance_guid", serviceInstanceGuid), + resource.TestCheckResourceAttr("ibm_mqcloud_queue_manager.mqcloud_queue_manager_instance", "name", name), + resource.TestCheckResourceAttr("ibm_mqcloud_queue_manager.mqcloud_queue_manager_instance", "display_name", displayName), + resource.TestCheckResourceAttr("ibm_mqcloud_queue_manager.mqcloud_queue_manager_instance", "location", location), + resource.TestCheckResourceAttr("ibm_mqcloud_queue_manager.mqcloud_queue_manager_instance", "size", size), + resource.TestCheckResourceAttr("ibm_mqcloud_queue_manager.mqcloud_queue_manager_instance", "version", version), + ), + }, + { + Config: testAccCheckIbmMqcloudQueueManagerConfig(serviceInstanceGuid, name, displayName, location, size, versionUpdate), + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr("ibm_mqcloud_queue_manager.mqcloud_queue_manager_instance", "service_instance_guid", serviceInstanceGuid), + resource.TestCheckResourceAttr("ibm_mqcloud_queue_manager.mqcloud_queue_manager_instance", "name", name), + resource.TestCheckResourceAttr("ibm_mqcloud_queue_manager.mqcloud_queue_manager_instance", "display_name", displayName), + resource.TestCheckResourceAttr("ibm_mqcloud_queue_manager.mqcloud_queue_manager_instance", "location", location), + resource.TestCheckResourceAttr("ibm_mqcloud_queue_manager.mqcloud_queue_manager_instance", "size", size), + resource.TestCheckResourceAttr("ibm_mqcloud_queue_manager.mqcloud_queue_manager_instance", "version", versionUpdate), + ), + }, + { + ResourceName: "ibm_mqcloud_queue_manager.mqcloud_queue_manager_instance", + ImportState: true, + ImportStateVerify: true, + }, + }, + }) +} + +func testAccCheckIbmMqcloudQueueManagerConfigBasic(serviceInstanceGuid string, name string, location string, size string) string { + return fmt.Sprintf(` + resource "ibm_mqcloud_queue_manager" "mqcloud_queue_manager_instance" { + service_instance_guid = "%s" + name = "%s" + location = "%s" + size = "%s" + } + `, serviceInstanceGuid, name, location, size) +} + +func testAccCheckIbmMqcloudQueueManagerConfig(serviceInstanceGuid string, name string, displayName string, location string, size string, version string) string { + return fmt.Sprintf(` + + resource "ibm_mqcloud_queue_manager" "mqcloud_queue_manager_instance" { + service_instance_guid = "%s" + name = "%s" + display_name = "%s" + location = "%s" + size = "%s" + version = "%s" + } + `, serviceInstanceGuid, name, displayName, location, size, version) +} + +func testAccCheckIbmMqcloudQueueManagerExists(n string, obj mqcloudv1.QueueManagerDetails) resource.TestCheckFunc { + return func(s *terraform.State) error { + rs, ok := s.RootModule().Resources[n] + if !ok { + return fmt.Errorf("Not found: %s", n) + } + + mqcloudClient, err := acc.TestAccProvider.Meta().(conns.ClientSession).MqcloudV1() + if err != nil { + return err + } + + getQueueManagerOptions := &mqcloudv1.GetQueueManagerOptions{} + + parts, err := flex.SepIdParts(rs.Primary.ID, "/") + if err != nil { + return err + } + + getQueueManagerOptions.SetServiceInstanceGuid(parts[0]) + getQueueManagerOptions.SetQueueManagerID(parts[1]) + + queueManagerDetails, _, err := mqcloudClient.GetQueueManager(getQueueManagerOptions) + if err != nil { + return err + } + + obj = *queueManagerDetails + return nil + } +} + +func testAccCheckIbmMqcloudQueueManagerDestroy(s *terraform.State) error { + mqcloudClient, err := acc.TestAccProvider.Meta().(conns.ClientSession).MqcloudV1() + if err != nil { + return err + } + for _, rs := range s.RootModule().Resources { + if rs.Type != "ibm_mqcloud_queue_manager" { + continue + } + + getQueueManagerOptions := &mqcloudv1.GetQueueManagerOptions{} + + parts, err := flex.SepIdParts(rs.Primary.ID, "/") + if err != nil { + return err + } + + getQueueManagerOptions.SetServiceInstanceGuid(parts[0]) + getQueueManagerOptions.SetQueueManagerID(parts[1]) + + // Try to find the key + _, response, err := mqcloudClient.GetQueueManager(getQueueManagerOptions) + + if err == nil { + return fmt.Errorf("mqcloud_queue_manager_instance still exists: %s", rs.Primary.ID) + } else if response.StatusCode != 404 { + return fmt.Errorf("Error checking for mqcloud_queue_manager_instance (%s) has been destroyed: %s", rs.Primary.ID, err) + } + } + + return nil +} diff --git a/ibm/service/mqcloud/resource_ibm_mqcloud_truststore_certificate.go b/ibm/service/mqcloud/resource_ibm_mqcloud_truststore_certificate.go new file mode 100644 index 0000000000..63a35c247e --- /dev/null +++ b/ibm/service/mqcloud/resource_ibm_mqcloud_truststore_certificate.go @@ -0,0 +1,297 @@ +// Copyright IBM Corp. 2023 All Rights Reserved. +// Licensed under the Mozilla Public License v2.0 + +package mqcloud + +import ( + "context" + "fmt" + "io" + "log" + "os" + "strings" + + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + + "github.com/IBM-Cloud/terraform-provider-ibm/ibm/conns" + "github.com/IBM-Cloud/terraform-provider-ibm/ibm/flex" + "github.com/IBM-Cloud/terraform-provider-ibm/ibm/validate" + "github.com/IBM/mqcloud-go-sdk/mqcloudv1" +) + +func ResourceIbmMqcloudTruststoreCertificate() *schema.Resource { + return &schema.Resource{ + CreateContext: resourceIbmMqcloudTruststoreCertificateCreate, + ReadContext: resourceIbmMqcloudTruststoreCertificateRead, + DeleteContext: resourceIbmMqcloudTruststoreCertificateDelete, + Importer: &schema.ResourceImporter{}, + + Schema: map[string]*schema.Schema{ + "service_instance_guid": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + ValidateFunc: validate.InvokeValidator("ibm_mqcloud_truststore_certificate", "service_instance_guid"), + Description: "The GUID that uniquely identifies the MQ on Cloud service instance.", + }, + "queue_manager_id": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + ValidateFunc: validate.InvokeValidator("ibm_mqcloud_truststore_certificate", "queue_manager_id"), + Description: "The id of the queue manager to retrieve its full details.", + }, + "label": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + ValidateFunc: validate.InvokeValidator("ibm_mqcloud_truststore_certificate", "label"), + Description: "Certificate label in queue manager store.", + }, + "certificate_type": { + Type: schema.TypeString, + Computed: true, + Description: "The type of certificate.", + }, + "fingerprint_sha256": { + Type: schema.TypeString, + Computed: true, + Description: "Fingerprint SHA256.", + }, + "subject_dn": { + Type: schema.TypeString, + Computed: true, + Description: "Subject's Distinguished Name.", + }, + "subject_cn": { + Type: schema.TypeString, + Computed: true, + Description: "Subject's Common Name.", + }, + "issuer_dn": { + Type: schema.TypeString, + Computed: true, + Description: "Issuer's Distinguished Name.", + }, + "issuer_cn": { + Type: schema.TypeString, + Computed: true, + Description: "Issuer's Common Name.", + }, + "issued": { + Type: schema.TypeString, + Computed: true, + Description: "The Date the certificate was issued.", + }, + "expiry": { + Type: schema.TypeString, + Computed: true, + Description: "Expiry date for the certificate.", + }, + "trusted": { + Type: schema.TypeBool, + Computed: true, + Description: "Indicates whether a certificate is trusted.", + }, + "href": { + Type: schema.TypeString, + Computed: true, + Description: "The URL for this trust store certificate.", + }, + "certificate_id": { + Type: schema.TypeString, + Computed: true, + Description: "Id of the certificate.", + }, + "certificate_file": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + Description: "The filename and path of the certificate to be uploaded.", + }, + }, + } +} + +func ResourceIbmMqcloudTruststoreCertificateValidator() *validate.ResourceValidator { + validateSchema := make([]validate.ValidateSchema, 0) + validateSchema = append(validateSchema, + validate.ValidateSchema{ + Identifier: "service_instance_guid", + ValidateFunctionIdentifier: validate.ValidateRegexpLen, + Type: validate.TypeString, + Required: true, + Regexp: `^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$`, + MinValueLength: 36, + MaxValueLength: 36, + }, + validate.ValidateSchema{ + Identifier: "queue_manager_id", + ValidateFunctionIdentifier: validate.ValidateRegexpLen, + Type: validate.TypeString, + Required: true, + Regexp: `^[0-9a-fA-F]{32}$`, + MinValueLength: 32, + MaxValueLength: 32, + }, + validate.ValidateSchema{ + Identifier: "label", + ValidateFunctionIdentifier: validate.ValidateRegexpLen, + Type: validate.TypeString, + Required: true, + Regexp: `^[a-zA-Z0-9_.]*$`, + MinValueLength: 1, + MaxValueLength: 64, + }, + ) + + resourceValidator := validate.ResourceValidator{ResourceName: "ibm_mqcloud_truststore_certificate", Schema: validateSchema} + return &resourceValidator +} + +func resourceIbmMqcloudTruststoreCertificateCreate(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { + mqcloudClient, err := meta.(conns.ClientSession).MqcloudV1() + if err != nil { + return diag.FromErr(err) + } + err = checkSIPlan(d, meta) + if err != nil { + return diag.FromErr(fmt.Errorf("Create Truststore Certificate failed %s", err)) + } + + createTrustStorePemCertificateOptions := &mqcloudv1.CreateTrustStorePemCertificateOptions{} + + createTrustStorePemCertificateOptions.SetServiceInstanceGuid(d.Get("service_instance_guid").(string)) + createTrustStorePemCertificateOptions.SetQueueManagerID(d.Get("queue_manager_id").(string)) + createTrustStorePemCertificateOptions.SetLabel(d.Get("label").(string)) + //Custom code to read certs and pass to SDK + certBytes, err := os.ReadFile(d.Get("certificate_file").(string)) // just pass the file name + if err != nil { + fmt.Print(err) + } + certString := string(certBytes) // convert content to a 'string' + rc := io.NopCloser(strings.NewReader(certString)) + // certificateFileModel, err := resourceIbmMqcloudTruststoreCertificateMapToio.ReadCloser(d.Get("certificate_file.0").(map[string]interface{})) + // if err != nil { + // return diag.FromErr(err) + // } + createTrustStorePemCertificateOptions.SetCertificateFile(rc) + + trustStoreCertificateDetails, response, err := mqcloudClient.CreateTrustStorePemCertificateWithContext(context, createTrustStorePemCertificateOptions) + if err != nil { + log.Printf("[DEBUG] CreateTrustStorePemCertificateWithContext failed %s\n%s", err, response) + return diag.FromErr(fmt.Errorf("CreateTrustStorePemCertificateWithContext failed %s\n%s", err, response)) + } + + d.SetId(fmt.Sprintf("%s/%s/%s", *createTrustStorePemCertificateOptions.ServiceInstanceGuid, *createTrustStorePemCertificateOptions.QueueManagerID, *trustStoreCertificateDetails.ID)) + + return resourceIbmMqcloudTruststoreCertificateRead(context, d, meta) +} + +func resourceIbmMqcloudTruststoreCertificateRead(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { + mqcloudClient, err := meta.(conns.ClientSession).MqcloudV1() + if err != nil { + return diag.FromErr(err) + } + + getTrustStoreCertificateOptions := &mqcloudv1.GetTrustStoreCertificateOptions{} + + parts, err := flex.SepIdParts(d.Id(), "/") + if err != nil { + return diag.FromErr(err) + } + + getTrustStoreCertificateOptions.SetServiceInstanceGuid(parts[0]) + getTrustStoreCertificateOptions.SetQueueManagerID(parts[1]) + getTrustStoreCertificateOptions.SetCertificateID(parts[2]) + + trustStoreCertificateDetails, response, err := mqcloudClient.GetTrustStoreCertificateWithContext(context, getTrustStoreCertificateOptions) + if err != nil { + if response != nil && response.StatusCode == 404 { + d.SetId("") + return nil + } + log.Printf("[DEBUG] GetTrustStoreCertificateWithContext failed %s\n%s", err, response) + return diag.FromErr(fmt.Errorf("GetTrustStoreCertificateWithContext failed %s\n%s", err, response)) + } + if err = d.Set("service_instance_guid", parts[0]); err != nil { + return diag.FromErr(fmt.Errorf("Error setting service_instance_guid: %s", err)) + } + if err = d.Set("queue_manager_id", parts[1]); err != nil { + return diag.FromErr(fmt.Errorf("Error setting queue_manager_id: %s", err)) + } + downloadCertificatePath := "./certificates/truststore/" + *trustStoreCertificateDetails.Label + ".pem" + if err = d.Set("certificate_file", downloadCertificatePath); err != nil { + return diag.FromErr(fmt.Errorf("Error setting certificate_file: %s", err)) + } + if err = d.Set("label", trustStoreCertificateDetails.Label); err != nil { + return diag.FromErr(fmt.Errorf("Error setting label: %s", err)) + } + if err = d.Set("certificate_type", trustStoreCertificateDetails.CertificateType); err != nil { + return diag.FromErr(fmt.Errorf("Error setting certificate_type: %s", err)) + } + if err = d.Set("fingerprint_sha256", trustStoreCertificateDetails.FingerprintSha256); err != nil { + return diag.FromErr(fmt.Errorf("Error setting fingerprint_sha256: %s", err)) + } + if err = d.Set("subject_dn", trustStoreCertificateDetails.SubjectDn); err != nil { + return diag.FromErr(fmt.Errorf("Error setting subject_dn: %s", err)) + } + if err = d.Set("subject_cn", trustStoreCertificateDetails.SubjectCn); err != nil { + return diag.FromErr(fmt.Errorf("Error setting subject_cn: %s", err)) + } + if err = d.Set("issuer_dn", trustStoreCertificateDetails.IssuerDn); err != nil { + return diag.FromErr(fmt.Errorf("Error setting issuer_dn: %s", err)) + } + if err = d.Set("issuer_cn", trustStoreCertificateDetails.IssuerCn); err != nil { + return diag.FromErr(fmt.Errorf("Error setting issuer_cn: %s", err)) + } + if err = d.Set("issued", flex.DateTimeToString(trustStoreCertificateDetails.Issued)); err != nil { + return diag.FromErr(fmt.Errorf("Error setting issued: %s", err)) + } + if err = d.Set("expiry", flex.DateTimeToString(trustStoreCertificateDetails.Expiry)); err != nil { + return diag.FromErr(fmt.Errorf("Error setting expiry: %s", err)) + } + if err = d.Set("trusted", trustStoreCertificateDetails.Trusted); err != nil { + return diag.FromErr(fmt.Errorf("Error setting trusted: %s", err)) + } + if err = d.Set("href", trustStoreCertificateDetails.Href); err != nil { + return diag.FromErr(fmt.Errorf("Error setting href: %s", err)) + } + if err = d.Set("certificate_id", trustStoreCertificateDetails.ID); err != nil { + return diag.FromErr(fmt.Errorf("Error setting certificate_id: %s", err)) + } + + return nil +} + +func resourceIbmMqcloudTruststoreCertificateDelete(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { + mqcloudClient, err := meta.(conns.ClientSession).MqcloudV1() + if err != nil { + return diag.FromErr(err) + } + err = checkSIPlan(d, meta) + if err != nil { + return diag.FromErr(fmt.Errorf("Delete Truststore Certificate failed %s", err)) + } + deleteTrustStoreCertificateOptions := &mqcloudv1.DeleteTrustStoreCertificateOptions{} + + parts, err := flex.SepIdParts(d.Id(), "/") + if err != nil { + return diag.FromErr(err) + } + + deleteTrustStoreCertificateOptions.SetServiceInstanceGuid(parts[0]) + deleteTrustStoreCertificateOptions.SetQueueManagerID(parts[1]) + deleteTrustStoreCertificateOptions.SetCertificateID(parts[2]) + + response, err := mqcloudClient.DeleteTrustStoreCertificateWithContext(context, deleteTrustStoreCertificateOptions) + if err != nil { + log.Printf("[DEBUG] DeleteTrustStoreCertificateWithContext failed %s\n%s", err, response) + return diag.FromErr(fmt.Errorf("DeleteTrustStoreCertificateWithContext failed %s\n%s", err, response)) + } + + d.SetId("") + + return nil +} diff --git a/ibm/service/mqcloud/resource_ibm_mqcloud_truststore_certificate_test.go b/ibm/service/mqcloud/resource_ibm_mqcloud_truststore_certificate_test.go new file mode 100644 index 0000000000..80acc0e4a1 --- /dev/null +++ b/ibm/service/mqcloud/resource_ibm_mqcloud_truststore_certificate_test.go @@ -0,0 +1,163 @@ +// Copyright IBM Corp. 2023 All Rights Reserved. +// Licensed under the Mozilla Public License v2.0 + +package mqcloud_test + +import ( + "fmt" + "testing" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" + + acc "github.com/IBM-Cloud/terraform-provider-ibm/ibm/acctest" + "github.com/IBM-Cloud/terraform-provider-ibm/ibm/conns" + "github.com/IBM-Cloud/terraform-provider-ibm/ibm/flex" + "github.com/IBM/mqcloud-go-sdk/mqcloudv1" +) + +func TestAccIbmMqcloudTruststoreCertificateBasic(t *testing.T) { + var conf mqcloudv1.TrustStoreCertificateDetails + serviceInstanceGuid := acc.MqcloudInstanceID + queueManagerID := acc.MqcloudQueueManagerID + label := fmt.Sprintf("tf_label_%d", acctest.RandIntRange(10, 100)) + certificateFile := acc.MqcloudTSCertFilePath + + resource.Test(t, resource.TestCase{ + PreCheck: func() { acc.TestAccPreCheckMqcloud(t) }, + Providers: acc.TestAccProviders, + CheckDestroy: testAccCheckIbmMqcloudTruststoreCertificateDestroy, + Steps: []resource.TestStep{ + { + Config: testAccCheckIbmMqcloudTruststoreCertificateConfigBasic(serviceInstanceGuid, queueManagerID, label, certificateFile), + Check: resource.ComposeAggregateTestCheckFunc( + testAccCheckIbmMqcloudTruststoreCertificateExists("ibm_mqcloud_truststore_certificate.mqcloud_truststore_certificate_instance", conf), + resource.TestCheckResourceAttr("ibm_mqcloud_truststore_certificate.mqcloud_truststore_certificate_instance", "service_instance_guid", serviceInstanceGuid), + resource.TestCheckResourceAttr("ibm_mqcloud_truststore_certificate.mqcloud_truststore_certificate_instance", "queue_manager_id", queueManagerID), + resource.TestCheckResourceAttr("ibm_mqcloud_truststore_certificate.mqcloud_truststore_certificate_instance", "label", label), + ), + }, + }, + }) +} + +func TestAccIbmMqcloudTruststoreCertificateAllArgs(t *testing.T) { + var conf mqcloudv1.TrustStoreCertificateDetails + serviceInstanceGuid := acc.MqcloudInstanceID + queueManagerID := acc.MqcloudQueueManagerID + label := fmt.Sprintf("tf_label_%d", acctest.RandIntRange(10, 100)) + certificateFile := acc.MqcloudTSCertFilePath + + resource.Test(t, resource.TestCase{ + PreCheck: func() { acc.TestAccPreCheckMqcloud(t) }, + Providers: acc.TestAccProviders, + CheckDestroy: testAccCheckIbmMqcloudTruststoreCertificateDestroy, + Steps: []resource.TestStep{ + { + Config: testAccCheckIbmMqcloudTruststoreCertificateConfig(serviceInstanceGuid, queueManagerID, label, certificateFile), + Check: resource.ComposeAggregateTestCheckFunc( + testAccCheckIbmMqcloudTruststoreCertificateExists("ibm_mqcloud_truststore_certificate.mqcloud_truststore_certificate_instance", conf), + resource.TestCheckResourceAttr("ibm_mqcloud_truststore_certificate.mqcloud_truststore_certificate_instance", "service_instance_guid", serviceInstanceGuid), + resource.TestCheckResourceAttr("ibm_mqcloud_truststore_certificate.mqcloud_truststore_certificate_instance", "queue_manager_id", queueManagerID), + resource.TestCheckResourceAttr("ibm_mqcloud_truststore_certificate.mqcloud_truststore_certificate_instance", "label", label), + ), + }, + { + ResourceName: "ibm_mqcloud_truststore_certificate.mqcloud_truststore_certificate_instance", + ImportState: true, + ImportStateVerify: true, + }, + }, + }) +} + +func testAccCheckIbmMqcloudTruststoreCertificateConfigBasic(serviceInstanceGuid string, queueManagerID string, label string, certificateFile string) string { + return fmt.Sprintf(` + resource "ibm_mqcloud_truststore_certificate" "mqcloud_truststore_certificate_instance" { + service_instance_guid = "%s" + queue_manager_id = "%s" + label = "%s" + certificate_file = "%s" + } + `, serviceInstanceGuid, queueManagerID, label, certificateFile) +} + +func testAccCheckIbmMqcloudTruststoreCertificateConfig(serviceInstanceGuid string, queueManagerID string, label string, certificateFile string) string { + return fmt.Sprintf(` + + resource "ibm_mqcloud_truststore_certificate" "mqcloud_truststore_certificate_instance" { + service_instance_guid = "%s" + queue_manager_id = "%s" + label = "%s" + certificate_file = "%s" + } + `, serviceInstanceGuid, queueManagerID, label, certificateFile) +} + +func testAccCheckIbmMqcloudTruststoreCertificateExists(n string, obj mqcloudv1.TrustStoreCertificateDetails) resource.TestCheckFunc { + return func(s *terraform.State) error { + rs, ok := s.RootModule().Resources[n] + if !ok { + return fmt.Errorf("Not found: %s", n) + } + + mqcloudClient, err := acc.TestAccProvider.Meta().(conns.ClientSession).MqcloudV1() + if err != nil { + return err + } + + getTrustStoreCertificateOptions := &mqcloudv1.GetTrustStoreCertificateOptions{} + + parts, err := flex.SepIdParts(rs.Primary.ID, "/") + if err != nil { + return err + } + + getTrustStoreCertificateOptions.SetServiceInstanceGuid(parts[0]) + getTrustStoreCertificateOptions.SetQueueManagerID(parts[1]) + getTrustStoreCertificateOptions.SetCertificateID(parts[2]) + + trustStoreCertificateDetails, _, err := mqcloudClient.GetTrustStoreCertificate(getTrustStoreCertificateOptions) + if err != nil { + return err + } + + obj = *trustStoreCertificateDetails + return nil + } +} + +func testAccCheckIbmMqcloudTruststoreCertificateDestroy(s *terraform.State) error { + mqcloudClient, err := acc.TestAccProvider.Meta().(conns.ClientSession).MqcloudV1() + if err != nil { + return err + } + for _, rs := range s.RootModule().Resources { + if rs.Type != "ibm_mqcloud_truststore_certificate" { + continue + } + + getTrustStoreCertificateOptions := &mqcloudv1.GetTrustStoreCertificateOptions{} + + parts, err := flex.SepIdParts(rs.Primary.ID, "/") + if err != nil { + return err + } + + getTrustStoreCertificateOptions.SetServiceInstanceGuid(parts[0]) + getTrustStoreCertificateOptions.SetQueueManagerID(parts[1]) + getTrustStoreCertificateOptions.SetCertificateID(parts[2]) + + // Try to find the key + _, response, err := mqcloudClient.GetTrustStoreCertificate(getTrustStoreCertificateOptions) + + if err == nil { + return fmt.Errorf("mqcloud_truststore_certificate still exists: %s", rs.Primary.ID) + } else if response.StatusCode != 404 { + return fmt.Errorf("Error checking for mqcloud_truststore_certificate (%s) has been destroyed: %s", rs.Primary.ID, err) + } + } + + return nil +} diff --git a/ibm/service/mqcloud/resource_ibm_mqcloud_user.go b/ibm/service/mqcloud/resource_ibm_mqcloud_user.go new file mode 100644 index 0000000000..3509b1d1da --- /dev/null +++ b/ibm/service/mqcloud/resource_ibm_mqcloud_user.go @@ -0,0 +1,196 @@ +// Copyright IBM Corp. 2023 All Rights Reserved. +// Licensed under the Mozilla Public License v2.0 + +package mqcloud + +import ( + "context" + "fmt" + "log" + + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + + "github.com/IBM-Cloud/terraform-provider-ibm/ibm/conns" + "github.com/IBM-Cloud/terraform-provider-ibm/ibm/flex" + "github.com/IBM-Cloud/terraform-provider-ibm/ibm/validate" + "github.com/IBM/mqcloud-go-sdk/mqcloudv1" +) + +func ResourceIbmMqcloudUser() *schema.Resource { + return &schema.Resource{ + CreateContext: resourceIbmMqcloudUserCreate, + ReadContext: resourceIbmMqcloudUserRead, + DeleteContext: resourceIbmMqcloudUserDelete, + Importer: &schema.ResourceImporter{}, + + Schema: map[string]*schema.Schema{ + "service_instance_guid": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + ValidateFunc: validate.InvokeValidator("ibm_mqcloud_user", "service_instance_guid"), + Description: "The GUID that uniquely identifies the MQ on Cloud service instance.", + }, + "name": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + ValidateFunc: validate.InvokeValidator("ibm_mqcloud_user", "name"), + Description: "The shortname of the user that will be used as the IBM MQ administrator in interactions with a queue manager for this service instance.", + }, + "email": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + ValidateFunc: validate.InvokeValidator("ibm_mqcloud_user", "email"), + Description: "The email of the user.", + }, + "href": { + Type: schema.TypeString, + Computed: true, + Description: "The URL for the user details.", + }, + "user_id": { + Type: schema.TypeString, + Computed: true, + Description: "The ID of the user which was allocated on creation, and can be used for delete calls.", + }, + }, + } +} + +func ResourceIbmMqcloudUserValidator() *validate.ResourceValidator { + validateSchema := make([]validate.ValidateSchema, 0) + validateSchema = append(validateSchema, + validate.ValidateSchema{ + Identifier: "service_instance_guid", + ValidateFunctionIdentifier: validate.ValidateRegexpLen, + Type: validate.TypeString, + Required: true, + Regexp: `^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$`, + MinValueLength: 36, + MaxValueLength: 36, + }, + validate.ValidateSchema{ + Identifier: "name", + ValidateFunctionIdentifier: validate.ValidateRegexpLen, + Type: validate.TypeString, + Required: true, + Regexp: `^[a-z][-a-z0-9]*$`, + MinValueLength: 1, + MaxValueLength: 12, + }, + validate.ValidateSchema{ + Identifier: "email", + ValidateFunctionIdentifier: validate.StringLenBetween, + Type: validate.TypeString, + Required: true, + MinValueLength: 5, + MaxValueLength: 253, + }, + ) + + resourceValidator := validate.ResourceValidator{ResourceName: "ibm_mqcloud_user", Schema: validateSchema} + return &resourceValidator +} + +func resourceIbmMqcloudUserCreate(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { + mqcloudClient, err := meta.(conns.ClientSession).MqcloudV1() + if err != nil { + return diag.FromErr(err) + } + err = checkSIPlan(d, meta) + if err != nil { + return diag.FromErr(fmt.Errorf("Create User failed %s", err)) + } + createUserOptions := &mqcloudv1.CreateUserOptions{} + + createUserOptions.SetServiceInstanceGuid(d.Get("service_instance_guid").(string)) + createUserOptions.SetEmail(d.Get("email").(string)) + createUserOptions.SetName(d.Get("name").(string)) + + userDetails, response, err := mqcloudClient.CreateUserWithContext(context, createUserOptions) + if err != nil { + log.Printf("[DEBUG] CreateUserWithContext failed %s\n%s", err, response) + return diag.FromErr(fmt.Errorf("CreateUserWithContext failed %s\n%s", err, response)) + } + + d.SetId(fmt.Sprintf("%s/%s", *createUserOptions.ServiceInstanceGuid, *userDetails.ID)) + + return resourceIbmMqcloudUserRead(context, d, meta) +} + +func resourceIbmMqcloudUserRead(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { + mqcloudClient, err := meta.(conns.ClientSession).MqcloudV1() + if err != nil { + return diag.FromErr(err) + } + + getUserOptions := &mqcloudv1.GetUserOptions{} + + parts, err := flex.SepIdParts(d.Id(), "/") + if err != nil { + return diag.FromErr(err) + } + + getUserOptions.SetServiceInstanceGuid(parts[0]) + getUserOptions.SetUserID(parts[1]) + + userDetails, response, err := mqcloudClient.GetUserWithContext(context, getUserOptions) + if err != nil { + if response != nil && response.StatusCode == 404 { + d.SetId("") + return nil + } + log.Printf("[DEBUG] GetUserWithContext failed %s\n%s", err, response) + return diag.FromErr(fmt.Errorf("GetUserWithContext failed %s\n%s", err, response)) + } + if err = d.Set("service_instance_guid", parts[0]); err != nil { + return diag.FromErr(fmt.Errorf("Error setting service_instance_guid: %s", err)) + } + if err = d.Set("name", userDetails.Name); err != nil { + return diag.FromErr(fmt.Errorf("Error setting name: %s", err)) + } + if err = d.Set("email", userDetails.Email); err != nil { + return diag.FromErr(fmt.Errorf("Error setting email: %s", err)) + } + if err = d.Set("href", userDetails.Href); err != nil { + return diag.FromErr(fmt.Errorf("Error setting href: %s", err)) + } + if err = d.Set("user_id", userDetails.ID); err != nil { + return diag.FromErr(fmt.Errorf("Error setting user_id: %s", err)) + } + + return nil +} + +func resourceIbmMqcloudUserDelete(context context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { + mqcloudClient, err := meta.(conns.ClientSession).MqcloudV1() + if err != nil { + return diag.FromErr(err) + } + err = checkSIPlan(d, meta) + if err != nil { + return diag.FromErr(fmt.Errorf("Delete User failed %s", err)) + } + deleteUserOptions := &mqcloudv1.DeleteUserOptions{} + + parts, err := flex.SepIdParts(d.Id(), "/") + if err != nil { + return diag.FromErr(err) + } + + deleteUserOptions.SetServiceInstanceGuid(parts[0]) + deleteUserOptions.SetUserID(parts[1]) + + response, err := mqcloudClient.DeleteUserWithContext(context, deleteUserOptions) + if err != nil { + log.Printf("[DEBUG] DeleteUserWithContext failed %s\n%s", err, response) + return diag.FromErr(fmt.Errorf("DeleteUserWithContext failed %s\n%s", err, response)) + } + + d.SetId("") + + return nil +} diff --git a/ibm/service/mqcloud/resource_ibm_mqcloud_user_test.go b/ibm/service/mqcloud/resource_ibm_mqcloud_user_test.go new file mode 100644 index 0000000000..551827f583 --- /dev/null +++ b/ibm/service/mqcloud/resource_ibm_mqcloud_user_test.go @@ -0,0 +1,157 @@ +// Copyright IBM Corp. 2023 All Rights Reserved. +// Licensed under the Mozilla Public License v2.0 + +package mqcloud_test + +import ( + "fmt" + "testing" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" + + acc "github.com/IBM-Cloud/terraform-provider-ibm/ibm/acctest" + "github.com/IBM-Cloud/terraform-provider-ibm/ibm/conns" + "github.com/IBM-Cloud/terraform-provider-ibm/ibm/flex" + "github.com/IBM/mqcloud-go-sdk/mqcloudv1" +) + +func TestAccIbmMqcloudUserBasic(t *testing.T) { + var conf mqcloudv1.UserDetails + serviceInstanceGuid := acc.MqcloudInstanceID + name := fmt.Sprintf("tfname%d", acctest.RandIntRange(10, 100)) + email := fmt.Sprintf("tfemail%d@ibm.com", acctest.RandIntRange(10, 100)) + + resource.Test(t, resource.TestCase{ + PreCheck: func() { acc.TestAccPreCheckMqcloud(t) }, + Providers: acc.TestAccProviders, + CheckDestroy: testAccCheckIbmMqcloudUserDestroy, + Steps: []resource.TestStep{ + { + Config: testAccCheckIbmMqcloudUserConfigBasic(serviceInstanceGuid, name, email), + Check: resource.ComposeAggregateTestCheckFunc( + testAccCheckIbmMqcloudUserExists("ibm_mqcloud_user.mqcloud_user_instance", conf), + resource.TestCheckResourceAttr("ibm_mqcloud_user.mqcloud_user_instance", "service_instance_guid", serviceInstanceGuid), + resource.TestCheckResourceAttr("ibm_mqcloud_user.mqcloud_user_instance", "name", name), + resource.TestCheckResourceAttr("ibm_mqcloud_user.mqcloud_user_instance", "email", email), + ), + }, + }, + }) +} + +func TestAccIbmMqcloudUserAllArgs(t *testing.T) { + var conf mqcloudv1.UserDetails + serviceInstanceGuid := acc.MqcloudInstanceID + name := fmt.Sprintf("tfname%d", acctest.RandIntRange(10, 100)) + email := fmt.Sprintf("tfemail%d@ibm.com", acctest.RandIntRange(10, 100)) + + resource.Test(t, resource.TestCase{ + PreCheck: func() { acc.TestAccPreCheckMqcloud(t) }, + Providers: acc.TestAccProviders, + CheckDestroy: testAccCheckIbmMqcloudUserDestroy, + Steps: []resource.TestStep{ + { + Config: testAccCheckIbmMqcloudUserConfig(serviceInstanceGuid, name, email), + Check: resource.ComposeAggregateTestCheckFunc( + testAccCheckIbmMqcloudUserExists("ibm_mqcloud_user.mqcloud_user_instance", conf), + resource.TestCheckResourceAttr("ibm_mqcloud_user.mqcloud_user_instance", "service_instance_guid", serviceInstanceGuid), + resource.TestCheckResourceAttr("ibm_mqcloud_user.mqcloud_user_instance", "name", name), + resource.TestCheckResourceAttr("ibm_mqcloud_user.mqcloud_user_instance", "email", email), + ), + }, + { + ResourceName: "ibm_mqcloud_user.mqcloud_user_instance", + ImportState: true, + ImportStateVerify: true, + }, + }, + }) +} + +func testAccCheckIbmMqcloudUserConfigBasic(serviceInstanceGuid string, name string, email string) string { + return fmt.Sprintf(` + resource "ibm_mqcloud_user" "mqcloud_user_instance" { + service_instance_guid = "%s" + name = "%s" + email = "%s" + } + `, serviceInstanceGuid, name, email) +} + +func testAccCheckIbmMqcloudUserConfig(serviceInstanceGuid string, name string, email string) string { + return fmt.Sprintf(` + + resource "ibm_mqcloud_user" "mqcloud_user_instance" { + service_instance_guid = "%s" + name = "%s" + email = "%s" + } + `, serviceInstanceGuid, name, email) +} + +func testAccCheckIbmMqcloudUserExists(n string, obj mqcloudv1.UserDetails) resource.TestCheckFunc { + return func(s *terraform.State) error { + rs, ok := s.RootModule().Resources[n] + if !ok { + return fmt.Errorf("Not found: %s", n) + } + + mqcloudClient, err := acc.TestAccProvider.Meta().(conns.ClientSession).MqcloudV1() + if err != nil { + return err + } + + getUserOptions := &mqcloudv1.GetUserOptions{} + + parts, err := flex.SepIdParts(rs.Primary.ID, "/") + if err != nil { + return err + } + + getUserOptions.SetServiceInstanceGuid(parts[0]) + getUserOptions.SetUserID(parts[1]) + + userDetails, _, err := mqcloudClient.GetUser(getUserOptions) + if err != nil { + return err + } + + obj = *userDetails + return nil + } +} + +func testAccCheckIbmMqcloudUserDestroy(s *terraform.State) error { + mqcloudClient, err := acc.TestAccProvider.Meta().(conns.ClientSession).MqcloudV1() + if err != nil { + return err + } + for _, rs := range s.RootModule().Resources { + if rs.Type != "ibm_mqcloud_user" { + continue + } + + getUserOptions := &mqcloudv1.GetUserOptions{} + + parts, err := flex.SepIdParts(rs.Primary.ID, "/") + if err != nil { + return err + } + + getUserOptions.SetServiceInstanceGuid(parts[0]) + getUserOptions.SetUserID(parts[1]) + + // Try to find the key + _, response, err := mqcloudClient.GetUser(getUserOptions) + + if err == nil { + return fmt.Errorf("mqcloud_user still exists: %s", rs.Primary.ID) + } else if response.StatusCode != 404 { + return fmt.Errorf("Error checking for mqcloud_user (%s) has been destroyed: %s", rs.Primary.ID, err) + } + } + + return nil +} diff --git a/ibm/service/mqcloud/utils.go b/ibm/service/mqcloud/utils.go new file mode 100644 index 0000000000..877b5ed79b --- /dev/null +++ b/ibm/service/mqcloud/utils.go @@ -0,0 +1,196 @@ +package mqcloud + +import ( + "context" + "fmt" + "os" + "strings" + "time" + + "strconv" + + "github.com/IBM-Cloud/terraform-provider-ibm/ibm/conns" + "github.com/IBM-Cloud/terraform-provider-ibm/ibm/flex" + rc "github.com/IBM/platform-services-go-sdk/resourcecontrollerv2" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + + "github.com/IBM/mqcloud-go-sdk/mqcloudv1" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" +) + +func loadWaitForQmStatusEnvVar() bool { + envValue := os.Getenv("IBMCLOUD_MQCLOUD_WAIT_FOR_QM_STATUS") + return strings.ToLower(envValue) != "false" +} + +var waitForQmStatus = loadWaitForQmStatusEnvVar() +var planCache = make(map[string]string) + +const qmStatus = "running" +const qmCreating = "initializing" +const isQueueManagerDeleting = "true" +const isQueueManagerDeleteDone = "true" +const reservedDeploymentPlan = "reserved-deployment" +const enforceReservedDeploymentPlan = true + +// waitForQmStatusUpdate Waits for QM to be in running state +func waitForQmStatusUpdate(context context.Context, d *schema.ResourceData, meta interface{}) (interface{}, error) { + mqcloudClient, err := meta.(conns.ClientSession).MqcloudV1() + if err != nil { + return "", err + } + + stateConf := &resource.StateChangeConf{ + Pending: []string{qmCreating}, + Target: []string{qmStatus}, + Refresh: func() (interface{}, string, error) { + getQueueManagerStatusOptions := &mqcloudv1.GetQueueManagerStatusOptions{} + parts, err := flex.SepIdParts(d.Id(), "/") + if err != nil { + return nil, "", err + } + getQueueManagerStatusOptions.SetServiceInstanceGuid(parts[0]) + getQueueManagerStatusOptions.SetQueueManagerID(parts[1]) + queueManagerStatus, response, err := mqcloudClient.GetQueueManagerStatusWithContext(context, getQueueManagerStatusOptions) + if err != nil { + return "", "", fmt.Errorf("GetQueueManagerWithContext ...... %s err: %s", response, err) + } + if queueManagerStatus == nil || queueManagerStatus.Status == nil { + return nil, "", fmt.Errorf("queueManagerStatus or queueManagerStatus.Status is nil") + } + fmt.Println("The queue manager is currently in the " + *queueManagerStatus.Status + " state ....") + + if *queueManagerStatus.Status == "running" { + return queueManagerStatus, qmStatus, nil + } else if *queueManagerStatus.Status == "initialization_failed" || *queueManagerStatus.Status == "restore_failed" || *queueManagerStatus.Status == "status_not_available" { + return queueManagerStatus, qmStatus, fmt.Errorf("%s", err) + } + return queueManagerStatus, qmCreating, nil + }, + Timeout: d.Timeout(schema.TimeoutCreate), + Delay: 10 * time.Second, + MinTimeout: 30 * time.Second, + } + return stateConf.WaitForStateContext(context) +} + +func waitForQueueManagerToDelete(context context.Context, d *schema.ResourceData, meta interface{}) (interface{}, error) { + mqcloudClient, err := meta.(conns.ClientSession).MqcloudV1() + if err != nil { + return false, err + } + + stateConf := &resource.StateChangeConf{ + Pending: []string{isQueueManagerDeleting}, + Target: []string{isQueueManagerDeleteDone}, + Refresh: func() (interface{}, string, error) { + getQueueManagerOptions := &mqcloudv1.GetQueueManagerOptions{} + + parts, err := flex.SepIdParts(d.Id(), "/") + if err != nil { + return "", "", err + } + + getQueueManagerOptions.SetServiceInstanceGuid(parts[0]) + getQueueManagerOptions.SetQueueManagerID(parts[1]) + + queueManagerDetails, response, err := mqcloudClient.GetQueueManagerWithContext(context, getQueueManagerOptions) + if err != nil { + if response != nil && response.StatusCode == 404 { + return queueManagerDetails, isQueueManagerDeleteDone, nil + } + return nil, "", err + } + return queueManagerDetails, isQueueManagerDeleting, nil + }, + Timeout: d.Timeout(schema.TimeoutDelete), + Delay: 60 * time.Second, + MinTimeout: 60 * time.Second, + } + + return stateConf.WaitForStateContext(context) +} + +// checkSIPlan checks whether a Service Instance (SI) is in a Reserved Deployment. +func checkSIPlan(d *schema.ResourceData, meta interface{}) error { + if !enforceReservedDeploymentPlan { + return nil + } + + instanceID := d.Get("service_instance_guid").(string) + // Check cache first + if plan, found := planCache[instanceID]; found { + return handlePlanCheck(plan, instanceID) + } + + // Creating a Resource Controller Client + rsConClient, err := meta.(conns.ClientSession).ResourceControllerV2API() + if err != nil { + return fmt.Errorf("[ERROR] Failed to create Resource Controller Client: %s", err) + } + + // Getting the resource instance + rsInst := rc.GetResourceInstanceOptions{ + ID: &instanceID, + } + instance, response, err := rsConClient.GetResourceInstance(&rsInst) + if err != nil { + return fmt.Errorf("[ERROR] Failed to retrieve resource instance: %s, Response: %s", err, response) + } + + // Creating a Resource Catalog Client + rsCatClient, err := meta.(conns.ClientSession).ResourceCatalogAPI() + if err != nil { + return fmt.Errorf("[ERROR] Failed to create Resource Catalog Client: %s", err) + } + rsCatRepo := rsCatClient.ResourceCatalog() + + // Checking the service plan + plan, err := rsCatRepo.GetServicePlanName(*instance.ResourcePlanID) + if err != nil { + return fmt.Errorf("[ERROR] Failed to retrieve service plan: %s", err) + } + + // Update cache + planCache[instanceID] = plan + + return handlePlanCheck(plan, instanceID) +} + +func handlePlanCheck(plan string, instanceID string) error { + if plan != reservedDeploymentPlan { + return fmt.Errorf("[ERROR] Terraform is only supported for Reserved Deployment Plan. Your Service Plan is: %s for the instance %s", plan, instanceID) + } + return nil +} + +func IsVersionDowngrade(oldVersion, newVersion string) bool { + oldParts := strings.Split(oldVersion, ".") + newParts := strings.Split(newVersion, ".") + + for i := 0; i < len(oldParts); i++ { + oldPartNum := strings.Split(oldParts[i], "_")[0] + newPartNum := strings.Split(newParts[i], "_")[0] + + oldPart, _ := strconv.Atoi(oldPartNum) + newPart, _ := strconv.Atoi(newPartNum) + + if newPart < oldPart { + return true + } else if newPart > oldPart { + return false + } + } + + oldPatchNum := strings.Split(oldParts[len(oldParts)-1], "_") + newPatchNum := strings.Split(newParts[len(newParts)-1], "_") + + if len(oldPatchNum) > 1 && len(newPatchNum) > 1 { + oldPatch, _ := strconv.Atoi(oldPatchNum[1]) + newPatch, _ := strconv.Atoi(newPatchNum[1]) + + return newPatch < oldPatch + } + + return false +} diff --git a/website/allowed-subcategories.txt b/website/allowed-subcategories.txt index 1e97423139..f80f98af65 100644 --- a/website/allowed-subcategories.txt +++ b/website/allowed-subcategories.txt @@ -26,6 +26,7 @@ Internet services Key Management Service Kubernetes Service Metrics Router +MQ on Cloud Object Storage Power Systems Project diff --git a/website/docs/d/mqcloud_application.html.markdown b/website/docs/d/mqcloud_application.html.markdown new file mode 100644 index 0000000000..0e854d5c8a --- /dev/null +++ b/website/docs/d/mqcloud_application.html.markdown @@ -0,0 +1,44 @@ +--- +layout: "ibm" +page_title: "IBM : ibm_mqcloud_application" +description: |- + Get information about mqcloud_application +subcategory: "MQ on Cloud" +--- + +# ibm_mqcloud_application + +Provides a read-only data source to retrieve information about a mqcloud_application. You can then reference the fields of the data source in other resources within the same configuration by using interpolation syntax. + +## Example Usage + +```hcl +data "ibm_mqcloud_application" "mqcloud_application" { + name = ibm_mqcloud_application.mqcloud_application_instance.name + service_instance_guid = ibm_mqcloud_application.mqcloud_application_instance.service_instance_guid +} +``` + +## Argument Reference + +You can specify the following arguments for this data source. + +* `name` - (Optional, String) The name of the application - conforming to MQ rules. + * Constraints: The maximum length is `12` characters. The minimum length is `1` character. +* `service_instance_guid` - (Required, Forces new resource, String) The GUID that uniquely identifies the MQ on Cloud service instance. + * Constraints: The maximum length is `36` characters. The minimum length is `36` characters. The value must match regular expression `/^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/`. + +## Attribute Reference + +After your data source is created, you can read values from the following attributes. + +* `id` - The unique identifier of the mqcloud_application. +* `applications` - (List) List of applications. + * Constraints: The maximum length is `50` items. The minimum length is `0` items. +Nested schema for **applications**: + * `create_api_key_uri` - (String) The URI to create a new apikey for the application. + * `href` - (String) The URL for this application. + * `id` - (String) The ID of the application which was allocated on creation, and can be used for delete calls. + * `name` - (String) The name of the application - conforming to MQ rules. + * Constraints: The maximum length is `12` characters. The minimum length is `1` character. + diff --git a/website/docs/d/mqcloud_keystore_certificate.html.markdown b/website/docs/d/mqcloud_keystore_certificate.html.markdown new file mode 100644 index 0000000000..6222ecd784 --- /dev/null +++ b/website/docs/d/mqcloud_keystore_certificate.html.markdown @@ -0,0 +1,63 @@ +--- +layout: "ibm" +page_title: "IBM : ibm_mqcloud_keystore_certificate" +description: |- + Get information about mqcloud_keystore_certificate +subcategory: "MQ on Cloud" +--- + +# ibm_mqcloud_keystore_certificate + +Provides a read-only data source to retrieve information about a mqcloud_keystore_certificate. You can then reference the fields of the data source in other resources within the same configuration by using interpolation syntax. + +## Example Usage + +```hcl +data "ibm_mqcloud_keystore_certificate" "mqcloud_keystore_certificate" { + label = ibm_mqcloud_keystore_certificate.mqcloud_keystore_certificate_instance.label + queue_manager_id = ibm_mqcloud_keystore_certificate.mqcloud_keystore_certificate_instance.queue_manager_id + service_instance_guid = ibm_mqcloud_keystore_certificate.mqcloud_keystore_certificate_instance.service_instance_guid +} +``` + +## Argument Reference + +You can specify the following arguments for this data source. + +* `label` - (Optional, String) Certificate label in queue manager store. + * Constraints: The maximum length is `64` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9_.]*$/`. +* `queue_manager_id` - (Required, Forces new resource, String) The id of the queue manager to retrieve its full details. + * Constraints: The maximum length is `32` characters. The minimum length is `32` characters. The value must match regular expression `/^[0-9a-fA-F]{32}$/`. +* `service_instance_guid` - (Required, Forces new resource, String) The GUID that uniquely identifies the MQ on Cloud service instance. + * Constraints: The maximum length is `36` characters. The minimum length is `36` characters. The value must match regular expression `/^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/`. + +## Attribute Reference + +After your data source is created, you can read values from the following attributes. + +* `id` - The unique identifier of the mqcloud_keystore_certificate. +* `key_store` - (List) The list of key store certificates. + * Constraints: The maximum length is `50` items. The minimum length is `0` items. +Nested schema for **key_store**: + * `certificate_type` - (String) The type of certificate. + * Constraints: Allowable values are: `key_store`. + * `dns_names` - (List) The list of DNS names. + * Constraints: The maximum length is `200` items. The minimum length is `0` items. + * `dns_names_total_count` - (Integer) The total count of dns names. + * `expiry` - (String) Expiry date for the certificate. + * `fingerprint_sha256` - (String) Fingerprint SHA256. + * Constraints: The value must match regular expression `/^[A-F0-9]{2}(:[A-F0-9]{2}){31}$/`. + * `href` - (String) The URL for this key store certificate. + * `id` - (String) ID of the certificate. + * Constraints: The maximum length is `16` characters. The minimum length is `1` character. The value must match regular expression `/^[0-9a-fA-F]*$/`. + * `is_default` - (Boolean) Indicates whether it is the queue manager's default certificate. + * `issued` - (String) Date certificate was issued. + * `issuer_cn` - (String) Issuer's Common Name. + * `issuer_dn` - (String) Issuer's Distinguished Name. + * `label` - (String) Certificate label in queue manager store. + * Constraints: The maximum length is `64` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9_.]*$/`. + * `subject_cn` - (String) Subject's Common Name. + * `subject_dn` - (String) Subject's Distinguished Name. + +* `total_count` - (Integer) The total count of key store certificates. + diff --git a/website/docs/d/mqcloud_queue_manager.html.markdown b/website/docs/d/mqcloud_queue_manager.html.markdown new file mode 100644 index 0000000000..59bfc7c76b --- /dev/null +++ b/website/docs/d/mqcloud_queue_manager.html.markdown @@ -0,0 +1,60 @@ +--- +layout: "ibm" +page_title: "IBM : ibm_mqcloud_queue_manager" +description: |- + Get information about mqcloud_queue_manager +subcategory: "MQ on Cloud" +--- + +# ibm_mqcloud_queue_manager + +Provides a read-only data source to retrieve information about a mqcloud_queue_manager. You can then reference the fields of the data source in other resources within the same configuration by using interpolation syntax. + +## Example Usage + +```hcl +data "ibm_mqcloud_queue_manager" "mqcloud_queue_manager" { + name = ibm_mqcloud_queue_manager.mqcloud_queue_manager_instance.name + service_instance_guid = ibm_mqcloud_queue_manager.mqcloud_queue_manager_instance.service_instance_guid +} +``` + +## Argument Reference + +You can specify the following arguments for this data source. + +* `name` - (Optional, String) A queue manager name conforming to MQ restrictions. + * Constraints: The maximum length is `48` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9._]*$/`. +* `service_instance_guid` - (Required, Forces new resource, String) The GUID that uniquely identifies the MQ on Cloud service instance. + * Constraints: The maximum length is `36` characters. The minimum length is `36` characters. The value must match regular expression `/^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/`. + +## Attribute Reference + +After your data source is created, you can read values from the following attributes. + +* `id` - The unique identifier of the mqcloud_queue_manager. + +* `queue_managers` - (List) List of queue managers. + * Constraints: The maximum length is `50` items. The minimum length is `0` items. +Nested schema for **queue_managers**: + * `administrator_api_endpoint_url` - (String) The url through which to access the Admin REST APIs for this queue manager. + * `available_upgrade_versions_uri` - (String) The uri through which the available versions to upgrade to can be found for this queue manager. + * `connection_info_uri` - (String) The uri through which the CDDT for this queue manager can be obtained. + * `date_created` - (String) RFC3339 formatted UTC date for when the queue manager was created. + * `display_name` - (String) A displayable name for the queue manager - limited only in length. + * Constraints: The maximum length is `150` characters. + * `href` - (String) The URL for this queue manager. + * `id` - (String) The ID of the queue manager which was allocated on creation, and can be used for delete calls. + * `location` - (String) The locations in which the queue manager could be deployed. + * Constraints: The maximum length is `150` characters. The minimum length is `2` characters. The value must match regular expression `/^([^[:ascii:]]|[a-zA-Z0-9-._: ])+$/`. + * `name` - (String) A queue manager name conforming to MQ restrictions. + * Constraints: The maximum length is `48` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9._]*$/`. + * `rest_api_endpoint_url` - (String) The url through which to access REST APIs for this queue manager. + * `size` - (String) The queue manager sizes of deployment available. Deployment of lite queue managers for aws_us_east_1 and aws_eu_west_1 locations is not available. + * Constraints: Allowable values are: `lite`, `xsmall`, `small`, `medium`, `large`. + * `status_uri` - (String) A reference uri to get deployment status of the queue manager. + * `upgrade_available` - (Boolean) Describes whether an upgrade is available for this queue manager. + * `version` - (String) The MQ version of the queue manager. + * Constraints: The maximum length is `15` characters. The minimum length is `7` characters. The value must match regular expression `/^[0-9]+.[0-9]+.[0-9]+_[0-9]+$/`. + * `web_console_url` - (String) The url through which to access the web console for this queue manager. + diff --git a/website/docs/d/mqcloud_queue_manager_status.html.markdown b/website/docs/d/mqcloud_queue_manager_status.html.markdown new file mode 100644 index 0000000000..342ac508c9 --- /dev/null +++ b/website/docs/d/mqcloud_queue_manager_status.html.markdown @@ -0,0 +1,38 @@ +--- +layout: "ibm" +page_title: "IBM : ibm_mqcloud_queue_manager_status" +description: |- + Get information about mqcloud_queue_manager_status +subcategory: "MQ on Cloud" +--- + +# ibm_mqcloud_queue_manager_status + +Provides a read-only data source to retrieve information about mqcloud_queue_manager_status. You can then reference the fields of the data source in other resources within the same configuration by using interpolation syntax. + +## Example Usage + +```hcl +data "ibm_mqcloud_queue_manager_status" "mqcloud_queue_manager_status" { + queue_manager_id = var.queue_manager_id + service_instance_guid = var.service_instance_guid +} +``` + +## Argument Reference + +You can specify the following arguments for this data source. + +* `queue_manager_id` - (Required, Forces new resource, String) The id of the queue manager to retrieve its full details. + * Constraints: The maximum length is `32` characters. The minimum length is `32` characters. The value must match regular expression `/^[0-9a-fA-F]{32}$/`. +* `service_instance_guid` - (Required, Forces new resource, String) The GUID that uniquely identifies the MQ on Cloud service instance. + * Constraints: The maximum length is `36` characters. The minimum length is `36` characters. The value must match regular expression `/^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/`. + +## Attribute Reference + +After your data source is created, you can read values from the following attributes. + +* `id` - The unique identifier of the mqcloud_queue_manager_status. +* `status` - (String) The deploying and failed states are not queue manager states, they are states which can occur when the request to deploy has been fired, or with that request has failed without producing a queue manager to have any state. The other states map to the queue manager states. State "ending" is either quiesing or ending immediately. State "ended" is either ended normally or endedimmediately. The others map one to one with queue manager states. + * Constraints: Allowable values are: `initializing`, `deploying`, `starting`, `running`, `stopping`, `stopped`, `status_not_available`, `deleting`, `failed`, `upgrading_version`, `updating_revision`, `initialization_failed`, `restoring_queue_manager`, `restoring_config`, `restore_failed`, `suspended`, `resumable`. + diff --git a/website/docs/d/mqcloud_truststore_certificate.html.markdown b/website/docs/d/mqcloud_truststore_certificate.html.markdown new file mode 100644 index 0000000000..5fb07ffb1a --- /dev/null +++ b/website/docs/d/mqcloud_truststore_certificate.html.markdown @@ -0,0 +1,60 @@ +--- +layout: "ibm" +page_title: "IBM : ibm_mqcloud_truststore_certificate" +description: |- + Get information about mqcloud_truststore_certificate +subcategory: "MQ on Cloud" +--- + +# ibm_mqcloud_truststore_certificate + +Provides a read-only data source to retrieve information about a mqcloud_truststore_certificate. You can then reference the fields of the data source in other resources within the same configuration by using interpolation syntax. + +## Example Usage + +```hcl +data "ibm_mqcloud_truststore_certificate" "mqcloud_truststore_certificate" { + label = ibm_mqcloud_truststore_certificate.mqcloud_truststore_certificate_instance.label + queue_manager_id = ibm_mqcloud_truststore_certificate.mqcloud_truststore_certificate_instance.queue_manager_id + service_instance_guid = ibm_mqcloud_truststore_certificate.mqcloud_truststore_certificate_instance.service_instance_guid +} +``` + +## Argument Reference + +You can specify the following arguments for this data source. + +* `label` - (Optional, String) Certificate label in queue manager store. + * Constraints: The maximum length is `64` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9_.]*$/`. +* `queue_manager_id` - (Required, Forces new resource, String) The id of the queue manager to retrieve its full details. + * Constraints: The maximum length is `32` characters. The minimum length is `32` characters. The value must match regular expression `/^[0-9a-fA-F]{32}$/`. +* `service_instance_guid` - (Required, Forces new resource, String) The GUID that uniquely identifies the MQ on Cloud service instance. + * Constraints: The maximum length is `36` characters. The minimum length is `36` characters. The value must match regular expression `/^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/`. + +## Attribute Reference + +After your data source is created, you can read values from the following attributes. + +* `id` - The unique identifier of the mqcloud_truststore_certificate. +* `total_count` - (Integer) The total count of trust store certificates. + +* `trust_store` - (List) The list of trust store certificates. + * Constraints: The maximum length is `50` items. The minimum length is `0` items. +Nested schema for **trust_store**: + * `certificate_type` - (String) The type of certificate. + * Constraints: Allowable values are: `trust_store`. + * `expiry` - (String) Expiry date for the certificate. + * `fingerprint_sha256` - (String) Fingerprint SHA256. + * Constraints: The value must match regular expression `/^[A-F0-9]{2}(:[A-F0-9]{2}){31}$/`. + * `href` - (String) The URL for this trust store certificate. + * `id` - (String) Id of the certificate. + * Constraints: The maximum length is `16` characters. The minimum length is `1` character. The value must match regular expression `/^[0-9a-fA-F]*$/`. + * `issued` - (String) The Date the certificate was issued. + * `issuer_cn` - (String) Issuer's Common Name. + * `issuer_dn` - (String) Issuer's Distinguished Name. + * `label` - (String) Certificate label in queue manager store. + * Constraints: The maximum length is `64` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9_.]*$/`. + * `subject_cn` - (String) Subject's Common Name. + * `subject_dn` - (String) Subject's Distinguished Name. + * `trusted` - (Boolean) Indicates whether a certificate is trusted. + diff --git a/website/docs/d/mqcloud_user.html.markdown b/website/docs/d/mqcloud_user.html.markdown new file mode 100644 index 0000000000..89c1aa4db7 --- /dev/null +++ b/website/docs/d/mqcloud_user.html.markdown @@ -0,0 +1,46 @@ +--- +layout: "ibm" +page_title: "IBM : ibm_mqcloud_user" +description: |- + Get information about mqcloud_user +subcategory: "MQ on Cloud" +--- + +# ibm_mqcloud_user + +Provides a read-only data source to retrieve information about a mqcloud_user. You can then reference the fields of the data source in other resources within the same configuration by using interpolation syntax. + +## Example Usage + +```hcl +data "ibm_mqcloud_user" "mqcloud_user" { + name = ibm_mqcloud_user.mqcloud_user_instance.name + service_instance_guid = ibm_mqcloud_user.mqcloud_user_instance.service_instance_guid +} +``` + +## Argument Reference + +You can specify the following arguments for this data source. + +* `name` - (Optional, String) The shortname of the user that will be used as the IBM MQ administrator in interactions with a queue manager for this service instance. + * Constraints: The maximum length is `12` characters. The minimum length is `1` character. The value must match regular expression `/^[a-z][-a-z0-9]*$/`. +* `service_instance_guid` - (Required, Forces new resource, String) The GUID that uniquely identifies the MQ on Cloud service instance. + * Constraints: The maximum length is `36` characters. The minimum length is `36` characters. The value must match regular expression `/^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/`. + +## Attribute Reference + +After your data source is created, you can read values from the following attributes. + +* `id` - The unique identifier of the mqcloud_user. + +* `users` - (List) List of users. + * Constraints: The maximum length is `50` items. The minimum length is `0` items. +Nested schema for **users**: + * `email` - (String) The email of the user. + * Constraints: The maximum length is `253` characters. The minimum length is `5` characters. + * `href` - (String) The URL for the user details. + * `id` - (String) The ID of the user which was allocated on creation, and can be used for delete calls. + * `name` - (String) The shortname of the user that will be used as the IBM MQ administrator in interactions with a queue manager for this service instance. + * Constraints: The maximum length is `12` characters. The minimum length is `1` character. The value must match regular expression `/^[a-z][-a-z0-9]*$/`. + diff --git a/website/docs/guides/custom-service-endpoints.html.md b/website/docs/guides/custom-service-endpoints.html.md index ac2a9ebe5d..b03eedc00b 100644 --- a/website/docs/guides/custom-service-endpoints.html.md +++ b/website/docs/guides/custom-service-endpoints.html.md @@ -14,10 +14,14 @@ The IBM Cloud Provider plug-in for Terraform can be configured to use non-defaul -- [Getting Started with custom service endpoints](#getting-started-with-custom-service-endpoints) -- [Supported endpoint customizations](#supported-endpoint-customizations) -- [File structure for endpoints file](#file-structure-for-endpoints-file) -- [Prioritisation of endpoints](#prioritisation-of-endpoints) +- [Customizing default cloud service endpoints](#customizing-default-cloud-service-endpoints) + - [Getting started with custom service endpoints](#getting-started-with-custom-service-endpoints) + - [Supported endpoint customizations](#supported-endpoint-customizations) + - [File structure for endpoints file](#file-structure-for-endpoints-file) + - [Prioritisation of endpoints](#prioritisation-of-endpoints) + - [1. Define service endpoints by using environment variables](#1-define-service-endpoints-by-using-environment-variables) + - [2. Define service endpoints by using an endpoints file](#2-define-service-endpoints-by-using-an-endpoints-file) + - [3. Use the default private or public service endpoint based on the `visibility` setting in the provider block](#3-use-the-default-private-or-public-service-endpoint-based-on-the-visibility-setting-in-the-provider-block) ## Getting started with custom service endpoints @@ -53,6 +57,7 @@ provider "ibm" { |Container Registry|IBMCLOUD_CR_API_ENDPOINT| |Kubernetes Service|IBMCLOUD_CS_API_ENDPOINT| |Metrics Router| IBMCLOUD_METRICS_ROUTING_API_ENDPOINT| +|MQ on Cloud| IBMCLOUD_MQCLOUD_CONFIG_ENDPOINT| |Direct Link|IBMCLOUD_DL_API_ENDPOINT| |Direct Link Provider|IBMCLOUD_DL_PROVIDER_API_ENDPOINT| |Enterprise Management|IBMCLOUD_ENTERPRISE_API_ENDPOINT| diff --git a/website/docs/r/mqcloud_application.html.markdown b/website/docs/r/mqcloud_application.html.markdown new file mode 100644 index 0000000000..a244325ade --- /dev/null +++ b/website/docs/r/mqcloud_application.html.markdown @@ -0,0 +1,55 @@ +--- +layout: "ibm" +page_title: "IBM : ibm_mqcloud_application" +description: |- + Manages mqcloud_application. +subcategory: "MQ on Cloud" +--- + +# ibm_mqcloud_application + +Create, update, and delete mqcloud_applications with this resource. + +## Example Usage + +```hcl +resource "ibm_mqcloud_application" "mqcloud_application_instance" { + name = "test-app" + service_instance_guid = var.service_instance_guid +} +``` + +## Argument Reference + +You can specify the following arguments for this resource. + +* `name` - (Required, Forces new resource, String) The name of the application - conforming to MQ rules. + * Constraints: The maximum length is `12` characters. The minimum length is `1` character. +* `service_instance_guid` - (Required, Forces new resource, String) The GUID that uniquely identifies the MQ on Cloud service instance. + * Constraints: The maximum length is `36` characters. The minimum length is `36` characters. The value must match regular expression `/^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/`. + +## Attribute Reference + +After your resource is created, you can read values from the listed arguments and the following attributes. + +* `id` - The unique identifier of the mqcloud_application. +* `application_id` - (String) The ID of the application which was allocated on creation, and can be used for delete calls. +* `create_api_key_uri` - (String) The URI to create a new apikey for the application. +* `href` - (String) The URL for this application. + + +## Import + +You can import the `ibm_mqcloud_application` resource by using `id`. +The `id` property can be formed from `service_instance_guid`, and `application_id` in the following format: + +
+<service_instance_guid>/<application_id> ++* `service_instance_guid`: A string in the format `a2b4d4bc-dadb-4637-bcec-9b7d1e723af8`. The GUID that uniquely identifies the MQ on Cloud service instance. +* `application_id`: A string. The ID of the application which was allocated on creation, and can be used for delete calls. + +# Syntax +
+$ terraform import ibm_mqcloud_application.mqcloud_application <service_instance_guid>/<application_id> +diff --git a/website/docs/r/mqcloud_keystore_certificate.html.markdown b/website/docs/r/mqcloud_keystore_certificate.html.markdown new file mode 100644 index 0000000000..e3b1a0108c --- /dev/null +++ b/website/docs/r/mqcloud_keystore_certificate.html.markdown @@ -0,0 +1,73 @@ +--- +layout: "ibm" +page_title: "IBM : ibm_mqcloud_keystore_certificate" +description: |- + Manages mqcloud_keystore_certificate. +subcategory: "MQ on Cloud" +--- + +# ibm_mqcloud_keystore_certificate + +Create, update, and delete mqcloud_keystore_certificates with this resource. + +## Example Usage + +```hcl +resource "ibm_mqcloud_keystore_certificate" "mqcloud_keystore_certificate_instance" { + label = "label" + queue_manager_id = var.queue_manager_id + service_instance_guid = var.service_instance_guid +} +``` + +## Argument Reference + +You can specify the following arguments for this resource. + +* `label` - (Required, Forces new resource, String) Certificate label in queue manager store. + * Constraints: The maximum length is `64` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9_.]*$/`. +* `queue_manager_id` - (Required, Forces new resource, String) The id of the queue manager to retrieve its full details. + * Constraints: The maximum length is `32` characters. The minimum length is `32` characters. The value must match regular expression `/^[0-9a-fA-F]{32}$/`. +* `service_instance_guid` - (Required, Forces new resource, String) The GUID that uniquely identifies the MQ on Cloud service instance. + * Constraints: The maximum length is `36` characters. The minimum length is `36` characters. The value must match regular expression `/^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/`. + +## Attribute Reference + +After your resource is created, you can read values from the listed arguments and the following attributes. + +* `id` - The unique identifier of the mqcloud_keystore_certificate. +* `certificate_id` - (String) ID of the certificate. + * Constraints: The maximum length is `16` characters. The minimum length is `1` character. The value must match regular expression `/^[0-9a-fA-F]*$/`. +* `certificate_type` - (String) The type of certificate. + * Constraints: Allowable values are: `key_store`. +* `dns_names` - (List) The list of DNS names. + * Constraints: The maximum length is `200` items. The minimum length is `0` items. +* `dns_names_total_count` - (Integer) The total count of dns names. +* `expiry` - (String) Expiry date for the certificate. +* `fingerprint_sha256` - (String) Fingerprint SHA256. + * Constraints: The value must match regular expression `/^[A-F0-9]{2}(:[A-F0-9]{2}){31}$/`. +* `href` - (String) The URL for this key store certificate. +* `is_default` - (Boolean) Indicates whether it is the queue manager's default certificate. +* `issued` - (String) Date certificate was issued. +* `issuer_cn` - (String) Issuer's Common Name. +* `issuer_dn` - (String) Issuer's Distinguished Name. +* `subject_cn` - (String) Subject's Common Name. +* `subject_dn` - (String) Subject's Distinguished Name. + + +## Import + +You can import the `ibm_mqcloud_keystore_certificate` resource by using `id`. +The `id` property can be formed from `service_instance_guid`, `queue_manager_id`, and `certificate_id` in the following format: + +
+<service_instance_guid>/<queue_manager_id>/<certificate_id> ++* `service_instance_guid`: A string in the format `a2b4d4bc-dadb-4637-bcec-9b7d1e723af8`. The GUID that uniquely identifies the MQ on Cloud service instance. +* `queue_manager_id`: A string in the format `b8e1aeda078009cf3db74e90d5d42328`. The id of the queue manager to retrieve its full details. +* `certificate_id`: A string. ID of the certificate. + +# Syntax +
+$ terraform import ibm_mqcloud_keystore_certificate.mqcloud_keystore_certificate <service_instance_guid>/<queue_manager_id>/<certificate_id> +diff --git a/website/docs/r/mqcloud_queue_manager.html.markdown b/website/docs/r/mqcloud_queue_manager.html.markdown new file mode 100644 index 0000000000..b26b62631e --- /dev/null +++ b/website/docs/r/mqcloud_queue_manager.html.markdown @@ -0,0 +1,74 @@ +--- +layout: "ibm" +page_title: "IBM : ibm_mqcloud_queue_manager" +description: |- + Manages mqcloud_queue_manager. +subcategory: "MQ on Cloud" +--- + +# ibm_mqcloud_queue_manager + +Create, update, and delete mqcloud_queue_managers with this resource. + +## Example Usage + +```hcl +resource "ibm_mqcloud_queue_manager" "mqcloud_queue_manager_instance" { + display_name = "A test queue manager" + location = "reserved-eu-fr-cluster-f884" + name = "testqm" + service_instance_guid = var.service_instance_guid + size = "lite" + version = "9.3.2_2" +} +``` + +## Argument Reference + +You can specify the following arguments for this resource. + +* `display_name` - (Optional, String) A displayable name for the queue manager - limited only in length. + * Constraints: The maximum length is `150` characters. +* `location` - (Required, String) The locations in which the queue manager could be deployed. + * Constraints: The maximum length is `150` characters. The minimum length is `2` characters. The value must match regular expression `/^([^[:ascii:]]|[a-zA-Z0-9-._: ])+$/`. +* `name` - (Required, String) A queue manager name conforming to MQ restrictions. + * Constraints: The maximum length is `48` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9._]*$/`. +* `service_instance_guid` - (Required, Forces new resource, String) The GUID that uniquely identifies the MQ on Cloud service instance. + * Constraints: The maximum length is `36` characters. The minimum length is `36` characters. The value must match regular expression `/^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/`. +* `size` - (Required, String) The queue manager sizes of deployment available. Deployment of lite queue managers for aws_us_east_1 and aws_eu_west_1 locations is not available. + * Constraints: Allowable values are: `lite`, `xsmall`, `small`, `medium`, `large`. +* `version` - (Optional, String) The MQ version of the queue manager. + * Constraints: The maximum length is `15` characters. The minimum length is `7` characters. The value must match regular expression `/^[0-9]+.[0-9]+.[0-9]+_[0-9]+$/`. + +## Attribute Reference + +After your resource is created, you can read values from the listed arguments and the following attributes. + +* `id` - The unique identifier of the mqcloud_queue_manager. +* `administrator_api_endpoint_url` - (String) The url through which to access the Admin REST APIs for this queue manager. +* `available_upgrade_versions_uri` - (String) The uri through which the available versions to upgrade to can be found for this queue manager. +* `connection_info_uri` - (String) The uri through which the CDDT for this queue manager can be obtained. +* `date_created` - (String) RFC3339 formatted UTC date for when the queue manager was created. +* `href` - (String) The URL for this queue manager. +* `queue_manager_id` - (String) The ID of the queue manager which was allocated on creation, and can be used for delete calls. +* `rest_api_endpoint_url` - (String) The url through which to access REST APIs for this queue manager. +* `status_uri` - (String) A reference uri to get deployment status of the queue manager. +* `upgrade_available` - (Boolean) Describes whether an upgrade is available for this queue manager. +* `web_console_url` - (String) The url through which to access the web console for this queue manager. + + +## Import + +You can import the `ibm_mqcloud_queue_manager` resource by using `id`. +The `id` property can be formed from `service_instance_guid`, and `queue_manager_id` in the following format: + +
+<service_instance_guid>/<queue_manager_id> ++* `service_instance_guid`: A string in the format `a2b4d4bc-dadb-4637-bcec-9b7d1e723af8`. The GUID that uniquely identifies the MQ on Cloud service instance. +* `queue_manager_id`: A string. The ID of the queue manager which was allocated on creation, and can be used for delete calls. + +# Syntax +
+$ terraform import ibm_mqcloud_queue_manager.mqcloud_queue_manager <service_instance_guid>/<queue_manager_id> +diff --git a/website/docs/r/mqcloud_truststore_certificate.html.markdown b/website/docs/r/mqcloud_truststore_certificate.html.markdown new file mode 100644 index 0000000000..ebc00ef103 --- /dev/null +++ b/website/docs/r/mqcloud_truststore_certificate.html.markdown @@ -0,0 +1,70 @@ +--- +layout: "ibm" +page_title: "IBM : ibm_mqcloud_truststore_certificate" +description: |- + Manages mqcloud_truststore_certificate. +subcategory: "MQ on Cloud" +--- + +# ibm_mqcloud_truststore_certificate + +Create, update, and delete mqcloud_truststore_certificates with this resource. + +## Example Usage + +```hcl +resource "ibm_mqcloud_truststore_certificate" "mqcloud_truststore_certificate_instance" { + label = "label" + queue_manager_id = var.queue_manager_id + service_instance_guid = var.service_instance_guid +} +``` + +## Argument Reference + +You can specify the following arguments for this resource. + +* `label` - (Required, Forces new resource, String) Certificate label in queue manager store. + * Constraints: The maximum length is `64` characters. The minimum length is `1` character. The value must match regular expression `/^[a-zA-Z0-9_.]*$/`. +* `queue_manager_id` - (Required, Forces new resource, String) The id of the queue manager to retrieve its full details. + * Constraints: The maximum length is `32` characters. The minimum length is `32` characters. The value must match regular expression `/^[0-9a-fA-F]{32}$/`. +* `service_instance_guid` - (Required, Forces new resource, String) The GUID that uniquely identifies the MQ on Cloud service instance. + * Constraints: The maximum length is `36` characters. The minimum length is `36` characters. The value must match regular expression `/^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/`. + +## Attribute Reference + +After your resource is created, you can read values from the listed arguments and the following attributes. + +* `id` - The unique identifier of the mqcloud_truststore_certificate. +* `certificate_id` - (String) Id of the certificate. + * Constraints: The maximum length is `16` characters. The minimum length is `1` character. The value must match regular expression `/^[0-9a-fA-F]*$/`. +* `certificate_type` - (String) The type of certificate. + * Constraints: Allowable values are: `trust_store`. +* `expiry` - (String) Expiry date for the certificate. +* `fingerprint_sha256` - (String) Fingerprint SHA256. + * Constraints: The value must match regular expression `/^[A-F0-9]{2}(:[A-F0-9]{2}){31}$/`. +* `href` - (String) The URL for this trust store certificate. +* `issued` - (String) The Date the certificate was issued. +* `issuer_cn` - (String) Issuer's Common Name. +* `issuer_dn` - (String) Issuer's Distinguished Name. +* `subject_cn` - (String) Subject's Common Name. +* `subject_dn` - (String) Subject's Distinguished Name. +* `trusted` - (Boolean) Indicates whether a certificate is trusted. + + +## Import + +You can import the `ibm_mqcloud_truststore_certificate` resource by using `id`. +The `id` property can be formed from `service_instance_guid`, `queue_manager_id`, and `certificate_id` in the following format: + +
+<service_instance_guid>/<queue_manager_id>/<certificate_id> ++* `service_instance_guid`: A string in the format `a2b4d4bc-dadb-4637-bcec-9b7d1e723af8`. The GUID that uniquely identifies the MQ on Cloud service instance. +* `queue_manager_id`: A string in the format `b8e1aeda078009cf3db74e90d5d42328`. The id of the queue manager to retrieve its full details. +* `certificate_id`: A string. Id of the certificate. + +# Syntax +
+$ terraform import ibm_mqcloud_truststore_certificate.mqcloud_truststore_certificate <service_instance_guid>/<queue_manager_id>/<certificate_id> +diff --git a/website/docs/r/mqcloud_user.html.markdown b/website/docs/r/mqcloud_user.html.markdown new file mode 100644 index 0000000000..6d12da2ab7 --- /dev/null +++ b/website/docs/r/mqcloud_user.html.markdown @@ -0,0 +1,57 @@ +--- +layout: "ibm" +page_title: "IBM : ibm_mqcloud_user" +description: |- + Manages mqcloud_user. +subcategory: "MQ on Cloud" +--- + +# ibm_mqcloud_user + +Create, update, and delete mqcloud_users with this resource. + +## Example Usage + +```hcl +resource "ibm_mqcloud_user" "mqcloud_user_instance" { + email = "user@example.com" + name = "t0scie98o57a" + service_instance_guid = var.service_instance_guid +} +``` + +## Argument Reference + +You can specify the following arguments for this resource. + +* `email` - (Required, Forces new resource, String) The email of the user. + * Constraints: The maximum length is `253` characters. The minimum length is `5` characters. +* `name` - (Required, Forces new resource, String) The shortname of the user that will be used as the IBM MQ administrator in interactions with a queue manager for this service instance. + * Constraints: The maximum length is `12` characters. The minimum length is `1` character. The value must match regular expression `/^[a-z][-a-z0-9]*$/`. +* `service_instance_guid` - (Required, Forces new resource, String) The GUID that uniquely identifies the MQ on Cloud service instance. + * Constraints: The maximum length is `36` characters. The minimum length is `36` characters. The value must match regular expression `/^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/`. + +## Attribute Reference + +After your resource is created, you can read values from the listed arguments and the following attributes. + +* `id` - The unique identifier of the mqcloud_user. +* `href` - (String) The URL for the user details. +* `user_id` - (String) The ID of the user which was allocated on creation, and can be used for delete calls. + + +## Import + +You can import the `ibm_mqcloud_user` resource by using `id`. +The `id` property can be formed from `service_instance_guid`, and `user_id` in the following format: + +
+<service_instance_guid>/<user_id> ++* `service_instance_guid`: A string in the format `a2b4d4bc-dadb-4637-bcec-9b7d1e723af8`. The GUID that uniquely identifies the MQ on Cloud service instance. +* `user_id`: A string. The ID of the user which was allocated on creation, and can be used for delete calls. + +# Syntax +
+$ terraform import ibm_mqcloud_user.mqcloud_user <service_instance_guid>/<user_id> +