Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add godot linter and fix issues #1042

Merged
merged 1 commit into from
Feb 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ linters:
# enables all defaults + the below, `golangci-lint linters` to see the list of active linters.
enable:
- gofmt
- godot
# TODO: re-enable things as we have main cleaned up vs the defaults
#- stylecheck
#- goconst
Expand Down
20 changes: 20 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -39,17 +39,37 @@ control-plane-clean: ## Delete bin and pkg dirs.
$(CURDIR)/control-plane/bin \
$(CURDIR)/control-plane/pkg

control-plane-lint: ## Run linter in the control-plane directory.
cd control-plane; golangci-lint run -c ../.golangci.yml

ctrl-generate: get-controller-gen ## Run CRD code generation.
cd control-plane; $(CONTROLLER_GEN) object:headerFile="build-support/controller/boilerplate.go.txt" paths="./..."




# ===========> CLI Targets

cli-lint: ## Run linter in the control-plane directory.
cd cli; golangci-lint run -c ../.golangci.yml




# ===========> Acceptance Tests Targets

acceptance-lint: ## Run linter in the control-plane directory.
cd acceptance; golangci-lint run -c ../.golangci.yml


# ===========> Shared Targets

help: ## Show targets and their descriptions.
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'

lint: ## Run linter in the control-plane, cli, and acceptance directories.
for p in control-plane cli acceptance; do cd $$p; golangci-lint run --path-prefix $$p -c ../.golangci.yml; cd ..; done

ctrl-manifests: get-controller-gen ## Generate CRD manifests.
cd control-plane; $(CONTROLLER_GEN) $(CRD_OPTIONS) rbac:roleName=manager-role webhook paths="./..." output:crd:artifacts:config=config/crd/bases
make copy-crds-to-chart
Expand Down
2 changes: 1 addition & 1 deletion acceptance/framework/consul/cli_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const (
CLIReleaseName = "consul"
)

// CLICluster
// CLICluster.
type CLICluster struct {
ctx environment.TestContext
namespace string
Expand Down
4 changes: 2 additions & 2 deletions acceptance/framework/consul/consul_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (
"k8s.io/client-go/kubernetes"
)

// Cluster represents a consul cluster object
// Cluster represents a consul cluster object.
type Cluster interface {
Create(t *testing.T)
Destroy(t *testing.T)
Expand All @@ -38,7 +38,7 @@ type Cluster interface {
}

// HelmCluster implements Cluster and uses Helm
// to create, destroy, and upgrade consul
// to create, destroy, and upgrade consul.
type HelmCluster struct {
// ACLToken is an optional ACL token that will be used to create
// a Consul API client. If not provided, we will attempt to read
Expand Down
2 changes: 1 addition & 1 deletion acceptance/framework/environment/environment.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const (
)

// TestEnvironment represents the infrastructure environment of the test,
// such as the kubernetes cluster(s) the test is running against
// such as the kubernetes cluster(s) the test is running against.
type TestEnvironment interface {
DefaultContext(t *testing.T) TestContext
Context(t *testing.T, name string) TestContext
Expand Down
2 changes: 1 addition & 1 deletion acceptance/tests/mesh-gateway/mesh_gateway_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
const staticClientName = "static-client"

// Test that Connect and wan federation over mesh gateways work in a default installation
// i.e. without ACLs because TLS is required for WAN federation over mesh gateways
// i.e. without ACLs because TLS is required for WAN federation over mesh gateways.
func TestMeshGatewayDefault(t *testing.T) {
env := suite.Environment()
cfg := suite.Config()
Expand Down
2 changes: 1 addition & 1 deletion cli/common/flag/flag_bool.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"github.com/posener/complete"
)

// -- BoolVar and boolValue
// -- BoolVar and boolValue.
type BoolVar struct {
Name string
Aliases []string
Expand Down
2 changes: 1 addition & 1 deletion cli/common/flag/flag_enum.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"github.com/posener/complete"
)

// -- EnumVar and enumValue
// -- EnumVar and enumValue.
type EnumVar struct {
Name string
Aliases []string
Expand Down
2 changes: 1 addition & 1 deletion cli/common/flag/flag_enum_single.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"github.com/posener/complete"
)

// -- EnumVar and enumValue
// -- EnumVar and enumValue.
type EnumSingleVar struct {
Name string
Aliases []string
Expand Down
2 changes: 1 addition & 1 deletion cli/common/flag/flag_float.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"github.com/posener/complete"
)

// -- Float64Var and float64Value
// -- Float64Var and float64Value.
type Float64Var struct {
Name string
Aliases []string
Expand Down
8 changes: 4 additions & 4 deletions cli/common/flag/flag_int.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"github.com/posener/complete"
)

// -- IntVar and intValue
// -- IntVar and intValue.
type IntVar struct {
Name string
Aliases []string
Expand Down Expand Up @@ -79,7 +79,7 @@ func (i *intValue) String() string { return strconv.Itoa(int(*i.target)) }
func (i *intValue) Example() string { return "int" }
func (i *intValue) Hidden() bool { return i.hidden }

// -- Int64Var and int64Value
// -- Int64Var and int64Value.
type Int64Var struct {
Name string
Aliases []string
Expand Down Expand Up @@ -151,7 +151,7 @@ func (i *int64Value) String() string { return strconv.FormatInt(int64(*i.targe
func (i *int64Value) Example() string { return "int" }
func (i *int64Value) Hidden() bool { return i.hidden }

// -- UintVar && uintValue
// -- UintVar && uintValue.
type UintVar struct {
Name string
Aliases []string
Expand Down Expand Up @@ -223,7 +223,7 @@ func (i *uintValue) String() string { return strconv.FormatUint(uint64(*i.targ
func (i *uintValue) Example() string { return "uint" }
func (i *uintValue) Hidden() bool { return i.hidden }

// -- Uint64Var and uint64Value
// -- Uint64Var and uint64Value.
type Uint64Var struct {
Name string
Aliases []string
Expand Down
2 changes: 1 addition & 1 deletion cli/common/flag/flag_string.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"github.com/posener/complete"
)

// -- StringVar and stringValue
// -- StringVar and stringValue.
type StringVar struct {
Name string
Aliases []string
Expand Down
2 changes: 1 addition & 1 deletion cli/common/flag/flag_string_map.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"github.com/posener/complete"
)

// -- StringMapVar and stringMapValue
// -- StringMapVar and stringMapValue.
type StringMapVar struct {
Name string
Aliases []string
Expand Down
2 changes: 1 addition & 1 deletion cli/common/flag/flag_string_slice.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"github.com/posener/complete"
)

// -- StringSliceVar and stringSliceValue
// -- StringSliceVar and stringSliceValue.
type StringSliceVar struct {
Name string
Aliases []string
Expand Down
2 changes: 1 addition & 1 deletion cli/common/flag/flag_time.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"github.com/posener/complete"
)

// -- DurationVar and durationValue
// -- DurationVar and durationValue.
type DurationVar struct {
Name string
Aliases []string
Expand Down
2 changes: 1 addition & 1 deletion cli/common/flag/flag_var.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"github.com/posener/complete"
)

// -- VarFlag
// -- VarFlag.
type VarFlag struct {
Name string
Aliases []string
Expand Down
12 changes: 6 additions & 6 deletions cli/common/terminal/basic.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (
"github.com/mattn/go-isatty"
)

// basicUI
// basicUI.
type basicUI struct {
ctx context.Context
}
Expand All @@ -26,7 +26,7 @@ func NewBasicUI(ctx context.Context) *basicUI {
}
}

// Input implements UI
// Input implements UI.
func (ui *basicUI) Input(input *Input) (string, error) {
var buf bytes.Buffer

Expand Down Expand Up @@ -67,12 +67,12 @@ func (ui *basicUI) Input(input *Input) (string, error) {
}
}

// Interactive implements UI
// Interactive implements UI.
func (ui *basicUI) Interactive() bool {
return isatty.IsTerminal(os.Stdin.Fd())
}

// Output implements UI
// Output implements UI.
func (ui *basicUI) Output(msg string, raw ...interface{}) {
msg, style, w := Interpret(msg, raw...)

Expand Down Expand Up @@ -112,7 +112,7 @@ func (ui *basicUI) Output(msg string, raw ...interface{}) {
fmt.Fprintln(w, msg)
}

// NamedValues implements UI
// NamedValues implements UI.
func (ui *basicUI) NamedValues(rows []NamedValue, opts ...Option) {
cfg := &config{Writer: color.Output}
for _, opt := range opts {
Expand Down Expand Up @@ -143,7 +143,7 @@ func (ui *basicUI) NamedValues(rows []NamedValue, opts ...Option) {
_, _ = colorInfo.Fprintln(cfg.Writer, buf.String())
}

// OutputWriters implements UI
// OutputWriters implements UI.
func (ui *basicUI) OutputWriters() (io.Writer, io.Writer, error) {
return os.Stdout, os.Stderr, nil
}
2 changes: 1 addition & 1 deletion cli/common/terminal/table.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func (t *Table) Rich(cols []string, colors []string) {
t.Rows = append(t.Rows, row)
}

// Table implements UI
// Table implements UI.
func (u *basicUI) Table(tbl *Table, opts ...Option) {
// Build our config and set our options
cfg := &config{Writer: color.Output}
Expand Down
4 changes: 2 additions & 2 deletions cli/common/terminal/ui.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
// ErrNonInteractive is returned when Input is called on a non-Interactive UI.
var ErrNonInteractive = errors.New("noninteractive UI doesn't support this operation")

// Passed to UI.NamedValues to provide a nicely formatted key: value output
// Passed to UI.NamedValues to provide a nicely formatted key: value output.
type NamedValue struct {
Name string
Value interface{}
Expand Down Expand Up @@ -66,7 +66,7 @@ type Input struct {
Secret bool
}

// Interpret decomposes the msg and arguments into the message, style, and writer
// Interpret decomposes the msg and arguments into the message, style, and writer.
func Interpret(msg string, raw ...interface{}) (string, string, io.Writer) {
// Build our args and options
var args []interface{}
Expand Down
4 changes: 2 additions & 2 deletions control-plane/api/v1alpha1/exportedservices_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,14 @@ type ExportedServices struct {

//+kubebuilder:object:root=true

// ExportedServicesList contains a list of ExportedServices
// ExportedServicesList contains a list of ExportedServices.
type ExportedServicesList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []ExportedServices `json:"items"`
}

// ExportedServicesSpec defines the desired state of ExportedServices
// ExportedServicesSpec defines the desired state of ExportedServices.
type ExportedServicesSpec struct {
// Services is a list of services to be exported and the list of partitions
// to expose them to.
Expand Down
4 changes: 2 additions & 2 deletions control-plane/api/v1alpha1/groupversion_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ import (
const ConsulHashicorpGroup string = "consul.hashicorp.com"

var (
// GroupVersion is group version used to register these objects
// GroupVersion is group version used to register these objects.
GroupVersion = schema.GroupVersion{Group: "consul.hashicorp.com", Version: "v1alpha1"}

// SchemeBuilder is used to add go types to the GroupVersionKind scheme
// SchemeBuilder is used to add go types to the GroupVersionKind scheme.
SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion}

// AddToScheme adds the types in this group-version to the given scheme.
Expand Down
4 changes: 2 additions & 2 deletions control-plane/api/v1alpha1/ingressgateway_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,14 @@ type IngressGateway struct {

// +kubebuilder:object:root=true

// IngressGatewayList contains a list of IngressGateway
// IngressGatewayList contains a list of IngressGateway.
type IngressGatewayList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []IngressGateway `json:"items"`
}

// IngressGatewaySpec defines the desired state of IngressGateway
// IngressGatewaySpec defines the desired state of IngressGateway.
type IngressGatewaySpec struct {
// TLS holds the TLS configuration for this gateway.
TLS GatewayTLSConfig `json:"tls,omitempty"`
Expand Down
4 changes: 2 additions & 2 deletions control-plane/api/v1alpha1/mesh_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,14 @@ type Mesh struct {

//+kubebuilder:object:root=true

// MeshList contains a list of Mesh
// MeshList contains a list of Mesh.
type MeshList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []Mesh `json:"items"`
}

// MeshSpec defines the desired state of Mesh
// MeshSpec defines the desired state of Mesh.
type MeshSpec struct {
TransparentProxy TransparentProxyMeshConfig `json:"transparentProxy,omitempty"`
}
Expand Down
4 changes: 2 additions & 2 deletions control-plane/api/v1alpha1/proxydefaults_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ type ProxyDefaults struct {

// +kubebuilder:object:root=true

// ProxyDefaultsList contains a list of ProxyDefaults
// ProxyDefaultsList contains a list of ProxyDefaults.
type ProxyDefaultsList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Expand All @@ -50,7 +50,7 @@ type ProxyDefaultsList struct {

// RawMessage for Config based on recommendation here: https://github.com/kubernetes-sigs/controller-tools/issues/294#issuecomment-518380816

// ProxyDefaultsSpec defines the desired state of ProxyDefaults
// ProxyDefaultsSpec defines the desired state of ProxyDefaults.
type ProxyDefaultsSpec struct {
// Config is an arbitrary map of configuration values used by Connect proxies.
// Any values that your proxy allows can be configured globally here.
Expand Down
4 changes: 2 additions & 2 deletions control-plane/api/v1alpha1/servicedefaults_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,14 @@ type ServiceDefaults struct {

// +kubebuilder:object:root=true

// ServiceDefaultsList contains a list of ServiceDefaults
// ServiceDefaultsList contains a list of ServiceDefaults.
type ServiceDefaultsList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []ServiceDefaults `json:"items"`
}

// ServiceDefaultsSpec defines the desired state of ServiceDefaults
// ServiceDefaultsSpec defines the desired state of ServiceDefaults.
type ServiceDefaultsSpec struct {
// Protocol sets the protocol of the service. This is used by Connect proxies for
// things like observability features and to unlock usage of the
Expand Down
Loading