From 31de8eb75ba6759c1703b980333716c4efd5999e Mon Sep 17 00:00:00 2001 From: Julio Montes Date: Fri, 9 Jul 2021 12:53:19 -0500 Subject: [PATCH] runtime: pkg: fix govet fieldalignment Fix structures alignment Signed-off-by: Julio Montes --- src/runtime/pkg/kata-monitor/monitor.go | 2 +- src/runtime/pkg/kata-monitor/pprof_test.go | 1 + .../pkg/katatestutils/constraints_api.go | 28 +++++++++---------- .../pkg/katatestutils/constraints_test.go | 13 +++++++++ src/runtime/pkg/katatestutils/utils.go | 14 +++++----- src/runtime/pkg/katautils/config.go | 10 +++---- src/runtime/pkg/katautils/config_test.go | 2 ++ src/runtime/pkg/utils/utils_test.go | 1 + 8 files changed, 44 insertions(+), 27 deletions(-) diff --git a/src/runtime/pkg/kata-monitor/monitor.go b/src/runtime/pkg/kata-monitor/monitor.go index 1c663a5fdd..87cd1187b6 100644 --- a/src/runtime/pkg/kata-monitor/monitor.go +++ b/src/runtime/pkg/kata-monitor/monitor.go @@ -29,10 +29,10 @@ func SetLogger(logger *logrus.Entry) { // KataMonitor is monitor agent type KataMonitor struct { + sandboxCache *sandboxCache containerdAddr string containerdConfigFile string containerdStatePath string - sandboxCache *sandboxCache } // NewKataMonitor create and return a new KataMonitor instance diff --git a/src/runtime/pkg/kata-monitor/pprof_test.go b/src/runtime/pkg/kata-monitor/pprof_test.go index 3f5e3e0c0b..221261d40b 100644 --- a/src/runtime/pkg/kata-monitor/pprof_test.go +++ b/src/runtime/pkg/kata-monitor/pprof_test.go @@ -44,6 +44,7 @@ func TestComposeSocketAddress(t *testing.T) { }, } + // nolint: govet testCases := []struct { url string err bool diff --git a/src/runtime/pkg/katatestutils/constraints_api.go b/src/runtime/pkg/katatestutils/constraints_api.go index ce4af56f2e..1bae25541b 100644 --- a/src/runtime/pkg/katatestutils/constraints_api.go +++ b/src/runtime/pkg/katatestutils/constraints_api.go @@ -28,12 +28,6 @@ const ( type Constraints struct { Issue string - UID int - - // Not ideal: set when UID needs to be checked. This allows - // a test for UID 0 to be detected. - UIDSet bool - // DistroName is the name of a distro in all lower-case letters. DistroName string @@ -44,8 +38,14 @@ type Constraints struct { // KernelVersion is the version of a particular kernel. KernelVersion string + UID int + // Operator is the operator to apply to one of the constraints. Operator Operator + + // Not ideal: set when UID needs to be checked. This allows + // a test for UID 0 to be detected. + UIDSet bool } // Constraint is a function that operates on a Constraints object to set @@ -54,23 +54,23 @@ type Constraint func(c *Constraints) // TestConstraint records details about test constraints. type TestConstraint struct { - Debug bool - - // Effective user ID of running test - ActualEUID int - DistroName string DistroVersion string KernelVersion string + // Optionally used to record an issue number that relates to the + // constraint. + Issue string + // Used to record all passed and failed constraints in // human-readable form. Passed []Result Failed []Result - // Optionally used to record an issue number that relates to the - // constraint. - Issue string + Debug bool + + // Effective user ID of running test + ActualEUID int } // NewKataTest creates a new TestConstraint object and is the main interface diff --git a/src/runtime/pkg/katatestutils/constraints_test.go b/src/runtime/pkg/katatestutils/constraints_test.go index 5af55eb7c4..8a95a9c800 100644 --- a/src/runtime/pkg/katatestutils/constraints_test.go +++ b/src/runtime/pkg/katatestutils/constraints_test.go @@ -27,12 +27,14 @@ const ( skipUnknownDistroName = "skipping test as cannot determine distro name" ) +// nolint: govet type testDataUID struct { uid int op Operator c Constraints } +// nolint: govet type testDataDistro struct { distro string op Operator @@ -341,6 +343,7 @@ func testGetKernelVersion() (version string, err error) { func TestOperatorString(t *testing.T) { assert := assert.New(t) + // nolint: govet type testData struct { op Operator value string @@ -473,6 +476,7 @@ func TestGetKernelVersion(t *testing.T) { func TestConstraintHandleDistroName(t *testing.T) { assert := assert.New(t) + // nolint: govet type testData struct { distro string op Operator @@ -568,6 +572,7 @@ func TestConstraintHandleDistroVersion(t *testing.T) { assert.NoError(err) assert.NotEqual(distroVersion, higherVersion) + // nolint: govet type testData struct { version string op Operator @@ -623,6 +628,7 @@ func TestConstraintHandleDistroVersion(t *testing.T) { func TestConstraintHandleVersionType(t *testing.T) { assert := assert.New(t) + // nolint: govet type testData struct { versionName string currentVersion string @@ -791,6 +797,7 @@ func TestConstraintHandleKernelVersion(t *testing.T) { newerPatch, err := semverBumpVersion(ver, false, false, true) assert.NoError(err) + // nolint: govet type testData struct { version string op Operator @@ -852,6 +859,7 @@ func TestConstraintHandleKernelVersion(t *testing.T) { func TestConstraintHandleUID(t *testing.T) { assert := assert.New(t) + // nolint: govet type testData struct { uid int op Operator @@ -897,6 +905,7 @@ func TestConstraintHandleUID(t *testing.T) { func TestConstraintHandleResults(t *testing.T) { assert := assert.New(t) + // nolint: govet type testData struct { result Result err error @@ -1330,6 +1339,7 @@ func TestConstraintNotValidDistroVersion(t *testing.T) { func TestConstraintConstraintValid(t *testing.T) { assert := assert.New(t) + // nolint: govet type testData struct { fn Constraint valid bool @@ -1522,6 +1532,7 @@ func TestConstraintConstraintValid(t *testing.T) { func TestEvalIntVersion(t *testing.T) { assert := assert.New(t) + // nolint: govet type testData struct { currentVer string op Operator @@ -1627,6 +1638,7 @@ func TestEvalIntVersion(t *testing.T) { func TestEvalFloatVersion(t *testing.T) { assert := assert.New(t) + // nolint: govet type testData struct { currentVer string op Operator @@ -1742,6 +1754,7 @@ func TestEvalFloatVersion(t *testing.T) { func TestEvalSemverVersion(t *testing.T) { assert := assert.New(t) + // nolint: govet type testData struct { currentVer string op Operator diff --git a/src/runtime/pkg/katatestutils/utils.go b/src/runtime/pkg/katatestutils/utils.go index b6da2fdb79..aab7876f7e 100644 --- a/src/runtime/pkg/katatestutils/utils.go +++ b/src/runtime/pkg/katatestutils/utils.go @@ -11,10 +11,6 @@ import "strconv" type RuntimeConfigOptions struct { Hypervisor string HypervisorPath string - DefaultVCPUCount uint32 - DefaultMaxVCPUCount uint32 - DefaultMemSize uint32 - DefaultMsize9p uint32 DefaultGuestHookPath string KernelPath string ImagePath string @@ -28,8 +24,15 @@ type RuntimeConfigOptions struct { AgentTraceType string SharedFS string VirtioFSDaemon string + JaegerEndpoint string + JaegerUser string + JaegerPassword string PFlash []string PCIeRootPort uint32 + DefaultVCPUCount uint32 + DefaultMaxVCPUCount uint32 + DefaultMemSize uint32 + DefaultMsize9p uint32 DisableBlock bool EnableIOThreads bool HotplugVFIOOnRootBus bool @@ -42,9 +45,6 @@ type RuntimeConfigOptions struct { AgentDebug bool AgentTrace bool EnablePprof bool - JaegerEndpoint string - JaegerUser string - JaegerPassword string } // ContainerIDTestDataType is a type used to test Container and Sandbox ID's. diff --git a/src/runtime/pkg/katautils/config.go b/src/runtime/pkg/katautils/config.go index 41ff6c3bdf..edf882c5f9 100644 --- a/src/runtime/pkg/katautils/config.go +++ b/src/runtime/pkg/katautils/config.go @@ -55,21 +55,21 @@ type tomlConfig struct { Hypervisor map[string]hypervisor Agent map[string]agent Runtime runtime - Factory factory - Netmon netmon Image image + Netmon netmon + Factory factory } type image struct { - ServiceOffload bool `toml:"service_offload"` Provision string `toml:"provision"` + ServiceOffload bool `toml:"service_offload"` } type factory struct { - Template bool `toml:"enable_template"` TemplatePath string `toml:"template_path"` - VMCacheNumber uint `toml:"vm_cache_number"` VMCacheEndpoint string `toml:"vm_cache_endpoint"` + VMCacheNumber uint `toml:"vm_cache_number"` + Template bool `toml:"enable_template"` } type hypervisor struct { diff --git a/src/runtime/pkg/katautils/config_test.go b/src/runtime/pkg/katautils/config_test.go index 0d02534f9a..e6df8985b5 100644 --- a/src/runtime/pkg/katautils/config_test.go +++ b/src/runtime/pkg/katautils/config_test.go @@ -39,6 +39,7 @@ var ( jaegerPassword = "jaeger_password1" ) +// nolint: govet type testRuntimeConfig struct { RuntimeConfig oci.RuntimeConfig RuntimeConfigFile string @@ -1574,6 +1575,7 @@ func TestCheckNetNsConfig(t *testing.T) { func TestCheckFactoryConfig(t *testing.T) { assert := assert.New(t) + // nolint: govet type testData struct { factoryEnabled bool expectError bool diff --git a/src/runtime/pkg/utils/utils_test.go b/src/runtime/pkg/utils/utils_test.go index 30189521d4..5af0f1e0c5 100644 --- a/src/runtime/pkg/utils/utils_test.go +++ b/src/runtime/pkg/utils/utils_test.go @@ -57,6 +57,7 @@ func TestEnsureDir(t *testing.T) { assert.NoError(err) defer os.RemoveAll(tmpdir) + // nolint: govet testCases := []struct { before func() path string