Skip to content

Commit

Permalink
host-map -> array
Browse files Browse the repository at this point in the history
  • Loading branch information
diptadas committed Apr 3, 2018
1 parent d9bfc49 commit 9762a4c
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 23 deletions.
2 changes: 1 addition & 1 deletion apis/voyager/v1beta1/annotations.go
Expand Up @@ -683,4 +683,4 @@ func (r Ingress) LimitRPM() int {
func (r Ingress) LimitConnections() int {
value, _ := get[LimitConnection](r.Annotations)
return value.(int)
}
}
7 changes: 4 additions & 3 deletions apis/voyager/v1beta1/ingress.go
Expand Up @@ -305,12 +305,13 @@ type FrontendRule struct {
}

type AuthOption struct {
Basic *BasicAuth `json:"basic,omitempty"`
TLS *TLSAuth `json:"tls,omitempty"`
OAuth map[string]OAuth `json:"oauth,omitempty"`
Basic *BasicAuth `json:"basic,omitempty"`
TLS *TLSAuth `json:"tls,omitempty"`
OAuth []OAuth `json:"oauth,omitempty"`
}

type OAuth struct {
Host string `json:"host,omitempty"`
AuthBackend string `json:"authBackend,omitempty"`
AuthPath string `json:"authPath,omitempty"`
SigninPath string `json:"signinPath,omitempty"`
Expand Down
10 changes: 8 additions & 2 deletions apis/voyager/v1beta1/openapi_generated.go
Expand Up @@ -77,8 +77,8 @@ func GetOpenAPIDefinitions(ref common.ReferenceCallback) map[string]common.OpenA
},
"oauth": {
SchemaProps: spec.SchemaProps{
Type: []string{"object"},
AdditionalProperties: &spec.SchemaOrBool{
Type: []string{"array"},
Items: &spec.SchemaOrArray{
Schema: &spec.Schema{
SchemaProps: spec.SchemaProps{
Ref: ref("github.com/appscode/voyager/apis/voyager/v1beta1.OAuth"),
Expand Down Expand Up @@ -1211,6 +1211,12 @@ func GetOpenAPIDefinitions(ref common.ReferenceCallback) map[string]common.OpenA
Schema: spec.Schema{
SchemaProps: spec.SchemaProps{
Properties: map[string]spec.Schema{
"host": {
SchemaProps: spec.SchemaProps{
Type: []string{"string"},
Format: "",
},
},
"authBackend": {
SchemaProps: spec.SchemaProps{
Type: []string{"string"},
Expand Down
8 changes: 3 additions & 5 deletions apis/voyager/v1beta1/zz_generated.deepcopy.go
Expand Up @@ -65,11 +65,9 @@ func (in *AuthOption) DeepCopyInto(out *AuthOption) {
}
if in.OAuth != nil {
in, out := &in.OAuth, &out.OAuth
*out = make(map[string]OAuth, len(*in))
for key, val := range *in {
newVal := new(OAuth)
val.DeepCopyInto(newVal)
(*out)[key] = *newVal
*out = make([]OAuth, len(*in))
for i := range *in {
(*in)[i].DeepCopyInto(&(*out)[i])
}
}
return
Expand Down
22 changes: 10 additions & 12 deletions pkg/ingress/parser.go
Expand Up @@ -14,7 +14,6 @@ import (
hpi "github.com/appscode/voyager/pkg/haproxy/api"
"github.com/appscode/voyager/pkg/haproxy/template"
_ "github.com/appscode/voyager/third_party/forked/cloudprovider/providers"
"github.com/golang/glog"
"github.com/pkg/errors"
"github.com/tredoe/osutil/user/crypt"
"github.com/tredoe/osutil/user/crypt/sha512_crypt"
Expand Down Expand Up @@ -237,9 +236,6 @@ func (c *controller) rewriteTarget(path string, rewriteRules []string) []string
}

func (c *controller) generateConfig() error {
glog.Info("=========================================================")
glog.Info(c.Ingress)
glog.Info("=========================================================")
if c.Ingress.SSLPassthrough() {
if err := c.convertRulesForSSLPassthrough(); err != nil {
return err
Expand Down Expand Up @@ -791,14 +787,16 @@ func (c *controller) generateConfig() error {
}

// parse external auth
if fr.Auth != nil && fr.Auth.OAuth != nil {
for i, host := range srv.Hosts {
if oauth, ok := fr.Auth.OAuth[host.Host]; ok {
srv.Hosts[i].ExternalAuth = &hpi.ExternalAuth{
AuthBackend: oauth.AuthBackend,
AuthPath: oauth.AuthPath,
SigninPath: oauth.SigninPath,
Paths: oauth.Paths,
if fr.Auth != nil && len(fr.Auth.OAuth) > 0 {
for i := range srv.Hosts {
for _, oauth := range fr.Auth.OAuth {
if oauth.Host == srv.Hosts[i].Host {
srv.Hosts[i].ExternalAuth = &hpi.ExternalAuth{
AuthBackend: oauth.AuthBackend,
AuthPath: oauth.AuthPath,
SigninPath: oauth.SigninPath,
Paths: oauth.Paths,
}
}
}
}
Expand Down

0 comments on commit 9762a4c

Please sign in to comment.