Skip to content

Commit

Permalink
bring in Matthew John's work
Browse files Browse the repository at this point in the history
  • Loading branch information
duytiennguyen-okta committed Feb 23, 2024
1 parent b78ab3e commit 912cfb5
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions okta/data_source_okta_app_saml.go
Original file line number Diff line number Diff line change
Expand Up @@ -320,20 +320,22 @@ func dataSourceAppSamlRead(ctx context.Context, d *schema.ResourceData, m interf
return diag.Errorf("no SAML application found with provided filter: %s", filters)
}

// Okta API for list apps uses a starts with query on label and name
// which could result in multiple matches on the data source's "label"
// property. We need to further inspect for an exact label match.
if filters.Label != "" {
foundMatch := false
for _, appItx := range appList {
if appItx.Label == filters.Label {
app = appItx
foundMatch = true
// guard on nils, an app is always set
app = appList[0]
for i, _app := range appList {
if _app.Label == filters.Label {
app = appList[i]
break
}
}
if !foundMatch {
return diag.Errorf("no SAML application found with the provided label: %s", filters.Label)
}
} else {
logger(m).Info("found multiple SAML applications with the criteria supplied, using the first one, sorted by creation date")
if len(appList) > 1 {
logger(m).Info("found multiple applications with the criteria supplied, using the first one, sorted by creation date")
}
app = appList[0]
}
}
Expand Down

0 comments on commit 912cfb5

Please sign in to comment.