Skip to content

Commit

Permalink
fix: treat empty attributes as nil values for keycloak_ldap_user_fede…
Browse files Browse the repository at this point in the history
…ration import (#784)
  • Loading branch information
MatrixCrawler committed Feb 15, 2023
1 parent 7255504 commit 9a8c071
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions keycloak/ldap_user_federation.go
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ func convertFromComponentToLdapUserFederation(component *component) (*LdapUserFe
return nil, err
}

priority, err := strconv.Atoi(component.getConfig("priority"))
priority, err := atoiAndTreatEmptyStringAsZero(component.getConfig("priority"))
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -273,17 +273,17 @@ func convertFromComponentToLdapUserFederation(component *component) (*LdapUserFe
return nil, err
}

batchSizeForSync, err := strconv.Atoi(component.getConfig("batchSizeForSync"))
batchSizeForSync, err := atoiAndTreatEmptyStringAsZero(component.getConfig("batchSizeForSync"))
if err != nil {
return nil, err
}

fullSyncPeriod, err := strconv.Atoi(component.getConfig("fullSyncPeriod"))
fullSyncPeriod, err := atoiAndTreatEmptyStringAsZero(component.getConfig("fullSyncPeriod"))
if err != nil {
return nil, err
}

changedSyncPeriod, err := strconv.Atoi(component.getConfig("changedSyncPeriod"))
changedSyncPeriod, err := atoiAndTreatEmptyStringAsZero(component.getConfig("changedSyncPeriod"))
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -396,7 +396,7 @@ func convertFromComponentToLdapUserFederation(component *component) (*LdapUserFe
defaultEvictioValue := -1

if evictionDay, ok := component.getConfigOk("evictionDay"); ok {
evictionDayInt, err := strconv.Atoi(evictionDay)
evictionDayInt, err := atoiAndTreatEmptyStringAsZero(evictionDay)
if err != nil {
return nil, fmt.Errorf("unable to parse `evictionDay`: %w", err)
}
Expand All @@ -407,7 +407,7 @@ func convertFromComponentToLdapUserFederation(component *component) (*LdapUserFe
}

if evictionHour, ok := component.getConfigOk("evictionHour"); ok {
evictionHourInt, err := strconv.Atoi(evictionHour)
evictionHourInt, err := atoiAndTreatEmptyStringAsZero(evictionHour)
if err != nil {
return nil, fmt.Errorf("unable to parse `evictionHour`: %w", err)
}
Expand All @@ -417,7 +417,7 @@ func convertFromComponentToLdapUserFederation(component *component) (*LdapUserFe
ldap.EvictionHour = &defaultEvictioValue
}
if evictionMinute, ok := component.getConfigOk("evictionMinute"); ok {
evictionMinuteInt, err := strconv.Atoi(evictionMinute)
evictionMinuteInt, err := atoiAndTreatEmptyStringAsZero(evictionMinute)
if err != nil {
return nil, fmt.Errorf("unable to parse `evictionMinute`: %w", err)
}
Expand Down

0 comments on commit 9a8c071

Please sign in to comment.