Bump kubernetes/client-go
This commit is contained in:
parent
029fa83690
commit
83a92596c3
901 changed files with 169303 additions and 306433 deletions
|
@ -4,39 +4,40 @@ import (
|
|||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"k8s.io/client-go/pkg/api/v1"
|
||||
"k8s.io/client-go/pkg/types"
|
||||
corev1 "k8s.io/api/core/v1"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/types"
|
||||
)
|
||||
|
||||
func buildEndpoint(opts ...func(*v1.Endpoints)) *v1.Endpoints {
|
||||
e := &v1.Endpoints{}
|
||||
func buildEndpoint(opts ...func(*corev1.Endpoints)) *corev1.Endpoints {
|
||||
e := &corev1.Endpoints{}
|
||||
for _, opt := range opts {
|
||||
opt(e)
|
||||
}
|
||||
return e
|
||||
}
|
||||
|
||||
func eNamespace(value string) func(*v1.Endpoints) {
|
||||
return func(i *v1.Endpoints) {
|
||||
func eNamespace(value string) func(*corev1.Endpoints) {
|
||||
return func(i *corev1.Endpoints) {
|
||||
i.Namespace = value
|
||||
}
|
||||
}
|
||||
|
||||
func eName(value string) func(*v1.Endpoints) {
|
||||
return func(i *v1.Endpoints) {
|
||||
func eName(value string) func(*corev1.Endpoints) {
|
||||
return func(i *corev1.Endpoints) {
|
||||
i.Name = value
|
||||
}
|
||||
}
|
||||
|
||||
func eUID(value types.UID) func(*v1.Endpoints) {
|
||||
return func(i *v1.Endpoints) {
|
||||
func eUID(value types.UID) func(*corev1.Endpoints) {
|
||||
return func(i *corev1.Endpoints) {
|
||||
i.UID = value
|
||||
}
|
||||
}
|
||||
|
||||
func subset(opts ...func(*v1.EndpointSubset)) func(*v1.Endpoints) {
|
||||
return func(e *v1.Endpoints) {
|
||||
s := &v1.EndpointSubset{}
|
||||
func subset(opts ...func(*corev1.EndpointSubset)) func(*corev1.Endpoints) {
|
||||
return func(e *corev1.Endpoints) {
|
||||
s := &corev1.EndpointSubset{}
|
||||
for _, opt := range opts {
|
||||
opt(s)
|
||||
}
|
||||
|
@ -44,9 +45,9 @@ func subset(opts ...func(*v1.EndpointSubset)) func(*v1.Endpoints) {
|
|||
}
|
||||
}
|
||||
|
||||
func eAddresses(opts ...func(*v1.EndpointAddress)) func(*v1.EndpointSubset) {
|
||||
return func(subset *v1.EndpointSubset) {
|
||||
a := &v1.EndpointAddress{}
|
||||
func eAddresses(opts ...func(*corev1.EndpointAddress)) func(*corev1.EndpointSubset) {
|
||||
return func(subset *corev1.EndpointSubset) {
|
||||
a := &corev1.EndpointAddress{}
|
||||
for _, opt := range opts {
|
||||
opt(a)
|
||||
}
|
||||
|
@ -54,24 +55,24 @@ func eAddresses(opts ...func(*v1.EndpointAddress)) func(*v1.EndpointSubset) {
|
|||
}
|
||||
}
|
||||
|
||||
func eAddress(ip string) func(*v1.EndpointAddress) {
|
||||
return func(address *v1.EndpointAddress) {
|
||||
func eAddress(ip string) func(*corev1.EndpointAddress) {
|
||||
return func(address *corev1.EndpointAddress) {
|
||||
address.IP = ip
|
||||
}
|
||||
}
|
||||
|
||||
func ePorts(opts ...func(port *v1.EndpointPort)) func(*v1.EndpointSubset) {
|
||||
return func(spec *v1.EndpointSubset) {
|
||||
func ePorts(opts ...func(port *corev1.EndpointPort)) func(*corev1.EndpointSubset) {
|
||||
return func(spec *corev1.EndpointSubset) {
|
||||
for _, opt := range opts {
|
||||
p := &v1.EndpointPort{}
|
||||
p := &corev1.EndpointPort{}
|
||||
opt(p)
|
||||
spec.Ports = append(spec.Ports, *p)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func ePort(port int32, name string) func(*v1.EndpointPort) {
|
||||
return func(sp *v1.EndpointPort) {
|
||||
func ePort(port int32, name string) func(*corev1.EndpointPort) {
|
||||
return func(sp *corev1.EndpointPort) {
|
||||
sp.Port = port
|
||||
sp.Name = name
|
||||
}
|
||||
|
@ -103,21 +104,21 @@ func TestBuildEndpoint(t *testing.T) {
|
|||
assert.EqualValues(t, sampleEndpoint1(), actual)
|
||||
}
|
||||
|
||||
func sampleEndpoint1() *v1.Endpoints {
|
||||
return &v1.Endpoints{
|
||||
ObjectMeta: v1.ObjectMeta{
|
||||
func sampleEndpoint1() *corev1.Endpoints {
|
||||
return &corev1.Endpoints{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: "service3",
|
||||
UID: "3",
|
||||
Namespace: "testing",
|
||||
},
|
||||
Subsets: []v1.EndpointSubset{
|
||||
Subsets: []corev1.EndpointSubset{
|
||||
{
|
||||
Addresses: []v1.EndpointAddress{
|
||||
Addresses: []corev1.EndpointAddress{
|
||||
{
|
||||
IP: "10.15.0.1",
|
||||
},
|
||||
},
|
||||
Ports: []v1.EndpointPort{
|
||||
Ports: []corev1.EndpointPort{
|
||||
{
|
||||
Name: "http",
|
||||
Port: 8080,
|
||||
|
@ -129,12 +130,12 @@ func sampleEndpoint1() *v1.Endpoints {
|
|||
},
|
||||
},
|
||||
{
|
||||
Addresses: []v1.EndpointAddress{
|
||||
Addresses: []corev1.EndpointAddress{
|
||||
{
|
||||
IP: "10.15.0.2",
|
||||
},
|
||||
},
|
||||
Ports: []v1.EndpointPort{
|
||||
Ports: []corev1.EndpointPort{
|
||||
{
|
||||
Name: "http",
|
||||
Port: 9080,
|
||||
|
|
|
@ -4,27 +4,27 @@ import (
|
|||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"k8s.io/client-go/pkg/api/v1"
|
||||
"k8s.io/client-go/pkg/apis/extensions/v1beta1"
|
||||
"k8s.io/client-go/pkg/util/intstr"
|
||||
extensionsv1beta1 "k8s.io/api/extensions/v1beta1"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/util/intstr"
|
||||
)
|
||||
|
||||
func buildIngress(opts ...func(*v1beta1.Ingress)) *v1beta1.Ingress {
|
||||
i := &v1beta1.Ingress{}
|
||||
func buildIngress(opts ...func(*extensionsv1beta1.Ingress)) *extensionsv1beta1.Ingress {
|
||||
i := &extensionsv1beta1.Ingress{}
|
||||
for _, opt := range opts {
|
||||
opt(i)
|
||||
}
|
||||
return i
|
||||
}
|
||||
|
||||
func iNamespace(value string) func(*v1beta1.Ingress) {
|
||||
return func(i *v1beta1.Ingress) {
|
||||
func iNamespace(value string) func(*extensionsv1beta1.Ingress) {
|
||||
return func(i *extensionsv1beta1.Ingress) {
|
||||
i.Namespace = value
|
||||
}
|
||||
}
|
||||
|
||||
func iAnnotation(name string, value string) func(*v1beta1.Ingress) {
|
||||
return func(i *v1beta1.Ingress) {
|
||||
func iAnnotation(name string, value string) func(*extensionsv1beta1.Ingress) {
|
||||
return func(i *extensionsv1beta1.Ingress) {
|
||||
if i.Annotations == nil {
|
||||
i.Annotations = make(map[string]string)
|
||||
}
|
||||
|
@ -32,9 +32,9 @@ func iAnnotation(name string, value string) func(*v1beta1.Ingress) {
|
|||
}
|
||||
}
|
||||
|
||||
func iRules(opts ...func(*v1beta1.IngressSpec)) func(*v1beta1.Ingress) {
|
||||
return func(i *v1beta1.Ingress) {
|
||||
s := &v1beta1.IngressSpec{}
|
||||
func iRules(opts ...func(*extensionsv1beta1.IngressSpec)) func(*extensionsv1beta1.Ingress) {
|
||||
return func(i *extensionsv1beta1.Ingress) {
|
||||
s := &extensionsv1beta1.IngressSpec{}
|
||||
for _, opt := range opts {
|
||||
opt(s)
|
||||
}
|
||||
|
@ -42,9 +42,9 @@ func iRules(opts ...func(*v1beta1.IngressSpec)) func(*v1beta1.Ingress) {
|
|||
}
|
||||
}
|
||||
|
||||
func iRule(opts ...func(*v1beta1.IngressRule)) func(*v1beta1.IngressSpec) {
|
||||
return func(spec *v1beta1.IngressSpec) {
|
||||
r := &v1beta1.IngressRule{}
|
||||
func iRule(opts ...func(*extensionsv1beta1.IngressRule)) func(*extensionsv1beta1.IngressSpec) {
|
||||
return func(spec *extensionsv1beta1.IngressSpec) {
|
||||
r := &extensionsv1beta1.IngressRule{}
|
||||
for _, opt := range opts {
|
||||
opt(r)
|
||||
}
|
||||
|
@ -52,24 +52,24 @@ func iRule(opts ...func(*v1beta1.IngressRule)) func(*v1beta1.IngressSpec) {
|
|||
}
|
||||
}
|
||||
|
||||
func iHost(name string) func(*v1beta1.IngressRule) {
|
||||
return func(rule *v1beta1.IngressRule) {
|
||||
func iHost(name string) func(*extensionsv1beta1.IngressRule) {
|
||||
return func(rule *extensionsv1beta1.IngressRule) {
|
||||
rule.Host = name
|
||||
}
|
||||
}
|
||||
|
||||
func iPaths(opts ...func(*v1beta1.HTTPIngressRuleValue)) func(*v1beta1.IngressRule) {
|
||||
return func(rule *v1beta1.IngressRule) {
|
||||
rule.HTTP = &v1beta1.HTTPIngressRuleValue{}
|
||||
func iPaths(opts ...func(*extensionsv1beta1.HTTPIngressRuleValue)) func(*extensionsv1beta1.IngressRule) {
|
||||
return func(rule *extensionsv1beta1.IngressRule) {
|
||||
rule.HTTP = &extensionsv1beta1.HTTPIngressRuleValue{}
|
||||
for _, opt := range opts {
|
||||
opt(rule.HTTP)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func onePath(opts ...func(*v1beta1.HTTPIngressPath)) func(*v1beta1.HTTPIngressRuleValue) {
|
||||
return func(irv *v1beta1.HTTPIngressRuleValue) {
|
||||
p := &v1beta1.HTTPIngressPath{}
|
||||
func onePath(opts ...func(*extensionsv1beta1.HTTPIngressPath)) func(*extensionsv1beta1.HTTPIngressRuleValue) {
|
||||
return func(irv *extensionsv1beta1.HTTPIngressRuleValue) {
|
||||
p := &extensionsv1beta1.HTTPIngressPath{}
|
||||
for _, opt := range opts {
|
||||
opt(p)
|
||||
}
|
||||
|
@ -77,33 +77,33 @@ func onePath(opts ...func(*v1beta1.HTTPIngressPath)) func(*v1beta1.HTTPIngressRu
|
|||
}
|
||||
}
|
||||
|
||||
func iPath(name string) func(*v1beta1.HTTPIngressPath) {
|
||||
return func(p *v1beta1.HTTPIngressPath) {
|
||||
func iPath(name string) func(*extensionsv1beta1.HTTPIngressPath) {
|
||||
return func(p *extensionsv1beta1.HTTPIngressPath) {
|
||||
p.Path = name
|
||||
}
|
||||
}
|
||||
|
||||
func iBackend(name string, port intstr.IntOrString) func(*v1beta1.HTTPIngressPath) {
|
||||
return func(p *v1beta1.HTTPIngressPath) {
|
||||
p.Backend = v1beta1.IngressBackend{
|
||||
func iBackend(name string, port intstr.IntOrString) func(*extensionsv1beta1.HTTPIngressPath) {
|
||||
return func(p *extensionsv1beta1.HTTPIngressPath) {
|
||||
p.Backend = extensionsv1beta1.IngressBackend{
|
||||
ServiceName: name,
|
||||
ServicePort: port,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func iTLSes(opts ...func(*v1beta1.IngressTLS)) func(*v1beta1.Ingress) {
|
||||
return func(i *v1beta1.Ingress) {
|
||||
func iTLSes(opts ...func(*extensionsv1beta1.IngressTLS)) func(*extensionsv1beta1.Ingress) {
|
||||
return func(i *extensionsv1beta1.Ingress) {
|
||||
for _, opt := range opts {
|
||||
iTLS := v1beta1.IngressTLS{}
|
||||
iTLS := extensionsv1beta1.IngressTLS{}
|
||||
opt(&iTLS)
|
||||
i.Spec.TLS = append(i.Spec.TLS, iTLS)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func iTLS(secret string, hosts ...string) func(*v1beta1.IngressTLS) {
|
||||
return func(i *v1beta1.IngressTLS) {
|
||||
func iTLS(secret string, hosts ...string) func(*extensionsv1beta1.IngressTLS) {
|
||||
return func(i *extensionsv1beta1.IngressTLS) {
|
||||
i.SecretName = secret
|
||||
i.Hosts = hosts
|
||||
}
|
||||
|
@ -133,28 +133,28 @@ func TestBuildIngress(t *testing.T) {
|
|||
assert.EqualValues(t, sampleIngress(), i)
|
||||
}
|
||||
|
||||
func sampleIngress() *v1beta1.Ingress {
|
||||
return &v1beta1.Ingress{
|
||||
ObjectMeta: v1.ObjectMeta{
|
||||
func sampleIngress() *extensionsv1beta1.Ingress {
|
||||
return &extensionsv1beta1.Ingress{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Namespace: "testing",
|
||||
},
|
||||
Spec: v1beta1.IngressSpec{
|
||||
Rules: []v1beta1.IngressRule{
|
||||
Spec: extensionsv1beta1.IngressSpec{
|
||||
Rules: []extensionsv1beta1.IngressRule{
|
||||
{
|
||||
Host: "foo",
|
||||
IngressRuleValue: v1beta1.IngressRuleValue{
|
||||
HTTP: &v1beta1.HTTPIngressRuleValue{
|
||||
Paths: []v1beta1.HTTPIngressPath{
|
||||
IngressRuleValue: extensionsv1beta1.IngressRuleValue{
|
||||
HTTP: &extensionsv1beta1.HTTPIngressRuleValue{
|
||||
Paths: []extensionsv1beta1.HTTPIngressPath{
|
||||
{
|
||||
Path: "/bar",
|
||||
Backend: v1beta1.IngressBackend{
|
||||
Backend: extensionsv1beta1.IngressBackend{
|
||||
ServiceName: "service1",
|
||||
ServicePort: intstr.FromInt(80),
|
||||
},
|
||||
},
|
||||
{
|
||||
Path: "/namedthing",
|
||||
Backend: v1beta1.IngressBackend{
|
||||
Backend: extensionsv1beta1.IngressBackend{
|
||||
ServiceName: "service4",
|
||||
ServicePort: intstr.FromString("https"),
|
||||
},
|
||||
|
@ -165,17 +165,17 @@ func sampleIngress() *v1beta1.Ingress {
|
|||
},
|
||||
{
|
||||
Host: "bar",
|
||||
IngressRuleValue: v1beta1.IngressRuleValue{
|
||||
HTTP: &v1beta1.HTTPIngressRuleValue{
|
||||
Paths: []v1beta1.HTTPIngressPath{
|
||||
IngressRuleValue: extensionsv1beta1.IngressRuleValue{
|
||||
HTTP: &extensionsv1beta1.HTTPIngressRuleValue{
|
||||
Paths: []extensionsv1beta1.HTTPIngressPath{
|
||||
{
|
||||
Backend: v1beta1.IngressBackend{
|
||||
Backend: extensionsv1beta1.IngressBackend{
|
||||
ServiceName: "service3",
|
||||
ServicePort: intstr.FromString("https"),
|
||||
},
|
||||
},
|
||||
{
|
||||
Backend: v1beta1.IngressBackend{
|
||||
Backend: extensionsv1beta1.IngressBackend{
|
||||
ServiceName: "service2",
|
||||
ServicePort: intstr.FromInt(802),
|
||||
},
|
||||
|
@ -185,7 +185,7 @@ func sampleIngress() *v1beta1.Ingress {
|
|||
},
|
||||
},
|
||||
},
|
||||
TLS: []v1beta1.IngressTLS{
|
||||
TLS: []extensionsv1beta1.IngressTLS{
|
||||
{
|
||||
Hosts: []string{"foo"},
|
||||
SecretName: "tls-secret",
|
||||
|
|
|
@ -4,38 +4,39 @@ import (
|
|||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"k8s.io/client-go/pkg/api/v1"
|
||||
"k8s.io/client-go/pkg/types"
|
||||
corev1 "k8s.io/api/core/v1"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/types"
|
||||
)
|
||||
|
||||
func buildService(opts ...func(*v1.Service)) *v1.Service {
|
||||
s := &v1.Service{}
|
||||
func buildService(opts ...func(*corev1.Service)) *corev1.Service {
|
||||
s := &corev1.Service{}
|
||||
for _, opt := range opts {
|
||||
opt(s)
|
||||
}
|
||||
return s
|
||||
}
|
||||
|
||||
func sNamespace(value string) func(*v1.Service) {
|
||||
return func(i *v1.Service) {
|
||||
func sNamespace(value string) func(*corev1.Service) {
|
||||
return func(i *corev1.Service) {
|
||||
i.Namespace = value
|
||||
}
|
||||
}
|
||||
|
||||
func sName(value string) func(*v1.Service) {
|
||||
return func(i *v1.Service) {
|
||||
func sName(value string) func(*corev1.Service) {
|
||||
return func(i *corev1.Service) {
|
||||
i.Name = value
|
||||
}
|
||||
}
|
||||
|
||||
func sUID(value types.UID) func(*v1.Service) {
|
||||
return func(i *v1.Service) {
|
||||
func sUID(value types.UID) func(*corev1.Service) {
|
||||
return func(i *corev1.Service) {
|
||||
i.UID = value
|
||||
}
|
||||
}
|
||||
|
||||
func sAnnotation(name string, value string) func(*v1.Service) {
|
||||
return func(s *v1.Service) {
|
||||
func sAnnotation(name string, value string) func(*corev1.Service) {
|
||||
return func(s *corev1.Service) {
|
||||
if s.Annotations == nil {
|
||||
s.Annotations = make(map[string]string)
|
||||
}
|
||||
|
@ -43,9 +44,9 @@ func sAnnotation(name string, value string) func(*v1.Service) {
|
|||
}
|
||||
}
|
||||
|
||||
func sSpec(opts ...func(*v1.ServiceSpec)) func(*v1.Service) {
|
||||
return func(i *v1.Service) {
|
||||
spec := &v1.ServiceSpec{}
|
||||
func sSpec(opts ...func(*corev1.ServiceSpec)) func(*corev1.Service) {
|
||||
return func(i *corev1.Service) {
|
||||
spec := &corev1.ServiceSpec{}
|
||||
for _, opt := range opts {
|
||||
opt(spec)
|
||||
}
|
||||
|
@ -53,36 +54,36 @@ func sSpec(opts ...func(*v1.ServiceSpec)) func(*v1.Service) {
|
|||
}
|
||||
}
|
||||
|
||||
func clusterIP(ip string) func(*v1.ServiceSpec) {
|
||||
return func(spec *v1.ServiceSpec) {
|
||||
func clusterIP(ip string) func(*corev1.ServiceSpec) {
|
||||
return func(spec *corev1.ServiceSpec) {
|
||||
spec.ClusterIP = ip
|
||||
}
|
||||
}
|
||||
|
||||
func sType(value v1.ServiceType) func(*v1.ServiceSpec) {
|
||||
return func(spec *v1.ServiceSpec) {
|
||||
func sType(value corev1.ServiceType) func(*corev1.ServiceSpec) {
|
||||
return func(spec *corev1.ServiceSpec) {
|
||||
spec.Type = value
|
||||
}
|
||||
}
|
||||
|
||||
func sExternalName(name string) func(*v1.ServiceSpec) {
|
||||
return func(spec *v1.ServiceSpec) {
|
||||
func sExternalName(name string) func(*corev1.ServiceSpec) {
|
||||
return func(spec *corev1.ServiceSpec) {
|
||||
spec.ExternalName = name
|
||||
}
|
||||
}
|
||||
|
||||
func sPorts(opts ...func(*v1.ServicePort)) func(*v1.ServiceSpec) {
|
||||
return func(spec *v1.ServiceSpec) {
|
||||
func sPorts(opts ...func(*corev1.ServicePort)) func(*corev1.ServiceSpec) {
|
||||
return func(spec *corev1.ServiceSpec) {
|
||||
for _, opt := range opts {
|
||||
p := &v1.ServicePort{}
|
||||
p := &corev1.ServicePort{}
|
||||
opt(p)
|
||||
spec.Ports = append(spec.Ports, *p)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func sPort(port int32, name string) func(*v1.ServicePort) {
|
||||
return func(sp *v1.ServicePort) {
|
||||
func sPort(port int32, name string) func(*corev1.ServicePort) {
|
||||
return func(sp *corev1.ServicePort) {
|
||||
sp.Port = port
|
||||
sp.Name = name
|
||||
}
|
||||
|
@ -121,16 +122,16 @@ func TestBuildService(t *testing.T) {
|
|||
assert.EqualValues(t, sampleService2(), actual2)
|
||||
}
|
||||
|
||||
func sampleService1() *v1.Service {
|
||||
return &v1.Service{
|
||||
ObjectMeta: v1.ObjectMeta{
|
||||
func sampleService1() *corev1.Service {
|
||||
return &corev1.Service{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: "service1",
|
||||
UID: "1",
|
||||
Namespace: "testing",
|
||||
},
|
||||
Spec: v1.ServiceSpec{
|
||||
Spec: corev1.ServiceSpec{
|
||||
ClusterIP: "10.0.0.1",
|
||||
Ports: []v1.ServicePort{
|
||||
Ports: []corev1.ServicePort{
|
||||
{
|
||||
Port: 80,
|
||||
},
|
||||
|
@ -139,18 +140,18 @@ func sampleService1() *v1.Service {
|
|||
}
|
||||
}
|
||||
|
||||
func sampleService2() *v1.Service {
|
||||
return &v1.Service{
|
||||
ObjectMeta: v1.ObjectMeta{
|
||||
func sampleService2() *corev1.Service {
|
||||
return &corev1.Service{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: "service3",
|
||||
UID: "3",
|
||||
Namespace: "testing",
|
||||
},
|
||||
Spec: v1.ServiceSpec{
|
||||
Spec: corev1.ServiceSpec{
|
||||
ClusterIP: "10.0.0.3",
|
||||
Type: "ExternalName",
|
||||
ExternalName: "example.com",
|
||||
Ports: []v1.ServicePort{
|
||||
Ports: []corev1.ServicePort{
|
||||
{
|
||||
Name: "http",
|
||||
Port: 80,
|
||||
|
|
|
@ -8,14 +8,14 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/containous/traefik/safe"
|
||||
corev1 "k8s.io/api/core/v1"
|
||||
extensionsv1beta1 "k8s.io/api/extensions/v1beta1"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/fields"
|
||||
"k8s.io/apimachinery/pkg/labels"
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
"k8s.io/apimachinery/pkg/watch"
|
||||
"k8s.io/client-go/kubernetes"
|
||||
"k8s.io/client-go/pkg/api"
|
||||
"k8s.io/client-go/pkg/api/v1"
|
||||
"k8s.io/client-go/pkg/apis/extensions/v1beta1"
|
||||
"k8s.io/client-go/pkg/fields"
|
||||
"k8s.io/client-go/pkg/labels"
|
||||
"k8s.io/client-go/pkg/runtime"
|
||||
"k8s.io/client-go/pkg/watch"
|
||||
"k8s.io/client-go/rest"
|
||||
"k8s.io/client-go/tools/cache"
|
||||
)
|
||||
|
@ -62,10 +62,10 @@ func (im *informerManager) extend(informer cache.SharedInformer, withSyncFunc bo
|
|||
// The stores can then be accessed via the Get* functions.
|
||||
type Client interface {
|
||||
WatchAll(namespaces Namespaces, labelSelector string, stopCh <-chan struct{}) (<-chan interface{}, error)
|
||||
GetIngresses() []*v1beta1.Ingress
|
||||
GetService(namespace, name string) (*v1.Service, bool, error)
|
||||
GetSecret(namespace, name string) (*v1.Secret, bool, error)
|
||||
GetEndpoints(namespace, name string) (*v1.Endpoints, bool, error)
|
||||
GetIngresses() []*extensionsv1beta1.Ingress
|
||||
GetService(namespace, name string) (*corev1.Service, bool, error)
|
||||
GetSecret(namespace, name string) (*corev1.Secret, bool, error)
|
||||
GetEndpoints(namespace, name string) (*corev1.Endpoints, bool, error)
|
||||
}
|
||||
|
||||
type clientImpl struct {
|
||||
|
@ -146,7 +146,7 @@ func (c *clientImpl) WatchAll(namespaces Namespaces, labelSelector string, stopC
|
|||
}
|
||||
|
||||
if len(namespaces) == 0 {
|
||||
namespaces = Namespaces{api.NamespaceAll}
|
||||
namespaces = Namespaces{metav1.NamespaceAll}
|
||||
c.isNamespaceAll = true
|
||||
}
|
||||
|
||||
|
@ -154,13 +154,13 @@ func (c *clientImpl) WatchAll(namespaces Namespaces, labelSelector string, stopC
|
|||
for _, ns := range namespaces {
|
||||
ns := ns
|
||||
informManager.extend(c.WatchIngresses(ns, kubeLabelSelector, eventCh), true)
|
||||
informManager.extend(c.WatchObjects(ns, kindServices, &v1.Service{}, c.svcStores, eventCh), true)
|
||||
informManager.extend(c.WatchObjects(ns, kindEndpoints, &v1.Endpoints{}, c.epStores, eventCh), true)
|
||||
informManager.extend(c.WatchObjects(ns, kindServices, &corev1.Service{}, c.svcStores, eventCh), true)
|
||||
informManager.extend(c.WatchObjects(ns, kindEndpoints, &corev1.Endpoints{}, c.epStores, eventCh), true)
|
||||
// Do not wait for the Secrets store to get synced since we cannot rely on
|
||||
// users having granted RBAC permissions for this object.
|
||||
// https://github.com/containous/traefik/issues/1784 should improve the
|
||||
// situation here in the future.
|
||||
informManager.extend(c.WatchObjects(ns, kindSecrets, &v1.Secret{}, c.secStores, eventCh), false)
|
||||
informManager.extend(c.WatchObjects(ns, kindSecrets, &corev1.Secret{}, c.secStores, eventCh), false)
|
||||
}
|
||||
|
||||
var wg sync.WaitGroup
|
||||
|
@ -188,14 +188,18 @@ func (c *clientImpl) WatchAll(namespaces Namespaces, labelSelector string, stopC
|
|||
|
||||
// WatchIngresses sets up a watch on Ingress objects and returns a corresponding shared informer.
|
||||
func (c *clientImpl) WatchIngresses(namespace string, labelSelector labels.Selector, watchCh chan<- interface{}) cache.SharedInformer {
|
||||
listWatch := newListWatchFromClientWithLabelSelector(
|
||||
c.clientset.ExtensionsV1beta1().RESTClient(),
|
||||
kindIngresses,
|
||||
namespace,
|
||||
fields.Everything(),
|
||||
labelSelector)
|
||||
|
||||
informer := loadInformer(listWatch, &v1beta1.Ingress{}, watchCh)
|
||||
listOptions := metav1.ListOptions{
|
||||
LabelSelector: labelSelector.String(),
|
||||
FieldSelector: fields.Everything().String(),
|
||||
}
|
||||
informer := loadInformer(&cache.ListWatch{
|
||||
ListFunc: func(options metav1.ListOptions) (runtime.Object, error) {
|
||||
return c.clientset.ExtensionsV1beta1().Ingresses(namespace).List(listOptions)
|
||||
},
|
||||
WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) {
|
||||
return c.clientset.ExtensionsV1beta1().Ingresses(namespace).Watch(listOptions)
|
||||
},
|
||||
}, &extensionsv1beta1.Ingress{}, watchCh)
|
||||
c.ingStores = append(c.ingStores, informer.GetStore())
|
||||
return informer
|
||||
}
|
||||
|
@ -220,22 +224,17 @@ func loadInformer(listWatch cache.ListerWatcher, object runtime.Object, watchCh
|
|||
resyncPeriod,
|
||||
)
|
||||
|
||||
if err := informer.AddEventHandler(newResourceEventHandler(watchCh)); err != nil {
|
||||
// This should only ever fail if we add an event handler after the
|
||||
// informer has been started already, which would be a programming bug.
|
||||
panic(err)
|
||||
}
|
||||
|
||||
informer.AddEventHandler(newResourceEventHandler(watchCh))
|
||||
return informer
|
||||
}
|
||||
|
||||
// GetIngresses returns all Ingresses for observed namespaces in the cluster.
|
||||
func (c *clientImpl) GetIngresses() []*v1beta1.Ingress {
|
||||
var result []*v1beta1.Ingress
|
||||
func (c *clientImpl) GetIngresses() []*extensionsv1beta1.Ingress {
|
||||
var result []*extensionsv1beta1.Ingress
|
||||
|
||||
for _, store := range c.ingStores {
|
||||
for _, obj := range store.List() {
|
||||
ing := obj.(*v1beta1.Ingress)
|
||||
ing := obj.(*extensionsv1beta1.Ingress)
|
||||
result = append(result, ing)
|
||||
}
|
||||
}
|
||||
|
@ -244,34 +243,34 @@ func (c *clientImpl) GetIngresses() []*v1beta1.Ingress {
|
|||
}
|
||||
|
||||
// GetService returns the named service from the given namespace.
|
||||
func (c *clientImpl) GetService(namespace, name string) (*v1.Service, bool, error) {
|
||||
var service *v1.Service
|
||||
func (c *clientImpl) GetService(namespace, name string) (*corev1.Service, bool, error) {
|
||||
var service *corev1.Service
|
||||
item, exists, err := c.svcStores[c.lookupNamespace(namespace)].GetByKey(namespace + "/" + name)
|
||||
if item != nil {
|
||||
service = item.(*v1.Service)
|
||||
service = item.(*corev1.Service)
|
||||
}
|
||||
|
||||
return service, exists, err
|
||||
}
|
||||
|
||||
// GetEndpoints returns the named endpoints from the given namespace.
|
||||
func (c *clientImpl) GetEndpoints(namespace, name string) (*v1.Endpoints, bool, error) {
|
||||
var endpoint *v1.Endpoints
|
||||
func (c *clientImpl) GetEndpoints(namespace, name string) (*corev1.Endpoints, bool, error) {
|
||||
var endpoint *corev1.Endpoints
|
||||
item, exists, err := c.epStores[c.lookupNamespace(namespace)].GetByKey(namespace + "/" + name)
|
||||
|
||||
if item != nil {
|
||||
endpoint = item.(*v1.Endpoints)
|
||||
endpoint = item.(*corev1.Endpoints)
|
||||
}
|
||||
|
||||
return endpoint, exists, err
|
||||
}
|
||||
|
||||
// GetSecret returns the named secret from the given namespace.
|
||||
func (c *clientImpl) GetSecret(namespace, name string) (*v1.Secret, bool, error) {
|
||||
var secret *v1.Secret
|
||||
func (c *clientImpl) GetSecret(namespace, name string) (*corev1.Secret, bool, error) {
|
||||
var secret *corev1.Secret
|
||||
item, exists, err := c.secStores[c.lookupNamespace(namespace)].GetByKey(namespace + "/" + name)
|
||||
if err == nil && item != nil {
|
||||
secret = item.(*v1.Secret)
|
||||
secret = item.(*corev1.Secret)
|
||||
}
|
||||
|
||||
return secret, exists, err
|
||||
|
@ -285,37 +284,11 @@ func (c *clientImpl) GetSecret(namespace, name string) (*v1.Secret, bool, error)
|
|||
// identifiers from the Kubernetes API, so we have to bridge this gap.
|
||||
func (c *clientImpl) lookupNamespace(ns string) string {
|
||||
if c.isNamespaceAll {
|
||||
return api.NamespaceAll
|
||||
return metav1.NamespaceAll
|
||||
}
|
||||
return ns
|
||||
}
|
||||
|
||||
// newListWatchFromClientWithLabelSelector creates a new ListWatch from the given parameters.
|
||||
// It extends cache.NewListWatchFromClient to support label selectors.
|
||||
func newListWatchFromClientWithLabelSelector(c cache.Getter, resource string, namespace string, fieldSelector fields.Selector, labelSelector labels.Selector) *cache.ListWatch {
|
||||
listFunc := func(options api.ListOptions) (runtime.Object, error) {
|
||||
return c.Get().
|
||||
Namespace(namespace).
|
||||
Resource(resource).
|
||||
VersionedParams(&options, api.ParameterCodec).
|
||||
FieldsSelectorParam(fieldSelector).
|
||||
LabelsSelectorParam(labelSelector).
|
||||
Do().
|
||||
Get()
|
||||
}
|
||||
watchFunc := func(options api.ListOptions) (watch.Interface, error) {
|
||||
return c.Get().
|
||||
Prefix("watch").
|
||||
Namespace(namespace).
|
||||
Resource(resource).
|
||||
VersionedParams(&options, api.ParameterCodec).
|
||||
FieldsSelectorParam(fieldSelector).
|
||||
LabelsSelectorParam(labelSelector).
|
||||
Watch()
|
||||
}
|
||||
return &cache.ListWatch{ListFunc: listFunc, WatchFunc: watchFunc}
|
||||
}
|
||||
|
||||
func newResourceEventHandler(events chan<- interface{}) cache.ResourceEventHandler {
|
||||
return &resourceEventHandler{events}
|
||||
}
|
||||
|
|
|
@ -1,15 +1,15 @@
|
|||
package kubernetes
|
||||
|
||||
import (
|
||||
"k8s.io/client-go/pkg/api/v1"
|
||||
"k8s.io/client-go/pkg/apis/extensions/v1beta1"
|
||||
corev1 "k8s.io/api/core/v1"
|
||||
extensionsv1beta1 "k8s.io/api/extensions/v1beta1"
|
||||
)
|
||||
|
||||
type clientMock struct {
|
||||
ingresses []*v1beta1.Ingress
|
||||
services []*v1.Service
|
||||
secrets []*v1.Secret
|
||||
endpoints []*v1.Endpoints
|
||||
ingresses []*extensionsv1beta1.Ingress
|
||||
services []*corev1.Service
|
||||
secrets []*corev1.Secret
|
||||
endpoints []*corev1.Endpoints
|
||||
watchChan chan interface{}
|
||||
|
||||
apiServiceError error
|
||||
|
@ -17,11 +17,11 @@ type clientMock struct {
|
|||
apiEndpointsError error
|
||||
}
|
||||
|
||||
func (c clientMock) GetIngresses() []*v1beta1.Ingress {
|
||||
func (c clientMock) GetIngresses() []*extensionsv1beta1.Ingress {
|
||||
return c.ingresses
|
||||
}
|
||||
|
||||
func (c clientMock) GetService(namespace, name string) (*v1.Service, bool, error) {
|
||||
func (c clientMock) GetService(namespace, name string) (*corev1.Service, bool, error) {
|
||||
if c.apiServiceError != nil {
|
||||
return nil, false, c.apiServiceError
|
||||
}
|
||||
|
@ -34,7 +34,7 @@ func (c clientMock) GetService(namespace, name string) (*v1.Service, bool, error
|
|||
return nil, false, nil
|
||||
}
|
||||
|
||||
func (c clientMock) GetEndpoints(namespace, name string) (*v1.Endpoints, bool, error) {
|
||||
func (c clientMock) GetEndpoints(namespace, name string) (*corev1.Endpoints, bool, error) {
|
||||
if c.apiEndpointsError != nil {
|
||||
return nil, false, c.apiEndpointsError
|
||||
}
|
||||
|
@ -45,10 +45,10 @@ func (c clientMock) GetEndpoints(namespace, name string) (*v1.Endpoints, bool, e
|
|||
}
|
||||
}
|
||||
|
||||
return &v1.Endpoints{}, false, nil
|
||||
return &corev1.Endpoints{}, false, nil
|
||||
}
|
||||
|
||||
func (c clientMock) GetSecret(namespace, name string) (*v1.Secret, bool, error) {
|
||||
func (c clientMock) GetSecret(namespace, name string) (*corev1.Secret, bool, error) {
|
||||
if c.apiSecretError != nil {
|
||||
return nil, false, c.apiSecretError
|
||||
}
|
||||
|
|
|
@ -22,9 +22,9 @@ import (
|
|||
"github.com/containous/traefik/tls"
|
||||
"github.com/containous/traefik/types"
|
||||
"gopkg.in/yaml.v2"
|
||||
"k8s.io/client-go/pkg/api/v1"
|
||||
"k8s.io/client-go/pkg/apis/extensions/v1beta1"
|
||||
"k8s.io/client-go/pkg/util/intstr"
|
||||
corev1 "k8s.io/api/core/v1"
|
||||
extensionsv1beta1 "k8s.io/api/extensions/v1beta1"
|
||||
"k8s.io/apimachinery/pkg/util/intstr"
|
||||
)
|
||||
|
||||
var _ provider.Provider = (*Provider)(nil)
|
||||
|
@ -313,7 +313,7 @@ func (p *Provider) loadConfig(templateObjects types.Configuration) *types.Config
|
|||
return configuration
|
||||
}
|
||||
|
||||
func getRuleForPath(pa v1beta1.HTTPIngressPath, i *v1beta1.Ingress) string {
|
||||
func getRuleForPath(pa extensionsv1beta1.HTTPIngressPath, i *extensionsv1beta1.Ingress) string {
|
||||
if len(pa.Path) == 0 {
|
||||
return ""
|
||||
}
|
||||
|
@ -335,7 +335,7 @@ func getRuleForHost(host string) string {
|
|||
return "Host:" + host
|
||||
}
|
||||
|
||||
func handleBasicAuthConfig(i *v1beta1.Ingress, k8sClient Client) ([]string, error) {
|
||||
func handleBasicAuthConfig(i *extensionsv1beta1.Ingress, k8sClient Client) ([]string, error) {
|
||||
annotationAuthType := getAnnotationName(i.Annotations, annotationKubernetesAuthType)
|
||||
authType, exists := i.Annotations[annotationAuthType]
|
||||
if !exists {
|
||||
|
@ -391,7 +391,7 @@ func loadAuthCredentials(namespace, secretName string, k8sClient Client) ([]stri
|
|||
return creds, nil
|
||||
}
|
||||
|
||||
func getTLS(ingress *v1beta1.Ingress, k8sClient Client) ([]*tls.Configuration, error) {
|
||||
func getTLS(ingress *extensionsv1beta1.Ingress, k8sClient Client) ([]*tls.Configuration, error) {
|
||||
var tlsConfigs []*tls.Configuration
|
||||
|
||||
for _, t := range ingress.Spec.TLS {
|
||||
|
@ -434,7 +434,7 @@ func getTLS(ingress *v1beta1.Ingress, k8sClient Client) ([]*tls.Configuration, e
|
|||
return tlsConfigs, nil
|
||||
}
|
||||
|
||||
func endpointPortNumber(servicePort v1.ServicePort, endpointPorts []v1.EndpointPort) int {
|
||||
func endpointPortNumber(servicePort corev1.ServicePort, endpointPorts []corev1.EndpointPort) int {
|
||||
if len(endpointPorts) > 0 {
|
||||
//name is optional if there is only one port
|
||||
port := endpointPorts[0]
|
||||
|
@ -448,7 +448,7 @@ func endpointPortNumber(servicePort v1.ServicePort, endpointPorts []v1.EndpointP
|
|||
return int(servicePort.Port)
|
||||
}
|
||||
|
||||
func equalPorts(servicePort v1.ServicePort, ingressPort intstr.IntOrString) bool {
|
||||
func equalPorts(servicePort corev1.ServicePort, ingressPort intstr.IntOrString) bool {
|
||||
if int(servicePort.Port) == ingressPort.IntValue() {
|
||||
return true
|
||||
}
|
||||
|
@ -465,7 +465,7 @@ func (p *Provider) shouldProcessIngress(annotationIngressClass string) bool {
|
|||
return annotationIngressClass == p.IngressClass
|
||||
}
|
||||
|
||||
func getFrontendRedirect(i *v1beta1.Ingress) *types.Redirect {
|
||||
func getFrontendRedirect(i *extensionsv1beta1.Ingress) *types.Redirect {
|
||||
permanent := getBoolValue(i.Annotations, annotationKubernetesRedirectPermanent, false)
|
||||
|
||||
redirectEntryPoint := getStringValue(i.Annotations, annotationKubernetesRedirectEntryPoint, "")
|
||||
|
@ -489,7 +489,7 @@ func getFrontendRedirect(i *v1beta1.Ingress) *types.Redirect {
|
|||
return nil
|
||||
}
|
||||
|
||||
func getBuffering(service *v1.Service) *types.Buffering {
|
||||
func getBuffering(service *corev1.Service) *types.Buffering {
|
||||
var buffering *types.Buffering
|
||||
|
||||
bufferingRaw := getStringValue(service.Annotations, annotationKubernetesBuffering, "")
|
||||
|
@ -506,7 +506,7 @@ func getBuffering(service *v1.Service) *types.Buffering {
|
|||
return buffering
|
||||
}
|
||||
|
||||
func getLoadBalancer(service *v1.Service) *types.LoadBalancer {
|
||||
func getLoadBalancer(service *corev1.Service) *types.LoadBalancer {
|
||||
loadBalancer := &types.LoadBalancer{
|
||||
Method: "wrr",
|
||||
}
|
||||
|
@ -527,7 +527,7 @@ func getLoadBalancer(service *v1.Service) *types.LoadBalancer {
|
|||
return loadBalancer
|
||||
}
|
||||
|
||||
func getStickiness(service *v1.Service) *types.Stickiness {
|
||||
func getStickiness(service *corev1.Service) *types.Stickiness {
|
||||
if getBoolValue(service.Annotations, annotationKubernetesAffinity, false) {
|
||||
stickiness := &types.Stickiness{}
|
||||
if cookieName := getStringValue(service.Annotations, annotationKubernetesSessionCookieName, ""); len(cookieName) > 0 {
|
||||
|
@ -538,7 +538,7 @@ func getStickiness(service *v1.Service) *types.Stickiness {
|
|||
return nil
|
||||
}
|
||||
|
||||
func getHeader(i *v1beta1.Ingress) *types.Headers {
|
||||
func getHeader(i *extensionsv1beta1.Ingress) *types.Headers {
|
||||
headers := &types.Headers{
|
||||
CustomRequestHeaders: getMapValue(i.Annotations, annotationKubernetesCustomRequestHeaders),
|
||||
CustomResponseHeaders: getMapValue(i.Annotations, annotationKubernetesCustomResponseHeaders),
|
||||
|
@ -569,7 +569,7 @@ func getHeader(i *v1beta1.Ingress) *types.Headers {
|
|||
return headers
|
||||
}
|
||||
|
||||
func getMaxConn(service *v1.Service) *types.MaxConn {
|
||||
func getMaxConn(service *corev1.Service) *types.MaxConn {
|
||||
amount := getInt64Value(service.Annotations, annotationKubernetesMaxConnAmount, -1)
|
||||
extractorFunc := getStringValue(service.Annotations, annotationKubernetesMaxConnExtractorFunc, "")
|
||||
if amount >= 0 && len(extractorFunc) > 0 {
|
||||
|
@ -581,7 +581,7 @@ func getMaxConn(service *v1.Service) *types.MaxConn {
|
|||
return nil
|
||||
}
|
||||
|
||||
func getCircuitBreaker(service *v1.Service) *types.CircuitBreaker {
|
||||
func getCircuitBreaker(service *corev1.Service) *types.CircuitBreaker {
|
||||
if expression := getStringValue(service.Annotations, annotationKubernetesCircuitBreakerExpression, ""); expression != "" {
|
||||
return &types.CircuitBreaker{
|
||||
Expression: expression,
|
||||
|
@ -590,7 +590,7 @@ func getCircuitBreaker(service *v1.Service) *types.CircuitBreaker {
|
|||
return nil
|
||||
}
|
||||
|
||||
func getErrorPages(i *v1beta1.Ingress) map[string]*types.ErrorPage {
|
||||
func getErrorPages(i *extensionsv1beta1.Ingress) map[string]*types.ErrorPage {
|
||||
var errorPages map[string]*types.ErrorPage
|
||||
|
||||
pagesRaw := getStringValue(i.Annotations, annotationKubernetesErrorPages, "")
|
||||
|
@ -606,7 +606,7 @@ func getErrorPages(i *v1beta1.Ingress) map[string]*types.ErrorPage {
|
|||
return errorPages
|
||||
}
|
||||
|
||||
func getRateLimit(i *v1beta1.Ingress) *types.RateLimit {
|
||||
func getRateLimit(i *extensionsv1beta1.Ingress) *types.RateLimit {
|
||||
var rateLimit *types.RateLimit
|
||||
|
||||
rateRaw := getStringValue(i.Annotations, annotationKubernetesRateLimit, "")
|
||||
|
|
|
@ -12,13 +12,14 @@ import (
|
|||
"github.com/containous/traefik/types"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
"k8s.io/client-go/pkg/api/v1"
|
||||
"k8s.io/client-go/pkg/apis/extensions/v1beta1"
|
||||
"k8s.io/client-go/pkg/util/intstr"
|
||||
corev1 "k8s.io/api/core/v1"
|
||||
extensionsv1beta1 "k8s.io/api/extensions/v1beta1"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/util/intstr"
|
||||
)
|
||||
|
||||
func TestLoadIngresses(t *testing.T) {
|
||||
ingresses := []*v1beta1.Ingress{
|
||||
ingresses := []*extensionsv1beta1.Ingress{
|
||||
buildIngress(
|
||||
iNamespace("testing"),
|
||||
iRules(
|
||||
|
@ -36,7 +37,7 @@ func TestLoadIngresses(t *testing.T) {
|
|||
),
|
||||
}
|
||||
|
||||
services := []*v1.Service{
|
||||
services := []*corev1.Service{
|
||||
buildService(
|
||||
sName("service1"),
|
||||
sNamespace("testing"),
|
||||
|
@ -76,7 +77,7 @@ func TestLoadIngresses(t *testing.T) {
|
|||
),
|
||||
}
|
||||
|
||||
endpoints := []*v1.Endpoints{
|
||||
endpoints := []*corev1.Endpoints{
|
||||
buildEndpoint(
|
||||
eNamespace("testing"),
|
||||
eName("service1"),
|
||||
|
@ -215,8 +216,8 @@ func TestRuleType(t *testing.T) {
|
|||
|
||||
watchChan := make(chan interface{})
|
||||
client := clientMock{
|
||||
ingresses: []*v1beta1.Ingress{ingress},
|
||||
services: []*v1.Service{service},
|
||||
ingresses: []*extensionsv1beta1.Ingress{ingress},
|
||||
services: []*corev1.Service{service},
|
||||
watchChan: watchChan,
|
||||
}
|
||||
provider := Provider{DisablePassHostHeaders: true}
|
||||
|
@ -236,7 +237,7 @@ func TestRuleType(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestGetPassHostHeader(t *testing.T) {
|
||||
ingresses := []*v1beta1.Ingress{
|
||||
ingresses := []*extensionsv1beta1.Ingress{
|
||||
buildIngress(
|
||||
iNamespace("awesome"),
|
||||
iRules(iRule(
|
||||
|
@ -248,7 +249,7 @@ func TestGetPassHostHeader(t *testing.T) {
|
|||
),
|
||||
}
|
||||
|
||||
services := []*v1.Service{
|
||||
services := []*corev1.Service{
|
||||
buildService(
|
||||
sNamespace("awesome"), sName("service1"), sUID("1"),
|
||||
sSpec(sPorts(sPort(801, "http"))),
|
||||
|
@ -281,7 +282,7 @@ func TestGetPassHostHeader(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestGetPassTLSCert(t *testing.T) {
|
||||
ingresses := []*v1beta1.Ingress{
|
||||
ingresses := []*extensionsv1beta1.Ingress{
|
||||
buildIngress(iNamespace("awesome"),
|
||||
iRules(iRule(
|
||||
iHost("foo"),
|
||||
|
@ -290,7 +291,7 @@ func TestGetPassTLSCert(t *testing.T) {
|
|||
),
|
||||
}
|
||||
|
||||
services := []*v1.Service{
|
||||
services := []*corev1.Service{
|
||||
buildService(
|
||||
sName("service1"),
|
||||
sNamespace("awesome"),
|
||||
|
@ -325,7 +326,7 @@ func TestGetPassTLSCert(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestOnlyReferencesServicesFromOwnNamespace(t *testing.T) {
|
||||
ingresses := []*v1beta1.Ingress{
|
||||
ingresses := []*extensionsv1beta1.Ingress{
|
||||
buildIngress(iNamespace("awesome"),
|
||||
iRules(iRule(
|
||||
iHost("foo"),
|
||||
|
@ -334,7 +335,7 @@ func TestOnlyReferencesServicesFromOwnNamespace(t *testing.T) {
|
|||
),
|
||||
}
|
||||
|
||||
services := []*v1.Service{
|
||||
services := []*corev1.Service{
|
||||
buildService(
|
||||
sNamespace("awesome"),
|
||||
sName("service"),
|
||||
|
@ -376,7 +377,7 @@ func TestOnlyReferencesServicesFromOwnNamespace(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestHostlessIngress(t *testing.T) {
|
||||
ingresses := []*v1beta1.Ingress{
|
||||
ingresses := []*extensionsv1beta1.Ingress{
|
||||
buildIngress(iNamespace("awesome"),
|
||||
iRules(iRule(
|
||||
iPaths(onePath(iPath("/bar"), iBackend("service1", intstr.FromInt(801))))),
|
||||
|
@ -384,7 +385,7 @@ func TestHostlessIngress(t *testing.T) {
|
|||
),
|
||||
}
|
||||
|
||||
services := []*v1.Service{
|
||||
services := []*corev1.Service{
|
||||
buildService(
|
||||
sName("service1"),
|
||||
sNamespace("awesome"),
|
||||
|
@ -416,7 +417,7 @@ func TestHostlessIngress(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestServiceAnnotations(t *testing.T) {
|
||||
ingresses := []*v1beta1.Ingress{
|
||||
ingresses := []*extensionsv1beta1.Ingress{
|
||||
buildIngress(iNamespace("testing"),
|
||||
iRules(
|
||||
iRule(
|
||||
|
@ -435,7 +436,7 @@ func TestServiceAnnotations(t *testing.T) {
|
|||
),
|
||||
}
|
||||
|
||||
services := []*v1.Service{
|
||||
services := []*corev1.Service{
|
||||
buildService(
|
||||
sName("service1"),
|
||||
sNamespace("testing"),
|
||||
|
@ -483,7 +484,7 @@ retryexpression: IsNetworkError() && Attempts() <= 2
|
|||
),
|
||||
}
|
||||
|
||||
endpoints := []*v1.Endpoints{
|
||||
endpoints := []*corev1.Endpoints{
|
||||
buildEndpoint(
|
||||
eNamespace("testing"),
|
||||
eName("service1"),
|
||||
|
@ -603,7 +604,7 @@ retryexpression: IsNetworkError() && Attempts() <= 2
|
|||
}
|
||||
|
||||
func TestIngressAnnotations(t *testing.T) {
|
||||
ingresses := []*v1beta1.Ingress{
|
||||
ingresses := []*extensionsv1beta1.Ingress{
|
||||
buildIngress(
|
||||
iNamespace("testing"),
|
||||
iAnnotation(annotationKubernetesPreserveHost, "false"),
|
||||
|
@ -767,7 +768,7 @@ rateset:
|
|||
),
|
||||
}
|
||||
|
||||
services := []*v1.Service{
|
||||
services := []*corev1.Service{
|
||||
buildService(
|
||||
sName("service1"),
|
||||
sNamespace("testing"),
|
||||
|
@ -788,9 +789,9 @@ rateset:
|
|||
),
|
||||
}
|
||||
|
||||
secrets := []*v1.Secret{
|
||||
secrets := []*corev1.Secret{
|
||||
{
|
||||
ObjectMeta: v1.ObjectMeta{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: "mySecret",
|
||||
UID: "1",
|
||||
Namespace: "testing",
|
||||
|
@ -1000,7 +1001,7 @@ rateset:
|
|||
}
|
||||
|
||||
func TestIngressClassAnnotation(t *testing.T) {
|
||||
ingresses := []*v1beta1.Ingress{
|
||||
ingresses := []*extensionsv1beta1.Ingress{
|
||||
buildIngress(
|
||||
iNamespace("testing"),
|
||||
iAnnotation(annotationKubernetesIngressClass, traefikDefaultIngressClass),
|
||||
|
@ -1038,7 +1039,7 @@ func TestIngressClassAnnotation(t *testing.T) {
|
|||
),
|
||||
}
|
||||
|
||||
services := []*v1.Service{
|
||||
services := []*corev1.Service{
|
||||
buildService(
|
||||
sName("service1"),
|
||||
sNamespace("testing"),
|
||||
|
@ -1147,7 +1148,7 @@ func TestIngressClassAnnotation(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestPriorityHeaderValue(t *testing.T) {
|
||||
ingresses := []*v1beta1.Ingress{
|
||||
ingresses := []*extensionsv1beta1.Ingress{
|
||||
buildIngress(
|
||||
iNamespace("testing"),
|
||||
iAnnotation(annotationKubernetesPriority, "1337"),
|
||||
|
@ -1159,7 +1160,7 @@ func TestPriorityHeaderValue(t *testing.T) {
|
|||
),
|
||||
}
|
||||
|
||||
services := []*v1.Service{
|
||||
services := []*corev1.Service{
|
||||
buildService(
|
||||
sName("service1"),
|
||||
sNamespace("testing"),
|
||||
|
@ -1172,7 +1173,7 @@ func TestPriorityHeaderValue(t *testing.T) {
|
|||
),
|
||||
}
|
||||
|
||||
var endpoints []*v1.Endpoints
|
||||
var endpoints []*corev1.Endpoints
|
||||
watchChan := make(chan interface{})
|
||||
client := clientMock{
|
||||
ingresses: ingresses,
|
||||
|
@ -1207,7 +1208,7 @@ func TestPriorityHeaderValue(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestInvalidPassTLSCertValue(t *testing.T) {
|
||||
ingresses := []*v1beta1.Ingress{
|
||||
ingresses := []*extensionsv1beta1.Ingress{
|
||||
buildIngress(
|
||||
iNamespace("testing"),
|
||||
iAnnotation(annotationKubernetesPassTLSCert, "herpderp"),
|
||||
|
@ -1219,7 +1220,7 @@ func TestInvalidPassTLSCertValue(t *testing.T) {
|
|||
),
|
||||
}
|
||||
|
||||
services := []*v1.Service{
|
||||
services := []*corev1.Service{
|
||||
buildService(
|
||||
sName("service1"),
|
||||
sNamespace("testing"),
|
||||
|
@ -1264,7 +1265,7 @@ func TestInvalidPassTLSCertValue(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestInvalidPassHostHeaderValue(t *testing.T) {
|
||||
ingresses := []*v1beta1.Ingress{
|
||||
ingresses := []*extensionsv1beta1.Ingress{
|
||||
buildIngress(
|
||||
iNamespace("testing"),
|
||||
iAnnotation(annotationKubernetesPreserveHost, "herpderp"),
|
||||
|
@ -1276,7 +1277,7 @@ func TestInvalidPassHostHeaderValue(t *testing.T) {
|
|||
),
|
||||
}
|
||||
|
||||
services := []*v1.Service{
|
||||
services := []*corev1.Service{
|
||||
buildService(
|
||||
sName("service1"),
|
||||
sNamespace("testing"),
|
||||
|
@ -1321,7 +1322,7 @@ func TestInvalidPassHostHeaderValue(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestKubeAPIErrors(t *testing.T) {
|
||||
ingresses := []*v1beta1.Ingress{
|
||||
ingresses := []*extensionsv1beta1.Ingress{
|
||||
buildIngress(
|
||||
iNamespace("testing"),
|
||||
iRules(
|
||||
|
@ -1332,7 +1333,7 @@ func TestKubeAPIErrors(t *testing.T) {
|
|||
),
|
||||
}
|
||||
|
||||
services := []*v1.Service{
|
||||
services := []*corev1.Service{
|
||||
buildService(
|
||||
sName("service1"),
|
||||
sNamespace("testing"),
|
||||
|
@ -1384,7 +1385,7 @@ func TestKubeAPIErrors(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestMissingResources(t *testing.T) {
|
||||
ingresses := []*v1beta1.Ingress{
|
||||
ingresses := []*extensionsv1beta1.Ingress{
|
||||
buildIngress(
|
||||
iNamespace("testing"),
|
||||
iRules(
|
||||
|
@ -1404,7 +1405,7 @@ func TestMissingResources(t *testing.T) {
|
|||
),
|
||||
}
|
||||
|
||||
services := []*v1.Service{
|
||||
services := []*corev1.Service{
|
||||
buildService(
|
||||
sName("fully_working_service"),
|
||||
sNamespace("testing"),
|
||||
|
@ -1431,7 +1432,7 @@ func TestMissingResources(t *testing.T) {
|
|||
),
|
||||
}
|
||||
|
||||
endpoints := []*v1.Endpoints{
|
||||
endpoints := []*corev1.Endpoints{
|
||||
buildEndpoint(
|
||||
eName("fully_working_service"),
|
||||
eUID("1"),
|
||||
|
@ -1500,7 +1501,7 @@ func TestMissingResources(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestBasicAuthInTemplate(t *testing.T) {
|
||||
ingresses := []*v1beta1.Ingress{
|
||||
ingresses := []*extensionsv1beta1.Ingress{
|
||||
buildIngress(
|
||||
iNamespace("testing"),
|
||||
iAnnotation(annotationKubernetesAuthType, "basic"),
|
||||
|
@ -1513,7 +1514,7 @@ func TestBasicAuthInTemplate(t *testing.T) {
|
|||
),
|
||||
}
|
||||
|
||||
services := []*v1.Service{
|
||||
services := []*corev1.Service{
|
||||
buildService(
|
||||
sName("service1"),
|
||||
sNamespace("testing"),
|
||||
|
@ -1526,8 +1527,8 @@ func TestBasicAuthInTemplate(t *testing.T) {
|
|||
),
|
||||
}
|
||||
|
||||
secrets := []*v1.Secret{{
|
||||
ObjectMeta: v1.ObjectMeta{
|
||||
secrets := []*corev1.Secret{{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: "mySecret",
|
||||
UID: "1",
|
||||
Namespace: "testing",
|
||||
|
@ -1537,7 +1538,7 @@ func TestBasicAuthInTemplate(t *testing.T) {
|
|||
},
|
||||
}}
|
||||
|
||||
var endpoints []*v1.Endpoints
|
||||
var endpoints []*corev1.Endpoints
|
||||
watchChan := make(chan interface{})
|
||||
client := clientMock{
|
||||
ingresses: ingresses,
|
||||
|
@ -1560,7 +1561,7 @@ func TestBasicAuthInTemplate(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestTLSSecretLoad(t *testing.T) {
|
||||
ingresses := []*v1beta1.Ingress{
|
||||
ingresses := []*extensionsv1beta1.Ingress{
|
||||
buildIngress(
|
||||
iNamespace("testing"),
|
||||
iAnnotation(annotationKubernetesFrontendEntryPoints, "ep1,ep2"),
|
||||
|
@ -1589,7 +1590,7 @@ func TestTLSSecretLoad(t *testing.T) {
|
|||
),
|
||||
),
|
||||
}
|
||||
services := []*v1.Service{
|
||||
services := []*corev1.Service{
|
||||
buildService(
|
||||
sName("example-com"),
|
||||
sNamespace("testing"),
|
||||
|
@ -1609,9 +1610,9 @@ func TestTLSSecretLoad(t *testing.T) {
|
|||
sPorts(sPort(80, "http"))),
|
||||
),
|
||||
}
|
||||
secrets := []*v1.Secret{
|
||||
secrets := []*corev1.Secret{
|
||||
{
|
||||
ObjectMeta: v1.ObjectMeta{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: "myTlsSecret",
|
||||
UID: "1",
|
||||
Namespace: "testing",
|
||||
|
@ -1622,7 +1623,7 @@ func TestTLSSecretLoad(t *testing.T) {
|
|||
},
|
||||
},
|
||||
}
|
||||
endpoints := []*v1.Endpoints{}
|
||||
endpoints := []*corev1.Endpoints{}
|
||||
watchChan := make(chan interface{})
|
||||
client := clientMock{
|
||||
ingresses: ingresses,
|
||||
|
@ -1691,7 +1692,7 @@ func TestGetTLS(t *testing.T) {
|
|||
|
||||
tests := []struct {
|
||||
desc string
|
||||
ingress *v1beta1.Ingress
|
||||
ingress *extensionsv1beta1.Ingress
|
||||
client Client
|
||||
result []*tls.Configuration
|
||||
errResult string
|
||||
|
@ -1714,9 +1715,9 @@ func TestGetTLS(t *testing.T) {
|
|||
desc: "entry 'tls.crt' in secret missing",
|
||||
ingress: testIngressWithoutHostname,
|
||||
client: clientMock{
|
||||
secrets: []*v1.Secret{
|
||||
secrets: []*corev1.Secret{
|
||||
{
|
||||
ObjectMeta: v1.ObjectMeta{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: "test-secret",
|
||||
Namespace: "testing",
|
||||
},
|
||||
|
@ -1732,9 +1733,9 @@ func TestGetTLS(t *testing.T) {
|
|||
desc: "entry 'tls.key' in secret missing",
|
||||
ingress: testIngressWithoutHostname,
|
||||
client: clientMock{
|
||||
secrets: []*v1.Secret{
|
||||
secrets: []*corev1.Secret{
|
||||
{
|
||||
ObjectMeta: v1.ObjectMeta{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: "test-secret",
|
||||
Namespace: "testing",
|
||||
},
|
||||
|
@ -1750,9 +1751,9 @@ func TestGetTLS(t *testing.T) {
|
|||
desc: "secret doesn't provide any of the required fields",
|
||||
ingress: testIngressWithoutHostname,
|
||||
client: clientMock{
|
||||
secrets: []*v1.Secret{
|
||||
secrets: []*corev1.Secret{
|
||||
{
|
||||
ObjectMeta: v1.ObjectMeta{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: "test-secret",
|
||||
Namespace: "testing",
|
||||
},
|
||||
|
@ -1777,9 +1778,9 @@ func TestGetTLS(t *testing.T) {
|
|||
),
|
||||
),
|
||||
client: clientMock{
|
||||
secrets: []*v1.Secret{
|
||||
secrets: []*corev1.Secret{
|
||||
{
|
||||
ObjectMeta: v1.ObjectMeta{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: "test-secret",
|
||||
Namespace: "testing",
|
||||
},
|
||||
|
@ -1814,9 +1815,9 @@ func TestGetTLS(t *testing.T) {
|
|||
iTLSes(iTLS("test-secret")),
|
||||
),
|
||||
client: clientMock{
|
||||
secrets: []*v1.Secret{
|
||||
secrets: []*corev1.Secret{
|
||||
{
|
||||
ObjectMeta: v1.ObjectMeta{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: "test-secret",
|
||||
Namespace: "testing",
|
||||
},
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue