Skip to content

Commit

Permalink
progress
Browse files Browse the repository at this point in the history
  • Loading branch information
katbyte committed May 29, 2019
1 parent f45fae4 commit 95466df
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 5 deletions.
5 changes: 5 additions & 0 deletions azuread/data_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"github.com/terraform-providers/terraform-provider-azuread/azuread/helpers/validate"
)

//todo data source for groups: return array of ids from names, or names from ids
func dataGroup() *schema.Resource {
return &schema.Resource{
Read: dataSourceActiveDirectoryGroupRead,
Expand All @@ -22,6 +23,10 @@ func dataGroup() *schema.Resource {
Required: true,
ValidateFunc: validate.NoEmptyStrings,
},

//todo abiliy to lookup by object ID?

//todo owners and members
},
}
}
Expand Down
10 changes: 6 additions & 4 deletions azuread/data_service_principal.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,10 @@ func dataSourceActiveDirectoryServicePrincipalRead(d *schema.ResourceData, meta

sp = &app

} else if _, ok := d.GetOk("display_name"); ok {
} else if v, ok := d.GetOk("display_name"); ok {

// use the display_name to find the Azure AD service principal
displayName := d.Get("display_name").(string)
displayName := v.(string)
filter := fmt.Sprintf("displayName eq '%s'", displayName)

apps, err := client.ListComplete(ctx, filter)
Expand All @@ -89,10 +89,10 @@ func dataSourceActiveDirectoryServicePrincipalRead(d *schema.ResourceData, meta
return fmt.Errorf("A Service Principal with the Display Name %q was not found", displayName)
}

} else {
} else if v, ok := d.GetOk("application_id"); ok{

// use the application_id to find the Azure AD service principal
applicationId := d.Get("application_id").(string)
applicationId := v.(string)
filter := fmt.Sprintf("appId eq '%s'", applicationId)

apps, err := client.ListComplete(ctx, filter)
Expand All @@ -115,6 +115,8 @@ func dataSourceActiveDirectoryServicePrincipalRead(d *schema.ResourceData, meta
return fmt.Errorf("A Service Principal for Application ID %q was not found", applicationId)
}

} else {
return fmt.Errorf("one of `object_id`, `display_name` or `application_id` must be specified")
}

if sp.ObjectID == nil {
Expand Down
12 changes: 11 additions & 1 deletion azuread/resource_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,16 @@ func resourceGroupUpdate(d *schema.ResourceData, meta interface{}) error {

if d.HasChange("owners") {


// get existing -> map
// get desired -> map

//remove missing
for

//add miss


owners := d.Get("owners").([]interface{})
ownersExpanded, err := expandGroupOwners(owners)
if err != nil {
Expand Down Expand Up @@ -232,7 +242,7 @@ func flattenGroupOwners(meta interface{}, owners graphrbac.DirectoryObjectListRe
result := make([]interface{}, 0)

for owners.NotDone() {
user, _ := owners.Value().AsUser()
user, _ := owners.Value().AsUser() //todo suppot other types!
if user != nil {
result = append(result, *user.ObjectID)
}
Expand Down

0 comments on commit 95466df

Please sign in to comment.