Skip to content

Commit

Permalink
add importas to golangci-lint (#2516)
Browse files Browse the repository at this point in the history
-  add importas rule
-  fix import names

Signed-off-by: Tharun <rajendrantharun@live.com>
  • Loading branch information
tharun208 authored Aug 8, 2021
1 parent 9ab4c8f commit 2e3ace0
Show file tree
Hide file tree
Showing 145 changed files with 984 additions and 977 deletions.
7 changes: 7 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ linters:
- gci
- gocritic
- govet
- importas
- misspell
- unconvert
- whitespace
Expand All @@ -22,6 +23,12 @@ linters-settings:
- singleCaseSwitch
gci:
local-prefixes: github.com/kumahq/kuma
importas:
alias:
- pkg: github.com/kumahq/kuma/pkg/core/resources/apis/mesh
alias: core_mesh
- pkg: github.com/kumahq/kuma/api/mesh/v1alpha1
alias: mesh_proto

issues:
fix: true
Expand Down
48 changes: 24 additions & 24 deletions app/kumactl/cmd/delete/delete_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
"github.com/kumahq/kuma/app/kumactl/cmd"
kumactl_cmd "github.com/kumahq/kuma/app/kumactl/pkg/cmd"
config_proto "github.com/kumahq/kuma/pkg/config/app/kumactl/v1alpha1"
mesh_core "github.com/kumahq/kuma/pkg/core/resources/apis/mesh"
core_mesh "github.com/kumahq/kuma/pkg/core/resources/apis/mesh"
"github.com/kumahq/kuma/pkg/core/resources/apis/system"
core_model "github.com/kumahq/kuma/pkg/core/resources/model"
core_store "github.com/kumahq/kuma/pkg/core/resources/store"
Expand Down Expand Up @@ -141,79 +141,79 @@ var _ = Describe("kumactl delete ", func() {
Entry("circuit-breaker", testCase{
typ: "circuit-breaker",
name: "web",
resource: func() core_model.Resource { return mesh_core.NewCircuitBreakerResource() },
resource: func() core_model.Resource { return core_mesh.NewCircuitBreakerResource() },
expectedMessage: "deleted CircuitBreaker \"web\"\n",
}),
Entry("dataplanes", testCase{
typ: "dataplane",
name: "web",
resource: func() core_model.Resource { return mesh_core.NewDataplaneResource() },
resource: func() core_model.Resource { return core_mesh.NewDataplaneResource() },
expectedMessage: "deleted Dataplane \"web\"\n",
}),
Entry("external-services", testCase{
typ: "external-service",
name: "httpbin",
resource: func() core_model.Resource { return mesh_core.NewExternalServiceResource() },
resource: func() core_model.Resource { return core_mesh.NewExternalServiceResource() },
expectedMessage: "deleted ExternalService \"httpbin\"\n",
}),
Entry("fault-injections", testCase{
typ: "fault-injection",
name: "web",
resource: func() core_model.Resource { return mesh_core.NewFaultInjectionResource() },
resource: func() core_model.Resource { return core_mesh.NewFaultInjectionResource() },
expectedMessage: "deleted FaultInjection \"web\"\n",
}),
Entry("healthchecks", testCase{
typ: "healthcheck",
name: "web-to-backend",
resource: func() core_model.Resource { return mesh_core.NewHealthCheckResource() },
resource: func() core_model.Resource { return core_mesh.NewHealthCheckResource() },
expectedMessage: "deleted HealthCheck \"web-to-backend\"\n",
}),
Entry("proxytemplate", testCase{
typ: "proxytemplate",
name: "test-pt",
resource: func() core_model.Resource { return mesh_core.NewProxyTemplateResource() },
resource: func() core_model.Resource { return core_mesh.NewProxyTemplateResource() },
expectedMessage: "deleted ProxyTemplate \"test-pt\"\n",
}),
Entry("retries", testCase{
typ: "retry",
name: "web-to-backend",
resource: func() core_model.Resource { return mesh_core.NewRetryResource() },
resource: func() core_model.Resource { return core_mesh.NewRetryResource() },
expectedMessage: "deleted Retry \"web-to-backend\"\n",
}),
Entry("rate-limits", testCase{
typ: "rate-limit",
name: "100-rps",
resource: func() core_model.Resource { return mesh_core.NewRateLimitResource() },
resource: func() core_model.Resource { return core_mesh.NewRateLimitResource() },
expectedMessage: "deleted RateLimit \"100-rps\"\n",
}),
Entry("timeouts", testCase{
typ: "timeout",
name: "web",
resource: func() core_model.Resource { return mesh_core.NewTimeoutResource() },
resource: func() core_model.Resource { return core_mesh.NewTimeoutResource() },
expectedMessage: "deleted Timeout \"web\"\n",
}),
Entry("traffic-logs", testCase{
typ: "traffic-log",
name: "all-requests",
resource: func() core_model.Resource { return mesh_core.NewTrafficLogResource() },
resource: func() core_model.Resource { return core_mesh.NewTrafficLogResource() },
expectedMessage: "deleted TrafficLog \"all-requests\"\n",
}),
Entry("traffic-permissions", testCase{
typ: "traffic-permission",
name: "everyone-to-everyone",
resource: func() core_model.Resource { return mesh_core.NewTrafficPermissionResource() },
resource: func() core_model.Resource { return core_mesh.NewTrafficPermissionResource() },
expectedMessage: "deleted TrafficPermission \"everyone-to-everyone\"\n",
}),
Entry("traffic-routes", testCase{
typ: "traffic-route",
name: "web-to-backend",
resource: func() core_model.Resource { return mesh_core.NewTrafficRouteResource() },
resource: func() core_model.Resource { return core_mesh.NewTrafficRouteResource() },
expectedMessage: "deleted TrafficRoute \"web-to-backend\"\n",
}),
Entry("traffic-traces", testCase{
typ: "traffic-trace",
name: "web",
resource: func() core_model.Resource { return mesh_core.NewTrafficTraceResource() },
resource: func() core_model.Resource { return core_mesh.NewTrafficTraceResource() },
expectedMessage: "deleted TrafficTrace \"web\"\n",
}),
Entry("secrets", testCase{
Expand Down Expand Up @@ -258,7 +258,7 @@ var _ = Describe("kumactl delete ", func() {
Entry("meshes", testCase{
typ: "mesh",
name: "test-mesh",
resource: func() core_model.Resource { return mesh_core.NewMeshResource() },
resource: func() core_model.Resource { return core_mesh.NewMeshResource() },
expectedMessage: "deleted Mesh \"test-mesh\"\n",
}),
Entry("global-secrets", testCase{
Expand Down Expand Up @@ -293,55 +293,55 @@ var _ = Describe("kumactl delete ", func() {
Entry("dataplanes", testCase{
typ: "dataplane",
name: "web",
resource: func() core_model.Resource { return mesh_core.NewDataplaneResource() },
resource: func() core_model.Resource { return core_mesh.NewDataplaneResource() },
expectedMessage: "Error: there is no Dataplane with name \"web\"\n",
}),
Entry("healthchecks", testCase{
typ: "healthcheck",
name: "web-to-backend",
resource: func() core_model.Resource { return mesh_core.NewHealthCheckResource() },
resource: func() core_model.Resource { return core_mesh.NewHealthCheckResource() },
expectedMessage: "Error: there is no HealthCheck with name \"web-to-backend\"\n",
}),
Entry("retries", testCase{
typ: "retry",
name: "web-to-backend",
resource: func() core_model.Resource { return mesh_core.NewRetryResource() },
resource: func() core_model.Resource { return core_mesh.NewRetryResource() },
expectedMessage: "Error: there is no Retry with name \"web-to-backend\"\n",
}),
Entry("traffic-permissions", testCase{
typ: "traffic-permission",
name: "everyone-to-everyone",
resource: func() core_model.Resource { return mesh_core.NewTrafficPermissionResource() },
resource: func() core_model.Resource { return core_mesh.NewTrafficPermissionResource() },
expectedMessage: "Error: there is no TrafficPermission with name \"everyone-to-everyone\"\n",
}),
Entry("traffic-logs", testCase{
typ: "traffic-log",
name: "all-requests",
resource: func() core_model.Resource { return mesh_core.NewTrafficLogResource() },
resource: func() core_model.Resource { return core_mesh.NewTrafficLogResource() },
expectedMessage: "Error: there is no TrafficLog with name \"all-requests\"\n",
}),
Entry("traffic-routes", testCase{
typ: "traffic-route",
name: "web-to-backend",
resource: func() core_model.Resource { return mesh_core.NewTrafficRouteResource() },
resource: func() core_model.Resource { return core_mesh.NewTrafficRouteResource() },
expectedMessage: "Error: there is no TrafficRoute with name \"web-to-backend\"\n",
}),
Entry("traffic-traces", testCase{
typ: "traffic-trace",
name: "web",
resource: func() core_model.Resource { return mesh_core.NewTrafficRouteResource() },
resource: func() core_model.Resource { return core_mesh.NewTrafficRouteResource() },
expectedMessage: "Error: there is no TrafficTrace with name \"web\"\n",
}),
Entry("fault-injections", testCase{
typ: "fault-injection",
name: "web",
resource: func() core_model.Resource { return mesh_core.NewFaultInjectionResource() },
resource: func() core_model.Resource { return core_mesh.NewFaultInjectionResource() },
expectedMessage: "Error: there is no FaultInjection with name \"web\"\n",
}),
Entry("fault-injections", testCase{
typ: "circuit-breaker",
name: "web",
resource: func() core_model.Resource { return mesh_core.NewCircuitBreakerResource() },
resource: func() core_model.Resource { return core_mesh.NewCircuitBreakerResource() },
expectedMessage: "Error: there is no CircuitBreaker with name \"web\"\n",
}),
Entry("secret", testCase{
Expand Down
42 changes: 21 additions & 21 deletions app/kumactl/cmd/get/get_circuit_breakers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (
"google.golang.org/protobuf/types/known/durationpb"
"google.golang.org/protobuf/types/known/wrapperspb"

kuma_mesh "github.com/kumahq/kuma/api/mesh/v1alpha1"
mesh_proto "github.com/kumahq/kuma/api/mesh/v1alpha1"
"github.com/kumahq/kuma/app/kumactl/cmd"
kumactl_cmd "github.com/kumahq/kuma/app/kumactl/pkg/cmd"
config_proto "github.com/kumahq/kuma/pkg/config/app/kumactl/v1alpha1"
Expand All @@ -32,33 +32,33 @@ var _ = Describe("kumactl get circuit-breakers", func() {

circuitBreakerResources := []*mesh.CircuitBreakerResource{
{
Spec: &kuma_mesh.CircuitBreaker{
Sources: []*kuma_mesh.Selector{
Spec: &mesh_proto.CircuitBreaker{
Sources: []*mesh_proto.Selector{
{
Match: map[string]string{
"service": "frontend",
"version": "0.1",
},
},
},
Destinations: []*kuma_mesh.Selector{
Destinations: []*mesh_proto.Selector{
{
Match: map[string]string{
"service": "backend",
},
},
},
Conf: &kuma_mesh.CircuitBreaker_Conf{
Conf: &mesh_proto.CircuitBreaker_Conf{
Interval: &durationpb.Duration{Seconds: 5},
BaseEjectionTime: &durationpb.Duration{Seconds: 5},
MaxEjectionPercent: &wrapperspb.UInt32Value{Value: 50},
SplitExternalAndLocalErrors: false,
Detectors: &kuma_mesh.CircuitBreaker_Conf_Detectors{
TotalErrors: &kuma_mesh.CircuitBreaker_Conf_Detectors_Errors{},
GatewayErrors: &kuma_mesh.CircuitBreaker_Conf_Detectors_Errors{},
LocalErrors: &kuma_mesh.CircuitBreaker_Conf_Detectors_Errors{},
StandardDeviation: &kuma_mesh.CircuitBreaker_Conf_Detectors_StandardDeviation{},
Failure: &kuma_mesh.CircuitBreaker_Conf_Detectors_Failure{},
Detectors: &mesh_proto.CircuitBreaker_Conf_Detectors{
TotalErrors: &mesh_proto.CircuitBreaker_Conf_Detectors_Errors{},
GatewayErrors: &mesh_proto.CircuitBreaker_Conf_Detectors_Errors{},
LocalErrors: &mesh_proto.CircuitBreaker_Conf_Detectors_Errors{},
StandardDeviation: &mesh_proto.CircuitBreaker_Conf_Detectors_StandardDeviation{},
Failure: &mesh_proto.CircuitBreaker_Conf_Detectors_Failure{},
},
},
},
Expand All @@ -68,37 +68,37 @@ var _ = Describe("kumactl get circuit-breakers", func() {
},
},
{
Spec: &kuma_mesh.CircuitBreaker{
Sources: []*kuma_mesh.Selector{
Spec: &mesh_proto.CircuitBreaker{
Sources: []*mesh_proto.Selector{
{
Match: map[string]string{
"service": "web",
"version": "0.1",
},
},
},
Destinations: []*kuma_mesh.Selector{
Destinations: []*mesh_proto.Selector{
{
Match: map[string]string{
"service": "redis",
},
},
},
Conf: &kuma_mesh.CircuitBreaker_Conf{
Conf: &mesh_proto.CircuitBreaker_Conf{
Interval: &durationpb.Duration{Seconds: 5},
BaseEjectionTime: &durationpb.Duration{Seconds: 5},
MaxEjectionPercent: &wrapperspb.UInt32Value{Value: 50},
SplitExternalAndLocalErrors: false,
Detectors: &kuma_mesh.CircuitBreaker_Conf_Detectors{
TotalErrors: &kuma_mesh.CircuitBreaker_Conf_Detectors_Errors{Consecutive: &wrapperspb.UInt32Value{Value: 20}},
GatewayErrors: &kuma_mesh.CircuitBreaker_Conf_Detectors_Errors{Consecutive: &wrapperspb.UInt32Value{Value: 10}},
LocalErrors: &kuma_mesh.CircuitBreaker_Conf_Detectors_Errors{Consecutive: &wrapperspb.UInt32Value{Value: 2}},
StandardDeviation: &kuma_mesh.CircuitBreaker_Conf_Detectors_StandardDeviation{
Detectors: &mesh_proto.CircuitBreaker_Conf_Detectors{
TotalErrors: &mesh_proto.CircuitBreaker_Conf_Detectors_Errors{Consecutive: &wrapperspb.UInt32Value{Value: 20}},
GatewayErrors: &mesh_proto.CircuitBreaker_Conf_Detectors_Errors{Consecutive: &wrapperspb.UInt32Value{Value: 10}},
LocalErrors: &mesh_proto.CircuitBreaker_Conf_Detectors_Errors{Consecutive: &wrapperspb.UInt32Value{Value: 2}},
StandardDeviation: &mesh_proto.CircuitBreaker_Conf_Detectors_StandardDeviation{
RequestVolume: &wrapperspb.UInt32Value{Value: 20},
MinimumHosts: &wrapperspb.UInt32Value{Value: 3},
Factor: &wrapperspb.DoubleValue{Value: 1.9},
},
Failure: &kuma_mesh.CircuitBreaker_Conf_Detectors_Failure{
Failure: &mesh_proto.CircuitBreaker_Conf_Detectors_Failure{
RequestVolume: &wrapperspb.UInt32Value{Value: 20},
MinimumHosts: &wrapperspb.UInt32Value{Value: 3},
Threshold: &wrapperspb.UInt32Value{Value: 85},
Expand Down
6 changes: 3 additions & 3 deletions app/kumactl/cmd/get/get_dataplanes_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
"github.com/kumahq/kuma/app/kumactl/cmd"
kumactl_cmd "github.com/kumahq/kuma/app/kumactl/pkg/cmd"
config_proto "github.com/kumahq/kuma/pkg/config/app/kumactl/v1alpha1"
mesh_core "github.com/kumahq/kuma/pkg/core/resources/apis/mesh"
core_mesh "github.com/kumahq/kuma/pkg/core/resources/apis/mesh"
core_model "github.com/kumahq/kuma/pkg/core/resources/model"
core_store "github.com/kumahq/kuma/pkg/core/resources/store"
memory_resources "github.com/kumahq/kuma/pkg/plugins/resources/memory"
Expand All @@ -28,10 +28,10 @@ import (

var _ = Describe("kumactl get dataplanes", func() {

var dataplanes []*mesh_core.DataplaneResource
var dataplanes []*core_mesh.DataplaneResource
BeforeEach(func() {
// setup
dataplanes = []*mesh_core.DataplaneResource{
dataplanes = []*core_mesh.DataplaneResource{
{
Meta: &test_model.ResourceMeta{
Mesh: "default",
Expand Down
6 changes: 3 additions & 3 deletions app/kumactl/cmd/get/get_external_services_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
"github.com/kumahq/kuma/app/kumactl/cmd"
kumactl_cmd "github.com/kumahq/kuma/app/kumactl/pkg/cmd"
config_proto "github.com/kumahq/kuma/pkg/config/app/kumactl/v1alpha1"
mesh_core "github.com/kumahq/kuma/pkg/core/resources/apis/mesh"
core_mesh "github.com/kumahq/kuma/pkg/core/resources/apis/mesh"
core_model "github.com/kumahq/kuma/pkg/core/resources/model"
core_store "github.com/kumahq/kuma/pkg/core/resources/store"
memory_resources "github.com/kumahq/kuma/pkg/plugins/resources/memory"
Expand All @@ -28,10 +28,10 @@ import (

var _ = Describe("kumactl get external-services", func() {

var externalServices []*mesh_core.ExternalServiceResource
var externalServices []*core_mesh.ExternalServiceResource
BeforeEach(func() {
// setup
externalServices = []*mesh_core.ExternalServiceResource{
externalServices = []*core_mesh.ExternalServiceResource{
{
Meta: &test_model.ResourceMeta{
Mesh: "default",
Expand Down
6 changes: 3 additions & 3 deletions app/kumactl/cmd/get/get_healthchecks_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
"github.com/kumahq/kuma/app/kumactl/cmd"
kumactl_cmd "github.com/kumahq/kuma/app/kumactl/pkg/cmd"
config_proto "github.com/kumahq/kuma/pkg/config/app/kumactl/v1alpha1"
mesh_core "github.com/kumahq/kuma/pkg/core/resources/apis/mesh"
core_mesh "github.com/kumahq/kuma/pkg/core/resources/apis/mesh"
core_model "github.com/kumahq/kuma/pkg/core/resources/model"
core_store "github.com/kumahq/kuma/pkg/core/resources/store"
memory_resources "github.com/kumahq/kuma/pkg/plugins/resources/memory"
Expand All @@ -28,9 +28,9 @@ import (

var _ = Describe("kumactl get healthchecks", func() {

var sampleHealthChecks []*mesh_core.HealthCheckResource
var sampleHealthChecks []*core_mesh.HealthCheckResource
BeforeEach(func() {
sampleHealthChecks = []*mesh_core.HealthCheckResource{
sampleHealthChecks = []*core_mesh.HealthCheckResource{
{
Meta: &test_model.ResourceMeta{
Mesh: "default",
Expand Down
6 changes: 3 additions & 3 deletions app/kumactl/cmd/get/get_proxytemplates_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
"github.com/kumahq/kuma/app/kumactl/cmd"
kumactl_cmd "github.com/kumahq/kuma/app/kumactl/pkg/cmd"
config_proto "github.com/kumahq/kuma/pkg/config/app/kumactl/v1alpha1"
mesh_core "github.com/kumahq/kuma/pkg/core/resources/apis/mesh"
core_mesh "github.com/kumahq/kuma/pkg/core/resources/apis/mesh"
core_model "github.com/kumahq/kuma/pkg/core/resources/model"
core_store "github.com/kumahq/kuma/pkg/core/resources/store"
memory_resources "github.com/kumahq/kuma/pkg/plugins/resources/memory"
Expand All @@ -28,10 +28,10 @@ import (

var _ = Describe("kumactl get proxytemplates", func() {

var sampleProxyTemplates []*mesh_core.ProxyTemplateResource
var sampleProxyTemplates []*core_mesh.ProxyTemplateResource

BeforeEach(func() {
sampleProxyTemplates = []*mesh_core.ProxyTemplateResource{
sampleProxyTemplates = []*core_mesh.ProxyTemplateResource{
{
Meta: &test_model.ResourceMeta{
Mesh: "default",
Expand Down
Loading

0 comments on commit 2e3ace0

Please sign in to comment.