Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated documentation #6

Merged
merged 3 commits into from
Oct 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading