Skip to content

NLB-6350: enable R34 directives #149

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

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
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
3 changes: 2 additions & 1 deletion analyze.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,15 @@ package crossplane
//go:generate sh -c "sh ./scripts/generate/generate.sh --url https://github.com/leev/ngx_http_geoip2_module.git --config-path ./scripts/generate/configs/geoip2_config.json > ./analyze_geoip2_directives.gen.go"

// Update for NPlus.
// NPlus source code is private. Please ensure you have the correct access
// NPlus source code is private. Please ensure you have the correct access
// and set the URL and branch in the environment variables NPLUS_URL and NPLUS_BRANCH.
// Filter in config is the directives not in https://nginx.org/en/docs/dirindex.html but in source code.
// Override for NPlus R33 and the latest version is for mgmt directives and if directive.
// For mgmt directives, we create a ngxMgmtMainConf as the context, which is not included in the source code.
// For the "if" directive, we create a bitmask ngxConfExpr in crossplane, which is not included in the source code.
//go:generate sh -c "sh ./scripts/generate/generate.sh --url $NPLUS_URL --config-path ./scripts/generate/configs/nplus_latest_config.json --branch $NPLUS_BRANCH --path ./src > ./analyze_nplus_latest_directives.gen.go"
//go:generate sh -c "sh ./scripts/generate/generate.sh --url $NPLUS_URL --config-path ./scripts/generate/configs/nplus_R33_config.json --branch $NPLUS_BRANCH --path ./src > analyze_nplus_R33_directives.gen.go"
//go:generate sh -c "sh ./scripts/generate/generate.sh --url $NPLUS_URL --config-path ./scripts/generate/configs/nplus_R34_config.json --branch $NPLUS_BRANCH --path ./src > analyze_nplus_R34_directives.gen.go"

import (
"fmt"
Expand Down
3 changes: 3 additions & 0 deletions analyze_lua_directives.gen.go

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

4 changes: 4 additions & 0 deletions analyze_map.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ var mapBodies = map[string]mapParameterMasks{
"otel_exporter": {
defaultMasks: ngxConfTake1,
},
"oidc_provider": {
specialParameterMasks: map[string]uint{"session_timeout": ngxConf1More, "scope": ngxConf1More},
defaultMasks: ngxConfTake1,
},
}

// analyzeMapBody validates the body of a map-like directive. Map-like directives are block directives
Expand Down
42 changes: 42 additions & 0 deletions analyze_map_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,48 @@ func TestAnalyzeMapBody(t *testing.T) {
term: "}",
wantErr: &ParseError{What: `unexpected "}"`, BlockCtx: "map"},
},
"valid oidc_provider": {
mapDirective: "oidc_provider",
parameter: &Directive{
Directive: "client_id",
Args: []string{"unique_id"},
Line: 5,
Block: Directives{},
},
term: ";",
},
"invalid oidc_provider": {
mapDirective: "oidc_provider",
parameter: &Directive{
Directive: "client_id ",
Args: []string{},
Line: 5,
Block: Directives{},
},
term: ";",
wantErr: &ParseError{What: "invalid number of parameters", BlockCtx: "oidc_provider"},
},
"valid oidc_provider scope": {
mapDirective: "oidc_provider",
parameter: &Directive{
Directive: "scope",
Args: []string{"openid"},
Line: 5,
Block: Directives{},
},
term: ";",
},
"invalid oidc_provider scope": {
mapDirective: "oidc_provider",
parameter: &Directive{
Directive: "scope",
Args: []string{},
Line: 5,
Block: Directives{},
},
term: ";",
wantErr: &ParseError{What: "invalid number of parameters", BlockCtx: "oidc_provider"},
},
}

for name, tc := range testcases {
Expand Down
4 changes: 4 additions & 0 deletions analyze_njs_directives.gen.go

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

Loading