Skip to content

Commit

Permalink
Merge pull request #984 from Juniper/982-deprecate-old-ct-resources-a…
Browse files Browse the repository at this point in the history
…nd-data-sources

Deprecate old CT resource and "primitive" data sources
  • Loading branch information
chrismarget-j authored Dec 8, 2024
2 parents e86e4eb + 0a56744 commit 391840e
Show file tree
Hide file tree
Showing 11 changed files with 72 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package tfapstra

import (
"context"

"github.com/Juniper/apstra-go-sdk/apstra"
connectivitytemplate "github.com/Juniper/terraform-provider-apstra/apstra/connectivity_template"
"github.com/hashicorp/terraform-plugin-framework/datasource"
Expand All @@ -22,6 +23,11 @@ func (o *dataSourceDatacenterCtBgpPeeringGenericSystem) Schema(_ context.Context
MarkdownDescription: docCategoryDatacenter + "This data source composes a Connectivity Template Primitive as a JSON string, " +
"suitable for use in the `primitives` attribute of an `apstra_datacenter_connectivity_template` " +
"resource or the `child_primitives` attribute of a Different Connectivity Template Primitive.",
DeprecationMessage: "This data source will be removed in a future version. Please migrate your use of the " +
"`apstra_datacenter_connectivity_template` resource (the likely reason this data source is being invoked) " +
"to one of the new resources which do not depend on this data source: " +
"`apstra_datacenter_connectivity_template_interface`, `apstra_datacenter_connectivity_template_loopback`, " +
"`apstra_datacenter_connectivity_template_svi`, or `apstra_datacenter_connectivity_template_system`.",
Attributes: connectivitytemplate.BgpPeeringGenericSystem{}.DataSourceAttributes(),
}
}
Expand All @@ -34,7 +40,7 @@ func (o *dataSourceDatacenterCtBgpPeeringGenericSystem) ValidateConfig(ctx conte
}

if config.Ipv4AddressingType.IsUnknown() || config.Ipv6AddressingType.IsUnknown() {
return //cannot validate until both values are known
return // cannot validate until both values are known
}

v4NoneString := apstra.CtPrimitiveIPv4ProtocolSessionAddressingNone.String() // "none"
Expand Down
6 changes: 6 additions & 0 deletions apstra/data_source_datacenter_ct_bgp_peering_ip_endpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package tfapstra

import (
"context"

connectivitytemplate "github.com/Juniper/terraform-provider-apstra/apstra/connectivity_template"
"github.com/hashicorp/terraform-plugin-framework/datasource"
"github.com/hashicorp/terraform-plugin-framework/datasource/schema"
Expand All @@ -21,6 +22,11 @@ func (o *dataSourceDatacenterCtBgpPeeringIpEndpoint) Schema(_ context.Context, _
MarkdownDescription: docCategoryDatacenter + "This data source composes a Connectivity Template Primitive as a JSON string, " +
"suitable for use in the `primitives` attribute of an `apstra_datacenter_connectivity_template` " +
"resource or the `child_primitives` attribute of a Different Connectivity Template Primitive.",
DeprecationMessage: "This data source will be removed in a future version. Please migrate your use of the " +
"`apstra_datacenter_connectivity_template` resource (the likely reason this data source is being invoked) " +
"to one of the new resources which do not depend on this data source: " +
"`apstra_datacenter_connectivity_template_interface`, `apstra_datacenter_connectivity_template_loopback`, " +
"`apstra_datacenter_connectivity_template_svi`, or `apstra_datacenter_connectivity_template_system`.",
Attributes: connectivitytemplate.BgpPeeringIpEndpoint{}.DataSourceAttributes(),
}
}
Expand Down
8 changes: 7 additions & 1 deletion apstra/data_source_datacenter_ct_custom_static_route.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@ package tfapstra
import (
"context"
"fmt"
"net"

connectivitytemplate "github.com/Juniper/terraform-provider-apstra/apstra/connectivity_template"
"github.com/Juniper/terraform-provider-apstra/apstra/utils"
"github.com/hashicorp/terraform-plugin-framework/datasource"
"github.com/hashicorp/terraform-plugin-framework/datasource/schema"
"github.com/hashicorp/terraform-plugin-framework/path"
"github.com/hashicorp/terraform-plugin-framework/types"
"net"
)

var _ datasource.DataSourceWithValidateConfig = &dataSourceDatacenterCtCustomStaticRoute{}
Expand All @@ -25,6 +26,11 @@ func (o *dataSourceDatacenterCtCustomStaticRoute) Schema(_ context.Context, _ da
MarkdownDescription: docCategoryDatacenter + "This data source composes a Connectivity Template Primitive as a JSON string, " +
"suitable for use in the `primitives` attribute of an `apstra_datacenter_connectivity_template` " +
"resource or the `child_primitives` attribute of a Different Connectivity Template Primitive.",
DeprecationMessage: "This data source will be removed in a future version. Please migrate your use of the " +
"`apstra_datacenter_connectivity_template` resource (the likely reason this data source is being invoked) " +
"to one of the new resources which do not depend on this data source: " +
"`apstra_datacenter_connectivity_template_interface`, `apstra_datacenter_connectivity_template_loopback`, " +
"`apstra_datacenter_connectivity_template_svi`, or `apstra_datacenter_connectivity_template_system`.",
Attributes: connectivitytemplate.CustomStaticRoute{}.DataSourceAttributes(),
}
}
Expand Down
6 changes: 6 additions & 0 deletions apstra/data_source_datacenter_ct_dynamic_bgp_peering.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package tfapstra

import (
"context"

connectivitytemplate "github.com/Juniper/terraform-provider-apstra/apstra/connectivity_template"
"github.com/hashicorp/terraform-plugin-framework/datasource"
"github.com/hashicorp/terraform-plugin-framework/datasource/schema"
Expand All @@ -21,6 +22,11 @@ func (o *dataSourceDatacenterCtDynamicBgpPeering) Schema(_ context.Context, _ da
MarkdownDescription: docCategoryDatacenter + "This data source composes a Connectivity Template Primitive as a JSON string, " +
"suitable for use in the `primitives` attribute of an `apstra_datacenter_connectivity_template` " +
"resource or the `child_primitives` attribute of a Different Connectivity Template Primitive.",
DeprecationMessage: "This data source will be removed in a future version. Please migrate your use of the " +
"`apstra_datacenter_connectivity_template` resource (the likely reason this data source is being invoked) " +
"to one of the new resources which do not depend on this data source: " +
"`apstra_datacenter_connectivity_template_interface`, `apstra_datacenter_connectivity_template_loopback`, " +
"`apstra_datacenter_connectivity_template_svi`, or `apstra_datacenter_connectivity_template_system`.",
Attributes: connectivitytemplate.DynamicBgpPeering{}.DataSourceAttributes(),
}
}
Expand Down
5 changes: 5 additions & 0 deletions apstra/data_source_datacenter_ct_ip_link.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ func (o *dataSourceDatacenterCtIpLink) Schema(_ context.Context, _ datasource.Sc
MarkdownDescription: docCategoryDatacenter + "This data source composes a Connectivity Template Primitive as a JSON string, " +
"suitable for use in the `primitives` attribute of an `apstra_datacenter_connectivity_template` " +
"resource or the `child_primitives` attribute of a Different Connectivity Template Primitive.",
DeprecationMessage: "This data source will be removed in a future version. Please migrate your use of the " +
"`apstra_datacenter_connectivity_template` resource (the likely reason this data source is being invoked) " +
"to one of the new resources which do not depend on this data source: " +
"`apstra_datacenter_connectivity_template_interface`, `apstra_datacenter_connectivity_template_loopback`, " +
"`apstra_datacenter_connectivity_template_svi`, or `apstra_datacenter_connectivity_template_system`.",
Attributes: connectivitytemplate.IpLink{}.DataSourceAttributes(),
}
}
Expand Down
6 changes: 6 additions & 0 deletions apstra/data_source_datacenter_ct_routing_policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package tfapstra

import (
"context"

connectivitytemplate "github.com/Juniper/terraform-provider-apstra/apstra/connectivity_template"
"github.com/hashicorp/terraform-plugin-framework/datasource"
"github.com/hashicorp/terraform-plugin-framework/datasource/schema"
Expand All @@ -21,6 +22,11 @@ func (o *dataSourceDatacenterCtRoutingPolicy) Schema(_ context.Context, _ dataso
MarkdownDescription: docCategoryDatacenter + "This data source composes a Connectivity Template Primitive as a JSON string, " +
"suitable for use in the `primitives` attribute of an `apstra_datacenter_connectivity_template` " +
"resource or the `child_primitives` attribute of a Different Connectivity Template Primitive.",
DeprecationMessage: "This data source will be removed in a future version. Please migrate your use of the " +
"`apstra_datacenter_connectivity_template` resource (the likely reason this data source is being invoked) " +
"to one of the new resources which do not depend on this data source: " +
"`apstra_datacenter_connectivity_template_interface`, `apstra_datacenter_connectivity_template_loopback`, " +
"`apstra_datacenter_connectivity_template_svi`, or `apstra_datacenter_connectivity_template_system`.",
Attributes: connectivitytemplate.RoutingPolicy{}.DataSourceAttributes(),
}
}
Expand Down
6 changes: 6 additions & 0 deletions apstra/data_source_datacenter_ct_routing_zone_constraint.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package tfapstra

import (
"context"

connectivitytemplate "github.com/Juniper/terraform-provider-apstra/apstra/connectivity_template"
"github.com/hashicorp/terraform-plugin-framework/datasource"
"github.com/hashicorp/terraform-plugin-framework/datasource/schema"
Expand All @@ -21,6 +22,11 @@ func (o *dataSourceDatacenterCtRoutingZoneConstraint) Schema(_ context.Context,
MarkdownDescription: docCategoryDatacenter + "This data source composes a Connectivity Template Primitive as a JSON string, " +
"suitable for use in the `primitives` attribute of an `apstra_datacenter_connectivity_template` " +
"resource or the `child_primitives` attribute of a Different Connectivity Template Primitive.",
DeprecationMessage: "This data source will be removed in a future version. Please migrate your use of the " +
"`apstra_datacenter_connectivity_template` resource (the likely reason this data source is being invoked) " +
"to one of the new resources which do not depend on this data source: " +
"`apstra_datacenter_connectivity_template_interface`, `apstra_datacenter_connectivity_template_loopback`, " +
"`apstra_datacenter_connectivity_template_svi`, or `apstra_datacenter_connectivity_template_system`.",
Attributes: connectivitytemplate.RoutingZoneConstraint{}.DataSourceAttributes(),
}
}
Expand Down
6 changes: 6 additions & 0 deletions apstra/data_source_datacenter_ct_static_route.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package tfapstra

import (
"context"

connectivitytemplate "github.com/Juniper/terraform-provider-apstra/apstra/connectivity_template"
"github.com/hashicorp/terraform-plugin-framework/datasource"
"github.com/hashicorp/terraform-plugin-framework/datasource/schema"
Expand All @@ -21,6 +22,11 @@ func (o *dataSourceDatacenterCtStaticRoute) Schema(_ context.Context, _ datasour
MarkdownDescription: docCategoryDatacenter + "This data source composes a Connectivity Template Primitive as a JSON string, " +
"suitable for use in the `primitives` attribute of an `apstra_datacenter_connectivity_template` " +
"resource or the `child_primitives` attribute of a Different Connectivity Template Primitive.",
DeprecationMessage: "This data source will be removed in a future version. Please migrate your use of the " +
"`apstra_datacenter_connectivity_template` resource (the likely reason this data source is being invoked) " +
"to one of the new resources which do not depend on this data source: " +
"`apstra_datacenter_connectivity_template_interface`, `apstra_datacenter_connectivity_template_loopback`, " +
"`apstra_datacenter_connectivity_template_svi`, or `apstra_datacenter_connectivity_template_system`.",
Attributes: connectivitytemplate.StaticRoute{}.DataSourceAttributes(),
}
}
Expand Down
6 changes: 6 additions & 0 deletions apstra/data_source_datacenter_ct_virtual_network_multiple.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package tfapstra

import (
"context"

connectivitytemplate "github.com/Juniper/terraform-provider-apstra/apstra/connectivity_template"
"github.com/hashicorp/terraform-plugin-framework/datasource"
"github.com/hashicorp/terraform-plugin-framework/datasource/schema"
Expand All @@ -21,6 +22,11 @@ func (o *dataSourceDatacenterCtVnMultiple) Schema(_ context.Context, _ datasourc
MarkdownDescription: docCategoryDatacenter + "This data source composes a Connectivity Template Primitive as a JSON string, " +
"suitable for use in the `primitives` attribute of an `apstra_datacenter_connectivity_template` " +
"resource or the `child_primitives` attribute of a Different Connectivity Template Primitive.",
DeprecationMessage: "This data source will be removed in a future version. Please migrate your use of the " +
"`apstra_datacenter_connectivity_template` resource (the likely reason this data source is being invoked) " +
"to one of the new resources which do not depend on this data source: " +
"`apstra_datacenter_connectivity_template_interface`, `apstra_datacenter_connectivity_template_loopback`, " +
"`apstra_datacenter_connectivity_template_svi`, or `apstra_datacenter_connectivity_template_system`.",
Attributes: connectivitytemplate.VnMultiple{}.DataSourceAttributes(),
}
}
Expand Down
6 changes: 6 additions & 0 deletions apstra/data_source_datacenter_ct_virtual_network_single.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package tfapstra

import (
"context"

connectivitytemplate "github.com/Juniper/terraform-provider-apstra/apstra/connectivity_template"
"github.com/hashicorp/terraform-plugin-framework/datasource"
"github.com/hashicorp/terraform-plugin-framework/datasource/schema"
Expand All @@ -21,6 +22,11 @@ func (o *dataSourceDatacenterCtVnSingle) Schema(_ context.Context, _ datasource.
MarkdownDescription: docCategoryDatacenter + "This data source composes a Connectivity Template Primitive as a JSON string, " +
"suitable for use in the `primitives` attribute of an `apstra_datacenter_connectivity_template` " +
"resource or the `child_primitives` attribute of a Different Connectivity Template Primitive.",
DeprecationMessage: "This data source will be removed in a future version. Please migrate your use of the " +
"`apstra_datacenter_connectivity_template` resource (the likely reason this data source is being invoked) " +
"to one of the new resources which do not depend on this data source: " +
"`apstra_datacenter_connectivity_template_interface`, `apstra_datacenter_connectivity_template_loopback`, " +
"`apstra_datacenter_connectivity_template_svi`, or `apstra_datacenter_connectivity_template_system`.",
Attributes: connectivitytemplate.VnSingle{}.DataSourceAttributes(),
}
}
Expand Down
15 changes: 11 additions & 4 deletions apstra/resource_datacenter_connectivity_template.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package tfapstra
import (
"context"
"fmt"

"github.com/Juniper/apstra-go-sdk/apstra"
"github.com/Juniper/terraform-provider-apstra/apstra/blueprint"
"github.com/Juniper/terraform-provider-apstra/apstra/utils"
Expand All @@ -11,9 +12,11 @@ import (
"github.com/hashicorp/terraform-plugin-framework/types"
)

var _ resource.ResourceWithConfigure = &resourceDatacenterConnectivityTemplate{}
var _ resourceWithSetDcBpClientFunc = &resourceDatacenterConnectivityTemplate{}
var _ resourceWithSetBpLockFunc = &resourceDatacenterConnectivityTemplate{}
var (
_ resource.ResourceWithConfigure = &resourceDatacenterConnectivityTemplate{}
_ resourceWithSetDcBpClientFunc = &resourceDatacenterConnectivityTemplate{}
_ resourceWithSetBpLockFunc = &resourceDatacenterConnectivityTemplate{}
)

type resourceDatacenterConnectivityTemplate struct {
getBpClientFunc func(context.Context, string) (*apstra.TwoStageL3ClosClient, error)
Expand All @@ -31,7 +34,11 @@ func (o *resourceDatacenterConnectivityTemplate) Configure(ctx context.Context,
func (o *resourceDatacenterConnectivityTemplate) Schema(_ context.Context, _ resource.SchemaRequest, resp *resource.SchemaResponse) {
resp.Schema = schema.Schema{
MarkdownDescription: docCategoryDatacenter + "This resource creates a Connectivity Template within a Datacenter Blueprint.",
Attributes: blueprint.ConnectivityTemplate{}.ResourceAttributes(),
DeprecationMessage: "This resource will be removed in a future version. Please migrate your configurations to use " +
"one of the new Connectivity Template resources: `apstra_datacenter_connectivity_template_interface`, " +
"`apstra_datacenter_connectivity_template_loopback`, `apstra_datacenter_connectivity_template_svi`, or " +
"`apstra_datacenter_connectivity_template_system`.",
Attributes: blueprint.ConnectivityTemplate{}.ResourceAttributes(),
}
}

Expand Down

0 comments on commit 391840e

Please sign in to comment.