Merge pull request #8853 from rikatz/move-more-utils
Move utils to better locations to help in decoupling
This commit is contained in:
commit
4391474bf1
12 changed files with 21 additions and 24 deletions
|
@ -28,7 +28,7 @@ import (
|
|||
"k8s.io/ingress-nginx/internal/ingress/annotations/parser"
|
||||
ing_errors "k8s.io/ingress-nginx/internal/ingress/errors"
|
||||
"k8s.io/ingress-nginx/internal/ingress/resolver"
|
||||
"k8s.io/ingress-nginx/internal/sets"
|
||||
"k8s.io/ingress-nginx/pkg/util/sets"
|
||||
)
|
||||
|
||||
// Config returns external authentication configuration for an Ingress rule
|
||||
|
|
|
@ -27,7 +27,7 @@ import (
|
|||
ing_errors "k8s.io/ingress-nginx/internal/ingress/errors"
|
||||
"k8s.io/ingress-nginx/internal/ingress/resolver"
|
||||
"k8s.io/ingress-nginx/internal/net"
|
||||
"k8s.io/ingress-nginx/internal/sets"
|
||||
"k8s.io/ingress-nginx/pkg/util/sets"
|
||||
)
|
||||
|
||||
const defaultKey = "$remote_addr"
|
||||
|
|
|
@ -27,7 +27,7 @@ import (
|
|||
"k8s.io/ingress-nginx/internal/ingress/annotations/parser"
|
||||
ing_errors "k8s.io/ingress-nginx/internal/ingress/errors"
|
||||
"k8s.io/ingress-nginx/internal/ingress/resolver"
|
||||
"k8s.io/ingress-nginx/internal/sets"
|
||||
"k8s.io/ingress-nginx/pkg/util/sets"
|
||||
)
|
||||
|
||||
// SourceRange returns the CIDR
|
||||
|
|
|
@ -26,7 +26,7 @@ import (
|
|||
"k8s.io/ingress-nginx/internal/ingress/annotations/parser"
|
||||
"k8s.io/ingress-nginx/internal/ingress/resolver"
|
||||
"k8s.io/ingress-nginx/internal/net"
|
||||
"k8s.io/ingress-nginx/internal/sets"
|
||||
"k8s.io/ingress-nginx/pkg/util/sets"
|
||||
)
|
||||
|
||||
const (
|
||||
|
|
|
@ -44,6 +44,7 @@ import (
|
|||
v1core "k8s.io/client-go/kubernetes/typed/core/v1"
|
||||
"k8s.io/client-go/tools/record"
|
||||
"k8s.io/client-go/util/flowcontrol"
|
||||
"k8s.io/ingress-nginx/pkg/tcpproxy"
|
||||
|
||||
adm_controller "k8s.io/ingress-nginx/internal/admission/controller"
|
||||
"k8s.io/ingress-nginx/internal/ingress"
|
||||
|
@ -58,7 +59,6 @@ import (
|
|||
"k8s.io/ingress-nginx/internal/net/ssl"
|
||||
"k8s.io/ingress-nginx/internal/nginx"
|
||||
"k8s.io/ingress-nginx/internal/task"
|
||||
"k8s.io/ingress-nginx/internal/watch"
|
||||
|
||||
"k8s.io/ingress-nginx/pkg/util/file"
|
||||
klog "k8s.io/klog/v2"
|
||||
|
@ -102,7 +102,7 @@ func NewNGINXController(config *Configuration, mc metric.Collector) *NGINXContro
|
|||
|
||||
runningConfig: new(ingress.Configuration),
|
||||
|
||||
Proxy: &TCPProxy{},
|
||||
Proxy: &tcpproxy.TCPProxy{},
|
||||
|
||||
metricCollector: mc,
|
||||
|
||||
|
@ -172,7 +172,7 @@ func NewNGINXController(config *Configuration, mc metric.Collector) *NGINXContro
|
|||
|
||||
n.t = ngxTpl
|
||||
|
||||
_, err = watch.NewFileWatcher(nginx.TemplatePath, onTemplateChange)
|
||||
_, err = file.NewFileWatcher(nginx.TemplatePath, onTemplateChange)
|
||||
if err != nil {
|
||||
klog.Fatalf("Error creating file watcher for %v: %v", nginx.TemplatePath, err)
|
||||
}
|
||||
|
@ -196,7 +196,7 @@ func NewNGINXController(config *Configuration, mc metric.Collector) *NGINXContro
|
|||
}
|
||||
|
||||
for _, f := range filesToWatch {
|
||||
_, err = watch.NewFileWatcher(f, func() {
|
||||
_, err = file.NewFileWatcher(f, func() {
|
||||
klog.InfoS("File changed detected. Reloading NGINX", "path", f)
|
||||
n.syncQueue.EnqueueTask(task.GetDummyObject("file-change"))
|
||||
})
|
||||
|
@ -242,7 +242,7 @@ type NGINXController struct {
|
|||
|
||||
isShuttingDown bool
|
||||
|
||||
Proxy *TCPProxy
|
||||
Proxy *tcpproxy.TCPProxy
|
||||
|
||||
store store.Storer
|
||||
|
||||
|
@ -440,7 +440,7 @@ func (n NGINXController) DefaultEndpoint() ingress.Endpoint {
|
|||
func (n NGINXController) generateTemplate(cfg ngx_config.Configuration, ingressCfg ingress.Configuration) ([]byte, error) {
|
||||
|
||||
if n.cfg.EnableSSLPassthrough {
|
||||
servers := []*TCPServer{}
|
||||
servers := []*tcpproxy.TCPServer{}
|
||||
for _, pb := range ingressCfg.PassthroughBackends {
|
||||
svc := pb.Service
|
||||
if svc == nil {
|
||||
|
@ -465,7 +465,7 @@ func (n NGINXController) generateTemplate(cfg ngx_config.Configuration, ingressC
|
|||
}
|
||||
|
||||
// TODO: Allow PassthroughBackends to specify they support proxy-protocol
|
||||
servers = append(servers, &TCPServer{
|
||||
servers = append(servers, &tcpproxy.TCPServer{
|
||||
Hostname: pb.Hostname,
|
||||
IP: svc.Spec.ClusterIP,
|
||||
Port: port,
|
||||
|
@ -752,8 +752,8 @@ func (n *NGINXController) setupSSLProxy() {
|
|||
proxyPort := n.cfg.ListenPorts.SSLProxy
|
||||
|
||||
klog.InfoS("Starting TLS proxy for SSL Passthrough")
|
||||
n.Proxy = &TCPProxy{
|
||||
Default: &TCPServer{
|
||||
n.Proxy = &tcpproxy.TCPProxy{
|
||||
Default: &tcpproxy.TCPServer{
|
||||
Hostname: "localhost",
|
||||
IP: "127.0.0.1",
|
||||
Port: proxyPort,
|
||||
|
|
|
@ -17,7 +17,7 @@ limitations under the License.
|
|||
package ingress
|
||||
|
||||
import (
|
||||
"k8s.io/ingress-nginx/internal/sets"
|
||||
"k8s.io/ingress-nginx/pkg/util/sets"
|
||||
)
|
||||
|
||||
// Equal tests for equality between two Configuration types
|
||||
|
|
|
@ -43,9 +43,8 @@ import (
|
|||
"k8s.io/ingress-nginx/internal/ingress"
|
||||
|
||||
ngx_config "k8s.io/ingress-nginx/internal/ingress/controller/config"
|
||||
"k8s.io/ingress-nginx/internal/watch"
|
||||
|
||||
"k8s.io/ingress-nginx/pkg/util/file"
|
||||
|
||||
klog "k8s.io/klog/v2"
|
||||
)
|
||||
|
||||
|
@ -509,8 +508,8 @@ func NewTLSListener(certificate, key string) *TLSListener {
|
|||
|
||||
l.load()
|
||||
|
||||
_, _ = watch.NewFileWatcher(certificate, l.load)
|
||||
_, _ = watch.NewFileWatcher(key, l.load)
|
||||
_, _ = file.NewFileWatcher(certificate, l.load)
|
||||
_, _ = file.NewFileWatcher(key, l.load)
|
||||
|
||||
return &l
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
|
|||
limitations under the License.
|
||||
*/
|
||||
|
||||
package controller
|
||||
package tcpproxy
|
||||
|
||||
import (
|
||||
"fmt"
|
|
@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
|
|||
limitations under the License.
|
||||
*/
|
||||
|
||||
package watch
|
||||
package file
|
||||
|
||||
import (
|
||||
"log"
|
|
@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
|
|||
limitations under the License.
|
||||
*/
|
||||
|
||||
package watch
|
||||
package file
|
||||
|
||||
import (
|
||||
"os"
|
||||
|
@ -22,8 +22,6 @@ import (
|
|||
"path/filepath"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"k8s.io/ingress-nginx/pkg/util/file"
|
||||
)
|
||||
|
||||
func prepareTimeout() chan bool {
|
||||
|
@ -61,7 +59,7 @@ func TestFileWatcher(t *testing.T) {
|
|||
t.Fatalf("expected no events before writing a file")
|
||||
case <-timeoutChan:
|
||||
}
|
||||
os.WriteFile(f.Name(), []byte{}, file.ReadWriteByUser)
|
||||
os.WriteFile(f.Name(), []byte{}, ReadWriteByUser)
|
||||
select {
|
||||
case <-events:
|
||||
case <-timeoutChan:
|
Loading…
Reference in a new issue