Skip to content

Commit

Permalink
refactor: replace avngen serviceuser (#1860)
Browse files Browse the repository at this point in the history
  • Loading branch information
byashimov authored Oct 7, 2024
1 parent ca15c5b commit aa10470
Show file tree
Hide file tree
Showing 13 changed files with 23 additions and 23 deletions.
2 changes: 1 addition & 1 deletion docs/data-sources/account_team_project.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,4 @@ data "aiven_account_team_project" "account_team_project1" {
### Read-Only

- `id` (String) The ID of this resource.
- `team_type` (String) The Account team project type. The possible values are `admin`, `operator`, `developer`, `read_only` and `project:read_permissions`.
- `team_type` (String) The Account team project type. The possible values are `admin`, `operator`, `developer`, `read_only` and `project:permissions:read`.
2 changes: 1 addition & 1 deletion docs/data-sources/project_user.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,4 @@ data "aiven_project_user" "mytestuser" {

- `accepted` (Boolean) Whether the user has accepted the request to join the project. Users get an invite and become project members after accepting the invite.
- `id` (String) The ID of this resource.
- `member_type` (String) Project membership type. The possible values are `admin`, `developer`, `operator`, `project:read_permissions` and `read_only`.
- `member_type` (String) Project membership type. The possible values are `admin`, `developer`, `operator`, `project:permissions:read` and `read_only`.
2 changes: 1 addition & 1 deletion docs/resources/account_team_project.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ resource "aiven_account_team_project" "main" {
### Optional

- `project_name` (String) The name of an already existing project
- `team_type` (String) The Account team project type. The possible values are `admin`, `operator`, `developer`, `read_only` and `project:read_permissions`.
- `team_type` (String) The Account team project type. The possible values are `admin`, `operator`, `developer`, `read_only` and `project:permissions:read`.
- `timeouts` (Block, Optional) (see [below for nested schema](#nestedblock--timeouts))

### Read-Only
Expand Down
2 changes: 1 addition & 1 deletion docs/resources/organization_group_project.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ resource "aiven_organization_group_project" "example" {

- `group_id` (String) The ID of the user group.
- `project` (String) The project that the users in the group are members of.
- `role` (String) [Project-level role](https://aiven.io/docs/platform/reference/project-member-privileges) assigned to all users in the group. The possible values are `admin`, `operator`, `developer`, `read_only` and `project:read_permissions`.
- `role` (String) [Project-level role](https://aiven.io/docs/platform/reference/project-member-privileges) assigned to all users in the group. The possible values are `admin`, `operator`, `developer`, `read_only` and `project:permissions:read`.

### Optional

Expand Down
2 changes: 1 addition & 1 deletion docs/resources/organization_permission.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ resource "aiven_organization_permission" "developers" {

Required:

- `permissions` (Set of String) List of permissions. The possible values are `admin`, `developer`, `operator`, `project:read_permissions` and `read_only`.
- `permissions` (Set of String) List of permissions. The possible values are `admin`, `developer`, `operator`, `project:permissions:read` and `read_only`.
- `principal_id` (String) ID of the user or group.
- `principal_type` (String) The type of principal. The possible values are `user` and `user_group`.

Expand Down
2 changes: 1 addition & 1 deletion docs/resources/project_user.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ resource "aiven_project_user" "mytestuser" {
### Required

- `email` (String) Email address of the user in lowercase. Changing this property forces recreation of the resource.
- `member_type` (String) Project membership type. The possible values are `admin`, `developer`, `operator`, `project:read_permissions` and `read_only`.
- `member_type` (String) Project membership type. The possible values are `admin`, `developer`, `operator`, `project:permissions:read` and `read_only`.
- `project` (String) The name of the project this resource belongs to. To set up proper dependencies please refer to this variable as a reference. Changing this property forces recreation of the resource.

### Optional
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ go 1.23

require (
github.com/aiven/aiven-go-client/v2 v2.27.0
github.com/aiven/go-client-codegen v0.34.0
github.com/aiven/go-client-codegen v0.38.0
github.com/avast/retry-go v3.0.0+incompatible
github.com/dave/jennifer v1.7.1
github.com/docker/go-units v0.5.0
Expand All @@ -16,6 +16,7 @@ require (
github.com/hashicorp/terraform-plugin-mux v0.16.0
github.com/hashicorp/terraform-plugin-sdk/v2 v2.34.0
github.com/kelseyhightower/envconfig v1.4.0
github.com/rs/zerolog v1.33.0
github.com/samber/lo v1.47.0
github.com/stoewer/go-strcase v1.3.0
github.com/stretchr/testify v1.9.0
Expand All @@ -37,7 +38,6 @@ require (
github.com/google/uuid v1.6.0 // indirect
github.com/googleapis/enterprise-certificate-proxy v0.3.2 // indirect
github.com/hashicorp/go-retryablehttp v0.7.7 // indirect
github.com/rs/zerolog v1.33.0 // indirect
github.com/vmihailenco/msgpack/v5 v5.4.1 // indirect
github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.47.0 // indirect
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -199,8 +199,8 @@ github.com/aiven/aiven-go-client/v2 v2.27.0 h1:iTr85xDpD8td3Okj2+djUOfGLlVvngvUw
github.com/aiven/aiven-go-client/v2 v2.27.0/go.mod h1:KdHfLIlIRZIfCSEBd39j1Q81jlSb6Nd+oCQKqERfnuA=
github.com/aiven/go-api-schemas v1.89.0 h1:YR2BMPMrp/UHhnP1qs4v0SHWn/Ebz+OTOpX+hD5UWN0=
github.com/aiven/go-api-schemas v1.89.0/go.mod h1:V8xqp59BeC2ptwKjh6MnxkzKVRxCWJRo3t6GvqgmURQ=
github.com/aiven/go-client-codegen v0.34.0 h1:59/8HkawCP1bBvBAhEA0rLdG7EqTrfdlS2dxZM0XpP8=
github.com/aiven/go-client-codegen v0.34.0/go.mod h1:FfbH32Xb+Hx5zeKTIug1Y8SfMeB+AKNRzxgrzkts2oA=
github.com/aiven/go-client-codegen v0.38.0 h1:WnH9CEtVbolqqKr9PlIZZE9pG4lWkNK+H6iyHO/b010=
github.com/aiven/go-client-codegen v0.38.0/go.mod h1:FfbH32Xb+Hx5zeKTIug1Y8SfMeB+AKNRzxgrzkts2oA=
github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY=
github.com/apparentlymart/go-dump v0.0.0-20180507223929-23540a00eaa3/go.mod h1:oL81AME2rN47vu18xqj1S1jPIPuN7afo62yKTNn3XMM=
github.com/apparentlymart/go-textseg v1.0.0/go.mod h1:z96Txxhf3xSFMPmb5X/1W05FF/Nj9VFpLOpjS5yuumk=
Expand Down
4 changes: 2 additions & 2 deletions internal/schemautil/schemautil.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"strings"

"github.com/aiven/aiven-go-client/v2"
"github.com/aiven/go-client-codegen/handler/serviceuser"
"github.com/aiven/go-client-codegen/handler/service"
"github.com/docker/go-units"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
)
Expand Down Expand Up @@ -311,7 +311,7 @@ func CopyServiceUserPropertiesFromAPIResponseToTerraform(

func CopyServiceUserGenPropertiesFromAPIResponseToTerraform(
d *schema.ResourceData,
user *serviceuser.ServiceUserGetOut,
user *service.ServiceUserGetOut,
projectName string,
serviceName string,
) error {
Expand Down
4 changes: 2 additions & 2 deletions internal/sdkprovider/service/mysql/mysql_user.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"context"

"github.com/aiven/aiven-go-client/v2"
"github.com/aiven/go-client-codegen/handler/serviceuser"
"github.com/aiven/go-client-codegen/handler/service"
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
Expand Down Expand Up @@ -37,7 +37,7 @@ var aivenMySQLUserSchema = map[string]*schema.Schema{
Optional: true,
DiffSuppressFunc: schemautil.EmptyObjectDiffSuppressFunc,
ValidateFunc: validation.StringInSlice([]string{"caching_sha2_password", "mysql_native_password"}, false),
Description: userconfig.Desc("Authentication details.").PossibleValuesString(serviceuser.AuthenticationTypeChoices()...).Build(),
Description: userconfig.Desc("Authentication details.").PossibleValuesString(service.AuthenticationTypeChoices()...).Build(),
},

// computed fields
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ func resourceServiceIntegrationCheckForPreexistingResource(ctx context.Context,
continue
}

if integration.IntegrationType == integrationType &&
if string(integration.IntegrationType) == integrationType &&
integration.SourceService == sourceServiceName &&
*integration.DestService == destinationServiceName {
return &integration, nil
Expand Down Expand Up @@ -336,5 +336,5 @@ func resourceServiceIntegrationCopyAPIResponseToTerraform(
return err
}

return converters.Flatten(converters.ServiceIntegrationUserConfig, integrationType, d, res.UserConfig)
return converters.Flatten(converters.ServiceIntegrationUserConfig, string(integrationType), d, res.UserConfig)
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func datasourceServiceIntegrationRead(ctx context.Context, d *schema.ResourceDat
continue
}

if i.IntegrationType == integrationType &&
if string(i.IntegrationType) == integrationType &&
i.SourceService == sourceServiceName &&
*i.DestService == destinationServiceName {

Expand Down
12 changes: 6 additions & 6 deletions internal/sdkprovider/service/valkey/valkey_user.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"context"

avngen "github.com/aiven/go-client-codegen"
"github.com/aiven/go-client-codegen/handler/serviceuser"
"github.com/aiven/go-client-codegen/handler/service"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"

"github.com/aiven/terraform-provider-aiven/internal/common"
Expand Down Expand Up @@ -103,9 +103,9 @@ func resourceValkeyUserCreate(ctx context.Context, d *schema.ResourceData, clien
commands := schemautil.FlattenToString(d.Get("valkey_acl_commands").([]interface{}))
keys := schemautil.FlattenToString(d.Get("valkey_acl_keys").([]interface{}))
channels := schemautil.FlattenToString(d.Get("valkey_acl_channels").([]interface{}))
var req = serviceuser.ServiceUserCreateIn{
var req = service.ServiceUserCreateIn{
Username: username,
AccessControl: &serviceuser.AccessControlIn{
AccessControl: &service.AccessControlIn{
ValkeyAclCategories: &categories,
ValkeyAclCommands: &commands,
ValkeyAclKeys: &keys,
Expand All @@ -124,8 +124,8 @@ func resourceValkeyUserCreate(ctx context.Context, d *schema.ResourceData, clien
}

if _, ok := d.GetOk("password"); ok {
var req = serviceuser.ServiceUserCredentialsModifyIn{NewPassword: schemautil.OptionalStringPointer(d, "password"),
Operation: serviceuser.OperationTypeResetCredentials}
var req = service.ServiceUserCredentialsModifyIn{NewPassword: schemautil.OptionalStringPointer(d, "password"),
Operation: service.OperationTypeResetCredentials}
_, err := client.ServiceUserCredentialsModify(ctx, projectName, serviceName, username, &req)
if err != nil {
return err
Expand All @@ -143,7 +143,7 @@ func resourceValkeyUserUpdate(ctx context.Context, d *schema.ResourceData, clien
return err
}

_, err = client.ServiceUserCredentialsModify(ctx, projectName, serviceName, username, &serviceuser.ServiceUserCredentialsModifyIn{
_, err = client.ServiceUserCredentialsModify(ctx, projectName, serviceName, username, &service.ServiceUserCredentialsModifyIn{
NewPassword: schemautil.OptionalStringPointer(d, "password"),
})
if err != nil {
Expand Down

0 comments on commit aa10470

Please sign in to comment.