diff --git a/.golangci.yml b/.golangci.yml index 1ea074adce..52b055c0c3 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -31,7 +31,6 @@ run: # autogenerated files. If it's not please let us know. skip-files: - # output configuration options output: # colored-line-number|line-number|json|tab|checkstyle, default is "colored-line-number" @@ -43,7 +42,6 @@ output: # print linter name in the end of issue text, default is true print-linter-name: true - linters: enable: - megacheck @@ -61,3 +59,7 @@ linters: - unparam - nakedret +issues: + # This turns off the default excludes - which was causing the linter + # to miss things like erroneous comments + exclude-use-default: false \ No newline at end of file diff --git a/build/build-image/Dockerfile b/build/build-image/Dockerfile index d6d662c74b..49724ee90c 100644 --- a/build/build-image/Dockerfile +++ b/build/build-image/Dockerfile @@ -69,7 +69,7 @@ RUN go get -u github.com/golang/dep/cmd/dep && \ go get -u golang.org/x/tools/cmd/goimports # install golang-ci linter -RUN curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s -- -b $GOPATH/bin v1.10.2 +RUN curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s -- -b $GOPATH/bin v1.12.2 # install the release branch of the code generator tools RUN mkdir -p /go/src && cd /go/src && mkdir -p k8s.io && cd k8s.io && \ diff --git a/pkg/apis/stable/v1alpha1/fleet.go b/pkg/apis/stable/v1alpha1/fleet.go index b74ba5115c..b89e54924a 100644 --- a/pkg/apis/stable/v1alpha1/fleet.go +++ b/pkg/apis/stable/v1alpha1/fleet.go @@ -27,13 +27,11 @@ const ( FleetGameServerSetLabel = stable.GroupName + "/fleet" ) -type SchedulingStrategy string - // +genclient // +genclient:noStatus // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object -// Fleet is the data structure for a gameserver resource +// Fleet is the data structure for a Fleet resource type Fleet struct { metav1.TypeMeta `json:",inline"` metav1.ObjectMeta `json:"metadata,omitempty"` @@ -44,7 +42,7 @@ type Fleet struct { // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object -// FleetList is a list of GameServer resources +// FleetList is a list of Fleet resources type FleetList struct { metav1.TypeMeta `json:",inline"` metav1.ListMeta `json:"metadata,omitempty"` @@ -64,7 +62,7 @@ type FleetSpec struct { Template GameServerTemplateSpec `json:"template"` } -// FleetStatus is the status of a GameServerSet +// FleetStatus is the status of a Fleet type FleetStatus struct { // Replicas the total number of current GameServer replicas Replicas int32 `json:"replicas"` diff --git a/pkg/apis/stable/v1alpha1/fleetautoscaler.go b/pkg/apis/stable/v1alpha1/fleetautoscaler.go index 716db8c22b..7f92c7462f 100644 --- a/pkg/apis/stable/v1alpha1/fleetautoscaler.go +++ b/pkg/apis/stable/v1alpha1/fleetautoscaler.go @@ -58,10 +58,13 @@ type FleetAutoscalerPolicy struct { Buffer *BufferPolicy `json:"buffer,omitempty"` } +// FleetAutoscalerPolicyType is the policy for autoscaling +// for a given Fleet type FleetAutoscalerPolicyType string const ( - // Kill all existing pods before creating new ones. + // BufferPolicyType FleetAutoscalerPolicyType is a simple buffering strategy for Ready + // GameServers BufferPolicyType FleetAutoscalerPolicyType = "Buffer" ) @@ -124,7 +127,7 @@ func (fas *FleetAutoscaler) ValidateUpdate(new *FleetAutoscaler, causes []metav1 return new.ValidateAutoScalingSettings(causes) } -//ValidateAutoScalingSettings validates the FleetAutoscaler scaling settings +// ValidateAutoScalingSettings validates the FleetAutoscaler scaling settings func (fas *FleetAutoscaler) ValidateAutoScalingSettings(causes []metav1.StatusCause) []metav1.StatusCause { if fas.Spec.Policy.Type == BufferPolicyType { causes = fas.Spec.Policy.Buffer.ValidateAutoScalingBufferPolicy(causes) @@ -132,7 +135,7 @@ func (fas *FleetAutoscaler) ValidateAutoScalingSettings(causes []metav1.StatusCa return causes } -//ValidateAutoScalingSettings validates the FleetAutoscaler Buffer policy settings +// ValidateAutoScalingBufferPolicy validates the FleetAutoscaler Buffer policy settings func (b *BufferPolicy) ValidateAutoScalingBufferPolicy(causes []metav1.StatusCause) []metav1.StatusCause { if b == nil { return append(causes, metav1.StatusCause{ diff --git a/pkg/apis/stable/v1alpha1/scheduling.go b/pkg/apis/stable/v1alpha1/scheduling.go index 13cf63d0c5..9f17579427 100644 --- a/pkg/apis/stable/v1alpha1/scheduling.go +++ b/pkg/apis/stable/v1alpha1/scheduling.go @@ -29,3 +29,7 @@ const ( // In future versions, this will also impact Fleet scale down, and Pod Scheduling. Distributed SchedulingStrategy = "Distributed" ) + +// SchedulingStrategy is the strategy that a Fleet & GameServers will use +// when scheduling GameServers' Pods across a cluster. +type SchedulingStrategy string diff --git a/pkg/gameservers/localsdk.go b/pkg/gameservers/localsdk.go index ec2b04a9e4..96b8b228a7 100644 --- a/pkg/gameservers/localsdk.go +++ b/pkg/gameservers/localsdk.go @@ -223,7 +223,7 @@ func (l *LocalSDKServer) setGameServerFromFilePath(filePath string) error { logrus.WithField("filePath", filePath).Info("Reading GameServer configuration") reader, err := os.Open(filePath) // nolint: gosec - defer reader.Close() // nolint: megacheck + defer reader.Close() // nolint: megacheck,errcheck if err != nil { return err diff --git a/test/e2e/framework/framework.go b/test/e2e/framework/framework.go index d4df574eb7..b85b84fe16 100644 --- a/test/e2e/framework/framework.go +++ b/test/e2e/framework/framework.go @@ -152,7 +152,7 @@ func (f *Framework) ListGameServersFromFleet(flt *v1alpha1.Fleet) ([]v1alpha1.Ga return results, nil } -// FleetReadyCountCondition checks the ready count in a fleet +// FleetReadyCount returns the ready count in a fleet func FleetReadyCount(amount int32) func(fleet *v1alpha1.Fleet) bool { return func(fleet *v1alpha1.Fleet) bool { return fleet.Status.ReadyReplicas == amount