Skip to content

Commit

Permalink
expose sdk bundle client function for injecting the client in crosspl…
Browse files Browse the repository at this point in the history
…ane (#666)

* expose sdk bundle client function for injecting the client in crossplane

* update policy documentation
  • Loading branch information
digna-ionos authored Sep 10, 2024
1 parent 828bac6 commit d85d312
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
6 changes: 5 additions & 1 deletion docs/resources/s3_bucket_policy.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,12 @@ Manages **S3 Buckets policies** on IonosCloud.

```hcl
resource "ionoscloud_s3_bucket" "example" {
name = "example"
}
resource "ionoscloud_s3_bucket_policy" "example" {
bucket = "your_bucket_name_here"
bucket = ionoscloud_s3_bucket.example.name
policy = jsonencode({
Version = "2012-10-17"
Statement = [
Expand Down
10 changes: 8 additions & 2 deletions ionoscloud/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -293,9 +293,14 @@ func providerConfigure(d *schema.ResourceData, terraformVersion string) (interfa
clientOpts.Password = password.(string)
clientOpts.Token = token.(string)
clientOpts.Url = cleanedUrl
clientOpts.Version = ionoscloud.Version
clientOpts.TerraformVersion = terraformVersion

return NewSDKBundleClient(clientOpts), nil
}

// NewSDKBundleClient returns a new SDK bundle client
func NewSDKBundleClient(clientOpts ClientOptions) interface{} {
clientOpts.Version = ionoscloud.Version
return services.SdkBundle{
CDNClient: NewClientByType(clientOpts, cdnClient).(*cdnService.Client),
AutoscalingClient: NewClientByType(clientOpts, autoscalingClient).(*autoscalingService.Client),
Expand All @@ -313,7 +318,7 @@ func providerConfigure(d *schema.ResourceData, terraformVersion string) (interfa
APIGatewayClient: NewClientByType(clientOpts, apiGatewayClient).(*apiGatewayService.Client),
VPNClient: NewClientByType(clientOpts, vpnClient).(*vpn.Client),
InMemoryDBClient: NewClientByType(clientOpts, inMemoryDBClient).(*inmemorydb.InMemoryDBClient),
}, nil
}
}

type clientType int
Expand All @@ -338,6 +343,7 @@ const (
inMemoryDBClient
)

// NewClientByType returns a new client based on the client type
func NewClientByType(clientOpts ClientOptions, clientType clientType) interface{} {
switch clientType {
case ionosClient:
Expand Down

0 comments on commit d85d312

Please sign in to comment.