Fix lint errors

This commit is contained in:
Manuel de Brito Fontes 2016-11-10 22:45:20 -03:00
parent 4ab3b66d40
commit 89313744bc
8 changed files with 20 additions and 22 deletions

View file

@ -27,6 +27,8 @@ before_script:
- export PATH=$PATH:$PWD/hack/e2e-internal/ - export PATH=$PATH:$PWD/hack/e2e-internal/
script: script:
- make fmt lint vet cover # enable kubernetes/ingress in
# coveralls.io and add cover task
- make fmt lint vet test
- make controllers controllers-images - make controllers controllers-images
#- make test-e2e #- make test-e2e

View file

@ -23,21 +23,19 @@ endif
# base package. It contains the common and backends code # base package. It contains the common and backends code
PKG := "k8s.io/ingress" PKG := "k8s.io/ingress"
GO_LIST_FILES=$(shell go list ${PKG}/... | grep -v vendor | grep -v "test/e2e") # TODO: fix lint errors in gce controller
GO_LIST_FILES=$(shell go list ${PKG}/... | grep -v vendor | grep -v -e "test/e2e" -e "controllers/gce/loadbalancers" -e "controllers/gce/controller")
.PHONY: fmt .PHONY: fmt
fmt: fmt:
@echo "+ $@"
@go list -f '{{if len .TestGoFiles}}"gofmt -s -l {{.Dir}}"{{end}}' ${GO_LIST_FILES} | xargs -L 1 sh -c @go list -f '{{if len .TestGoFiles}}"gofmt -s -l {{.Dir}}"{{end}}' ${GO_LIST_FILES} | xargs -L 1 sh -c
.PHONY: lint .PHONY: lint
lint: lint:
@echo "+ $@"
@go list -f '{{if len .TestGoFiles}}"golint {{.Dir}}/..."{{end}}' ${GO_LIST_FILES} | xargs -L 1 sh -c @go list -f '{{if len .TestGoFiles}}"golint {{.Dir}}/..."{{end}}' ${GO_LIST_FILES} | xargs -L 1 sh -c
.PHONY: test .PHONY: test
test: fmt lint vet test:
@echo "+ $@"
@go test -v -race -tags "$(BUILDTAGS) cgo" ${GO_LIST_FILES} @go test -v -race -tags "$(BUILDTAGS) cgo" ${GO_LIST_FILES}
.PHONY: test-e2e .PHONY: test-e2e
@ -46,14 +44,12 @@ test-e2e: ginkgo
.PHONY: cover .PHONY: cover
cover: cover:
@echo "+ $@"
@go list -f '{{if len .TestGoFiles}}"go test -coverprofile={{.Dir}}/.coverprofile {{.ImportPath}}"{{end}}' ${GO_LIST_FILES} | xargs -L 1 sh -c @go list -f '{{if len .TestGoFiles}}"go test -coverprofile={{.Dir}}/.coverprofile {{.ImportPath}}"{{end}}' ${GO_LIST_FILES} | xargs -L 1 sh -c
gover gover
goveralls -coverprofile=gover.coverprofile -service travis-ci -repotoken ${COVERALLS_TOKEN} goveralls -coverprofile=gover.coverprofile -service travis-ci -repotoken ${COVERALLS_TOKEN}
.PHONY: vet .PHONY: vet
vet: vet:
@echo "+ $@"
@go vet ${GO_LIST_FILES} @go vet ${GO_LIST_FILES}
.PHONY: clean .PHONY: clean

View file

@ -1,6 +1,6 @@
// vim: ft=asciidoc // vim: ft=asciidoc
[![Build Status](https://travis-ci.org/kubernetes/ingress.svg?branch=master)](https://travis-ci.org/kubernetes/ingress) image:https://travis-ci.org/kubernetes/ingress.svg?branch=master["Build Status", link="https://travis-ci.org/kubernetes/ingress"]
= Ingress = Ingress
:toc: macro :toc: macro

View file

@ -354,7 +354,7 @@ func (lbc *LoadBalancerController) sync(key string) (err error) {
} }
ing := *obj.(*extensions.Ingress) ing := *obj.(*extensions.Ingress)
if urlMap, err := lbc.tr.toUrlMap(&ing); err != nil { if urlMap, err := lbc.tr.toURLMap(&ing); err != nil {
syncError = fmt.Errorf("%v, convert to url map error %v", syncError, err) syncError = fmt.Errorf("%v, convert to url map error %v", syncError, err)
} else if err := l7.UpdateUrlMap(urlMap); err != nil { } else if err := l7.UpdateUrlMap(urlMap); err != nil {
lbc.recorder.Eventf(&ing, api.EventTypeWarning, "UrlMap", err.Error()) lbc.recorder.Eventf(&ing, api.EventTypeWarning, "UrlMap", err.Error())

View file

@ -51,8 +51,8 @@ func defaultBackendName(clusterName string) string {
} }
// newLoadBalancerController create a loadbalancer controller. // newLoadBalancerController create a loadbalancer controller.
func newLoadBalancerController(t *testing.T, cm *fakeClusterManager, masterUrl string) *LoadBalancerController { func newLoadBalancerController(t *testing.T, cm *fakeClusterManager, masterURL string) *LoadBalancerController {
client := client.NewForConfigOrDie(&restclient.Config{Host: masterUrl, ContentConfig: restclient.ContentConfig{GroupVersion: testapi.Default.GroupVersion()}}) client := client.NewForConfigOrDie(&restclient.Config{Host: masterURL, ContentConfig: restclient.ContentConfig{GroupVersion: testapi.Default.GroupVersion()}})
lb, err := NewLoadBalancerController(client, cm.ClusterManager, 1*time.Second, api.NamespaceAll) lb, err := NewLoadBalancerController(client, cm.ClusterManager, 1*time.Second, api.NamespaceAll)
if err != nil { if err != nil {
t.Fatalf("%v", err) t.Fatalf("%v", err)

View file

@ -226,8 +226,8 @@ type GCETranslator struct {
*LoadBalancerController *LoadBalancerController
} }
// toUrlMap converts an ingress to a map of subdomain: url-regex: gce backend. // toURLMap converts an ingress to a map of subdomain: url-regex: gce backend.
func (t *GCETranslator) toUrlMap(ing *extensions.Ingress) (utils.GCEURLMap, error) { func (t *GCETranslator) toURLMap(ing *extensions.Ingress) (utils.GCEURLMap, error) {
hostPathBackend := utils.GCEURLMap{} hostPathBackend := utils.GCEURLMap{}
for _, rule := range ing.Spec.Rules { for _, rule := range ing.Spec.Rules {
if rule.HTTP == nil { if rule.HTTP == nil {

View file

@ -123,37 +123,37 @@ type ConfigMapStore interface {
cache.Store cache.Store
} }
// ApiServerConfigMapStore only services Add and GetByKey from apiserver. // APIServerConfigMapStore only services Add and GetByKey from apiserver.
// TODO: Implement all the other store methods and make this a write // TODO: Implement all the other store methods and make this a write
// through cache. // through cache.
type ApiServerConfigMapStore struct { type APIServerConfigMapStore struct {
ConfigMapStore ConfigMapStore
client client.Interface client client.Interface
} }
// Add adds the given config map to the apiserver's store. // Add adds the given config map to the apiserver's store.
func (a *ApiServerConfigMapStore) Add(obj interface{}) error { func (a *APIServerConfigMapStore) Add(obj interface{}) error {
cfg := obj.(*api.ConfigMap) cfg := obj.(*api.ConfigMap)
_, err := a.client.Core().ConfigMaps(cfg.Namespace).Create(cfg) _, err := a.client.Core().ConfigMaps(cfg.Namespace).Create(cfg)
return err return err
} }
// Update updates the existing config map object. // Update updates the existing config map object.
func (a *ApiServerConfigMapStore) Update(obj interface{}) error { func (a *APIServerConfigMapStore) Update(obj interface{}) error {
cfg := obj.(*api.ConfigMap) cfg := obj.(*api.ConfigMap)
_, err := a.client.Core().ConfigMaps(cfg.Namespace).Update(cfg) _, err := a.client.Core().ConfigMaps(cfg.Namespace).Update(cfg)
return err return err
} }
// Delete deletes the existing config map object. // Delete deletes the existing config map object.
func (a *ApiServerConfigMapStore) Delete(obj interface{}) error { func (a *APIServerConfigMapStore) Delete(obj interface{}) error {
cfg := obj.(*api.ConfigMap) cfg := obj.(*api.ConfigMap)
return a.client.Core().ConfigMaps(cfg.Namespace).Delete(cfg.Name, &api.DeleteOptions{}) return a.client.Core().ConfigMaps(cfg.Namespace).Delete(cfg.Name, &api.DeleteOptions{})
} }
// GetByKey returns the config map for a given key. // GetByKey returns the config map for a given key.
// The key must take the form namespace/name. // The key must take the form namespace/name.
func (a *ApiServerConfigMapStore) GetByKey(key string) (item interface{}, exists bool, err error) { func (a *APIServerConfigMapStore) GetByKey(key string) (item interface{}, exists bool, err error) {
nsName := strings.Split(key, "/") nsName := strings.Split(key, "/")
if len(nsName) != 2 { if len(nsName) != 2 {
return nil, false, fmt.Errorf("Failed to get key %v, unexpecte format, expecting ns/name", key) return nil, false, fmt.Errorf("Failed to get key %v, unexpecte format, expecting ns/name", key)
@ -173,5 +173,5 @@ func (a *ApiServerConfigMapStore) GetByKey(key string) (item interface{}, exists
// NewConfigMapStore returns a config map store capable of persisting updates // NewConfigMapStore returns a config map store capable of persisting updates
// to apiserver. // to apiserver.
func NewConfigMapStore(c client.Interface) ConfigMapStore { func NewConfigMapStore(c client.Interface) ConfigMapStore {
return &ApiServerConfigMapStore{ConfigMapStore: cache.NewStore(cache.MetaNamespaceKeyFunc), client: c} return &APIServerConfigMapStore{ConfigMapStore: cache.NewStore(cache.MetaNamespaceKeyFunc), client: c}
} }

View file

@ -25,10 +25,10 @@ import (
"k8s.io/kubernetes/pkg/apis/extensions" "k8s.io/kubernetes/pkg/apis/extensions"
"k8s.io/kubernetes/pkg/client/cache" "k8s.io/kubernetes/pkg/client/cache"
"github.com/golang/glog"
"k8s.io/ingress/core/pkg/ingress" "k8s.io/ingress/core/pkg/ingress"
"k8s.io/ingress/core/pkg/ingress/annotations/parser" "k8s.io/ingress/core/pkg/ingress/annotations/parser"
ssl "k8s.io/ingress/core/pkg/net/ssl" ssl "k8s.io/ingress/core/pkg/net/ssl"
"github.com/golang/glog"
) )
// syncSecret keeps in sync Secrets used by Ingress rules with files to allow // syncSecret keeps in sync Secrets used by Ingress rules with files to allow