Skip to content

Commit

Permalink
AntiDDos COO Eip + Name Change for AntiDDoS COO Domain (#5)
Browse files Browse the repository at this point in the history
* Add `st-alicloud_ddoscoo_domain_resources` data source.

* Add `st-alicloud_ddoscoo_instances` data source.

---------

Co-authored-by: Lek <[email protected]>
  • Loading branch information
ruokei and HaloGithub authored Mar 20, 2023
1 parent 1a5286b commit a0d4abc
Show file tree
Hide file tree
Showing 12 changed files with 474 additions and 35 deletions.
10 changes: 8 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,17 @@ scenario. The reason behind every resources and data sources are stated as below
### Data Sources
- **st-alicloud_antiddos_coo_domain**
- **st-alicloud_ddoscoo_domain_resources**
Official AliCloud Terraform provider does not support querying the CNAME of
AntiDDoS domain resources through
[*alicloud_antiddos_coo_domain_resources*](https://registry.terraform.io/providers/aliyun/alicloud/latest/docs/data-sources/ddoscoo_domain_resources).
[*alicloud_ddoscoo_domain_resources*](https://registry.terraform.io/providers/aliyun/alicloud/latest/docs/data-sources/ddoscoo_domain_resources).
- **st-alicloud_ddoscoo_instances**
Official AliCloud Terraform provider does not support querying the EIP of
AntiDDoS instance resources through
[*alicloud_ddoscoo_instances*](https://registry.terraform.io/providers/aliyun/alicloud/latest/docs/data-sources/ddoscoo_instances).
- **st-alicloud_cdn_domain**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,28 +14,28 @@ import (
)

var (
_ datasource.DataSource = &antiddosCooDataSource{}
_ datasource.DataSourceWithConfigure = &antiddosCooDataSource{}
_ datasource.DataSource = &ddoscooDomainResourcesDataSource{}
_ datasource.DataSourceWithConfigure = &ddoscooDomainResourcesDataSource{}
)

func NewAntiddosCooDataSource() datasource.DataSource {
return &antiddosCooDataSource{}
func NewDdosCooDomainResourcesDataSource() datasource.DataSource {
return &ddoscooDomainResourcesDataSource{}
}

type antiddosCooDataSource struct {
type ddoscooDomainResourcesDataSource struct {
client *alicloudAntiddosClient.Client
}

type antiddosCooDataSourceModel struct {
type ddoscooDomainResourcesDataSourceModel struct {
DomainName types.String `tfsdk:"domain_name"`
DomainCName types.String `tfsdk:"domain_cname"`
}

func (d *antiddosCooDataSource) Metadata(_ context.Context, req datasource.MetadataRequest, resp *datasource.MetadataResponse) {
resp.TypeName = req.ProviderTypeName + "_antiddos_coo_domain"
func (d *ddoscooDomainResourcesDataSource) Metadata(_ context.Context, req datasource.MetadataRequest, resp *datasource.MetadataResponse) {
resp.TypeName = req.ProviderTypeName + "_ddoscoo_domain_resources"
}

func (d *antiddosCooDataSource) Schema(_ context.Context, req datasource.SchemaRequest, resp *datasource.SchemaResponse) {
func (d *ddoscooDomainResourcesDataSource) Schema(_ context.Context, req datasource.SchemaRequest, resp *datasource.SchemaResponse) {
resp.Schema = schema.Schema{
Description: "This data source provides the AntiDDoS domain resources of the current AliCloud user.",
Attributes: map[string]schema.Attribute{
Expand All @@ -51,16 +51,16 @@ func (d *antiddosCooDataSource) Schema(_ context.Context, req datasource.SchemaR
}
}

func (d *antiddosCooDataSource) Configure(_ context.Context, req datasource.ConfigureRequest, resp *datasource.ConfigureResponse) {
func (d *ddoscooDomainResourcesDataSource) Configure(_ context.Context, req datasource.ConfigureRequest, resp *datasource.ConfigureResponse) {
if req.ProviderData == nil {
return
}

d.client = req.ProviderData.(alicloudClients).antiddosClient
}

func (d *antiddosCooDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) {
var plan, state antiddosCooDataSourceModel
func (d *ddoscooDomainResourcesDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) {
var plan, state ddoscooDomainResourcesDataSourceModel
diags := req.Config.Get(ctx, &plan)
resp.Diagnostics.Append(diags...)
if resp.Diagnostics.HasError() {
Expand Down
Loading

0 comments on commit a0d4abc

Please sign in to comment.