Skip to content

Commit

Permalink
Bug: nonjson: Ensure sku, display-name, or id are set
Browse files Browse the repository at this point in the history
  • Loading branch information
zsrv committed Feb 14, 2023
1 parent 9a35ab2 commit 1a527c8
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions cmd/nonjson.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,25 +73,32 @@ var nonjsonEncodeCmd = &cobra.Command{

pk := nonjson.NewProductKey()

var swidSet bool
switch {
case swSKU != "":
swid, err := nonjson.SoftwareIdentifiers.BySKU(swSKU)
if err != nil {
return err
}
pk.SoftwareIdentifier = *swid
swidSet = true
case swDisplayName != "":
swid, err := nonjson.SoftwareIdentifiers.ByDisplayName(swDisplayName)
if err != nil {
return err
}
pk.SoftwareIdentifier = *swid
swidSet = true
case len(swID) > 0:
swid, err := nonjson.SoftwareIdentifiers.ByID(swID[0])
if err != nil {
return err
}
pk.SoftwareIdentifier = *swid
swidSet = true
}
if swidSet != true {
return errors.New("one of sku, display-name, id are required")
}

if softwareVersion != "" {
Expand Down

0 comments on commit 1a527c8

Please sign in to comment.