Skip to content

Commit a821390

Browse files
mikhail-putilovMikhail Putilov
authored andcommitted
Revert (#747) as a fix for (#870) and (#1007)
Signed-off-by: Mikhail Putilov <[email protected]>
1 parent be3b093 commit a821390

File tree

4 files changed

+14
-59
lines changed

4 files changed

+14
-59
lines changed

provider/data_source_keycloak_openid_client.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -110,19 +110,19 @@ func dataSourceKeycloakOpenidClient() *schema.Resource {
110110
},
111111
"client_offline_session_idle_timeout": {
112112
Type: schema.TypeString,
113-
Computed: true,
113+
Optional: true,
114114
},
115115
"client_offline_session_max_lifespan": {
116116
Type: schema.TypeString,
117-
Computed: true,
117+
Optional: true,
118118
},
119119
"client_session_idle_timeout": {
120120
Type: schema.TypeString,
121-
Computed: true,
121+
Optional: true,
122122
},
123123
"client_session_max_lifespan": {
124124
Type: schema.TypeString,
125-
Computed: true,
125+
Optional: true,
126126
},
127127
"exclude_session_state_from_auth_response": {
128128
Type: schema.TypeBool,

provider/resource_keycloak_openid_client.go

Lines changed: 10 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ func resourceKeycloakOpenidClient() *schema.Resource {
4848
"name": {
4949
Type: schema.TypeString,
5050
Optional: true,
51-
Computed: true,
5251
},
5352
"enabled": {
5453
Type: schema.TypeBool,
@@ -58,7 +57,6 @@ func resourceKeycloakOpenidClient() *schema.Resource {
5857
"description": {
5958
Type: schema.TypeString,
6059
Optional: true,
61-
Computed: true,
6260
},
6361
"access_type": {
6462
Type: schema.TypeString,
@@ -106,34 +104,33 @@ func resourceKeycloakOpenidClient() *schema.Resource {
106104
"standard_flow_enabled": {
107105
Type: schema.TypeBool,
108106
Optional: true,
109-
Computed: true,
107+
Default: false,
110108
},
111109
"implicit_flow_enabled": {
112110
Type: schema.TypeBool,
113111
Optional: true,
114-
Computed: true,
112+
Default: false,
115113
},
116114
"direct_access_grants_enabled": {
117115
Type: schema.TypeBool,
118116
Optional: true,
119-
Computed: true,
117+
Default: false,
120118
},
121119
"service_accounts_enabled": {
122120
Type: schema.TypeBool,
123121
Optional: true,
124-
Computed: true,
122+
Default: false,
125123
},
126124
"frontchannel_logout_enabled": {
127125
Type: schema.TypeBool,
128126
Optional: true,
129-
Computed: true,
127+
Default: false,
130128
},
131129
"valid_redirect_uris": {
132130
Type: schema.TypeSet,
133131
Elem: &schema.Schema{Type: schema.TypeString},
134132
Set: schema.HashString,
135133
Optional: true,
136-
Computed: true,
137134
},
138135
"valid_post_logout_redirect_uris": {
139136
Type: schema.TypeSet,
@@ -147,22 +144,18 @@ func resourceKeycloakOpenidClient() *schema.Resource {
147144
Elem: &schema.Schema{Type: schema.TypeString},
148145
Set: schema.HashString,
149146
Optional: true,
150-
Computed: true,
151147
},
152148
"root_url": {
153149
Type: schema.TypeString,
154150
Optional: true,
155-
Computed: true,
156151
},
157152
"admin_url": {
158153
Type: schema.TypeString,
159154
Optional: true,
160-
Computed: true,
161155
},
162156
"base_url": {
163157
Type: schema.TypeString,
164158
Optional: true,
165-
Computed: true,
166159
},
167160
"service_account_user_id": {
168161
Type: schema.TypeString,
@@ -176,27 +169,22 @@ func resourceKeycloakOpenidClient() *schema.Resource {
176169
"access_token_lifespan": {
177170
Type: schema.TypeString,
178171
Optional: true,
179-
Computed: true,
180172
},
181173
"client_offline_session_idle_timeout": {
182174
Type: schema.TypeString,
183175
Optional: true,
184-
Computed: true,
185176
},
186177
"client_offline_session_max_lifespan": {
187178
Type: schema.TypeString,
188179
Optional: true,
189-
Computed: true,
190180
},
191181
"client_session_idle_timeout": {
192182
Type: schema.TypeString,
193183
Optional: true,
194-
Computed: true,
195184
},
196185
"client_session_max_lifespan": {
197186
Type: schema.TypeString,
198187
Optional: true,
199-
Computed: true,
200188
},
201189
"exclude_session_state_from_auth_response": {
202190
Type: schema.TypeBool,
@@ -250,17 +238,16 @@ func resourceKeycloakOpenidClient() *schema.Resource {
250238
"consent_required": {
251239
Type: schema.TypeBool,
252240
Optional: true,
253-
Computed: true,
241+
Default: false,
254242
},
255243
"display_on_consent_screen": {
256244
Type: schema.TypeBool,
257245
Optional: true,
258-
Computed: true,
246+
Default: false,
259247
},
260248
"consent_screen_text": {
261249
Type: schema.TypeString,
262250
Optional: true,
263-
Computed: true,
264251
},
265252
"authentication_flow_binding_overrides": {
266253
Type: schema.TypeSet,
@@ -342,12 +329,6 @@ func resourceKeycloakOpenidClient() *schema.Resource {
342329
Optional: true,
343330
Default: false,
344331
},
345-
"import": {
346-
Type: schema.TypeBool,
347-
Optional: true,
348-
Default: false,
349-
ForceNew: true,
350-
},
351332
},
352333
CustomizeDiff: resourceKeycloakOpenidClientDiff(),
353334
}
@@ -603,25 +584,9 @@ func resourceKeycloakOpenidClientCreate(ctx context.Context, data *schema.Resour
603584
return diag.FromErr(err)
604585
}
605586

606-
if data.Get("import").(bool) {
607-
existingClient, err := keycloakClient.GetOpenidClientByClientId(ctx, client.RealmId, client.ClientId)
608-
if err != nil {
609-
return diag.FromErr(err)
610-
}
611-
612-
if err = mergo.Merge(client, existingClient); err != nil {
613-
return diag.FromErr(err)
614-
}
615-
616-
err = keycloakClient.UpdateOpenidClient(ctx, client)
617-
if err != nil {
618-
return diag.FromErr(err)
619-
}
620-
} else {
621-
err = keycloakClient.NewOpenidClient(ctx, client)
622-
if err != nil {
623-
return diag.FromErr(err)
624-
}
587+
err = keycloakClient.NewOpenidClient(ctx, client)
588+
if err != nil {
589+
return diag.FromErr(err)
625590
}
626591

627592
err = setOpenidClientData(ctx, keycloakClient, data, client)
@@ -648,10 +613,6 @@ func resourceKeycloakOpenidClientRead(ctx context.Context, data *schema.Resource
648613
return diag.FromErr(err)
649614
}
650615

651-
if _, ok := data.GetOk("import"); !ok {
652-
data.Set("import", false)
653-
}
654-
655616
return nil
656617
}
657618

@@ -687,9 +648,6 @@ func resourceKeycloakOpenidClientUpdate(ctx context.Context, data *schema.Resour
687648
}
688649

689650
func resourceKeycloakOpenidClientDelete(ctx context.Context, data *schema.ResourceData, meta interface{}) diag.Diagnostics {
690-
if data.Get("import").(bool) {
691-
return nil
692-
}
693651
keycloakClient := meta.(*keycloak.KeycloakClient)
694652

695653
realmId := data.Get("realm_id").(string)

provider/resource_keycloak_openid_client_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2102,7 +2102,6 @@ resource "keycloak_openid_client" "client" {
21022102
access_type = "PUBLIC"
21032103
root_url = ""
21042104
enabled = %t
2105-
import = true
21062105
}
21072106
`, testAccRealm.Realm, clientId, enabled)
21082107
}

provider/resource_keycloak_role_test.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -846,7 +846,6 @@ data "keycloak_realm" "realm" {
846846
resource "keycloak_openid_client" "imported-client" {
847847
realm_id = data.keycloak_realm.realm.id
848848
client_id = "%s"
849-
import = true
850849
access_type = "PUBLIC"
851850
}
852851
resource "keycloak_role" "imported-client-role" {
@@ -866,7 +865,6 @@ data "keycloak_realm" "realm" {
866865
resource "keycloak_openid_client" "imported-client" {
867866
realm_id = data.keycloak_realm.realm.id
868867
client_id = "%s"
869-
import = true
870868
access_type = "PUBLIC"
871869
}
872870
resource "keycloak_role" "imported-client-role" {

0 commit comments

Comments
 (0)