Skip to content

Commit

Permalink
chore: integrate api7/types. (#134)
Browse files Browse the repository at this point in the history
  • Loading branch information
tokers committed Dec 29, 2020
1 parent ad0348c commit 782730a
Show file tree
Hide file tree
Showing 30 changed files with 495 additions and 49 deletions.
3 changes: 3 additions & 0 deletions .actions/ASF-Release.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ ASFLicenseHeaderMarkdown.txt
.pydevproject
.rat-excludes
.tox
# zz_generated.deepcopy.go is generated by tool, which has different license
# header format.
zz_generated.deepcopy.go

# Exclude Apache standard legal files
CREDITS.txt
Expand Down
1 change: 0 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ require (
github.com/gogo/protobuf v1.3.1 // indirect
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b
github.com/gxthrj/apisix-ingress-types v0.1.3
github.com/gxthrj/apisix-types v0.1.3
github.com/hashicorp/go-memdb v1.0.4
github.com/k0kubun/colorstring v0.0.0-20150214042306-9440f1994b88 // indirect
github.com/mattn/go-colorable v0.1.4 // indirect
Expand Down
2 changes: 0 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuy
github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
github.com/api7/ingress-types v0.1.3 h1:euvLySusNeOjzOjnpZl+J3Ve5ZcWoby/lm3lPmH4xTI=
github.com/api7/ingress-types v0.1.3/go.mod h1:xWuHLSHGN4/JZjz9b0ftKgtE3yZ7NehkJAiTyZ+KoPA=
github.com/api7/types v0.1.3 h1:AuDAM1a5N+b7ovBduomIVMXlGlPa6EDCSj7XZon0AzY=
github.com/api7/types v0.1.3/go.mod h1:STdHATWxqIeJhUEXt6dZTd6z0To0qO70K/1mnfBtlC0=
github.com/armon/circbuf v0.0.0-20150827004946-bbbad097214e/go.mod h1:3U/XgcO3hCbHZ8TKRvWD2dDTCfh9M9ya+I9JpbB7O8o=
github.com/armon/go-metrics v0.0.0-20180917152333-f0300d1749da/go.mod h1:Q73ZrmVTwzkszR9V5SSuryQ31EELlFMUz1kKyl939pY=
github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8=
Expand Down
3 changes: 1 addition & 2 deletions pkg/ingress/apisix/annotation.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,8 @@ package apisix
import (
"strconv"

apisix "github.com/gxthrj/apisix-types/pkg/apis/apisix/v1"

seven "github.com/api7/ingress-controller/pkg/seven/apisix"
apisix "github.com/api7/ingress-controller/pkg/types/apisix/v1"
)

// BuildAnnotation return plugins and group
Expand Down
2 changes: 1 addition & 1 deletion pkg/ingress/apisix/route.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ import (
"strconv"

ingress "github.com/gxthrj/apisix-ingress-types/pkg/apis/config/v1"
apisix "github.com/gxthrj/apisix-types/pkg/apis/apisix/v1"

"github.com/api7/ingress-controller/pkg/ingress/endpoint"
"github.com/api7/ingress-controller/pkg/seven/conf"
apisix "github.com/api7/ingress-controller/pkg/types/apisix/v1"
)

const (
Expand Down
2 changes: 1 addition & 1 deletion pkg/ingress/apisix/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ import (
"strconv"

ingress "github.com/gxthrj/apisix-ingress-types/pkg/apis/config/v1"
apisix "github.com/gxthrj/apisix-types/pkg/apis/apisix/v1"

"github.com/api7/ingress-controller/pkg/ingress/endpoint"
"github.com/api7/ingress-controller/pkg/seven/conf"
apisix "github.com/api7/ingress-controller/pkg/types/apisix/v1"
)

const (
Expand Down
4 changes: 2 additions & 2 deletions pkg/ingress/apisix/tls.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ package apisix

import (
ingress "github.com/gxthrj/apisix-ingress-types/pkg/apis/config/v1"
apisix "github.com/gxthrj/apisix-types/pkg/apis/apisix/v1"
"k8s.io/api/core/v1"
v1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

ingressConf "github.com/api7/ingress-controller/pkg/kube"
"github.com/api7/ingress-controller/pkg/seven/conf"
apisix "github.com/api7/ingress-controller/pkg/types/apisix/v1"
)

const (
Expand Down
9 changes: 5 additions & 4 deletions pkg/ingress/apisix/tls_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,11 @@ import (
"fmt"
"testing"

a6Type "github.com/gxthrj/apisix-types/pkg/apis/apisix/v1"
"github.com/stretchr/testify/assert"
"gopkg.in/yaml.v2"
"k8s.io/api/core/v1"
v1 "k8s.io/api/core/v1"

apisix "github.com/api7/ingress-controller/pkg/types/apisix/v1"
)

func TestConvert(t *testing.T) {
Expand All @@ -46,7 +47,7 @@ spec:
cert := "root"
key := "123456"
group := ""
sslExpect := &a6Type.Ssl{
sslExpect := &apisix.Ssl{
ID: &id,
Snis: snis,
Cert: &cert,
Expand Down Expand Up @@ -89,7 +90,7 @@ spec:
cert := "root"
key := "123456"
group := "127.0.0.1:9080"
sslExpect := &a6Type.Ssl{
sslExpect := &apisix.Ssl{
ID: &id,
Snis: snis,
Cert: &cert,
Expand Down
2 changes: 1 addition & 1 deletion pkg/ingress/apisix/upstream.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ import (
"strconv"

ingress "github.com/gxthrj/apisix-ingress-types/pkg/apis/config/v1"
apisix "github.com/gxthrj/apisix-types/pkg/apis/apisix/v1"

"github.com/api7/ingress-controller/pkg/ingress/endpoint"
"github.com/api7/ingress-controller/pkg/seven/conf"
apisix "github.com/api7/ingress-controller/pkg/types/apisix/v1"
)

const (
Expand Down
3 changes: 2 additions & 1 deletion pkg/ingress/apisix/upstream_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,10 @@ import (
"testing"

ingress "github.com/gxthrj/apisix-ingress-types/pkg/apis/config/v1"
"github.com/gxthrj/apisix-types/pkg/apis/apisix/v1"
"github.com/stretchr/testify/assert"
"gopkg.in/yaml.v2"

v1 "github.com/api7/ingress-controller/pkg/types/apisix/v1"
)

func TestApisixUpstreamCRD_Convert(t *testing.T) {
Expand Down
7 changes: 4 additions & 3 deletions pkg/ingress/controller/apisix_route.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,24 +16,25 @@ package controller

import (
"fmt"
"time"

api6V1 "github.com/gxthrj/apisix-ingress-types/pkg/apis/config/v1"
clientSet "github.com/gxthrj/apisix-ingress-types/pkg/client/clientset/versioned"
api6Scheme "github.com/gxthrj/apisix-ingress-types/pkg/client/clientset/versioned/scheme"
api6Informers "github.com/gxthrj/apisix-ingress-types/pkg/client/informers/externalversions/config/v1"
"github.com/gxthrj/apisix-ingress-types/pkg/client/listers/config/v1"
apisixV1 "github.com/gxthrj/apisix-types/pkg/apis/apisix/v1"
v1 "github.com/gxthrj/apisix-ingress-types/pkg/client/listers/config/v1"
"k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/util/runtime"
"k8s.io/apimachinery/pkg/util/wait"
"k8s.io/client-go/kubernetes"
"k8s.io/client-go/kubernetes/scheme"
"k8s.io/client-go/tools/cache"
"k8s.io/client-go/util/workqueue"
"time"

"github.com/api7/ingress-controller/pkg/ingress/apisix"
"github.com/api7/ingress-controller/pkg/log"
"github.com/api7/ingress-controller/pkg/seven/state"
apisixV1 "github.com/api7/ingress-controller/pkg/types/apisix/v1"
)

type ApisixRouteController struct {
Expand Down
19 changes: 10 additions & 9 deletions pkg/ingress/controller/endpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@ package controller

import (
"fmt"
"strconv"
"time"

"github.com/golang/glog"
apisixType "github.com/gxthrj/apisix-types/pkg/apis/apisix/v1"
CoreV1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/util/runtime"
Expand All @@ -26,14 +28,13 @@ import (
CoreListerV1 "k8s.io/client-go/listers/core/v1"
"k8s.io/client-go/tools/cache"
"k8s.io/client-go/util/workqueue"
"strconv"
"time"

"github.com/api7/ingress-controller/pkg/kube"
"github.com/api7/ingress-controller/pkg/log"
"github.com/api7/ingress-controller/pkg/seven/apisix"
sevenConf "github.com/api7/ingress-controller/pkg/seven/conf"
"github.com/api7/ingress-controller/pkg/seven/state"
apisixv1 "github.com/api7/ingress-controller/pkg/types/apisix/v1"
)

type EndpointController struct {
Expand Down Expand Up @@ -150,12 +151,12 @@ func (c *EndpointController) process(ep *CoreV1.Endpoints) {
//if err == nil {
// for _, upstream := range upstreams {
// if *(upstream.Name) == upstreamName {
// nodes := make([]*apisixType.Node, 0)
// nodes := make([]*apisixv1.Node, 0)
// for _, ip := range ips {
// ipAddress := ip
// p := int(port.Port)
// weight := 100
// node := &apisixType.Node{IP: &ipAddress, Port: &p, Weight: &weight}
// node := &apisixv1.Node{IP: &ipAddress, Port: &p, Weight: &weight}
// nodes = append(nodes, node)
// }
// upstream.Nodes = nodes
Expand All @@ -164,7 +165,7 @@ func (c *EndpointController) process(ep *CoreV1.Endpoints) {
// //apisix.UpdateUpstream(upstream)
// fromKind := WatchFromKind
// upstream.FromKind = &fromKind
// upstreams := []*apisixType.Upstream{upstream}
// upstreams := []*apisixv1.Upstream{upstream}
// comb := state.ApisixCombination{Routes: nil, Services: nil, Upstreams: upstreams}
// if _, err = comb.Solver(); err != nil {
// glog.Errorf(err.Error())
Expand All @@ -183,12 +184,12 @@ func syncWithGroup(group, upstreamName string, ips []string, port CoreV1.Endpoin
if err == nil {
for _, upstream := range upstreams {
if *(upstream.Name) == upstreamName {
nodes := make([]*apisixType.Node, 0)
nodes := make([]*apisixv1.Node, 0)
for _, ip := range ips {
ipAddress := ip
p := int(port.Port)
weight := 100
node := &apisixType.Node{IP: &ipAddress, Port: &p, Weight: &weight}
node := &apisixv1.Node{IP: &ipAddress, Port: &p, Weight: &weight}
nodes = append(nodes, node)
}
upstream.Nodes = nodes
Expand All @@ -197,7 +198,7 @@ func syncWithGroup(group, upstreamName string, ips []string, port CoreV1.Endpoin
//apisix.UpdateUpstream(upstream)
fromKind := WatchFromKind
upstream.FromKind = &fromKind
upstreams := []*apisixType.Upstream{upstream}
upstreams := []*apisixv1.Upstream{upstream}
comb := state.ApisixCombination{Routes: nil, Services: nil, Upstreams: upstreams}
if _, err = comb.Solver(); err != nil {
glog.Errorf(err.Error())
Expand Down
10 changes: 5 additions & 5 deletions pkg/ingress/controller/watch.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ import (

"github.com/api7/ingress-controller/pkg/kube"
"github.com/golang/glog"
apisixType "github.com/gxthrj/apisix-types/pkg/apis/apisix/v1"
"k8s.io/api/core/v1"
v1 "k8s.io/api/core/v1"

"github.com/api7/ingress-controller/pkg/seven/apisix"
sevenConf "github.com/api7/ingress-controller/pkg/seven/conf"
"github.com/api7/ingress-controller/pkg/seven/state"
apisixv1 "github.com/api7/ingress-controller/pkg/types/apisix/v1"
)

const (
Expand Down Expand Up @@ -75,12 +75,12 @@ func (c *controller) process(obj interface{}) {
if err == nil {
for _, upstream := range upstreams {
if *(upstream.Name) == upstreamName {
nodes := make([]*apisixType.Node, 0)
nodes := make([]*apisixv1.Node, 0)
for _, ip := range ips {
ipAddress := ip
p := int(port.Port)
weight := 100
node := &apisixType.Node{IP: &ipAddress, Port: &p, Weight: &weight}
node := &apisixv1.Node{IP: &ipAddress, Port: &p, Weight: &weight}
nodes = append(nodes, node)
}
upstream.Nodes = nodes
Expand All @@ -89,7 +89,7 @@ func (c *controller) process(obj interface{}) {
//apisix.UpdateUpstream(upstream)
fromKind := WatchFromKind
upstream.FromKind = &fromKind
upstreams := []*apisixType.Upstream{upstream}
upstreams := []*apisixv1.Upstream{upstream}
comb := state.ApisixCombination{Routes: nil, Services: nil, Upstreams: upstreams}
if _, err = comb.Solver(); err != nil {
glog.Errorf(err.Error())
Expand Down
5 changes: 3 additions & 2 deletions pkg/ingress/endpoint/ep.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@
package endpoint

import (
"github.com/api7/ingress-controller/pkg/kube"
"github.com/golang/glog"
"github.com/gxthrj/apisix-types/pkg/apis/apisix/v1"

"github.com/api7/ingress-controller/pkg/kube"
v1 "github.com/api7/ingress-controller/pkg/types/apisix/v1"
)

type Endpoint interface {
Expand Down
3 changes: 1 addition & 2 deletions pkg/seven/apisix/route.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,10 @@ import (
"fmt"
"strings"

"github.com/gxthrj/apisix-types/pkg/apis/apisix/v1"

"github.com/api7/ingress-controller/pkg/seven/conf"
sevendb "github.com/api7/ingress-controller/pkg/seven/db"
"github.com/api7/ingress-controller/pkg/seven/utils"
v1 "github.com/api7/ingress-controller/pkg/types/apisix/v1"
)

// FindCurrentRoute find current route in memDB
Expand Down
2 changes: 1 addition & 1 deletion pkg/seven/apisix/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ import (
"strings"

"github.com/golang/glog"
"github.com/gxthrj/apisix-types/pkg/apis/apisix/v1"

"github.com/api7/ingress-controller/pkg/seven/conf"
sevendb "github.com/api7/ingress-controller/pkg/seven/db"
"github.com/api7/ingress-controller/pkg/seven/utils"
v1 "github.com/api7/ingress-controller/pkg/types/apisix/v1"
)

// FindCurrentService find service from memDB,
Expand Down
2 changes: 1 addition & 1 deletion pkg/seven/apisix/ssl.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ import (
"strings"

"github.com/golang/glog"
"github.com/gxthrj/apisix-types/pkg/apis/apisix/v1"

"github.com/api7/ingress-controller/pkg/seven/conf"
"github.com/api7/ingress-controller/pkg/seven/utils"
v1 "github.com/api7/ingress-controller/pkg/types/apisix/v1"
)

// ListSsl list ssl from etcd , convert to v1.Upstream
Expand Down
2 changes: 1 addition & 1 deletion pkg/seven/apisix/upstream.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ import (
"strings"

"github.com/golang/glog"
"github.com/gxthrj/apisix-types/pkg/apis/apisix/v1"

"github.com/api7/ingress-controller/pkg/seven/conf"
"github.com/api7/ingress-controller/pkg/seven/db"
"github.com/api7/ingress-controller/pkg/seven/utils"
v1 "github.com/api7/ingress-controller/pkg/types/apisix/v1"
)

// FindCurrentUpstream find upstream from memDB,
Expand Down
3 changes: 2 additions & 1 deletion pkg/seven/db/route.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@ package db
import (
"fmt"

"github.com/gxthrj/apisix-types/pkg/apis/apisix/v1"
"github.com/hashicorp/go-memdb"

v1 "github.com/api7/ingress-controller/pkg/types/apisix/v1"
)

const (
Expand Down
3 changes: 2 additions & 1 deletion pkg/seven/db/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@ package db
import (
"fmt"

"github.com/gxthrj/apisix-types/pkg/apis/apisix/v1"
"github.com/hashicorp/go-memdb"

v1 "github.com/api7/ingress-controller/pkg/types/apisix/v1"
)

const (
Expand Down
4 changes: 3 additions & 1 deletion pkg/seven/db/upstream.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@ package db

import (
"fmt"
"github.com/gxthrj/apisix-types/pkg/apis/apisix/v1"

"github.com/hashicorp/go-memdb"

v1 "github.com/api7/ingress-controller/pkg/types/apisix/v1"
)

const (
Expand Down
2 changes: 1 addition & 1 deletion pkg/seven/state/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ import (
"strings"

"github.com/golang/glog"
"github.com/gxthrj/apisix-types/pkg/apis/apisix/v1"

"github.com/api7/ingress-controller/pkg/seven/apisix"
"github.com/api7/ingress-controller/pkg/seven/db"
"github.com/api7/ingress-controller/pkg/seven/utils"
v1 "github.com/api7/ingress-controller/pkg/types/apisix/v1"
)

const (
Expand Down
2 changes: 1 addition & 1 deletion pkg/seven/state/event.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
package state

import (
"github.com/gxthrj/apisix-types/pkg/apis/apisix/v1"
v1 "github.com/api7/ingress-controller/pkg/types/apisix/v1"
)

type ApisixCombination struct {
Expand Down
Loading

0 comments on commit 782730a

Please sign in to comment.