Skip to content

go generate support for private modules(currently NAP) #116

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

Merged
merged 1 commit into from
Aug 1, 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
12 changes: 12 additions & 0 deletions analyze.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@

package crossplane

// Upgrade for .gen.go files. If you don't have access to some private modules,
// please use -skip options to skip them. e.g. go generate -skip="nap".

// Update for headersmore
//go:generate sh -c "sh ./scripts/generate/generate.sh --url https://github.com/openresty/headers-more-nginx-module.git --config-path ./scripts/generate/configs/headersmore_config.json > ./analyze_headersMore_directives.gen.go"

Expand All @@ -26,6 +29,15 @@ package crossplane
// Otel provides its own config handler for some directives and they don't have context. Currently we don't support them.
//go:generate sh -c "sh ./scripts/generate/generate.sh --url https://github.com/nginxinc/nginx-otel.git --config-path ./scripts/generate/configs/otel_config.json --branch main > ./analyze_otel_directives.gen.go"

// Update for NAP v4 and v5.
// NAP is a private module. Please ensure you have correct access and put the url.
// and branch of it in environment variable NAP_URL, NAP_V4_BRANCH, and NAP_V5_BRANCH.
// Override is for flag dirctives. NAP used ngxConfTake1 for flag directives, we change them to ngxConfFlag in crossplane.
// NAP v4
//go:generate sh -c "sh ./scripts/generate/generate.sh --url $NAP_URL --config-path ./scripts/generate/configs/nap_v4_config.json --branch $NAP_V4_BRANCH --path ./src > analyze_appProtectWAFv4_directives.gen.go"
// NAP v5
//go:generate sh -c "sh ./scripts/generate/generate.sh --url $NAP_URL --config-path ./scripts/generate/configs/nap_v5_config.json --branch $NAP_V5_BRANCH --path ./src > analyze_appProtectWAFv5_directives.gen.go"

import (
"fmt"
)
Expand Down
88 changes: 88 additions & 0 deletions analyze_appProtectWAFv4_directives.gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

51 changes: 0 additions & 51 deletions analyze_appProtectWAFv4_directives.go

This file was deleted.

88 changes: 88 additions & 0 deletions analyze_appProtectWAFv5_directives.gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

51 changes: 0 additions & 51 deletions analyze_appProtectWAFv5_directives.go

This file was deleted.

9 changes: 9 additions & 0 deletions scripts/generate/configs/nap_v4_config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"directiveMapName":"appProtectWAFv4Directives",
"matchFuncName":"MatchAppProtectWAFv4",
"matchFuncComment":"MatchAppProtectWAFv4 is a MatchFunc for App Protect v4 module.",
"override":{
"app_protect_enable":[["ngxHTTPMainConf", "ngxHTTPSrvConf" , "ngxHTTPLocConf", "ngxConfFlag"]],
"app_protect_security_log_enable":[["ngxHTTPMainConf", "ngxHTTPSrvConf", "ngxHTTPLocConf", "ngxConfFlag"]]
}
}
9 changes: 9 additions & 0 deletions scripts/generate/configs/nap_v5_config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"directiveMapName":"appProtectWAFv5Directives",
"matchFuncName":"MatchAppProtectWAFv5",
"matchFuncComment":"MatchAppProtectWAFv5 is a MatchFunc for App Protect v5 module.",
"override":{
"app_protect_enable":[["ngxHTTPMainConf", "ngxHTTPSrvConf" , "ngxHTTPLocConf", "ngxConfFlag"]],
"app_protect_security_log_enable":[["ngxHTTPMainConf", "ngxHTTPSrvConf", "ngxHTTPLocConf", "ngxConfFlag"]]
}
}