From 3bfce3671043be3bad4f59d08c83bd2fd925c648 Mon Sep 17 00:00:00 2001 From: Iryna Shustava Date: Tue, 22 Feb 2022 11:52:27 -0700 Subject: [PATCH] Add godot linter and fix issues Also, add makefile targets for linters --- .golangci.yml | 1 + Makefile | 20 +++++++++++ acceptance/framework/consul/cli_cluster.go | 2 +- acceptance/framework/consul/consul_cluster.go | 4 +-- .../framework/environment/environment.go | 2 +- .../tests/mesh-gateway/mesh_gateway_test.go | 2 +- cli/common/flag/flag_bool.go | 2 +- cli/common/flag/flag_enum.go | 2 +- cli/common/flag/flag_enum_single.go | 2 +- cli/common/flag/flag_float.go | 2 +- cli/common/flag/flag_int.go | 8 ++--- cli/common/flag/flag_string.go | 2 +- cli/common/flag/flag_string_map.go | 2 +- cli/common/flag/flag_string_slice.go | 2 +- cli/common/flag/flag_time.go | 2 +- cli/common/flag/flag_var.go | 2 +- cli/common/terminal/basic.go | 12 +++---- cli/common/terminal/table.go | 2 +- cli/common/terminal/ui.go | 4 +-- .../api/v1alpha1/exportedservices_types.go | 4 +-- .../api/v1alpha1/groupversion_info.go | 4 +-- .../api/v1alpha1/ingressgateway_types.go | 4 +-- control-plane/api/v1alpha1/mesh_types.go | 4 +-- .../api/v1alpha1/proxydefaults_types.go | 4 +-- .../api/v1alpha1/servicedefaults_types.go | 4 +-- .../api/v1alpha1/serviceintentions_types.go | 4 +-- .../api/v1alpha1/serviceresolver_types.go | 4 +-- .../api/v1alpha1/servicerouter_types.go | 4 +-- .../api/v1alpha1/servicesplitter_types.go | 4 +-- control-plane/api/v1alpha1/shared_types.go | 2 +- control-plane/api/v1alpha1/status.go | 8 ++--- .../api/v1alpha1/terminatinggateway_types.go | 6 ++-- control-plane/catalog/to-consul/resource.go | 12 +++---- .../catalog/to-consul/resource_test.go | 34 +++++++++---------- control-plane/catalog/to-consul/syncer.go | 4 +-- control-plane/catalog/to-consul/testing.go | 2 +- control-plane/catalog/to-k8s/sink.go | 2 +- control-plane/catalog/to-k8s/sink_test.go | 6 ++-- control-plane/catalog/to-k8s/source_test.go | 6 ++-- control-plane/connect-inject/annotations.go | 6 ++-- .../connect-inject/container_init_test.go | 2 +- control-plane/connect-inject/handler_test.go | 4 +-- .../controller/configentry_controller_test.go | 4 +-- .../controller/exportedservices_controller.go | 2 +- control-plane/controller/mesh_controller.go | 2 +- .../controller/proxydefaults_controller.go | 2 +- .../serviceintentions_controller.go | 2 +- .../controller/servicesplitter_controller.go | 2 +- control-plane/helper/cert/source_gen.go | 2 +- control-plane/helper/cert/source_gen_test.go | 4 +-- .../helper/coalesce/coalesce_test.go | 6 ++-- control-plane/helper/controller/controller.go | 4 +-- .../helper/controller/controller_test.go | 4 +-- .../subcommand/common/common_test.go | 2 +- .../subcommand/consul-sidecar/command.go | 2 +- .../subcommand/consul-sidecar/command_test.go | 2 +- .../subcommand/flags/flag_map_value.go | 2 +- .../get-consul-client-ca/command_test.go | 4 +-- .../subcommand/server-acl-init/rules.go | 2 +- .../subcommand/sync-catalog/command.go | 2 +- .../subcommand/sync-catalog/command_test.go | 14 ++++---- .../webhook-cert-manager/command.go | 2 +- 62 files changed, 148 insertions(+), 127 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index d6f534e8be..99e8b2ee8c 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -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 diff --git a/Makefile b/Makefile index 49b8822d1b..1cd32824cb 100644 --- a/Makefile +++ b/Makefile @@ -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 diff --git a/acceptance/framework/consul/cli_cluster.go b/acceptance/framework/consul/cli_cluster.go index 71662b88d8..27191b7fa3 100644 --- a/acceptance/framework/consul/cli_cluster.go +++ b/acceptance/framework/consul/cli_cluster.go @@ -29,7 +29,7 @@ const ( CLIReleaseName = "consul" ) -// CLICluster +// CLICluster. type CLICluster struct { ctx environment.TestContext namespace string diff --git a/acceptance/framework/consul/consul_cluster.go b/acceptance/framework/consul/consul_cluster.go index f2586b5c5b..3842809660 100644 --- a/acceptance/framework/consul/consul_cluster.go +++ b/acceptance/framework/consul/consul_cluster.go @@ -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) @@ -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 diff --git a/acceptance/framework/environment/environment.go b/acceptance/framework/environment/environment.go index 7c8a89e15b..15121b97e3 100644 --- a/acceptance/framework/environment/environment.go +++ b/acceptance/framework/environment/environment.go @@ -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 diff --git a/acceptance/tests/mesh-gateway/mesh_gateway_test.go b/acceptance/tests/mesh-gateway/mesh_gateway_test.go index d6e4be90be..230f5b01f4 100644 --- a/acceptance/tests/mesh-gateway/mesh_gateway_test.go +++ b/acceptance/tests/mesh-gateway/mesh_gateway_test.go @@ -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() diff --git a/cli/common/flag/flag_bool.go b/cli/common/flag/flag_bool.go index 6240cf2a63..2862c2fe40 100644 --- a/cli/common/flag/flag_bool.go +++ b/cli/common/flag/flag_bool.go @@ -7,7 +7,7 @@ import ( "github.com/posener/complete" ) -// -- BoolVar and boolValue +// -- BoolVar and boolValue. type BoolVar struct { Name string Aliases []string diff --git a/cli/common/flag/flag_enum.go b/cli/common/flag/flag_enum.go index 90e33069fa..ac9ecaedc1 100644 --- a/cli/common/flag/flag_enum.go +++ b/cli/common/flag/flag_enum.go @@ -8,7 +8,7 @@ import ( "github.com/posener/complete" ) -// -- EnumVar and enumValue +// -- EnumVar and enumValue. type EnumVar struct { Name string Aliases []string diff --git a/cli/common/flag/flag_enum_single.go b/cli/common/flag/flag_enum_single.go index 667f7707bd..ddef52796b 100644 --- a/cli/common/flag/flag_enum_single.go +++ b/cli/common/flag/flag_enum_single.go @@ -8,7 +8,7 @@ import ( "github.com/posener/complete" ) -// -- EnumVar and enumValue +// -- EnumVar and enumValue. type EnumSingleVar struct { Name string Aliases []string diff --git a/cli/common/flag/flag_float.go b/cli/common/flag/flag_float.go index 0a2f5c994e..1f7fcfad67 100644 --- a/cli/common/flag/flag_float.go +++ b/cli/common/flag/flag_float.go @@ -7,7 +7,7 @@ import ( "github.com/posener/complete" ) -// -- Float64Var and float64Value +// -- Float64Var and float64Value. type Float64Var struct { Name string Aliases []string diff --git a/cli/common/flag/flag_int.go b/cli/common/flag/flag_int.go index 12e87bef9c..419dabaa0e 100644 --- a/cli/common/flag/flag_int.go +++ b/cli/common/flag/flag_int.go @@ -7,7 +7,7 @@ import ( "github.com/posener/complete" ) -// -- IntVar and intValue +// -- IntVar and intValue. type IntVar struct { Name string Aliases []string @@ -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 @@ -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 @@ -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 diff --git a/cli/common/flag/flag_string.go b/cli/common/flag/flag_string.go index ee17a2916d..b16a1be16d 100644 --- a/cli/common/flag/flag_string.go +++ b/cli/common/flag/flag_string.go @@ -6,7 +6,7 @@ import ( "github.com/posener/complete" ) -// -- StringVar and stringValue +// -- StringVar and stringValue. type StringVar struct { Name string Aliases []string diff --git a/cli/common/flag/flag_string_map.go b/cli/common/flag/flag_string_map.go index 009b1d7761..5314a66655 100644 --- a/cli/common/flag/flag_string_map.go +++ b/cli/common/flag/flag_string_map.go @@ -8,7 +8,7 @@ import ( "github.com/posener/complete" ) -// -- StringMapVar and stringMapValue +// -- StringMapVar and stringMapValue. type StringMapVar struct { Name string Aliases []string diff --git a/cli/common/flag/flag_string_slice.go b/cli/common/flag/flag_string_slice.go index 7f27c245a4..b567c64936 100644 --- a/cli/common/flag/flag_string_slice.go +++ b/cli/common/flag/flag_string_slice.go @@ -7,7 +7,7 @@ import ( "github.com/posener/complete" ) -// -- StringSliceVar and stringSliceValue +// -- StringSliceVar and stringSliceValue. type StringSliceVar struct { Name string Aliases []string diff --git a/cli/common/flag/flag_time.go b/cli/common/flag/flag_time.go index 39562b765d..45dc297f3d 100644 --- a/cli/common/flag/flag_time.go +++ b/cli/common/flag/flag_time.go @@ -8,7 +8,7 @@ import ( "github.com/posener/complete" ) -// -- DurationVar and durationValue +// -- DurationVar and durationValue. type DurationVar struct { Name string Aliases []string diff --git a/cli/common/flag/flag_var.go b/cli/common/flag/flag_var.go index 7546c517f4..1b4114f16f 100644 --- a/cli/common/flag/flag_var.go +++ b/cli/common/flag/flag_var.go @@ -8,7 +8,7 @@ import ( "github.com/posener/complete" ) -// -- VarFlag +// -- VarFlag. type VarFlag struct { Name string Aliases []string diff --git a/cli/common/terminal/basic.go b/cli/common/terminal/basic.go index 2425b2d53c..d06815b8f5 100644 --- a/cli/common/terminal/basic.go +++ b/cli/common/terminal/basic.go @@ -15,7 +15,7 @@ import ( "github.com/mattn/go-isatty" ) -// basicUI +// basicUI. type basicUI struct { ctx context.Context } @@ -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 @@ -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...) @@ -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 { @@ -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 } diff --git a/cli/common/terminal/table.go b/cli/common/terminal/table.go index 4d55e0006e..c8e8c2c67b 100644 --- a/cli/common/terminal/table.go +++ b/cli/common/terminal/table.go @@ -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} diff --git a/cli/common/terminal/ui.go b/cli/common/terminal/ui.go index e7d938a408..a9baa7aa87 100644 --- a/cli/common/terminal/ui.go +++ b/cli/common/terminal/ui.go @@ -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{} @@ -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{} diff --git a/control-plane/api/v1alpha1/exportedservices_types.go b/control-plane/api/v1alpha1/exportedservices_types.go index 7d744c055d..01c54dbe17 100644 --- a/control-plane/api/v1alpha1/exportedservices_types.go +++ b/control-plane/api/v1alpha1/exportedservices_types.go @@ -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. diff --git a/control-plane/api/v1alpha1/groupversion_info.go b/control-plane/api/v1alpha1/groupversion_info.go index b6054efb6f..cdbe085af4 100644 --- a/control-plane/api/v1alpha1/groupversion_info.go +++ b/control-plane/api/v1alpha1/groupversion_info.go @@ -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. diff --git a/control-plane/api/v1alpha1/ingressgateway_types.go b/control-plane/api/v1alpha1/ingressgateway_types.go index ca32e72dd0..aef9917b49 100644 --- a/control-plane/api/v1alpha1/ingressgateway_types.go +++ b/control-plane/api/v1alpha1/ingressgateway_types.go @@ -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"` diff --git a/control-plane/api/v1alpha1/mesh_types.go b/control-plane/api/v1alpha1/mesh_types.go index c62a684f65..057ba9f071 100644 --- a/control-plane/api/v1alpha1/mesh_types.go +++ b/control-plane/api/v1alpha1/mesh_types.go @@ -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"` } diff --git a/control-plane/api/v1alpha1/proxydefaults_types.go b/control-plane/api/v1alpha1/proxydefaults_types.go index 1e38842d4b..22f498cf8e 100644 --- a/control-plane/api/v1alpha1/proxydefaults_types.go +++ b/control-plane/api/v1alpha1/proxydefaults_types.go @@ -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"` @@ -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. diff --git a/control-plane/api/v1alpha1/servicedefaults_types.go b/control-plane/api/v1alpha1/servicedefaults_types.go index f5b0160397..fe4b85c755 100644 --- a/control-plane/api/v1alpha1/servicedefaults_types.go +++ b/control-plane/api/v1alpha1/servicedefaults_types.go @@ -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 diff --git a/control-plane/api/v1alpha1/serviceintentions_types.go b/control-plane/api/v1alpha1/serviceintentions_types.go index 2a776e8209..0bab3adc74 100644 --- a/control-plane/api/v1alpha1/serviceintentions_types.go +++ b/control-plane/api/v1alpha1/serviceintentions_types.go @@ -40,14 +40,14 @@ type ServiceIntentions struct { // +kubebuilder:object:root=true -// ServiceIntentionsList contains a list of ServiceIntentions +// ServiceIntentionsList contains a list of ServiceIntentions. type ServiceIntentionsList struct { metav1.TypeMeta `json:",inline"` metav1.ListMeta `json:"metadata,omitempty"` Items []ServiceIntentions `json:"items"` } -// ServiceIntentionsSpec defines the desired state of ServiceIntentions +// ServiceIntentionsSpec defines the desired state of ServiceIntentions. type ServiceIntentionsSpec struct { // Destination is the intention destination that will have the authorization granted to. Destination Destination `json:"destination,omitempty"` diff --git a/control-plane/api/v1alpha1/serviceresolver_types.go b/control-plane/api/v1alpha1/serviceresolver_types.go index 7ce67cb370..2d5fc1e8c8 100644 --- a/control-plane/api/v1alpha1/serviceresolver_types.go +++ b/control-plane/api/v1alpha1/serviceresolver_types.go @@ -37,14 +37,14 @@ type ServiceResolver struct { // +kubebuilder:object:root=true -// ServiceResolverList contains a list of ServiceResolver +// ServiceResolverList contains a list of ServiceResolver. type ServiceResolverList struct { metav1.TypeMeta `json:",inline"` metav1.ListMeta `json:"metadata,omitempty"` Items []ServiceResolver `json:"items"` } -// ServiceResolverSpec defines the desired state of ServiceResolver +// ServiceResolverSpec defines the desired state of ServiceResolver. type ServiceResolverSpec struct { // DefaultSubset is the subset to use when no explicit subset is requested. // If empty the unnamed subset is used. diff --git a/control-plane/api/v1alpha1/servicerouter_types.go b/control-plane/api/v1alpha1/servicerouter_types.go index cc455a0853..9f8f7fc3fd 100644 --- a/control-plane/api/v1alpha1/servicerouter_types.go +++ b/control-plane/api/v1alpha1/servicerouter_types.go @@ -41,14 +41,14 @@ type ServiceRouter struct { // +kubebuilder:object:root=true -// ServiceRouterList contains a list of ServiceRouter +// ServiceRouterList contains a list of ServiceRouter. type ServiceRouterList struct { metav1.TypeMeta `json:",inline"` metav1.ListMeta `json:"metadata,omitempty"` Items []ServiceRouter `json:"items"` } -// ServiceRouterSpec defines the desired state of ServiceRouter +// ServiceRouterSpec defines the desired state of ServiceRouter. type ServiceRouterSpec struct { // Routes are the list of routes to consider when processing L7 requests. // The first route to match in the list is terminal and stops further diff --git a/control-plane/api/v1alpha1/servicesplitter_types.go b/control-plane/api/v1alpha1/servicesplitter_types.go index fb5ba74d7f..b61b1a320b 100644 --- a/control-plane/api/v1alpha1/servicesplitter_types.go +++ b/control-plane/api/v1alpha1/servicesplitter_types.go @@ -37,7 +37,7 @@ type ServiceSplitter struct { // +kubebuilder:object:root=true -// ServiceSplitterList contains a list of ServiceSplitter +// ServiceSplitterList contains a list of ServiceSplitter. type ServiceSplitterList struct { metav1.TypeMeta `json:",inline"` metav1.ListMeta `json:"metadata,omitempty"` @@ -46,7 +46,7 @@ type ServiceSplitterList struct { type ServiceSplits []ServiceSplit -// ServiceSplitterSpec defines the desired state of ServiceSplitter +// ServiceSplitterSpec defines the desired state of ServiceSplitter. type ServiceSplitterSpec struct { // Splits defines how much traffic to send to which set of service instances during a traffic split. // The sum of weights across all splits must add up to 100. diff --git a/control-plane/api/v1alpha1/shared_types.go b/control-plane/api/v1alpha1/shared_types.go index 1191614698..9b884cf476 100644 --- a/control-plane/api/v1alpha1/shared_types.go +++ b/control-plane/api/v1alpha1/shared_types.go @@ -52,7 +52,7 @@ type TransparentProxy struct { } // MeshGateway controls how Mesh Gateways are used for upstream Connect -// services +// services. type MeshGateway struct { // Mode is the mode that should be used for the upstream connection. // One of none, local, or remote. diff --git a/control-plane/api/v1alpha1/status.go b/control-plane/api/v1alpha1/status.go index 1dd19241f2..d7cd0e0b78 100644 --- a/control-plane/api/v1alpha1/status.go +++ b/control-plane/api/v1alpha1/status.go @@ -5,7 +5,7 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) -// Conditions is the schema for the conditions portion of the payload +// Conditions is the schema for the conditions portion of the payload. type Conditions []Condition // ConditionType is a camel-cased condition type. @@ -42,7 +42,7 @@ type Condition struct { Message string `json:"message,omitempty" description:"human-readable message indicating details about last transition"` } -// IsTrue is true if the condition is True +// IsTrue is true if the condition is True. func (c *Condition) IsTrue() bool { if c == nil { return false @@ -50,7 +50,7 @@ func (c *Condition) IsTrue() bool { return c.Status == corev1.ConditionTrue } -// IsFalse is true if the condition is False +// IsFalse is true if the condition is False. func (c *Condition) IsFalse() bool { if c == nil { return false @@ -58,7 +58,7 @@ func (c *Condition) IsFalse() bool { return c.Status == corev1.ConditionFalse } -// IsUnknown is true if the condition is Unknown +// IsUnknown is true if the condition is Unknown. func (c *Condition) IsUnknown() bool { if c == nil { return true diff --git a/control-plane/api/v1alpha1/terminatinggateway_types.go b/control-plane/api/v1alpha1/terminatinggateway_types.go index 1236307b99..6e708b5d44 100644 --- a/control-plane/api/v1alpha1/terminatinggateway_types.go +++ b/control-plane/api/v1alpha1/terminatinggateway_types.go @@ -41,20 +41,20 @@ type TerminatingGateway struct { // +kubebuilder:object:root=true -// TerminatingGatewayList contains a list of TerminatingGateway +// TerminatingGatewayList contains a list of TerminatingGateway. type TerminatingGatewayList struct { metav1.TypeMeta `json:",inline"` metav1.ListMeta `json:"metadata,omitempty"` Items []TerminatingGateway `json:"items"` } -// TerminatingGatewaySpec defines the desired state of TerminatingGateway +// TerminatingGatewaySpec defines the desired state of TerminatingGateway. type TerminatingGatewaySpec struct { // Services is a list of service names represented by the terminating gateway. Services []LinkedService `json:"services,omitempty"` } -// A LinkedService is a service represented by a terminating gateway +// A LinkedService is a service represented by a terminating gateway. type LinkedService struct { // The namespace the service is registered in. Namespace string `json:"namespace,omitempty"` diff --git a/control-plane/catalog/to-consul/resource.go b/control-plane/catalog/to-consul/resource.go index 5188f2ccb5..4444f14b18 100644 --- a/control-plane/catalog/to-consul/resource.go +++ b/control-plane/catalog/to-consul/resource.go @@ -35,14 +35,14 @@ type NodePortSyncType string const ( // Only sync NodePort services with a node's ExternalIP address. - // Doesn't sync if an ExternalIP doesn't exist + // Doesn't sync if an ExternalIP doesn't exist. ExternalOnly NodePortSyncType = "ExternalOnly" // Sync with an ExternalIP first, if it doesn't exist, use the - // node's InternalIP address instead + // node's InternalIP address instead. ExternalFirst NodePortSyncType = "ExternalFirst" - // Sync NodePort services using + // Sync NodePort services using. InternalOnly NodePortSyncType = "InternalOnly" ) @@ -226,7 +226,7 @@ func (t *ServiceResource) Delete(key string, _ interface{}) error { // doDelete is a helper function for deletion. // -// Precondition: assumes t.serviceLock is held +// Precondition: assumes t.serviceLock is held. func (t *ServiceResource) doDelete(key string) { delete(t.serviceMap, key) t.Log.Debug("[doDelete] deleting service from serviceMap", "key", key) @@ -292,7 +292,7 @@ func (t *ServiceResource) shouldSync(svc *apiv1.Service) bool { // shouldTrackEndpoints returns true if the endpoints for the given key // should be tracked. // -// Precondition: this requires the lock to be held +// Precondition: this requires the lock to be held. func (t *ServiceResource) shouldTrackEndpoints(key string) bool { // The service must be one we care about for us to watch the endpoints. // We care about a service that exists in our service map (is enabled @@ -664,7 +664,7 @@ func (t *ServiceResource) registerServiceInstance( // sync calls the Syncer.Sync function from the generated registrations. // -// Precondition: lock must be held +// Precondition: lock must be held. func (t *ServiceResource) sync() { // NOTE(mitchellh): This isn't the most efficient way to do this and // the times that sync are called are also not the most efficient. All diff --git a/control-plane/catalog/to-consul/resource_test.go b/control-plane/catalog/to-consul/resource_test.go index 6bc99eb5f7..9fc5ced094 100644 --- a/control-plane/catalog/to-consul/resource_test.go +++ b/control-plane/catalog/to-consul/resource_test.go @@ -102,7 +102,7 @@ func TestServiceResource_defaultEnableDisable(t *testing.T) { }) } -// Test that we can default disable +// Test that we can default disable. func TestServiceResource_defaultDisable(t *testing.T) { t.Parallel() client := fake.NewSimpleClientset() @@ -128,7 +128,7 @@ func TestServiceResource_defaultDisable(t *testing.T) { }) } -// Test that we can default disable but override +// Test that we can default disable but override. func TestServiceResource_defaultDisableEnable(t *testing.T) { t.Parallel() client := fake.NewSimpleClientset() @@ -196,7 +196,7 @@ func TestServiceResource_changeSyncToFalse(t *testing.T) { } // Test that the k8s namespace is appended with a '-' -// when AddK8SNamespaceSuffix is true +// when AddK8SNamespaceSuffix is true. func TestServiceResource_addK8SNamespace(t *testing.T) { t.Parallel() client := fake.NewSimpleClientset() @@ -224,7 +224,7 @@ func TestServiceResource_addK8SNamespace(t *testing.T) { } // Test k8s namespace suffix is appended -// when the consul prefix is provided +// when the consul prefix is provided. func TestServiceResource_addK8SNamespaceWithPrefix(t *testing.T) { t.Parallel() client := fake.NewSimpleClientset() @@ -281,7 +281,7 @@ func TestServiceResource_ConsulNodeName(t *testing.T) { } // Test k8s namespace suffix is not appended -// when the service name annotation is provided +// when the service name annotation is provided. func TestServiceResource_addK8SNamespaceWithNameAnnotation(t *testing.T) { t.Parallel() client := fake.NewSimpleClientset() @@ -339,7 +339,7 @@ func TestServiceResource_externalIP(t *testing.T) { }) } -// Test externalIP with Prefix +// Test externalIP with Prefix. func TestServiceResource_externalIPPrefix(t *testing.T) { t.Parallel() client := fake.NewSimpleClientset() @@ -397,7 +397,7 @@ func TestServiceResource_lb(t *testing.T) { }) } -// Test that the proper registrations are generated for a LoadBalancer with a prefix +// Test that the proper registrations are generated for a LoadBalancer with a prefix. func TestServiceResource_lbPrefix(t *testing.T) { t.Parallel() client := fake.NewSimpleClientset() @@ -460,7 +460,7 @@ func TestServiceResource_lbMultiEndpoint(t *testing.T) { }) } -// Test explicit name annotation +// Test explicit name annotation. func TestServiceResource_lbAnnotatedName(t *testing.T) { t.Parallel() client := fake.NewSimpleClientset() @@ -487,7 +487,7 @@ func TestServiceResource_lbAnnotatedName(t *testing.T) { }) } -// Test default port and additional ports in the meta +// Test default port and additional ports in the meta. func TestServiceResource_lbPort(t *testing.T) { t.Parallel() client := fake.NewSimpleClientset() @@ -519,7 +519,7 @@ func TestServiceResource_lbPort(t *testing.T) { }) } -// Test default port works with override annotation +// Test default port works with override annotation. func TestServiceResource_lbAnnotatedPort(t *testing.T) { t.Parallel() client := fake.NewSimpleClientset() @@ -552,7 +552,7 @@ func TestServiceResource_lbAnnotatedPort(t *testing.T) { }) } -// Test annotated tags +// Test annotated tags. func TestServiceResource_lbAnnotatedTags(t *testing.T) { t.Parallel() client := fake.NewSimpleClientset() @@ -580,7 +580,7 @@ func TestServiceResource_lbAnnotatedTags(t *testing.T) { }) } -// Test annotated service meta +// Test annotated service meta. func TestServiceResource_lbAnnotatedMeta(t *testing.T) { t.Parallel() client := fake.NewSimpleClientset() @@ -607,7 +607,7 @@ func TestServiceResource_lbAnnotatedMeta(t *testing.T) { }) } -// Test that with LoadBalancerEndpointsSync set to true we track the IP of the endpoints not the LB IP/name +// Test that with LoadBalancerEndpointsSync set to true we track the IP of the endpoints not the LB IP/name. func TestServiceResource_lbRegisterEndpoints(t *testing.T) { t.Parallel() client := fake.NewSimpleClientset() @@ -701,7 +701,7 @@ func TestServiceResource_nodePort(t *testing.T) { }) } -// Test node port works with prefix +// Test node port works with prefix. func TestServiceResource_nodePortPrefix(t *testing.T) { t.Parallel() client := fake.NewSimpleClientset() @@ -922,7 +922,7 @@ func TestServiceResource_nodePort_internalOnlySync(t *testing.T) { } // Test that the proper registrations are generated for a NodePort type -// when preferring to sync external Node IPs over internal IPs +// when preferring to sync external Node IPs over internal IPs. func TestServiceResource_nodePort_externalFirstSync(t *testing.T) { t.Parallel() client := fake.NewSimpleClientset() @@ -1005,7 +1005,7 @@ func TestServiceResource_clusterIP(t *testing.T) { }) } -// Test clusterIP with prefix +// Test clusterIP with prefix. func TestServiceResource_clusterIPPrefix(t *testing.T) { t.Parallel() client := fake.NewSimpleClientset() @@ -1188,7 +1188,7 @@ func TestServiceResource_clusterIPSyncDisabled(t *testing.T) { }) } -// Test that the ClusterIP services are synced when watching all namespaces +// Test that the ClusterIP services are synced when watching all namespaces. func TestServiceResource_clusterIPAllNamespaces(t *testing.T) { t.Parallel() client := fake.NewSimpleClientset() diff --git a/control-plane/catalog/to-consul/syncer.go b/control-plane/catalog/to-consul/syncer.go index 557e51bf0d..2e2edad61a 100644 --- a/control-plane/catalog/to-consul/syncer.go +++ b/control-plane/catalog/to-consul/syncer.go @@ -98,7 +98,7 @@ type ConsulSyncer struct { watchers map[string]map[string]context.CancelFunc } -// Sync implements Syncer +// Sync implements Syncer. func (s *ConsulSyncer) Sync(rs []*api.CatalogRegistration) { // Grab the lock so we can replace the sync state s.lock.Lock() @@ -317,7 +317,7 @@ func (s *ConsulSyncer) watchService(ctx context.Context, name, namespace string) // scheduleReapService finds all the instances of the service with the given // name that have the k8s tag and schedules them for removal. // -// Precondition: lock must be held +// Precondition: lock must be held. func (s *ConsulSyncer) scheduleReapServiceLocked(name, namespace string) error { // Set up query options opts := api.QueryOptions{AllowStale: true} diff --git a/control-plane/catalog/to-consul/testing.go b/control-plane/catalog/to-consul/testing.go index 89813ac5d6..e6541c6ba1 100644 --- a/control-plane/catalog/to-consul/testing.go +++ b/control-plane/catalog/to-consul/testing.go @@ -17,7 +17,7 @@ type testSyncer struct { Registrations []*api.CatalogRegistration } -// Sync implements Syncer +// Sync implements Syncer. func (s *testSyncer) Sync(rs []*api.CatalogRegistration) { s.Lock() defer s.Unlock() diff --git a/control-plane/catalog/to-k8s/sink.go b/control-plane/catalog/to-k8s/sink.go index e3bfed7789..fa8821989e 100644 --- a/control-plane/catalog/to-k8s/sink.go +++ b/control-plane/catalog/to-k8s/sink.go @@ -82,7 +82,7 @@ type K8SSink struct { triggerCh chan struct{} } -// SetServices implements Sink +// SetServices implements Sink. func (s *K8SSink) SetServices(svcs map[string]string) { s.lock.Lock() defer s.lock.Unlock() diff --git a/control-plane/catalog/to-k8s/sink_test.go b/control-plane/catalog/to-k8s/sink_test.go index 2883b1f9f3..fbce7bbaaf 100644 --- a/control-plane/catalog/to-k8s/sink_test.go +++ b/control-plane/catalog/to-k8s/sink_test.go @@ -221,7 +221,7 @@ func TestK8SSink_updateReconcile(t *testing.T) { }) } -// Test that if the service is updated locally, it is reconciled +// Test that if the service is updated locally, it is reconciled. func TestK8SSink_updateService(t *testing.T) { t.Parallel() client := fake.NewSimpleClientset() @@ -284,7 +284,7 @@ func TestK8SSink_updateService(t *testing.T) { }) } -// Test that if the service is deleted remotely, it is recreated +// Test that if the service is deleted remotely, it is recreated. func TestK8SSink_deleteReconcileRemote(t *testing.T) { t.Parallel() client := fake.NewSimpleClientset() @@ -347,7 +347,7 @@ func TestK8SSink_deleteReconcileRemote(t *testing.T) { }) } -// Test that if the service is deleted locally, it is recreated +// Test that if the service is deleted locally, it is recreated. func TestK8SSink_deleteReconcileLocal(t *testing.T) { t.Parallel() client := fake.NewSimpleClientset() diff --git a/control-plane/catalog/to-k8s/source_test.go b/control-plane/catalog/to-k8s/source_test.go index f7e97fe19f..d3ed4a8a26 100644 --- a/control-plane/catalog/to-k8s/source_test.go +++ b/control-plane/catalog/to-k8s/source_test.go @@ -259,7 +259,7 @@ func TestSource_deleteServiceInstance(t *testing.T) { }) } -// testRegistration creates a Consul test registration +// testRegistration creates a Consul test registration. func testRegistration(node, service string, tags []string) *api.CatalogRegistration { return &api.CatalogRegistration{ Node: node, @@ -271,13 +271,13 @@ func testRegistration(node, service string, tags []string) *api.CatalogRegistrat } } -// testSource creates a Source and Sink for testing +// testSource creates a Source and Sink for testing. func testSource(client *api.Client) (*Source, *TestSink, func()) { return testSourceWithConfig(client, func(source *Source) {}) } // testSourceWithConfig starts a Source that can be configured -// prior to starting via the configurator method +// prior to starting via the configurator method. func testSourceWithConfig(client *api.Client, configurator func(*Source)) (*Source, *TestSink, func()) { sink := &TestSink{} s := &Source{ diff --git a/control-plane/connect-inject/annotations.go b/control-plane/connect-inject/annotations.go index 8e9730d41a..ec723d80fd 100644 --- a/control-plane/connect-inject/annotations.go +++ b/control-plane/connect-inject/annotations.go @@ -13,7 +13,7 @@ const ( // annotationInject is the key of the annotation that controls whether // injection is explicitly enabled or disabled for a pod. This should - // be set to a truthy or falsy value, as parseable by strconv.ParseBool + // be set to a truthy or falsy value, as parseable by strconv.ParseBool. annotationInject = "consul.hashicorp.com/connect-inject" // annotationService is the name of the service to proxy. This defaults @@ -39,7 +39,7 @@ const ( annotationUpstreams = "consul.hashicorp.com/connect-service-upstreams" // annotationTags is a list of tags to register with the service - // this is specified as a comma separated list e.g. abc,123 + // this is specified as a comma separated list e.g. abc,123. annotationTags = "consul.hashicorp.com/service-tags" // annotationConnectTags is a list of tags to register with the service @@ -53,7 +53,7 @@ const ( // annotationMeta is a list of metadata key/value pairs to add to the service // registration. This is specified in the format `:` - // e.g. consul.hashicorp.com/service-meta-foo:bar + // e.g. consul.hashicorp.com/service-meta-foo:bar. annotationMeta = "consul.hashicorp.com/service-meta-" // annotationSyncPeriod controls the -sync-period flag passed to the diff --git a/control-plane/connect-inject/container_init_test.go b/control-plane/connect-inject/container_init_test.go index f536ba68f0..2b8927f258 100644 --- a/control-plane/connect-inject/container_init_test.go +++ b/control-plane/connect-inject/container_init_test.go @@ -956,7 +956,7 @@ consul-k8s-control-plane connect-init -pod-name=${POD_NAME} -pod-namespace=${POD // If Consul CA cert is set, // Consul addresses should use HTTPS -// and CA cert should be set as env variable +// and CA cert should be set as env variable. func TestHandlerContainerInit_WithTLS(t *testing.T) { require := require.New(t) h := Handler{ diff --git a/control-plane/connect-inject/handler_test.go b/control-plane/connect-inject/handler_test.go index cd77de66f4..0ae01fd93c 100644 --- a/control-plane/connect-inject/handler_test.go +++ b/control-plane/connect-inject/handler_test.go @@ -863,7 +863,7 @@ func TestHandlerPrometheusAnnotations(t *testing.T) { } } -// Test portValue function +// Test portValue function. func TestHandlerPortValue(t *testing.T) { cases := []struct { Name string @@ -950,7 +950,7 @@ func TestHandlerPortValue(t *testing.T) { } } -// Test consulNamespace function +// Test consulNamespace function. func TestConsulNamespace(t *testing.T) { cases := []struct { Name string diff --git a/control-plane/controller/configentry_controller_test.go b/control-plane/controller/configentry_controller_test.go index 9ed1c324ac..74787beb12 100644 --- a/control-plane/controller/configentry_controller_test.go +++ b/control-plane/controller/configentry_controller_test.go @@ -1468,7 +1468,7 @@ func TestConfigEntryControllers_setsSyncedToTrue(t *testing.T) { } // Test that if the config entry exists in Consul but is not managed by the -// controller, creating/updating the resource fails +// controller, creating/updating the resource fails. func TestConfigEntryControllers_doesNotCreateUnownedConfigEntry(t *testing.T) { t.Parallel() kubeNS := "default" @@ -1566,7 +1566,7 @@ func TestConfigEntryControllers_doesNotCreateUnownedConfigEntry(t *testing.T) { } // Test that if the config entry exists in Consul but is not managed by the -// controller, deleting the resource does not delete the Consul config entry +// controller, deleting the resource does not delete the Consul config entry. func TestConfigEntryControllers_doesNotDeleteUnownedConfig(t *testing.T) { t.Parallel() kubeNS := "default" diff --git a/control-plane/controller/exportedservices_controller.go b/control-plane/controller/exportedservices_controller.go index be0445f4a1..84e767d6dc 100644 --- a/control-plane/controller/exportedservices_controller.go +++ b/control-plane/controller/exportedservices_controller.go @@ -12,7 +12,7 @@ import ( consulv1alpha1 "github.com/hashicorp/consul-k8s/control-plane/api/v1alpha1" ) -// ExportedServicesController reconciles a ExportedServices object +// ExportedServicesController reconciles a ExportedServices object. type ExportedServicesController struct { client.Client Log logr.Logger diff --git a/control-plane/controller/mesh_controller.go b/control-plane/controller/mesh_controller.go index 61652d23fe..e15f49fca0 100644 --- a/control-plane/controller/mesh_controller.go +++ b/control-plane/controller/mesh_controller.go @@ -12,7 +12,7 @@ import ( consulv1alpha1 "github.com/hashicorp/consul-k8s/control-plane/api/v1alpha1" ) -// MeshController reconciles a Mesh object +// MeshController reconciles a Mesh object. type MeshController struct { client.Client Log logr.Logger diff --git a/control-plane/controller/proxydefaults_controller.go b/control-plane/controller/proxydefaults_controller.go index 658806d340..a63e121522 100644 --- a/control-plane/controller/proxydefaults_controller.go +++ b/control-plane/controller/proxydefaults_controller.go @@ -12,7 +12,7 @@ import ( consulv1alpha1 "github.com/hashicorp/consul-k8s/control-plane/api/v1alpha1" ) -// ProxyDefaultsController reconciles a ProxyDefaults object +// ProxyDefaultsController reconciles a ProxyDefaults object. type ProxyDefaultsController struct { client.Client Log logr.Logger diff --git a/control-plane/controller/serviceintentions_controller.go b/control-plane/controller/serviceintentions_controller.go index 1ee1db037c..3b70447517 100644 --- a/control-plane/controller/serviceintentions_controller.go +++ b/control-plane/controller/serviceintentions_controller.go @@ -12,7 +12,7 @@ import ( consulv1alpha1 "github.com/hashicorp/consul-k8s/control-plane/api/v1alpha1" ) -// ServiceIntentionsController reconciles a ServiceIntentions object +// ServiceIntentionsController reconciles a ServiceIntentions object. type ServiceIntentionsController struct { client.Client Log logr.Logger diff --git a/control-plane/controller/servicesplitter_controller.go b/control-plane/controller/servicesplitter_controller.go index a8b6267c70..9d07845dbb 100644 --- a/control-plane/controller/servicesplitter_controller.go +++ b/control-plane/controller/servicesplitter_controller.go @@ -12,7 +12,7 @@ import ( consulv1alpha1 "github.com/hashicorp/consul-k8s/control-plane/api/v1alpha1" ) -// ServiceSplitterReconciler reconciles a ServiceSplitter object +// ServiceSplitterReconciler reconciles a ServiceSplitter object. type ServiceSplitterController struct { client.Client Log logr.Logger diff --git a/control-plane/helper/cert/source_gen.go b/control-plane/helper/cert/source_gen.go index 8226e9ce72..e9c79ed390 100644 --- a/control-plane/helper/cert/source_gen.go +++ b/control-plane/helper/cert/source_gen.go @@ -34,7 +34,7 @@ type GenSource struct { caSigner crypto.Signer } -// Certificate implements Source +// Certificate implements Source. func (s *GenSource) Certificate(ctx context.Context, last *Bundle) (Bundle, error) { s.mu.Lock() defer s.mu.Unlock() diff --git a/control-plane/helper/cert/source_gen_test.go b/control-plane/helper/cert/source_gen_test.go index b654f10d0f..8926e89174 100644 --- a/control-plane/helper/cert/source_gen_test.go +++ b/control-plane/helper/cert/source_gen_test.go @@ -20,7 +20,7 @@ func init() { hasOpenSSL = err == nil } -// Test that valid certificates are generated +// Test that valid certificates are generated. func TestGenSource_valid(t *testing.T) { t.Parallel() @@ -36,7 +36,7 @@ func TestGenSource_valid(t *testing.T) { testBundleVerify(t, &bundle) } -// Test that certs are regenerated near expiry +// Test that certs are regenerated near expiry. func TestGenSource_expiry(t *testing.T) { t.Parallel() diff --git a/control-plane/helper/coalesce/coalesce_test.go b/control-plane/helper/coalesce/coalesce_test.go index 2cfe7bd65c..8489fed8b4 100644 --- a/control-plane/helper/coalesce/coalesce_test.go +++ b/control-plane/helper/coalesce/coalesce_test.go @@ -46,11 +46,11 @@ func TestCoalesce_max(t *testing.T) { testSummer(&total, deltaCh)) duration := time.Since(start) if total < 4 || total > 6 { - // 4 to 6 to account for CI weirdness + // 4 to 6 to account for CI weirdness. t.Fatalf("total should be 4 to 6: %d", total) } - // We should complete in the max period + // We should complete in the max period. if duration < 500*time.Millisecond { t.Fatalf("duration should be greater than max: %s", duration) } @@ -58,7 +58,7 @@ func TestCoalesce_max(t *testing.T) { // Test that if the cancel function is called, Coalesce exits. // We test this via having a function that just sleeps and then calling -// cancel on it. We expect that Coalesce exits +// cancel on it. We expect that Coalesce exits. func TestCoalesce_cancel(t *testing.T) { total := 0 deltaCh := make(chan int, 10) diff --git a/control-plane/helper/controller/controller.go b/control-plane/helper/controller/controller.go index 66a1d3b005..6edfb9d89c 100644 --- a/control-plane/helper/controller/controller.go +++ b/control-plane/helper/controller/controller.go @@ -134,7 +134,7 @@ func (c *Controller) Run(stopCh <-chan struct{}) { }, time.Second, stopCh) } -// HasSynced implements cache.Controller +// HasSynced implements cache.Controller. func (c *Controller) HasSynced() bool { if c.informer == nil { return false @@ -143,7 +143,7 @@ func (c *Controller) HasSynced() bool { return c.informer.HasSynced() } -// LastSyncResourceVersion implements cache.Controller +// LastSyncResourceVersion implements cache.Controller. func (c *Controller) LastSyncResourceVersion() string { if c.informer == nil { return "" diff --git a/control-plane/helper/controller/controller_test.go b/control-plane/helper/controller/controller_test.go index 2f83bc5705..43fe677280 100644 --- a/control-plane/helper/controller/controller_test.go +++ b/control-plane/helper/controller/controller_test.go @@ -22,7 +22,7 @@ func TestController_impl(t *testing.T) { var _ cache.Controller = &Controller{} } -// Test that data that exists before is synced +// Test that data that exists before is synced. func TestController_initialData(t *testing.T) { t.Parallel() require := require.New(t) @@ -46,7 +46,7 @@ func TestController_initialData(t *testing.T) { require.Len(deleted, 0) } -// Test that created data after starting is loaded +// Test that created data after starting is loaded. func TestController_create(t *testing.T) { t.Parallel() require := require.New(t) diff --git a/control-plane/subcommand/common/common_test.go b/control-plane/subcommand/common/common_test.go index d5ac9a11b1..179d10a114 100644 --- a/control-plane/subcommand/common/common_test.go +++ b/control-plane/subcommand/common/common_test.go @@ -29,7 +29,7 @@ func TestZapLogger_InvalidLogLevel(t *testing.T) { require.EqualError(t, err, "unknown log level \"invalid\": unrecognized level: \"invalid\"") } -// ZapLogger should convert "trace" log level to "debug" +// ZapLogger should convert "trace" log level to "debug". func TestZapLogger_TraceLogLevel(t *testing.T) { _, err := ZapLogger("trace", false) require.NoError(t, err) diff --git a/control-plane/subcommand/consul-sidecar/command.go b/control-plane/subcommand/consul-sidecar/command.go index b6ff0d9d39..509696378d 100644 --- a/control-plane/subcommand/consul-sidecar/command.go +++ b/control-plane/subcommand/consul-sidecar/command.go @@ -398,7 +398,7 @@ func (c *Command) parseConsulFlags() []string { } // interrupt sends os.Interrupt signal to the command -// so it can exit gracefully. This function is needed for tests +// so it can exit gracefully. This function is needed for tests. func (c *Command) interrupt() { c.sendSignal(syscall.SIGINT) } diff --git a/control-plane/subcommand/consul-sidecar/command_test.go b/control-plane/subcommand/consul-sidecar/command_test.go index 53008ffab9..f9b7c77625 100644 --- a/control-plane/subcommand/consul-sidecar/command_test.go +++ b/control-plane/subcommand/consul-sidecar/command_test.go @@ -225,7 +225,7 @@ func (em *mockEnvoyMetricsGetter) Get(_ string) (resp *http.Response, err error) return response, nil } -// mockServiceMetricsGetter +// mockServiceMetricsGetter. type mockServiceMetricsGetter struct { // reqURL is the last URL that was passed to Get(url) reqURL string diff --git a/control-plane/subcommand/flags/flag_map_value.go b/control-plane/subcommand/flags/flag_map_value.go index cb10c8ecc4..9ddb4dad08 100644 --- a/control-plane/subcommand/flags/flag_map_value.go +++ b/control-plane/subcommand/flags/flag_map_value.go @@ -9,7 +9,7 @@ import ( // Taken from https://github.com/hashicorp/consul/blob/35daee45bc3bf9fdce5845f2219576e861b23f40/command/flags/flag_map_value.go // This was done so we don't depend on internal Consul implementation. -// Ensure implements +// Ensure implements. var _ flag.Value = (*FlagMapValue)(nil) // FlagMapValue is a flag implementation used to provide key=value semantics diff --git a/control-plane/subcommand/get-consul-client-ca/command_test.go b/control-plane/subcommand/get-consul-client-ca/command_test.go index 8655465771..4250e6d81f 100644 --- a/control-plane/subcommand/get-consul-client-ca/command_test.go +++ b/control-plane/subcommand/get-consul-client-ca/command_test.go @@ -64,7 +64,7 @@ func TestRun_FlagsValidation(t *testing.T) { // Test that in the happy case scenario // we retrieve the CA from Consul and -// write it to a file +// write it to a file. func TestRun(t *testing.T) { t.Parallel() outputFile, err := ioutil.TempFile("", "ca") @@ -293,7 +293,7 @@ func TestRun_GetsOnlyActiveRoot(t *testing.T) { } // Test that when using cloud auto-join -// it uses the provider to get the address of the server +// it uses the provider to get the address of the server. func TestRun_WithProvider(t *testing.T) { t.Parallel() outputFile, err := ioutil.TempFile("", "ca") diff --git a/control-plane/subcommand/server-acl-init/rules.go b/control-plane/subcommand/server-acl-init/rules.go index 83d836cd6d..a634e9473d 100644 --- a/control-plane/subcommand/server-acl-init/rules.go +++ b/control-plane/subcommand/server-acl-init/rules.go @@ -233,7 +233,7 @@ partition "{{ .PartitionName }}" { // Creating a separate terminating gateway rule function because // eventually this may need to be created with permissions for // all of the services it represents, though that is not part -// of the initial implementation +// of the initial implementation. func (c *Command) terminatingGatewayRules(name, namespace string) (string, error) { terminatingGatewayRulesTpl := ` {{- if .EnablePartitions }} diff --git a/control-plane/subcommand/sync-catalog/command.go b/control-plane/subcommand/sync-catalog/command.go index fa478412c2..105ce6619c 100644 --- a/control-plane/subcommand/sync-catalog/command.go +++ b/control-plane/subcommand/sync-catalog/command.go @@ -382,7 +382,7 @@ func (c *Command) Help() string { } // interrupt sends os.Interrupt signal to the command -// so it can exit gracefully. This function is needed for tests +// so it can exit gracefully. This function is needed for tests. func (c *Command) interrupt() { c.sendSignal(syscall.SIGINT) } diff --git a/control-plane/subcommand/sync-catalog/command_test.go b/control-plane/subcommand/sync-catalog/command_test.go index 3956b24f2d..6cc629336e 100644 --- a/control-plane/subcommand/sync-catalog/command_test.go +++ b/control-plane/subcommand/sync-catalog/command_test.go @@ -18,7 +18,7 @@ import ( "k8s.io/client-go/kubernetes/fake" ) -// Test flag validation +// Test flag validation. func TestRun_FlagValidation(t *testing.T) { t.Parallel() @@ -51,7 +51,7 @@ func TestRun_FlagValidation(t *testing.T) { } } -// Test that the default consul service is synced to k8s +// Test that the default consul service is synced to k8s. func TestRun_Defaults_SyncsConsulServiceToK8s(t *testing.T) { t.Parallel() @@ -83,7 +83,7 @@ func TestRun_Defaults_SyncsConsulServiceToK8s(t *testing.T) { }) } -// Test that the command exits cleanly on signals +// Test that the command exits cleanly on signals. func TestRun_ExitCleanlyOnSignals(t *testing.T) { t.Run("SIGINT", testSignalHandling(syscall.SIGINT)) t.Run("SIGTERM", testSignalHandling(syscall.SIGTERM)) @@ -126,7 +126,7 @@ func testSignalHandling(sig os.Signal) func(*testing.T) { } // Test that when -add-k8s-namespace-suffix flag is used -// k8s namespaces are appended to the service names synced to Consul +// k8s namespaces are appended to the service names synced to Consul. func TestRun_ToConsulWithAddK8SNamespaceSuffix(t *testing.T) { t.Parallel() @@ -171,7 +171,7 @@ func TestRun_ToConsulWithAddK8SNamespaceSuffix(t *testing.T) { } // Test that switching AddK8SNamespaceSuffix from false to true -// results in re-registering services in Consul with namespaced names +// results in re-registering services in Consul with namespaced names. func TestCommand_Run_ToConsulChangeAddK8SNamespaceSuffixToTrue(t *testing.T) { t.Parallel() @@ -231,7 +231,7 @@ func TestCommand_Run_ToConsulChangeAddK8SNamespaceSuffixToTrue(t *testing.T) { // Test that services with same name but in different namespaces // get registered as different services in consul -// when using -add-k8s-namespace-suffix +// when using -add-k8s-namespace-suffix. func TestCommand_Run_ToConsulTwoServicesSameNameDifferentNamespace(t *testing.T) { t.Parallel() @@ -574,7 +574,7 @@ func TestRun_ToConsulChangingFlags(t *testing.T) { } } -// Set up test consul agent and fake kubernetes cluster client +// Set up test consul agent and fake kubernetes cluster client. func completeSetup(t *testing.T) (*fake.Clientset, *testutil.TestServer) { k8s := fake.NewSimpleClientset() diff --git a/control-plane/subcommand/webhook-cert-manager/command.go b/control-plane/subcommand/webhook-cert-manager/command.go index 2f69889975..570a432ad9 100644 --- a/control-plane/subcommand/webhook-cert-manager/command.go +++ b/control-plane/subcommand/webhook-cert-manager/command.go @@ -412,7 +412,7 @@ func (c *Command) Synopsis() string { } // interrupt sends os.Interrupt signal to the command -// so it can exit gracefully. This function is needed for tests +// so it can exit gracefully. This function is needed for tests. func (c *Command) interrupt() { c.sendSignal(syscall.SIGINT) }