mirror of
https://github.com/psviderski/uncloud.git
synced 2026-08-26 11:03:34 +00:00
chore: Enable more linters
This commit is contained in:
@@ -14,7 +14,7 @@ on:
|
|||||||
permissions:
|
permissions:
|
||||||
contents: read
|
contents: read
|
||||||
jobs:
|
jobs:
|
||||||
test:
|
lint:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
|
|||||||
+20
-3
@@ -2,11 +2,28 @@ version: "2"
|
|||||||
linters:
|
linters:
|
||||||
default: none
|
default: none
|
||||||
enable:
|
enable:
|
||||||
|
- bodyclose
|
||||||
|
# - dogsled
|
||||||
|
- dupl
|
||||||
# - errcheck
|
# - errcheck
|
||||||
- govet
|
- gochecknoinits
|
||||||
|
- goconst
|
||||||
|
# - gocritic
|
||||||
|
# - gocyclo
|
||||||
|
# - godot
|
||||||
|
# - gosec
|
||||||
|
# - govet
|
||||||
- ineffassign
|
- ineffassign
|
||||||
- staticcheck
|
- misspell
|
||||||
- unused
|
- nakedret
|
||||||
|
# - prealloc
|
||||||
|
# - revive
|
||||||
|
# - staticcheck
|
||||||
|
- unconvert
|
||||||
|
# - unparam
|
||||||
|
# - unused
|
||||||
|
- whitespace
|
||||||
|
|
||||||
formatters:
|
formatters:
|
||||||
enable:
|
enable:
|
||||||
- gofmt
|
- gofmt
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ version = "2.2.2"
|
|||||||
backend = "aqua:golangci/golangci-lint"
|
backend = "aqua:golangci/golangci-lint"
|
||||||
|
|
||||||
[tools.golangci-lint.checksums]
|
[tools.golangci-lint.checksums]
|
||||||
|
"golangci-lint-2.2.2-darwin-arm64.tar.gz" = "sha256:d84d94d042c0d495fd1746f3d18948a75de163b17a14e8de3ef840928dd2df74"
|
||||||
"golangci-lint-2.2.2-linux-amd64.tar.gz" = "sha256:c27fbde948a87d326feacd21df2f61a9c54dbd2e3bfa185c0a1cd6917a6f964f"
|
"golangci-lint-2.2.2-linux-amd64.tar.gz" = "sha256:c27fbde948a87d326feacd21df2f61a9c54dbd2e3bfa185c0a1cd6917a6f964f"
|
||||||
|
|
||||||
[tools.protoc]
|
[tools.protoc]
|
||||||
|
|||||||
@@ -93,9 +93,17 @@ vet:
|
|||||||
format:
|
format:
|
||||||
go fmt ./...
|
go fmt ./...
|
||||||
|
|
||||||
.PHONY: lint
|
LINT_TARGETS := lint lint-and-fix
|
||||||
lint:
|
.PHONY: $(LINT_TARGETS) _lint
|
||||||
golangci-lint run
|
$(LINT_TARGETS): _lint
|
||||||
|
lint: ARGS=
|
||||||
|
lint-and-fix: ARGS=--fix
|
||||||
|
_lint:
|
||||||
|
golangci-lint run $(ARGS)
|
||||||
|
|
||||||
|
# .PHONY: lint-and-fix
|
||||||
|
# lint-and-fix: lint
|
||||||
|
# ARGS="--fix"
|
||||||
|
|
||||||
.PHONY: docs-image-push
|
.PHONY: docs-image-push
|
||||||
docs-image:
|
docs-image:
|
||||||
|
|||||||
@@ -4,18 +4,19 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"log/slog"
|
||||||
|
|
||||||
"github.com/hashicorp/serf/serf"
|
"github.com/hashicorp/serf/serf"
|
||||||
"github.com/ipfs/boxo/datastore/dshelp"
|
"github.com/ipfs/boxo/datastore/dshelp"
|
||||||
dag "github.com/ipfs/boxo/ipld/merkledag"
|
dag "github.com/ipfs/boxo/ipld/merkledag"
|
||||||
"github.com/ipfs/go-cid"
|
"github.com/ipfs/go-cid"
|
||||||
ds "github.com/ipfs/go-datastore"
|
ds "github.com/ipfs/go-datastore"
|
||||||
ipld "github.com/ipfs/go-ipld-format"
|
ipld "github.com/ipfs/go-ipld-format"
|
||||||
"log/slog"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// Implements the DAGService interface.
|
// Implements the DAGService interface.
|
||||||
// TODO: implement SessionDAGService to optimize node fetching.
|
// TODO: implement SessionDAGService to optimize node fetching.
|
||||||
// TOOD: persistentSerfDAG?
|
// TODO: persistentSerfDAG?
|
||||||
type dagSyncer struct {
|
type dagSyncer struct {
|
||||||
// Persistent storage for the nodes.
|
// Persistent storage for the nodes.
|
||||||
store ds.Datastore
|
store ds.Datastore
|
||||||
@@ -50,8 +51,7 @@ func (d *dagSyncer) Get(ctx context.Context, cid cid.Cid) (ipld.Node, error) {
|
|||||||
}
|
}
|
||||||
slog.Debug("Queried node from peers", "cid", cid, "deadline", query.Deadline())
|
slog.Debug("Queried node from peers", "cid", cid, "deadline", query.Deadline())
|
||||||
|
|
||||||
responded := false
|
for {
|
||||||
for !responded {
|
|
||||||
select {
|
select {
|
||||||
case resp, ok := <-query.ResponseCh():
|
case resp, ok := <-query.ResponseCh():
|
||||||
if !ok {
|
if !ok {
|
||||||
@@ -63,7 +63,6 @@ func (d *dagSyncer) Get(ctx context.Context, cid cid.Cid) (ipld.Node, error) {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
slog.Debug("Received node from peer", "cid", cid, "peer", resp.From)
|
slog.Debug("Received node from peer", "cid", cid, "peer", resp.From)
|
||||||
responded = true
|
|
||||||
query.Close()
|
query.Close()
|
||||||
|
|
||||||
node, err = nodeFromBytes(resp.Payload)
|
node, err = nodeFromBytes(resp.Payload)
|
||||||
|
|||||||
@@ -88,7 +88,6 @@ func ServiceSpecFromCompose(project *types.Project, serviceName string) (api.Ser
|
|||||||
default:
|
default:
|
||||||
return spec, fmt.Errorf("unsupported deploy mode: '%s'", service.Deploy.Mode)
|
return spec, fmt.Errorf("unsupported deploy mode: '%s'", service.Deploy.Mode)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: can service.tmpfs be handled as tmpfs volume mounts as well?
|
// TODO: can service.tmpfs be handled as tmpfs volume mounts as well?
|
||||||
|
|||||||
@@ -160,6 +160,5 @@ func TestComposeBuild(t *testing.T) {
|
|||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
assert.Equal(t, tags, []string{"version2"}, "Tags for service service-second do not match")
|
assert.Equal(t, tags, []string{"version2"}, "Tags for service service-second do not match")
|
||||||
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -97,7 +97,7 @@ func TestComposeDeployment(t *testing.T) {
|
|||||||
deploy, err := compose.NewDeployment(ctx, cli, project)
|
deploy, err := compose.NewDeployment(ctx, cli, project)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
plan, err := deploy.Plan(ctx)
|
_, err = deploy.Plan(ctx)
|
||||||
require.ErrorContains(t, err, "external volumes not found: 'test-compose-volumes-external'")
|
require.ErrorContains(t, err, "external volumes not found: 'test-compose-volumes-external'")
|
||||||
|
|
||||||
externalVolumeOpts := volume.CreateOptions{Name: "test-compose-volumes-external"}
|
externalVolumeOpts := volume.CreateOptions{Name: "test-compose-volumes-external"}
|
||||||
@@ -108,7 +108,7 @@ func TestComposeDeployment(t *testing.T) {
|
|||||||
deploy, err = compose.NewDeployment(ctx, cli, project)
|
deploy, err = compose.NewDeployment(ctx, cli, project)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
plan, err = deploy.Plan(ctx)
|
plan, err := deploy.Plan(ctx)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
assert.Len(t, plan.Operations, 5, "Expected 2 volumes creation and 3 services to deploy")
|
assert.Len(t, plan.Operations, 5, "Expected 2 volumes creation and 3 services to deploy")
|
||||||
|
|
||||||
|
|||||||
@@ -1119,7 +1119,7 @@ func TestServiceLifecycle(t *testing.T) {
|
|||||||
Entrypoint: []string{"///pause"},
|
Entrypoint: []string{"///pause"},
|
||||||
Env: map[string]string{
|
Env: map[string]string{
|
||||||
"VAR": "value",
|
"VAR": "value",
|
||||||
"EMTPY": "",
|
"EMPTY": "",
|
||||||
"BOOL": "true",
|
"BOOL": "true",
|
||||||
"": "ignored",
|
"": "ignored",
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user