Skip to content

Commit

Permalink
Revert updated section and field ID code
Browse files Browse the repository at this point in the history
  • Loading branch information
williamhpark committed Oct 17, 2023
1 parent 8e48918 commit 4af6d01
Showing 1 changed file with 9 additions and 14 deletions.
23 changes: 9 additions & 14 deletions onepassword/resource_onepassword_item.go
Original file line number Diff line number Diff line change
Expand Up @@ -547,16 +547,19 @@ func dataToItem(data *schema.ResourceData) (*onepassword.Item, error) {
return nil, fmt.Errorf("Unable to parse section: %v", sections[i])
}

if section["id"].(string) == "" {
sid, err := uuid.GenerateUUID()
if err != nil {
return nil, fmt.Errorf("Unable to generate a section id: %w", err)
}
sid, err := uuid.GenerateUUID()
if err != nil {
return nil, fmt.Errorf("Unable to generate a section id: %w", err)
}

if section["id"].(string) != "" {
sid = section["id"].(string)
} else {
section["id"] = sid
}

s := &onepassword.ItemSection{
ID: section["id"].(string),
ID: sid,
Label: section["label"].(string),
}
item.Sections = append(item.Sections, s)
Expand All @@ -568,14 +571,6 @@ func dataToItem(data *schema.ResourceData) (*onepassword.Item, error) {
return nil, fmt.Errorf("Unable to parse section field: %v", sectionFields[j])
}

if field["id"].(string) == "" {
fid, err := uuid.GenerateUUID()
if err != nil {
return nil, fmt.Errorf("Unable to generate a field id: %w", err)
}
field["id"] = fid
}

f := &onepassword.ItemField{
Section: s,
ID: field["id"].(string),
Expand Down

0 comments on commit 4af6d01

Please sign in to comment.