Skip to content

Commit

Permalink
More code review
Browse files Browse the repository at this point in the history
  • Loading branch information
sjberman committed Aug 11, 2023
1 parent 3adb59d commit d945668
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 6 deletions.
6 changes: 3 additions & 3 deletions apis/v1alpha1/nginxgateway_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,13 @@ type Logging struct {
type ControllerLogLevel string

const (
// Info level for control plane logging.
// ControllerLogLevelInfo is the info level for control plane logging.
ControllerLogLevelInfo ControllerLogLevel = "info"

// Debug level for control plane logging.
// ControllerLogLevelDebug is the debug level for control plane logging.
ControllerLogLevelDebug ControllerLogLevel = "debug"

// Error level for control plane logging.
// ControllerLogLevelError is the error level for control plane logging.
ControllerLogLevelError ControllerLogLevel = "error"
)

Expand Down
17 changes: 17 additions & 0 deletions cmd/gateway/commands_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ func TestStaticModeCmdFlagValidation(t *testing.T) {
name: "valid flags",
args: []string{
"--gateway=nginx-gateway/nginx",
"--config=nginx-gateway-config",
"--update-gatewayclass-status=true",
},
wantErr: false,
Expand All @@ -142,6 +143,22 @@ func TestStaticModeCmdFlagValidation(t *testing.T) {
expectedErrPrefix: `invalid argument "nginx-gateway" for "--gateway" flag: invalid format; ` +
"must be NAMESPACE/NAME",
},
{
name: "config is set to empty string",
args: []string{
"--config=",
},
wantErr: true,
expectedErrPrefix: `invalid argument "" for "-c, --config" flag: must be set`,
},
{
name: "config is set to invalid string",
args: []string{
"--config=!@#$",
},
wantErr: true,
expectedErrPrefix: `invalid argument "!@#$" for "-c, --config" flag: invalid format`,
},
{
name: "update-gatewayclass-status is set to empty string",
args: []string{
Expand Down
2 changes: 1 addition & 1 deletion deploy/manifests/nginx-gateway.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ metadata:
spec:
controllerName: gateway.nginx.org/nginx-gateway-controller
---
# Source: nginx-kubernetes-gateway/templates/control-config.yaml
# Source: nginx-kubernetes-gateway/templates/nginxgateway.yaml
apiVersion: gateway.nginx.org/v1alpha1
kind: NginxGateway
metadata:
Expand Down
5 changes: 3 additions & 2 deletions docs/control-plane-configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@ of the resource is `<release-name>-config`. It is deployed in the same Namespace

The control plane only watches this single instance of the custom resource. If the resource is invalid per the OpenAPI
schema, the Kubernetes API server will reject the changes. If the resource is deleted or deemed invalid by NGINX
Kubernetes Gateway, an error Event is created in the `nginx-gateway` Namespace, and the default values will be used by
the control plane for its configuration.
Kubernetes Gateway, a warning Event is created in the `nginx-gateway` Namespace, and the default values will be used by
the control plane for its configuration. Additionally, the control plane updates the status of the resource (if it exists)
to reflect whether it is valid or not.

### Spec

Expand Down

0 comments on commit d945668

Please sign in to comment.