feat: better handling of organization.AccountItems on init_data import (#3263)

* Better handling of accountitems on init_data import.

* Removed commented code.

* Update init_data.go

* Update init_data.go

---------

Co-authored-by: Yang Luo <hsluoyz@qq.com>
This commit is contained in:
Corey Gaspard 2024-10-02 19:49:09 -05:00 committed by GitHub
parent c9635d9e2b
commit c0f22bae43
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -182,6 +182,9 @@ func readInitDataFromFile(filePath string) (*InitData, error) {
if organization.Tags == nil {
organization.Tags = []string{}
}
if organization.AccountItems == nil {
organization.AccountItems = []*AccountItem{}
}
}
for _, application := range data.Applications {
if application.Providers == nil {
@ -275,7 +278,9 @@ func initDefinedOrganization(organization *Organization) {
}
}
organization.CreatedTime = util.GetCurrentTime()
organization.AccountItems = getBuiltInAccountItems()
if len(organization.AccountItems) == 0 {
organization.AccountItems = getBuiltInAccountItems()
}
_, err = AddOrganization(organization)
if err != nil {