Skip to content

Commit

Permalink
chore: bump Go to 1.23.3, rekres, regenerate sources, make linters happy
Browse files Browse the repository at this point in the history
Bump Go, rekres (using a build with this fix: siderolabs/kres#464), regenerate sources, comply with the new golangci-lint linters.

Signed-off-by: Utku Ozdemir <[email protected]>
  • Loading branch information
utkuozdemir committed Nov 22, 2024
1 parent 9085e82 commit 033e051
Show file tree
Hide file tree
Showing 31 changed files with 78 additions and 68 deletions.
3 changes: 1 addition & 2 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# THIS FILE WAS AUTOMATICALLY GENERATED, PLEASE DO NOT EDIT.
#
# Generated on 2024-10-30T12:55:25Z by kres 6d3cad4.
# Generated on 2024-11-21T22:07:50Z by kres a8af16d.

# options for analysis running
run:
Expand Down Expand Up @@ -127,7 +127,6 @@ linters:
- gochecknoglobals
- gochecknoinits
- godox
- gomnd
- gomoddirectives
- gosec
- inamedparam
Expand Down
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# syntax = docker/dockerfile-upstream:1.11.0-labs
# syntax = docker/dockerfile-upstream:1.11.1-labs

# THIS FILE WAS AUTOMATICALLY GENERATED, PLEASE DO NOT EDIT.
#
# Generated on 2024-11-05T11:24:27Z by kres 5fa0b38-dirty.
# Generated on 2024-11-21T22:07:50Z by kres a8af16d.

ARG JS_TOOLCHAIN
ARG TOOLCHAIN
Expand Down
23 changes: 17 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# THIS FILE WAS AUTOMATICALLY GENERATED, PLEASE DO NOT EDIT.
#
# Generated on 2024-11-05T11:24:27Z by kres 5fa0b38-dirty.
# Generated on 2024-11-21T22:34:08Z by kres b3b0da76.

# common variables

Expand All @@ -24,11 +24,11 @@ PROTOBUF_GO_VERSION ?= 1.35.1
GRPC_GO_VERSION ?= 1.5.1
GRPC_GATEWAY_VERSION ?= 2.23.0
VTPROTOBUF_VERSION ?= 0.6.0
GOIMPORTS_VERSION ?= 0.26.0
GOIMPORTS_VERSION ?= 0.27.0
DEEPCOPY_VERSION ?= v0.5.6
GOLANGCILINT_VERSION ?= v1.61.0
GOLANGCILINT_VERSION ?= v1.62.0
GOFUMPT_VERSION ?= v0.7.0
GO_VERSION ?= 1.23.2
GO_VERSION ?= 1.23.3
GO_BUILDFLAGS ?=
GO_LDFLAGS ?=
CGO_ENABLED ?= 0
Expand All @@ -43,11 +43,13 @@ PLATFORM ?= linux/amd64
PROGRESS ?= auto
PUSH ?= false
CI_ARGS ?=
BUILDKIT_MULTI_PLATFORM ?= 1
COMMON_ARGS = --file=Dockerfile
COMMON_ARGS += --provenance=false
COMMON_ARGS += --progress=$(PROGRESS)
COMMON_ARGS += --platform=$(PLATFORM)
COMMON_ARGS += --push=$(PUSH)
COMMON_ARGS += --build-arg=BUILDKIT_MULTI_PLATFORM=$(BUILDKIT_MULTI_PLATFORM)
COMMON_ARGS += --build-arg=ARTIFACTS="$(ARTIFACTS)"
COMMON_ARGS += --build-arg=SHA="$(SHA)"
COMMON_ARGS += --build-arg=TAG="$(TAG)"
Expand Down Expand Up @@ -155,9 +157,18 @@ target-%: ## Builds the specified target defined in the Dockerfile. The build r

local-%: ## Builds the specified target defined in the Dockerfile using the local output type. The build result will be output to the specified local destination.
@$(MAKE) target-$* TARGET_ARGS="--output=type=local,dest=$(DEST) $(TARGET_ARGS)"
@PLATFORM=$(PLATFORM) DEST=$(DEST) bash -c '\
for platform in $$(tr "," "\n" <<< "$$PLATFORM"); do \
echo $$platform; \
directory="$${platform//\//_}"; \
if [[ -d "$$DEST/$$directory" ]]; then \
mv "$$DEST/$$directory/"* $$DEST; \
rmdir "$$DEST/$$directory/"; \
fi; \
done'

generate-frontend: ## Generate .proto definitions.
@$(MAKE) local-$@ DEST=./
@$(MAKE) local-$@ DEST=./ BUILDKIT_MULTI_PLATFORM=0

.PHONY: js
js: ## Prepare js base toolchain.
Expand All @@ -178,7 +189,7 @@ $(ARTIFACTS)/frontend-js:
frontend: $(ARTIFACTS)/frontend-js ## Builds js release for frontend.

generate: ## Generate .proto definitions.
@$(MAKE) local-$@ DEST=./
@$(MAKE) local-$@ DEST=./ BUILDKIT_MULTI_PLATFORM=0

lint-golangci-lint-client: ## Runs golangci-lint linter.
@$(MAKE) target-$@
Expand Down
3 changes: 1 addition & 2 deletions client/.golangci.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# THIS FILE WAS AUTOMATICALLY GENERATED, PLEASE DO NOT EDIT.
#
# Generated on 2024-06-19T21:17:41Z by kres 4c9f215.
# Generated on 2024-11-21T22:07:50Z by kres a8af16d.

# options for analysis running
run:
Expand Down Expand Up @@ -127,7 +127,6 @@ linters:
- gochecknoglobals
- gochecknoinits
- godox
- gomnd
- gomoddirectives
- gosec
- inamedparam
Expand Down
2 changes: 1 addition & 1 deletion client/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/siderolabs/omni/client

go 1.23.0
go 1.23.3

replace (
// forked go-yaml that introduces RawYAML interface, which can be used to populate YAML fields using bytes
Expand Down
2 changes: 1 addition & 1 deletion client/pkg/infra/controllers/provision.go
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ func (ctrl *ProvisionController[T]) reconcileRunning(ctx context.Context, r cont
machineRequestStatus.TypedSpec().Value.Error = ""
machineRequestStatus.TypedSpec().Value.Stage = specs.MachineRequestStatusSpec_PROVISIONING

if err = safe.WriterModify(ctx, r, res.(T), func(st T) error { //nolint:forcetypeassert
if err = safe.WriterModify(ctx, r, res.(T), func(st T) error { //nolint:forcetypeassert,errcheck
err = step.Run(ctx, logger, provision.NewContext(
machineRequest,
machineRequestStatus,
Expand Down
4 changes: 4 additions & 0 deletions client/pkg/template/internal/models/machineset.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ type MachineClassConfig struct {
}

// Size extends protobuf generated allocation type enum to parse string constants.
//
//nolint:recvcheck
type Size struct {
Value uint32
AllocationType specs.MachineSetSpec_MachineAllocation_Type
Expand Down Expand Up @@ -112,6 +114,8 @@ func (c Size) MarshalYAML() (any, error) {
}

// UpdateStrategyType extends protobuf generated update strategy enum to parse string constants.
//
//nolint:recvcheck
type UpdateStrategyType uint32

// UnmarshalYAML implements yaml.Unmarshaler.
Expand Down
2 changes: 1 addition & 1 deletion cmd/integration-test/pkg/tests/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func resourceDetails(res resource.Resource) string {
}

if res.Metadata().Type() == omni.MachineStatusType {
network := res.Spec().(*omni.MachineStatusSpec).Value.Network //nolint:forcetypeassert
network := res.Spec().(*omni.MachineStatusSpec).Value.Network //nolint:forcetypeassert,errcheck
if network != nil {
parts = append(parts, fmt.Sprintf("hostname: %s", network.Hostname))
}
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/siderolabs/omni

go 1.23.2
go 1.23.3

replace (
// use nested module
Expand Down
2 changes: 1 addition & 1 deletion go.work
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
go 1.23.2
go 1.23.3

use (
.
Expand Down
38 changes: 15 additions & 23 deletions internal/backend/grpc/management.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,14 @@ import (
"github.com/siderolabs/omni/internal/pkg/xcontext"
)

type talosRuntime interface {
GetClient(ctx context.Context, clusterName string) (*talos.Client, error)
}

type kubernetesRuntime interface {
GetKubeconfig(ctx context.Context, cluster *commonOmni.Context) (*rest.Config, error)
}

// JWTSigningKeyProvider is an interface for a JWT signing key provider.
type JWTSigningKeyProvider interface {
SigningKey(ctx context.Context) (op.SigningKey, error)
Expand Down Expand Up @@ -411,11 +419,7 @@ func (s *managementServer) KubernetesUpgradePreChecks(ctx context.Context, req *
return nil, status.Errorf(codes.InvalidArgument, "unsupported upgrade path: %s", path)
}

type kubeConfigGetter interface {
GetKubeconfig(ctx context.Context, cluster *commonOmni.Context) (*rest.Config, error)
}

k8sRuntime, err := runtime.LookupInterface[kubeConfigGetter](kubernetes.Name)
k8sRuntime, err := runtime.LookupInterface[kubernetesRuntime](kubernetes.Name)
if err != nil {
return nil, err
}
Expand All @@ -425,16 +429,12 @@ func (s *managementServer) KubernetesUpgradePreChecks(ctx context.Context, req *
return nil, fmt.Errorf("error getting kubeconfig: %w", err)
}

type talosClientGetter interface {
GetClient(ctx context.Context, clusterName string) (*talos.Client, error)
}

talosRuntime, err := runtime.LookupInterface[talosClientGetter](talos.Name)
talosRt, err := runtime.LookupInterface[talosRuntime](talos.Name)
if err != nil {
return nil, err
}

talosClient, err := talosRuntime.GetClient(ctx, requestContext.Name)
talosClient, err := talosRt.GetClient(ctx, requestContext.Name)
if err != nil {
return nil, fmt.Errorf("error getting talos client: %w", err)
}
Expand Down Expand Up @@ -504,30 +504,22 @@ func (s *managementServer) KubernetesSyncManifests(req *management.KubernetesSyn
return status.Error(codes.InvalidArgument, "unable to extract request context")
}

type kubernetesConfigurator interface {
GetKubeconfig(ctx context.Context, context *commonOmni.Context) (*rest.Config, error)
}

kubernetesRuntime, err := runtime.LookupInterface[kubernetesConfigurator](kubernetes.Name)
k8sRuntime, err := runtime.LookupInterface[kubernetesRuntime](kubernetes.Name)
if err != nil {
return err
}

cfg, err := kubernetesRuntime.GetKubeconfig(ctx, requestContext)
cfg, err := k8sRuntime.GetKubeconfig(ctx, requestContext)
if err != nil {
return fmt.Errorf("failed to get kubeconfig: %w", err)
}

type talosClientProvider interface {
GetClient(ctx context.Context, clusterName string) (*talos.Client, error)
}

talosRuntime, err := runtime.LookupInterface[talosClientProvider](talos.Name)
talosRt, err := runtime.LookupInterface[talosRuntime](talos.Name)
if err != nil {
return err
}

talosClient, err := talosRuntime.GetClient(ctx, requestContext.Name)
talosClient, err := talosRt.GetClient(ctx, requestContext.Name)
if err != nil {
return fmt.Errorf("failed to get talos client: %w", err)
}
Expand Down
2 changes: 1 addition & 1 deletion internal/backend/k8sproxy/multiplex.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ func (m *multiplexer) getClusterConnector(ctx context.Context, clusterName strin
return nil, res.Err
}

return res.Val.(*clusterConnector), nil //nolint:forcetypeassert
return res.Val.(*clusterConnector), nil //nolint:forcetypeassert,errcheck
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ func TestStorage(t *testing.T) {

assert.Len(t, keySet, 1)
assert.Equal(t, keySet[0].ID(), signingKey.ID())
assert.Equal(t, *keySet[0].Key().(*rsa.PublicKey), privateKey.PublicKey) //nolint:forcetypeassert
assert.Equal(t, *keySet[0].Key().(*rsa.PublicKey), privateKey.PublicKey) //nolint:forcetypeassert,errcheck

expectedPublicKeyIDs := []string{signingKey.ID()}

Expand Down
2 changes: 1 addition & 1 deletion internal/backend/runtime/kubernetes/kubernetes.go
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ func (r *Runtime) getOrCreateClient(ctx context.Context, opts *runtime.QueryOpti
return nil, res.Err
}

return res.Val.(*Client), nil //nolint:forcetypeassert // we know the type
return res.Val.(*Client), nil //nolint:forcetypeassert,errcheck // we know the type
}
}

Expand Down
2 changes: 1 addition & 1 deletion internal/backend/runtime/omni/audit/audit_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ func TestAudit(t *testing.T) {
subFS: fsSub(t, logDir, "log"),
File: "2012-01-01.jsonlog",
},
os.DirFS(tempDir).(subFS), //nolint:forcetypeassert
os.DirFS(tempDir).(subFS), //nolint:forcetypeassert,errcheck
cmpIgnoreTime,
)
}
Expand Down
4 changes: 2 additions & 2 deletions internal/backend/runtime/omni/audit/log_file.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ func (l *LogFile) RemoveFiles(start, end time.Time) error {
return fmt.Errorf("end time is before start time")
}

dirFiles, err := getDirFiles(os.DirFS(l.dir).(fs.ReadDirFS))
dirFiles, err := getDirFiles(os.DirFS(l.dir).(fs.ReadDirFS)) //nolint:errcheck
if err != nil {
return err
}
Expand Down Expand Up @@ -148,7 +148,7 @@ func (l *LogFile) ReadAuditLog(start, end time.Time) (io.ReadCloser, error) {
l.mu.Lock()
defer l.mu.Unlock()

dirFiles, err := getDirFiles(os.DirFS(l.dir).(fs.ReadDirFS))
dirFiles, err := getDirFiles(os.DirFS(l.dir).(fs.ReadDirFS)) //nolint:errcheck
if err != nil {
return nil, fmt.Errorf("failed to read audit log directory: %w", err)
}
Expand Down
8 changes: 4 additions & 4 deletions internal/backend/runtime/omni/audit/log_file_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func TestLogFile_CurrentDay(t *testing.T) {
equalDirs(
t,
fsSub(t, currentDay, "currentday"),
os.DirFS(dir).(subFS), //nolint:forcetypeassert
os.DirFS(dir).(subFS), //nolint:forcetypeassert,errcheck
defaultCmp,
)
}
Expand Down Expand Up @@ -78,7 +78,7 @@ func TestLogFile_CurrentAndNewDay(t *testing.T) {
equalDirs(
t,
fsSub(t, nextDay, "nextday"),
os.DirFS(dir).(subFS), //nolint:forcetypeassert
os.DirFS(dir).(subFS), //nolint:forcetypeassert,errcheck
defaultCmp,
)
}
Expand Down Expand Up @@ -119,7 +119,7 @@ func TestLogFile_CurrentDayConcurrent(t *testing.T) {
t,
fsSub(t, concurrent, "concurrent"),
&sortedFileFS{
subFS: os.DirFS(dir).(subFS), //nolint:forcetypeassert
subFS: os.DirFS(dir).(subFS), //nolint:forcetypeassert,errcheck
},
defaultCmp,
)
Expand All @@ -137,7 +137,7 @@ type subFS interface {
}

func fsSub(t *testing.T, subFs subFS, folder string) subFS {
return must.Value(fs.Sub(subFs, filepath.Join("testdata", folder)))(t).(subFS) //nolint:forcetypeassert
return must.Value(fs.Sub(subFs, filepath.Join("testdata", folder)))(t).(subFS) //nolint:forcetypeassert,errcheck
}

func equalDirs(t *testing.T, expected, actual subFS, cmpFn func(t *testing.T, expected, actual string)) {
Expand Down
2 changes: 1 addition & 1 deletion internal/backend/runtime/omni/audit/walk_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ func TestFindOldFiles(t *testing.T) {
now := time.Date(2012, 1, 30, 0, 0, 0, 1, time.Local)
thirtyDays := audit.TruncateToDate(now.AddDate(0, 0, -30))

dirFiles := must.Value(audit.GetDirFiles(must.Value(mapFS.Sub("logdir"))(t).(fs.ReadDirFS)))(t) //nolint:forcetypeassert
dirFiles := must.Value(audit.GetDirFiles(must.Value(mapFS.Sub("logdir"))(t).(fs.ReadDirFS)))(t) //nolint:forcetypeassert,errcheck
logFiles := audit.FilterLogFiles(dirFiles)
olderFiles := audit.FilterByTime(logFiles, time.Unix(0, 0), thirtyDays)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -285,11 +285,7 @@ func (auditor *nodeAuditor) unmarkNodesAsInvalid(cluster string, nodes []string)
}

func getKubernetesClient(ctx context.Context, cluster string) (KubernetesClient, error) {
type kubeRuntime interface {
GetClient(ctx context.Context, cluster string) (*kubernetes.Client, error)
}

k8s, err := runtime.LookupInterface[kubeRuntime](kubernetes.Name)
k8s, err := runtime.LookupInterface[kubernetesRuntime](kubernetes.Name)
if err != nil {
return nil, err
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -523,11 +523,7 @@ var controlplanePodSelector = func() labels.Selector {
}()

func (ctrl *KubernetesStatusController) startWatcher(ctx context.Context, logger *zap.Logger, cluster string, notifyCh chan<- kubernetesWatcherNotify) error {
type kubernetesClient interface {
GetClient(ctx context.Context, cluster string) (*kubernetes.Client, error)
}

r, err := runtime.LookupInterface[kubernetesClient](kubernetes.Name)
r, err := runtime.LookupInterface[kubernetesRuntime](kubernetes.Name)
if err != nil {
return err
}
Expand Down Expand Up @@ -816,8 +812,8 @@ func IsExposedServiceEvent(k8sObject, oldK8sObject any, logger *zap.Logger) bool
return false
}

oldAnnotations := oldK8sObject.(*corev1.Service).GetObjectMeta().GetAnnotations() //nolint:forcetypeassert
newAnnotations := k8sObject.(*corev1.Service).GetObjectMeta().GetAnnotations() //nolint:forcetypeassert
oldAnnotations := oldK8sObject.(*corev1.Service).GetObjectMeta().GetAnnotations() //nolint:forcetypeassert,errcheck
newAnnotations := k8sObject.(*corev1.Service).GetObjectMeta().GetAnnotations() //nolint:forcetypeassert,errcheck

for _, key := range []string{ServiceLabelAnnotationKey, ServicePortAnnotationKey, ServiceIconAnnotationKey} {
if oldAnnotations[key] != newAnnotations[key] {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func NewLabelsExtractorController[T generic.ResourceWithRD]() *qtransform.QContr

*res.Metadata() = resource.NewMetadata(rd.DefaultNamespace, rd.Type, labels.Metadata().ID(), resource.VersionUndefined)

return res.(T) //nolint:forcetypeassert
return res.(T) //nolint:forcetypeassert,errcheck
},
TransformFunc: func(_ context.Context, _ controller.Reader, _ *zap.Logger, res T, labels *system.ResourceLabels[T]) error {
*labels.Metadata().Labels() = *res.Metadata().Labels()
Expand Down
Loading

0 comments on commit 033e051

Please sign in to comment.