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 3623caf
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 20 deletions.
6 changes: 3 additions & 3 deletions docs/resources/integration.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,9 @@ resource "juju_integration" "this" {

Optional:

- `endpoint` (String) The endpoint name.
- `name` (String) The name of the application.
- `offer_url` (String) The URL of a remote application.
- `endpoint` (String) The endpoint name. This attribute may not be used at the same time as the offer_url.
- `name` (String) The name of the application. This attribute may not be used at the same time as the offer_url.
- `offer_url` (String) The URL of a remote application. This attribute may not be used at the same time as name and endpoint.


### Notes
Expand Down
9 changes: 4 additions & 5 deletions docs/resources/offer.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,22 @@ A resource that represent a Juju Offer.
## Example Usage

```terraform
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
}
}
```
Expand Down
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
}
}
34 changes: 27 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,39 @@ 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: []validator.String{
stringvalidator.ConflictsWith(path.Expressions{
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: []validator.String{
stringvalidator.ConflictsWith(path.Expressions{
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: []validator.String{
stringvalidator.ConflictsWith(path.Expressions{
path.MatchRelative().AtParent().AtName("name"),
path.MatchRelative().AtParent().AtName("endpoint"),
}...),
},
},
},
},
Expand Down

0 comments on commit 3623caf

Please sign in to comment.