runtime: cli: fix govet fieldalignment

Fix structures alignment

Signed-off-by: Julio Montes <julio.montes@intel.com>
This commit is contained in:
Julio Montes 2021-07-09 12:52:31 -05:00
parent 54bcd3c946
commit 0dc59df68f
6 changed files with 115 additions and 115 deletions

View File

@ -34,12 +34,12 @@ import (
) )
type kernelModule struct { type kernelModule struct {
// description
desc string
// maps parameter names to values // maps parameter names to values
parameters map[string]string parameters map[string]string
// description
desc string
// if it is definitely required // if it is definitely required
required bool required bool
} }
@ -54,10 +54,10 @@ type kvmExtension struct {
} }
type vmContainerCapableDetails struct { type vmContainerCapableDetails struct {
cpuInfoFile string
requiredCPUFlags map[string]string requiredCPUFlags map[string]string
requiredCPUAttribs map[string]string requiredCPUAttribs map[string]string
requiredKernelModules map[string]kernelModule requiredKernelModules map[string]kernelModule
cpuInfoFile string
} }
const ( const (

View File

@ -109,12 +109,12 @@ func TestCheckCheckKernelModulesNoNesting(t *testing.T) {
} }
actualModuleData := []testModuleData{ actualModuleData := []testModuleData{
{filepath.Join(sysModuleDir, "kvm"), true, ""}, {filepath.Join(sysModuleDir, "kvm"), "", true},
{filepath.Join(sysModuleDir, "kvm_intel"), true, ""}, {filepath.Join(sysModuleDir, "kvm_intel"), "", true},
{filepath.Join(sysModuleDir, "kvm_intel/parameters/unrestricted_guest"), false, "Y"}, {filepath.Join(sysModuleDir, "kvm_intel/parameters/unrestricted_guest"), "Y", false},
// XXX: force a warning // XXX: force a warning
{filepath.Join(sysModuleDir, "kvm_intel/parameters/nested"), false, "N"}, {filepath.Join(sysModuleDir, "kvm_intel/parameters/nested"), "N", false},
} }
vendor := archGenuineIntel vendor := archGenuineIntel
@ -194,12 +194,12 @@ func TestCheckCheckKernelModulesNoUnrestrictedGuest(t *testing.T) {
} }
actualModuleData := []testModuleData{ actualModuleData := []testModuleData{
{filepath.Join(sysModuleDir, "kvm"), true, ""}, {filepath.Join(sysModuleDir, "kvm"), "", true},
{filepath.Join(sysModuleDir, "kvm_intel"), true, ""}, {filepath.Join(sysModuleDir, "kvm_intel"), "", true},
{filepath.Join(sysModuleDir, "kvm_intel/parameters/nested"), false, "Y"}, {filepath.Join(sysModuleDir, "kvm_intel/parameters/nested"), "Y", false},
// XXX: force a failure on non-VMM systems // XXX: force a failure on non-VMM systems
{filepath.Join(sysModuleDir, "kvm_intel/parameters/unrestricted_guest"), false, "N"}, {filepath.Join(sysModuleDir, "kvm_intel/parameters/unrestricted_guest"), "N", false},
} }
vendor := archGenuineIntel vendor := archGenuineIntel
@ -295,10 +295,10 @@ func TestCheckHostIsVMContainerCapable(t *testing.T) {
} }
moduleData = []testModuleData{ moduleData = []testModuleData{
{filepath.Join(sysModuleDir, "kvm"), true, ""}, {filepath.Join(sysModuleDir, "kvm"), "", true},
{filepath.Join(sysModuleDir, "kvm_intel"), true, ""}, {filepath.Join(sysModuleDir, "kvm_intel"), "", true},
{filepath.Join(sysModuleDir, "kvm_intel/parameters/nested"), false, "Y"}, {filepath.Join(sysModuleDir, "kvm_intel/parameters/nested"), "Y", false},
{filepath.Join(sysModuleDir, "kvm_intel/parameters/unrestricted_guest"), false, "Y"}, {filepath.Join(sysModuleDir, "kvm_intel/parameters/unrestricted_guest"), "Y", false},
} }
} else if cpuType == cpuTypeAMD { } else if cpuType == cpuTypeAMD {
cpuData = []testCPUData{ cpuData = []testCPUData{
@ -311,9 +311,9 @@ func TestCheckHostIsVMContainerCapable(t *testing.T) {
} }
moduleData = []testModuleData{ moduleData = []testModuleData{
{filepath.Join(sysModuleDir, "kvm"), true, ""}, {filepath.Join(sysModuleDir, "kvm"), "", true},
{filepath.Join(sysModuleDir, "kvm_amd"), true, ""}, {filepath.Join(sysModuleDir, "kvm_amd"), "", true},
{filepath.Join(sysModuleDir, "kvm_amd/parameters/nested"), false, "1"}, {filepath.Join(sysModuleDir, "kvm_amd/parameters/nested"), "1", false},
} }
} }
@ -338,51 +338,51 @@ func TestArchKernelParamHandler(t *testing.T) {
assert := assert.New(t) assert := assert.New(t)
type testData struct { type testData struct {
onVMM bool
expectIgnore bool
fields logrus.Fields fields logrus.Fields
msg string msg string
onVMM bool
expectIgnore bool
} }
data := []testData{ data := []testData{
{true, false, logrus.Fields{}, ""}, {logrus.Fields{}, "", true, false},
{false, false, logrus.Fields{}, ""}, {logrus.Fields{}, "", false, false},
{ {
false,
false,
logrus.Fields{ logrus.Fields{
// wrong type // wrong type
"parameter": 123, "parameter": 123,
}, },
"foo", "foo",
false,
false,
}, },
{ {
false,
false,
logrus.Fields{ logrus.Fields{
"parameter": "unrestricted_guest", "parameter": "unrestricted_guest",
}, },
"", "",
false,
false,
}, },
{ {
true,
true,
logrus.Fields{ logrus.Fields{
"parameter": "unrestricted_guest", "parameter": "unrestricted_guest",
}, },
"", "",
true,
true,
}, },
{ {
false,
true,
logrus.Fields{ logrus.Fields{
"parameter": "nested", "parameter": "nested",
}, },
"", "",
false,
true,
}, },
} }

View File

@ -26,8 +26,8 @@ import (
type testModuleData struct { type testModuleData struct {
path string path string
isDir bool
contents string contents string
isDir bool
} }
// nolint: structcheck, unused, deadcode // nolint: structcheck, unused, deadcode
@ -400,46 +400,46 @@ func TestCheckCheckCPUFlags(t *testing.T) {
assert := assert.New(t) assert := assert.New(t)
type testData struct { type testData struct {
cpuflags string
required map[string]string required map[string]string
cpuflags string
expectCount uint32 expectCount uint32
} }
data := []testData{ data := []testData{
{ {
"",
map[string]string{}, map[string]string{},
"",
0, 0,
}, },
{ {
"",
map[string]string{ map[string]string{
"a": "A flag", "a": "A flag",
}, },
"",
0, 0,
}, },
{ {
"",
map[string]string{ map[string]string{
"a": "A flag", "a": "A flag",
"b": "B flag", "b": "B flag",
}, },
"",
0, 0,
}, },
{ {
"a b c",
map[string]string{ map[string]string{
"b": "B flag", "b": "B flag",
}, },
"a b c",
0, 0,
}, },
{ {
"a b c",
map[string]string{ map[string]string{
"x": "X flag", "x": "X flag",
"y": "Y flag", "y": "Y flag",
"z": "Z flag", "z": "Z flag",
}, },
"a b c",
3, 3,
}, },
} }
@ -454,54 +454,54 @@ func TestCheckCheckCPUAttribs(t *testing.T) {
assert := assert.New(t) assert := assert.New(t)
type testData struct { type testData struct {
cpuinfo string
required map[string]string required map[string]string
cpuinfo string
expectCount uint32 expectCount uint32
} }
data := []testData{ data := []testData{
{ {
"",
map[string]string{}, map[string]string{},
"",
0, 0,
}, },
{ {
"",
map[string]string{ map[string]string{
"a": "", "a": "",
}, },
"",
0, 0,
}, },
{ {
map[string]string{
"b": "B attribute",
},
"a: b", "a: b",
map[string]string{
"b": "B attribute",
},
0, 0,
}, },
{ {
map[string]string{
"b": "B attribute",
},
"a: b\nc: d\ne: f", "a: b\nc: d\ne: f",
map[string]string{
"b": "B attribute",
},
0, 0,
}, },
{ {
"a: b\n",
map[string]string{ map[string]string{
"b": "B attribute", "b": "B attribute",
"c": "C attribute", "c": "C attribute",
"d": "D attribute", "d": "D attribute",
}, },
"a: b\n",
2, 2,
}, },
{ {
"a: b\nc: d\ne: f",
map[string]string{ map[string]string{
"b": "B attribute", "b": "B attribute",
"d": "D attribute", "d": "D attribute",
"f": "F attribute", "f": "F attribute",
}, },
"a: b\nc: d\ne: f",
0, 0,
}, },
} }

View File

@ -72,29 +72,29 @@ type RuntimeConfigInfo struct {
// RuntimeInfo stores runtime details. // RuntimeInfo stores runtime details.
type RuntimeInfo struct { type RuntimeInfo struct {
Version RuntimeVersionInfo
Config RuntimeConfigInfo Config RuntimeConfigInfo
Path string
Experimental []exp.Feature
Version RuntimeVersionInfo
Debug bool Debug bool
Trace bool Trace bool
DisableGuestSeccomp bool DisableGuestSeccomp bool
DisableNewNetNs bool DisableNewNetNs bool
SandboxCgroupOnly bool SandboxCgroupOnly bool
Experimental []exp.Feature
Path string
} }
type VersionInfo struct { type VersionInfo struct {
Semver string Semver string
Commit string
Major uint64 Major uint64
Minor uint64 Minor uint64
Patch uint64 Patch uint64
Commit string
} }
// RuntimeVersionInfo stores details of the runtime version // RuntimeVersionInfo stores details of the runtime version
type RuntimeVersionInfo struct { type RuntimeVersionInfo struct {
Version VersionInfo
OCI string OCI string
Version VersionInfo
} }
// HypervisorInfo stores hypervisor details // HypervisorInfo stores hypervisor details
@ -115,10 +115,10 @@ type HypervisorInfo struct {
// AgentInfo stores agent details // AgentInfo stores agent details
type AgentInfo struct { type AgentInfo struct {
Debug bool
Trace bool
TraceMode string TraceMode string
TraceType string TraceType string
Debug bool
Trace bool
} }
// DistroInfo stores host operating system distribution details. // DistroInfo stores host operating system distribution details.
@ -140,8 +140,8 @@ type HostInfo struct {
// NetmonInfo stores netmon details // NetmonInfo stores netmon details
type NetmonInfo struct { type NetmonInfo struct {
Version VersionInfo
Path string Path string
Version VersionInfo
Debug bool Debug bool
Enable bool Enable bool
} }
@ -151,15 +151,15 @@ type NetmonInfo struct {
// //
// XXX: Any changes must be coupled with a change to formatVersion. // XXX: Any changes must be coupled with a change to formatVersion.
type EnvInfo struct { type EnvInfo struct {
Meta MetaInfo
Runtime RuntimeInfo
Hypervisor HypervisorInfo
Image ImageInfo
Kernel KernelInfo Kernel KernelInfo
Meta MetaInfo
Image ImageInfo
Initrd InitrdInfo Initrd InitrdInfo
Agent AgentInfo Agent AgentInfo
Host HostInfo Hypervisor HypervisorInfo
Netmon NetmonInfo Netmon NetmonInfo
Runtime RuntimeInfo
Host HostInfo
} }
func getMetaInfo() MetaInfo { func getMetaInfo() MetaInfo {

View File

@ -21,10 +21,10 @@ import (
type ReleaseCmd int type ReleaseCmd int
type releaseDetails struct { type releaseDetails struct {
version semver.Version
date string date string
url string url string
filename string filename string
version semver.Version
} }
const ( const (

View File

@ -55,16 +55,16 @@ func TestGetReleaseURL(t *testing.T) {
type testData struct { type testData struct {
currentVersion string currentVersion string
expectError bool
expectedURL string expectedURL string
expectError bool
} }
data := []testData{ data := []testData{
{"0.0.0", true, ""}, {"0.0.0", "", true},
{"1.0.0", false, kata1xURL}, {"1.0.0", kata1xURL, false},
{"1.9999.9999", false, kata1xURL}, {"1.9999.9999", kata1xURL, false},
{"2.0.0-alpha3", false, kata2xURL}, {"2.0.0-alpha3", kata2xURL, false},
{"2.9999.9999", false, kata2xURL}, {"2.9999.9999", kata2xURL, false},
} }
for i, d := range data { for i, d := range data {
@ -99,17 +99,17 @@ func TestGetReleaseURLEnvVar(t *testing.T) {
type testData struct { type testData struct {
envVarValue string envVarValue string
expectError bool
expectedURL string expectedURL string
expectError bool
} }
data := []testData{ data := []testData{
{"", false, expectedReleasesURL}, {"", expectedReleasesURL, false},
{"http://google.com", true, ""}, {"http://google.com", "", true},
{"https://katacontainers.io", true, ""}, {"https://katacontainers.io", "", true},
{"https://github.com/kata-containers/runtime/releases/latest", true, ""}, {"https://github.com/kata-containers/runtime/releases/latest", "", true},
{"https://github.com/kata-containers/kata-containers/releases/latest", true, ""}, {"https://github.com/kata-containers/kata-containers/releases/latest", "", true},
{expectedReleasesURL, false, expectedReleasesURL}, {expectedReleasesURL, expectedReleasesURL, false},
} }
assert.Equal(os.Getenv("KATA_RELEASE_URL"), "") assert.Equal(os.Getenv("KATA_RELEASE_URL"), "")
@ -138,9 +138,9 @@ func TestMakeRelease(t *testing.T) {
type testData struct { type testData struct {
release map[string]interface{} release map[string]interface{}
expectError bool
expectedVersion string expectedVersion string
expectedDetails releaseDetails expectedDetails releaseDetails
expectError bool
} }
invalidRel1 := map[string]interface{}{"foo": 1} invalidRel1 := map[string]interface{}{"foo": 1}
@ -228,17 +228,17 @@ func TestMakeRelease(t *testing.T) {
} }
data := []testData{ data := []testData{
{invalidRel1, true, "", releaseDetails{}}, {invalidRel1, "", releaseDetails{}, true},
{invalidRel2, true, "", releaseDetails{}}, {invalidRel2, "", releaseDetails{}, true},
{invalidRel3, true, "", releaseDetails{}}, {invalidRel3, "", releaseDetails{}, true},
{invalidRelMissingVersion, true, "", releaseDetails{}}, {invalidRelMissingVersion, "", releaseDetails{}, true},
{invalidRelInvalidVersion, true, "", releaseDetails{}}, {invalidRelInvalidVersion, "", releaseDetails{}, true},
{invalidRelMissingAssets, true, "", releaseDetails{}}, {invalidRelMissingAssets, "", releaseDetails{}, true},
{invalidRelAssetsMissingURL, true, "", releaseDetails{}}, {invalidRelAssetsMissingURL, "", releaseDetails{}, true},
{invalidRelAssetsMissingFile, true, "", releaseDetails{}}, {invalidRelAssetsMissingFile, "", releaseDetails{}, true},
{invalidRelAssetsMissingDate, true, "", releaseDetails{}}, {invalidRelAssetsMissingDate, "", releaseDetails{}, true},
{validRel, false, testRelVersion, validReleaseDetails}, {validRel, testRelVersion, validReleaseDetails, false},
} }
for i, d := range data { for i, d := range data {
@ -453,47 +453,47 @@ func TestGetNewReleaseType(t *testing.T) {
type testData struct { type testData struct {
currentVer string currentVer string
latestVer string latestVer string
expectError bool
result string result string
expectError bool
} }
data := []testData{ data := []testData{
// Check build metadata (ignored for version comparisons) // Check build metadata (ignored for version comparisons)
{"2.0.0+build", "2.0.0", true, ""}, {"2.0.0+build", "2.0.0", "", true},
{"2.0.0+build-1", "2.0.0+build-2", true, ""}, {"2.0.0+build-1", "2.0.0+build-2", "", true},
{"1.12.0+build", "1.12.0", true, ""}, {"1.12.0+build", "1.12.0", "", true},
{"2.0.0-rc3+foo", "2.0.0", false, "major"}, {"2.0.0-rc3+foo", "2.0.0", "major", false},
{"2.0.0-rc3+foo", "2.0.0-rc4", false, "pre-release"}, {"2.0.0-rc3+foo", "2.0.0-rc4", "pre-release", false},
{"1.12.0+foo", "1.13.0", false, "minor"}, {"1.12.0+foo", "1.13.0", "minor", false},
{"1.12.0+build", "2.0.0", false, "major"}, {"1.12.0+build", "2.0.0", "major", false},
{"1.12.0+build", "1.13.0", false, "minor"}, {"1.12.0+build", "1.13.0", "minor", false},
{"1.12.0-rc2+build", "1.12.1", false, "patch"}, {"1.12.0-rc2+build", "1.12.1", "patch", false},
{"1.12.0-rc2+build", "1.12.1-foo", false, "patch pre-release"}, {"1.12.0-rc2+build", "1.12.1-foo", "patch pre-release", false},
{"1.12.0-rc4+wibble", "1.12.0", false, "major"}, {"1.12.0-rc4+wibble", "1.12.0", "major", false},
{"2.0.0-alpha3", "1.0.0", true, ""}, {"2.0.0-alpha3", "1.0.0", "", true},
{"1.0.0", "1.0.0", true, ""}, {"1.0.0", "1.0.0", "", true},
{"2.0.0", "1.0.0", true, ""}, {"2.0.0", "1.0.0", "", true},
{"1.0.0", "2.0.0", false, "major"}, {"1.0.0", "2.0.0", "major", false},
{"2.0.0-alpha3", "2.0.0-alpha4", false, "pre-release"}, {"2.0.0-alpha3", "2.0.0-alpha4", "pre-release", false},
{"1.0.0", "2.0.0-alpha3", false, "major pre-release"}, {"1.0.0", "2.0.0-alpha3", "major pre-release", false},
{"1.0.0", "1.1.2", false, "minor"}, {"1.0.0", "1.1.2", "minor", false},
{"1.0.0", "1.1.2-pre2", false, "minor pre-release"}, {"1.0.0", "1.1.2-pre2", "minor pre-release", false},
{"1.0.0", "1.1.2-foo", false, "minor pre-release"}, {"1.0.0", "1.1.2-foo", "minor pre-release", false},
{"1.0.0", "1.0.3", false, "patch"}, {"1.0.0", "1.0.3", "patch", false},
{"1.0.0-beta29", "1.0.0-beta30", false, "pre-release"}, {"1.0.0-beta29", "1.0.0-beta30", "pre-release", false},
{"1.0.0", "1.0.3-alpha99.1b", false, "patch pre-release"}, {"1.0.0", "1.0.3-alpha99.1b", "patch pre-release", false},
{"2.0.0-rc0", "2.0.0", false, "major"}, {"2.0.0-rc0", "2.0.0", "major", false},
{"2.0.0-rc1", "2.0.0", false, "major"}, {"2.0.0-rc1", "2.0.0", "major", false},
{"1.12.0-rc0", "1.12.0", false, "major"}, {"1.12.0-rc0", "1.12.0", "major", false},
{"1.12.0-rc5", "1.12.0", false, "major"}, {"1.12.0-rc5", "1.12.0", "major", false},
} }
for i, d := range data { for i, d := range data {