Skip to content

Commit

Permalink
feat(lb): Migrate loadbalancer sdk to framework (#430)
Browse files Browse the repository at this point in the history
* feat: migrate loadbalancer sdk to framework

* chore: add error message

* chore: lb 리소스 이름 지정

* fix: idleTimeoutValue null값 개선

* fix: 코드 중복 개선

* fix: delete시 누락된 active 코드 수정

* fix: 코드 리뷰 반영 및 각종 오류 개선

* feat: 기존 리소스와의 호환을 위한 ID값 추가

* feat: types.ListValueFrom 에러처리 추가

* feat: 호환성을 위한 timeout 설정 추가

* refactor: change msg datasource to resource

* fix: change valid length (#434)

* fix(autoscaling): Autoscaling test failure (#436)

* fix: autoscalig acctest

* chore: Upgrade Go version to v1.21

chore: Upgrade Go version to v1.21

chore: upgrade Go to v1.21

ci: Set go version 1.21 in GitHub Actions

ci: Upgrade actions version (checkout, setup-go, ci-lint)

ci: Upgrade golangci-lint v1.59

* feat: Add Object Storage service (#439)

* chore: Upgrade Go version to v1.21

chore: Upgrade Go version to v1.21

chore: upgrade Go to v1.21

ci: Set go version 1.21 in GitHub Actions

ci: Upgrade actions version (checkout, setup-go, ci-lint)

ci: Upgrade golangci-lint v1.59

* chore: Install AWS SDK for Object Storage API

* feat: Add S3 Client configuration

* feat: Add Object Storage Resources

* feat: Add objectstorage_bucket resource

* feat: Add objectstorage_bucket_acl resource

* feat: Add objectstorage_object resource

* feat: Add objectstorage_object_acl resource

* fix: add "_bucket" suffix to bucket resource

* feat: Add examples of object storage

* docs: Add initial documentation of object storage

* feat: add type casting function for nested listValue

* feat: Add BucketRegion to bucket chema

* fix: Add detailed schema of grants & type casting method

* chore: Add error exception

* feat: Add regex validator for resource id

* chore: remove redundant EOL

* fix: Remove BucketName, BucketRegion from schema(doesn't provided)

* refactor: Add TrimForIDParsing util

* feat: Add temporary file creation logic

* feat: Add aclOptions for testing

* fix: Removed Unavailable object acl

* feat: Add Bucket data source

* fix: Add new bucket creation for independant testing

* fix: aws.String => ncloud.String

* chore: fix typo

* chore: change string value with constants

* refactor: expand TrimForParsing to parse vairous strings (not only ID)

* feat: use region info from initial configuration

* refactor: Set bucket id same as bucket name

* fix: Add detailed string validator with regex for bucket_name

* feat: Add NewObjectDataSource data source

* refactor: Move ObjectIDParser to object.go

* refactor: Set Object Resource ID with new format

* feat: set independent object testing

* feat: Add Owner info & Creation Date to bucket data source

* feat: Add OwnerID & OwnerDisplayname at object_acl attribute

* fix: set bucket_id & object_id w/o NRN

* docs: Add documentation of object storage resources

* feat: Change format - make resource id with '/' in object storage - object

* feat: Add objectstorage_object_copy

* fix: Change to do not use pointer method

* docs: Add data source documentation of bucket

* docs: Add object_storage_object.md in data-source

* docs: Add object_storage_object_copy.md

* feat: Add CreationDate attribute to bucket

* fix: fix logic to check whether output is nil

* fix: Add format of creationDate

* feat: Delete panic from object_copy Update

* feat: Remove endpoint from Config struct

* fix: Remove Optional keyword from creation_date(computed)

* refactor: set bucket unique value from bucket_id to bucket_name

* fix: Remove unused headbucket

* feat: Add bucket ID (since it uses id for default)

* feat: Add attributes based on HeadObjectOutput

* feat: Add endpoint abstract logic

* refactor: Move post fetch logic into refreshFromOutput

* feat: Add genEndpointWithCode (region, site)

* feat: Add optional endpoint configuration

* feat: Add region formatting logic

* feat: Add Optional variables compatible with aws sdk in object-kind resource

* docs: Update docs with additional attributes

* fix: Remove Object Encryption logic entirely

* feat: Add site variable in example tf code

* chore: Add Error with Diagnostics

* refactor: remove endpoint from providerConfig

* chore: add missed packages

* fix: fix endpoint env to optional

* fix: Parse bucket info after pulling plan data

* refactor: Abstract BucketNameValidator

* fix: Remove optional from creation_date

* fix: Change serverless environment => platform independent

* fix: change id with object_url

* feat: Add attribute documentation

* feat: Add update logic to object_acl

* feat: Add update logic to bucket_acl

* fix: Fix typo

Revert "fix: Fix typo"

This reverts commit 37c7737.

fix: Fix typo

* [Feat] Add Login Key Data Source (#442)

* feat: add login key data source

* docs: add login key docs

* docs: Fix typo (#438)

* docs(redis): Correct indentation in main.if

* docs(server): Correct indentation in server_products.md

* docs(mysql): Fix typo in mysql_products.md

* docs(mssql): Fix typo in mssql_products.md

* feat: Add documentation about object storage endpoint (#443)

* feat: Add util functions for endpoint formatting

feat: Add documentation about object storage endpoint

feat: Add mapRegionWithEnv util func

docs: Add env configuration guide

feat: remove endpoint from docs

feat: Modify endpoint extracting func

* docs: Add extra comment for optional env

* feat: migrate loadbalancer sdk to framework

* git rebase

* fix: go mod tidy 수정

* feat: lb attribute 추가

* fix: go mod 버전 conflict 수정

* fix: 사용되지 않는 모듈 삭제

* fix(lb): Fix migration Errors

* fix: Add idleTimeout validator

* fix(lb): Handle error properly

* fix: Generalize confictsWithValue validators

* fix: Generalize conflictsWithValue validator again

---------

Co-authored-by: Wonchul Lee <wch.lee@navercorp.com>
  • Loading branch information
inpyu and wonchulee authored Sep 22, 2024
1 parent 02b65c8 commit c973fc2
Show file tree
Hide file tree
Showing 8 changed files with 775 additions and 211 deletions.
3 changes: 2 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ require (
github.com/aws/aws-sdk-go-v2/service/s3 v1.58.3
github.com/hashicorp/go-multierror v1.1.1
github.com/hashicorp/terraform-plugin-framework v1.11.0
github.com/hashicorp/terraform-plugin-framework-timeouts v0.4.1
github.com/hashicorp/terraform-plugin-go v0.23.0
github.com/hashicorp/terraform-plugin-log v0.9.0
github.com/hashicorp/terraform-plugin-mux v0.16.0
Expand Down Expand Up @@ -59,7 +60,7 @@ require (
github.com/hashicorp/logutils v1.0.0 // indirect
github.com/hashicorp/terraform-exec v0.21.0 // indirect
github.com/hashicorp/terraform-json v0.22.1 // indirect
github.com/hashicorp/terraform-plugin-framework-validators v0.10.0
github.com/hashicorp/terraform-plugin-framework-validators v0.13.0
github.com/hashicorp/terraform-registry-address v0.2.3 // indirect
github.com/hashicorp/terraform-svchost v0.1.1 // indirect
github.com/hashicorp/yamux v0.1.1 // indirect
Expand Down
6 changes: 4 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,10 @@ github.com/hashicorp/terraform-json v0.22.1 h1:xft84GZR0QzjPVWs4lRUwvTcPnegqlyS7
github.com/hashicorp/terraform-json v0.22.1/go.mod h1:JbWSQCLFSXFFhg42T7l9iJwdGXBYV8fmmD6o/ML4p3A=
github.com/hashicorp/terraform-plugin-framework v1.11.0 h1:M7+9zBArexHFXDx/pKTxjE6n/2UCXY6b8FIq9ZYhwfE=
github.com/hashicorp/terraform-plugin-framework v1.11.0/go.mod h1:qBXLDn69kM97NNVi/MQ9qgd1uWWsVftGSnygYG1tImM=
github.com/hashicorp/terraform-plugin-framework-validators v0.10.0 h1:4L0tmy/8esP6OcvocVymw52lY0HyQ5OxB7VNl7k4bS0=
github.com/hashicorp/terraform-plugin-framework-validators v0.10.0/go.mod h1:qdQJCdimB9JeX2YwOpItEu+IrfoJjWQ5PhLpAOMDQAE=
github.com/hashicorp/terraform-plugin-framework-timeouts v0.4.1 h1:gm5b1kHgFFhaKFhm4h2TgvMUlNzFAtUqlcOWnWPm+9E=
github.com/hashicorp/terraform-plugin-framework-timeouts v0.4.1/go.mod h1:MsjL1sQ9L7wGwzJ5RjcI6FzEMdyoBnw+XK8ZnOvQOLY=
github.com/hashicorp/terraform-plugin-framework-validators v0.13.0 h1:bxZfGo9DIUoLLtHMElsu+zwqI4IsMZQBRRy4iLzZJ8E=
github.com/hashicorp/terraform-plugin-framework-validators v0.13.0/go.mod h1:wGeI02gEhj9nPANU62F2jCaHjXulejm/X+af4PdZaNo=
github.com/hashicorp/terraform-plugin-go v0.23.0 h1:AALVuU1gD1kPb48aPQUjug9Ir/125t+AAurhqphJ2Co=
github.com/hashicorp/terraform-plugin-go v0.23.0/go.mod h1:1E3Cr9h2vMlahWMbsSEcNrOCxovCZhOOIXjFHbjc/lQ=
github.com/hashicorp/terraform-plugin-log v0.9.0 h1:i7hOA+vdAItN1/7UrfBqBwvYPQ9TFvymaRGZED3FCV0=
Expand Down
20 changes: 20 additions & 0 deletions internal/common/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,30 @@ package common
import (
"log"

datasourceschema "github.com/hashicorp/terraform-plugin-framework/datasource/schema"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/terraform-providers/terraform-provider-ncloud/internal/conn"
)

func CopyResourceSchemaToDataSourceSchema(resourceSchema datasourceschema.Schema, extraFields map[string]datasourceschema.Attribute) datasourceschema.Schema {
dataSourceAttributes := map[string]datasourceschema.Attribute{}

for name, attr := range resourceSchema.Attributes {
if name == "id" {
continue
}
dataSourceAttributes[name] = attr
}

for name, attr := range extraFields {
dataSourceAttributes[name] = attr
}

return datasourceschema.Schema{
Attributes: dataSourceAttributes,
}
}

// Get the schema for a nested DataSourceSchema generated from the ResourceSchema
func GetDataSourceItemSchema(resourceSchema *schema.Resource) *schema.Resource {
if _, idExists := resourceSchema.Schema["id"]; !idExists {
Expand Down
3 changes: 3 additions & 0 deletions internal/provider/fwprovider/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"

"github.com/terraform-providers/terraform-provider-ncloud/internal/service/hadoop"
"github.com/terraform-providers/terraform-provider-ncloud/internal/service/loadbalancer"
"github.com/terraform-providers/terraform-provider-ncloud/internal/service/objectstorage"

multierror "github.com/hashicorp/go-multierror"
Expand Down Expand Up @@ -99,6 +100,7 @@ func (p *fwprovider) DataSources(ctx context.Context) []func() datasource.DataSo
dataSources = append(dataSources, mssql.NewMssqlDataSource)
dataSources = append(dataSources, mssql.NewMssqlImageProductsDataSource)
dataSources = append(dataSources, mssql.NewMssqlProductsDataSource)
dataSources = append(dataSources, loadbalancer.NewLoadBalancerDataSource)
dataSources = append(dataSources, objectstorage.NewBucketDataSource)
dataSources = append(dataSources, objectstorage.NewObjectDataSource)

Expand Down Expand Up @@ -127,6 +129,7 @@ func (p *fwprovider) Resources(ctx context.Context) []func() resource.Resource {
resources = append(resources, redis.NewRedisConfigGroupResource)
resources = append(resources, redis.NewRedisResource)
resources = append(resources, mssql.NewMssqlResource)
resources = append(resources, loadbalancer.NewLbResource)
resources = append(resources, objectstorage.NewBucketResource)
resources = append(resources, objectstorage.NewObjectResource)
resources = append(resources, objectstorage.NewObjectACLResource)
Expand Down
2 changes: 0 additions & 2 deletions internal/provider/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ func New(ctx context.Context) *schema.Provider {
"ncloud_cdss_os_image": cdss.DataSourceNcloudCDSSOsImage(),
"ncloud_cdss_os_images": cdss.DataSourceNcloudCDSSOsImages(),
"ncloud_launch_configuration": autoscaling.DataSourceNcloudLaunchConfiguration(),
"ncloud_lb": loadbalancer.DataSourceNcloudLb(),
"ncloud_lb_listener": loadbalancer.DataSourceNcloudLbListener(),
"ncloud_lb_target_group": loadbalancer.DataSourceNcloudLbTargetGroup(),
"ncloud_member_server_image": server.DataSourceNcloudMemberServerImage(),
Expand Down Expand Up @@ -116,7 +115,6 @@ func New(ctx context.Context) *schema.Provider {
"ncloud_lb_listener": loadbalancer.ResourceNcloudLbListener(),
"ncloud_lb_target_group_attachment": loadbalancer.ResourceNcloudLbTargetGroupAttachment(),
"ncloud_lb_target_group": loadbalancer.ResourceNcloudLbTargetGroup(),
"ncloud_lb": loadbalancer.ResourceNcloudLb(),
"ncloud_load_balancer_ssl_certificate": classicloadbalancer.ResourceNcloudLoadBalancerSSLCertificate(),
"ncloud_load_balancer": classicloadbalancer.ResourceNcloudLoadBalancer(),
"ncloud_nas_volume": nasvolume.ResourceNcloudNasVolume(),
Expand Down
Loading

0 comments on commit c973fc2

Please sign in to comment.