Skip to content

Commit

Permalink
Move APIs to be used by both controller and configurer (#8854)
Browse files Browse the repository at this point in the history
  • Loading branch information
rikatz authored Jul 22, 2022
1 parent 4391474 commit c86d50e
Show file tree
Hide file tree
Showing 30 changed files with 30 additions and 35 deletions.
2 changes: 1 addition & 1 deletion hack/update-codegen.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ chmod +x ${CODEGEN_PKG}/generate-groups.sh
# nginxingress:v1alpha1 \
# --output-base "$(dirname ${BASH_SOURCE})/../../.."
${CODEGEN_PKG}/generate-groups.sh "deepcopy" \
k8s.io/ingress-nginx/internal k8s.io/ingress-nginx/internal \
k8s.io/ingress-nginx/internal k8s.io/ingress-nginx/pkg/apis \
.:ingress \
--output-base "$(dirname ${BASH_SOURCE})/../../.." \
--go-header-file ${SCRIPT_ROOT}/hack/boilerplate/boilerplate.generated.go.txt
2 changes: 1 addition & 1 deletion internal/ingress/controller/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ import (

apiv1 "k8s.io/api/core/v1"

"k8s.io/ingress-nginx/internal/ingress"
"k8s.io/ingress-nginx/internal/ingress/defaults"
"k8s.io/ingress-nginx/pkg/apis/ingress"
"k8s.io/ingress-nginx/pkg/util/runtime"
)

Expand Down
2 changes: 1 addition & 1 deletion internal/ingress/controller/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ import (
"k8s.io/apimachinery/pkg/util/sets"
"k8s.io/apimachinery/pkg/util/wait"
clientset "k8s.io/client-go/kubernetes"
"k8s.io/ingress-nginx/internal/ingress"
"k8s.io/ingress-nginx/internal/ingress/annotations"
"k8s.io/ingress-nginx/internal/ingress/annotations/log"
"k8s.io/ingress-nginx/internal/ingress/annotations/parser"
Expand All @@ -45,6 +44,7 @@ import (
"k8s.io/ingress-nginx/internal/ingress/metric/collectors"
"k8s.io/ingress-nginx/internal/k8s"
"k8s.io/ingress-nginx/internal/nginx"
"k8s.io/ingress-nginx/pkg/apis/ingress"
"k8s.io/klog/v2"
)

Expand Down
2 changes: 1 addition & 1 deletion internal/ingress/controller/controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ import (
"k8s.io/apimachinery/pkg/labels"
"k8s.io/client-go/kubernetes/fake"

"k8s.io/ingress-nginx/internal/ingress"
"k8s.io/ingress-nginx/pkg/apis/ingress"

"k8s.io/ingress-nginx/internal/ingress/annotations"
"k8s.io/ingress-nginx/internal/ingress/annotations/canary"
Expand Down
2 changes: 1 addition & 1 deletion internal/ingress/controller/endpoints.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ import (

corev1 "k8s.io/api/core/v1"

"k8s.io/ingress-nginx/internal/ingress"
"k8s.io/ingress-nginx/internal/k8s"
"k8s.io/ingress-nginx/pkg/apis/ingress"
)

// getEndpoints returns a list of Endpoint structs for a given service/target port combination.
Expand Down
2 changes: 1 addition & 1 deletion internal/ingress/controller/endpoints_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (

corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/util/intstr"
"k8s.io/ingress-nginx/internal/ingress"
"k8s.io/ingress-nginx/pkg/apis/ingress"
)

func TestGetEndpoints(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion internal/ingress/controller/location.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (
"strings"

networking "k8s.io/api/networking/v1"
"k8s.io/ingress-nginx/internal/ingress"
"k8s.io/ingress-nginx/pkg/apis/ingress"
)

var (
Expand Down
2 changes: 1 addition & 1 deletion internal/ingress/controller/nginx.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ import (
"k8s.io/ingress-nginx/pkg/tcpproxy"

adm_controller "k8s.io/ingress-nginx/internal/admission/controller"
"k8s.io/ingress-nginx/internal/ingress"
ngx_config "k8s.io/ingress-nginx/internal/ingress/controller/config"
"k8s.io/ingress-nginx/internal/ingress/controller/process"
"k8s.io/ingress-nginx/internal/ingress/controller/store"
Expand All @@ -59,6 +58,7 @@ import (
"k8s.io/ingress-nginx/internal/net/ssl"
"k8s.io/ingress-nginx/internal/nginx"
"k8s.io/ingress-nginx/internal/task"
"k8s.io/ingress-nginx/pkg/apis/ingress"

"k8s.io/ingress-nginx/pkg/util/file"
klog "k8s.io/klog/v2"
Expand Down
2 changes: 1 addition & 1 deletion internal/ingress/controller/nginx_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ import (
apiv1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/util/wait"

"k8s.io/ingress-nginx/internal/ingress"
"k8s.io/ingress-nginx/internal/nginx"
"k8s.io/ingress-nginx/pkg/apis/ingress"
)

func TestIsDynamicConfigurationEnough(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion internal/ingress/controller/store/backend_ssl.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (
networking "k8s.io/api/networking/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

"k8s.io/ingress-nginx/internal/ingress"
"k8s.io/ingress-nginx/pkg/apis/ingress"

klog "k8s.io/klog/v2"

Expand Down
2 changes: 1 addition & 1 deletion internal/ingress/controller/store/ingress.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ package store
import (
networking "k8s.io/api/networking/v1"
"k8s.io/client-go/tools/cache"
"k8s.io/ingress-nginx/internal/ingress"
"k8s.io/ingress-nginx/pkg/apis/ingress"
)

// IngressLister makes a Store that lists Ingress.
Expand Down
2 changes: 1 addition & 1 deletion internal/ingress/controller/store/ingress_annotation.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ package store

import (
"k8s.io/client-go/tools/cache"
"k8s.io/ingress-nginx/internal/ingress"
"k8s.io/ingress-nginx/pkg/apis/ingress"
)

// IngressWithAnnotationsLister makes a Store that lists Ingress rules with annotations already parsed
Expand Down
2 changes: 1 addition & 1 deletion internal/ingress/controller/store/local_secret.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (

"k8s.io/client-go/tools/cache"

"k8s.io/ingress-nginx/internal/ingress"
"k8s.io/ingress-nginx/pkg/apis/ingress"
)

// SSLCertTracker holds a store of referenced Secrets in Ingress rules
Expand Down
2 changes: 1 addition & 1 deletion internal/ingress/controller/store/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ import (
"k8s.io/ingress-nginx/pkg/util/file"
klog "k8s.io/klog/v2"

"k8s.io/ingress-nginx/internal/ingress"
"k8s.io/ingress-nginx/internal/ingress/annotations"
"k8s.io/ingress-nginx/internal/ingress/annotations/parser"
ngx_config "k8s.io/ingress-nginx/internal/ingress/controller/config"
Expand All @@ -58,6 +57,7 @@ import (
"k8s.io/ingress-nginx/internal/ingress/errors"
"k8s.io/ingress-nginx/internal/ingress/resolver"
"k8s.io/ingress-nginx/internal/k8s"
"k8s.io/ingress-nginx/pkg/apis/ingress"
)

// IngressFilterFunc decides if an Ingress should be omitted or not
Expand Down
2 changes: 1 addition & 1 deletion internal/ingress/controller/store/store_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ import (
"k8s.io/client-go/tools/cache"
"sigs.k8s.io/controller-runtime/pkg/envtest"

"k8s.io/ingress-nginx/internal/ingress"
"k8s.io/ingress-nginx/internal/ingress/annotations/parser"
"k8s.io/ingress-nginx/internal/ingress/controller/ingressclass"
"k8s.io/ingress-nginx/pkg/apis/ingress"
"k8s.io/ingress-nginx/test/e2e/framework"
)

Expand Down
2 changes: 1 addition & 1 deletion internal/ingress/controller/template/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,12 @@ import (
"k8s.io/apimachinery/pkg/util/sets"
"k8s.io/klog/v2"

"k8s.io/ingress-nginx/internal/ingress"
"k8s.io/ingress-nginx/internal/ingress/annotations/influxdb"
"k8s.io/ingress-nginx/internal/ingress/annotations/parser"
"k8s.io/ingress-nginx/internal/ingress/annotations/ratelimit"
"k8s.io/ingress-nginx/internal/ingress/controller/config"
ing_net "k8s.io/ingress-nginx/internal/net"
"k8s.io/ingress-nginx/pkg/apis/ingress"
)

const (
Expand Down
2 changes: 1 addition & 1 deletion internal/ingress/controller/template/template_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ import (
networking "k8s.io/api/networking/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

"k8s.io/ingress-nginx/internal/ingress"
"k8s.io/ingress-nginx/internal/ingress/annotations/authreq"
"k8s.io/ingress-nginx/internal/ingress/annotations/influxdb"
"k8s.io/ingress-nginx/internal/ingress/annotations/modsecurity"
Expand All @@ -43,6 +42,7 @@ import (
"k8s.io/ingress-nginx/internal/ingress/annotations/rewrite"
"k8s.io/ingress-nginx/internal/ingress/controller/config"
"k8s.io/ingress-nginx/internal/nginx"
"k8s.io/ingress-nginx/pkg/apis/ingress"
)

func init() {
Expand Down
2 changes: 1 addition & 1 deletion internal/ingress/controller/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import (
api "k8s.io/api/core/v1"
networking "k8s.io/api/networking/v1"
"k8s.io/apimachinery/pkg/util/intstr"
"k8s.io/ingress-nginx/internal/ingress"
"k8s.io/ingress-nginx/pkg/apis/ingress"
klog "k8s.io/klog/v2"
)

Expand Down
2 changes: 1 addition & 1 deletion internal/ingress/metric/collectors/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (

"github.com/prometheus/client_golang/prometheus"
"k8s.io/apimachinery/pkg/util/sets"
"k8s.io/ingress-nginx/internal/ingress"
"k8s.io/ingress-nginx/pkg/apis/ingress"
"k8s.io/ingress-nginx/version"
"k8s.io/klog/v2"
)
Expand Down
2 changes: 1 addition & 1 deletion internal/ingress/metric/collectors/controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (
"time"

"github.com/prometheus/client_golang/prometheus"
"k8s.io/ingress-nginx/internal/ingress"
"k8s.io/ingress-nginx/pkg/apis/ingress"
)

func TestControllerCounters(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion internal/ingress/metric/dummy.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ package metric

import (
"k8s.io/apimachinery/pkg/util/sets"
"k8s.io/ingress-nginx/internal/ingress"
"k8s.io/ingress-nginx/pkg/apis/ingress"
)

// NewDummyCollector returns a dummy metric collector
Expand Down
2 changes: 1 addition & 1 deletion internal/ingress/metric/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ import (
"k8s.io/klog/v2"

"k8s.io/apimachinery/pkg/util/sets"
"k8s.io/ingress-nginx/internal/ingress"
"k8s.io/ingress-nginx/internal/ingress/metric/collectors"
"k8s.io/ingress-nginx/pkg/apis/ingress"
)

// Collector defines the interface for a metric collector
Expand Down
2 changes: 1 addition & 1 deletion internal/ingress/status/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ import (
"k8s.io/apimachinery/pkg/util/wait"
clientset "k8s.io/client-go/kubernetes"

"k8s.io/ingress-nginx/internal/ingress"
"k8s.io/ingress-nginx/internal/k8s"
"k8s.io/ingress-nginx/internal/task"
"k8s.io/ingress-nginx/pkg/apis/ingress"
)

// UpdateInterval defines the time interval, in seconds, in
Expand Down
2 changes: 1 addition & 1 deletion internal/ingress/status/status_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
testclient "k8s.io/client-go/kubernetes/fake"

"k8s.io/ingress-nginx/internal/ingress"
"k8s.io/ingress-nginx/internal/ingress/controller/ingressclass"
"k8s.io/ingress-nginx/internal/k8s"
"k8s.io/ingress-nginx/internal/task"
"k8s.io/ingress-nginx/pkg/apis/ingress"
)

func buildLoadBalancerIngressByIP() []apiv1.LoadBalancerIngress {
Expand Down
2 changes: 1 addition & 1 deletion internal/net/ssl/ssl.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ import (
"github.com/zakjan/cert-chain-resolver/certUtil"
"k8s.io/apimachinery/pkg/util/sets"

"k8s.io/ingress-nginx/internal/ingress"
"k8s.io/ingress-nginx/pkg/apis/ingress"

ngx_config "k8s.io/ingress-nginx/internal/ingress/controller/config"
"k8s.io/ingress-nginx/pkg/util/file"
Expand Down
File renamed without changes.
9 changes: 2 additions & 7 deletions internal/ingress/types.go → pkg/apis/ingress/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,8 @@ import (
"k8s.io/ingress-nginx/internal/ingress/annotations/rewrite"
)

var (
// DefaultSSLDirectory defines the location where the SSL certificates will be generated
// This directory contains all the SSL certificates that are specified in Ingress rules.
// The name of each file is <namespace>-<secret name>.pem. The content is the concatenated
// certificate and key.
DefaultSSLDirectory = "/ingress-controller/ssl"
)
// TODO: The API shouldn't be importing structs from annotation code. Instead we probably want a conversion from internal
// to API object, or see how much effort is to move the structs of annotations to become an "API'ish" as well

// Configuration holds the definition of all the parts required to describe all
// ingresses reachable by the ingress controller (using a filter by namespace)
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,19 @@ import (
)

func TestEqualConfiguration(t *testing.T) {
ap, _ := filepath.Abs("../../test/manifests/configuration-a.json")
ap, _ := filepath.Abs("../../../test/manifests/configuration-a.json")
a, err := readJSON(ap)
if err != nil {
t.Errorf("unexpected error reading JSON file: %v", err)
}

bp, _ := filepath.Abs("../../test/manifests/configuration-b.json")
bp, _ := filepath.Abs("../../../test/manifests/configuration-b.json")
b, err := readJSON(bp)
if err != nil {
t.Errorf("unexpected error reading JSON file: %v", err)
}

cp, _ := filepath.Abs("../../test/manifests/configuration-c.json")
cp, _ := filepath.Abs("../../../test/manifests/configuration-c.json")
c, err := readJSON(cp)
if err != nil {
t.Errorf("unexpected error reading JSON file: %v", err)
Expand Down
File renamed without changes.

0 comments on commit c86d50e

Please sign in to comment.