Permalink
Browse files

More stringent linting rules (and update linter)

I noticed that the linter was allowing through some commenting rules that
weren't very good, so removed the option that was allowing that to happen
`exclude-use-default`, and then also updated the linter while I was in here
to the latest version.
  • Loading branch information...
markmandel committed Nov 15, 2018
1 parent 21c7edc commit 88adba4399df60a8566a71814584df5b540b9e85
@@ -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
@@ -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 && \
@@ -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"`
@@ -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,15 +127,15 @@ 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)
}
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{
@@ -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
@@ -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
@@ -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

0 comments on commit 88adba4

Please sign in to comment.