chore: re-enable nolintlint and typecheck linters

Drop startup/rand.go, as since Go 1.20 `rand.Seed` is done
automatically.

Signed-off-by: Andrey Smirnov <andrey.smirnov@siderolabs.com>
This commit is contained in:
Andrey Smirnov 2023-08-25 01:05:41 +04:00
parent c51e2c9b48
commit 3c9f7a7de6
No known key found for this signature in database
GPG Key ID: FE042E3D4085A811
135 changed files with 72 additions and 265 deletions

View File

@ -156,13 +156,11 @@ linters:
- nestif
- nilnil # we return "nil, nil"
- nonamedreturns
- nolintlint
- nosnakecase
- paralleltest
- promlinter # https://github.com/golangci/golangci-lint/issues/2222
- tagliatelle # we have many different conventions
- thelper
- typecheck
- varnamelen # too annoying
- wrapcheck
- contextcheck # enable once golangci-lint 1.50.1 or 1.51 lands

View File

@ -13,7 +13,6 @@ import (
"github.com/siderolabs/talos/pkg/machinery/constants"
)
// nolint:gocyclo
func (i *Installer) installExtensions() error {
builder := extensions.Builder{
InitramfsPath: fmt.Sprintf(constants.InitramfsAssetPath, i.options.Arch),

View File

@ -287,7 +287,6 @@ func validateFlags() error {
return err
}
// nolint:gocyclo
func writeConfigBundle(configBundle *bundle.Bundle, outputPaths configOutputPaths, commentsFlags encoder.CommentsFlags) error {
outputTypesSet := slices.ToSet(genConfigCmdFlags.outputTypes)

View File

@ -9,13 +9,9 @@ import (
"os"
"github.com/siderolabs/talos/cmd/talosctl/cmd"
"github.com/siderolabs/talos/pkg/cli"
"github.com/siderolabs/talos/pkg/startup"
)
func main() {
cli.Should(startup.RandSeed())
if err := cmd.Execute(); err != nil {
os.Exit(1)
}

View File

@ -8,12 +8,10 @@ package main
import (
"context"
cryptorand "crypto/rand"
"encoding/binary"
"encoding/json"
"fmt"
"io"
"log"
"math/rand"
"os"
"path/filepath"
"sync"
@ -77,8 +75,6 @@ func run() error {
log.Fatalf("error seeding rand: %s", err)
}
rand.Seed(int64(binary.LittleEndian.Uint64(seed))) //nolint:staticcheck
ctx, cancel := context.WithCancel(context.Background())
defer cancel()

View File

@ -72,10 +72,6 @@ func apidMain() error {
startup.LimitMaxProcs(constants.ApidMaxProcs)
if err := startup.RandSeed(); err != nil {
return fmt.Errorf("failed to seed RNG: %w", err)
}
runtimeConn, err := grpc.Dial("unix://"+constants.APIRuntimeSocketPath, grpc.WithTransportCredentials(insecure.NewCredentials()))
if err != nil {
return fmt.Errorf("failed to dial runtime connection: %w", err)

View File

@ -117,7 +117,7 @@ func (cl *clusterState) String() string {
}))
}
//nolint:gocyclo,cyclop
//nolint:gocyclo
func buildClusterInfo(ctx context.Context,
req *clusterapi.HealthCheckRequest,
r runtime.Runtime,

View File

@ -297,8 +297,6 @@ func (s *Server) GenerateConfiguration(ctx context.Context, in *machine.Generate
}
// Reboot implements the machine.MachineServer interface.
//
//nolint:dupl
func (s *Server) Reboot(ctx context.Context, in *machine.RebootRequest) (reply *machine.RebootResponse, err error) {
actorID := uuid.New().String()
@ -330,8 +328,6 @@ func (s *Server) Reboot(ctx context.Context, in *machine.RebootRequest) (reply *
}
// Rollback implements the machine.MachineServer interface.
//
//nolint:gocyclo
func (s *Server) Rollback(ctx context.Context, in *machine.RollbackRequest) (*machine.RollbackResponse, error) {
log.Printf("rollback via API received")
@ -407,8 +403,6 @@ func (s *Server) Bootstrap(ctx context.Context, in *machine.BootstrapRequest) (r
}
// Shutdown implements the machine.MachineServer interface.
//
//nolint:dupl
func (s *Server) Shutdown(ctx context.Context, in *machine.ShutdownRequest) (reply *machine.ShutdownResponse, err error) {
actorID := uuid.New().String()
@ -563,7 +557,7 @@ func (opt *ResetOptions) GetSystemDiskTargets() []runtime.PartitionTarget {
// Reset resets the node.
//
//nolint:gocyclo,cyclop
//nolint:gocyclo
func (s *Server) Reset(ctx context.Context, in *machine.ResetRequest) (reply *machine.ResetResponse, err error) {
actorID := uuid.New().String()
@ -2229,7 +2223,7 @@ func (s *Server) PacketCapture(in *machine.PacketCaptureRequest, srv machine.Mac
if err = srv.SendMsg(&common.Data{Bytes: data}); err != nil {
cancel()
pr.CloseWithError(err) //nolint:errcheck
pr.CloseWithError(err)
}
}
@ -2244,7 +2238,7 @@ func capturePackets(pw *io.PipeWriter, handle *pcapgo.EthernetHandle, snapLen ui
pcapw := pcapgo.NewWriterNanos(pw)
if err := pcapw.WriteFileHeader(snapLen, linkType); err != nil {
pw.CloseWithError(err) //nolint:errcheck
pw.CloseWithError(err)
return
}
@ -2263,7 +2257,7 @@ func capturePackets(pw *io.PipeWriter, handle *pcapgo.EthernetHandle, snapLen ui
packet, err := pkgsrc.NextPacket()
if err == nil {
if err = pcapw.WritePacket(packet.Metadata().CaptureInfo, packet.Data()); err != nil {
pw.CloseWithError(err) //nolint:errcheck
pw.CloseWithError(err)
return
}
@ -2286,7 +2280,7 @@ func capturePackets(pw *io.PipeWriter, handle *pcapgo.EthernetHandle, snapLen ui
errors.Is(err, io.ErrNoProgress) || errors.Is(err, io.ErrClosedPipe) || errors.Is(err, io.ErrShortBuffer) ||
errors.Is(err, syscall.EBADF) ||
strings.Contains(err.Error(), "use of closed file") {
pw.CloseWithError(err) //nolint:errcheck
pw.CloseWithError(err)
return
}

View File

@ -167,11 +167,6 @@ func run() error {
// Limit GOMAXPROCS.
startup.LimitMaxProcs(constants.MachinedMaxProcs)
// Ensure RNG is seeded.
if err := startup.RandSeed(); err != nil {
return err
}
// Set the PATH env var.
if err := os.Setenv("PATH", constants.PATH); err != nil {
return errors.New("error setting PATH")

View File

@ -273,7 +273,7 @@ func (ctrl *DiscoveryServiceController) Run(ctx context.Context, r controller.Ru
Affiliate: localData,
Endpoints: localEndpoints,
}, otherEndpoints); err != nil {
return fmt.Errorf("error setting local affiliate data: %w", err) //nolint:govet
return fmt.Errorf("error setting local affiliate data: %w", err)
}
prevLocalData = localData
@ -312,7 +312,7 @@ func (ctrl *DiscoveryServiceController) Run(ctx context.Context, r controller.Ru
return nil
}); err != nil {
return err //nolint:govet
return err
}
touchedIDs[id] = struct{}{}

View File

@ -49,8 +49,6 @@ func (ctrl *SeccompProfileController) Outputs() []controller.Output {
}
// Run implements controller.StatsController interface.
//
//nolint:gocyclo,cyclop
func (ctrl *SeccompProfileController) Run(ctx context.Context, r controller.Runtime, logger *zap.Logger) error {
for {
select {

View File

@ -26,7 +26,7 @@ import (
)
// DefaultSuite is a base suite for controller testing.
type DefaultSuite struct { //nolint:govet
type DefaultSuite struct {
suite.Suite
state state.State

View File

@ -56,7 +56,7 @@ func (ctrl *MemberController) Outputs() []controller.Output {
// Run implements controller.Controller interface.
//
//nolint:gocyclo,cyclop
//nolint:gocyclo
func (ctrl *MemberController) Run(ctx context.Context, r controller.Runtime, logger *zap.Logger) error {
for {
select {

View File

@ -76,7 +76,7 @@ func (suite *MemberSuite) assertInexistentEtcdMember(member *etcd.Member) func()
}
}
func (suite *MemberSuite) TestEtcdRunning() { //nolint:dupl
func (suite *MemberSuite) TestEtcdRunning() {
// given
suite.ctrl.GetLocalMemberIDFunc = func(ctx context.Context) (uint64, error) {
return 123, nil
@ -98,7 +98,7 @@ func (suite *MemberSuite) TestEtcdRunning() { //nolint:dupl
)
}
func (suite *MemberSuite) TestEtcdNotRunning() { //nolint:dupl
func (suite *MemberSuite) TestEtcdNotRunning() {
// given
suite.ctrl.GetLocalMemberIDFunc = func(ctx context.Context) (uint64, error) {
return 123, nil

View File

@ -2,7 +2,6 @@
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
//nolint:dupl
package k8s_test
import (

View File

@ -106,7 +106,6 @@ func (ctrl *EndpointController) Run(ctx context.Context, r controller.Runtime, l
}
}
//nolint:gocyclo
func (ctrl *EndpointController) watchEndpointsOnWorker(ctx context.Context, r controller.Runtime, logger *zap.Logger) error {
logger.Debug("waiting for kubelet client config", zap.String("file", constants.KubeletKubeconfig))
@ -144,7 +143,6 @@ func (ctrl *EndpointController) watchEndpointsOnWorker(ctx context.Context, r co
}
}
//nolint:gocyclo
func (ctrl *EndpointController) watchEndpointsOnControlPlane(ctx context.Context, r controller.Runtime, logger *zap.Logger) error {
if err := r.UpdateInputs([]controller.Input{
{

View File

@ -73,7 +73,7 @@ func (ctrl *KubeletStaticPodController) Outputs() []controller.Output {
// Run implements controller.Controller interface.
//
//nolint:gocyclo,cyclop
//nolint:gocyclo
func (ctrl *KubeletStaticPodController) Run(ctx context.Context, r controller.Runtime, logger *zap.Logger) error {
var kubeletClient *kubelet.Client

View File

@ -34,7 +34,7 @@ func (ctrl *RenderSecretsStaticPodController) Name() string {
}
// Inputs implements controller.Controller interface.
func (ctrl *RenderSecretsStaticPodController) Inputs() []controller.Input { //nolint:dupl
func (ctrl *RenderSecretsStaticPodController) Inputs() []controller.Input {
return []controller.Input{
{
Namespace: secrets.NamespaceName,

View File

@ -65,8 +65,6 @@ type podList struct {
}
// Run implements controller.Controller interface.
//
//nolint:gocyclo,cyclop
func (ctrl *StaticPodServerController) Run(ctx context.Context, r controller.Runtime, logger *zap.Logger) error {
ctrl.staticPodVersions = map[string]string{}

View File

@ -67,7 +67,7 @@ func (ctrl *CRDController) Outputs() []controller.Output {
// Run implements controller.Controller interface.
//
//nolint:gocyclo,cyclop
//nolint:gocyclo
func (ctrl *CRDController) Run(ctx context.Context, r controller.Runtime, logger *zap.Logger) error {
var crdControllerCtxCancel context.CancelFunc

View File

@ -248,7 +248,7 @@ func (t *CRDController) Run(ctx context.Context, workers int) error {
}
func (t *CRDController) runWorker(ctx context.Context) {
for t.processNextWorkItem(ctx) { //nolint:revive
for t.processNextWorkItem(ctx) {
}
}
@ -293,7 +293,7 @@ func (t *CRDController) processNextWorkItem(ctx context.Context) bool {
return true
}
//nolint:gocyclo,cyclop,dupl
//nolint:gocyclo,cyclop
func (t *CRDController) syncHandler(ctx context.Context, key string) error {
namespace, name, err := cache.SplitMetaNamespaceKey(key)
if err != nil {

View File

@ -2,7 +2,6 @@
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
//nolint:dupl
package network_test
import (

View File

@ -166,7 +166,6 @@ func (suite *AddressMergeSuite) TestMerge() {
)
}
//nolint:gocyclo
func (suite *AddressMergeSuite) TestMergeFlapping() {
// simulate two conflicting address definitions which are getting removed/added constantly
dhcp := network.NewAddressSpec(network.ConfigNamespaceName, "dhcp/eth0/10.0.0.1/8")

View File

@ -2,7 +2,6 @@
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
//nolint:dupl
package network_test
import (

View File

@ -2,7 +2,6 @@
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
//nolint:dupl
package network_test
import (
@ -199,7 +198,7 @@ func (suite *EtcFileConfigSuite) TestNoSearchDomain() {
suite.testFiles(
[]resource.Resource{cfg, suite.defaultAddress, suite.hostnameStatus, suite.resolverStatus},
"nameserver 1.1.1.1\nnameserver 2.2.2.2\nnameserver 3.3.3.3\n",
"127.0.0.1 localhost\n33.11.22.44 foo.example.com foo\n::1 localhost ip6-localhost ip6-loopback\nff02::1 ip6-allnodes\nff02::2 ip6-allrouters\n", //nolint:lll
"127.0.0.1 localhost\n33.11.22.44 foo.example.com foo\n::1 localhost ip6-localhost ip6-loopback\nff02::1 ip6-allnodes\nff02::2 ip6-allrouters\n",
)
}

View File

@ -2,7 +2,6 @@
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
//nolint:dupl
package network_test
import (

View File

@ -192,7 +192,6 @@ func (suite *LinkMergeSuite) TestMergeLogicalLink() {
)
}
//nolint:gocyclo
func (suite *LinkMergeSuite) TestMergeFlapping() {
// simulate two conflicting link definitions which are getting removed/added constantly
dhcp := network.NewLinkSpec(network.ConfigNamespaceName, "dhcp/eth0")

View File

@ -143,8 +143,8 @@ func (ctrl *LinkSpecController) Run(ctx context.Context, r controller.Runtime, l
// in proper order.
func SortBonds(items []resource.Resource) {
sort.Slice(items, func(i, j int) bool {
left := items[i].(*network.LinkSpec).TypedSpec() //nolint:errcheck
right := items[j].(*network.LinkSpec).TypedSpec() //nolint:errcheck
left := items[i].(*network.LinkSpec).TypedSpec()
right := items[j].(*network.LinkSpec).TypedSpec()
l := ordered.MakeTriple(left.Name, 0, "")
if left.BondSlave.MasterName != "" {

View File

@ -104,7 +104,7 @@ func (ctrl *LinkStatusController) Run(ctx context.Context, r controller.Runtime,
if err != nil {
logger.Warn("error dialing ethtool ioctl socket", zap.Error(err))
} else {
defer ethIoctlClient.Close() //nolint:errcheck
defer ethIoctlClient.Close()
}
wgClient, err := wgctrl.New()

View File

@ -147,7 +147,7 @@ func (suite *LinkStatusSuite) TestInterfaceHwInfo() {
suite.Require().NoError(err)
for _, res := range resources.Items {
spec := res.(*network.LinkStatus).TypedSpec() //nolint:errcheck,forcetypeassert
spec := res.(*network.LinkStatus).TypedSpec() //nolint:forcetypeassert
if !spec.Physical() {
continue

View File

@ -127,8 +127,6 @@ func SetBridgeSlave(link *network.LinkSpecSpec, bridge string) {
}
// SetBridgeMaster sets the bridge master spec.
//
//nolint:gocyclo
func SetBridgeMaster(link *network.LinkSpecSpec, bridge talosconfig.Bridge) error {
link.Logical = true
link.Kind = network.LinkKindBridge

View File

@ -67,7 +67,7 @@ func (suite *NodeAddressSuite) TestDefaults() {
)
}
//nolint:gocyclo,cyclop
//nolint:gocyclo
func (suite *NodeAddressSuite) TestFilters() {
var (
addressStatusController netctrl.AddressStatusController

View File

@ -136,7 +136,7 @@ func (d *DHCP4) waitForNetworkReady(ctx context.Context) error {
// Run the operator loop.
//
//nolint:gocyclo,cyclop,dupl
//nolint:gocyclo,cyclop
func (d *DHCP4) Run(ctx context.Context, notifyCh chan<- struct{}) {
const minRenewDuration = 5 * time.Second // Protect from renewing too often

View File

@ -62,7 +62,7 @@ func (d *DHCP6) Prefix() string {
// Run the operator loop.
//
//nolint:gocyclo,dupl
//nolint:gocyclo
func (d *DHCP6) Run(ctx context.Context, notifyCh chan<- struct{}) {
iface, err := net.InterfaceByName(d.linkName)
if err != nil {

View File

@ -2,7 +2,6 @@
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
//nolint:dupl
package network_test
import (

View File

@ -139,7 +139,6 @@ func (ctrl *ProbeController) reconcileRunners(ctx context.Context, r controller.
return nil
}
//nolint:gocyclo,cyclop
func (ctrl *ProbeController) reconcileOutputs(ctx context.Context, r controller.Runtime, ev probe.Notification) error {
if _, exists := ctrl.runners[ev.ID]; !exists {
// probe was already removed, late notification, ignore it

View File

@ -2,7 +2,6 @@
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
//nolint:dupl
package network_test
import (

View File

@ -2,7 +2,6 @@
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
//nolint:dupl
package network_test
import (

View File

@ -2,7 +2,6 @@
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
//nolint:dupl
package network_test
import (

View File

@ -2,7 +2,6 @@
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
//nolint:dupl
package network_test
import (

View File

@ -2,7 +2,6 @@
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
//nolint:dupl
package network_test
import (

View File

@ -54,7 +54,7 @@ func (ctrl *EventsSinkConfigController) Outputs() []controller.Output {
// Run implements controller.Controller interface.
//
//nolint:gocyclo,cyclop
//nolint:gocyclo
func (ctrl *EventsSinkConfigController) Run(ctx context.Context, r controller.Runtime, logger *zap.Logger) (err error) {
for {
select {

View File

@ -56,7 +56,7 @@ func (ctrl *KmsgLogConfigController) Outputs() []controller.Output {
// Run implements controller.Controller interface.
//
//nolint:gocyclo,cyclop
//nolint:gocyclo
func (ctrl *KmsgLogConfigController) Run(ctx context.Context, r controller.Runtime, logger *zap.Logger) (err error) {
for {
select {

View File

@ -59,7 +59,8 @@ func (ctrl *SecurityStateController) Outputs() []controller.Output {
}
// Run implements controller.Controller interface.
// nolint:gocyclo
//
//nolint:gocyclo
func (ctrl *SecurityStateController) Run(ctx context.Context, r controller.Runtime, logger *zap.Logger) error {
for {
select {

View File

@ -2,7 +2,6 @@
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
//nolint:dupl
package secrets_test
import (

View File

@ -2,7 +2,6 @@
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
//nolint:dupl
package secrets_test
import (

View File

@ -2,7 +2,6 @@
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
//nolint:dupl
package secrets_test
import (

View File

@ -2,7 +2,6 @@
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
//nolint:dupl
package secrets_test
import (

View File

@ -70,7 +70,7 @@ func (ctrl *KubernetesController) Outputs() []controller.Output {
// Run implements controller.Controller interface.
//
//nolint:gocyclo,cyclop
//nolint:gocyclo
func (ctrl *KubernetesController) Run(ctx context.Context, r controller.Runtime, logger *zap.Logger) error {
refreshTicker := time.NewTicker(KubernetesCertificateValidityDuration / 2)
defer refreshTicker.Stop()

View File

@ -2,7 +2,6 @@
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
//nolint:dupl
package secrets_test
import (

View File

@ -2,7 +2,6 @@
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
//nolint:dupl
package secrets_test
import (

View File

@ -2,7 +2,6 @@
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
//nolint:dupl
package secrets_test
import (

View File

@ -30,8 +30,6 @@ func (ctrl *MaintenanceCertSANsController) Name() string {
}
// Inputs implements controller.Controller interface.
//
//nolint:dupl
func (ctrl *MaintenanceCertSANsController) Inputs() []controller.Input {
return []controller.Input{
{
@ -60,8 +58,6 @@ func (ctrl *MaintenanceCertSANsController) Outputs() []controller.Output {
}
// Run implements controller.Controller interface.
//
//nolint:gocyclo
func (ctrl *MaintenanceCertSANsController) Run(ctx context.Context, r controller.Runtime, logger *zap.Logger) error {
for {
select {

View File

@ -68,8 +68,6 @@ func NewRootEtcdController() *RootEtcdController {
type RootKubernetesController = transform.Controller[*config.MachineConfig, *secrets.KubernetesRoot]
// NewRootKubernetesController instanciates the controller.
//
//nolint:gocyclo
func NewRootKubernetesController() *RootKubernetesController {
return transform.NewController(
transform.Settings[*config.MachineConfig, *secrets.KubernetesRoot]{

View File

@ -2,7 +2,6 @@
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
//nolint:dupl
package secrets_test
import (

View File

@ -119,7 +119,7 @@ func (ctrl *TrustdController) Run(ctx context.Context, r controller.Runtime, log
}
}
//nolint:gocyclo,cyclop,dupl
//nolint:gocyclo,dupl
func (ctrl *TrustdController) reconcile(ctx context.Context, r controller.Runtime, logger *zap.Logger) error {
inputs := []controller.Input{
{

View File

@ -2,7 +2,6 @@
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
//nolint:dupl
package secrets_test
import (

View File

@ -15,8 +15,6 @@ import (
// Probe probes a block device for GRUB bootloader.
//
// If the 'disk' is passed, search happens on that disk only, otherwise searches all partitions.
//
//nolint:gocyclo
func Probe(ctx context.Context, disk string) (*Config, error) {
var grubConf *Config

View File

@ -20,7 +20,8 @@ import (
)
// Revert reverts the bootloader to the previous version.
// nolint:gocyclo
//
//nolint:gocyclo
func (c *Config) Revert(ctx context.Context) error {
if c == nil {
return fmt.Errorf("cannot revert bootloader: %w", bootloaderNotInstalledError{})

View File

@ -18,7 +18,8 @@ import (
)
// PartitionOp mounts a partition with the specified label, executes the operation func, and unmounts the partition.
// nolint:gocyclo
//
//nolint:gocyclo
func PartitionOp(ctx context.Context, disk string, partitionLabel string, opFunc func() error) error {
var probedBlockDevice *blockdevice.BlockDevice

View File

@ -66,7 +66,7 @@ func WriteVariable(c efivario.Context, name, value string) error {
return err
}
defer unix.Mount("efivarfs", constants.EFIVarsMountPoint, "efivarfs", unix.MS_REMOUNT|unix.MS_RDONLY, "") // nolint: errcheck
defer unix.Mount("efivarfs", constants.EFIVarsMountPoint, "efivarfs", unix.MS_REMOUNT|unix.MS_RDONLY, "") //nolint:errcheck
out := make([]byte, (len(value)+1)*2)

View File

@ -49,7 +49,8 @@ func New() *Config {
}
// Probe for existing sd-boot bootloader.
// nolint:gocyclo
//
//nolint:gocyclo
func Probe(ctx context.Context, disk string) (*Config, error) {
// if not UEFI boot, nothing to do
if !isUEFIBoot() {

View File

@ -29,7 +29,6 @@ type MetadataConfig struct {
Zone string `json:"availability-zone,omitempty"`
}
//nolint:gocyclo
func (e *Exoscale) getMetadata(ctx context.Context) (metadata *MetadataConfig, err error) {
getMetadataKey := func(key string) (string, error) {
res, metaerr := download.Download(ctx, fmt.Sprintf("%s/%s", ExoscaleMetadataEndpoint, key),

View File

@ -99,8 +99,6 @@ func (n *Nocloud) KernelArgs() procfs.Parameters {
}
// NetworkConfiguration implements the runtime.Platform interface.
//
//nolint:gocyclo
func (n *Nocloud) NetworkConfiguration(ctx context.Context, st state.State, ch chan<- *runtime.PlatformNetworkConfig) error {
metadataConfigDl, metadataNetworkConfigDl, _, metadata, err := n.acquireConfig(ctx, st)
if stderrors.Is(err, errors.ErrNoConfigSource) {

View File

@ -37,7 +37,7 @@ type MetadataConfig struct {
}
func (o *Oracle) getMetadata(ctx context.Context) (*MetadataConfig, error) {
metaConfigDl, err := download.Download(ctx, OracleMetadataEndpoint, //nolint:errcheck
metaConfigDl, err := download.Download(ctx, OracleMetadataEndpoint,
download.WithHeaders(map[string]string{"Authorization": "Bearer Oracle"}),
download.WithErrorOnNotFound(errors.ErrNoHostname),
download.WithErrorOnEmptyResponse(errors.ErrNoHostname))

View File

@ -72,8 +72,6 @@ func NewController() (*Controller, error) {
// Run executes all phases known to the controller in serial. `Controller`
// aborts immediately if any phase fails.
//
//nolint:gocyclo
func (c *Controller) Run(ctx context.Context, seq runtime.Sequence, data interface{}, setters ...runtime.LockOption) error {
// We must ensure that the runtime is configured since all sequences depend
// on the runtime.

View File

@ -295,7 +295,7 @@ func (*Sequencer) Reboot(r runtime.Runtime) []runtime.Phase {
// Reset is the reset sequence.
//
//nolint:gocyclo,cyclop
//nolint:gocyclo
func (*Sequencer) Reset(r runtime.Runtime, in runtime.ResetOptions) []runtime.Phase {
phases := PhaseList{}

View File

@ -190,7 +190,6 @@ func (p *processRunner) build() (commandWrapper, error) {
}, nil
}
//nolint:gocyclo
func (p *processRunner) run(eventSink events.Recorder) error {
cmdWrapper, err := p.build()
if err != nil {

View File

@ -191,8 +191,6 @@ var ErrSkip = errors.New("service skipped")
// Run returns an error when a service stops.
//
// Run should be run in a goroutine.
//
//nolint:gocyclo
func (svcrunner *ServiceRunner) Run() error {
defer func() {
// reset context for the next run

View File

@ -2,7 +2,7 @@
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
//nolint:golint,dupl
//nolint:golint
package services
import (

View File

@ -2,7 +2,7 @@
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
//nolint:golint,dupl
//nolint:golint
package services
import (

View File

@ -375,7 +375,6 @@ func buildInitialCluster(ctx context.Context, r runtime.Runtime, name string, pe
return initial, id, nil
}
//nolint:gocyclo
func (e *Etcd) argsForInit(ctx context.Context, r runtime.Runtime, spec *etcdresource.SpecSpec) error {
var upgraded bool

View File

@ -2,7 +2,7 @@
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
//nolint:golint,dupl
//nolint:golint
package services
import (

View File

@ -19,7 +19,6 @@ func revertBootloader(ctx context.Context) {
}
}
//nolint:gocyclo
func revertBootloadInternal(ctx context.Context) error {
metaState, err := meta.New(ctx, nil)
if err != nil {

View File

@ -158,8 +158,6 @@ func (s *Server) Version(ctx context.Context, in *emptypb.Empty) (*machine.Versi
}
// Upgrade initiates an upgrade.
//
//nolint:gocyclo,cyclop
func (s *Server) Upgrade(ctx context.Context, in *machine.UpgradeRequest) (reply *machine.UpgradeResponse, err error) {
if err = assertPeerSideroLink(ctx); err != nil {
return nil, err

View File

@ -52,7 +52,6 @@ func Main() {
}
}
//nolint:gocyclo
func trustdMain() error {
ctx, cancel := signal.NotifyContext(context.Background(), syscall.SIGTERM, syscall.SIGINT)
defer cancel()
@ -67,10 +66,6 @@ func trustdMain() error {
var err error
if err = startup.RandSeed(); err != nil {
return fmt.Errorf("startup: %s", err)
}
runtimeConn, err := grpc.Dial("unix://"+constants.TrustdRuntimeSocketPath, grpc.WithTransportCredentials(insecure.NewCredentials()))
if err != nil {
return fmt.Errorf("failed to dial runtime connection: %w", err)

View File

@ -228,8 +228,6 @@ func (suite *ApplyConfigSuite) TestApplyWithoutReboot() {
}
// TestApplyConfigRotateEncryptionSecrets verify key rotation by sequential apply config calls.
//
//nolint:gocyclo
func (suite *ApplyConfigSuite) TestApplyConfigRotateEncryptionSecrets() {
if testing.Short() {
suite.T().Skip("skipping in short mode")
@ -248,11 +246,11 @@ func (suite *ApplyConfigSuite) TestApplyConfigRotateEncryptionSecrets() {
encryption := machineConfig.MachineConfig.MachineSystemDiskEncryption
if encryption == nil { //nolint:staticcheck
if encryption == nil {
suite.T().Skip("skipped in not encrypted mode")
}
cfg := encryption.EphemeralPartition //nolint:staticcheck
cfg := encryption.EphemeralPartition
if cfg == nil {
suite.T().Skip("skipped in not encrypted mode")
@ -458,8 +456,6 @@ func (suite *ApplyConfigSuite) TestApplyDryRun() {
}
// TestApplyTry applies the config in try mode with a short timeout.
//
//nolint:gocyclo
func (suite *ApplyConfigSuite) TestApplyTry() {
nodes := suite.DiscoverNodeInternalIPsByType(suite.ctx, machine.TypeWorker)
suite.Require().NotEmpty(nodes)

View File

@ -126,7 +126,6 @@ func (suite *CGroupsSuite) TestCGroupsVersion() {
}
}
//nolint:gocyclo
func (suite *CGroupsSuite) readCmdline(ctx context.Context) (string, error) {
reader, err := suite.Client.Read(ctx, "/proc/cmdline")
if err != nil {

View File

@ -277,7 +277,6 @@ func (suite *DiscoverySuite) TestKubeSpanPeers() {
}
}
//nolint:dupl
func (suite *DiscoverySuite) getMembers(nodeCtx context.Context) []*cluster.Member {
var result []*cluster.Member
@ -300,7 +299,6 @@ func (suite *DiscoverySuite) getNodeIdentity(nodeCtx context.Context) *cluster.I
return identity
}
//nolint:dupl
func (suite *DiscoverySuite) getAffiliates(nodeCtx context.Context, namespace resource.Namespace) []*cluster.Affiliate {
var result []*cluster.Affiliate
@ -312,7 +310,6 @@ func (suite *DiscoverySuite) getAffiliates(nodeCtx context.Context, namespace re
return result
}
//nolint:dupl
func (suite *DiscoverySuite) getKubeSpanPeerSpecs(nodeCtx context.Context) []*kubespan.PeerSpec {
var result []*kubespan.PeerSpec
@ -328,7 +325,6 @@ func (suite *DiscoverySuite) getKubeSpanPeerSpecs(nodeCtx context.Context) []*ku
return result
}
//nolint:dupl
func (suite *DiscoverySuite) getKubeSpanPeerStatuses(nodeCtx context.Context) []*kubespan.PeerStatus {
var result []*kubespan.PeerStatus

View File

@ -54,7 +54,6 @@ func (suite *MachineStatusSuite) TestMachineStatusReady() {
}
}
//nolint:gocyclo
func (suite *MachineStatusSuite) waitMachineStatusReady(node string) error {
ctx, cancel := context.WithTimeout(client.WithNode(suite.ctx, node), 30*time.Second)
defer cancel()

View File

@ -154,8 +154,6 @@ func (suite *ResetSuite) TestResetNoGracefulControlplane() {
}
// TestResetWithSpecEphemeral resets only ephemeral partition on the node.
//
//nolint:dupl
func (suite *ResetSuite) TestResetWithSpecEphemeral() {
node := suite.RandomDiscoveredNodeInternalIP()
@ -195,8 +193,6 @@ func (suite *ResetSuite) TestResetWithSpecEphemeral() {
// TestResetWithSpecState resets only state partition on the node.
//
// As ephemeral partition is not reset, so kubelet cert shouldn't change.
//
//nolint:dupl
func (suite *ResetSuite) TestResetWithSpecState() {
if suite.Capabilities().SecureBooted {
// this is because in secure boot mode, the machine config is only applied and cannot be passed as kernel args
@ -254,8 +250,6 @@ func (suite *ResetSuite) TestResetWithSpecState() {
// TestResetDuringBoot resets the node multiple times, second reset is done
// before boot sequence is complete.
//
//nolint:dupl
func (suite *ResetSuite) TestResetDuringBoot() {
node := suite.RandomDiscoveredNodeInternalIP()
nodeCtx := client.WithNodes(suite.ctx, node)

View File

@ -70,8 +70,6 @@ func (suite *ServiceAccountSuite) TearDownTest() {
}
// TestValid tests Kubernetes service accounts.
//
//nolint:dupl
func (suite *ServiceAccountSuite) TestValid() {
name := "test-valid"
@ -160,8 +158,6 @@ func (suite *ServiceAccountSuite) TestNotAllowedRoles() {
}
// TestFeatureNotEnabled tests Kubernetes service accounts when API access feature is not enabled.
//
//nolint:dupl
func (suite *ServiceAccountSuite) TestFeatureNotEnabled() {
name := "test-feature-not-enabled"

View File

@ -122,8 +122,6 @@ func (apiSuite *APISuite) DiscoverNodeInternalIPsByType(ctx context.Context, mac
}
// RandomDiscoveredNodeInternalIP returns the internal IP a random node of the specified type (or any type if no types are specified).
//
//nolint:dupl
func (apiSuite *APISuite) RandomDiscoveredNodeInternalIP(types ...machine.Type) string {
nodeInfo := apiSuite.DiscoverNodes(context.TODO())

View File

@ -58,8 +58,6 @@ func (cliSuite *CLISuite) DiscoverNodeInternalIPsByType(ctx context.Context, mac
}
// RandomDiscoveredNodeInternalIP returns the internal IP a random node of the specified type (or any type if no types are specified).
//
//nolint:dupl
func (cliSuite *CLISuite) RandomDiscoveredNodeInternalIP(types ...machine.Type) string {
nodeInfo := cliSuite.DiscoverNodes(context.TODO())

View File

@ -30,8 +30,6 @@ func (suite *HealthSuite) SuiteName() string {
}
// TestClientSideWithExplicitNodes does successful health check run from client-side, providing the explicit set of nodes.
//
//nolint:gocyclo
func (suite *HealthSuite) TestClientSideWithExplicitNodes() {
info := suite.DiscoverNodes(context.TODO())
@ -59,8 +57,6 @@ func (suite *HealthSuite) TestClientSideWithExplicitNodes() {
// TestClientSideWithDiscovery does a health check run from client-side without explicitly specifying the nodes.
// It verifies that the check still passes, because the nodes get populated by the discovery service.
//
//nolint:gocyclo
func (suite *HealthSuite) TestClientSideWithDiscovery() {
discoveryEnabled, err := suite.isDiscoveryEnabled()
suite.Require().NoError(err)

View File

@ -153,7 +153,7 @@ func GenerateHosts(cfg config.Registries, basePath string) (*HostsConfig, error)
}
}
buf.Write(tomlBytes) //nolint:errcheck
buf.Write(tomlBytes)
}
directory.Files = append(directory.Files,

View File

@ -185,7 +185,7 @@ func findContainer(cntID string, containers []*runtimeapi.Container) (*runtimeap
return nil, false
}
// nolint: gocyclo
//nolint:gocyclo
func (i *inspector) buildPod(sandbox *runtimeapi.PodSandbox) (*ctrs.Pod, error) {
sandboxStatus, sandboxInfo, err := i.client.PodSandboxStatus(i.ctx, sandbox.Id)
if err != nil {

View File

@ -64,8 +64,6 @@ type NetworkConfigGrid struct {
}
// NewNetworkConfigGrid initializes NetworkConfigGrid.
//
//nolint:gocyclo
func NewNetworkConfigGrid(ctx context.Context, dashboard *Dashboard) *NetworkConfigGrid {
widget := &NetworkConfigGrid{
Grid: *tview.NewGrid(),
@ -336,7 +334,6 @@ func (widget *NetworkConfigGrid) clearForm() {
func (widget *NetworkConfigGrid) updateNodeData(data resourcedata.Data) {
nodeData := widget.getOrCreateNodeData(data.Node)
//nolint:gocritic
switch res := data.Resource.(type) {
case *network.LinkStatus:
if data.Deleted {

View File

@ -66,8 +66,6 @@ func AnnotationsFromAffiliate(affiliate *cluster.Affiliate) map[string]string {
// AffiliateFromNode converts Kubernetes Node resource to Affiliate.
//
// If the Node resource doesn't have cluster discovery annotations, nil is returned.
//
//nolint:gocyclo
func AffiliateFromNode(node *v1.Node) *cluster.AffiliateSpec {
nodeID, ok := node.Annotations[constants.ClusterNodeIDAnnotation]
if !ok {

View File

@ -67,8 +67,6 @@ func (gen *CertificateGenerator) buildOptions(autoSANs, includeLocalhost bool) [
}
// GeneratePeerCert generates etcd peer certificate and key from etcd CA.
//
//nolint:dupl
func (gen *CertificateGenerator) GeneratePeerCert() (*x509.PEMEncodedCertificateAndKey, error) {
opts := gen.buildOptions(true, false)
@ -93,8 +91,6 @@ func (gen *CertificateGenerator) GeneratePeerCert() (*x509.PEMEncodedCertificate
}
// GenerateServerCert generates server etcd certificate and key from etcd CA.
//
//nolint:dupl
func (gen *CertificateGenerator) GenerateServerCert() (*x509.PEMEncodedCertificateAndKey, error) {
opts := gen.buildOptions(true, true)

View File

@ -41,7 +41,8 @@ func (ext *Extension) KernelModuleDirectory() string {
}
// GenerateKernelModuleDependencyTreeExtension generates a kernel module dependency tree extension.
// nolint:gocyclo
//
//nolint:gocyclo
func GenerateKernelModuleDependencyTreeExtension(extensionsPathWithKernelModules []string, arch string, printFunc func(format string, v ...any)) (*Extension, error) {
printFunc("preparing to run depmod to generate kernel modules dependency tree")

View File

@ -300,7 +300,7 @@ func (meta *Meta) DeleteTag(ctx context.Context, t uint8) (bool, error) {
return ok, nil
}
err := meta.state.Destroy(ctx, runtime.NewMetaKey(runtime.NamespaceName, runtime.MetaKeyTagToID(t)).Metadata()) //nolint:errcheck
err := meta.state.Destroy(ctx, runtime.NewMetaKey(runtime.NamespaceName, runtime.MetaKeyTagToID(t)).Metadata())
if state.IsNotFoundError(err) {
err = nil
}

View File

@ -77,7 +77,7 @@ func PCRExtent(pcr int, data []byte) error {
return err
}
defer t.Close() // nolint: errcheck
defer t.Close() //nolint:errcheck
// since we are using SHA256, we can assume that the PCR bank is SHA256
digest := sha256.Sum256(data)
@ -127,7 +127,7 @@ func PolicyPCRDigest(t transport.TPM, policyHandle tpm2.TPMHandle, pcrSelection
return &policyGetDigestResponse.PolicyDigest, nil
}
// nolint:gocyclo
//nolint:gocyclo
func validatePCRBanks(t transport.TPM) error {
pcrValue, err := ReadPCR(t, secureboot.UKIPCR)
if err != nil {

View File

@ -21,7 +21,7 @@ func Seal(key []byte) (*SealedResponse, error) {
if err != nil {
return nil, err
}
defer t.Close() // nolint: errcheck
defer t.Close() //nolint:errcheck
// fail early if PCR banks are not present or filled with all zeroes or 0xff
if err = validatePCRBanks(t); err != nil {

View File

@ -21,13 +21,14 @@ import (
)
// Unseal unseals a sealed blob using the TPM
// nolint:gocyclo,cyclop
//
//nolint:gocyclo,cyclop
func Unseal(sealed SealedResponse) ([]byte, error) {
t, err := transport.OpenTPM()
if err != nil {
return nil, err
}
defer t.Close() // nolint: errcheck
defer t.Close() //nolint:errcheck
// fail early if PCR banks are not present or filled with all zeroes or 0xff
if err = validatePCRBanks(t); err != nil {
@ -106,7 +107,7 @@ func Unseal(sealed SealedResponse) ([]byte, error) {
return nil, fmt.Errorf("failed to create policy session: %v", err)
}
defer policyCloseFunc() // nolint: errcheck
defer policyCloseFunc() //nolint:errcheck
pubKey, err := ParsePCRSigningPubKey(constants.PCRPublicKey)
if err != nil {

View File

@ -37,8 +37,8 @@ func Merge(parts []string) ([]byte, error) {
var out bytes.Buffer
_, _ = out.Write(header) //nolint:errcheck
_ = out.WriteByte('\n') //nolint:errcheck
_, _ = out.Write(header)
_ = out.WriteByte('\n')
if err := toml.NewEncoder(&out).Encode(merged); err != nil {
return nil, fmt.Errorf("error encoding merged config: %w", err)

View File

@ -86,8 +86,6 @@ type Link struct {
}
// Links gets a list of network interfaces.
//
//nolint:gocyclo
func (c *Connection) Links() ([]Link, error) {
ctx := c.nodeCtx

View File

@ -21,8 +21,6 @@ import (
)
// EtcdConsistentAssertion checks that etcd membership is consistent across nodes.
//
//nolint:gocyclo
func EtcdConsistentAssertion(ctx context.Context, cl ClusterInfo) error {
cli, err := cl.Client()
if err != nil {

View File

@ -25,8 +25,6 @@ import (
)
// K8sAllNodesReportedAssertion checks whether all the nodes show up in node list.
//
//nolint:gocyclo
func K8sAllNodesReportedAssertion(ctx context.Context, cl ClusterInfo) error {
clientset, err := cl.K8sClient(ctx)
if err != nil {
@ -387,8 +385,6 @@ func ReplicaSetPresent(ctx context.Context, cluster cluster.K8sProvider, namespa
}
// K8sControlPlaneStaticPods checks whether all the controlplane nodes are running required Kubernetes static pods.
//
//nolint:gocyclo,cyclop
func K8sControlPlaneStaticPods(ctx context.Context, cl ClusterInfo) error {
expectedNodes := append(cl.NodesByType(machine.TypeInit), cl.NodesByType(machine.TypeControlPlane)...)

View File

@ -33,8 +33,6 @@ var LogLinesPerService = map[string]int32{
// CrashDump produces information to help with debugging.
//
// CrashDump implements CrashDumper interface.
//
//nolint:gocyclo
func (s *APICrashDumper) CrashDump(ctx context.Context, out io.Writer) {
cli, err := s.Client()
if err != nil {

Some files were not shown because too many files have changed in this diff Show More