Skip to content

Commit

Permalink
Fix linter errors (#449)
Browse files Browse the repository at this point in the history
Signed-off-by: Tamal Saha <tamal@appscode.com>
  • Loading branch information
tamalsaha committed Oct 2, 2019
1 parent 1b2a09b commit 630714c
Show file tree
Hide file tree
Showing 21 changed files with 63 additions and 49 deletions.
7 changes: 5 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ ARCH := $(if $(GOARCH),$(GOARCH),$(shell go env GOARCH))
BASEIMAGE_PROD ?= gcr.io/distroless/static
BASEIMAGE_DBG ?= debian:stretch

GO_VERSION ?= 1.12.7
GO_VERSION ?= 1.12.10
BUILD_IMAGE ?= appscode/golang-dev:$(GO_VERSION)-stretch

OUTBIN = bin/$(OS)_$(ARCH)/$(BIN)
Expand All @@ -72,7 +72,10 @@ endif
# Directories that we need created to build/test.
BUILD_DIRS := bin/$(OS)_$(ARCH) \
.go/bin/$(OS)_$(ARCH) \
.go/cache
.go/cache \
$(HOME)/.credentials \
$(HOME)/.kube \
$(HOME)/.minikube

# If you want to build all binaries, see the 'all-build' rule.
# If you want to build all containers, see the 'all-container' rule.
Expand Down
2 changes: 1 addition & 1 deletion apis/config/v1alpha1/galera_arbitrator_config_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@ type GaleraArbitratorConfiguration struct {
// This method is needed to form the SST request string that contains SST request to
// trigger state snapshot dump (state backup) on one of the other nodes.
// Ref: https://galeracluster.com/library/documentation/mysql-wsrep-options.html#wsrep-sst-method
SSTMethod string `json:"sstMethod, omitempty"`
SSTMethod string `json:"sstMethod,omitempty"`
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ const (
LabelDatabaseName = GenericKey + "/name"
LabelRole = GenericKey + "/role"

ComponentDatabase = "database"
RoleStats = "stats"
DefaultStatsPath = "/metrics"

PostgresKey = ResourceSingularPostgres + "." + GenericKey
ElasticsearchKey = ResourceSingularElasticsearch + "." + GenericKey
MySQLKey = ResourceSingularMySQL + "." + GenericKey
Expand Down
6 changes: 3 additions & 3 deletions apis/kubedb/v1alpha1/elasticsearch_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func (e Elasticsearch) OffshootLabels() map[string]string {
out[meta_util.NameLabelKey] = ResourceSingularElasticsearch
out[meta_util.VersionLabelKey] = string(e.Spec.Version)
out[meta_util.InstanceLabelKey] = e.Name
out[meta_util.ComponentLabelKey] = "database"
out[meta_util.ComponentLabelKey] = ComponentDatabase
out[meta_util.ManagedByLabelKey] = GenericKey
return meta_util.FilterKeys(GenericKey, out, e.Labels)
}
Expand Down Expand Up @@ -111,7 +111,7 @@ func (e elasticsearchStatsService) ServiceMonitorName() string {
}

func (e elasticsearchStatsService) Path() string {
return "/metrics"
return DefaultStatsPath
}

func (e elasticsearchStatsService) Scheme() string {
Expand All @@ -124,7 +124,7 @@ func (e Elasticsearch) StatsService() mona.StatsAccessor {

func (e Elasticsearch) StatsServiceLabels() map[string]string {
lbl := meta_util.FilterKeys(GenericKey, e.OffshootSelectors(), e.Labels)
lbl[LabelRole] = "stats"
lbl[LabelRole] = RoleStats
return lbl
}

Expand Down
4 changes: 2 additions & 2 deletions apis/kubedb/v1alpha1/etcd_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func (e Etcd) OffshootLabels() map[string]string {
out[meta_util.NameLabelKey] = ResourceSingularEtcd
out[meta_util.VersionLabelKey] = string(e.Spec.Version)
out[meta_util.InstanceLabelKey] = e.Name
out[meta_util.ComponentLabelKey] = "database"
out[meta_util.ComponentLabelKey] = ComponentDatabase
out[meta_util.ManagedByLabelKey] = GenericKey
return meta_util.FilterKeys(GenericKey, out, e.Labels)
}
Expand Down Expand Up @@ -111,7 +111,7 @@ func (e Etcd) StatsService() mona.StatsAccessor {

func (e Etcd) StatsServiceLabels() map[string]string {
lbl := meta_util.FilterKeys(GenericKey, e.OffshootSelectors(), e.Labels)
lbl[LabelRole] = "stats"
lbl[LabelRole] = RoleStats
return lbl
}

Expand Down
6 changes: 3 additions & 3 deletions apis/kubedb/v1alpha1/mariadb_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func (m MariaDB) OffshootLabels() map[string]string {
out[meta_util.NameLabelKey] = ResourceSingularMariaDB
out[meta_util.VersionLabelKey] = string(m.Spec.Version)
out[meta_util.InstanceLabelKey] = m.Name
out[meta_util.ComponentLabelKey] = "database"
out[meta_util.ComponentLabelKey] = ComponentDatabase
out[meta_util.ManagedByLabelKey] = GenericKey
return meta_util.FilterKeys(GenericKey, out, m.Labels)
}
Expand Down Expand Up @@ -94,7 +94,7 @@ func (m mariadbStatsService) ServiceMonitorName() string {
}

func (m mariadbStatsService) Path() string {
return "/metrics"
return DefaultStatsPath
}

func (m mariadbStatsService) Scheme() string {
Expand All @@ -107,7 +107,7 @@ func (m MariaDB) StatsService() mona.StatsAccessor {

func (m MariaDB) StatsServiceLabels() map[string]string {
lbl := meta_util.FilterKeys(GenericKey, m.OffshootSelectors(), m.Labels)
lbl[LabelRole] = "stats"
lbl[LabelRole] = RoleStats
return lbl
}

Expand Down
6 changes: 3 additions & 3 deletions apis/kubedb/v1alpha1/memcached_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func (m Memcached) OffshootLabels() map[string]string {
out[meta_util.NameLabelKey] = ResourceSingularMemcached
out[meta_util.VersionLabelKey] = string(m.Spec.Version)
out[meta_util.InstanceLabelKey] = m.Name
out[meta_util.ComponentLabelKey] = "database"
out[meta_util.ComponentLabelKey] = ComponentDatabase
out[meta_util.ManagedByLabelKey] = GenericKey
return meta_util.FilterKeys(GenericKey, out, m.Labels)
}
Expand Down Expand Up @@ -89,7 +89,7 @@ func (m memcachedStatsService) ServiceMonitorName() string {
}

func (m memcachedStatsService) Path() string {
return "/metrics"
return DefaultStatsPath
}

func (m memcachedStatsService) Scheme() string {
Expand All @@ -102,7 +102,7 @@ func (m Memcached) StatsService() mona.StatsAccessor {

func (m Memcached) StatsServiceLabels() map[string]string {
lbl := meta_util.FilterKeys(GenericKey, m.OffshootSelectors(), m.Labels)
lbl[LabelRole] = "stats"
lbl[LabelRole] = RoleStats
return lbl
}

Expand Down
6 changes: 3 additions & 3 deletions apis/kubedb/v1alpha1/mongodb_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ func (m MongoDB) OffshootLabels() map[string]string {
out[meta_util.NameLabelKey] = ResourceSingularMongoDB
out[meta_util.VersionLabelKey] = string(m.Spec.Version)
out[meta_util.InstanceLabelKey] = m.Name
out[meta_util.ComponentLabelKey] = "database"
out[meta_util.ComponentLabelKey] = ComponentDatabase
out[meta_util.ManagedByLabelKey] = GenericKey
return meta_util.FilterKeys(GenericKey, out, m.Labels)
}
Expand Down Expand Up @@ -250,7 +250,7 @@ func (m mongoDBStatsService) ServiceMonitorName() string {
}

func (m mongoDBStatsService) Path() string {
return "/metrics"
return DefaultStatsPath
}

func (m mongoDBStatsService) Scheme() string {
Expand All @@ -263,7 +263,7 @@ func (m MongoDB) StatsService() mona.StatsAccessor {

func (m MongoDB) StatsServiceLabels() map[string]string {
lbl := meta_util.FilterKeys(GenericKey, m.OffshootSelectors(), m.Labels)
lbl[LabelRole] = "stats"
lbl[LabelRole] = RoleStats
return lbl
}

Expand Down
6 changes: 3 additions & 3 deletions apis/kubedb/v1alpha1/mysql_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func (m MySQL) OffshootLabels() map[string]string {
out[meta_util.NameLabelKey] = ResourceSingularMySQL
out[meta_util.VersionLabelKey] = string(m.Spec.Version)
out[meta_util.InstanceLabelKey] = m.Name
out[meta_util.ComponentLabelKey] = "database"
out[meta_util.ComponentLabelKey] = ComponentDatabase
out[meta_util.ManagedByLabelKey] = GenericKey
return meta_util.FilterKeys(GenericKey, out, m.Labels)
}
Expand Down Expand Up @@ -108,7 +108,7 @@ func (m mysqlStatsService) ServiceMonitorName() string {
}

func (m mysqlStatsService) Path() string {
return "/metrics"
return DefaultStatsPath
}

func (m mysqlStatsService) Scheme() string {
Expand All @@ -121,7 +121,7 @@ func (m MySQL) StatsService() mona.StatsAccessor {

func (m MySQL) StatsServiceLabels() map[string]string {
lbl := meta_util.FilterKeys(GenericKey, m.OffshootSelectors(), m.Labels)
lbl[LabelRole] = "stats"
lbl[LabelRole] = RoleStats
return lbl
}

Expand Down
6 changes: 3 additions & 3 deletions apis/kubedb/v1alpha1/perconaxtradb_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func (p PerconaXtraDB) OffshootLabels() map[string]string {
out[meta_util.NameLabelKey] = ResourceSingularPerconaXtraDB
out[meta_util.VersionLabelKey] = string(p.Spec.Version)
out[meta_util.InstanceLabelKey] = p.Name
out[meta_util.ComponentLabelKey] = "database"
out[meta_util.ComponentLabelKey] = ComponentDatabase
out[meta_util.ManagedByLabelKey] = GenericKey
return meta_util.FilterKeys(GenericKey, out, p.Labels)
}
Expand Down Expand Up @@ -110,7 +110,7 @@ func (p perconaXtraDBStatsService) ServiceMonitorName() string {
}

func (p perconaXtraDBStatsService) Path() string {
return "/metrics"
return DefaultStatsPath
}

func (p perconaXtraDBStatsService) Scheme() string {
Expand All @@ -123,7 +123,7 @@ func (p PerconaXtraDB) StatsService() mona.StatsAccessor {

func (p PerconaXtraDB) StatsServiceLabels() map[string]string {
lbl := meta_util.FilterKeys(GenericKey, p.OffshootSelectors(), p.Labels)
lbl[LabelRole] = "stats"
lbl[LabelRole] = RoleStats
return lbl
}

Expand Down
4 changes: 2 additions & 2 deletions apis/kubedb/v1alpha1/pgbouncer_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ func (p pgbouncerStatsService) ServiceMonitorName() string {
}

func (p pgbouncerStatsService) Path() string {
return "/metrics"
return DefaultStatsPath
}

func (p pgbouncerStatsService) Scheme() string {
Expand All @@ -106,7 +106,7 @@ func (p PgBouncer) StatsService() mona.StatsAccessor {

func (p PgBouncer) StatsServiceLabels() map[string]string {
lbl := meta_util.FilterKeys(GenericKey, p.OffshootSelectors(), p.Labels)
lbl[LabelRole] = "stats"
lbl[LabelRole] = RoleStats
return lbl
}

Expand Down
6 changes: 3 additions & 3 deletions apis/kubedb/v1alpha1/pgbouncer_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,13 @@ type PgBouncerSpec struct {
PodTemplate ofst.PodTemplateSpec `json:"podTemplate,omitempty"`
// Databases to proxy by connection pooling
// +optional
Databases []Databases `json:"databases, omitempty"`
Databases []Databases `json:"databases,omitempty"`
// ConnectionPoolConfig defines Connection pool configuration
// +optional
ConnectionPool *ConnectionPoolConfig `json:"connectionPool, omitempty"`
ConnectionPool *ConnectionPoolConfig `json:"connectionPool,omitempty"`
// UserListSecretRef is a secret with a list of PgBouncer user and passwords
// +optional
UserListSecretRef *core.LocalObjectReference `json:"userListSecretRef, omitempty"`
UserListSecretRef *core.LocalObjectReference `json:"userListSecretRef,omitempty"`
// Monitor is used monitor database instance
// +optional
Monitor *mona.AgentSpec `json:"monitor,omitempty"`
Expand Down
6 changes: 3 additions & 3 deletions apis/kubedb/v1alpha1/postgres_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func (p Postgres) OffshootLabels() map[string]string {
out[meta_util.NameLabelKey] = ResourceSingularPostgres
out[meta_util.VersionLabelKey] = string(p.Spec.Version)
out[meta_util.InstanceLabelKey] = p.Name
out[meta_util.ComponentLabelKey] = "database"
out[meta_util.ComponentLabelKey] = ComponentDatabase
out[meta_util.ManagedByLabelKey] = GenericKey
return meta_util.FilterKeys(GenericKey, out, p.Labels)
}
Expand Down Expand Up @@ -95,7 +95,7 @@ func (p postgresStatsService) ServiceMonitorName() string {
}

func (p postgresStatsService) Path() string {
return "/metrics"
return DefaultStatsPath
}

func (p postgresStatsService) Scheme() string {
Expand All @@ -108,7 +108,7 @@ func (p Postgres) StatsService() mona.StatsAccessor {

func (p Postgres) StatsServiceLabels() map[string]string {
lbl := meta_util.FilterKeys(GenericKey, p.OffshootSelectors(), p.Labels)
lbl[LabelRole] = "stats"
lbl[LabelRole] = RoleStats
return lbl
}

Expand Down
6 changes: 3 additions & 3 deletions apis/kubedb/v1alpha1/redis_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func (r Redis) OffshootLabels() map[string]string {
out[meta_util.NameLabelKey] = ResourceSingularRedis
out[meta_util.VersionLabelKey] = string(r.Spec.Version)
out[meta_util.InstanceLabelKey] = r.Name
out[meta_util.ComponentLabelKey] = "database"
out[meta_util.ComponentLabelKey] = ComponentDatabase
out[meta_util.ManagedByLabelKey] = GenericKey
return meta_util.FilterKeys(GenericKey, out, r.Labels)
}
Expand Down Expand Up @@ -102,7 +102,7 @@ func (r redisStatsService) ServiceMonitorName() string {
}

func (r redisStatsService) Path() string {
return "/metrics"
return DefaultStatsPath
}

func (r redisStatsService) Scheme() string {
Expand All @@ -115,7 +115,7 @@ func (r Redis) StatsService() mona.StatsAccessor {

func (r Redis) StatsServiceLabels() map[string]string {
lbl := meta_util.FilterKeys(GenericKey, r.OffshootSelectors(), r.Labels)
lbl[LabelRole] = "stats"
lbl[LabelRole] = RoleStats
return lbl
}

Expand Down
4 changes: 3 additions & 1 deletion pkg/admission/dormantdatabase/admission_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ import (
)

func init() {
scheme.AddToScheme(clientsetscheme.Scheme)
if err := scheme.AddToScheme(clientsetscheme.Scheme); err != nil {
panic(err)
}
}

var requestKind = metav1.GroupVersionKind{
Expand Down
4 changes: 3 additions & 1 deletion pkg/admission/namespace/admission_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ import (
)

func init() {
scheme.AddToScheme(clientsetscheme.Scheme)
if err := scheme.AddToScheme(clientsetscheme.Scheme); err != nil {
panic(err)
}
}

var requestKind = metav1.GroupVersionKind{
Expand Down
6 changes: 4 additions & 2 deletions pkg/admission/snapshot/admission_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
metaV1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/client-go/kubernetes/fake"
clientSetScheme "k8s.io/client-go/kubernetes/scheme"
clientsetscheme "k8s.io/client-go/kubernetes/scheme"
"kmodules.xyz/client-go/meta"
store "kmodules.xyz/objectstore-api/api/v1"
api "kubedb.dev/apimachinery/apis/kubedb/v1alpha1"
Expand All @@ -22,7 +22,9 @@ import (
)

func init() {
scheme.AddToScheme(clientSetScheme.Scheme)
if err := scheme.AddToScheme(clientsetscheme.Scheme); err != nil {
panic(err)
}
}

var requestKind = metaV1.GroupVersionKind{
Expand Down
6 changes: 5 additions & 1 deletion pkg/controller/dormantdatabase/workqueue.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func (c *Controller) runDormantDatabase(key string) error {
log.Errorln(err)
return err
}
dormantDatabase, _, err = util.PatchDormantDatabase(c.ExtClient.KubedbV1alpha1(), dormantDatabase, func(in *api.DormantDatabase) *api.DormantDatabase {
_, _, err = util.PatchDormantDatabase(c.ExtClient.KubedbV1alpha1(), dormantDatabase, func(in *api.DormantDatabase) *api.DormantDatabase {
in.ObjectMeta = core_util.RemoveFinalizer(in.ObjectMeta, api.GenericKey)
return in
})
Expand All @@ -47,6 +47,10 @@ func (c *Controller) runDormantDatabase(key string) error {
in.ObjectMeta = core_util.AddFinalizer(in.ObjectMeta, api.GenericKey)
return in
})
if err != nil {
log.Errorln(err)
return err
}
if err := c.create(dormantDatabase); err != nil {
log.Errorln(err)
return err
Expand Down
1 change: 0 additions & 1 deletion pkg/controller/restoresession/workqueue.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ func (c *Controller) addEventHandler(selector labels.Selector) {
}
},
DeleteFunc: func(obj interface{}) {
return
},
}, selector))
}
Expand Down
Loading

0 comments on commit 630714c

Please sign in to comment.