Skip to content

Commit

Permalink
Move DisableHTTP2 to top level in spec
Browse files Browse the repository at this point in the history
  • Loading branch information
ciarams87 committed May 15, 2024
1 parent 97b3321 commit 5abffd1
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 59 deletions.
14 changes: 3 additions & 11 deletions apis/v1alpha1/nginxproxy_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,11 @@ type NginxProxySpec struct {
//
// +optional
Telemetry *Telemetry `json:"telemetry,omitempty"`
// BaseHTTPConfig specifies the base http context configuration.
// DisableHTTP2 defines if http2 should be disabled for all servers.
// Default is false, meaning http2 will be enabled for all servers.
//
// +optional
BaseHTTPConfig *BaseHTTPConfig `json:"baseHTTPConfig,omitempty"`
DisableHTTP2 bool `json:"disableHTTP2"`
}

// Telemetry specifies the OpenTelemetry configuration.
Expand Down Expand Up @@ -92,12 +93,3 @@ type TelemetryExporter struct {
// +kubebuilder:validation:Pattern=`^(?:http?:\/\/)?[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?)*(?::\d{1,5})?$`
Endpoint string `json:"endpoint"`
}

// BaseHTTPConfig defines the http context level settings that should be applied across all servers.
type BaseHTTPConfig struct {
// DisableHTTP2 defines if http2 should be disabled for all servers.
// Default is false, meaning http2 will be enabled for all servers.
//
// +optional
DisableHTTP2 bool `json:"disableHTTP2"`
}
20 changes: 0 additions & 20 deletions apis/v1alpha1/zz_generated.deepcopy.go

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

14 changes: 5 additions & 9 deletions config/crd/bases/gateway.nginx.org_nginxproxies.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,11 @@ spec:
spec:
description: Spec defines the desired state of the NginxProxy.
properties:
baseHTTPConfig:
description: BaseHTTPConfig specifies the base http context configuration.
properties:
disableHTTP2:
description: |-
DisableHTTP2 defines if http2 should be disabled for all servers.
Default is false, meaning http2 will be enabled for all servers.
type: boolean
type: object
disableHTTP2:
description: |-
DisableHTTP2 defines if http2 should be disabled for all servers.
Default is false, meaning http2 will be enabled for all servers.
type: boolean
telemetry:
description: Telemetry specifies the OpenTelemetry configuration.
properties:
Expand Down
14 changes: 5 additions & 9 deletions deploy/crds.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -700,15 +700,11 @@ spec:
spec:
description: Spec defines the desired state of the NginxProxy.
properties:
baseHTTPConfig:
description: BaseHTTPConfig specifies the base http context configuration.
properties:
disableHTTP2:
description: |-
DisableHTTP2 defines if http2 should be disabled for all servers.
Default is false, meaning http2 will be enabled for all servers.
type: boolean
type: object
disableHTTP2:
description: |-
DisableHTTP2 defines if http2 should be disabled for all servers.
Default is false, meaning http2 will be enabled for all servers.
type: boolean
telemetry:
description: Telemetry specifies the OpenTelemetry configuration.
properties:
Expand Down
4 changes: 2 additions & 2 deletions internal/mode/static/state/dataplane/configuration.go
Original file line number Diff line number Diff line change
Expand Up @@ -628,11 +628,11 @@ func buildBaseHTTPConfig(g *graph.Graph) BaseHTTPConfig {
// HTTP2 should be enabled by default
HTTP2: true,
}
if g.NginxProxy == nil || g.NginxProxy.Spec.BaseHTTPConfig == nil {
if g.NginxProxy == nil {
return baseConfig
}

if g.NginxProxy.Spec.BaseHTTPConfig.DisableHTTP2 {
if g.NginxProxy.Spec.DisableHTTP2 {
baseConfig.HTTP2 = false
}

Expand Down
4 changes: 1 addition & 3 deletions internal/mode/static/state/dataplane/configuration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -555,9 +555,7 @@ func TestBuildConfiguration(t *testing.T) {
},
ServiceName: helpers.GetPointer("my-svc"),
},
BaseHTTPConfig: &ngfAPI.BaseHTTPConfig{
DisableHTTP2: true,
},
DisableHTTP2: true,
},
}

Expand Down
4 changes: 1 addition & 3 deletions internal/mode/static/state/graph/grpcroute_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,7 @@ func TestBuildGRPCRoutes(t *testing.T) {

npCfg := &ngfAPI.NginxProxy{
Spec: ngfAPI.NginxProxySpec{
BaseHTTPConfig: &ngfAPI.BaseHTTPConfig{
DisableHTTP2: false,
},
DisableHTTP2: false,
},
}

Expand Down
4 changes: 2 additions & 2 deletions internal/mode/static/state/graph/route_common.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,10 +163,10 @@ func buildRoutesForGateways(
}

func isHTTP2Disabled(npCfg *ngfAPI.NginxProxy) bool {
if npCfg == nil || npCfg.Spec.BaseHTTPConfig == nil {
if npCfg == nil {
return false
}
return npCfg.Spec.BaseHTTPConfig.DisableHTTP2
return npCfg.Spec.DisableHTTP2
}

func buildSectionNameRefs(
Expand Down

0 comments on commit 5abffd1

Please sign in to comment.