Skip to content

Commit

Permalink
More stringent linting rules (and update linter)
Browse files Browse the repository at this point in the history
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 88adba4
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 13 deletions.
6 changes: 4 additions & 2 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -43,7 +42,6 @@ output:
# print linter name in the end of issue text, default is true
print-linter-name: true


linters:
enable:
- megacheck
Expand All @@ -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
2 changes: 1 addition & 1 deletion build/build-image/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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 && \
Expand Down
8 changes: 3 additions & 5 deletions pkg/apis/stable/v1alpha1/fleet.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand All @@ -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"`
Expand All @@ -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"`
Expand Down
9 changes: 6 additions & 3 deletions pkg/apis/stable/v1alpha1/fleetautoscaler.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down Expand Up @@ -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{
Expand Down
4 changes: 4 additions & 0 deletions pkg/apis/stable/v1alpha1/scheduling.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion pkg/gameservers/localsdk.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/framework/framework.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 88adba4

Please sign in to comment.