Skip to content

Commit f06ccf3

Browse files
authored
feat: Add write bindings to OIDC provider resource (#86)
1 parent 058f4bd commit f06ccf3

File tree

5 files changed

+51
-18
lines changed

5 files changed

+51
-18
lines changed

docs/resources/oidc_provider.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ description: |-
2626
- `bindings` (Attributes Set) The users and groups able to utilize this provider. (see [below for nested schema](#nestedatt--bindings))
2727
- `description` (String) Description of this OIDC provider.
2828
- `redirect_uris` (Set of String)
29+
- `write_bindings` (Attributes Set) (see [below for nested schema](#nestedatt--write_bindings))
2930

3031
### Read-Only
3132

@@ -41,3 +42,13 @@ Optional:
4142
- `group_id` (String)
4243
- `id` (String)
4344
- `user_id` (String)
45+
46+
47+
<a id="nestedatt--write_bindings"></a>
48+
### Nested Schema for `write_bindings`
49+
50+
Optional:
51+
52+
- `group_id` (String)
53+
- `id` (String)
54+
- `user_id` (String)

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ require (
1212
github.com/hashicorp/terraform-plugin-framework-validators v0.16.0
1313
github.com/hashicorp/terraform-plugin-log v0.9.0
1414
github.com/mitchellh/go-homedir v1.1.0
15-
github.com/pluralsh/console/go/client v1.33.0
15+
github.com/pluralsh/console/go/client v1.35.0
1616
github.com/pluralsh/plural-cli v0.12.1
1717
github.com/pluralsh/polly v0.2.0
1818
github.com/samber/lo v1.49.1

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -618,8 +618,8 @@ github.com/pjbgf/sha1cd v0.3.2/go.mod h1:zQWigSxVmsHEZow5qaLtPYxpcKMMQpa09ixqBxu
618618
github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
619619
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
620620
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
621-
github.com/pluralsh/console/go/client v1.33.0 h1:rsp3zopb0wdMEvvQ+dOTM+I3qCoFWOk62JETwIPJrFw=
622-
github.com/pluralsh/console/go/client v1.33.0/go.mod h1:rPx6hufc/s17Wzy+7C4ZnA1nmn1JR0m4JeoxAQYj8+4=
621+
github.com/pluralsh/console/go/client v1.35.0 h1:SJ72OQOKaWpjtLDQhX4h+Wvaror0DlriMOjli28LlW8=
622+
github.com/pluralsh/console/go/client v1.35.0/go.mod h1:rPx6hufc/s17Wzy+7C4ZnA1nmn1JR0m4JeoxAQYj8+4=
623623
github.com/pluralsh/gqlclient v1.12.2 h1:BrEFAASktf4quFw57CIaLAd+NZUTLhG08fe6tnhBQN4=
624624
github.com/pluralsh/gqlclient v1.12.2/go.mod h1:OEjN9L63x8m3A3eQBv5kVkFgiY9fp2aZ0cgOF0uII58=
625625
github.com/pluralsh/plural-cli v0.12.1 h1:+bcYoepZ2tT1qRwb5RgXnVPs23RO7X+T0iTgVECBpa4=

internal/model/oidc_provider.go

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13,24 +13,26 @@ import (
1313
)
1414

1515
type OIDCProvider struct {
16-
ID types.String `tfsdk:"id"`
17-
Name types.String `tfsdk:"name"`
18-
Type types.String `tfsdk:"type"`
19-
Description types.String `tfsdk:"description"`
20-
ClientID types.String `tfsdk:"client_id"`
21-
ClientSecret types.String `tfsdk:"client_secret"`
22-
AuthMethod types.String `tfsdk:"auth_method"`
23-
RedirectURIs types.Set `tfsdk:"redirect_uris"`
24-
Bindings types.Set `tfsdk:"bindings"`
16+
ID types.String `tfsdk:"id"`
17+
Name types.String `tfsdk:"name"`
18+
Type types.String `tfsdk:"type"`
19+
Description types.String `tfsdk:"description"`
20+
ClientID types.String `tfsdk:"client_id"`
21+
ClientSecret types.String `tfsdk:"client_secret"`
22+
AuthMethod types.String `tfsdk:"auth_method"`
23+
RedirectURIs types.Set `tfsdk:"redirect_uris"`
24+
Bindings types.Set `tfsdk:"bindings"`
25+
WriteBindings types.Set `tfsdk:"write_bindings"`
2526
}
2627

2728
func (p *OIDCProvider) Attributes(ctx context.Context, d *diag.Diagnostics) gqlclient.OidcProviderAttributes {
2829
return gqlclient.OidcProviderAttributes{
29-
Name: p.Name.ValueString(),
30-
Description: p.descriptionAttribute(),
31-
AuthMethod: p.authMethodAttribute(),
32-
RedirectUris: p.redirectURIsAttribute(ctx, d),
33-
Bindings: common.SetToPolicyBindingAttributes(p.Bindings, ctx, d),
30+
Name: p.Name.ValueString(),
31+
Description: p.descriptionAttribute(),
32+
AuthMethod: p.authMethodAttribute(),
33+
RedirectUris: p.redirectURIsAttribute(ctx, d),
34+
Bindings: common.SetToPolicyBindingAttributes(p.Bindings, ctx, d),
35+
WriteBindings: common.SetToPolicyBindingAttributes(p.WriteBindings, ctx, d),
3436
}
3537
}
3638

internal/resource/oidc_provider.go

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ func (r *OIDCProviderResource) Schema(_ context.Context, _ resource.SchemaReques
9494
ElementType: types.StringType,
9595
},
9696
"bindings": schema.SetNestedAttribute{
97-
Description: "The users and groups able to utilize this provider..",
97+
Description: "The users and groups able to utilize this provider.",
9898
MarkdownDescription: "The users and groups able to utilize this provider.",
9999
Optional: true,
100100
NestedObject: schema.NestedAttributeObject{
@@ -115,6 +115,26 @@ func (r *OIDCProviderResource) Schema(_ context.Context, _ resource.SchemaReques
115115
},
116116
PlanModifiers: []planmodifier.Set{setplanmodifier.RequiresReplace()},
117117
},
118+
"write_bindings": schema.SetNestedAttribute{
119+
Optional: true,
120+
NestedObject: schema.NestedAttributeObject{
121+
Attributes: map[string]schema.Attribute{
122+
"group_id": schema.StringAttribute{
123+
Optional: true,
124+
PlanModifiers: []planmodifier.String{stringplanmodifier.RequiresReplace()},
125+
},
126+
"id": schema.StringAttribute{
127+
Optional: true,
128+
PlanModifiers: []planmodifier.String{stringplanmodifier.RequiresReplace()},
129+
},
130+
"user_id": schema.StringAttribute{
131+
Optional: true,
132+
PlanModifiers: []planmodifier.String{stringplanmodifier.RequiresReplace()},
133+
},
134+
},
135+
},
136+
PlanModifiers: []planmodifier.Set{setplanmodifier.RequiresReplace()},
137+
},
118138
},
119139
}
120140
}

0 commit comments

Comments
 (0)