diff --git a/docs/resources/cdn_origingroup.md b/docs/resources/cdn_origingroup.md index 6f08da5..5b0d3cd 100644 --- a/docs/resources/cdn_origingroup.md +++ b/docs/resources/cdn_origingroup.md @@ -57,6 +57,3 @@ Optional: - `backup` (Boolean) true — The option is active. The origin will not be used until one of active origins become unavailable. false — The option is disabled. - `enabled` (Boolean) The setting allows to enable or disable an Origin source in the Origins group -Read-Only: - -- `id` (Number) The ID of this resource. diff --git a/gcore/resource_gcore_cdn_origin_group.go b/gcore/resource_gcore_cdn_origin_group.go index 37489a3..a2daf7b 100644 --- a/gcore/resource_gcore_cdn_origin_group.go +++ b/gcore/resource_gcore_cdn_origin_group.go @@ -53,10 +53,6 @@ func resourceCDNOriginGroup() *schema.Resource { Computed: true, Description: "true — The option is active. The origin will not be used until one of active origins become unavailable. false — The option is disabled.", }, - "id": { - Type: schema.TypeInt, - Computed: true, - }, }, }, }, @@ -77,7 +73,7 @@ func resourceCDNOriginGroupCreate(ctx context.Context, d *schema.ResourceData, m var req origingroups.GroupRequest req.Name = d.Get("name").(string) req.UseNext = d.Get("use_next").(bool) - req.Origins = setToOriginRequests(d.Get("origin").(*schema.Set)) + req.Sources = setToSourceRequests(d.Get("origin").(*schema.Set)) result, err := client.OriginGroups().Create(ctx, &req) if err != nil { @@ -109,7 +105,7 @@ func resourceCDNOriginGroupRead(ctx context.Context, d *schema.ResourceData, m i d.Set("name", result.Name) d.Set("use_next", result.UseNext) - if err := d.Set("origin", originsToSet(result.Origins)); err != nil { + if err := d.Set("origin", originsToSet(result.Sources)); err != nil { return diag.FromErr(err) } @@ -131,7 +127,7 @@ func resourceCDNOriginGroupUpdate(ctx context.Context, d *schema.ResourceData, m var req origingroups.GroupRequest req.Name = d.Get("name").(string) req.UseNext = d.Get("use_next").(bool) - req.Origins = setToOriginRequests(d.Get("origin").(*schema.Set)) + req.Sources = setToSourceRequests(d.Get("origin").(*schema.Set)) if _, err := client.OriginGroups().Update(ctx, id, &req); err != nil { return diag.FromErr(err) @@ -163,9 +159,9 @@ func resourceCDNOriginGroupDelete(ctx context.Context, d *schema.ResourceData, m return nil } -func setToOriginRequests(s *schema.Set) (origins []origingroups.OriginRequest) { +func setToSourceRequests(s *schema.Set) (origins []origingroups.SourceRequest) { for _, fields := range s.List() { - var originReq origingroups.OriginRequest + var originReq origingroups.SourceRequest for key, val := range fields.(map[string]interface{}) { switch key { @@ -184,12 +180,11 @@ func setToOriginRequests(s *schema.Set) (origins []origingroups.OriginRequest) { return origins } -func originsToSet(origins []origingroups.Origin) *schema.Set { +func originsToSet(origins []origingroups.Source) *schema.Set { s := &schema.Set{F: originSetIDFunc} for _, origin := range origins { fields := make(map[string]interface{}) - fields["id"] = origin.ID fields["source"] = origin.Source fields["enabled"] = origin.Enabled fields["backup"] = origin.Backup @@ -204,7 +199,7 @@ func originSetIDFunc(i interface{}) int { fields := i.(map[string]interface{}) h := md5.New() - key := fmt.Sprintf("%d-%s-%t-%t", fields["id"], fields["source"], fields["enabled"], fields["backup"]) + key := fmt.Sprintf("%d-%s-%t-%t", fields["source"], fields["enabled"], fields["backup"]) log.Printf("[DEBUG] Origin Set ID = %s\n", key) io.WriteString(h, key) diff --git a/go.mod b/go.mod index 9b1b7a4..c3c38ff 100644 --- a/go.mod +++ b/go.mod @@ -6,7 +6,7 @@ require ( github.com/AlekSi/pointer v1.2.0 github.com/G-Core/gcore-dns-sdk-go v0.2.7-0.20230801110428-99ef24b50d4d github.com/G-Core/gcore-storage-sdk-go v0.1.34 - github.com/G-Core/gcorelabscdn-go v0.1.32 + github.com/G-Core/gcorelabscdn-go v1.0.0 github.com/G-Core/gcorelabscloud-go v0.6.2 github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320 github.com/hashicorp/terraform-plugin-sdk/v2 v2.27.0 diff --git a/go.sum b/go.sum index d703104..6910d05 100644 --- a/go.sum +++ b/go.sum @@ -5,9 +5,8 @@ github.com/G-Core/gcore-dns-sdk-go v0.2.7-0.20230801110428-99ef24b50d4d h1:nqduB github.com/G-Core/gcore-dns-sdk-go v0.2.7-0.20230801110428-99ef24b50d4d/go.mod h1:KliUjfPonDvXyAGNiuO+MYVG/7lmWHZ+4Hi0sPxgOjg= github.com/G-Core/gcore-storage-sdk-go v0.1.34 h1:0GPQfz1kA6mQi6fiisGsh0Um4H9PZeHWIPsc825cDrY= github.com/G-Core/gcore-storage-sdk-go v0.1.34/go.mod h1:BUAEZZZJJt/+luRFunqziv3+JnbVMLbQXDWz9kV8Te8= -github.com/G-Core/gcorelabscdn-go v0.1.32 h1:VGSmNdoW3lZm5lNf5lPpcO4lSdJYZIltxWkwfxlfodA= -github.com/G-Core/gcorelabscdn-go v0.1.32/go.mod h1:iSGXaTvZBzDHQW+rKFS918BgFVpONcyLEijwh8WsXpE= -github.com/G-Core/gcorelabscloud-go v0.6.0/go.mod h1:13Z1USxlxPbDFuYQyWqfNexlk4kUvOYTXbnvV/Z1lZo= +github.com/G-Core/gcorelabscdn-go v1.0.0 h1:aPjwy6UWAmi8p+Vi8OEfmDM4bOq5r+rkOi9SebbvPas= +github.com/G-Core/gcorelabscdn-go v1.0.0/go.mod h1:iSGXaTvZBzDHQW+rKFS918BgFVpONcyLEijwh8WsXpE= github.com/G-Core/gcorelabscloud-go v0.6.2 h1:oCo3yurVnGKZLkRuQ7GVQK1LuLFEjq3mFWiX/PUI69M= github.com/G-Core/gcorelabscloud-go v0.6.2/go.mod h1:13Z1USxlxPbDFuYQyWqfNexlk4kUvOYTXbnvV/Z1lZo= github.com/Masterminds/goutils v1.1.1 h1:5nUrii3FMTL5diU80unEVvNevw1nH4+ZV4DSLVJLSYI=