From 02d9fa4868b732994413ab48ac73956d7fbde0aa Mon Sep 17 00:00:00 2001 From: Aristides Neto Date: Sat, 19 Oct 2024 08:29:02 -0300 Subject: [PATCH 1/3] Updating provider fields documentation --- internal/provider/resource_acl_destination_rule.go | 8 ++++++++ internal/provider/utils.go | 2 ++ 2 files changed, 10 insertions(+) diff --git a/internal/provider/resource_acl_destination_rule.go b/internal/provider/resource_acl_destination_rule.go index 1ab6832..6bb2579 100644 --- a/internal/provider/resource_acl_destination_rule.go +++ b/internal/provider/resource_acl_destination_rule.go @@ -45,6 +45,7 @@ func resourceACLDestinationRule() *schema.Resource { Type: schema.TypeString, ExactlyOneOf: oneDestination, ValidateFunc: validation.IsCIDR, + Description: "Destination IP address", }, "dns": { @@ -52,6 +53,7 @@ func resourceACLDestinationRule() *schema.Resource { ForceNew: true, Type: schema.TypeString, ExactlyOneOf: oneDestination, + Description: "Destination fully qualified domain name (FQDN)", }, "app": { @@ -59,6 +61,7 @@ func resourceACLDestinationRule() *schema.Resource { ForceNew: true, Type: schema.TypeString, ExactlyOneOf: oneDestination, + Description: "Destination tsuru app name", }, "pool": { @@ -66,6 +69,7 @@ func resourceACLDestinationRule() *schema.Resource { ForceNew: true, Type: schema.TypeString, ExactlyOneOf: oneDestination, + Description: "Tsuru Pool name", }, "rpaas": { @@ -76,23 +80,27 @@ func resourceACLDestinationRule() *schema.Resource { MinItems: 1, ExactlyOneOf: oneDestination, Elem: rpaasSchema("rpaas"), + Description: "Destination tsuru rpaas name", }, "port": { Optional: true, ForceNew: true, Type: schema.TypeList, + Description: "Destination port and protocol list", ConflictsWith: []string{"app", "rpaas"}, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ "protocol": { Type: schema.TypeString, + Description: "Procotol name (ex: TCP, UDP, tcp, udp...)", Required: true, ForceNew: true, ValidateFunc: validation.StringInSlice([]string{"TCP", "UDP", "tcp", "udp"}, false), }, "number": { Type: schema.TypeInt, + Description: "Port number", Required: true, ForceNew: true, ValidateFunc: validation.IsPortNumber, diff --git a/internal/provider/utils.go b/internal/provider/utils.go index 744b066..2e1b534 100644 --- a/internal/provider/utils.go +++ b/internal/provider/utils.go @@ -130,12 +130,14 @@ func rpaasSchema(baseName string) *schema.Resource { Schema: map[string]*schema.Schema{ "service_name": { Type: schema.TypeString, + Description: "Destination rpaas service name (ex: rpaasv2-be, rpaasv2-fe)", Optional: true, ForceNew: true, ExactlyOneOf: []string{baseName + ".0.service_name"}, }, "instance": { Type: schema.TypeString, + Description: "Destination rpaas instance name", Optional: true, ForceNew: true, ExactlyOneOf: []string{baseName + ".0.instance"}, From 73180b16cb782ccdbdb7b9e48573197047cf77a2 Mon Sep 17 00:00:00 2001 From: Aristides Neto Date: Sat, 19 Oct 2024 08:30:41 -0300 Subject: [PATCH 2/3] Removed condition that appeared to be unused --- internal/provider/resource_acl_destination_rule.go | 4 ---- 1 file changed, 4 deletions(-) diff --git a/internal/provider/resource_acl_destination_rule.go b/internal/provider/resource_acl_destination_rule.go index 6bb2579..31115c3 100644 --- a/internal/provider/resource_acl_destination_rule.go +++ b/internal/provider/resource_acl_destination_rule.go @@ -164,10 +164,6 @@ func resourceACLDestinationRuleCreate(ctx context.Context, d *schema.ResourceDat return resource.NonRetryableError(err) } - if err != nil { - return resource.NonRetryableError(err) - } - d.SetId(rule.RuleID) return nil }) From f37a69aef8d775580bb03dd6ea20763025dd4ba0 Mon Sep 17 00:00:00 2001 From: Aristides Neto Date: Sat, 19 Oct 2024 08:31:24 -0300 Subject: [PATCH 3/3] Removed function that was not used in the code --- internal/provider/utils.go | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/internal/provider/utils.go b/internal/provider/utils.go index 2e1b534..fe53bce 100644 --- a/internal/provider/utils.go +++ b/internal/provider/utils.go @@ -106,25 +106,6 @@ func parseTsuruApp(d *schema.ResourceData) *types.TsuruAppRule { } } -func tsuruSchema(baseName string) *schema.Resource { - return &schema.Resource{ - Schema: map[string]*schema.Schema{ - "name": { - Type: schema.TypeString, - Optional: true, - ForceNew: true, - ExactlyOneOf: []string{baseName + ".0.pool"}, - }, - "pool": { - Type: schema.TypeString, - Optional: true, - ForceNew: true, - ExactlyOneOf: []string{baseName + ".0.name"}, - }, - }, - } -} - func rpaasSchema(baseName string) *schema.Resource { return &schema.Resource{ Schema: map[string]*schema.Schema{