Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions .golangci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,27 @@ linters:
- errcheck
- goconst
- gosec
# fieldalignment is useful for runtime structs, but test fixtures are
# usually clearer in table-driven test order.
- path: '_test\.go'
text: 'fieldalignment:'
linters:
- govet
# Preserve Kubernetes API type conventions.
- path: 'pkg/apis/microshift/v1alpha1/types\.go'
text: 'fieldalignment:'
linters:
- govet
# Preserve user-facing configuration field order.
- path: 'pkg/config/.*\.go'
text: 'fieldalignment:'
linters:
- govet
# Preserve OVSDB model field order.
- path: 'pkg/controllers/c2cc/nbdb\.go'
text: 'fieldalignment:'
linters:
- govet
- path: 'pkg/cmd/init\.go'
text: 'calculated cyclomatic complexity for function initKubeconfigs is'
- path: 'pkg/config/config\.go'
Expand Down Expand Up @@ -120,6 +141,9 @@ linters:
settings:
cyclop:
max-complexity: 20
govet:
enable:
- fieldalignment
funcorder:
struct-method: false
inamedparam:
Expand Down
3 changes: 2 additions & 1 deletion pkg/admin/prerun/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ var (
errDataVersionDoesNotExist = errors.New("version file for MicroShift data does not exist")
)

//nolint:govet // fieldalignment: preserve persisted version metadata JSON field order.
type versionFile struct {
Version versionMetadata `json:"version"`
DeploymentID string `json:"deployment_id,omitempty"`
Expand Down Expand Up @@ -117,8 +118,8 @@ func WriteVersionMetadata() error {
}

type versions struct {
exec versionMetadata
data *versionMetadata
exec versionMetadata
}

// getVersions obtains and returns versions of executable and data dir.
Expand Down
9 changes: 5 additions & 4 deletions pkg/controllers/c2cc/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,17 @@ const (
var healthcheckCRD = []string{"crd/microshift.io_remoteclusters.yaml"}

type C2CCRouteManager struct {
cfg *config.Config
nodeName string
kubeconfig string

kubeClient kubernetes.Interface
microshiftClient microshiftclient.MicroshiftV1alpha1Interface
cfg *config.Config
ovn *ovnRouteManager
annotation *annotationManager
nftMgr *nftablesManager
routes *linuxRouteManager
svcRoutes *serviceRouteManager
healthcheck *healthcheckCRManager
nodeName string
kubeconfig string
}

func NewC2CCRouteManager(cfg *config.Config) *C2CCRouteManager {
Expand Down Expand Up @@ -215,6 +214,7 @@ func (c *C2CCRouteManager) initForCleanup(ctx context.Context) func() {
}

func (c *C2CCRouteManager) fullReconcile(ctx context.Context) {
//nolint:govet // fieldalignment: keep positional composite literal order.
subsystems := []struct {
name string
fn func(context.Context) error
Expand All @@ -236,6 +236,7 @@ func (c *C2CCRouteManager) fullReconcile(ctx context.Context) {
func (c *C2CCRouteManager) cleanupAll(ctx context.Context) {
klog.V(2).Infof("Cleaning up any leftover C2CC state")

//nolint:govet // fieldalignment: keep positional composite literal order.
type cleanable struct {
name string
fn func(context.Context) error
Expand Down
3 changes: 2 additions & 1 deletion pkg/controllers/c2cc/nbdb.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@ func waitForOVNSocket(ctx context.Context) error {
}
}

func connectOVNNB(ctx context.Context) (client.Client, error) { //nolint:ireturn
//nolint:ireturn // libovsdb exposes client.Client as the public connection interface.
func connectOVNNB(ctx context.Context) (client.Client, error) {
if err := waitForOVNSocket(ctx); err != nil {
return nil, fmt.Errorf("failed to wait for OVN NB socket: %w", err)
}
Expand Down
1 change: 1 addition & 0 deletions pkg/controllers/c2cc/routes.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ const (
c2ccRulePriority = 100
)

//nolint:govet // fieldalignment: keep the embedded route-table fields first.
type linuxRouteManager struct {
policyRouteTable

Expand Down
1 change: 1 addition & 0 deletions pkg/controllers/c2cc/service_routes.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ const (
mgmtPortInterface = "ovn-k8s-mp0"
)

//nolint:govet // fieldalignment: keep the embedded route-table fields first.
type serviceRouteManager struct {
policyRouteTable

Expand Down
3 changes: 1 addition & 2 deletions pkg/controllers/cluster-policy-controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,9 @@ import (
)

type ClusterPolicyController struct {
configErr error
run func(context.Context) error
kubeconfig string

configErr error
}

func NewClusterPolicyController(cfg *config.Config) *ClusterPolicyController {
Expand Down
12 changes: 6 additions & 6 deletions pkg/controllers/filewatcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,17 @@ import (
)

type fileWatcherConfig struct {
serviceName string
dependencies []string
file string
labels map[string]string
annotations map[string]string
kubeconfig string
enabled bool
serviceName string
configMapNamespace string
configMapName string
configMapDataKey string
labels map[string]string
annotations map[string]string
file string
dependencies []string
eventMask fsnotify.Op
enabled bool
reAddOnCreate bool
mergeAnnotations bool
deleteOnDisable bool
Expand Down
7 changes: 3 additions & 4 deletions pkg/controllers/kube-apiserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,12 @@ func init() {
}

type KubeAPIServer struct {
kasConfigBytes []byte
verbosity int
configuration *config.Config

configuration *config.Config
masterURL string
servingCAPath string
advertiseAddress string
kasConfigBytes []byte
verbosity int
}

func NewKubeAPIServer(cfg *config.Config) *KubeAPIServer {
Expand Down
5 changes: 2 additions & 3 deletions pkg/controllers/kube-controller-manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,10 @@ const (
)

type KubeControllerManager struct {
args []string
applyFn func() error

// TODO: report configuration errors immediately
configureErr error
applyFn func() error
args []string
}

func NewKubeControllerManager(ctx context.Context, cfg *config.Config) *KubeControllerManager {
Expand Down
3 changes: 1 addition & 2 deletions pkg/controllers/openshift-route-controller-manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,10 @@ import (
)

type OCPRouteControllerManager struct {
configErr error
run func(context.Context) error
kubeconfig string
kubeadmconfig string

configErr error
}

const (
Expand Down
12 changes: 6 additions & 6 deletions pkg/loadbalancerservice/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,16 @@ const (
)

type LoadbalancerServiceController struct {
IPAddresses []string
NICNames []string
indexer cache.Indexer
queue workqueue.TypedRateLimitingInterface[string]
informer cache.SharedIndexInformer
client *kubernetes.Clientset
NodeIP string
KubeConfig string
IPAddresses []string
NICNames []string
Ipv4 bool
Ipv6 bool
client *kubernetes.Clientset
indexer cache.Indexer
queue workqueue.TypedRateLimitingInterface[string]
informer cache.SharedIndexInformer
}

var _ servicemanager.Service = &LoadbalancerServiceController{}
Expand Down
1 change: 1 addition & 0 deletions pkg/mdns/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
"k8s.io/klog/v2"
)

//nolint:govet // fieldalignment: keep the embedded mutex first.
type MicroShiftmDNSController struct {
sync.Mutex

Expand Down
1 change: 1 addition & 0 deletions pkg/mdns/server/resolver.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (

const defaultTTL = 120

//nolint:govet // fieldalignment: keep the embedded mutex first.
type Resolver struct {
sync.Mutex

Expand Down
4 changes: 2 additions & 2 deletions pkg/mdns/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ const (
)

type Server struct {
iface *net.Interface
responder Responder
listeners []*net.UDPConn
iface *net.Interface
stopCh chan struct{}
listeners []*net.UDPConn
}

type Responder interface {
Expand Down
10 changes: 4 additions & 6 deletions pkg/servicemanager/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,12 @@ import (
)

type ServiceManager struct {
name string
deps []string

services []Service
serviceMap map[string]Service
startRec *startuprecorder.StartupRecorder

errChan chan error
errChan chan error
name string
deps []string
services []Service
}

func NewServiceManager(startRec *startuprecorder.StartupRecorder) *ServiceManager {
Expand Down
3 changes: 1 addition & 2 deletions pkg/servicemanager/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,9 @@ import (
type RunFunc func(ctx context.Context, ready chan<- struct{}, stopped chan<- struct{}) error

type GenericService struct {
run RunFunc
name string
deps []string

run RunFunc
}

func NewGenericService(name string, dependencies []string, run RunFunc) *GenericService {
Expand Down
6 changes: 4 additions & 2 deletions pkg/servicemanager/startuprecorder/startuprecorder.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"k8s.io/klog/v2"
)

//nolint:govet // fieldalignment: preserve startup service JSON field order.
type ServiceData struct {
Name string `json:"name"`
Dependencies []string `json:"dependencies"`
Expand All @@ -24,16 +25,17 @@ type MicroshiftData struct {
TimeToReady time.Duration `json:"timeToReady"`
}

//nolint:govet // fieldalignment: preserve startup JSON top-level field order.
type StartupData struct {
Services []ServiceData `json:"services"`
Microshift MicroshiftData `json:"microshift"`
}

type StartupRecorder struct {
Data StartupData
allLogged chan struct{}
Data StartupData

ServiceCount int
allLogged chan struct{}
m sync.Mutex
}

Expand Down
4 changes: 2 additions & 2 deletions pkg/telemetry/telemetry.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,14 @@ type MetricLabel struct {
}

type TelemetryClient struct {
// For proxy configuration.
transport http.RoundTripper
endpoint string
clusterId string
// next two attributes are required to compute the cpu usage based
// on the cpu seconds we get from kubelet.
previousCPUSeconds float64
previousCPUtimestamp int64
// For proxy configuration.
transport http.RoundTripper
}

func NewTelemetryClient(endpoint, clusterId, proxy string) *TelemetryClient {
Expand Down
7 changes: 3 additions & 4 deletions pkg/util/all_err_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,10 @@ import (
// AllErrGroup is a helper to wait for all goroutines and get all errors that occurred.
// It's based on sync.WaitGroup (which doesn't capture any errors) and errgroup.Group (which only captures the first error).
type AllErrGroup struct {
wg sync.WaitGroup
mu sync.Mutex
errs []error

errs []error
wg sync.WaitGroup
amount int
mu sync.Mutex
}

func (g *AllErrGroup) Go(f func() error) {
Expand Down
3 changes: 1 addition & 2 deletions pkg/util/cryptomaterial/certchains/chainsbuilder.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,10 @@ type CertificateChainsBuilder interface {
}

type certificateChains struct {
signers []CertificateSignerBuilder

// fileBundles maps fileName -> signers, where fileName is the filename of a CA bundle
// where PEM certificates should be stored
fileBundles map[string][][]string
signers []CertificateSignerBuilder
}

func NewCertificateChains(signers ...CertificateSignerBuilder) CertificateChainsBuilder {
Expand Down
10 changes: 4 additions & 6 deletions pkg/util/cryptomaterial/certchains/signerbuilder.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,16 @@ type CertificateSignerBuilder interface {
}

type certificateSigner struct {
signerName string
signerDir string
signerValidity time.Duration

// signerConfig should only be used in case this is a sub-ca signer
// It should be populated during CertificateSigner.SignSubCA()
signerConfig *crypto.CA
signerName string
signerDir string
subCAs []CertificateSignerBuilder
certificatesToSign []CSRInfo

// locations of bundles where this signer appears
caBundlePaths []string
caBundlePaths []string
signerValidity time.Duration
}

// NewCertificateSigner returns a builder object for a certificate chain for the given signer
Expand Down
Loading