Skip to content

Commit

Permalink
Merge pull request #945 from Juniper/929-remove-obsolete-fabric_link_…
Browse files Browse the repository at this point in the history
…addressing-attribute-from-template-resourcesdata-sources

Remove obsolete `fabric_link_addressing` attribute from template resources
  • Loading branch information
bwJuniper authored Oct 21, 2024
2 parents 810ee58 + 6543901 commit 781e1c6
Show file tree
Hide file tree
Showing 8 changed files with 13 additions and 77 deletions.
32 changes: 8 additions & 24 deletions apstra/design/template_pod_based.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"context"

"github.com/Juniper/apstra-go-sdk/apstra"
apstravalidator "github.com/Juniper/terraform-provider-apstra/apstra/apstra_validator"
"github.com/Juniper/terraform-provider-apstra/apstra/utils"
"github.com/hashicorp/terraform-plugin-framework-validators/mapvalidator"
"github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator"
Expand All @@ -21,20 +20,18 @@ import (
)

type TemplatePodBased struct {
Id types.String `tfsdk:"id"`
Name types.String `tfsdk:"name"`
SuperSpine types.Object `tfsdk:"super_spine"`
FabricAddressing types.String `tfsdk:"fabric_link_addressing"`
PodInfos types.Map `tfsdk:"pod_infos"`
Id types.String `tfsdk:"id"`
Name types.String `tfsdk:"name"`
SuperSpine types.Object `tfsdk:"super_spine"`
PodInfos types.Map `tfsdk:"pod_infos"`
}

func (o TemplatePodBased) AttrTypes() map[string]attr.Type {
return map[string]attr.Type{
"id": types.StringType,
"name": types.StringType,
"super_spine": types.ObjectType{AttrTypes: SuperSpine{}.AttrTypes()},
"fabric_link_addressing": types.StringType,
"pod_infos": types.MapType{ElemType: types.ObjectType{AttrTypes: TemplatePodInfo{}.AttrTypes()}},
"id": types.StringType,
"name": types.StringType,
"super_spine": types.ObjectType{AttrTypes: SuperSpine{}.AttrTypes()},
"pod_infos": types.MapType{ElemType: types.ObjectType{AttrTypes: TemplatePodInfo{}.AttrTypes()}},
}
}

Expand Down Expand Up @@ -63,11 +60,6 @@ func (o TemplatePodBased) DataSourceAttributes() map[string]dataSourceSchema.Att
Computed: true,
Attributes: SuperSpine{}.DataSourceAttributes(),
},
"fabric_link_addressing": dataSourceSchema.StringAttribute{
DeprecationMessage: "Apstra 4.1.0 is not supported by this release. This field must not be used.",
MarkdownDescription: "Fabric addressing scheme for Spine/Superspine links.",
Computed: true,
},
"pod_infos": dataSourceSchema.MapNestedAttribute{
MarkdownDescription: "Map of Pod Type info (count + details)",
Computed: true,
Expand Down Expand Up @@ -95,13 +87,6 @@ func (o TemplatePodBased) ResourceAttributes() map[string]resourceSchema.Attribu
Required: true,
Attributes: SuperSpine{}.ResourceAttributes(),
},
"fabric_link_addressing": resourceSchema.StringAttribute{
DeprecationMessage: "Apstra 4.1.0 is not supported by this release. This field must not be used.",
MarkdownDescription: "Fabric addressing scheme for Spine/SuperSpine links.",
Optional: true,
Computed: true,
Validators: []validator.String{apstravalidator.MustBeOneOf([]attr.Value{types.StringNull()})},
},
"pod_infos": resourceSchema.MapNestedAttribute{
MarkdownDescription: "Map of Pod Type info (count + details) keyed by Pod Based Template ID.",
Required: true,
Expand Down Expand Up @@ -154,7 +139,6 @@ func (o *TemplatePodBased) LoadApiData(ctx context.Context, in *apstra.TemplateP
o.Name = types.StringValue(in.DisplayName)
o.SuperSpine = NewDesignTemplateSuperSpineObject(ctx, &in.Superspine, diags)
o.PodInfos = NewPodInfoMap(ctx, in, diags)
o.FabricAddressing = types.StringNull()
}

func (o *TemplatePodBased) CopyWriteOnlyElements(ctx context.Context, src *TemplatePodBased, diags *diag.Diagnostics) {
Expand Down
26 changes: 0 additions & 26 deletions apstra/design/template_rack_based.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"fmt"

"github.com/Juniper/apstra-go-sdk/apstra"
apstravalidator "github.com/Juniper/terraform-provider-apstra/apstra/apstra_validator"
"github.com/Juniper/terraform-provider-apstra/apstra/utils"
"github.com/hashicorp/terraform-plugin-framework-validators/mapvalidator"
"github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator"
Expand All @@ -27,7 +26,6 @@ type TemplateRackBased struct {
Spine types.Object `tfsdk:"spine"`
AsnAllocation types.String `tfsdk:"asn_allocation_scheme"`
OverlayControlProtocol types.String `tfsdk:"overlay_control_protocol"`
FabricAddressing types.String `tfsdk:"fabric_link_addressing"`
RackInfos types.Map `tfsdk:"rack_infos"`
}

Expand All @@ -38,7 +36,6 @@ func (o TemplateRackBased) AttrTypes() map[string]attr.Type {
"spine": types.ObjectType{AttrTypes: Spine{}.AttrTypes()},
"asn_allocation_scheme": types.StringType,
"overlay_control_protocol": types.StringType,
"fabric_link_addressing": types.StringType,
"rack_infos": types.MapType{ElemType: types.ObjectType{AttrTypes: TemplateRackInfo{}.AttrTypes()}},
}
}
Expand Down Expand Up @@ -77,11 +74,6 @@ func (o TemplateRackBased) DataSourceAttributes() map[string]dataSourceSchema.At
MarkdownDescription: "Defines the inter-rack virtual network overlay protocol in the fabric.",
Computed: true,
},
"fabric_link_addressing": dataSourceSchema.StringAttribute{
DeprecationMessage: "Apstra 4.1.0 is not supported by this release. This field must not be used.",
MarkdownDescription: "Fabric addressing scheme for Spine/Leaf links.",
Computed: true,
},
"rack_infos": dataSourceSchema.MapNestedAttribute{
MarkdownDescription: "Map of Rack Type info (count + details)",
Computed: true,
Expand Down Expand Up @@ -116,11 +108,6 @@ func (o TemplateRackBased) DataSourceAttributesNested() map[string]dataSourceSch
MarkdownDescription: "Defines the inter-rack virtual network overlay protocol in the fabric.",
Computed: true,
},
"fabric_link_addressing": dataSourceSchema.StringAttribute{
DeprecationMessage: "Apstra 4.1.0 is not supported by this release. This field must not be used.",
MarkdownDescription: "Fabric addressing scheme for Spine/Leaf links.",
Computed: true,
},
"rack_infos": dataSourceSchema.MapNestedAttribute{
MarkdownDescription: "Map of Rack Type info (count + details)",
Computed: true,
Expand Down Expand Up @@ -163,13 +150,6 @@ func (o TemplateRackBased) ResourceAttributes() map[string]resourceSchema.Attrib
// todo make sure not ipv6 with evpn
},
},
"fabric_link_addressing": resourceSchema.StringAttribute{
DeprecationMessage: "Apstra 4.1.0 is not supported by this release. This field must not be used.",
MarkdownDescription: "Fabric addressing scheme for Spine/Leaf links.",
Optional: true,
Computed: true,
Validators: []validator.String{apstravalidator.MustBeOneOf([]attr.Value{types.StringNull()})},
},
"rack_infos": resourceSchema.MapNestedAttribute{
MarkdownDescription: "Map of Rack Type info (count + details) keyed by Rack Type ID.",
Required: true,
Expand Down Expand Up @@ -205,11 +185,6 @@ func (o TemplateRackBased) ResourceAttributesNested() map[string]resourceSchema.
MarkdownDescription: "Defines the inter-rack virtual network overlay protocol in the fabric.",
Computed: true,
},
"fabric_link_addressing": resourceSchema.StringAttribute{
DeprecationMessage: "Apstra 4.1.0 is not supported by this release. This field must not be used.",
MarkdownDescription: "Fabric addressing scheme for Spine/Leaf links.",
Computed: true,
},
"rack_infos": resourceSchema.MapNestedAttribute{
MarkdownDescription: "Map of Rack Type info (count + details)",
Computed: true,
Expand Down Expand Up @@ -292,7 +267,6 @@ func (o *TemplateRackBased) LoadApiData(ctx context.Context, in *apstra.Template
o.AsnAllocation = types.StringValue(utils.StringersToFriendlyString(in.AsnAllocationPolicy.SpineAsnScheme))
o.OverlayControlProtocol = types.StringValue(utils.StringersToFriendlyString(in.VirtualNetworkPolicy.OverlayControlProtocol))
o.RackInfos = NewRackInfoMap(ctx, in, diags)
o.FabricAddressing = types.StringNull()
}

func (o *TemplateRackBased) CopyWriteOnlyElements(ctx context.Context, src *TemplateRackBased, diags *diag.Diagnostics) {
Expand Down
17 changes: 5 additions & 12 deletions apstra/resource_template_pod_based_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ const (
resourceTemplatePodBasedHCL = `
resource %q %q {
name = %q
fabric_link_addressing = %s
super_spine = {
logical_device_id = %q
per_plane_count = %d
Expand All @@ -35,12 +34,11 @@ resource %q %q {
)

type resourceTestPodTemplate struct {
name string
fabricLinkAddressing *string
ssLd string
perPlaneCount int
planeCount *int
podInfo map[string]int
name string
ssLd string
perPlaneCount int
planeCount *int
podInfo map[string]int
}

func (o resourceTestPodTemplate) render(rType, rName string) string {
Expand All @@ -51,7 +49,6 @@ func (o resourceTestPodTemplate) render(rType, rName string) string {
return fmt.Sprintf(resourceTemplatePodBasedHCL,
rType, rName,
o.name,
stringPtrOrNull(o.fabricLinkAddressing),
o.ssLd,
o.perPlaneCount,
intPtrOrNull(o.planeCount),
Expand All @@ -66,10 +63,6 @@ func (o resourceTestPodTemplate) testChecks(t testing.TB, rType, rName string) t
result.append(t, "TestCheckResourceAttrSet", "id")
result.append(t, "TestCheckResourceAttr", "name", o.name)

if o.fabricLinkAddressing != nil {
result.append(t, "TestCheckResourceAttr", "fabric_link_addressing", *o.fabricLinkAddressing)
}

result.append(t, "TestCheckResourceAttr", "super_spine.logical_device_id", o.ssLd)
result.append(t, "TestCheckResourceAttr", "super_spine.per_plane_count", strconv.Itoa(o.perPlaneCount))

Expand Down
3 changes: 0 additions & 3 deletions apstra/resource_template_rack_based_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ resource "apstra_template_rack_based" "test" {
overlay_control_protocol = %q // mandatory field
rack_infos = %s // mandatory field
spine = %s // mandatory field
fabric_link_addressing = %s
}
`
resourceTemplateRackBasedRackInfoHcl = `
Expand Down Expand Up @@ -68,7 +67,6 @@ func TestResourceTemplateRackBased(t *testing.T) {
overlayControlProtocol string
rackInfos map[string]int
spine spine
fabricLinkAddressing string
}

renderConfig := func(config config) string {
Expand All @@ -78,7 +76,6 @@ func TestResourceTemplateRackBased(t *testing.T) {
config.overlayControlProtocol,
renderRackInfos(config.rackInfos),
renderSpine(config.spine),
stringOrNull(config.fabricLinkAddressing),
)
}

Expand Down
2 changes: 0 additions & 2 deletions docs/data-sources/template_pod_based.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ resource "apstra_template_pod_based" "example" {

### Read-Only

- `fabric_link_addressing` (String, Deprecated) Fabric addressing scheme for Spine/Superspine links.
- `pod_infos` (Attributes Map) Map of Pod Type info (count + details) (see [below for nested schema](#nestedatt--pod_infos))
- `super_spine` (Attributes) Super Spine layer details (see [below for nested schema](#nestedatt--super_spine))

Expand All @@ -53,7 +52,6 @@ Read-Only:
Read-Only:

- `asn_allocation_scheme` (String) "unique" is for 3-stage designs; "single" is for 5-stage designs.
- `fabric_link_addressing` (String, Deprecated) Fabric addressing scheme for Spine/Leaf links.
- `id` (String) ID of the pod inside the 5 stage template.
- `name` (String) Name of the pod inside the 5 stage template.
- `overlay_control_protocol` (String) Defines the inter-rack virtual network overlay protocol in the fabric.
Expand Down
1 change: 0 additions & 1 deletion docs/data-sources/template_rack_based.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ output "rack_based_template_id_to_name" {
### Read-Only

- `asn_allocation_scheme` (String) "unique" is for 3-stage designs; "single" is for 5-stage designs.
- `fabric_link_addressing` (String, Deprecated) Fabric addressing scheme for Spine/Leaf links.
- `overlay_control_protocol` (String) Defines the inter-rack virtual network overlay protocol in the fabric.
- `rack_infos` (Attributes Map) Map of Rack Type info (count + details) (see [below for nested schema](#nestedatt--rack_infos))
- `spine` (Attributes) Spine layer details (see [below for nested schema](#nestedatt--spine))
Expand Down
5 changes: 0 additions & 5 deletions docs/resources/template_pod_based.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,6 @@ resource "apstra_template_pod_based" "example" {
- `pod_infos` (Attributes Map) Map of Pod Type info (count + details) keyed by Pod Based Template ID. (see [below for nested schema](#nestedatt--pod_infos))
- `super_spine` (Attributes) SuperSpine layer details (see [below for nested schema](#nestedatt--super_spine))

### Optional

- `fabric_link_addressing` (String, Deprecated) Fabric addressing scheme for Spine/SuperSpine links.

### Read-Only

- `id` (String) Apstra ID of the Pod Based Template.
Expand All @@ -64,7 +60,6 @@ Read-Only:
Read-Only:

- `asn_allocation_scheme` (String) "unique" is for 3-stage designs; "single" is for 5-stage designs.
- `fabric_link_addressing` (String, Deprecated) Fabric addressing scheme for Spine/Leaf links.
- `id` (String) ID of the pod inside the 5 stage template.
- `name` (String) Name of the pod inside the 5 stage template.
- `overlay_control_protocol` (String) Defines the inter-rack virtual network overlay protocol in the fabric.
Expand Down
4 changes: 0 additions & 4 deletions docs/resources/template_rack_based.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,6 @@ resource "apstra_template_rack_based" "r" {
- `rack_infos` (Attributes Map) Map of Rack Type info (count + details) keyed by Rack Type ID. (see [below for nested schema](#nestedatt--rack_infos))
- `spine` (Attributes) Spine layer details (see [below for nested schema](#nestedatt--spine))

### Optional

- `fabric_link_addressing` (String, Deprecated) Fabric addressing scheme for Spine/Leaf links.

### Read-Only

- `id` (String) Apstra ID of the Rack Based Template.
Expand Down

0 comments on commit 781e1c6

Please sign in to comment.