Fix lint errors
This commit is contained in:
parent
ea7f943160
commit
4103537ea1
6 changed files with 20 additions and 19 deletions
|
@ -20,16 +20,16 @@ import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"path"
|
||||||
"strings"
|
|
||||||
"reflect"
|
"reflect"
|
||||||
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
|
|
||||||
"k8s.io/ingress/controllers/nginx/pkg/config"
|
"k8s.io/ingress/controllers/nginx/pkg/config"
|
||||||
"k8s.io/ingress/core/pkg/ingress"
|
"k8s.io/ingress/core/pkg/ingress"
|
||||||
"k8s.io/ingress/core/pkg/ingress/annotations/rewrite"
|
|
||||||
"k8s.io/ingress/core/pkg/ingress/annotations/authreq"
|
"k8s.io/ingress/core/pkg/ingress/annotations/authreq"
|
||||||
|
"k8s.io/ingress/core/pkg/ingress/annotations/rewrite"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
|
|
@ -18,8 +18,8 @@ package authreq
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"net/url"
|
"net/url"
|
||||||
"strings"
|
|
||||||
"regexp"
|
"regexp"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"k8s.io/kubernetes/pkg/apis/extensions"
|
"k8s.io/kubernetes/pkg/apis/extensions"
|
||||||
|
|
||||||
|
@ -33,20 +33,20 @@ const (
|
||||||
authSigninURL = "ingress.kubernetes.io/auth-signin"
|
authSigninURL = "ingress.kubernetes.io/auth-signin"
|
||||||
authMethod = "ingress.kubernetes.io/auth-method"
|
authMethod = "ingress.kubernetes.io/auth-method"
|
||||||
authBody = "ingress.kubernetes.io/auth-send-body"
|
authBody = "ingress.kubernetes.io/auth-send-body"
|
||||||
authHeaders = "ingress.kubernetes.io/auth-response-headers"
|
authHeaders = "ingress.kubernetes.io/auth-response-headers"
|
||||||
)
|
)
|
||||||
|
|
||||||
// External returns external authentication configuration for an Ingress rule
|
// External returns external authentication configuration for an Ingress rule
|
||||||
type External struct {
|
type External struct {
|
||||||
URL string `json:"url"`
|
URL string `json:"url"`
|
||||||
SigninURL string `json:"signinUrl"`
|
SigninURL string `json:"signinUrl"`
|
||||||
Method string `json:"method"`
|
Method string `json:"method"`
|
||||||
SendBody bool `json:"sendBody"`
|
SendBody bool `json:"sendBody"`
|
||||||
ResponseHeaders []string `json:"responseHeaders"`
|
ResponseHeaders []string `json:"responseHeaders"`
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
methods = []string{"GET", "HEAD", "POST", "PUT", "PATCH", "DELETE", "CONNECT", "OPTIONS", "TRACE"}
|
methods = []string{"GET", "HEAD", "POST", "PUT", "PATCH", "DELETE", "CONNECT", "OPTIONS", "TRACE"}
|
||||||
headerRegexp = regexp.MustCompile(`^[a-zA-Z\d\-_]+$`)
|
headerRegexp = regexp.MustCompile(`^[a-zA-Z\d\-_]+$`)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -128,10 +128,10 @@ func (a authReq) Parse(ing *extensions.Ingress) (interface{}, error) {
|
||||||
sb, _ := parser.GetBoolAnnotation(authBody, ing)
|
sb, _ := parser.GetBoolAnnotation(authBody, ing)
|
||||||
|
|
||||||
return &External{
|
return &External{
|
||||||
URL: str,
|
URL: str,
|
||||||
SigninURL: signin,
|
SigninURL: signin,
|
||||||
Method: m,
|
Method: m,
|
||||||
SendBody: sb,
|
SendBody: sb,
|
||||||
ResponseHeaders: h,
|
ResponseHeaders: h,
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,8 +18,8 @@ package authreq
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"testing"
|
|
||||||
"reflect"
|
"reflect"
|
||||||
|
"testing"
|
||||||
|
|
||||||
"k8s.io/kubernetes/pkg/api"
|
"k8s.io/kubernetes/pkg/api"
|
||||||
"k8s.io/kubernetes/pkg/apis/extensions"
|
"k8s.io/kubernetes/pkg/apis/extensions"
|
||||||
|
|
|
@ -34,7 +34,7 @@ func IsValidService(kubeClient clientset.Interface, name string) (*api.Service,
|
||||||
return kubeClient.Core().Services(ns).Get(name)
|
return kubeClient.Core().Services(ns).Get(name)
|
||||||
}
|
}
|
||||||
|
|
||||||
// isValidConfigMap check if exists a configmap with the specified name
|
// IsValidConfigMap check if exists a configmap with the specified name
|
||||||
func IsValidConfigMap(kubeClient clientset.Interface, fullName string) (*api.ConfigMap, error) {
|
func IsValidConfigMap(kubeClient clientset.Interface, fullName string) (*api.ConfigMap, error) {
|
||||||
|
|
||||||
ns, name, err := ParseNameNS(fullName)
|
ns, name, err := ParseNameNS(fullName)
|
||||||
|
@ -53,7 +53,7 @@ func IsValidConfigMap(kubeClient clientset.Interface, fullName string) (*api.Con
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// isValidNamespace chck if exists a namespace with the specified name
|
// IsValidNamespace chck if exists a namespace with the specified name
|
||||||
func IsValidNamespace(kubeClient clientset.Interface, name string) (*api.Namespace, error) {
|
func IsValidNamespace(kubeClient clientset.Interface, name string) (*api.Namespace, error) {
|
||||||
return kubeClient.Core().Namespaces().Get(name)
|
return kubeClient.Core().Namespaces().Get(name)
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,10 +2,10 @@ package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
|
||||||
"strings"
|
|
||||||
"math/rand"
|
"math/rand"
|
||||||
|
"net/http"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Sample authentication service returning several HTTP headers in response
|
// Sample authentication service returning several HTTP headers in response
|
||||||
|
|
|
@ -6,7 +6,8 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
func handler(w http.ResponseWriter, r *http.Request) {
|
func handler(w http.ResponseWriter, r *http.Request) {
|
||||||
fmt.Fprintf(w, "UserID: %s, UserRole: %s", r.Header.Get("UserID"), r.Header.Get("UserRole"))}
|
fmt.Fprintf(w, "UserID: %s, UserRole: %s", r.Header.Get("UserID"), r.Header.Get("UserRole"))
|
||||||
|
}
|
||||||
|
|
||||||
// Sample "echo" service displaying UserID and UserRole HTTP request headers
|
// Sample "echo" service displaying UserID and UserRole HTTP request headers
|
||||||
func main() {
|
func main() {
|
||||||
|
|
Loading…
Reference in a new issue