Skip to content

Commit

Permalink
Small tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
sergiught committed Aug 31, 2023
1 parent dadd368 commit 6a3234c
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions internal/auth0/connection/expand.go
Original file line number Diff line number Diff line change
Expand Up @@ -781,6 +781,11 @@ func expandConnectionOptionsScopes(data *schema.ResourceData, options scoper) {
}
}

// passThroughUnconfigurableConnectionOptions ensures that read-only connection options
// set by external services do not get removed from the connection resource.
//
// This is necessary because the "/api/v2/connections/{id}" endpoint does not follow usual
// PATCH behavior, the 'options' property is entirely replaced by the payload object.
func passThroughUnconfigurableConnectionOptions(
ctx context.Context,
api *management.Management,
Expand Down Expand Up @@ -817,6 +822,10 @@ func passThroughUnconfigurableConnectionOptionsAD(
return err
}

if existingConnection.Options == nil {
return nil
}

existingOptions := existingConnection.Options.(*management.ConnectionOptionsAD)

expandedOptions := connection.Options.(*management.ConnectionOptionsAD)
Expand All @@ -842,6 +851,10 @@ func passThroughUnconfigurableConnectionOptionsAzureAD(
return err
}

if existingConnection.Options == nil {
return nil
}

existingOptions := existingConnection.Options.(*management.ConnectionOptionsAzureAD)

expandedOptions := connection.Options.(*management.ConnectionOptionsAzureAD)
Expand All @@ -867,6 +880,10 @@ func passThroughUnconfigurableConnectionOptionsADFS(
return err
}

if existingConnection.Options == nil {
return nil
}

existingOptions := existingConnection.Options.(*management.ConnectionOptionsADFS)

expandedOptions := connection.Options.(*management.ConnectionOptionsADFS)
Expand All @@ -891,6 +908,10 @@ func passThroughUnconfigurableConnectionOptionsSAML(
return err
}

if existingConnection.Options == nil {
return nil
}

existingOptions := existingConnection.Options.(*management.ConnectionOptionsSAML)

expandedOptions := connection.Options.(*management.ConnectionOptionsSAML)
Expand Down Expand Up @@ -919,6 +940,10 @@ func passThroughUnconfigurableConnectionOptionsPingFederate(
return err
}

if existingConnection.Options == nil {
return nil
}

existingOptions := existingConnection.Options.(*management.ConnectionOptionsPingFederate)

expandedOptions := connection.Options.(*management.ConnectionOptionsPingFederate)
Expand Down

0 comments on commit 6a3234c

Please sign in to comment.