Skip to content

Commit

Permalink
fix(product_enablement): check for ProductUndefined
Browse files Browse the repository at this point in the history
  • Loading branch information
Integralist committed Oct 9, 2023
1 parent af48095 commit a26f755
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions pkg/commands/products/root.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package products

import (
"errors"
"fmt"
"io"

Expand Down Expand Up @@ -79,8 +80,12 @@ func (c *RootCommand) Exec(_ io.Reader, out io.Writer) error {
}

if c.enableProduct != "" {
p := identifyProduct(c.enableProduct)
if p == fastly.ProductUndefined {
return errors.New("unrecognised product")
}
if _, err := ac.EnableProduct(&fastly.ProductEnablementInput{
ProductID: identifyProduct(c.enableProduct),
ProductID: p,
ServiceID: serviceID,
}); err != nil {
return fmt.Errorf("failed to enable product '%s': %w", c.enableProduct, err)
Expand All @@ -90,8 +95,12 @@ func (c *RootCommand) Exec(_ io.Reader, out io.Writer) error {
}

if c.disableProduct != "" {
p := identifyProduct(c.disableProduct)
if p == fastly.ProductUndefined {
return errors.New("unrecognised product")
}
if err := ac.DisableProduct(&fastly.ProductEnablementInput{
ProductID: identifyProduct(c.disableProduct),
ProductID: p,
ServiceID: serviceID,
}); err != nil {
return fmt.Errorf("failed to disable product '%s': %w", c.disableProduct, err)
Expand Down

0 comments on commit a26f755

Please sign in to comment.