Skip to content

Update directory structure #3401

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

Merged
merged 1 commit into from
May 27, 2025
Merged
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
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,8 @@ jobs:
sbom: true
provenance: mode=max
build-args: |
NJS_DIR=internal/mode/static/nginx/modules/src
NGINX_CONF_DIR=internal/mode/static/nginx/conf
NJS_DIR=internal/controller/nginx/modules/src
NGINX_CONF_DIR=internal/controller/nginx/conf
BUILD_AGENT=gha
secrets: |
${{ contains(inputs.image, 'plus') && format('"nginx-repo.crt={0}"', secrets.NGINX_CRT) || '' }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ jobs:
node-version-file: .nvmrc

- name: Run tests
run: npm --prefix ${{ github.workspace }}/internal/mode/static/nginx/modules install-ci-test
run: npm --prefix ${{ github.workspace }}/internal/controller/nginx/modules install-ci-test

- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@18283e04ce6e62d37312384ff67231eb8fd56d24 # v5.4.3
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/conformance.yml
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,8 @@ jobs:
cache-from: type=gha,scope=${{ inputs.image }}
pull: true
build-args: |
NJS_DIR=internal/mode/static/nginx/modules/src
NGINX_CONF_DIR=internal/mode/static/nginx/conf
NJS_DIR=internal/controller/nginx/modules/src
NGINX_CONF_DIR=internal/controller/nginx/conf
BUILD_AGENT=gha

- name: Update Go Modules
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/functional.yml
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,8 @@ jobs:
cache-from: type=gha,scope=${{ inputs.image }}
pull: true
build-args: |
NJS_DIR=internal/mode/static/nginx/modules/src
NGINX_CONF_DIR=internal/mode/static/nginx/conf
NJS_DIR=internal/controller/nginx/modules/src
NGINX_CONF_DIR=internal/controller/nginx/conf
BUILD_AGENT=gha

- name: Setup license file for plus
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/helm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ jobs:
cache-from: type=gha,scope=${{ inputs.image }}
pull: true
build-args: |
NJS_DIR=internal/mode/static/nginx/modules/src
NGINX_CONF_DIR=internal/mode/static/nginx/conf
NJS_DIR=internal/controller/nginx/modules/src
NGINX_CONF_DIR=internal/controller/nginx/conf
BUILD_AGENT=gha

- name: Install cloud-provider-kind
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ jobs:
id: prettier-run
uses: rutajdash/prettier-cli-action@d42c4325a3b344f3bd4be482bc34de521998d557 # v1.0.2
with:
config_path: ${{ github.workspace }}/internal/mode/static/nginx/modules/.prettierrc
file_pattern: ${{ github.workspace }}/internal/mode/static/nginx/modules/**/*.js
config_path: ${{ github.workspace }}/internal/controller/nginx/modules/.prettierrc
file_pattern: ${{ github.workspace }}/internal/controller/nginx/modules/**/*.js
prettier_version: 3.3.3 # renovate: datasource=npm depName=prettier

- name: Prettier Output
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ tests/**/*.csv
node_modules/

# JS test coverage
internal/mode/static/nginx/modules/coverage
internal/controller/nginx/modules/coverage

# MacOS Finder
.DS_Store
Expand Down
2 changes: 1 addition & 1 deletion .gitleaksignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
68d1f6eb80d23c8650c11629459dd6a06c986ca1:internal/state/graph/graph_test.go:private-key:44
890fddb787ff3560b9b743647a36b649d498ae51:internal/state/graph/secret_test.go:private-key:35
890fddb787ff3560b9b743647a36b649d498ae51:internal/state/change_processor_test.go:private-key:211
internal/mode/static/state/graph/config_maps_test.go:private-key:35
internal/controller/state/graph/config_maps_test.go:private-key:35
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
VERSION = edge
SELF_DIR := $(dir $(abspath $(lastword $(MAKEFILE_LIST))))
CHART_DIR = $(SELF_DIR)charts/nginx-gateway-fabric
NGINX_CONF_DIR = internal/mode/static/nginx/conf
NJS_DIR = internal/mode/static/nginx/modules/src
NGINX_CONF_DIR = internal/controller/nginx/conf
NJS_DIR = internal/controller/nginx/modules/src
KIND_CONFIG_FILE = $(SELF_DIR)config/cluster/kind-cluster.yaml
NGINX_DOCKER_BUILD_PLUS_ARGS = --secret id=nginx-repo.crt,src=$(SELF_DIR)nginx-repo.crt --secret id=nginx-repo.key,src=$(SELF_DIR)nginx-repo.key
BUILD_AGENT = local
Expand Down Expand Up @@ -202,7 +202,7 @@ unit-test: ## Run unit tests for the go code
.PHONY: njs-unit-test
njs-unit-test: ## Run unit tests for the njs httpmatches module
docker run --rm -w /modules \
-v $(CURDIR)/internal/mode/static/nginx/modules:/modules/ \
-v $(CURDIR)/internal/controller/nginx/modules:/modules/ \
node:${NODE_VERSION} \
/bin/bash -c "npm ci && npm test && npm run clean"

Expand Down
10 changes: 5 additions & 5 deletions cmd/gateway/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@
"sigs.k8s.io/controller-runtime/pkg/log"
ctlrZap "sigs.k8s.io/controller-runtime/pkg/log/zap"

"github.com/nginx/nginx-gateway-fabric/internal/controller"
"github.com/nginx/nginx-gateway-fabric/internal/controller/config"
"github.com/nginx/nginx-gateway-fabric/internal/controller/licensing"
ngxConfig "github.com/nginx/nginx-gateway-fabric/internal/controller/nginx/config"
"github.com/nginx/nginx-gateway-fabric/internal/framework/file"
"github.com/nginx/nginx-gateway-fabric/internal/mode/static"
"github.com/nginx/nginx-gateway-fabric/internal/mode/static/config"
"github.com/nginx/nginx-gateway-fabric/internal/mode/static/licensing"
ngxConfig "github.com/nginx/nginx-gateway-fabric/internal/mode/static/nginx/config"
)

// These flags are shared by multiple commands.
Expand Down Expand Up @@ -259,7 +259,7 @@
NGINXSCCName: nginxSCCName.value,
}

if err := static.StartManager(conf); err != nil {
if err := controller.StartManager(conf); err != nil {

Check warning on line 262 in cmd/gateway/commands.go

View check run for this annotation

Codecov / codecov/patch

cmd/gateway/commands.go#L262

Added line #L262 was not covered by tests
return fmt.Errorf("failed to start control loop: %w", err)
}

Expand Down
2 changes: 1 addition & 1 deletion cmd/gateway/commands_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"github.com/spf13/cobra"
"github.com/spf13/pflag"

"github.com/nginx/nginx-gateway-fabric/internal/mode/static/config"
"github.com/nginx/nginx-gateway-fabric/internal/controller/config"
)

type flagTestCase struct {
Expand Down
4 changes: 2 additions & 2 deletions cmd/gateway/initialize.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ import (

"github.com/go-logr/logr"

"github.com/nginx/nginx-gateway-fabric/internal/controller/licensing"
"github.com/nginx/nginx-gateway-fabric/internal/controller/nginx/config"
"github.com/nginx/nginx-gateway-fabric/internal/framework/file"
"github.com/nginx/nginx-gateway-fabric/internal/mode/static/licensing"
"github.com/nginx/nginx-gateway-fabric/internal/mode/static/nginx/config"
)

const (
Expand Down
6 changes: 3 additions & 3 deletions cmd/gateway/initialize_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ import (
"github.com/go-logr/logr"
. "github.com/onsi/gomega"

"github.com/nginx/nginx-gateway-fabric/internal/controller/licensing/licensingfakes"
"github.com/nginx/nginx-gateway-fabric/internal/controller/nginx/config/configfakes"
"github.com/nginx/nginx-gateway-fabric/internal/controller/state/dataplane"
"github.com/nginx/nginx-gateway-fabric/internal/framework/file"
"github.com/nginx/nginx-gateway-fabric/internal/framework/file/filefakes"
"github.com/nginx/nginx-gateway-fabric/internal/framework/helpers"
"github.com/nginx/nginx-gateway-fabric/internal/mode/static/licensing/licensingfakes"
"github.com/nginx/nginx-gateway-fabric/internal/mode/static/nginx/config/configfakes"
"github.com/nginx/nginx-gateway-fabric/internal/mode/static/state/dataplane"
)

func TestInitialize_OSS(t *testing.T) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package static
package controller

import (
"encoding/json"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package static
package controller

import (
"errors"
Expand All @@ -11,8 +11,8 @@ import (
"k8s.io/client-go/tools/record"

ngfAPI "github.com/nginx/nginx-gateway-fabric/apis/v1alpha1"
"github.com/nginx/nginx-gateway-fabric/internal/controller/controllerfakes"
"github.com/nginx/nginx-gateway-fabric/internal/framework/helpers"
"github.com/nginx/nginx-gateway-fabric/internal/mode/static/staticfakes"
)

func TestUpdateControlPlane(t *testing.T) {
Expand Down Expand Up @@ -75,7 +75,7 @@ func TestUpdateControlPlane(t *testing.T) {
t.Parallel()
g := NewWithT(t)

fakeLogSetter := &staticfakes.FakeLogLevelSetter{
fakeLogSetter := &controllerfakes.FakeLogLevelSetter{
SetLevelStub: func(_ string) error {
return test.setLevelErr
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package static_test
package controller_test

import (
"testing"
Expand All @@ -7,8 +7,8 @@ import (
. "github.com/onsi/gomega"
)

func TestStatic(t *testing.T) {
func TestController(t *testing.T) {
t.Parallel()
RegisterFailHandler(Fail)
RunSpecs(t, "Static Suite")
RunSpecs(t, "Controller Suite")
}

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

4 changes: 4 additions & 0 deletions internal/controller/doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/*
Package controller contains all the packages that relate to the controller implementation of NGF.
*/
package controller
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package static
package controller

import (
"context"
Expand All @@ -18,20 +18,19 @@ import (
gatewayv1 "sigs.k8s.io/gateway-api/apis/v1"

ngfAPI "github.com/nginx/nginx-gateway-fabric/apis/v1alpha1"
ngfConfig "github.com/nginx/nginx-gateway-fabric/internal/controller/config"
"github.com/nginx/nginx-gateway-fabric/internal/controller/licensing"
"github.com/nginx/nginx-gateway-fabric/internal/controller/nginx/agent"
ngxConfig "github.com/nginx/nginx-gateway-fabric/internal/controller/nginx/config"
"github.com/nginx/nginx-gateway-fabric/internal/controller/provisioner"
"github.com/nginx/nginx-gateway-fabric/internal/controller/state"
"github.com/nginx/nginx-gateway-fabric/internal/controller/state/dataplane"
"github.com/nginx/nginx-gateway-fabric/internal/controller/state/graph"
"github.com/nginx/nginx-gateway-fabric/internal/controller/state/resolver"
"github.com/nginx/nginx-gateway-fabric/internal/controller/status"
"github.com/nginx/nginx-gateway-fabric/internal/framework/controller"
"github.com/nginx/nginx-gateway-fabric/internal/framework/events"
"github.com/nginx/nginx-gateway-fabric/internal/framework/helpers"
frameworkStatus "github.com/nginx/nginx-gateway-fabric/internal/framework/status"
ngfConfig "github.com/nginx/nginx-gateway-fabric/internal/mode/static/config"
"github.com/nginx/nginx-gateway-fabric/internal/mode/static/licensing"
"github.com/nginx/nginx-gateway-fabric/internal/mode/static/nginx/agent"
ngxConfig "github.com/nginx/nginx-gateway-fabric/internal/mode/static/nginx/config"
"github.com/nginx/nginx-gateway-fabric/internal/mode/static/provisioner"
"github.com/nginx/nginx-gateway-fabric/internal/mode/static/state"
"github.com/nginx/nginx-gateway-fabric/internal/mode/static/state/dataplane"
"github.com/nginx/nginx-gateway-fabric/internal/mode/static/state/graph"
"github.com/nginx/nginx-gateway-fabric/internal/mode/static/state/resolver"
"github.com/nginx/nginx-gateway-fabric/internal/mode/static/status"
)

type handlerMetricsCollector interface {
Expand All @@ -48,7 +47,7 @@ type eventHandlerConfig struct {
// metricsCollector collects metrics for this controller.
metricsCollector handlerMetricsCollector
// statusUpdater updates statuses on Kubernetes resources.
statusUpdater frameworkStatus.GroupUpdater
statusUpdater status.GroupUpdater
// processor is the state ChangeProcessor.
processor state.ChangeProcessor
// serviceResolver resolves Services to Endpoints.
Expand Down Expand Up @@ -351,7 +350,7 @@ func (h *eventHandlerImpl) updateStatuses(ctx context.Context, gr *graph.Graph,
)

reqs := make(
[]frameworkStatus.UpdateRequest,
[]status.UpdateRequest,
0,
len(gcReqs)+len(routeReqs)+len(polReqs)+len(ngfPolReqs)+len(snippetsFilterReqs),
)
Expand Down Expand Up @@ -445,7 +444,7 @@ func (h *eventHandlerImpl) updateControlPlaneAndSetStatus(
cpUpdateRes.Error = err
}

var reqs []frameworkStatus.UpdateRequest
var reqs []status.UpdateRequest

req := status.PrepareNginxGatewayStatus(cfg, metav1.Now(), cpUpdateRes)
if req != nil {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package static
package controller

import (
"context"
Expand All @@ -20,22 +20,22 @@ import (
gatewayv1 "sigs.k8s.io/gateway-api/apis/v1"

ngfAPI "github.com/nginx/nginx-gateway-fabric/apis/v1alpha1"
"github.com/nginx/nginx-gateway-fabric/internal/controller/config"
"github.com/nginx/nginx-gateway-fabric/internal/controller/licensing/licensingfakes"
"github.com/nginx/nginx-gateway-fabric/internal/controller/metrics/collectors"
"github.com/nginx/nginx-gateway-fabric/internal/controller/nginx/agent"
"github.com/nginx/nginx-gateway-fabric/internal/controller/nginx/agent/agentfakes"
agentgrpcfakes "github.com/nginx/nginx-gateway-fabric/internal/controller/nginx/agent/grpc/grpcfakes"
"github.com/nginx/nginx-gateway-fabric/internal/controller/nginx/config/configfakes"
"github.com/nginx/nginx-gateway-fabric/internal/controller/provisioner/provisionerfakes"
"github.com/nginx/nginx-gateway-fabric/internal/controller/state/dataplane"
"github.com/nginx/nginx-gateway-fabric/internal/controller/state/graph"
"github.com/nginx/nginx-gateway-fabric/internal/controller/state/statefakes"
"github.com/nginx/nginx-gateway-fabric/internal/controller/status"
"github.com/nginx/nginx-gateway-fabric/internal/controller/status/statusfakes"
"github.com/nginx/nginx-gateway-fabric/internal/framework/controller"
"github.com/nginx/nginx-gateway-fabric/internal/framework/events"
"github.com/nginx/nginx-gateway-fabric/internal/framework/helpers"
"github.com/nginx/nginx-gateway-fabric/internal/framework/status/statusfakes"
"github.com/nginx/nginx-gateway-fabric/internal/mode/static/config"
"github.com/nginx/nginx-gateway-fabric/internal/mode/static/licensing/licensingfakes"
"github.com/nginx/nginx-gateway-fabric/internal/mode/static/metrics/collectors"
"github.com/nginx/nginx-gateway-fabric/internal/mode/static/nginx/agent"
"github.com/nginx/nginx-gateway-fabric/internal/mode/static/nginx/agent/agentfakes"
agentgrpcfakes "github.com/nginx/nginx-gateway-fabric/internal/mode/static/nginx/agent/grpc/grpcfakes"
"github.com/nginx/nginx-gateway-fabric/internal/mode/static/nginx/config/configfakes"
"github.com/nginx/nginx-gateway-fabric/internal/mode/static/provisioner/provisionerfakes"
"github.com/nginx/nginx-gateway-fabric/internal/mode/static/state/dataplane"
"github.com/nginx/nginx-gateway-fabric/internal/mode/static/state/graph"
"github.com/nginx/nginx-gateway-fabric/internal/mode/static/state/statefakes"
"github.com/nginx/nginx-gateway-fabric/internal/mode/static/status"
)

var _ = Describe("eventHandler", func() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package static
package controller

import (
"errors"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package static
package controller

import (
"testing"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import (
"github.com/go-logr/logr"
"sigs.k8s.io/controller-runtime/pkg/client"

"github.com/nginx/nginx-gateway-fabric/internal/mode/static/state/dataplane"
"github.com/nginx/nginx-gateway-fabric/internal/mode/static/telemetry"
"github.com/nginx/nginx-gateway-fabric/internal/controller/state/dataplane"
"github.com/nginx/nginx-gateway-fabric/internal/controller/telemetry"
)

//go:generate go tool counterfeiter -generate
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"sigs.k8s.io/controller-runtime/pkg/client/fake"

"github.com/nginx/nginx-gateway-fabric/internal/controller/licensing"
"github.com/nginx/nginx-gateway-fabric/internal/controller/state/dataplane"
"github.com/nginx/nginx-gateway-fabric/internal/framework/helpers"
"github.com/nginx/nginx-gateway-fabric/internal/mode/static/licensing"
"github.com/nginx/nginx-gateway-fabric/internal/mode/static/state/dataplane"
)

var _ = Describe("DeploymentContextCollector", func() {
Expand Down

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

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package static
package controller

import (
"errors"
Expand All @@ -7,6 +7,8 @@ import (
"go.uber.org/zap/zapcore"
)

//go:generate go tool counterfeiter -generate

//counterfeiter:generate . logLevelSetter

// logLevelSetter defines an interface for setting the logging level of a logger.
Expand Down
Loading
Loading