Skip to content

Commit

Permalink
Fix formatting and enable more linters for that
Browse files Browse the repository at this point in the history
  • Loading branch information
koct9i committed Jun 27, 2024
1 parent 85832ef commit 6a6f343
Show file tree
Hide file tree
Showing 24 changed files with 26 additions and 27 deletions.
4 changes: 2 additions & 2 deletions .golangci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ linters:
# - goconst # finds repeated strings that could be replaced by a constant
- gocritic # provides diagnostics that check for bugs, performance and style issues
# - godot # checks if comments end in a period
# - goimports # in addition to fixing imports, goimports also formats your code in the same style as gofmt
- goimports # in addition to fixing imports, goimports also formats your code in the same style as gofmt
# - gomnd # detects magic numbers
- gomoddirectives # manages the use of 'replace', 'retract', and 'excludes' directives in go.mod
- gomodguard # allow and block lists linter for direct Go module dependencies. This is different from depguard where there are different block types for example version constraints and module recommendations
Expand Down Expand Up @@ -110,7 +110,7 @@ linters:
# - unparam # reports unused function parameters
- usestdlibvars # detects the possibility to use variables/constants from the Go standard library
- wastedassign # finds wasted assignment statements
# - whitespace # detects leading and trailing whitespace
- whitespace # detects leading and trailing whitespace
# - wrapcheck # checks that errors returned from external packages are wrapped
# - wsl # add or remove empty lines

Expand Down
1 change: 0 additions & 1 deletion api/v1/ytsaurus_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,6 @@ func (r *Ytsaurus) validateInstanceSpec(instanceSpec InstanceSpec, path *field.P

if instanceSpec.Locations != nil {
for locationIdx, location := range instanceSpec.Locations {

inVolumeMount := false
for _, volumeMount := range instanceSpec.VolumeMounts {
if strings.HasPrefix(location.Path, volumeMount.MountPath) {
Expand Down
3 changes: 2 additions & 1 deletion controllers/chyt_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,11 @@ package controllers

import (
"context"
"time"

corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/types"
"k8s.io/client-go/tools/record"
"time"

"k8s.io/apimachinery/pkg/runtime"
ctrl "sigs.k8s.io/controller-runtime"
Expand Down
3 changes: 2 additions & 1 deletion controllers/chyt_sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@ package controllers

import (
"context"
"time"

ytv1 "github.com/ytsaurus/yt-k8s-operator/api/v1"
"github.com/ytsaurus/yt-k8s-operator/pkg/apiproxy"
"github.com/ytsaurus/yt-k8s-operator/pkg/components"
"github.com/ytsaurus/yt-k8s-operator/pkg/ytconfig"
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/log"
"time"
)

func (r *ChytReconciler) Sync(ctx context.Context, resource *ytv1.Chyt, ytsaurus *ytv1.Ytsaurus) (ctrl.Result, error) {
Expand Down
3 changes: 2 additions & 1 deletion controllers/spyt_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,11 @@ package controllers

import (
"context"
"time"

corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/types"
"k8s.io/client-go/tools/record"
"time"

"k8s.io/apimachinery/pkg/runtime"
ctrl "sigs.k8s.io/controller-runtime"
Expand Down
3 changes: 2 additions & 1 deletion controllers/spyt_sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@ package controllers

import (
"context"
"time"

ytv1 "github.com/ytsaurus/yt-k8s-operator/api/v1"
"github.com/ytsaurus/yt-k8s-operator/pkg/apiproxy"
"github.com/ytsaurus/yt-k8s-operator/pkg/components"
"github.com/ytsaurus/yt-k8s-operator/pkg/ytconfig"
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/log"
"time"
)

func (r *SpytReconciler) Sync(ctx context.Context, resource *ytv1.Spyt, ytsaurus *ytv1.Ytsaurus) (ctrl.Result, error) {
Expand Down
1 change: 1 addition & 0 deletions controllers/ytsaurus_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package controllers

import (
"context"

appsv1 "k8s.io/api/apps/v1"
corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/runtime"
Expand Down
3 changes: 2 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,11 @@ package main

import (
"flag"
"go.uber.org/zap/zapcore"
"os"
"strings"

"go.uber.org/zap/zapcore"

"github.com/ytsaurus/yt-k8s-operator/controllers"
metricsserver "sigs.k8s.io/controller-runtime/pkg/metrics/server"
"sigs.k8s.io/controller-runtime/pkg/webhook"
Expand Down
1 change: 1 addition & 0 deletions pkg/apiproxy/chyt.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package apiproxy

import (
"context"

ytv1 "github.com/ytsaurus/yt-k8s-operator/api/v1"
"k8s.io/apimachinery/pkg/api/meta"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand Down
1 change: 1 addition & 0 deletions pkg/apiproxy/proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package apiproxy
import (
"context"
"fmt"

corev1 "k8s.io/api/core/v1"
apierrors "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand Down
1 change: 1 addition & 0 deletions pkg/apiproxy/spyt.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package apiproxy

import (
"context"

ytv1 "github.com/ytsaurus/yt-k8s-operator/api/v1"
"k8s.io/apimachinery/pkg/api/meta"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand Down
10 changes: 5 additions & 5 deletions pkg/apiproxy/ytsaurus.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,10 +140,10 @@ func (c *Ytsaurus) IsStatusConditionFalse(conditionType string) bool {

func sortConditions(conditions []metav1.Condition) {
slices.SortStableFunc(conditions, func(a, b metav1.Condition) int {
statusOrder := []metav1.ConditionStatus{metav1.ConditionTrue, metav1.ConditionFalse, metav1.ConditionUnknown}
if diff := cmp.Compare(slices.Index(statusOrder, a.Status), slices.Index(statusOrder, b.Status)); diff != 0 {
return diff
}
return a.LastTransitionTime.Compare(b.LastTransitionTime.Time)
statusOrder := []metav1.ConditionStatus{metav1.ConditionTrue, metav1.ConditionFalse, metav1.ConditionUnknown}
if diff := cmp.Compare(slices.Index(statusOrder, a.Status), slices.Index(statusOrder, b.Status)); diff != 0 {
return diff
}
return a.LastTransitionTime.Compare(b.LastTransitionTime.Time)
})
}
1 change: 0 additions & 1 deletion pkg/components/chyt.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ func NewChyt(
cfgen *ytconfig.Generator,
chyt *apiproxy.Chyt,
ytsaurus *ytv1.Ytsaurus) *Chyt {

l := labeller.Labeller{
ObjectMeta: &chyt.GetResource().ObjectMeta,
APIProxy: chyt.APIProxy(),
Expand Down
2 changes: 0 additions & 2 deletions pkg/components/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ func CreateTabletCells(ctx context.Context, ytClient yt.Client, bundle string, t
ypath.Path(fmt.Sprintf("//sys/tablet_cell_bundles/%s/@tablet_cell_count", bundle)),
&initTabletCellCount,
nil); err != nil {

logger.Error(err, "Getting table_cell_count failed")
return err
}
Expand Down Expand Up @@ -176,7 +175,6 @@ func SetWithIgnoreExisting(path string, value string) string {
func AddAffinity(statefulSet *appsv1.StatefulSet,
nodeSelectorRequirementKey string,
nodeSelectorRequirementValues []string) {

affinity := &corev1.Affinity{}
if statefulSet.Spec.Template.Spec.Affinity != nil {
affinity = statefulSet.Spec.Template.Spec.Affinity
Expand Down
1 change: 0 additions & 1 deletion pkg/components/httpproxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ func NewHTTPProxy(
ytsaurus *apiproxy.Ytsaurus,
masterReconciler Component,
spec ytv1.HTTPProxiesSpec) *HttpProxy {

resource := ytsaurus.GetResource()
l := labeller.Labeller{
ObjectMeta: &resource.ObjectMeta,
Expand Down
1 change: 0 additions & 1 deletion pkg/components/spyt.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ func NewSpyt(
cfgen *ytconfig.Generator,
spyt *apiproxy.Spyt,
ytsaurus *ytv1.Ytsaurus) *Spyt {

l := labeller.Labeller{
ObjectMeta: &spyt.GetResource().ObjectMeta,
APIProxy: spyt.APIProxy(),
Expand Down
2 changes: 0 additions & 2 deletions pkg/components/ui.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ func (u *UI) IsUpdatable() bool {
func (u *UI) GetType() consts.ComponentType { return consts.UIType }

func (u *UI) Fetch(ctx context.Context) error {

return resources.Fetch(ctx,
u.microservice,
u.initJob,
Expand Down Expand Up @@ -254,7 +253,6 @@ func (u *UI) doSync(ctx context.Context, dry bool) (ComponentStatus, error) {

if u.ytsaurus.GetClusterState() == ytv1.ClusterStateUpdating {
if IsUpdatingComponent(u.ytsaurus, u) {

if u.ytsaurus.GetUpdateState() == ytv1.UpdateStateWaitingForPodsRemoval {
if !dry {
err = removePods(ctx, u.microservice, &u.localComponent)
Expand Down
3 changes: 2 additions & 1 deletion pkg/components/volume.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@ package components

import (
"fmt"
"path"

ytv1 "github.com/ytsaurus/yt-k8s-operator/api/v1"
"github.com/ytsaurus/yt-k8s-operator/pkg/consts"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"path"
)

func createVolumeClaims(specVolumeClaimTemplates []ytv1.EmbeddedPersistentVolumeClaim) []corev1.PersistentVolumeClaim {
Expand Down
2 changes: 0 additions & 2 deletions pkg/components/ytsaurus_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,6 @@ func (yc *YtsaurusClient) handleUpdatingState(ctx context.Context) (ComponentSta
case ytv1.UpdateStatePossibilityCheck:
if !yc.ytsaurus.IsUpdateStatusConditionTrue(consts.ConditionHasPossibility) &&
!yc.ytsaurus.IsUpdateStatusConditionTrue(consts.ConditionNoPossibility) {

ok, msg, err := yc.HandlePossibilityCheck(ctx)
if err != nil {
return SimpleStatus(SyncStatusUpdating), err
Expand Down Expand Up @@ -301,7 +300,6 @@ func (yc *YtsaurusClient) handleUpdatingState(ctx context.Context) (ComponentSta

case ytv1.UpdateStateWaitingForTabletCellsRecovery:
if !yc.ytsaurus.IsUpdateStatusConditionTrue(consts.ConditionTabletCellsRecovered) {

err = yc.RecoverTableCells(ctx, yc.ytsaurus.GetResource().Status.UpdateStatus.TabletCellBundles)
if err != nil {
return SimpleStatus(SyncStatusUpdating), err
Expand Down
1 change: 1 addition & 0 deletions pkg/resources/deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package resources

import (
"context"

"github.com/ytsaurus/yt-k8s-operator/pkg/apiproxy"
labeller2 "github.com/ytsaurus/yt-k8s-operator/pkg/labeller"
appsv1 "k8s.io/api/apps/v1"
Expand Down
1 change: 0 additions & 1 deletion pkg/testutil/testhelper.go
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,6 @@ func FetchAndCheckConfigMapContainsEventually(h *TestHelper, objectKey, cmKey, e
require.Contains(h.t, cmData, cmKey)
ysonContent := cmData[cmKey]
require.Contains(h.t, ysonContent, expectSubstr)

}

func FetchConfigMapData(h *TestHelper, objectKey, mapKey string) string {
Expand Down
1 change: 0 additions & 1 deletion pkg/ytconfig/cri.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ func GetContainerdSocketPath(spec *ytv1.ExecNodesSpec) string {
}

func (g *NodeGenerator) GetContainerdConfig(spec *ytv1.ExecNodesSpec) ([]byte, error) {

criSpec := spec.JobEnvironment.CRI

var rootPath *string
Expand Down
3 changes: 2 additions & 1 deletion pkg/ytconfig/logging.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ package ytconfig

import (
"fmt"
"go.ytsaurus.tech/library/go/ptr"
"path"

"go.ytsaurus.tech/library/go/ptr"

ytv1 "github.com/ytsaurus/yt-k8s-operator/api/v1"
)

Expand Down
1 change: 0 additions & 1 deletion test/e2e/ytsaurus_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,6 @@ func getMasterPod(name, namespace string) corev1.Pod {
}

func deleteYtsaurus(ctx context.Context, ytsaurus *ytv1.Ytsaurus) {

if err := k8sClient.Delete(ctx, ytsaurus); err != nil {
log.Error(err, "Deleting ytsaurus failed")
}
Expand Down

0 comments on commit 6a6f343

Please sign in to comment.