Skip to content

Commit

Permalink
Merge pull request #43 from mittwald/bugfix/app-userinputs-str
Browse files Browse the repository at this point in the history
Fix double-quoting of app user inputs
  • Loading branch information
martin-helmich authored Apr 15, 2024
2 parents ed794b9 + ce80288 commit 8a82e45
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions internal/provider/resource/appresource/model_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"fmt"
"github.com/hashicorp/terraform-plugin-framework/diag"
"github.com/hashicorp/terraform-plugin-framework/path"
"github.com/hashicorp/terraform-plugin-framework/types"
"github.com/hashicorp/terraform-plugin-framework/types/basetypes"
"github.com/mittwald/terraform-provider-mittwald/api/mittwaldv2"
Expand Down Expand Up @@ -57,10 +58,14 @@ func (m *ResourceModel) ToCreateRequest(ctx context.Context, d diag.Diagnostics,
}

for key, value := range m.UserInputs.Elements() {
b.UserInputs = append(b.UserInputs, mittwaldv2.DeMittwaldV1AppSavedUserInput{
Name: key,
Value: value.String(),
})
if s, ok := value.(types.String); ok {
b.UserInputs = append(b.UserInputs, mittwaldv2.DeMittwaldV1AppSavedUserInput{
Name: key,
Value: s.ValueString(),
})
} else {
d.AddAttributeError(path.Root("user_inputs").AtMapKey(key), "invalid type", fmt.Sprintf("expected string, got %T", value))
}
}

return
Expand Down

0 comments on commit 8a82e45

Please sign in to comment.