Skip to content

Commit

Permalink
Support ingress.appscode.com key for all annotations (#792)
Browse files Browse the repository at this point in the history
  • Loading branch information
diptadas authored and tamalsaha committed Jan 2, 2018
1 parent 513caf2 commit 2446af1
Show file tree
Hide file tree
Showing 76 changed files with 2,657 additions and 2,375 deletions.
259 changes: 165 additions & 94 deletions apis/voyager/v1beta1/annotations.go

Large diffs are not rendered by default.

9 changes: 9 additions & 0 deletions apis/voyager/v1beta1/annotations_test.go
Expand Up @@ -49,3 +49,12 @@ func TestGetOptions(t *testing.T) {
}
assert.Equal(t, responseMap, opt)
}

func TestIngressKey(t *testing.T) {
key, err := toIngressKey(CORSEnabled)
assert.Equal(t, err, nil)
annotation := map[string]string{key: "true"}
ret, err := getBool(annotation, CORSEnabled)
assert.Equal(t, nil, err)
assert.Equal(t, true, ret)
}
2 changes: 1 addition & 1 deletion apis/voyager/v1beta1/diff.go
Expand Up @@ -20,7 +20,7 @@ const (
)

// if ingressClass == "voyager", then only handle ingress that has voyager annotation
// if ingressClass == "", then handle no annotaion or voyager annotation
// if ingressClass == "", then handle no annotation or voyager annotation
func (r Ingress) ShouldHandleIngress(ingressClass string) bool {
// https://github.com/appscode/voyager/blob/master/api/conversion_v1beta1.go#L44
if r.APISchema() == APISchemaEngress {
Expand Down
36 changes: 33 additions & 3 deletions apis/voyager/v1beta1/diff_test.go
Expand Up @@ -14,7 +14,7 @@ func TestShouldHandleIngress(t *testing.T) {
dataTables[&Ingress{
ObjectMeta: metav1.ObjectMeta{
Annotations: map[string]string{
"kubernetes.io/ingress.class": "voyager",
APISchema: APISchemaEngress,
},
},
}] = map[string]bool{
Expand All @@ -25,10 +25,23 @@ func TestShouldHandleIngress(t *testing.T) {
"aws": true,
}

dataTables[&Ingress{
ObjectMeta: metav1.ObjectMeta{
Annotations: map[string]string{},
},
}] = map[string]bool{
"voyager": true,
"": true,
"gce": true,
"gke": true,
"aws": true,
}

dataTables[&Ingress{
ObjectMeta: metav1.ObjectMeta{
Annotations: map[string]string{
APISchema: APISchemaEngress,
APISchema: APISchemaIngress,
ingressClassAnnotationKey: "voyager",
},
},
}] = map[string]bool{
Expand All @@ -41,7 +54,24 @@ func TestShouldHandleIngress(t *testing.T) {

dataTables[&Ingress{
ObjectMeta: metav1.ObjectMeta{
Annotations: map[string]string{},
Annotations: map[string]string{
APISchema: APISchemaIngress,
ingressClassAnnotationKey: "gce",
},
},
}] = map[string]bool{
"voyager": false,
"": false,
"gce": true,
"gke": false,
"aws": false,
}

dataTables[&Ingress{
ObjectMeta: metav1.ObjectMeta{
Annotations: map[string]string{
APISchema: APISchemaIngress,
},
},
}] = map[string]bool{
"voyager": false,
Expand Down
2 changes: 1 addition & 1 deletion client/typed/voyager/v1beta1/util/kubernetes.go
Expand Up @@ -5,7 +5,7 @@ import (

"github.com/appscode/kutil/meta"
api "github.com/appscode/voyager/apis/voyager/v1beta1"
"github.com/kubernetes/apimachinery/pkg/conversion"
"k8s.io/apimachinery/pkg/conversion"
"k8s.io/apimachinery/pkg/runtime/schema"
)

Expand Down
36 changes: 16 additions & 20 deletions glide.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 13 additions & 17 deletions glide.yaml
Expand Up @@ -7,14 +7,15 @@ import:
- package: github.com/Azure/go-autorest
version: ~8.1.1
- package: github.com/appscode/go
version: master
- package: github.com/appscode/haproxy_exporter
version: 0.8.1
- package: github.com/appscode/kloader
version: 5.0.0
- package: github.com/appscode/kutil
version: release-5.0
- package: github.com/appscode/kube-mon
version: master
- package: github.com/appscode/kutil
version: release-5.0
- package: github.com/appscode/pat
- package: github.com/aws/aws-sdk-go
version: v1.7.0
Expand All @@ -25,28 +26,28 @@ import:
version: client-go-5
- package: github.com/ghodss/yaml
version: v1.0.0
- package: github.com/go-openapi/spec
- package: github.com/golang/glog
- package: github.com/google/go-cmp
version: master
- package: github.com/hashicorp/go-version
repo: https://github.com/appscode/go-version.git
vcs: git
version: master
- package: github.com/hashicorp/vault
version: v0.8.3
version: v0.9.1
- package: github.com/jpillora/go-ogle-analytics
- package: github.com/moul/http2curl
- package: github.com/onsi/ginkgo
version: v1.4.0
- package: github.com/onsi/gomega
version: v1.2.0
- package: github.com/orcaman/concurrent-map
- package: github.com/pkg/errors
version: v0.8.0
- package: github.com/pires/go-proxyproto
- package: github.com/prometheus/client_golang
version: v0.8.0
- package: github.com/prometheus/common
version: 3233b24a36715a2fe36d162260457857a56d672d
- package: github.com/sirupsen/logrus
version: v1.0.3
- package: github.com/spf13/afero
version: master
- package: github.com/spf13/cobra
Expand All @@ -62,27 +63,22 @@ import:
repo: https://github.com/appscode/oauth2.git
vcs: git
version: master
- package: github.com/kelseyhightower/passwd
version: master
- package: google.golang.org/api
- package: gopkg.in/gcfg.v1
version: v1.2.0
version: v1.2.1
- package: k8s.io/api
version: kubernetes-1.8.3
- package: k8s.io/apiextensions-apiserver
version: kubernetes-1.8.3
- package: k8s.io/apimachinery
version: kubernetes-1.8.3
- package: k8s.io/client-go
version: kubernetes-1.8.3
- package: k8s.io/apiextensions-apiserver
version: release-1.8
- package: k8s.io/kube-openapi
- package: k8s.io/kubernetes
repo: https://github.com/appscode/kubernetes.git
version: v1.8.3
vcs: git
- package: github.com/google/uuid
version: master
- package: github.com/pires/go-proxyproto
version: master
testImport:
- package: github.com/stretchr/testify
version: v1.1.4
version: v1.2.0
21 changes: 16 additions & 5 deletions test/e2e/ingress_ops.go
Expand Up @@ -5,6 +5,8 @@ import (
"net/http"
"time"

"strings"

"github.com/appscode/go/log"
api "github.com/appscode/voyager/apis/voyager/v1beta1"
"github.com/appscode/voyager/test/framework"
Expand Down Expand Up @@ -541,11 +543,7 @@ var _ = Describe("IngressOperations", func() {
})

Describe("With CORS Enabled", func() {
BeforeEach(func() {
ing.Annotations[api.CORSEnabled] = "true"
})

It("Should Response CORS", func() {
shouldResponseCORS := func() {
By("Getting HTTP endpoints")
eps, err := f.Ingress.GetHTTPEndpoints(ing)
Expect(err).NotTo(HaveOccurred())
Expand All @@ -560,6 +558,19 @@ var _ = Describe("IngressOperations", func() {
Expect(r.ResponseHeader.Get("Access-Control-Allow-Origin")).Should(Equal("test.e2e"))
})
Expect(err).NotTo(HaveOccurred())
}
Context("Engress key", func() {
BeforeEach(func() {
ing.Annotations[api.CORSEnabled] = "true"
})
It("Should Response CORS", shouldResponseCORS)
})
Context("Ingress key", func() {
BeforeEach(func() {
key := api.IngressKey + strings.TrimPrefix(api.CORSEnabled, api.EngressKey)
ing.Annotations[key] = "true"
})
It("Should Response CORS", shouldResponseCORS)
})
})

Expand Down
2 changes: 1 addition & 1 deletion vendor/github.com/JamesClonk/vultr/lib/client.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions vendor/github.com/appscode/kube-mon/parser.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 2446af1

Please sign in to comment.