Skip to content

Commit

Permalink
build(deps): bump github.com/aiven/aiven-go-client/v2 from 2.1.0 to 2…
Browse files Browse the repository at this point in the history
….2.0 (#1400)
  • Loading branch information
dependabot[bot] authored and Serpentiel committed Nov 6, 2023
1 parent 1fe5e69 commit a6eaec4
Show file tree
Hide file tree
Showing 9 changed files with 36 additions and 36 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/aiven/terraform-provider-aiven
go 1.21.1

require (
github.com/aiven/aiven-go-client/v2 v2.1.0
github.com/aiven/aiven-go-client/v2 v2.2.0
github.com/avast/retry-go v3.0.0+incompatible
github.com/dave/jennifer v1.7.0
github.com/docker/go-units v0.5.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -201,8 +201,8 @@ github.com/acomagu/bufpipe v1.0.4/go.mod h1:mxdxdup/WdsKVreO5GpW4+M/1CE2sMG4jeGJ
github.com/agext/levenshtein v1.2.1/go.mod h1:JEDfjyjHDjOF/1e4FlBE/PkbqA9OfWu2ki2W0IB5558=
github.com/agext/levenshtein v1.2.3 h1:YB2fHEn0UJagG8T1rrWknE3ZQzWM06O8AMAatNn7lmo=
github.com/agext/levenshtein v1.2.3/go.mod h1:JEDfjyjHDjOF/1e4FlBE/PkbqA9OfWu2ki2W0IB5558=
github.com/aiven/aiven-go-client/v2 v2.1.0 h1:n8k34HpEQ7KgxRcyX/F5WKR6xh8MSAM6TtPHnghDNGg=
github.com/aiven/aiven-go-client/v2 v2.1.0/go.mod h1:x0xhzxWEKAwKv0xY5FvECiI6tesWshcPHvjwl0B/1SU=
github.com/aiven/aiven-go-client/v2 v2.2.0 h1:ZPeIMF3Jt/wPrwFj3mO1Z8KtP9OHc6GpMtZXmwfBsE4=
github.com/aiven/aiven-go-client/v2 v2.2.0/go.mod h1:x0xhzxWEKAwKv0xY5FvECiI6tesWshcPHvjwl0B/1SU=
github.com/aiven/go-api-schemas v1.38.0 h1:l+OOMYRG1tddTFQN4OihE6+sxVdP5fKeRN/9uoKFnkk=
github.com/aiven/go-api-schemas v1.38.0/go.mod h1:/bPxBUHza/2Aeer6hIIdB++GxKiw9K1KCBtRa2rtZ5I=
github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY=
Expand Down
28 changes: 14 additions & 14 deletions internal/sdkprovider/service/opensearch/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,26 +20,26 @@ func resourceOpenSearchACLModifyRemoteConfig(
project string,
serviceName string,
client *aiven.Client,
modifiers ...func(*aiven.ElasticSearchACLConfig),
modifiers ...func(*aiven.OpenSearchACLConfig),
) error {
resourceOpenSearchACLModifierMutex.Lock()
defer resourceOpenSearchACLModifierMutex.Unlock()

r, err := client.ElasticsearchACLs.Get(ctx, project, serviceName)
r, err := client.OpenSearchACLs.Get(ctx, project, serviceName)
if err != nil {
return err
}

config := r.ElasticSearchACLConfig
config := r.OpenSearchACLConfig
for i := range modifiers {
modifiers[i](&config)
}

_, err = client.ElasticsearchACLs.Update(
_, err = client.OpenSearchACLs.Update(
ctx,
project,
serviceName,
aiven.ElasticsearchACLRequest{ElasticSearchACLConfig: config})
aiven.OpenSearchACLRequest{OpenSearchACLConfig: config})
if err != nil {
return err
}
Expand All @@ -48,35 +48,35 @@ func resourceOpenSearchACLModifyRemoteConfig(

// some modifiers

func resourceElasticsearchACLModifierUpdateACLRule(
func resourceOpenSearchACLModifierUpdateACLRule(
ctx context.Context,
username string,
index string,
permission string,
) func(*aiven.ElasticSearchACLConfig) {
return func(cfg *aiven.ElasticSearchACLConfig) {
) func(*aiven.OpenSearchACLConfig) {
return func(cfg *aiven.OpenSearchACLConfig) {
cfg.Add(resourceOpenSearchACLRuleMkAivenACL(username, index, permission))

// delete the old acl if it's there
if prevPerm, ok := resourceElasticsearchACLRuleGetPermissionFromACLResponse(*cfg, username, index); ok && prevPerm != permission {
if prevPerm, ok := resourceOpenSearchACLRuleGetPermissionFromACLResponse(*cfg, username, index); ok && prevPerm != permission {
cfg.Delete(ctx, resourceOpenSearchACLRuleMkAivenACL(username, index, prevPerm))
}
}
}

func resourceElasticsearchACLModifierDeleteACLRule(
func resourceOpenSearchACLModifierDeleteACLRule(
ctx context.Context,
username string,
index string,
permission string,
) func(*aiven.ElasticSearchACLConfig) {
return func(cfg *aiven.ElasticSearchACLConfig) {
) func(*aiven.OpenSearchACLConfig) {
return func(cfg *aiven.OpenSearchACLConfig) {
cfg.Delete(ctx, resourceOpenSearchACLRuleMkAivenACL(username, index, permission))
}
}

func resourceElasticsearchACLModifierToggleConfigFields(enabled, extednedACL bool) func(*aiven.ElasticSearchACLConfig) {
return func(cfg *aiven.ElasticSearchACLConfig) {
func resourceOpenSearchACLModifierToggleConfigFields(enabled, extednedACL bool) func(*aiven.OpenSearchACLConfig) {
return func(cfg *aiven.OpenSearchACLConfig) {
cfg.Enabled = enabled
cfg.ExtendedAcl = extednedACL
}
Expand Down
10 changes: 5 additions & 5 deletions internal/sdkprovider/service/opensearch/opensearch_acl_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func resourceOpenSearchACLConfigRead(ctx context.Context, d *schema.ResourceData
return diag.FromErr(err)
}

r, err := client.ElasticsearchACLs.Get(ctx, project, serviceName)
r, err := client.OpenSearchACLs.Get(ctx, project, serviceName)
if err != nil {
return diag.FromErr(schemautil.ResourceReadHandleNotFound(err, d))
}
Expand All @@ -64,10 +64,10 @@ func resourceOpenSearchACLConfigRead(ctx context.Context, d *schema.ResourceData
if err := d.Set("service_name", serviceName); err != nil {
return diag.Errorf("error setting ACLs `service_name` for resource %s: %s", d.Id(), err)
}
if err := d.Set("extended_acl", r.ElasticSearchACLConfig.ExtendedAcl); err != nil {
if err := d.Set("extended_acl", r.OpenSearchACLConfig.ExtendedAcl); err != nil {
return diag.Errorf("error setting ACLs `extended_acl` for resource %s: %s", d.Id(), err)
}
if err := d.Set("enabled", r.ElasticSearchACLConfig.Enabled); err != nil {
if err := d.Set("enabled", r.OpenSearchACLConfig.Enabled); err != nil {
return diag.Errorf("error setting ACLs `enable` for resource %s: %s", d.Id(), err)
}
return nil
Expand All @@ -79,7 +79,7 @@ func resourceOpenSearchACLConfigUpdate(ctx context.Context, d *schema.ResourceDa
project := d.Get("project").(string)
serviceName := d.Get("service_name").(string)

modifier := resourceElasticsearchACLModifierToggleConfigFields(d.Get("enabled").(bool), d.Get("extended_acl").(bool))
modifier := resourceOpenSearchACLModifierToggleConfigFields(d.Get("enabled").(bool), d.Get("extended_acl").(bool))
err := resourceOpenSearchACLModifyRemoteConfig(ctx, project, serviceName, client, modifier)
if err != nil {
return diag.FromErr(err)
Expand All @@ -96,7 +96,7 @@ func resourceOpenSearchACLConfigDelete(ctx context.Context, d *schema.ResourceDa
project := d.Get("project").(string)
serviceName := d.Get("service_name").(string)

modifier := resourceElasticsearchACLModifierToggleConfigFields(false, false)
modifier := resourceOpenSearchACLModifierToggleConfigFields(false, false)
err := resourceOpenSearchACLModifyRemoteConfig(ctx, project, serviceName, client, modifier)
if err != nil {
return diag.FromErr(err)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func datasourceOpenSearchACLConfigRead(ctx context.Context, d *schema.ResourceDa
projectName := d.Get("project").(string)
serviceName := d.Get("service_name").(string)

acl, err := client.ElasticsearchACLs.Get(ctx, projectName, serviceName)
acl, err := client.OpenSearchACLs.Get(ctx, projectName, serviceName)
if err != nil {
return diag.FromErr(err)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ func testAccCheckAivenOpenSearchACLConfigResourceDestroy(s *terraform.State) err
return err
}

r, err := c.ElasticsearchACLs.Get(ctx, projectName, serviceName)
r, err := c.OpenSearchACLs.Get(ctx, projectName, serviceName)
if err != nil {
if err.(aiven.Error).Status != 404 {
return err
Expand Down
16 changes: 8 additions & 8 deletions internal/sdkprovider/service/opensearch/opensearch_acl_rule.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func ResourceOpenSearchACLRule() *schema.Resource {
}
}

func resourceElasticsearchACLRuleGetPermissionFromACLResponse(cfg aiven.ElasticSearchACLConfig, username, index string) (string, bool) {
func resourceOpenSearchACLRuleGetPermissionFromACLResponse(cfg aiven.OpenSearchACLConfig, username, index string) (string, bool) {
for _, acl := range cfg.ACLs {
if acl.Username != username {
continue
Expand All @@ -75,11 +75,11 @@ func resourceOpenSearchACLRuleRead(ctx context.Context, d *schema.ResourceData,
return diag.FromErr(err)
}

r, err := client.ElasticsearchACLs.Get(ctx, project, serviceName)
r, err := client.OpenSearchACLs.Get(ctx, project, serviceName)
if err != nil {
return diag.FromErr(schemautil.ResourceReadHandleNotFound(err, d))
}
permission, found := resourceElasticsearchACLRuleGetPermissionFromACLResponse(r.ElasticSearchACLConfig, username, index)
permission, found := resourceOpenSearchACLRuleGetPermissionFromACLResponse(r.OpenSearchACLConfig, username, index)
if !found {
return diag.FromErr(schemautil.ResourceReadHandleNotFound(err, d))
}
Expand All @@ -103,10 +103,10 @@ func resourceOpenSearchACLRuleRead(ctx context.Context, d *schema.ResourceData,
return nil
}

func resourceOpenSearchACLRuleMkAivenACL(username, index, permission string) aiven.ElasticSearchACL {
return aiven.ElasticSearchACL{
func resourceOpenSearchACLRuleMkAivenACL(username, index, permission string) aiven.OpenSearchACL {
return aiven.OpenSearchACL{
Username: username,
Rules: []aiven.ElasticsearchACLRule{
Rules: []aiven.OpenSearchACLRule{
{
Index: index,
Permission: permission,
Expand All @@ -124,7 +124,7 @@ func resourceOpenSearchACLRuleUpdate(ctx context.Context, d *schema.ResourceData
index := d.Get("index").(string)
permission := d.Get("permission").(string)

modifier := resourceElasticsearchACLModifierUpdateACLRule(ctx, username, index, permission)
modifier := resourceOpenSearchACLModifierUpdateACLRule(ctx, username, index, permission)
err := resourceOpenSearchACLModifyRemoteConfig(ctx, project, serviceName, client, modifier)
if err != nil {
return diag.FromErr(err)
Expand All @@ -144,7 +144,7 @@ func resourceOpenSearchACLRuleDelete(ctx context.Context, d *schema.ResourceData
index := d.Get("index").(string)
permission := d.Get("permission").(string)

modifier := resourceElasticsearchACLModifierDeleteACLRule(ctx, username, index, permission)
modifier := resourceOpenSearchACLModifierDeleteACLRule(ctx, username, index, permission)
err := resourceOpenSearchACLModifyRemoteConfig(ctx, project, serviceName, client, modifier)
if err != nil {
return diag.FromErr(err)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ func datasourceOpenSearchACLRuleRead(ctx context.Context, d *schema.ResourceData
username := d.Get("username").(string)
index := d.Get("index").(string)

r, err := client.ElasticsearchACLs.Get(ctx, projectName, serviceName)
r, err := client.OpenSearchACLs.Get(ctx, projectName, serviceName)
if err != nil {
return diag.FromErr(err)
}

if _, found := resourceElasticsearchACLRuleGetPermissionFromACLResponse(r.ElasticSearchACLConfig, username, index); !found {
if _, found := resourceOpenSearchACLRuleGetPermissionFromACLResponse(r.OpenSearchACLConfig, username, index); !found {
return diag.Errorf("acl rule %s/%s/%s/%s not found", projectName, serviceName, username, index)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ func testAccCheckAivenOpenSearchACLRuleResourceDestroy(s *terraform.State) error
return err
}

r, err := c.ElasticsearchACLs.Get(ctx, projectName, serviceName)
r, err := c.OpenSearchACLs.Get(ctx, projectName, serviceName)
if err != nil {
if err.(aiven.Error).Status != 404 {
return err
Expand All @@ -101,7 +101,7 @@ func testAccCheckAivenOpenSearchACLRuleResourceDestroy(s *terraform.State) error
return nil
}

for _, acl := range r.ElasticSearchACLConfig.ACLs {
for _, acl := range r.OpenSearchACLConfig.ACLs {
if acl.Username != username {
continue
}
Expand Down

0 comments on commit a6eaec4

Please sign in to comment.