Skip to content

Commit

Permalink
Merge pull request #100 from 1Password/wpark/96-fix-sections
Browse files Browse the repository at this point in the history
Fix item creation with sections
  • Loading branch information
volodymyrZotov authored Oct 17, 2023
2 parents db29adc + 3977adf commit 2c7bb58
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions onepassword/resource_onepassword_item.go
Original file line number Diff line number Diff line change
Expand Up @@ -546,19 +546,17 @@ func dataToItem(data *schema.ResourceData) (*onepassword.Item, error) {
if !ok {
return nil, fmt.Errorf("Unable to parse section: %v", sections[i])
}
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 {
if section["id"].(string) == "" {
sid, err := uuid.GenerateUUID()
if err != nil {
return nil, fmt.Errorf("Unable to generate a section id: %w", err)
}
section["id"] = sid
}

s := &onepassword.ItemSection{
ID: sid,
ID: section["id"].(string),
Label: section["label"].(string),
}
item.Sections = append(item.Sections, s)
Expand All @@ -574,7 +572,7 @@ func dataToItem(data *schema.ResourceData) (*onepassword.Item, error) {
Section: s,
ID: field["id"].(string),
Type: onepassword.ItemFieldType(field["type"].(string)),
Purpose: onepassword.ItemFieldPurpose(field["type"].(string)),
Purpose: onepassword.ItemFieldPurpose(field["purpose"].(string)),
Label: field["label"].(string),
Value: field["value"].(string),
}
Expand Down

0 comments on commit 2c7bb58

Please sign in to comment.