Skip to content

Commit

Permalink
linting, tidying
Browse files Browse the repository at this point in the history
  • Loading branch information
manicminer authored and BrendanThompson committed Jun 18, 2024
1 parent 17d51db commit 32d994b
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 21 deletions.
10 changes: 5 additions & 5 deletions docs/resources/synchronization_job_provision_on_demand.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ resource "azuread_application" "example" {
}
resource "azuread_service_principal" "example" {
application_id = azuread_application.example.application_id
use_existing = true
client_id = azuread_application.example.client_id
use_existing = true
}
resource "azuread_synchronization_secret" "example" {
Expand Down Expand Up @@ -91,15 +91,15 @@ The following arguments are supported:

`parameter` block supports the following:

* `rule_id` (Required) The identifier of the synchronizationRule to be applied. This rule ID is defined in the schema for a given synchronization job or template.
* `rule_id` (Required) The identifier of the synchronization rule to be applied. This rule ID is defined in the schema for a given synchronization job or template.
* `subject` (Required) One or more `subject` blocks as documented below.

---

`subject` block supports the following:

* `object_id` (String) The identifier of an object to which a synchronizationJob is to be applied.
* `object_type_name` (String) The type of the object to which a synchronizationJob is to be applied.
* `object_id` (String) The identifier of an object to which a synchronization job is to be applied. Can be one of the following: (1) An onPremisesDistinguishedName for synchronization from Active Directory to Azure AD. (2) The user ID for synchronization from Azure AD to a third-party. (3) The Worker ID of the Workday worker for synchronization from Workday to either Active Directory or Azure AD.
* `object_type_name` (String) The type of the object to which a synchronization job is to be applied. Can be one of the following: `user` for synchronizing between Active Directory and Azure AD, `User` for synchronizing a user between Azure AD and a third-party application, `Worker` for synchronization a user between Workday and either Active Directory or Azure AD, `Group` for synchronizing a group between Azure AD and a third-party application.

## Attributes Reference

Expand Down
2 changes: 1 addition & 1 deletion internal/services/synchronization/synchronization.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func expandSynchronizationJobApplicationParameters(in []interface{}) *[]msgraph.
item := raw.(map[string]interface{})

result = append(result, msgraph.SynchronizationJobApplicationParameters{
Subjects: expandSynchronizationJobSubject(item["subjects"].([]interface{})),
Subjects: expandSynchronizationJobSubject(item["subject"].([]interface{})),
RuleId: pointer.To(item["rule_id"].(string)),
})
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@ import (
"time"

"github.com/hashicorp/go-azure-sdk/sdk/odata"

"github.com/hashicorp/go-uuid"

"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/hashicorp/terraform-provider-azuread/internal/clients"
Expand All @@ -26,8 +24,8 @@ func synchronizationJobProvisionOnDemandResource() *schema.Resource {

Timeouts: &schema.ResourceTimeout{
Create: schema.DefaultTimeout(15 * time.Minute),
Read: schema.DefaultTimeout(5 * time.Minute),
Delete: schema.DefaultTimeout(5 * time.Minute),
Read: schema.DefaultTimeout(1 * time.Minute),
Delete: schema.DefaultTimeout(1 * time.Minute),
},
SchemaVersion: 0,

Expand All @@ -39,12 +37,14 @@ func synchronizationJobProvisionOnDemandResource() *schema.Resource {
ForceNew: true,
ValidateDiagFunc: validation.ValidateDiag(validation.IsUUID),
},

"synchronization_job_id": {
Description: "The identifier for the synchronization jop.",
Type: schema.TypeString,
Required: true,
ForceNew: true,
},

"parameter": {
Description: "Represents the objects that will be provisioned and the synchronization rules executed. The resource is primarily used for on-demand provisioning.",
Type: schema.TypeList,
Expand All @@ -53,11 +53,12 @@ func synchronizationJobProvisionOnDemandResource() *schema.Resource {
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"rule_id": {
Description: "The identifier of the synchronizationRule to be applied. This rule ID is defined in the schema for a given synchronization job or template.",
Description: "The identifier of the synchronization rule to be applied. This rule ID is defined in the schema for a given synchronization job or template.",
Type: schema.TypeString,
Required: true,
ForceNew: true,
},

"subject": {
Description: "The identifiers of one or more objects to which a synchronizationJob is to be applied.",
Type: schema.TypeList,
Expand All @@ -66,12 +67,13 @@ func synchronizationJobProvisionOnDemandResource() *schema.Resource {
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"object_id": {
Description: "The identifier of an object to which a synchronization Job is to be applied. Can be one of the following: (1) An onPremisesDistinguishedName for synchronization from Active Directory to Azure AD. (2) The user ID for synchronization from Azure AD to a third-party. (3) The Worker ID of the Workday worker for synchronization from Workday to either Active Directory or Azure AD.",
Description: "The identifier of an object to which a synchronization job is to be applied. Can be one of the following: (1) An onPremisesDistinguishedName for synchronization from Active Directory to Azure AD. (2) The user ID for synchronization from Azure AD to a third-party. (3) The Worker ID of the Workday worker for synchronization from Workday to either Active Directory or Azure AD.",
Type: schema.TypeString,
Required: true,
},

"object_type_name": {
Description: "The type of the object to which a synchronization Job is to be applied. Can be one of the following: `user` for synchronizing between Active Directory and Azure AD, `User` for synchronizing a user between Azure AD and a third-party application, `Worker` for synchronization a user between Workday and either Active Directory or Azure AD, `Group` for synchronizing a group between Azure AD and a third-party application.",
Description: "The type of the object to which a synchronization job is to be applied. Can be one of the following: `user` for synchronizing between Active Directory and Azure AD, `User` for synchronizing a user between Azure AD and a third-party application, `Worker` for synchronization a user between Workday and either Active Directory or Azure AD, `Group` for synchronizing a group between Azure AD and a third-party application.",
Type: schema.TypeString,
Required: true,
ValidateFunc: validation.StringInSlice([]string{"Group", "user", "User", "Worker"}, false),
Expand All @@ -82,11 +84,14 @@ func synchronizationJobProvisionOnDemandResource() *schema.Resource {
},
},
},

"triggers": {
Type: schema.TypeMap,
Optional: true,
ForceNew: true,
Elem: &schema.Schema{Type: schema.TypeString},
Elem: &schema.Schema{
Type: schema.TypeString,
},
},
},
}
Expand Down Expand Up @@ -122,6 +127,7 @@ func synchronizationProvisionOnDemandResourceCreate(ctx context.Context, d *sche
if job == nil || job.ID == nil {
return tf.ErrorDiagF(errors.New("nil job or job with nil ID was returned"), "API error retrieving job with object ID %q/%s", objectId, jobId)
}

// Create a new synchronization job
synchronizationProvisionOnDemand := &msgraph.SynchronizationJobProvisionOnDemand{
Parameters: expandSynchronizationJobApplicationParameters(d.Get("parameter").([]interface{})),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"testing"

"github.com/hashicorp/go-azure-helpers/lang/pointer"

"github.com/hashicorp/terraform-plugin-testing/terraform"
"github.com/hashicorp/terraform-provider-azuread/internal/acceptance"
"github.com/hashicorp/terraform-provider-azuread/internal/clients"
Expand All @@ -23,12 +22,12 @@ func TestAccSynchronizationJobProvisionOnDemand_basic(t *testing.T) {
{
// The provisioned app isn't actually integrated so this will never work
Config: r.basic(data),
ExpectError: regexp.MustCompile("CredentialsMissing: Please configure provisioning by providing your admin credentials then retry the provision on-demand."),
ExpectError: regexp.MustCompile("CredentialsMissing: Please configure provisioning"),
},
})
}

func (r SynchronizationJobProvisionOnDemandResource) Exists(ctx context.Context, client *clients.Client, state *terraform.InstanceState) (*bool, error) {
func (r SynchronizationJobProvisionOnDemandResource) Exists(_ context.Context, _ *clients.Client, _ *terraform.InstanceState) (*bool, error) {
return pointer.To(true), nil
}

Expand All @@ -49,9 +48,9 @@ resource "azuread_application" "test" {
}
resource "azuread_service_principal" "test" {
application_id = azuread_application.test.application_id
owners = [data.azuread_client_config.test.object_id]
use_existing = true
client_id = azuread_application.test.client_id
owners = [data.azuread_client_config.test.object_id]
use_existing = true
}
resource "azuread_synchronization_job" "test" {
Expand All @@ -73,8 +72,10 @@ func (r SynchronizationJobProvisionOnDemandResource) basic(data acceptance.TestD
resource "azuread_synchronization_job_provision_on_demand" "test" {
service_principal_id = azuread_service_principal.test.id
synchronization_job_id = trimprefix(azuread_synchronization_job.test.id, "${azuread_service_principal.test.id}/job/")
parameter {
rule_id = "03f7d90d-bf71-41b1-bda6-aaf0ddbee5d8" //no api to check this so assuming the rule id is the same globally :finger_crossed:
rule_id = "03f7d90d-bf71-41b1-bda6-aaf0ddbee5d8" // appears to be a global value
subject {
object_id = azuread_group.test.id
object_type_name = "Group"
Expand Down

0 comments on commit 32d994b

Please sign in to comment.