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

fix: added missing planmodifier to the computed IDs #306

Merged
merged 1 commit into from
Jul 20, 2023
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
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import (
"github.com/hashicorp/terraform-plugin-framework/path"
"github.com/hashicorp/terraform-plugin-framework/resource"
"github.com/hashicorp/terraform-plugin-framework/resource/schema"
"github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier"
"github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier"
"github.com/hashicorp/terraform-plugin-framework/schema/validator"

"github.com/SAP/terraform-provider-btp/internal/btpcli"
Expand Down Expand Up @@ -75,6 +77,9 @@ __Further documentation:__
"id": schema.StringAttribute{
MarkdownDescription: "The origin of the identity provider.",
Computed: true,
PlanModifiers: []planmodifier.String{
stringplanmodifier.UseStateForUnknown(),
},
},
"type": schema.StringAttribute{
MarkdownDescription: "The trust type.",
Expand Down
11 changes: 0 additions & 11 deletions internal/provider/resource_subaccount.go
Original file line number Diff line number Diff line change
Expand Up @@ -244,17 +244,6 @@ func (rs *subaccountResource) Create(ctx context.Context, req resource.CreateReq
args.Labels = labels
}

// The BTP CLI and CIS use different parameters for the subaccount usage
// To trigger the right state we must distinguish how to set the value in CREATE scenarios
// Options: "" == ignored in CREATE request, "true" == boolean true in CREATE request, "false" == boolean false in CREATE request
/*if plan.Usage.IsUnknown() || plan.Usage.IsNull() {
// No usage explicitly requested
args.UsedForProduction = ""
} else {
// Explicit setting of usage requested

}
*/
args.UsedForProduction = mapUsageToUsedForProduction(plan.Usage.ValueString())

cliRes, _, err := rs.cli.Accounts.Subaccount.Create(ctx, &args)
Expand Down
5 changes: 5 additions & 0 deletions internal/provider/resource_subaccount_environment_instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import (
"github.com/hashicorp/terraform-plugin-framework/path"
"github.com/hashicorp/terraform-plugin-framework/resource"
"github.com/hashicorp/terraform-plugin-framework/resource/schema"
"github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier"
"github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier"
"github.com/hashicorp/terraform-plugin-framework/schema/validator"
"github.com/hashicorp/terraform-plugin-framework/types"

Expand Down Expand Up @@ -88,6 +90,9 @@ __Further documentation:__
"id": schema.StringAttribute{
MarkdownDescription: "The ID of the environment instance.",
Computed: true,
PlanModifiers: []planmodifier.String{
stringplanmodifier.UseStateForUnknown(),
},
},
"broker_id": schema.StringAttribute{
MarkdownDescription: "The ID of the associated environment broker.",
Expand Down
3 changes: 3 additions & 0 deletions internal/provider/resource_subaccount_service_binding.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,9 @@ func (rs *subaccountServiceBindingResource) Schema(_ context.Context, _ resource
"id": schema.StringAttribute{
MarkdownDescription: "The ID of the service binding.",
Computed: true,
PlanModifiers: []planmodifier.String{
stringplanmodifier.UseStateForUnknown(),
},
},
"ready": schema.BoolAttribute{
MarkdownDescription: "Shows whether the service binding is ready.",
Expand Down
3 changes: 3 additions & 0 deletions internal/provider/resource_subaccount_subscription.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,9 @@ You must be assigned to the subaccount admin role.`,
"id": schema.StringAttribute{
MarkdownDescription: "The technical ID generated by XSUAA for a multitenant application when a consumer subscribes to the application.",
Computed: true,
PlanModifiers: []planmodifier.String{
stringplanmodifier.UseStateForUnknown(),
},
},
"subscription_url": schema.StringAttribute{
MarkdownDescription: "The URL for app users to launch the subscribed application.",
Expand Down
5 changes: 5 additions & 0 deletions internal/provider/resource_subaccount_trust_configuration.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import (
"github.com/hashicorp/terraform-plugin-framework/path"
"github.com/hashicorp/terraform-plugin-framework/resource"
"github.com/hashicorp/terraform-plugin-framework/resource/schema"
"github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier"
"github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier"
"github.com/hashicorp/terraform-plugin-framework/schema/validator"

"github.com/SAP/terraform-provider-btp/internal/btpcli"
Expand Down Expand Up @@ -83,6 +85,9 @@ __Further documentation:__
"id": schema.StringAttribute{
MarkdownDescription: "The origin of the identity provider.",
Computed: true,
PlanModifiers: []planmodifier.String{
stringplanmodifier.UseStateForUnknown(),
},
},
"type": schema.StringAttribute{
MarkdownDescription: "The trust type.",
Expand Down
Loading