Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(products): Add support for NGWAF product #1322

Merged
merged 2 commits into from
Oct 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ require (
)

require (
github.com/fastly/go-fastly/v9 v9.10.0
github.com/fastly/go-fastly/v9 v9.11.0
github.com/hashicorp/cap v0.7.0
github.com/kennygrant/sanitize v1.2.4
github.com/otiai10/copy v1.14.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ github.com/dsnet/compress v0.0.2-0.20210315054119-f66993602bf5/go.mod h1:qssHWj6
github.com/dsnet/golib v0.0.0-20171103203638-1ea166775780/go.mod h1:Lj+Z9rebOhdfkVLjJ8T6VcRQv3SXugXy999NBtR9aFY=
github.com/dustinkirkland/golang-petname v0.0.0-20231002161417-6a283f1aaaf2 h1:S6Dco8FtAhEI/qkg/00H6RdEGC+MCy5GPiQ+xweNRFE=
github.com/dustinkirkland/golang-petname v0.0.0-20231002161417-6a283f1aaaf2/go.mod h1:8AuBTZBRSFqEYBPYULd+NN474/zZBLP+6WeT5S9xlAc=
github.com/fastly/go-fastly/v9 v9.10.0 h1:Emg9foA2+o7ERs7NVit18Wih8TEEOC+XEeb8Kcyehtw=
github.com/fastly/go-fastly/v9 v9.10.0/go.mod h1:5w2jgJBZqQEebOwM/rRg7wutAcpDTziiMYWb/6qdM7U=
github.com/fastly/go-fastly/v9 v9.11.0 h1:VuvLrtjEdaA/NfA+/qcSKw1MlC2LiUjfk8jwmhEbm0Q=
github.com/fastly/go-fastly/v9 v9.11.0/go.mod h1:5w2jgJBZqQEebOwM/rRg7wutAcpDTziiMYWb/6qdM7U=
github.com/fastly/kingpin v2.1.12-0.20191105091915-95d230a53780+incompatible h1:FhrXlfhgGCS+uc6YwyiFUt04alnjpoX7vgDKJxS6Qbk=
github.com/fastly/kingpin v2.1.12-0.20191105091915-95d230a53780+incompatible/go.mod h1:U8UynVoU1SQaqD2I4ZqgYd5lx3A1ipQYn4aSt2Y5h6c=
github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk=
Expand Down
8 changes: 6 additions & 2 deletions pkg/commands/products/products_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ brotli_compression false
domain_inspector false
fanout false
image_optimizer false
ngwaf false
origin_inspector false
websockets false
`,
Expand All @@ -53,19 +54,20 @@ brotli_compression true
domain_inspector true
fanout true
image_optimizer true
ngwaf true
origin_inspector true
websockets true
`,
},
{
Name: "validate flag parsing error for enabling product",
Args: "--service-id 123 --enable foo",
WantError: "error parsing arguments: enum value must be one of bot_management,brotli_compression,domain_inspector,fanout,image_optimizer,origin_inspector,websockets, got 'foo'",
WantError: "error parsing arguments: enum value must be one of bot_management,brotli_compression,domain_inspector,fanout,image_optimizer,ngwaf,origin_inspector,websockets, got 'foo'",
},
{
Name: "validate flag parsing error for disabling product",
Args: "--service-id 123 --disable foo",
WantError: "error parsing arguments: enum value must be one of bot_management,brotli_compression,domain_inspector,fanout,image_optimizer,origin_inspector,websockets, got 'foo'",
WantError: "error parsing arguments: enum value must be one of bot_management,brotli_compression,domain_inspector,fanout,image_optimizer,ngwaf,origin_inspector,websockets, got 'foo'",
},
{
Name: "validate success for enabling product",
Expand Down Expand Up @@ -106,6 +108,7 @@ websockets true
"domain_inspector": false,
"fanout": false,
"image_optimizer": false,
"ngwaf": false,
"origin_inspector": false,
"websockets": false
}`,
Expand All @@ -124,6 +127,7 @@ websockets true
"domain_inspector": true,
"fanout": true,
"image_optimizer": true,
"ngwaf": true,
"origin_inspector": true,
"websockets": true
}`,
Expand Down
11 changes: 11 additions & 0 deletions pkg/commands/products/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ var ProductEnablementOptions = []string{
"domain_inspector",
"fanout",
"image_optimizer",
"ngwaf",
"origin_inspector",
"websockets",
}
Expand Down Expand Up @@ -142,6 +143,12 @@ func (c *RootCommand) Exec(_ io.Reader, out io.Writer) error {
}); err == nil {
ps.ImageOptimizer = true
}
if _, err = ac.GetProduct(&fastly.ProductEnablementInput{
ProductID: fastly.ProductNGWAF,
ServiceID: serviceID,
}); err == nil {
ps.NGWAF = true
}
if _, err = ac.GetProduct(&fastly.ProductEnablementInput{
ProductID: fastly.ProductOriginInspector,
ServiceID: serviceID,
Expand All @@ -166,6 +173,7 @@ func (c *RootCommand) Exec(_ io.Reader, out io.Writer) error {
t.AddLine(fastly.ProductDomainInspector, ps.DomainInspector)
t.AddLine(fastly.ProductFanout, ps.Fanout)
t.AddLine(fastly.ProductImageOptimizer, ps.ImageOptimizer)
t.AddLine(fastly.ProductNGWAF, ps.NGWAF)
t.AddLine(fastly.ProductOriginInspector, ps.OriginInspector)
t.AddLine(fastly.ProductWebSockets, ps.WebSockets)
t.Print()
Expand All @@ -184,6 +192,8 @@ func identifyProduct(product string) fastly.Product {
return fastly.ProductFanout
case "image_optimizer":
return fastly.ProductImageOptimizer
case "ngwaf":
return fastly.ProductNGWAF
case "origin_inspector":
return fastly.ProductOriginInspector
case "websockets":
Expand All @@ -200,6 +210,7 @@ type ProductStatus struct {
DomainInspector bool `json:"domain_inspector"`
Fanout bool `json:"fanout"`
ImageOptimizer bool `json:"image_optimizer"`
NGWAF bool `json:"ngwaf"`
OriginInspector bool `json:"origin_inspector"`
WebSockets bool `json:"websockets"`
}
Loading