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

Force replace when changing display_name of databricks_service_principal #1783

Merged
merged 2 commits into from
Nov 21, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 1 addition & 1 deletion scim/resource_service_principal.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ func (a ServicePrincipalsAPI) Delete(servicePrincipalID string) error {
func ResourceServicePrincipal() *schema.Resource {
type entity struct {
ApplicationID string `json:"application_id,omitempty" tf:"computed,force_new"`
DisplayName string `json:"display_name,omitempty" tf:"computed"`
DisplayName string `json:"display_name,omitempty" tf:"computed,force_new"`
Active bool `json:"active,omitempty"`
ExternalID string `json:"external_id,omitempty" tf:"suppress_diff"`
}
Expand Down
50 changes: 35 additions & 15 deletions scim/resource_service_principal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ func TestResourceServicePrincipalUpdateOnAWS(t *testing.T) {
// application ID is not allowed to be modified by client side on AWS

Schemas: []URN{ServicePrincipalSchema},
DisplayName: "Changed Name",
DisplayName: "Example Service Principal",
Active: true,
Entitlements: entitlements{
{
Expand All @@ -249,7 +249,7 @@ func TestResourceServicePrincipalUpdateOnAWS(t *testing.T) {
Response: User{
Schemas: []URN{ServicePrincipalSchema},
ApplicationID: "existing-application-id",
DisplayName: "Changed Name",
DisplayName: "Example Service Principal",
Active: true,
Entitlements: entitlements{
{
Expand All @@ -270,15 +270,18 @@ func TestResourceServicePrincipalUpdateOnAWS(t *testing.T) {
},
},
Resource: ResourceServicePrincipal(),
Update: true,
ID: "abc",
InstanceState: map[string]string{
"display_name": "Example Service Principal",
},
Update: true,
ID: "abc",
HCL: `
display_name = "Changed Name"
display_name = "Example Service Principal"
allow_cluster_create = false
allow_instance_pool_create = true
`,
}.ApplyAndExpectData(t, map[string]any{
"display_name": "Changed Name",
"display_name": "Example Service Principal",
"allow_cluster_create": false,
"allow_instance_pool_create": true,
})
Expand Down Expand Up @@ -309,8 +312,13 @@ func TestResourceServicePrincipalUpdateOnAzure(t *testing.T) {
ApplicationID: "existing-application-id",

Schemas: []URN{ServicePrincipalSchema},
DisplayName: "Changed Name",
Active: true,
DisplayName: "Example Service Principal",
Entitlements: entitlements{
{
Value: "allow-cluster-create",
},
},
Active: true,
},
},
{
Expand All @@ -319,8 +327,13 @@ func TestResourceServicePrincipalUpdateOnAzure(t *testing.T) {
Response: User{
Schemas: []URN{ServicePrincipalSchema},
ApplicationID: "existing-application-id",
DisplayName: "Changed Name",
Active: true,
DisplayName: "Example Service Principal",
Entitlements: entitlements{
{
Value: "allow-cluster-create",
},
},
Active: true,
},
},
},
Expand All @@ -333,7 +346,8 @@ func TestResourceServicePrincipalUpdateOnAzure(t *testing.T) {
},
HCL: `
application_id = "existing-application-id"
display_name = "Changed Name"
display_name = "Example Service Principal"
allow_cluster_create = true
`,
}.ApplyNoError(t)
}
Expand All @@ -342,8 +356,11 @@ func TestResourceServicePrincipalUpdate_Error(t *testing.T) {
qa.ResourceFixture{
Fixtures: qa.HTTPFailures,
Resource: ResourceServicePrincipal(),
Update: true,
ID: "abc",
InstanceState: map[string]string{
"display_name": "Changed Name",
},
Update: true,
ID: "abc",
HCL: `
display_name = "Changed Name"
allow_cluster_create = false
Expand Down Expand Up @@ -372,8 +389,11 @@ func TestResourceServicePrincipalUpdate_ErrorPut(t *testing.T) {
qa.HTTPFailures[0],
},
Resource: ResourceServicePrincipal(),
Update: true,
ID: "abc",
InstanceState: map[string]string{
"display_name": "Changed Name",
},
Update: true,
ID: "abc",
HCL: `
display_name = "Changed Name"
allow_cluster_create = false
Expand Down