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 5524e4e
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions pkg/commands/products/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,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")

Check failure on line 84 in pkg/commands/products/root.go

View workflow job for this annotation

GitHub Actions / lint

undefined: errors

Check failure on line 84 in pkg/commands/products/root.go

View workflow job for this annotation

GitHub Actions / test (0.27.0, 1.21.x, 18, ubuntu-latest)

undefined: errors

Check failure on line 84 in pkg/commands/products/root.go

View workflow job for this annotation

GitHub Actions / test (0.27.0, 1.21.x, 18, macos-latest)

undefined: errors
}
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 +94,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")

Check failure on line 99 in pkg/commands/products/root.go

View workflow job for this annotation

GitHub Actions / lint

undefined: errors

Check failure on line 99 in pkg/commands/products/root.go

View workflow job for this annotation

GitHub Actions / test (0.27.0, 1.21.x, 18, ubuntu-latest)

undefined: errors

Check failure on line 99 in pkg/commands/products/root.go

View workflow job for this annotation

GitHub Actions / test (0.27.0, 1.21.x, 18, macos-latest)

undefined: errors
}
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 5524e4e

Please sign in to comment.