Skip to content

Commit

Permalink
Merge pull request #112 from dengsh12/NLB5194
Browse files Browse the repository at this point in the history
go generate support for oss/public modules
  • Loading branch information
dengsh12 authored Jul 30, 2024
2 parents 86bf818 + bb4f6db commit 9c47563
Show file tree
Hide file tree
Showing 43 changed files with 6,621 additions and 6,211 deletions.
4 changes: 4 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ run:
modules-download-mode: mod
skip-dirs-use-default: true


# Specific linter settings
linters-settings:
gocyclo:
Expand All @@ -62,6 +63,9 @@ linters-settings:
local-prefixes: gitswarm.f5net.com/indigo,gitlab.com/f5
errcheck:
ignore: ^Close.*,os:^Setenv.*,fmt:.*,io/ioutil:^Read.*,github.com/spf13/viper:.*,github.com/pkg/errors:^Wrap.*
funclen:
skip-ifles:
- ".*\\.gen\\.go"

lll:
line-length: 140
Expand Down
21 changes: 20 additions & 1 deletion analyze.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,25 @@

package crossplane

// 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"

// Update for njs
//go:generate sh -c "sh ./scripts/generate/generate.sh --url https://github.com/nginx/njs.git --config-path ./scripts/generate/configs/njs_config.json > ./analyze_njs_directives.gen.go"

// Update for OSS, filter in config is the directives not in https://nginx.org/en/docs/dirindex.html but in source code.
// Override in config is for the "if" directive. We create a bitmask ngxConfExpr for it in crossplane, which is not in source code.
//go:generate sh -c "sh ./scripts/generate/generate.sh --url https://github.com/nginx/nginx.git --config-path ./scripts/generate/configs/oss_latest_config.json > ./analyze_oss_latest_directives.gen.go"
//go:generate sh -c "sh ./scripts/generate/generate.sh --url https://github.com/nginx/nginx.git --config-path ./scripts/generate/configs/oss_126_config.json --branch branches/stable-1.26 > ./analyze_oss_126_directives.gen.go"
//go:generate sh -c "sh ./scripts/generate/generate.sh --url https://github.com/nginx/nginx.git --config-path ./scripts/generate/configs/oss_124_config.json --branch branches/stable-1.24 > ./analyze_oss_124_directives.gen.go"

// Update for lua, override is for the lua block directives, see https://github.com/nginxinc/nginx-go-crossplane/pull/86.
//go:generate sh -c "sh ./scripts/generate/generate.sh --url https://github.com/openresty/lua-nginx-module.git --config-path ./scripts/generate/configs/lua_config.json --path ./src > ./analyze_lua_directives.gen.go"

// Update for otel. Filter is for some directives withou context.
// 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"

import (
"fmt"
)
Expand Down Expand Up @@ -219,7 +238,7 @@ func unionBitmaskMaps(maps ...map[string][]uint) map[string][]uint {
// not provided. It is union of latest Nplus, Njs, and Otel.
//
//nolint:gochecknoglobals
var defaultDirectives = unionBitmaskMaps(ngxPlusLatestDirectives, moduleNjsDirectives, moduleOtelDirectives)
var defaultDirectives = unionBitmaskMaps(nginxPlusLatestDirectives, njsDirectives, otelDirectives)

func DefaultDirectivesMatchFunc(directive string) ([]uint, bool) {
masks, matched := defaultDirectives[directive]
Expand Down
4 changes: 2 additions & 2 deletions analyze_appProtectWAFv4_directives.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ var appProtectWAFv4Directives = map[string][]uint{
},
}

// AppProtectWAFv4DirectivesMatchFn is a match function for parsing an NGINX config that contains the
// MatchAppProtectWAFv4 is a match function for parsing an NGINX config that contains the
// App Protect v4 module.
func AppProtectWAFv4DirectivesMatchFn(directive string) ([]uint, bool) {
func MatchAppProtectWAFv4(directive string) ([]uint, bool) {
masks, matched := appProtectWAFv4Directives[directive]
return masks, matched
}
4 changes: 2 additions & 2 deletions analyze_appProtectWAFv5_directives.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ var appProtectWAFv5Directives = map[string][]uint{
},
}

// AppProtectWAFv5DirectivesMatchFn is a match function for parsing an NGINX config that contains the
// MatchAppProtectWAFv5 is a match function for parsing an NGINX config that contains the
// App Protect v5 module.
func AppProtectWAFv5DirectivesMatchFn(directive string) ([]uint, bool) {
func MatchAppProtectWAFv5(directive string) ([]uint, bool) {
masks, matched := appProtectWAFv5Directives[directive]
return masks, matched
}
37 changes: 37 additions & 0 deletions analyze_headersMore_directives.gen.go

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

36 changes: 0 additions & 36 deletions analyze_headersMore_directives.go

This file was deleted.

Loading

0 comments on commit 9c47563

Please sign in to comment.