mirror of
https://github.com/kubernetes-sigs/external-dns.git
synced 2025-08-06 01:26:59 +02:00
use istio client-go and clean up k8s deps
This commit is contained in:
parent
3db7f993c9
commit
b1b46e7bec
45
go.mod
45
go.mod
@ -3,22 +3,22 @@ module sigs.k8s.io/external-dns
|
||||
go 1.14
|
||||
|
||||
require (
|
||||
cloud.google.com/go v0.44.3
|
||||
cloud.google.com/go v0.50.0
|
||||
github.com/Azure/azure-sdk-for-go v36.0.0+incompatible
|
||||
github.com/Azure/go-autorest/autorest v0.9.0
|
||||
github.com/Azure/go-autorest/autorest/adal v0.6.0
|
||||
github.com/Azure/go-autorest/autorest v0.9.4
|
||||
github.com/Azure/go-autorest/autorest/adal v0.8.3
|
||||
github.com/Azure/go-autorest/autorest/azure/auth v0.0.0-00010101000000-000000000000
|
||||
github.com/Azure/go-autorest/autorest/to v0.3.0
|
||||
github.com/akamai/AkamaiOPEN-edgegrid-golang v0.9.11
|
||||
github.com/alecthomas/assert v0.0.0-20170929043011-405dbfeb8e38 // indirect
|
||||
github.com/alecthomas/colour v0.1.0 // indirect
|
||||
github.com/alecthomas/kingpin v2.2.5+incompatible
|
||||
github.com/alecthomas/repr v0.0.0-20181024024818-d37bc2a10ba1 // indirect
|
||||
github.com/alecthomas/repr v0.0.0-20200325044227-4184120f674c // indirect
|
||||
github.com/aliyun/alibaba-cloud-sdk-go v0.0.0-20180828111155-cad214d7d71f
|
||||
github.com/aws/aws-sdk-go v1.27.4
|
||||
github.com/cloudflare/cloudflare-go v0.10.1
|
||||
github.com/cloudfoundry-community/go-cfclient v0.0.0-20190201205600-f136f9222381
|
||||
github.com/denverdino/aliyungo v0.0.0-20180815121905-69560d9530f5
|
||||
github.com/denverdino/aliyungo v0.0.0-20190125010748-a747050bb1ba
|
||||
github.com/digitalocean/godo v1.34.0
|
||||
github.com/dnaeon/go-vcr v1.0.1 // indirect
|
||||
github.com/dnsimple/dnsimple-go v0.60.0
|
||||
@ -28,41 +28,41 @@ require (
|
||||
github.com/gobs/pretty v0.0.0-20180724170744-09732c25a95b // indirect
|
||||
github.com/golang/sync v0.0.0-20180314180146-1d60e4601c6f
|
||||
github.com/gophercloud/gophercloud v0.1.0
|
||||
github.com/gorilla/mux v1.7.4 // indirect
|
||||
github.com/infobloxopen/infoblox-go-client v0.0.0-20180606155407-61dc5f9b0a65
|
||||
github.com/linki/instrumented_http v0.2.0
|
||||
github.com/linode/linodego v0.3.0
|
||||
github.com/mattn/go-isatty v0.0.11 // indirect
|
||||
github.com/maxatome/go-testdeep v1.4.0
|
||||
github.com/miekg/dns v1.1.25
|
||||
github.com/nesv/go-dynect v0.6.0
|
||||
github.com/nic-at/rc0go v1.1.0
|
||||
github.com/openshift/api v0.0.0-20190322043348-8741ff068a47
|
||||
github.com/openshift/client-go v3.9.0+incompatible
|
||||
github.com/openshift/api v0.0.0-20200302134843-001335d6cc34
|
||||
github.com/openshift/client-go v0.0.0-20200116145930-eb24d03d8420
|
||||
github.com/oracle/oci-go-sdk v1.8.0
|
||||
github.com/ovh/go-ovh v0.0.0-20181109152953-ba5adb4cf014
|
||||
github.com/pkg/errors v0.9.1
|
||||
github.com/projectcontour/contour v1.4.0
|
||||
github.com/prometheus/client_golang v1.1.0
|
||||
github.com/sanyu/dynectsoap v0.0.0-20181203081243-b83de5edc4e0
|
||||
github.com/sergi/go-diff v1.1.0 // indirect
|
||||
github.com/satori/go.uuid v1.2.0 // indirect
|
||||
github.com/sirupsen/logrus v1.4.2
|
||||
github.com/smartystreets/go-aws-auth v0.0.0-20180515143844-0c1422d1fdb9 // indirect
|
||||
github.com/smartystreets/gunit v1.1.1 // indirect
|
||||
github.com/stretchr/testify v1.4.0
|
||||
github.com/smartystreets/gunit v1.3.4 // indirect
|
||||
github.com/stretchr/testify v1.5.1
|
||||
github.com/transip/gotransip v5.8.2+incompatible
|
||||
github.com/vinyldns/go-vinyldns v0.0.0-20190611170422-7119fe55ed92
|
||||
github.com/vultr/govultr v0.3.2
|
||||
go.etcd.io/etcd v0.5.0-alpha.5.0.20200401174654-e694b7bb0875
|
||||
golang.org/x/net v0.0.0-20191004110552-13f9640d40b9
|
||||
golang.org/x/net v0.0.0-20191209160850-c0dbc17a3553
|
||||
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45
|
||||
google.golang.org/api v0.9.0
|
||||
google.golang.org/api v0.15.0
|
||||
gopkg.in/ns1/ns1-go.v2 v2.0.0-20190322154155-0dafb5275fd1
|
||||
gopkg.in/yaml.v2 v2.2.7
|
||||
istio.io/api v0.0.0-20190820204432-483f2547d882
|
||||
istio.io/istio v0.0.0-20190322063008-2b1331886076
|
||||
k8s.io/api v0.17.0
|
||||
k8s.io/apimachinery v0.17.0
|
||||
k8s.io/client-go v10.0.0+incompatible
|
||||
gopkg.in/yaml.v2 v2.2.8
|
||||
istio.io/api v0.0.0-20200324230725-4b064f75ad8f
|
||||
istio.io/client-go v0.0.0-20200324231043-96a582576da1
|
||||
k8s.io/api v0.17.2
|
||||
k8s.io/apimachinery v0.17.2
|
||||
k8s.io/client-go v0.17.2
|
||||
k8s.io/klog v1.0.0
|
||||
)
|
||||
|
||||
@ -72,12 +72,5 @@ replace (
|
||||
github.com/Azure/go-autorest/autorest/adal => github.com/Azure/go-autorest/autorest/adal v0.6.0
|
||||
github.com/Azure/go-autorest/autorest/azure/auth => github.com/Azure/go-autorest/autorest/azure/auth v0.3.0
|
||||
github.com/golang/glog => github.com/kubermatic/glog-logrus v0.0.0-20180829085450-3fa5b9870d1d
|
||||
istio.io/api => istio.io/api v0.0.0-20190820204432-483f2547d882
|
||||
istio.io/istio => istio.io/istio v0.0.0-20190911205955-c2bd59595ce6
|
||||
k8s.io/api => k8s.io/api v0.0.0-20190817221950-ebce17126a01
|
||||
k8s.io/apiextensions-apiserver => k8s.io/apiextensions-apiserver v0.0.0-20190919022157-e8460a76b3ad
|
||||
k8s.io/apimachinery => k8s.io/apimachinery v0.0.0-20190817221809-bf4de9df677c
|
||||
k8s.io/client-go => k8s.io/client-go v0.0.0-20190817222206-ee6c071a42cf
|
||||
k8s.io/klog => github.com/mikkeloscar/knolog v0.0.0-20190326191552-80742771eb6b
|
||||
github.com/envoyproxy/go-control-plane => github.com/envoyproxy/go-control-plane v0.8.7-0.20190821215049-f062b07a671a
|
||||
)
|
||||
|
@ -92,7 +92,7 @@ func NewCRDClientForAPIVersionKind(client kubernetes.Interface, kubeConfig, kube
|
||||
|
||||
config.ContentConfig.GroupVersion = &groupVersion
|
||||
config.APIPath = "/apis"
|
||||
config.NegotiatedSerializer = serializer.DirectCodecFactory{CodecFactory: serializer.NewCodecFactory(scheme)}
|
||||
config.NegotiatedSerializer = serializer.WithoutConversionCodecFactory{CodecFactory: serializer.NewCodecFactory(scheme)}
|
||||
|
||||
crdClient, err := rest.UnversionedRESTClientFor(config)
|
||||
if err != nil {
|
||||
|
@ -78,7 +78,7 @@ func startCRDServerToServeTargets(endpoints []*endpoint.Endpoint, apiVersion, ki
|
||||
},
|
||||
}
|
||||
|
||||
codecFactory := serializer.DirectCodecFactory{
|
||||
codecFactory := serializer.WithoutConversionCodecFactory{
|
||||
CodecFactory: serializer.NewCodecFactory(scheme),
|
||||
}
|
||||
|
||||
|
@ -25,8 +25,8 @@ import (
|
||||
"time"
|
||||
|
||||
log "github.com/sirupsen/logrus"
|
||||
istionetworking "istio.io/api/networking/v1alpha3"
|
||||
istiomodel "istio.io/istio/pilot/pkg/model"
|
||||
networkingv1alpha3 "istio.io/client-go/pkg/apis/networking/v1alpha3"
|
||||
istioclient "istio.io/client-go/pkg/clientset/versioned"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/labels"
|
||||
"k8s.io/apimachinery/pkg/util/wait"
|
||||
@ -43,7 +43,7 @@ import (
|
||||
// Use targetAnnotationKey to explicitly set Endpoint.
|
||||
type gatewaySource struct {
|
||||
kubeClient kubernetes.Interface
|
||||
istioClient istiomodel.ConfigStore
|
||||
istioClient istioclient.Interface
|
||||
namespace string
|
||||
annotationFilter string
|
||||
fqdnTemplate *template.Template
|
||||
@ -55,7 +55,7 @@ type gatewaySource struct {
|
||||
// NewIstioGatewaySource creates a new gatewaySource with the given config.
|
||||
func NewIstioGatewaySource(
|
||||
kubeClient kubernetes.Interface,
|
||||
istioClient istiomodel.ConfigStore,
|
||||
istioClient istioclient.Interface,
|
||||
namespace string,
|
||||
annotationFilter string,
|
||||
fqdnTemplate string,
|
||||
@ -116,35 +116,36 @@ func NewIstioGatewaySource(
|
||||
// Endpoints returns endpoint objects for each host-target combination that should be processed.
|
||||
// Retrieves all gateway resources in the source's namespace(s).
|
||||
func (sc *gatewaySource) Endpoints() ([]*endpoint.Endpoint, error) {
|
||||
configs, err := sc.istioClient.List(istiomodel.Gateway.Type, sc.namespace)
|
||||
gwList, err := sc.istioClient.NetworkingV1alpha3().Gateways(sc.namespace).List(metav1.ListOptions{})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
configs, err = sc.filterByAnnotations(configs)
|
||||
gateways := gwList.Items
|
||||
gateways, err = sc.filterByAnnotations(gateways)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
endpoints := []*endpoint.Endpoint{}
|
||||
|
||||
for _, config := range configs {
|
||||
for _, gateway := range gateways {
|
||||
// Check controller annotation to see if we are responsible.
|
||||
controller, ok := config.Annotations[controllerAnnotationKey]
|
||||
controller, ok := gateway.Annotations[controllerAnnotationKey]
|
||||
if ok && controller != controllerAnnotationValue {
|
||||
log.Debugf("Skipping gateway %s/%s because controller value does not match, found: %s, required: %s",
|
||||
config.Namespace, config.Name, controller, controllerAnnotationValue)
|
||||
gateway.Namespace, gateway.Name, controller, controllerAnnotationValue)
|
||||
continue
|
||||
}
|
||||
|
||||
gwEndpoints, err := sc.endpointsFromGatewayConfig(config)
|
||||
gwEndpoints, err := sc.endpointsFromGatewayConfig(gateway)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// apply template if host is missing on gateway
|
||||
if (sc.combineFQDNAnnotation || len(gwEndpoints) == 0) && sc.fqdnTemplate != nil {
|
||||
iEndpoints, err := sc.endpointsFromTemplate(&config)
|
||||
iEndpoints, err := sc.endpointsFromTemplate2(gateway)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -157,12 +158,12 @@ func (sc *gatewaySource) Endpoints() ([]*endpoint.Endpoint, error) {
|
||||
}
|
||||
|
||||
if len(gwEndpoints) == 0 {
|
||||
log.Debugf("No endpoints could be generated from gateway %s/%s", config.Namespace, config.Name)
|
||||
log.Debugf("No endpoints could be generated from gateway %s/%s", gateway.Namespace, gateway.Name)
|
||||
continue
|
||||
}
|
||||
|
||||
log.Debugf("Endpoints generated from gateway: %s/%s: %v", config.Namespace, config.Name, gwEndpoints)
|
||||
sc.setResourceLabel(config, gwEndpoints)
|
||||
log.Debugf("Endpoints generated from gateway: %s/%s: %v", gateway.Namespace, gateway.Name, gwEndpoints)
|
||||
sc.setResourceLabel(gateway, gwEndpoints)
|
||||
endpoints = append(endpoints, gwEndpoints...)
|
||||
}
|
||||
|
||||
@ -176,31 +177,31 @@ func (sc *gatewaySource) Endpoints() ([]*endpoint.Endpoint, error) {
|
||||
func (sc *gatewaySource) AddEventHandler(handler func() error, stopChan <-chan struct{}, minInterval time.Duration) {
|
||||
}
|
||||
|
||||
func (sc *gatewaySource) endpointsFromTemplate(config *istiomodel.Config) ([]*endpoint.Endpoint, error) {
|
||||
func (sc *gatewaySource) endpointsFromTemplate2(gateway networkingv1alpha3.Gateway) ([]*endpoint.Endpoint, error) {
|
||||
// Process the whole template string
|
||||
var buf bytes.Buffer
|
||||
err := sc.fqdnTemplate.Execute(&buf, config)
|
||||
err := sc.fqdnTemplate.Execute(&buf, gateway)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to apply template on istio config %s: %v", config, err)
|
||||
return nil, fmt.Errorf("failed to apply template on istio config %v: %v", gateway, err)
|
||||
}
|
||||
|
||||
hostnames := buf.String()
|
||||
|
||||
ttl, err := getTTLFromAnnotations(config.Annotations)
|
||||
ttl, err := getTTLFromAnnotations(gateway.Annotations)
|
||||
if err != nil {
|
||||
log.Warn(err)
|
||||
}
|
||||
|
||||
targets := getTargetsFromTargetAnnotation(config.Annotations)
|
||||
targets := getTargetsFromTargetAnnotation(gateway.Annotations)
|
||||
|
||||
if len(targets) == 0 {
|
||||
targets, err = sc.targetsFromGatewayConfig(config)
|
||||
targets, err = sc.targetsFromGatewayConfig(gateway)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
providerSpecific, setIdentifier := getProviderSpecificAnnotations(config.Annotations)
|
||||
providerSpecific, setIdentifier := getProviderSpecificAnnotations(gateway.Annotations)
|
||||
|
||||
var endpoints []*endpoint.Endpoint
|
||||
// splits the FQDN template and removes the trailing periods
|
||||
@ -212,8 +213,8 @@ func (sc *gatewaySource) endpointsFromTemplate(config *istiomodel.Config) ([]*en
|
||||
return endpoints, nil
|
||||
}
|
||||
|
||||
// filterByAnnotations filters a list of configs by a given annotation selector.
|
||||
func (sc *gatewaySource) filterByAnnotations(configs []istiomodel.Config) ([]istiomodel.Config, error) {
|
||||
// filterByAnnotations2 filters a list of configs by a given annotation selector.
|
||||
func (sc *gatewaySource) filterByAnnotations(gateways []networkingv1alpha3.Gateway) ([]networkingv1alpha3.Gateway, error) {
|
||||
labelSelector, err := metav1.ParseToLabelSelector(sc.annotationFilter)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@ -225,33 +226,32 @@ func (sc *gatewaySource) filterByAnnotations(configs []istiomodel.Config) ([]ist
|
||||
|
||||
// empty filter returns original list
|
||||
if selector.Empty() {
|
||||
return configs, nil
|
||||
return gateways, nil
|
||||
}
|
||||
|
||||
filteredList := []istiomodel.Config{}
|
||||
var filteredList []networkingv1alpha3.Gateway
|
||||
|
||||
for _, config := range configs {
|
||||
for _, gw := range gateways {
|
||||
// convert the annotations to an equivalent label selector
|
||||
annotations := labels.Set(config.Annotations)
|
||||
annotations := labels.Set(gw.Annotations)
|
||||
|
||||
// include if the annotations match the selector
|
||||
if selector.Matches(annotations) {
|
||||
filteredList = append(filteredList, config)
|
||||
filteredList = append(filteredList, gw)
|
||||
}
|
||||
}
|
||||
|
||||
return filteredList, nil
|
||||
}
|
||||
|
||||
func (sc *gatewaySource) setResourceLabel(config istiomodel.Config, endpoints []*endpoint.Endpoint) {
|
||||
func (sc *gatewaySource) setResourceLabel(gateway networkingv1alpha3.Gateway, endpoints []*endpoint.Endpoint) {
|
||||
for _, ep := range endpoints {
|
||||
ep.Labels[endpoint.ResourceLabelKey] = fmt.Sprintf("gateway/%s/%s", config.Namespace, config.Name)
|
||||
ep.Labels[endpoint.ResourceLabelKey] = fmt.Sprintf("gateway/%s/%s", gateway.Namespace, gateway.Name)
|
||||
}
|
||||
}
|
||||
|
||||
func (sc *gatewaySource) targetsFromGatewayConfig(config *istiomodel.Config) (targets endpoint.Targets, err error) {
|
||||
gateway := config.Spec.(*istionetworking.Gateway)
|
||||
labelSelector, err := metav1.ParseToLabelSelector(labels.Set(gateway.Selector).String())
|
||||
func (sc *gatewaySource) targetsFromGatewayConfig(gateway networkingv1alpha3.Gateway) (targets endpoint.Targets, err error) {
|
||||
labelSelector, err := metav1.ParseToLabelSelector(labels.Set(gateway.Spec.Selector).String())
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -281,28 +281,26 @@ func (sc *gatewaySource) targetsFromGatewayConfig(config *istiomodel.Config) (ta
|
||||
}
|
||||
|
||||
// endpointsFromGatewayConfig extracts the endpoints from an Istio Gateway Config object
|
||||
func (sc *gatewaySource) endpointsFromGatewayConfig(config istiomodel.Config) ([]*endpoint.Endpoint, error) {
|
||||
func (sc *gatewaySource) endpointsFromGatewayConfig(gateway networkingv1alpha3.Gateway) ([]*endpoint.Endpoint, error) {
|
||||
var endpoints []*endpoint.Endpoint
|
||||
|
||||
ttl, err := getTTLFromAnnotations(config.Annotations)
|
||||
ttl, err := getTTLFromAnnotations(gateway.Annotations)
|
||||
if err != nil {
|
||||
log.Warn(err)
|
||||
}
|
||||
|
||||
targets := getTargetsFromTargetAnnotation(config.Annotations)
|
||||
targets := getTargetsFromTargetAnnotation(gateway.Annotations)
|
||||
|
||||
if len(targets) == 0 {
|
||||
targets, err = sc.targetsFromGatewayConfig(&config)
|
||||
targets, err = sc.targetsFromGatewayConfig(gateway)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
gateway := config.Spec.(*istionetworking.Gateway)
|
||||
providerSpecific, setIdentifier := getProviderSpecificAnnotations(gateway.Annotations)
|
||||
|
||||
providerSpecific, setIdentifier := getProviderSpecificAnnotations(config.Annotations)
|
||||
|
||||
for _, server := range gateway.Servers {
|
||||
for _, server := range gateway.Spec.Servers {
|
||||
for _, host := range server.Hosts {
|
||||
if host == "" {
|
||||
continue
|
||||
@ -322,7 +320,7 @@ func (sc *gatewaySource) endpointsFromGatewayConfig(config istiomodel.Config) ([
|
||||
|
||||
// Skip endpoints if we do not want entries from annotations
|
||||
if !sc.ignoreHostnameAnnotation {
|
||||
hostnameList := getHostnamesFromAnnotations(config.Annotations)
|
||||
hostnameList := getHostnamesFromAnnotations(gateway.Annotations)
|
||||
for _, hostname := range hostnameList {
|
||||
endpoints = append(endpoints, endpointsForHostname(hostname, targets, ttl, providerSpecific, setIdentifier)...)
|
||||
}
|
||||
|
@ -17,16 +17,16 @@ limitations under the License.
|
||||
package source
|
||||
|
||||
import (
|
||||
"strconv"
|
||||
"sync"
|
||||
"testing"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
"github.com/stretchr/testify/suite"
|
||||
istionetworking "istio.io/api/networking/v1alpha3"
|
||||
istiomodel "istio.io/istio/pilot/pkg/model"
|
||||
networkingv1alpha3api "istio.io/api/networking/v1alpha3"
|
||||
networkingv1alpha3 "istio.io/client-go/pkg/apis/networking/v1alpha3"
|
||||
istioclient "istio.io/client-go/pkg/clientset/versioned"
|
||||
istiofake "istio.io/client-go/pkg/clientset/versioned/fake"
|
||||
v1 "k8s.io/api/core/v1"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/client-go/kubernetes/fake"
|
||||
@ -37,13 +37,10 @@ import (
|
||||
// This is a compile-time validation that gatewaySource is a Source.
|
||||
var _ Source = &gatewaySource{}
|
||||
|
||||
var gatewayType = istiomodel.Gateway.Type
|
||||
|
||||
type GatewaySuite struct {
|
||||
suite.Suite
|
||||
source Source
|
||||
lbServices []*v1.Service
|
||||
config istiomodel.Config
|
||||
}
|
||||
|
||||
func (suite *GatewaySuite) SetupTest() {
|
||||
@ -81,13 +78,6 @@ func (suite *GatewaySuite) SetupTest() {
|
||||
false,
|
||||
)
|
||||
suite.NoError(err, "should initialize gateway source")
|
||||
|
||||
suite.config = (fakeGatewayConfig{
|
||||
name: "foo-gateway-with-targets",
|
||||
namespace: "default",
|
||||
dnsnames: [][]string{{"foo"}},
|
||||
}).Config()
|
||||
_, err = fakeIstioClient.Create(suite.config)
|
||||
suite.NoError(err, "should succeed")
|
||||
}
|
||||
|
||||
@ -316,9 +306,10 @@ func testEndpointsFromGatewayConfig(t *testing.T) {
|
||||
},
|
||||
} {
|
||||
t.Run(ti.title, func(t *testing.T) {
|
||||
gatewayCfg := ti.config.Config()
|
||||
if source, err := newTestGatewaySource(ti.lbServices); err != nil {
|
||||
require.NoError(t, err)
|
||||
} else if endpoints, err := source.endpointsFromGatewayConfig(ti.config.Config()); err != nil {
|
||||
} else if endpoints, err := source.endpointsFromGatewayConfig(*gatewayCfg); err != nil {
|
||||
require.NoError(t, err)
|
||||
} else {
|
||||
validateEndpoints(t, endpoints, ti.expected)
|
||||
@ -328,7 +319,6 @@ func testEndpointsFromGatewayConfig(t *testing.T) {
|
||||
}
|
||||
|
||||
func testGatewayEndpoints(t *testing.T) {
|
||||
namespace := "testing"
|
||||
for _, ti := range []struct {
|
||||
title string
|
||||
targetNamespace string
|
||||
@ -357,12 +347,12 @@ func testGatewayEndpoints(t *testing.T) {
|
||||
configItems: []fakeGatewayConfig{
|
||||
{
|
||||
name: "fake1",
|
||||
namespace: namespace,
|
||||
namespace: "",
|
||||
dnsnames: [][]string{{"example.org"}},
|
||||
},
|
||||
{
|
||||
name: "fake2",
|
||||
namespace: namespace,
|
||||
namespace: "",
|
||||
dnsnames: [][]string{{"new.org"}},
|
||||
},
|
||||
},
|
||||
@ -397,12 +387,12 @@ func testGatewayEndpoints(t *testing.T) {
|
||||
configItems: []fakeGatewayConfig{
|
||||
{
|
||||
name: "fake1",
|
||||
namespace: "testing1",
|
||||
namespace: "",
|
||||
dnsnames: [][]string{{"example.org"}},
|
||||
},
|
||||
{
|
||||
name: "fake2",
|
||||
namespace: "testing2",
|
||||
namespace: "",
|
||||
dnsnames: [][]string{{"new.org"}},
|
||||
},
|
||||
},
|
||||
@ -441,11 +431,6 @@ func testGatewayEndpoints(t *testing.T) {
|
||||
namespace: "testing1",
|
||||
dnsnames: [][]string{{"example.org"}},
|
||||
},
|
||||
{
|
||||
name: "fake2",
|
||||
namespace: "testing2",
|
||||
dnsnames: [][]string{{"new.org"}},
|
||||
},
|
||||
},
|
||||
expected: []*endpoint.Endpoint{
|
||||
{
|
||||
@ -470,7 +455,7 @@ func testGatewayEndpoints(t *testing.T) {
|
||||
configItems: []fakeGatewayConfig{
|
||||
{
|
||||
name: "fake1",
|
||||
namespace: namespace,
|
||||
namespace: "",
|
||||
annotations: map[string]string{
|
||||
"kubernetes.io/gateway.class": "nginx",
|
||||
},
|
||||
@ -496,7 +481,7 @@ func testGatewayEndpoints(t *testing.T) {
|
||||
configItems: []fakeGatewayConfig{
|
||||
{
|
||||
name: "fake1",
|
||||
namespace: namespace,
|
||||
namespace: "",
|
||||
annotations: map[string]string{
|
||||
"kubernetes.io/gateway.class": "tectonic",
|
||||
},
|
||||
@ -517,7 +502,7 @@ func testGatewayEndpoints(t *testing.T) {
|
||||
configItems: []fakeGatewayConfig{
|
||||
{
|
||||
name: "fake1",
|
||||
namespace: namespace,
|
||||
namespace: "",
|
||||
annotations: map[string]string{
|
||||
"kubernetes.io/gateway.class": "alb",
|
||||
},
|
||||
@ -539,7 +524,7 @@ func testGatewayEndpoints(t *testing.T) {
|
||||
configItems: []fakeGatewayConfig{
|
||||
{
|
||||
name: "fake1",
|
||||
namespace: namespace,
|
||||
namespace: "",
|
||||
annotations: map[string]string{
|
||||
"kubernetes.io/gateway.class": "nginx",
|
||||
},
|
||||
@ -565,7 +550,7 @@ func testGatewayEndpoints(t *testing.T) {
|
||||
configItems: []fakeGatewayConfig{
|
||||
{
|
||||
name: "fake1",
|
||||
namespace: namespace,
|
||||
namespace: "",
|
||||
annotations: map[string]string{
|
||||
"kubernetes.io/gateway.class": "alb",
|
||||
},
|
||||
@ -585,7 +570,7 @@ func testGatewayEndpoints(t *testing.T) {
|
||||
configItems: []fakeGatewayConfig{
|
||||
{
|
||||
name: "fake1",
|
||||
namespace: namespace,
|
||||
namespace: "",
|
||||
annotations: map[string]string{
|
||||
controllerAnnotationKey: controllerAnnotationValue,
|
||||
},
|
||||
@ -610,7 +595,7 @@ func testGatewayEndpoints(t *testing.T) {
|
||||
configItems: []fakeGatewayConfig{
|
||||
{
|
||||
name: "fake1",
|
||||
namespace: namespace,
|
||||
namespace: "",
|
||||
annotations: map[string]string{
|
||||
controllerAnnotationKey: "some-other-tool",
|
||||
},
|
||||
@ -631,7 +616,7 @@ func testGatewayEndpoints(t *testing.T) {
|
||||
configItems: []fakeGatewayConfig{
|
||||
{
|
||||
name: "fake1",
|
||||
namespace: namespace,
|
||||
namespace: "",
|
||||
annotations: map[string]string{
|
||||
controllerAnnotationKey: controllerAnnotationValue,
|
||||
},
|
||||
@ -661,7 +646,7 @@ func testGatewayEndpoints(t *testing.T) {
|
||||
configItems: []fakeGatewayConfig{
|
||||
{
|
||||
name: "fake1",
|
||||
namespace: namespace,
|
||||
namespace: "",
|
||||
annotations: map[string]string{
|
||||
controllerAnnotationKey: "other-controller",
|
||||
},
|
||||
@ -682,7 +667,7 @@ func testGatewayEndpoints(t *testing.T) {
|
||||
configItems: []fakeGatewayConfig{
|
||||
{
|
||||
name: "fake1",
|
||||
namespace: namespace,
|
||||
namespace: "",
|
||||
annotations: map[string]string{},
|
||||
dnsnames: [][]string{},
|
||||
},
|
||||
@ -712,13 +697,13 @@ func testGatewayEndpoints(t *testing.T) {
|
||||
configItems: []fakeGatewayConfig{
|
||||
{
|
||||
name: "fake1",
|
||||
namespace: namespace,
|
||||
namespace: "",
|
||||
annotations: map[string]string{},
|
||||
dnsnames: [][]string{},
|
||||
},
|
||||
{
|
||||
name: "fake2",
|
||||
namespace: namespace,
|
||||
namespace: "",
|
||||
annotations: map[string]string{
|
||||
targetAnnotationKey: "gateway-target.com",
|
||||
},
|
||||
@ -766,7 +751,7 @@ func testGatewayEndpoints(t *testing.T) {
|
||||
configItems: []fakeGatewayConfig{
|
||||
{
|
||||
name: "fake1",
|
||||
namespace: namespace,
|
||||
namespace: "",
|
||||
annotations: map[string]string{
|
||||
targetAnnotationKey: "gateway-target.com",
|
||||
},
|
||||
@ -774,7 +759,7 @@ func testGatewayEndpoints(t *testing.T) {
|
||||
},
|
||||
{
|
||||
name: "fake2",
|
||||
namespace: namespace,
|
||||
namespace: "",
|
||||
annotations: map[string]string{
|
||||
targetAnnotationKey: "gateway-target.com",
|
||||
},
|
||||
@ -782,7 +767,7 @@ func testGatewayEndpoints(t *testing.T) {
|
||||
},
|
||||
{
|
||||
name: "fake3",
|
||||
namespace: namespace,
|
||||
namespace: "",
|
||||
annotations: map[string]string{
|
||||
targetAnnotationKey: "1.2.3.4",
|
||||
},
|
||||
@ -818,7 +803,7 @@ func testGatewayEndpoints(t *testing.T) {
|
||||
configItems: []fakeGatewayConfig{
|
||||
{
|
||||
name: "fake1",
|
||||
namespace: namespace,
|
||||
namespace: "",
|
||||
annotations: map[string]string{
|
||||
hostnameAnnotationKey: "dns-through-hostname.com",
|
||||
},
|
||||
@ -849,7 +834,7 @@ func testGatewayEndpoints(t *testing.T) {
|
||||
configItems: []fakeGatewayConfig{
|
||||
{
|
||||
name: "fake1",
|
||||
namespace: namespace,
|
||||
namespace: "",
|
||||
annotations: map[string]string{
|
||||
hostnameAnnotationKey: "dns-through-hostname.com, another-dns-through-hostname.com",
|
||||
},
|
||||
@ -885,7 +870,7 @@ func testGatewayEndpoints(t *testing.T) {
|
||||
configItems: []fakeGatewayConfig{
|
||||
{
|
||||
name: "fake1",
|
||||
namespace: namespace,
|
||||
namespace: "",
|
||||
annotations: map[string]string{
|
||||
hostnameAnnotationKey: "dns-through-hostname.com",
|
||||
targetAnnotationKey: "gateway-target.com",
|
||||
@ -917,7 +902,7 @@ func testGatewayEndpoints(t *testing.T) {
|
||||
configItems: []fakeGatewayConfig{
|
||||
{
|
||||
name: "fake1",
|
||||
namespace: namespace,
|
||||
namespace: "",
|
||||
annotations: map[string]string{
|
||||
targetAnnotationKey: "gateway-target.com",
|
||||
ttlAnnotationKey: "6",
|
||||
@ -926,7 +911,7 @@ func testGatewayEndpoints(t *testing.T) {
|
||||
},
|
||||
{
|
||||
name: "fake2",
|
||||
namespace: namespace,
|
||||
namespace: "",
|
||||
annotations: map[string]string{
|
||||
targetAnnotationKey: "gateway-target.com",
|
||||
ttlAnnotationKey: "1",
|
||||
@ -935,7 +920,7 @@ func testGatewayEndpoints(t *testing.T) {
|
||||
},
|
||||
{
|
||||
name: "fake3",
|
||||
namespace: namespace,
|
||||
namespace: "",
|
||||
annotations: map[string]string{
|
||||
targetAnnotationKey: "gateway-target.com",
|
||||
ttlAnnotationKey: "10s",
|
||||
@ -973,7 +958,7 @@ func testGatewayEndpoints(t *testing.T) {
|
||||
configItems: []fakeGatewayConfig{
|
||||
{
|
||||
name: "fake1",
|
||||
namespace: namespace,
|
||||
namespace: "",
|
||||
annotations: map[string]string{
|
||||
targetAnnotationKey: "gateway-target.com",
|
||||
},
|
||||
@ -981,7 +966,7 @@ func testGatewayEndpoints(t *testing.T) {
|
||||
},
|
||||
{
|
||||
name: "fake2",
|
||||
namespace: namespace,
|
||||
namespace: "",
|
||||
annotations: map[string]string{
|
||||
targetAnnotationKey: "gateway-target.com",
|
||||
},
|
||||
@ -989,7 +974,7 @@ func testGatewayEndpoints(t *testing.T) {
|
||||
},
|
||||
{
|
||||
name: "fake3",
|
||||
namespace: namespace,
|
||||
namespace: "",
|
||||
annotations: map[string]string{
|
||||
targetAnnotationKey: "1.2.3.4",
|
||||
},
|
||||
@ -1027,7 +1012,7 @@ func testGatewayEndpoints(t *testing.T) {
|
||||
configItems: []fakeGatewayConfig{
|
||||
{
|
||||
name: "fake1",
|
||||
namespace: namespace,
|
||||
namespace: "",
|
||||
annotations: map[string]string{
|
||||
targetAnnotationKey: "",
|
||||
},
|
||||
@ -1049,7 +1034,7 @@ func testGatewayEndpoints(t *testing.T) {
|
||||
configItems: []fakeGatewayConfig{
|
||||
{
|
||||
name: "fake1",
|
||||
namespace: namespace,
|
||||
namespace: "",
|
||||
annotations: map[string]string{
|
||||
hostnameAnnotationKey: "ignore.me",
|
||||
},
|
||||
@ -1057,7 +1042,7 @@ func testGatewayEndpoints(t *testing.T) {
|
||||
},
|
||||
{
|
||||
name: "fake2",
|
||||
namespace: namespace,
|
||||
namespace: "",
|
||||
annotations: map[string]string{
|
||||
hostnameAnnotationKey: "ignore.me.too",
|
||||
},
|
||||
@ -1086,10 +1071,6 @@ func testGatewayEndpoints(t *testing.T) {
|
||||
},
|
||||
} {
|
||||
t.Run(ti.title, func(t *testing.T) {
|
||||
configs := make([]istiomodel.Config, 0)
|
||||
for _, item := range ti.configItems {
|
||||
configs = append(configs, item.Config())
|
||||
}
|
||||
|
||||
fakeKubernetesClient := fake.NewSimpleClientset()
|
||||
|
||||
@ -1100,8 +1081,9 @@ func testGatewayEndpoints(t *testing.T) {
|
||||
}
|
||||
|
||||
fakeIstioClient := NewFakeConfigStore()
|
||||
for _, config := range configs {
|
||||
_, err := fakeIstioClient.Create(config)
|
||||
for _, config := range ti.configItems {
|
||||
gatewayCfg := config.Config()
|
||||
_, err := fakeIstioClient.NetworkingV1alpha3().Gateways(ti.targetNamespace).Create(gatewayCfg)
|
||||
require.NoError(t, err)
|
||||
}
|
||||
|
||||
@ -1204,137 +1186,31 @@ type fakeGatewayConfig struct {
|
||||
selector map[string]string
|
||||
}
|
||||
|
||||
func (c fakeGatewayConfig) Config() istiomodel.Config {
|
||||
gw := &istionetworking.Gateway{
|
||||
Servers: []*istionetworking.Server{},
|
||||
func (c fakeGatewayConfig) Config() *networkingv1alpha3.Gateway {
|
||||
gw := networkingv1alpha3.Gateway{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: c.name,
|
||||
Namespace: c.namespace,
|
||||
Annotations: c.annotations,
|
||||
},
|
||||
Spec: networkingv1alpha3api.Gateway{
|
||||
Servers: nil,
|
||||
Selector: c.selector,
|
||||
},
|
||||
}
|
||||
|
||||
var servers []*networkingv1alpha3api.Server
|
||||
for _, dnsnames := range c.dnsnames {
|
||||
gw.Servers = append(gw.Servers, &istionetworking.Server{
|
||||
servers = append(servers, &networkingv1alpha3api.Server{
|
||||
Hosts: dnsnames,
|
||||
})
|
||||
}
|
||||
|
||||
gw.Selector = c.selector
|
||||
gw.Spec.Servers = servers
|
||||
|
||||
config := istiomodel.Config{
|
||||
ConfigMeta: istiomodel.ConfigMeta{
|
||||
Namespace: c.namespace,
|
||||
Name: c.name,
|
||||
Type: gatewayType,
|
||||
Annotations: c.annotations,
|
||||
},
|
||||
Spec: gw,
|
||||
}
|
||||
|
||||
return config
|
||||
return &gw
|
||||
}
|
||||
|
||||
type fakeConfigStore struct {
|
||||
descriptor istiomodel.ConfigDescriptor
|
||||
configs []*istiomodel.Config
|
||||
sync.RWMutex
|
||||
}
|
||||
|
||||
func NewFakeConfigStore() istiomodel.ConfigStore {
|
||||
return &fakeConfigStore{
|
||||
descriptor: istiomodel.ConfigDescriptor{
|
||||
istiomodel.Gateway,
|
||||
},
|
||||
configs: make([]*istiomodel.Config, 0),
|
||||
}
|
||||
}
|
||||
|
||||
func (f *fakeConfigStore) ConfigDescriptor() istiomodel.ConfigDescriptor {
|
||||
return f.descriptor
|
||||
}
|
||||
|
||||
func (f *fakeConfigStore) Get(typ, name, namespace string) (config *istiomodel.Config) {
|
||||
f.RLock()
|
||||
defer f.RUnlock()
|
||||
|
||||
if cfg, _ := f.get(typ, name, namespace); cfg != nil {
|
||||
config = cfg
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
func (f *fakeConfigStore) get(typ, name, namespace string) (*istiomodel.Config, int) {
|
||||
for idx, cfg := range f.configs {
|
||||
if cfg.Type == typ && cfg.Name == name && cfg.Namespace == namespace {
|
||||
return cfg, idx
|
||||
}
|
||||
}
|
||||
|
||||
return nil, -1
|
||||
}
|
||||
|
||||
func (f *fakeConfigStore) List(typ, namespace string) (configs []istiomodel.Config, err error) {
|
||||
f.RLock()
|
||||
defer f.RUnlock()
|
||||
|
||||
if namespace == "" {
|
||||
for _, cfg := range f.configs {
|
||||
configs = append(configs, *cfg)
|
||||
}
|
||||
} else {
|
||||
for _, cfg := range f.configs {
|
||||
if cfg.Type == typ && cfg.Namespace == namespace {
|
||||
configs = append(configs, *cfg)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
func (f *fakeConfigStore) Create(config istiomodel.Config) (revision string, err error) {
|
||||
f.Lock()
|
||||
defer f.Unlock()
|
||||
|
||||
if cfg, _ := f.get(config.Type, config.Name, config.Namespace); cfg != nil {
|
||||
err = errors.New("config already exists")
|
||||
} else {
|
||||
revision = "0"
|
||||
cfg := &config
|
||||
cfg.ResourceVersion = revision
|
||||
f.configs = append(f.configs, cfg)
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
func (f *fakeConfigStore) Update(config istiomodel.Config) (newRevision string, err error) {
|
||||
f.Lock()
|
||||
defer f.Unlock()
|
||||
|
||||
if oldCfg, idx := f.get(config.Type, config.Name, config.Namespace); oldCfg == nil {
|
||||
err = errors.New("config does not exist")
|
||||
} else if oldRevision, e := strconv.Atoi(oldCfg.ResourceVersion); e != nil {
|
||||
err = e
|
||||
} else {
|
||||
newRevision = strconv.Itoa(oldRevision + 1)
|
||||
cfg := &config
|
||||
cfg.ResourceVersion = newRevision
|
||||
f.configs[idx] = cfg
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
func (f *fakeConfigStore) Delete(typ, name, namespace string) error {
|
||||
f.Lock()
|
||||
defer f.Unlock()
|
||||
|
||||
_, idx := f.get(typ, name, namespace)
|
||||
if idx < 0 {
|
||||
return errors.New("config does not exist")
|
||||
}
|
||||
|
||||
copy(f.configs[idx:], f.configs[idx+1:])
|
||||
f.configs[len(f.configs)-1] = nil
|
||||
f.configs = f.configs[:len(f.configs)-1]
|
||||
|
||||
return nil
|
||||
func NewFakeConfigStore() istioclient.Interface {
|
||||
return istiofake.NewSimpleClientset()
|
||||
}
|
||||
|
@ -62,7 +62,7 @@ func (suite *IngressSuite) SetupTest() {
|
||||
hostnames: []string{"v1"},
|
||||
annotations: map[string]string{ALBDualstackAnnotationKey: ALBDualstackAnnotationValue},
|
||||
}).Ingress()
|
||||
_, err = fakeClient.Extensions().Ingresses(suite.fooWithTargets.Namespace).Create(suite.fooWithTargets)
|
||||
_, err = fakeClient.ExtensionsV1beta1().Ingresses(suite.fooWithTargets.Namespace).Create(suite.fooWithTargets)
|
||||
suite.NoError(err, "should succeed")
|
||||
}
|
||||
|
||||
@ -1009,7 +1009,7 @@ func testIngressEndpoints(t *testing.T) {
|
||||
ti.ignoreHostnameAnnotation,
|
||||
)
|
||||
for _, ingress := range ingresses {
|
||||
_, err := fakeClient.Extensions().Ingresses(ingress.Namespace).Create(ingress)
|
||||
_, err := fakeClient.ExtensionsV1beta1().Ingresses(ingress.Namespace).Create(ingress)
|
||||
require.NoError(t, err)
|
||||
}
|
||||
|
||||
|
@ -1551,7 +1551,7 @@ func TestNodePortServices(t *testing.T) {
|
||||
|
||||
// Create the nodes
|
||||
for _, node := range tc.nodes {
|
||||
if _, err := kubernetes.Core().Nodes().Create(node); err != nil {
|
||||
if _, err := kubernetes.CoreV1().Nodes().Create(node); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
@ -17,7 +17,6 @@ limitations under the License.
|
||||
package source
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"net/http"
|
||||
"os"
|
||||
"strings"
|
||||
@ -27,9 +26,9 @@ import (
|
||||
"github.com/cloudfoundry-community/go-cfclient"
|
||||
"github.com/linki/instrumented_http"
|
||||
openshift "github.com/openshift/client-go/route/clientset/versioned"
|
||||
"github.com/pkg/errors"
|
||||
log "github.com/sirupsen/logrus"
|
||||
istiocontroller "istio.io/istio/pilot/pkg/config/kube/crd/controller"
|
||||
istiomodel "istio.io/istio/pilot/pkg/model"
|
||||
istioclient "istio.io/client-go/pkg/clientset/versioned"
|
||||
"k8s.io/client-go/dynamic"
|
||||
"k8s.io/client-go/kubernetes"
|
||||
"k8s.io/client-go/rest"
|
||||
@ -68,7 +67,7 @@ type Config struct {
|
||||
// ClientGenerator provides clients
|
||||
type ClientGenerator interface {
|
||||
KubeClient() (kubernetes.Interface, error)
|
||||
IstioClient() (istiomodel.ConfigStore, error)
|
||||
IstioClient() (istioclient.Interface, error)
|
||||
CloudFoundryClient(cfAPPEndpoint string, cfUsername string, cfPassword string) (*cfclient.Client, error)
|
||||
DynamicKubernetesClient() (dynamic.Interface, error)
|
||||
OpenShiftClient() (openshift.Interface, error)
|
||||
@ -81,7 +80,7 @@ type SingletonClientGenerator struct {
|
||||
KubeMaster string
|
||||
RequestTimeout time.Duration
|
||||
kubeClient kubernetes.Interface
|
||||
istioClient istiomodel.ConfigStore
|
||||
istioClient *istioclient.Clientset
|
||||
cfClient *cfclient.Client
|
||||
contourClient dynamic.Interface
|
||||
openshiftClient openshift.Interface
|
||||
@ -101,11 +100,11 @@ func (p *SingletonClientGenerator) KubeClient() (kubernetes.Interface, error) {
|
||||
return p.kubeClient, err
|
||||
}
|
||||
|
||||
// IstioClient generates an istio client if it was not created before
|
||||
func (p *SingletonClientGenerator) IstioClient() (istiomodel.ConfigStore, error) {
|
||||
// IstioClient generates an istio go client if it was not created before
|
||||
func (p *SingletonClientGenerator) IstioClient() (istioclient.Interface, error) {
|
||||
var err error
|
||||
p.istioOnce.Do(func() {
|
||||
p.istioClient, err = NewIstioClient(p.KubeConfig)
|
||||
p.istioClient, err = NewIstioClient(p.KubeConfig, p.KubeMaster)
|
||||
})
|
||||
return p.istioClient, err
|
||||
}
|
||||
@ -316,26 +315,24 @@ func NewKubeClient(kubeConfig, kubeMaster string, requestTimeout time.Duration)
|
||||
// wrappers) to the client's config at this level. Furthermore, the Istio client
|
||||
// constructor does not expose the ability to override the Kubernetes master,
|
||||
// so the Master config attribute has no effect.
|
||||
func NewIstioClient(kubeConfig string) (*istiocontroller.Client, error) {
|
||||
func NewIstioClient(kubeConfig string, kubeMaster string) (*istioclient.Clientset, error) {
|
||||
if kubeConfig == "" {
|
||||
if _, err := os.Stat(clientcmd.RecommendedHomeFile); err == nil {
|
||||
kubeConfig = clientcmd.RecommendedHomeFile
|
||||
}
|
||||
}
|
||||
|
||||
client, err := istiocontroller.NewClient(
|
||||
kubeConfig,
|
||||
"",
|
||||
istiomodel.ConfigDescriptor{istiomodel.Gateway},
|
||||
"",
|
||||
)
|
||||
restCfg, err := clientcmd.BuildConfigFromFlags(kubeMaster, kubeConfig)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
log.Info("Created Istio client")
|
||||
ic, err := istioclient.NewForConfig(restCfg)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "Failed to create istio client")
|
||||
}
|
||||
|
||||
return client, nil
|
||||
return ic, nil
|
||||
}
|
||||
|
||||
// NewDynamicKubernetesClient returns a new Dynamic Kubernetes client object. It takes a Config and
|
||||
|
@ -24,7 +24,7 @@ import (
|
||||
openshift "github.com/openshift/client-go/route/clientset/versioned"
|
||||
"github.com/stretchr/testify/mock"
|
||||
"github.com/stretchr/testify/suite"
|
||||
istiomodel "istio.io/istio/pilot/pkg/model"
|
||||
istioclient "istio.io/client-go/pkg/clientset/versioned"
|
||||
"k8s.io/client-go/dynamic"
|
||||
"k8s.io/client-go/kubernetes"
|
||||
fakeKube "k8s.io/client-go/kubernetes/fake"
|
||||
@ -33,7 +33,7 @@ import (
|
||||
type MockClientGenerator struct {
|
||||
mock.Mock
|
||||
kubeClient kubernetes.Interface
|
||||
istioClient istiomodel.ConfigStore
|
||||
istioClient istioclient.Interface
|
||||
cloudFoundryClient *cfclient.Client
|
||||
dynamicKubernetesClient dynamic.Interface
|
||||
openshiftClient openshift.Interface
|
||||
@ -48,10 +48,10 @@ func (m *MockClientGenerator) KubeClient() (kubernetes.Interface, error) {
|
||||
return nil, args.Error(1)
|
||||
}
|
||||
|
||||
func (m *MockClientGenerator) IstioClient() (istiomodel.ConfigStore, error) {
|
||||
func (m *MockClientGenerator) IstioClient() (istioclient.Interface, error) {
|
||||
args := m.Called()
|
||||
if args.Error(1) == nil {
|
||||
m.istioClient = args.Get(0).(istiomodel.ConfigStore)
|
||||
m.istioClient = args.Get(0).(istioclient.Interface)
|
||||
return m.istioClient, nil
|
||||
}
|
||||
return nil, args.Error(1)
|
||||
|
Loading…
Reference in New Issue
Block a user