Skip to content

Commit

Permalink
Merge pull request #6 from aristidesneto/feat/update-doc
Browse files Browse the repository at this point in the history
Updated documentation
  • Loading branch information
wpjunior authored Oct 21, 2024
2 parents 2e45174 + f37a69a commit 2da9f0b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 23 deletions.
12 changes: 8 additions & 4 deletions internal/provider/resource_acl_destination_rule.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,27 +45,31 @@ func resourceACLDestinationRule() *schema.Resource {
Type: schema.TypeString,
ExactlyOneOf: oneDestination,
ValidateFunc: validation.IsCIDR,
Description: "Destination IP address",
},

"dns": {
Optional: true,
ForceNew: true,
Type: schema.TypeString,
ExactlyOneOf: oneDestination,
Description: "Destination fully qualified domain name (FQDN)",
},

"app": {
Optional: true,
ForceNew: true,
Type: schema.TypeString,
ExactlyOneOf: oneDestination,
Description: "Destination tsuru app name",
},

"pool": {
Optional: true,
ForceNew: true,
Type: schema.TypeString,
ExactlyOneOf: oneDestination,
Description: "Tsuru Pool name",
},

"rpaas": {
Expand All @@ -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,
Expand Down Expand Up @@ -156,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
})
Expand Down
21 changes: 2 additions & 19 deletions internal/provider/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,36 +106,19 @@ 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{
"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"},
Expand Down

0 comments on commit 2da9f0b

Please sign in to comment.