Skip to content

Commit

Permalink
doc: update offer_url use in integration resource
Browse files Browse the repository at this point in the history
Per juju#449, indicate that offer_url and name/endpoint are mutually
exclusive in an integration resource.
  • Loading branch information
hmlanigan committed Oct 23, 2024
1 parent e40722b commit 09a268d
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 12 deletions.
9 changes: 4 additions & 5 deletions examples/resources/juju_offer/resource.tf
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
resource "juju_offer" "this" {
resource "juju_offer" "myoffer" {
model = juju_model.development.name
application_name = juju_application.percona-cluster.name
endpoint = server
}

// an offer can then be used in an integration as below:
resource "juju_integration" "this" {
// an offer can then be used in an cross model integration as below:
resource "juju_integration" "myintegration" {
model = juju_model.development-destination.name

application {
name = juju_application.wordpress.name
endpoint = "db"
}

application {
offer_url = juju_offer.this.url
offer_url = juju_offer.myoffer.url
}
}
28 changes: 21 additions & 7 deletions internal/provider/resource_integration.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"strings"

"github.com/hashicorp/terraform-plugin-framework-validators/setvalidator"
"github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator"
"github.com/hashicorp/terraform-plugin-framework/diag"
"github.com/hashicorp/terraform-plugin-framework/path"
"github.com/hashicorp/terraform-plugin-framework/resource"
Expand Down Expand Up @@ -138,20 +139,33 @@ func (r *integrationResource) Schema(_ context.Context, _ resource.SchemaRequest
NestedObject: schema.NestedBlockObject{
Attributes: map[string]schema.Attribute{
"name": schema.StringAttribute{
Description: "The name of the application.",
Optional: true,
Description: "The name of the application. This attribute may not be used at the" +
" same time as the offer_url.",
Optional: true,
Validators: stringvalidator.ConflictsWith(
path.MatchRelative().AtParent().AtName("offer_url"),
),
},
"endpoint": schema.StringAttribute{
Description: "The endpoint name.",
Optional: true,
Computed: true,
Description: "The endpoint name. This attribute may not be used at the" +
" same time as the offer_url.",
Optional: true,
Computed: true,
Validators: stringvalidator.ConflictsWith(
path.MatchRelative().AtParent().AtName("offer_url"),
),
},
"offer_url": schema.StringAttribute{
Description: "The URL of a remote application.",
Optional: true,
Description: "The URL of a remote application. This attribute may not be used at the" +
"same time as name and endpoint.",
Optional: true,
PlanModifiers: []planmodifier.String{
stringplanmodifier.UseStateForUnknown(),
},
Validators: stringvalidator.ConflictsWith(
path.MatchRelative().AtParent().AtName("name"),
path.MatchRelative().AtParent().AtName("endpoint"),
),
},
},
},
Expand Down

0 comments on commit 09a268d

Please sign in to comment.