Fix comments
Signed-off-by: z1cheng <imchench@gmail.com>
This commit is contained in:
parent
587963a1c6
commit
515de74955
7 changed files with 50 additions and 46 deletions
|
@ -716,7 +716,7 @@ Do not try to edit it manually.
|
||||||
|
|
||||||
### [[Flag] watch namespace selector](https://github.com/kubernetes/ingress-nginx/tree/main/test/e2e/settings/namespace_selector.go#L30)
|
### [[Flag] watch namespace selector](https://github.com/kubernetes/ingress-nginx/tree/main/test/e2e/settings/namespace_selector.go#L30)
|
||||||
|
|
||||||
- [should ingore Ingress of namespace without label foo=bar and accept those of namespace with label foo=bar](https://github.com/kubernetes/ingress-nginx/tree/main/test/e2e/settings/namespace_selector.go#L63)
|
- [should ignore Ingress of namespace without label foo=bar and accept those of namespace with label foo=bar](https://github.com/kubernetes/ingress-nginx/tree/main/test/e2e/settings/namespace_selector.go#L63)
|
||||||
|
|
||||||
### [[Security] no-auth-locations](https://github.com/kubernetes/ingress-nginx/tree/main/test/e2e/settings/no_auth_locations.go#L33)
|
### [[Security] no-auth-locations](https://github.com/kubernetes/ingress-nginx/tree/main/test/e2e/settings/no_auth_locations.go#L33)
|
||||||
|
|
||||||
|
|
|
@ -65,6 +65,9 @@ func TestParse(t *testing.T) {
|
||||||
if testCase.skipValidation {
|
if testCase.skipValidation {
|
||||||
parser.EnableAnnotationValidation = false
|
parser.EnableAnnotationValidation = false
|
||||||
}
|
}
|
||||||
|
t.Cleanup(func() {
|
||||||
|
parser.EnableAnnotationValidation = true
|
||||||
|
})
|
||||||
result, err := ap.Parse(ing)
|
result, err := ap.Parse(ing)
|
||||||
if (err != nil) != testCase.wantErr {
|
if (err != nil) != testCase.wantErr {
|
||||||
t.Errorf("ParseAliasAnnotation() annotation: %s, error = %v, wantErr %v", testCase.annotations, err, testCase.wantErr)
|
t.Errorf("ParseAliasAnnotation() annotation: %s, error = %v, wantErr %v", testCase.annotations, err, testCase.wantErr)
|
||||||
|
@ -73,6 +76,4 @@ func TestParse(t *testing.T) {
|
||||||
t.Errorf("expected %v but returned %v, annotations: %s", testCase.expected, result, testCase.annotations)
|
t.Errorf("expected %v but returned %v, annotations: %s", testCase.expected, result, testCase.annotations)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
parser.EnableAnnotationValidation = true
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -86,7 +86,6 @@ type Ingress struct {
|
||||||
CorsConfig cors.Config
|
CorsConfig cors.Config
|
||||||
CustomHTTPErrors []int
|
CustomHTTPErrors []int
|
||||||
DefaultBackend *apiv1.Service
|
DefaultBackend *apiv1.Service
|
||||||
// TODO: Change this back into an error when https://github.com/imdario/mergo/issues/100 is resolved
|
|
||||||
FastCGI fastcgi.Config
|
FastCGI fastcgi.Config
|
||||||
Denied *string
|
Denied *string
|
||||||
ExternalAuth authreq.Config
|
ExternalAuth authreq.Config
|
||||||
|
|
|
@ -195,7 +195,7 @@ func (n *NGINXController) syncIngress(interface{}) error {
|
||||||
|
|
||||||
pcfg.ConfigurationChecksum = fmt.Sprintf("%v", hash)
|
pcfg.ConfigurationChecksum = fmt.Sprintf("%v", hash)
|
||||||
|
|
||||||
err := n.OnUpdate(pcfg)
|
err := n.OnUpdate(*pcfg)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
n.metricCollector.IncReloadErrorCount()
|
n.metricCollector.IncReloadErrorCount()
|
||||||
n.metricCollector.ConfigSuccess(hash, false)
|
n.metricCollector.ConfigSuccess(hash, false)
|
||||||
|
@ -410,7 +410,7 @@ func (n *NGINXController) CheckIngress(ing *networking.Ingress) error {
|
||||||
testedSize = 1
|
testedSize = 1
|
||||||
}
|
}
|
||||||
|
|
||||||
content, err := n.generateTemplate(&cfg, pcfg)
|
content, err := n.generateTemplate(cfg, *pcfg)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
n.metricCollector.IncCheckErrorCount(ing.ObjectMeta.Namespace, ing.Name)
|
n.metricCollector.IncCheckErrorCount(ing.ObjectMeta.Namespace, ing.Name)
|
||||||
return err
|
return err
|
||||||
|
@ -530,7 +530,7 @@ func (n *NGINXController) getStreamServices(configmapName string, proto apiv1.Pr
|
||||||
klog.V(3).Infof("Searching Endpoints with %v port number %d for Service %q", proto, targetPort, nsName)
|
klog.V(3).Infof("Searching Endpoints with %v port number %d for Service %q", proto, targetPort, nsName)
|
||||||
for i := range svc.Spec.Ports {
|
for i := range svc.Spec.Ports {
|
||||||
sp := svc.Spec.Ports[i]
|
sp := svc.Spec.Ports[i]
|
||||||
//nolint:gosec // Ingore G109 error
|
//nolint:gosec // Ignore G109 error
|
||||||
if sp.Port == int32(targetPort) {
|
if sp.Port == int32(targetPort) {
|
||||||
if sp.Protocol == proto {
|
if sp.Protocol == proto {
|
||||||
endps = getEndpointsFromSlices(svc, &sp, proto, zone, n.store.GetServiceEndpointsSlices)
|
endps = getEndpointsFromSlices(svc, &sp, proto, zone, n.store.GetServiceEndpointsSlices)
|
||||||
|
@ -1750,7 +1750,7 @@ func externalNamePorts(name string, svc *apiv1.Service) *apiv1.ServicePort {
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, svcPort := range svc.Spec.Ports {
|
for _, svcPort := range svc.Spec.Ports {
|
||||||
//nolint:gosec // Ingore G109 error
|
//nolint:gosec // Ignore G109 error
|
||||||
if svcPort.Port != int32(port) {
|
if svcPort.Port != int32(port) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
@ -1770,7 +1770,7 @@ func externalNamePorts(name string, svc *apiv1.Service) *apiv1.ServicePort {
|
||||||
// ExternalName without port
|
// ExternalName without port
|
||||||
return &apiv1.ServicePort{
|
return &apiv1.ServicePort{
|
||||||
Protocol: "TCP",
|
Protocol: "TCP",
|
||||||
//nolint:gosec // Ingore G109 error
|
//nolint:gosec // Ignore G109 error
|
||||||
Port: int32(port),
|
Port: int32(port),
|
||||||
TargetPort: intstr.FromInt(port),
|
TargetPort: intstr.FromInt(port),
|
||||||
}
|
}
|
||||||
|
|
|
@ -438,7 +438,9 @@ func (n *NGINXController) DefaultEndpoint() ingress.Endpoint {
|
||||||
}
|
}
|
||||||
|
|
||||||
// generateTemplate returns the nginx configuration file content
|
// generateTemplate returns the nginx configuration file content
|
||||||
func (n *NGINXController) generateTemplate(cfg *ngx_config.Configuration, ingressCfg *ingress.Configuration) ([]byte, error) {
|
//
|
||||||
|
//nolint:gocritic // the cfg shouldn't be changed, and shouldn't be mutated by other processes while being rendered.
|
||||||
|
func (n *NGINXController) generateTemplate(cfg ngx_config.Configuration, ingressCfg ingress.Configuration) ([]byte, error) {
|
||||||
if n.cfg.EnableSSLPassthrough {
|
if n.cfg.EnableSSLPassthrough {
|
||||||
servers := []*tcpproxy.TCPServer{}
|
servers := []*tcpproxy.TCPServer{}
|
||||||
for _, pb := range ingressCfg.PassthroughBackends {
|
for _, pb := range ingressCfg.PassthroughBackends {
|
||||||
|
@ -598,7 +600,7 @@ func (n *NGINXController) generateTemplate(cfg *ngx_config.Configuration, ingres
|
||||||
Servers: ingressCfg.Servers,
|
Servers: ingressCfg.Servers,
|
||||||
TCPBackends: ingressCfg.TCPEndpoints,
|
TCPBackends: ingressCfg.TCPEndpoints,
|
||||||
UDPBackends: ingressCfg.UDPEndpoints,
|
UDPBackends: ingressCfg.UDPEndpoints,
|
||||||
Cfg: *cfg,
|
Cfg: cfg,
|
||||||
IsIPV6Enabled: n.isIPV6Enabled && !cfg.DisableIpv6,
|
IsIPV6Enabled: n.isIPV6Enabled && !cfg.DisableIpv6,
|
||||||
NginxStatusIpv4Whitelist: cfg.NginxStatusIpv4Whitelist,
|
NginxStatusIpv4Whitelist: cfg.NginxStatusIpv4Whitelist,
|
||||||
NginxStatusIpv6Whitelist: cfg.NginxStatusIpv6Whitelist,
|
NginxStatusIpv6Whitelist: cfg.NginxStatusIpv6Whitelist,
|
||||||
|
@ -658,11 +660,13 @@ Error: %v
|
||||||
// changes were detected. The received backend Configuration is merged with the
|
// changes were detected. The received backend Configuration is merged with the
|
||||||
// configuration ConfigMap before generating the final configuration file.
|
// configuration ConfigMap before generating the final configuration file.
|
||||||
// Returns nil in case the backend was successfully reloaded.
|
// Returns nil in case the backend was successfully reloaded.
|
||||||
func (n *NGINXController) OnUpdate(ingressCfg *ingress.Configuration) error {
|
//
|
||||||
|
//nolint:gocritic // the cfg shouldn't be changed, and shouldn't be mutated by other processes while being rendered.
|
||||||
|
func (n *NGINXController) OnUpdate(ingressCfg ingress.Configuration) error {
|
||||||
cfg := n.store.GetBackendConfiguration()
|
cfg := n.store.GetBackendConfiguration()
|
||||||
cfg.Resolver = n.resolver
|
cfg.Resolver = n.resolver
|
||||||
|
|
||||||
content, err := n.generateTemplate(&cfg, ingressCfg)
|
content, err := n.generateTemplate(cfg, ingressCfg)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,7 +44,7 @@ import (
|
||||||
// which the status should check if an update is required.
|
// which the status should check if an update is required.
|
||||||
var UpdateInterval = 60
|
var UpdateInterval = 60
|
||||||
|
|
||||||
// Syncer syncer
|
// Syncer is an interface that implements syncer
|
||||||
type Syncer interface {
|
type Syncer interface {
|
||||||
Run(chan struct{})
|
Run(chan struct{})
|
||||||
|
|
||||||
|
@ -56,7 +56,7 @@ type ingressLister interface {
|
||||||
ListIngresses() []*ingress.Ingress
|
ListIngresses() []*ingress.Ingress
|
||||||
}
|
}
|
||||||
|
|
||||||
// Config config
|
// Config is a structure that implements Client interfaces
|
||||||
type Config struct {
|
type Config struct {
|
||||||
Client clientset.Interface
|
Client clientset.Interface
|
||||||
|
|
||||||
|
|
|
@ -59,7 +59,7 @@ var _ = framework.IngressNginxDescribeSerial("[Flag] watch namespace selector",
|
||||||
})
|
})
|
||||||
|
|
||||||
ginkgo.Context("With specific watch-namespace-selector flags", func() {
|
ginkgo.Context("With specific watch-namespace-selector flags", func() {
|
||||||
ginkgo.It("should ingore Ingress of namespace without label foo=bar and accept those of namespace with label foo=bar", func() {
|
ginkgo.It("should ignore Ingress of namespace without label foo=bar and accept those of namespace with label foo=bar", func() {
|
||||||
f.WaitForNginxConfiguration(func(cfg string) bool {
|
f.WaitForNginxConfiguration(func(cfg string) bool {
|
||||||
return !strings.Contains(cfg, "server_name bar") &&
|
return !strings.Contains(cfg, "server_name bar") &&
|
||||||
strings.Contains(cfg, "server_name foo")
|
strings.Contains(cfg, "server_name foo")
|
||||||
|
|
Loading…
Reference in a new issue