Skip to content

Commit

Permalink
update to latest version of istio-api repo (istio#1898)
Browse files Browse the repository at this point in the history
* update to latest refactoring of istio-api repo

* proxyconfig->routing

* update gopkg for circleci
  • Loading branch information
ZackButcher authored and rshriram committed Nov 29, 2017
1 parent b3d6fa1 commit a1ba1fb
Show file tree
Hide file tree
Showing 56 changed files with 663 additions and 651 deletions.
2 changes: 1 addition & 1 deletion Gopkg.toml
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
### as we cache dep ensure.
[[constraint]]
name = "istio.io/api"
revision = "9f333d0643ba30f18dbc43bc08e0604e9371fe76"
revision = "cda38551dd4b693d703cae0e72b649a293550aba"

[[constraint]]
name = "istio.io/fortio"
Expand Down
2 changes: 1 addition & 1 deletion istio_api.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
################################################################################
#

ISTIO_API_SHA = "80e750910cd1a63367153b30e2a047973b68e5f0"
ISTIO_API_SHA = "cda38551dd4b693d703cae0e72b649a293550aba"

def go_istio_api_repositories(use_local=False):
if use_local:
Expand Down
5 changes: 3 additions & 2 deletions pilot/adapter/config/ingress/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ go_library(
"//pilot/platform/kube:go_default_library",
"@com_github_golang_glog//:go_default_library",
"@com_github_hashicorp_go_multierror//:go_default_library",
"@io_istio_api//proxy/v1/config:go_default_library",
"@io_istio_api//mesh/v1alpha1:go_default_library",
"@io_istio_api//routing/v1alpha1:go_default_library",
"@io_k8s_api//core/v1:go_default_library",
"@io_k8s_api//extensions/v1beta1:go_default_library",
"@io_k8s_apimachinery//pkg/apis/meta/v1:go_default_library",
Expand Down Expand Up @@ -43,7 +44,7 @@ go_test(
"//pilot/test/mock:go_default_library",
"//pilot/test/util:go_default_library",
"@com_github_golang_glog//:go_default_library",
"@io_istio_api//proxy/v1/config:go_default_library",
"@io_istio_api//routing/v1alpha1:go_default_library",
"@io_k8s_api//core/v1:go_default_library",
"@io_k8s_api//extensions/v1beta1:go_default_library",
"@io_k8s_apimachinery//pkg/apis/meta/v1:go_default_library",
Expand Down
6 changes: 3 additions & 3 deletions pilot/adapter/config/ingress/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@ import (
"k8s.io/client-go/kubernetes"
"k8s.io/client-go/tools/cache"

proxyconfig "istio.io/api/proxy/v1/config"
meshconfig "istio.io/api/mesh/v1alpha1"
"istio.io/istio/pilot/model"
"istio.io/istio/pilot/platform/kube"
)

type controller struct {
mesh *proxyconfig.MeshConfig
mesh *meshconfig.MeshConfig
domainSuffix string

client kubernetes.Interface
Expand All @@ -49,7 +49,7 @@ var (
)

// NewController creates a new Kubernetes controller
func NewController(client kubernetes.Interface, mesh *proxyconfig.MeshConfig,
func NewController(client kubernetes.Interface, mesh *meshconfig.MeshConfig,
options kube.ControllerOptions) model.ConfigStoreCache {
handler := &kube.ChainHandler{}

Expand Down
6 changes: 3 additions & 3 deletions pilot/adapter/config/ingress/controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (
"k8s.io/apimachinery/pkg/util/intstr"
"k8s.io/client-go/kubernetes/fake"

proxyconfig "istio.io/api/proxy/v1/config"
routing "istio.io/api/routing/v1alpha1"
"istio.io/istio/pilot/model"
"istio.io/istio/pilot/platform/kube"
"istio.io/istio/pilot/proxy"
Expand Down Expand Up @@ -221,12 +221,12 @@ func TestIngressController(t *testing.T) {
if !exists {
t.Errorf("expected IngressRule with key %v to exist", listMsg.Key())
} else {
listRule, ok := listMsg.Spec.(*proxyconfig.IngressRule)
listRule, ok := listMsg.Spec.(*routing.IngressRule)
if !ok {
t.Errorf("expected IngressRule but got %v", listMsg.Spec)
}

getRule, ok := getMsg.Spec.(*proxyconfig.IngressRule)
getRule, ok := getMsg.Spec.(*routing.IngressRule)
if !ok {
t.Errorf("expected IngressRule but got %v", getMsg)
}
Expand Down
45 changes: 23 additions & 22 deletions pilot/adapter/config/ingress/conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ import (
"k8s.io/api/extensions/v1beta1"
"k8s.io/apimachinery/pkg/util/intstr"

proxyconfig "istio.io/api/proxy/v1/config"
meshconfig "istio.io/api/mesh/v1alpha1"
routing "istio.io/api/routing/v1alpha1"
"istio.io/istio/pilot/model"
"istio.io/istio/pilot/platform/kube"
)
Expand Down Expand Up @@ -63,53 +64,53 @@ func convertIngress(ingress v1beta1.Ingress, domainSuffix string) []model.Config

func createIngressRule(name, host, path, domainSuffix string,
ingress v1beta1.Ingress, backend v1beta1.IngressBackend, tlsSecret string) model.Config {
rule := &proxyconfig.IngressRule{
Destination: &proxyconfig.IstioService{
rule := &routing.IngressRule{
Destination: &routing.IstioService{
Name: backend.ServiceName,
},
TlsSecret: tlsSecret,
Match: &proxyconfig.MatchCondition{
Request: &proxyconfig.MatchRequest{
Headers: make(map[string]*proxyconfig.StringMatch, 2),
Match: &routing.MatchCondition{
Request: &routing.MatchRequest{
Headers: make(map[string]*routing.StringMatch, 2),
},
},
}
switch backend.ServicePort.Type {
case intstr.Int:
rule.DestinationServicePort = &proxyconfig.IngressRule_DestinationPort{
rule.DestinationServicePort = &routing.IngressRule_DestinationPort{
DestinationPort: int32(backend.ServicePort.IntValue()),
}
case intstr.String:
rule.DestinationServicePort = &proxyconfig.IngressRule_DestinationPortName{
rule.DestinationServicePort = &routing.IngressRule_DestinationPortName{
DestinationPortName: backend.ServicePort.String(),
}
}

if host != "" {
rule.Match.Request.Headers[model.HeaderAuthority] = &proxyconfig.StringMatch{
MatchType: &proxyconfig.StringMatch_Exact{Exact: host},
rule.Match.Request.Headers[model.HeaderAuthority] = &routing.StringMatch{
MatchType: &routing.StringMatch_Exact{Exact: host},
}
}

if path != "" {
if isRegularExpression(path) {
if strings.HasSuffix(path, ".*") && !isRegularExpression(strings.TrimSuffix(path, ".*")) {
rule.Match.Request.Headers[model.HeaderURI] = &proxyconfig.StringMatch{
MatchType: &proxyconfig.StringMatch_Prefix{Prefix: strings.TrimSuffix(path, ".*")},
rule.Match.Request.Headers[model.HeaderURI] = &routing.StringMatch{
MatchType: &routing.StringMatch_Prefix{Prefix: strings.TrimSuffix(path, ".*")},
}
} else {
rule.Match.Request.Headers[model.HeaderURI] = &proxyconfig.StringMatch{
MatchType: &proxyconfig.StringMatch_Regex{Regex: path},
rule.Match.Request.Headers[model.HeaderURI] = &routing.StringMatch{
MatchType: &routing.StringMatch_Regex{Regex: path},
}
}
} else {
rule.Match.Request.Headers[model.HeaderURI] = &proxyconfig.StringMatch{
MatchType: &proxyconfig.StringMatch_Exact{Exact: path},
rule.Match.Request.Headers[model.HeaderURI] = &routing.StringMatch{
MatchType: &routing.StringMatch_Exact{Exact: path},
}
}
} else {
rule.Match.Request.Headers[model.HeaderURI] = &proxyconfig.StringMatch{
MatchType: &proxyconfig.StringMatch_Prefix{Prefix: "/"},
rule.Match.Request.Headers[model.HeaderURI] = &routing.StringMatch{
MatchType: &routing.StringMatch_Prefix{Prefix: "/"},
}
}

Expand Down Expand Up @@ -166,18 +167,18 @@ func isRegularExpression(s string) bool {
// shouldProcessIngress determines whether the given ingress resource should be processed
// by the controller, based on its ingress class annotation.
// See https://github.com/kubernetes/ingress/blob/master/examples/PREREQUISITES.md#ingress-class
func shouldProcessIngress(mesh *proxyconfig.MeshConfig, ingress *v1beta1.Ingress) bool {
func shouldProcessIngress(mesh *meshconfig.MeshConfig, ingress *v1beta1.Ingress) bool {
class, exists := "", false
if ingress.Annotations != nil {
class, exists = ingress.Annotations[kube.IngressClassAnnotation]
}

switch mesh.IngressControllerMode {
case proxyconfig.MeshConfig_OFF:
case meshconfig.MeshConfig_OFF:
return false
case proxyconfig.MeshConfig_STRICT:
case meshconfig.MeshConfig_STRICT:
return exists && class == mesh.IngressClass
case proxyconfig.MeshConfig_DEFAULT:
case meshconfig.MeshConfig_DEFAULT:
return !exists || class == mesh.IngressClass
default:
glog.Warningf("invalid ingress synchronization mode: %v", mesh.IngressControllerMode)
Expand Down
18 changes: 9 additions & 9 deletions pilot/adapter/config/ingress/conversion_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (
meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/intstr"

proxyconfig "istio.io/api/proxy/v1/config"
meshconfig "istio.io/api/mesh/v1alpha1"
"istio.io/istio/pilot/proxy"
)

Expand Down Expand Up @@ -92,17 +92,17 @@ func TestIsRegularExpression(t *testing.T) {
func TestIngressClass(t *testing.T) {
istio := proxy.DefaultMeshConfig().IngressClass
cases := []struct {
ingressMode proxyconfig.MeshConfig_IngressControllerMode
ingressMode meshconfig.MeshConfig_IngressControllerMode
ingressClass string
shouldProcess bool
}{
{ingressMode: proxyconfig.MeshConfig_DEFAULT, ingressClass: "nginx", shouldProcess: false},
{ingressMode: proxyconfig.MeshConfig_STRICT, ingressClass: "nginx", shouldProcess: false},
{ingressMode: proxyconfig.MeshConfig_OFF, ingressClass: istio, shouldProcess: false},
{ingressMode: proxyconfig.MeshConfig_DEFAULT, ingressClass: istio, shouldProcess: true},
{ingressMode: proxyconfig.MeshConfig_STRICT, ingressClass: istio, shouldProcess: true},
{ingressMode: proxyconfig.MeshConfig_DEFAULT, ingressClass: "", shouldProcess: true},
{ingressMode: proxyconfig.MeshConfig_STRICT, ingressClass: "", shouldProcess: false},
{ingressMode: meshconfig.MeshConfig_DEFAULT, ingressClass: "nginx", shouldProcess: false},
{ingressMode: meshconfig.MeshConfig_STRICT, ingressClass: "nginx", shouldProcess: false},
{ingressMode: meshconfig.MeshConfig_OFF, ingressClass: istio, shouldProcess: false},
{ingressMode: meshconfig.MeshConfig_DEFAULT, ingressClass: istio, shouldProcess: true},
{ingressMode: meshconfig.MeshConfig_STRICT, ingressClass: istio, shouldProcess: true},
{ingressMode: meshconfig.MeshConfig_DEFAULT, ingressClass: "", shouldProcess: true},
{ingressMode: meshconfig.MeshConfig_STRICT, ingressClass: "", shouldProcess: false},
{ingressMode: -1, shouldProcess: false},
}

Expand Down
10 changes: 5 additions & 5 deletions pilot/adapter/config/ingress/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import (
"k8s.io/ingress/core/pkg/ingress/status"
"k8s.io/ingress/core/pkg/ingress/store"

proxyconfig "istio.io/api/proxy/v1/config"
meshconfig "istio.io/api/mesh/v1alpha1"
"istio.io/istio/pilot/platform/kube"
)

Expand All @@ -54,7 +54,7 @@ func (s *StatusSyncer) Run(stopCh <-chan struct{}) {
}

// NewStatusSyncer creates a new instance
func NewStatusSyncer(mesh *proxyconfig.MeshConfig,
func NewStatusSyncer(mesh *meshconfig.MeshConfig,
client kubernetes.Interface,
ingressNamespace string,
options kube.ControllerOptions) (*StatusSyncer, error) {
Expand Down Expand Up @@ -107,14 +107,14 @@ func NewStatusSyncer(mesh *proxyconfig.MeshConfig,
// convertIngressControllerMode converts Ingress controller mode into k8s ingress status syncer ingress class and
// default ingress class. Ingress class and default ingress class are used by the syncer to determine whether or not to
// update the IP of a ingress resource.
func convertIngressControllerMode(mode proxyconfig.MeshConfig_IngressControllerMode,
func convertIngressControllerMode(mode meshconfig.MeshConfig_IngressControllerMode,
class string) (string, string) {
var ingressClass, defaultIngressClass string
switch mode {
case proxyconfig.MeshConfig_DEFAULT:
case meshconfig.MeshConfig_DEFAULT:
defaultIngressClass = class
ingressClass = class
case proxyconfig.MeshConfig_STRICT:
case meshconfig.MeshConfig_STRICT:
ingressClass = class
}
return ingressClass, defaultIngressClass
Expand Down
16 changes: 8 additions & 8 deletions pilot/adapter/config/ingress/status_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (
"k8s.io/client-go/kubernetes/fake"
"k8s.io/ingress/core/pkg/ingress/annotations/class"

proxyconfig "istio.io/api/proxy/v1/config"
meshconfig "istio.io/api/mesh/v1alpha1"
"istio.io/istio/pilot/platform/kube"
"istio.io/istio/pilot/proxy"
)
Expand All @@ -49,37 +49,37 @@ func makeAnnotatedIngress(annotation string) *extensions.Ingress {
// representation correctly.
func TestConvertIngressControllerMode(t *testing.T) {
cases := []struct {
Mode proxyconfig.MeshConfig_IngressControllerMode
Mode meshconfig.MeshConfig_IngressControllerMode
Annotation string
Ignore bool
}{
{
Mode: proxyconfig.MeshConfig_DEFAULT,
Mode: meshconfig.MeshConfig_DEFAULT,
Annotation: "",
Ignore: true,
},
{
Mode: proxyconfig.MeshConfig_DEFAULT,
Mode: meshconfig.MeshConfig_DEFAULT,
Annotation: "istio",
Ignore: true,
},
{
Mode: proxyconfig.MeshConfig_DEFAULT,
Mode: meshconfig.MeshConfig_DEFAULT,
Annotation: "nginx",
Ignore: false,
},
{
Mode: proxyconfig.MeshConfig_STRICT,
Mode: meshconfig.MeshConfig_STRICT,
Annotation: "",
Ignore: false,
},
{
Mode: proxyconfig.MeshConfig_STRICT,
Mode: meshconfig.MeshConfig_STRICT,
Annotation: "istio",
Ignore: true,
},
{
Mode: proxyconfig.MeshConfig_STRICT,
Mode: meshconfig.MeshConfig_STRICT,
Annotation: "nginx",
Ignore: false,
},
Expand Down
2 changes: 1 addition & 1 deletion pilot/cmd/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ go_library(
"@com_github_golang_glog//:go_default_library",
"@com_github_hashicorp_go_multierror//:go_default_library",
"@com_github_spf13_cobra//:go_default_library",
"@io_istio_api//proxy/v1/config:go_default_library",
"@io_istio_api//mesh/v1alpha1:go_default_library",
],
)
4 changes: 2 additions & 2 deletions pilot/cmd/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@ import (
multierror "github.com/hashicorp/go-multierror"
"github.com/spf13/cobra"

proxyconfig "istio.io/api/proxy/v1/config"
meshconfig "istio.io/api/mesh/v1alpha1"
"istio.io/istio/pilot/proxy"
"istio.io/istio/pilot/tools/version"
)

// ReadMeshConfig gets mesh configuration from a config file
func ReadMeshConfig(filename string) (*proxyconfig.MeshConfig, error) {
func ReadMeshConfig(filename string) (*meshconfig.MeshConfig, error) {
yaml, err := ioutil.ReadFile(filename)
if err != nil {
return nil, multierror.Prefix(err, "cannot read mesh config file")
Expand Down
2 changes: 1 addition & 1 deletion pilot/cmd/pilot-agent/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ go_library(
"@com_github_golang_protobuf//ptypes:go_default_library",
"@com_github_golang_protobuf//ptypes/duration:go_default_library",
"@com_github_spf13_cobra//:go_default_library",
"@io_istio_api//proxy/v1/config:go_default_library",
"@io_istio_api//mesh/v1alpha1:go_default_library",
],
)

Expand Down
12 changes: 6 additions & 6 deletions pilot/cmd/pilot-agent/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (
"github.com/golang/protobuf/ptypes/duration"
"github.com/spf13/cobra"

proxyconfig "istio.io/api/proxy/v1/config"
meshconfig "istio.io/api/mesh/v1alpha1"
"istio.io/istio/pilot/cmd"
"istio.io/istio/pilot/model"
"istio.io/istio/pilot/platform"
Expand Down Expand Up @@ -108,7 +108,7 @@ var (

glog.V(2).Infof("Proxy role: %#v", role)

proxyConfig := proxyconfig.ProxyConfig{}
proxyConfig := meshconfig.ProxyConfig{}

// set all flags
proxyConfig.CustomConfigFile = customConfigFile
Expand All @@ -127,11 +127,11 @@ var (

var pilotSAN []string
switch controlPlaneAuthPolicy {
case proxyconfig.AuthenticationPolicy_NONE.String():
proxyConfig.ControlPlaneAuthPolicy = proxyconfig.AuthenticationPolicy_NONE
case proxyconfig.AuthenticationPolicy_MUTUAL_TLS.String():
case meshconfig.AuthenticationPolicy_NONE.String():
proxyConfig.ControlPlaneAuthPolicy = meshconfig.AuthenticationPolicy_NONE
case meshconfig.AuthenticationPolicy_MUTUAL_TLS.String():
var ns string
proxyConfig.ControlPlaneAuthPolicy = proxyconfig.AuthenticationPolicy_MUTUAL_TLS
proxyConfig.ControlPlaneAuthPolicy = meshconfig.AuthenticationPolicy_MUTUAL_TLS
if serviceregistry == platform.KubernetesRegistry {
partDiscoveryAddress := strings.Split(discoveryAddress, ":")
discoveryHostname := partDiscoveryAddress[0]
Expand Down
2 changes: 1 addition & 1 deletion pilot/cmd/pilot-discovery/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ go_library(
"@com_github_golang_glog//:go_default_library",
"@com_github_hashicorp_go_multierror//:go_default_library",
"@com_github_spf13_cobra//:go_default_library",
"@io_istio_api//proxy/v1/config:go_default_library",
"@io_istio_api//mesh/v1alpha1:go_default_library",
"@io_k8s_apimachinery//pkg/apis/meta/v1:go_default_library",
],
)
Expand Down
Loading

0 comments on commit a1ba1fb

Please sign in to comment.