mirror of
https://github.com/mulgadc/spinifex.git
synced 2026-10-15 09:01:31 +00:00
chore: enable lint rules
This commit is contained in:
@@ -30,6 +30,7 @@ linters:
|
||||
- ineffassign # detects assignments to existing variables that are not used
|
||||
- makezero # finds slice declarations with non-zero initial length followed by append
|
||||
- mirror # catches wrong mirror patterns in bytes/strings usage
|
||||
- misspell # finds commonly misspelled English words
|
||||
- musttag # checks structs passed to marshal/unmarshal have proper tags
|
||||
- modernize # modernizes code to use newer Go idioms (go fix analyzers)
|
||||
- nakedret # finds naked returns in functions
|
||||
@@ -43,6 +44,7 @@ linters:
|
||||
- recvcheck # checks for receiver type consistency (pointer vs value)
|
||||
- sloglint # enforces consistent log/slog usage (key-value pairs, no globals)
|
||||
- staticcheck # extensive static analysis checks
|
||||
- tparallel # detects inappropriate usage of t.Parallel()
|
||||
- unconvert # removes unnecessary type conversions
|
||||
- usestdlibvars # detects hardcoded values that should use stdlib constants
|
||||
- usetesting # catches os.TempDir() etc. in tests — should use t.TempDir()
|
||||
|
||||
@@ -640,6 +640,8 @@ func TestGenerateSignedCert_IncludesHostname(t *testing.T) {
|
||||
// --- Certificate orchestrator ---
|
||||
|
||||
// TestGenerateCertificatesIfNeeded uses subtests to share the initial generation.
|
||||
//
|
||||
//nolint:tparallel // subtests mutate the shared dir in order: SkipsWhenAllExist pins the CA modtime that ForcePreservesCARegeneratesServerCert then regenerates against
|
||||
func TestGenerateCertificatesIfNeeded(t *testing.T) {
|
||||
t.Parallel()
|
||||
dir := t.TempDir()
|
||||
@@ -710,6 +712,7 @@ func TestGenerateServerCertOnly(t *testing.T) {
|
||||
require.NoError(t, GenerateCACert(filepath.Join(caDir, "ca.pem"), filepath.Join(caDir, "ca.key")))
|
||||
|
||||
t.Run("Success", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
dir := t.TempDir()
|
||||
// Copy CA files into test dir
|
||||
caCert, _ := os.ReadFile(filepath.Join(caDir, "ca.pem"))
|
||||
@@ -744,6 +747,7 @@ func TestGenerateServerCertOnly(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("MissingCA", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
dir := t.TempDir()
|
||||
err := GenerateServerCertOnly(dir, "10.0.0.5", "us-east-1", "spinifex.internal")
|
||||
assert.Error(t, err)
|
||||
|
||||
@@ -14,6 +14,8 @@ import (
|
||||
|
||||
// TestGenerateIPSecPeerCert shares a CA across subtests so the 4096-bit
|
||||
// CA-key generation runs once (~0.7s).
|
||||
//
|
||||
//nolint:tparallel // the parent cannot be parallel: it overrides the charonCATrustDir/charonRereadCAs package vars for the duration of the test
|
||||
func TestGenerateIPSecPeerCert(t *testing.T) {
|
||||
// Redirect the charon trust-store symlink at a temp dir so the test
|
||||
// doesn't try to write to /etc/ipsec.d/cacerts on the host. Restored
|
||||
|
||||
@@ -102,7 +102,7 @@ func TestCreatePlacementGroup_MissingName(t *testing.T) {
|
||||
func TestCreatePlacementGroup_MissingStrategyDefaultsToCluster(t *testing.T) {
|
||||
svc := setupTestService(t)
|
||||
out, err := svc.CreatePlacementGroup(context.Background(), &ec2.CreatePlacementGroupInput{
|
||||
GroupName: aws.String("no-strat"),
|
||||
GroupName: aws.String("no-strategy"),
|
||||
}, testAccountID)
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, "cluster", *out.PlacementGroup.Strategy)
|
||||
@@ -111,7 +111,7 @@ func TestCreatePlacementGroup_MissingStrategyDefaultsToCluster(t *testing.T) {
|
||||
func TestCreatePlacementGroup_EmptyStrategyDefaultsToCluster(t *testing.T) {
|
||||
svc := setupTestService(t)
|
||||
out, err := svc.CreatePlacementGroup(context.Background(), &ec2.CreatePlacementGroupInput{
|
||||
GroupName: aws.String("empty-strat"),
|
||||
GroupName: aws.String("empty-strategy"),
|
||||
Strategy: aws.String(""),
|
||||
}, testAccountID)
|
||||
require.NoError(t, err)
|
||||
|
||||
@@ -288,6 +288,7 @@ func TestDescribeTags_InvalidFilterName(t *testing.T) {
|
||||
|
||||
_, err := svc.DescribeTags(context.Background(), &ec2.DescribeTagsInput{
|
||||
Filters: []*ec2.Filter{
|
||||
//nolint:misspell // the typo is the point: "resouce-id" must not match the valid "resource-id" filter
|
||||
{Name: aws.String("resouce-id"), Values: []*string{aws.String("i-test1")}},
|
||||
},
|
||||
}, testAccountID)
|
||||
|
||||
Reference in New Issue
Block a user