-
Notifications
You must be signed in to change notification settings - Fork 97
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add field to NginxProxy to allow disabling HTTP2 (#1925)
* Add field to NginxProxy to allow disabling HTTP2
- Loading branch information
Showing
20 changed files
with
278 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package config | ||
|
||
import ( | ||
gotemplate "text/template" | ||
|
||
"github.com/nginxinc/nginx-gateway-fabric/internal/mode/static/state/dataplane" | ||
) | ||
|
||
var baseHTTPTemplate = gotemplate.Must(gotemplate.New("baseHttp").Parse(baseHTTPTemplateText)) | ||
|
||
func executeBaseHTTPConfig(conf dataplane.Configuration) []executeResult { | ||
result := executeResult{ | ||
dest: httpConfigFile, | ||
data: execute(baseHTTPTemplate, conf.BaseHTTPConfig), | ||
} | ||
|
||
return []executeResult{result} | ||
} |
5 changes: 5 additions & 0 deletions
5
internal/mode/static/nginx/config/base_http_config_template.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package config | ||
|
||
const baseHTTPTemplateText = ` | ||
{{- if .HTTP2 }}http2 on;{{ end }} | ||
` |
52 changes: 52 additions & 0 deletions
52
internal/mode/static/nginx/config/base_http_config_test.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package config | ||
|
||
import ( | ||
"strings" | ||
"testing" | ||
|
||
. "github.com/onsi/gomega" | ||
|
||
"github.com/nginxinc/nginx-gateway-fabric/internal/mode/static/state/dataplane" | ||
) | ||
|
||
func TestExecuteBaseHttp(t *testing.T) { | ||
confOn := dataplane.Configuration{ | ||
BaseHTTPConfig: dataplane.BaseHTTPConfig{ | ||
HTTP2: true, | ||
}, | ||
} | ||
|
||
confOff := dataplane.Configuration{ | ||
BaseHTTPConfig: dataplane.BaseHTTPConfig{ | ||
HTTP2: false, | ||
}, | ||
} | ||
|
||
expSubStr := "http2 on;" | ||
|
||
tests := []struct { | ||
name string | ||
conf dataplane.Configuration | ||
expCount int | ||
}{ | ||
{ | ||
name: "http2 on", | ||
conf: confOn, | ||
expCount: 1, | ||
}, | ||
{ | ||
name: "http2 off", | ||
expCount: 0, | ||
conf: confOff, | ||
}, | ||
} | ||
|
||
for _, test := range tests { | ||
|
||
g := NewWithT(t) | ||
|
||
res := executeBaseHTTPConfig(test.conf) | ||
g.Expect(res).To(HaveLen(1)) | ||
g.Expect(test.expCount).To(Equal(strings.Count(string(res[0].data), expSubStr))) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.