Skip to content

Commit 17fbe59

Browse files
authored
Add service connector validate flag (#19)
* Add service connector validate flag * Fix the docs
1 parent c9a53db commit 17fbe59

File tree

2 files changed

+25
-13
lines changed

2 files changed

+25
-13
lines changed

docs/resources/service_connector.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ resource "zenml_service_connector" "gcp_connector" {
3535
environment = "production"
3636
team = "ml-ops"
3737
}
38+
39+
verify = true
3840
}
3941
```
4042

@@ -50,6 +52,7 @@ resource "zenml_service_connector" "gcp_connector" {
5052
* `resource_type` - (Optional) A resource type this connector can be used for (e.g., `s3-bucket`, `kubernetes-cluster`, `docker-registry`). To find out which resource types are supported by a connector, run `zenml service-connector describe-type <connector-type>`.
5153
* `configuration` - (Required, Sensitive) A map of configuration key-value pairs for the connector. Every authentication method has its own set of required and optional configuration parameters. To find out which parameters are required and optional for a given authentication method, run `zenml service-connector describe-type <connector-type> -a <auth-method>` or visit the [Service Connector ZenML documentation page](https://docs.zenml.io/how-to/infrastructure-deployment/auth-management) for the connector type and authentication method for more information.
5254
* `labels` - (Optional) A map of labels to associate with the connector.
55+
* `verify` - (Optional) Whether to verify the connector configuration and credentials before creating or updating the connector. Defaults to `true`.
5356

5457
## Attributes Reference
5558

@@ -61,6 +64,6 @@ In addition to all arguments above, the following attributes are exported:
6164

6265
Service connectors can be imported using the `id`, e.g.
6366

64-
```
67+
```shell
6568
$ terraform import zenml_service_connector.example 12345678-1234-1234-1234-123456789012
6669
```

internal/provider/resource_service_connector.go

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,11 @@ func resourceServiceConnector() *schema.Resource {
6666
Type: schema.TypeString,
6767
},
6868
},
69+
"verify": {
70+
Type: schema.TypeBool,
71+
Optional: true,
72+
Default: true,
73+
},
6974
},
7075

7176
CustomizeDiff: func(ctx context.Context, d *schema.ResourceDiff, m interface{}) error {
@@ -143,13 +148,15 @@ func resourceServiceConnectorCreate(ctx context.Context, d *schema.ResourceData,
143148
}
144149

145150
err = retry.RetryContext(ctx, d.Timeout(schema.TimeoutCreate)-time.Minute, func() *retry.RetryError {
146-
verify, err := client.VerifyServiceConnector(ctx, *connector)
147-
if err != nil {
148-
return retry.NonRetryableError(fmt.Errorf("Error verifying service connector: %s", err))
149-
}
151+
if d.Get("verify").(bool) {
152+
verify, err := client.VerifyServiceConnector(ctx, *connector)
153+
if err != nil {
154+
return retry.NonRetryableError(fmt.Errorf("Error verifying service connector: %s", err))
155+
}
150156

151-
if verify.Error != nil {
152-
return retry.RetryableError(fmt.Errorf("error verifying service connector: %s", *verify.Error))
157+
if verify.Error != nil {
158+
return retry.RetryableError(fmt.Errorf("error verifying service connector: %s", *verify.Error))
159+
}
153160
}
154161

155162
resp, err := client.CreateServiceConnector(ctx, *connector)
@@ -236,13 +243,15 @@ func resourceServiceConnectorUpdate(ctx context.Context, d *schema.ResourceData,
236243
}
237244

238245
err = retry.RetryContext(ctx, d.Timeout(schema.TimeoutCreate)-time.Minute, func() *retry.RetryError {
239-
resources, err := client.VerifyServiceConnector(ctx, *connector)
240-
if err != nil {
241-
return retry.NonRetryableError(fmt.Errorf("Error verifying service connector: %s", err))
242-
}
246+
if d.Get("verify").(bool) {
247+
resources, err := client.VerifyServiceConnector(ctx, *connector)
248+
if err != nil {
249+
return retry.NonRetryableError(fmt.Errorf("Error verifying service connector: %s", err))
250+
}
243251

244-
if resources.Error != nil {
245-
return retry.RetryableError(fmt.Errorf("error verifying service connector: %s", *resources.Error))
252+
if resources.Error != nil {
253+
return retry.RetryableError(fmt.Errorf("error verifying service connector: %s", *resources.Error))
254+
}
246255
}
247256

248257
update := ServiceConnectorUpdate{}

0 commit comments

Comments
 (0)