Skip to content

Commit

Permalink
doc: add depreciation message
Browse files Browse the repository at this point in the history
  • Loading branch information
azrod committed Dec 9, 2024
1 parent fba8e88 commit e229052
Show file tree
Hide file tree
Showing 12 changed files with 253 additions and 10 deletions.
11 changes: 11 additions & 0 deletions .changelog/861.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
```release-note:deprecation
`resource/cloudavenue_vdc_group` - The `cloudavenue_vdc_group` resource is deprecated and will be removed in the release v0.30.0. Please use the `cloudavenue_vdcg` resource instead.
```

```release-note:deprecation
`datasource/cloudavenue_vdc_group` - The `cloudavenue_vdc_group` datasource is deprecated and will be removed in the release v0.30.0. Please use the `cloudavenue_vdcg` datasource instead.
```

```release-note:note
`resource/cloudavenue_vdc_group` - Add a migration guide to migrate from `cloudavenue_vdc_group` to `cloudavenue_vdcg`.
```
5 changes: 4 additions & 1 deletion docs/data-sources/vdc_group.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,14 @@ page_title: "cloudavenue_vdc_group Data Source - cloudavenue"
subcategory: "vDC (Virtual Datacenter)"
description: |-
The cloudavenue_vdc_group data source allows you to retrieve informations about an existing VDC Group.
!> Resource deprecated The resource has renamed to cloudavenue_vdcg https://registry.terraform.io/providers/orange-cloudavenue/cloudavenue/latest/docs/data-sources/vdcg, it will be removed in the version v0.30.0 of the provider.
---

# cloudavenue_vdc_group (Data Source)

The `cloudavenue_vdc_group` data source allows you to retrieve informations about an existing VDC Group.
The `cloudavenue_vdc_group` data source allows you to retrieve informations about an existing VDC Group.

!> **Resource deprecated** The resource has renamed to [`cloudavenue_vdcg`](https://registry.terraform.io/providers/orange-cloudavenue/cloudavenue/latest/docs/data-sources/vdcg), it will be removed in the version `v0.30.0` of the provider.

## Example Usage

Expand Down
55 changes: 53 additions & 2 deletions docs/resources/vdc_group.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,63 @@ page_title: "cloudavenue_vdc_group Resource - cloudavenue"
subcategory: "vDC (Virtual Datacenter)"
description: |-
The cloudavenue_vdc_group resource allows you to manage VDC Group.
!> Resource deprecated The resource has renamed to cloudavenue_vdcg https://registry.terraform.io/providers/orange-cloudavenue/cloudavenue/latest/docs/resources/vdcg, it will be removed in the version v0.30.0 of the provider.
---

# cloudavenue_vdc_group (Resource)

The `cloudavenue_vdc_group` resource allows you to manage VDC Group.

The `cloudavenue_vdc_group` resource allows you to manage VDC Group.

!> **Resource deprecated** The resource has renamed to [`cloudavenue_vdcg`](https://registry.terraform.io/providers/orange-cloudavenue/cloudavenue/latest/docs/resources/vdcg), it will be removed in the version `v0.30.0` of the provider.

## How to migrate existing resources

Original configuration:

```terraform
resource "cloudavenue_vdc_group" "example" {
name = "example"
vdc_ids = [
cloudavenue_vdc.example.id,
]
}
```

Migrated configuration:

Rename the resource to `cloudavenue_vdcg` and add the `moved` block to the configuration:

```hcl
resource "cloudavenue_vdcg" "example" {
name = "example"
vdc_ids = [
cloudavenue_vdc.example.id,
]
}
moved {
from = cloudavenue_vdc_group.example
to = cloudavenue_vdcg.example
}
```

Run `terraform plan` and `terraform apply` to migrate the resource.

Example of terraform plan output:

```shell
Terraform will perform the following actions:

# cloudavenue_vdc_group.example has moved to cloudavenue_vdcg.example
resource "cloudavenue_vdcg" "example" {
id = "urn:vcloud:vdcGroup:xxxx-xxxx-xxxxx-xxxxxx"
name = "example"
# (3 unchanged attributes hidden)
}

Plan: 0 to add, 0 to change, 0 to destroy.
```

## Example Usage

```terraform
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ toolchain go1.23.3
require (
github.com/FrangipaneTeam/terraform-analytic-tool v0.0.12
github.com/FrangipaneTeam/terraform-plugin-framework-planmodifiers v1.3.4
github.com/FrangipaneTeam/terraform-plugin-framework-superschema v1.8.0
github.com/FrangipaneTeam/terraform-plugin-framework-superschema v1.8.1
github.com/FrangipaneTeam/terraform-plugin-framework-supertypes v0.4.0
github.com/FrangipaneTeam/terraform-plugin-framework-validators v1.8.1
github.com/aws/aws-sdk-go v1.55.5
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ github.com/FrangipaneTeam/terraform-analytic-tool v0.0.12 h1:rbh0EtyILnuyu07RuOh
github.com/FrangipaneTeam/terraform-analytic-tool v0.0.12/go.mod h1:j3TxedNm9WrKKseOSBKxnNtquuXa0FQChO/QdcvPKtg=
github.com/FrangipaneTeam/terraform-plugin-framework-planmodifiers v1.3.4 h1:FGb+DIj8AtUehYLt7b0t1rjqK/7sggkoZwR4tqdQjcc=
github.com/FrangipaneTeam/terraform-plugin-framework-planmodifiers v1.3.4/go.mod h1:ngKE3iJWLWPLZ64umTr5ndnqd9mvMxHUZPk9pCkGSJY=
github.com/FrangipaneTeam/terraform-plugin-framework-superschema v1.8.0 h1:x9MfFpk8neqrcwEiSXKEsieI0Cr747yjhlRnPQIjUtA=
github.com/FrangipaneTeam/terraform-plugin-framework-superschema v1.8.0/go.mod h1:AkcBw7L/PhgCm1A4P4adGrbEjE7i2maeCn/Jeh5t5Lo=
github.com/FrangipaneTeam/terraform-plugin-framework-superschema v1.8.1 h1:ov6LOLLANE9nZVQ1DrpMLuITkejMzTbZLE54xtxZ14A=
github.com/FrangipaneTeam/terraform-plugin-framework-superschema v1.8.1/go.mod h1:AkcBw7L/PhgCm1A4P4adGrbEjE7i2maeCn/Jeh5t5Lo=
github.com/FrangipaneTeam/terraform-plugin-framework-supertypes v0.4.0 h1:5lFfjKOhBxBQNwQ63PZWBc5Unqgi5ppYq9RDoN05N+k=
github.com/FrangipaneTeam/terraform-plugin-framework-supertypes v0.4.0/go.mod h1:klzXBi/0nMGXBh4bzRjP2wef+HE6rfCMia81Glc2+eY=
github.com/FrangipaneTeam/terraform-plugin-framework-validators v1.8.1 h1:C17IEM0/4sxsTN0IpwDdgncea/cxfZVlWESIWvlEuBo=
Expand Down
1 change: 0 additions & 1 deletion internal/provider/vdc/vdc_group_datasource.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// Package vdc provides a Terraform datasource.
package vdc

import (
Expand Down
1 change: 0 additions & 1 deletion internal/provider/vdc/vdc_group_resource.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// Package vdc provides a Terraform resource.
package vdc

import (
Expand Down
17 changes: 17 additions & 0 deletions internal/provider/vdc/vdc_group_schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,26 @@ func groupSchema() superschema.Schema {
return superschema.Schema{
Resource: superschema.SchemaDetails{
MarkdownDescription: "The `cloudavenue_vdc_group` resource allows you to manage VDC Group.",
Deprecated: superschema.DeprecatedResource{
DeprecationMessage: "The `cloudavenue_vdc_group` resource is deprecated. Please use the `cloudavenue_vdcg` resource instead.",
ComputeMarkdownDeprecationMessage: true,
Renamed: true,
TargetResourceName: "cloudavenue_vdcg",
TargetRelease: "v0.30.0",
LinkToMigrationGuide: "https://registry.terraform.io/providers/orange-cloudavenue/cloudavenue/latest/docs/resources/vdc_group#how-to-migrate-existing-resources",
LinkToNewResourceDoc: "https://registry.terraform.io/providers/orange-cloudavenue/cloudavenue/latest/docs/resources/vdcg",
},
},
DataSource: superschema.SchemaDetails{
MarkdownDescription: "The `cloudavenue_vdc_group` data source allows you to retrieve informations about an existing VDC Group.",
Deprecated: superschema.DeprecatedResource{
DeprecationMessage: "The `cloudavenue_vdc_group` data source is deprecated. Please use the `cloudavenue_vdcg` data source instead.",
ComputeMarkdownDeprecationMessage: true,
Renamed: true,
TargetResourceName: "cloudavenue_vdcg",
TargetRelease: "v0.30.0",
LinkToNewResourceDoc: "https://registry.terraform.io/providers/orange-cloudavenue/cloudavenue/latest/docs/data-sources/vdcg",
},
},
Attributes: map[string]superschema.Attribute{
"id": superschema.SuperStringAttribute{
Expand Down
2 changes: 1 addition & 1 deletion internal/provider/vdc/vdc_group_schema_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func TestGroupResourceSchema(t *testing.T) {
}
}

func TestVPNIPSecDataSourceSchema(t *testing.T) {
func TestGroupDataSourceSchema(t *testing.T) {
t.Parallel()

ctx := context.Background()
Expand Down
74 changes: 74 additions & 0 deletions internal/provider/vdcg/vdcg_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,31 @@ package vdcg
import (
"context"
"fmt"
"strings"

"github.com/vmware/go-vcloud-director/v2/govcd"

"github.com/hashicorp/terraform-plugin-framework/diag"
"github.com/hashicorp/terraform-plugin-framework/path"

"github.com/hashicorp/terraform-plugin-framework/resource"
"github.com/hashicorp/terraform-plugin-framework/resource/schema"

supertypes "github.com/FrangipaneTeam/terraform-plugin-framework-supertypes"

"github.com/orange-cloudavenue/cloudavenue-sdk-go/pkg/urn"
"github.com/orange-cloudavenue/terraform-provider-cloudavenue/internal/client"
"github.com/orange-cloudavenue/terraform-provider-cloudavenue/internal/metrics"
"github.com/orange-cloudavenue/terraform-provider-cloudavenue/internal/provider/common/adminorg"
"github.com/orange-cloudavenue/terraform-provider-cloudavenue/internal/provider/vdc"
)

// Ensure the implementation satisfies the expected interfaces.
var (
_ resource.Resource = &vdcgResource{}
_ resource.ResourceWithConfigure = &vdcgResource{}
_ resource.ResourceWithImportState = &vdcgResource{}
_ resource.ResourceWithMoveState = &vdcgResource{}
)

// NewvdcgResource is a helper function to simplify the provider implementation.
Expand Down Expand Up @@ -68,6 +74,74 @@ func (r *vdcgResource) Configure(ctx context.Context, req resource.ConfigureRequ
r.client = client
}

// ResourceWithMoveState interface implementation.
func (r *vdcgResource) MoveState(ctx context.Context) []resource.StateMover {
return []resource.StateMover{
{
SourceSchema: func() *schema.Schema {
ctx := context.Background()
schemaRequest := resource.SchemaRequest{}
schemaResponse := &resource.SchemaResponse{}

vdc.NewGroupResource().Schema(ctx, schemaRequest, schemaResponse)
if schemaResponse.Diagnostics.HasError() {
return nil
}

return &schemaResponse.Schema
}(),
StateMover: func(ctx context.Context, req resource.MoveStateRequest, resp *resource.MoveStateResponse) {
if req.SourceTypeName != "cloudavenue_vdc_group" {
return
}

if req.SourceSchemaVersion != 0 {
return
}

if !strings.HasSuffix(req.SourceProviderAddress, "orange-cloudavenue/cloudavenue") {
return
}

source := vdc.GroupModel{}
dest := vdcgModel{
ID: supertypes.NewStringNull(),
Name: supertypes.NewStringNull(),
Description: supertypes.NewStringNull(),
VDCIDs: supertypes.NewSetValueOfNull[string](ctx),
Status: supertypes.NewStringNull(),
Type: supertypes.NewStringNull(),
}

resp.Diagnostics.Append(req.SourceState.Get(ctx, &source)...)
if resp.Diagnostics.HasError() {
return
}

dest.ID.Set(source.ID.Get())
dest.Name.Set(source.Name.Get())
dest.Description.Set(source.Description.Get())
dest.Status.Set(source.Status.Get())
dest.Type.Set(source.Type.Get())

vdcids, d := source.GetVDCIds(ctx)
if d.HasError() {
resp.Diagnostics.Append(d...)
return
}

resp.Diagnostics.Append(dest.VDCIDs.Set(ctx, vdcids.Get())...)
if resp.Diagnostics.HasError() {
resp.Diagnostics.AddError("Error setting VDC IDs", "Error setting VDC IDs")
return
}

resp.Diagnostics.Append(resp.TargetState.Set(ctx, &dest)...)
},
},
}
}

// Create creates the resource and sets the initial Terraform state.
func (r *vdcgResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) {
defer metrics.New("cloudavenue_vdcg", r.client.GetOrgName(), metrics.Create)()
Expand Down
48 changes: 48 additions & 0 deletions internal/testsacc/vdcg_resource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,54 @@ func (r *VDCGResource) Tests(ctx context.Context) map[testsacc.TestName]func(ctx
},
}
},
// This test not working on testsacc
// "example_move_state": func(_ context.Context, resourceName string) testsacc.Test {
// return testsacc.Test{
// CommonChecks: []resource.TestCheckFunc{},
// // ! Create testing
// Create: testsacc.TFConfig{
// TFConfig: testsacc.GenerateFromTemplate(resourceName, `
// resource "cloudavenue_vdc_group" "example_move_state" {
// name = "move-state"
// vdc_ids = [
// cloudavenue_vdc.example_vdc_group_1.id,
// ]
// }`),
// Checks: []resource.TestCheckFunc{
// resource.TestCheckResourceAttrWith("cloudavenue_vdc_group.example_move_state", "id", urn.TestIsType(urn.VDCGroup)),
// resource.TestCheckResourceAttrSet("cloudavenue_vdc_group.example_move_state", "status"),
// resource.TestCheckResourceAttrSet("cloudavenue_vdc_group.example_move_state", "type"),
// resource.TestCheckResourceAttr("cloudavenue_vdc_group.example_move_state", "name", "move-state"),
// resource.TestCheckResourceAttr("cloudavenue_vdc_group.example_move_state", "vdc_ids.#", "1"),
// },
// },
// // ! Updates testing
// Updates: []testsacc.TFConfig{
// // Update description and add a new vdc_id
// {
// TFConfig: testsacc.GenerateFromTemplate(resourceName, `
// resource "cloudavenue_vdcg" "example_move_state" {
// name = "move-state"
// vdc_ids = [
// cloudavenue_vdc.example_vdc_group_1.id,
// ]
// }

// moved {
// from = cloudavenue_vdc_group.example
// to = cloudavenue_vdcg.example
// }`),
// Checks: []resource.TestCheckFunc{
// resource.TestCheckResourceAttrWith(resourceName, "id", urn.TestIsType(urn.VDCGroup)),
// resource.TestCheckResourceAttrSet(resourceName, "status"),
// resource.TestCheckResourceAttrSet(resourceName, "type"),
// resource.TestCheckResourceAttr(resourceName, "name", "move-state"),
// resource.TestCheckResourceAttr(resourceName, "vdc_ids.#", "1"),
// },
// },
// },
// }
// },
}
}

Expand Down
43 changes: 42 additions & 1 deletion templates/resources/vdc_group.md.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,48 @@ description: |-
# {{.Name}} ({{.Type}})

{{ .Description | trimspace }}


## How to migrate existing resources

Original configuration:

{{ tffile .ExampleFile }}

Migrated configuration:

Rename the resource to `cloudavenue_vdcg` and add the `moved` block to the configuration:

```hcl
resource "cloudavenue_vdcg" "example" {
name = "example"
vdc_ids = [
cloudavenue_vdc.example.id,
]
}

moved {
from = cloudavenue_vdc_group.example
to = cloudavenue_vdcg.example
}
```

Run `terraform plan` and `terraform apply` to migrate the resource.

Example of terraform plan output:

```shell
Terraform will perform the following actions:

# cloudavenue_vdc_group.example has moved to cloudavenue_vdcg.example
resource "cloudavenue_vdcg" "example" {
id = "urn:vcloud:vdcGroup:xxxx-xxxx-xxxxx-xxxxxx"
name = "example"
# (3 unchanged attributes hidden)
}

Plan: 0 to add, 0 to change, 0 to destroy.
```

{{ if .HasExample -}}
## Example Usage

Expand Down

0 comments on commit e229052

Please sign in to comment.