Merge pull request #77 from coreos/simplify

various: gofmt -s
This commit is contained in:
Jimmy Zelinskie 2016-02-24 19:44:43 -05:00
commit d1e9a21e0e
20 changed files with 91 additions and 91 deletions

View File

@ -48,9 +48,9 @@ type ClairAPI struct {
}
type AddLayoutRequestAPI struct {
ID string `json:"ID"`
Path string `json:"Path"`
ParantID string `json:"ParantID"`
ID string `json:"ID"`
Path string `json:"Path"`
ParentID string `json:"ParentID"`
ImageFormat string `json:"ImageFormat"`
}
@ -333,7 +333,7 @@ func CheckPriority(priority string) (result string, err error) {
return "", err
}
if match {
result = strings.ToUpper(string(priority[0])) + strings.ToLower(priority[1:len(priority)])
result = strings.ToUpper(string(priority[0])) + strings.ToLower(priority[1:])
return
}
return "", errors.New("Unknown priority " + priority)

View File

@ -83,7 +83,7 @@ func TestRaceAffects(t *testing.T) {
Name: uuid.New(),
Namespace: feature.Namespace,
FixedIn: []database.FeatureVersion{
database.FeatureVersion{
{
Feature: feature,
Version: types.NewVersionUnsafe(strconv.Itoa(version)),
},

View File

@ -55,25 +55,25 @@ func TestInsertFeature(t *testing.T) {
// Insert invalid FeatureVersion.
for _, invalidFeatureVersion := range []database.FeatureVersion{
database.FeatureVersion{
{
Feature: database.Feature{},
Version: types.NewVersionUnsafe("1.0"),
},
database.FeatureVersion{
{
Feature: database.Feature{
Namespace: database.Namespace{},
Name: "TestInsertFeature2",
},
Version: types.NewVersionUnsafe("1.0"),
},
database.FeatureVersion{
{
Feature: database.Feature{
Namespace: database.Namespace{Name: "TestInsertFeatureNamespace2"},
Name: "TestInsertFeature2",
},
Version: types.NewVersionUnsafe(""),
},
database.FeatureVersion{
{
Feature: database.Feature{
Namespace: database.Namespace{Name: "TestInsertFeatureNamespace2"},
Name: "TestInsertFeature2",

View File

@ -43,7 +43,7 @@ func (pgSQL *pgSQL) FindLayer(name string, withFeatures, withVulnerabilities boo
t := time.Now()
err := pgSQL.QueryRow(searchLayer, name).
Scan(&layer.ID, &layer.Name, &layer.EngineVersion, &parentID, &parentName, &namespaceID,
&namespaceName)
&namespaceName)
observeQueryTime("FindLayer", "searchLayer", t)
if err != nil {

View File

@ -124,9 +124,9 @@ func TestInsertLayer(t *testing.T) {
func testInsertLayerInvalid(t *testing.T, datastore database.Datastore) {
invalidLayers := []database.Layer{
database.Layer{},
database.Layer{Name: "layer0", Parent: &database.Layer{}},
database.Layer{Name: "layer0", Parent: &database.Layer{Name: "UnknownLayer"}},
{},
{Name: "layer0", Parent: &database.Layer{}},
{Name: "layer0", Parent: &database.Layer{Name: "UnknownLayer"}},
}
for _, invalidLayer := range invalidLayers {
@ -180,23 +180,23 @@ func testInsertLayerTree(t *testing.T, datastore database.Datastore) {
}
layers := []database.Layer{
database.Layer{
{
Name: "TestInsertLayer1",
},
database.Layer{
{
Name: "TestInsertLayer2",
Parent: &database.Layer{Name: "TestInsertLayer1"},
Namespace: &database.Namespace{Name: "TestInsertLayerNamespace1"},
},
// This layer changes the namespace and adds Features.
database.Layer{
{
Name: "TestInsertLayer3",
Parent: &database.Layer{Name: "TestInsertLayer2"},
Namespace: &database.Namespace{Name: "TestInsertLayerNamespace2"},
Features: []database.FeatureVersion{f1, f2, f3},
},
// This layer covers the case where the last layer doesn't provide any new Feature.
database.Layer{
{
Name: "TestInsertLayer4a",
Parent: &database.Layer{Name: "TestInsertLayer3"},
Features: []database.FeatureVersion{f1, f2, f3},
@ -204,7 +204,7 @@ func testInsertLayerTree(t *testing.T, datastore database.Datastore) {
// This layer covers the case where the last layer provides Features.
// It also modifies the Namespace ("upgrade") but keeps some Features not upgraded, their
// Namespaces should then remain unchanged.
database.Layer{
{
Name: "TestInsertLayer4b",
Parent: &database.Layer{Name: "TestInsertLayer3"},
Namespace: &database.Namespace{Name: "TestInsertLayerNamespace3"},

View File

@ -15,9 +15,9 @@
package pgsql
import (
"fmt"
"testing"
"fmt"
"github.com/coreos/clair/database"
"github.com/stretchr/testify/assert"
)

View File

@ -36,7 +36,7 @@ func TestNotification(t *testing.T) {
l1 := database.Layer{
Name: "TestNotificationLayer1",
Features: []database.FeatureVersion{
database.FeatureVersion{
{
Feature: f1,
Version: types.NewVersionUnsafe("0.1"),
},
@ -46,7 +46,7 @@ func TestNotification(t *testing.T) {
l2 := database.Layer{
Name: "TestNotificationLayer2",
Features: []database.FeatureVersion{
database.FeatureVersion{
{
Feature: f1,
Version: types.NewVersionUnsafe("0.2"),
},
@ -56,7 +56,7 @@ func TestNotification(t *testing.T) {
l3 := database.Layer{
Name: "TestNotificationLayer3",
Features: []database.FeatureVersion{
database.FeatureVersion{
{
Feature: f1,
Version: types.NewVersionUnsafe("0.3"),
},
@ -66,7 +66,7 @@ func TestNotification(t *testing.T) {
l4 := database.Layer{
Name: "TestNotificationLayer4",
Features: []database.FeatureVersion{
database.FeatureVersion{
{
Feature: f2,
Version: types.NewVersionUnsafe("0.1"),
},
@ -88,7 +88,7 @@ func TestNotification(t *testing.T) {
Link: "TestNotificationLink1",
Severity: "Unknown",
FixedIn: []database.FeatureVersion{
database.FeatureVersion{
{
Feature: f1,
Version: types.NewVersionUnsafe("1.0"),
},
@ -148,11 +148,11 @@ func TestNotification(t *testing.T) {
v1b := v1
v1b.Severity = types.High
v1b.FixedIn = []database.FeatureVersion{
database.FeatureVersion{
{
Feature: f1,
Version: types.MinVersion,
},
database.FeatureVersion{
{
Feature: f2,
Version: types.MaxVersion,
},

View File

@ -465,7 +465,7 @@ func (pgSQL *pgSQL) DeleteVulnerabilityFix(vulnerabilityNamespace, vulnerability
Name: vulnerabilityNamespace,
},
FixedIn: []database.FeatureVersion{
database.FeatureVersion{
{
Feature: database.Feature{
Name: featureName,
Namespace: database.Namespace{

View File

@ -44,11 +44,11 @@ func TestFindVulnerability(t *testing.T) {
Severity: types.High,
Namespace: database.Namespace{Name: "debian:7"},
FixedIn: []database.FeatureVersion{
database.FeatureVersion{
{
Feature: database.Feature{Name: "openssl"},
Version: types.NewVersionUnsafe("2.0"),
},
database.FeatureVersion{
{
Feature: database.Feature{Name: "libssl"},
Version: types.NewVersionUnsafe("1.9-abc"),
},
@ -161,30 +161,30 @@ func TestInsertVulnerability(t *testing.T) {
// Insert invalid vulnerabilities.
for _, vulnerability := range []database.Vulnerability{
database.Vulnerability{
{
Name: "",
Namespace: n1,
FixedIn: []database.FeatureVersion{f1},
Severity: types.Unknown,
},
database.Vulnerability{
{
Name: "TestInsertVulnerability0",
Namespace: database.Namespace{},
FixedIn: []database.FeatureVersion{f1},
Severity: types.Unknown,
},
database.Vulnerability{
{
Name: "TestInsertVulnerability0-",
Namespace: database.Namespace{},
FixedIn: []database.FeatureVersion{f1},
},
database.Vulnerability{
{
Name: "TestInsertVulnerability0",
Namespace: n1,
FixedIn: []database.FeatureVersion{f1},
Severity: types.Priority(""),
},
database.Vulnerability{
{
Name: "TestInsertVulnerability0",
Namespace: n1,
FixedIn: []database.FeatureVersion{f2},

View File

@ -39,14 +39,14 @@ func TestDebianParser(t *testing.T) {
assert.Equal(t, "This vulnerability is not very dangerous.", vulnerability.Description)
expectedFeatureVersions := []database.FeatureVersion{
database.FeatureVersion{
{
Feature: database.Feature{
Namespace: database.Namespace{Name: "debian:8"},
Name: "aptdaemon",
},
Version: types.MaxVersion,
},
database.FeatureVersion{
{
Feature: database.Feature{
Namespace: database.Namespace{Name: "debian:unstable"},
@ -65,21 +65,21 @@ func TestDebianParser(t *testing.T) {
assert.Equal(t, "But this one is very dangerous.", vulnerability.Description)
expectedFeatureVersions := []database.FeatureVersion{
database.FeatureVersion{
{
Feature: database.Feature{
Namespace: database.Namespace{Name: "debian:8"},
Name: "aptdaemon",
},
Version: types.NewVersionUnsafe("0.7.0"),
},
database.FeatureVersion{
{
Feature: database.Feature{
Namespace: database.Namespace{Name: "debian:unstable"},
Name: "aptdaemon",
},
Version: types.NewVersionUnsafe("0.7.0"),
},
database.FeatureVersion{
{
Feature: database.Feature{
Namespace: database.Namespace{Name: "debian:8"},
Name: "asterisk",
@ -97,7 +97,7 @@ func TestDebianParser(t *testing.T) {
assert.Equal(t, "Un-affected packages.", vulnerability.Description)
expectedFeatureVersions := []database.FeatureVersion{
database.FeatureVersion{
{
Feature: database.Feature{
Namespace: database.Namespace{Name: "debian:8"},
Name: "asterisk",

View File

@ -39,21 +39,21 @@ func TestRHELParser(t *testing.T) {
assert.Equal(t, `Xerces-C is a validating XML parser written in a portable subset of C++. A flaw was found in the way the Xerces-C XML parser processed certain XML documents. A remote attacker could provide specially crafted XML input that, when parsed by an application using Xerces-C, would cause that application to crash.`, vulnerabilities[0].Description)
expectedFeatureVersions := []database.FeatureVersion{
database.FeatureVersion{
{
Feature: database.Feature{
Namespace: database.Namespace{Name: "centos:7"},
Name: "xerces-c",
},
Version: types.NewVersionUnsafe("3.1.1-7.el7_1"),
},
database.FeatureVersion{
{
Feature: database.Feature{
Namespace: database.Namespace{Name: "centos:7"},
Name: "xerces-c-devel",
},
Version: types.NewVersionUnsafe("3.1.1-7.el7_1"),
},
database.FeatureVersion{
{
Feature: database.Feature{
Namespace: database.Namespace{Name: "centos:7"},
Name: "xerces-c-doc",
@ -77,14 +77,14 @@ func TestRHELParser(t *testing.T) {
assert.Equal(t, `Mozilla Firefox is an open source web browser. XULRunner provides the XUL Runtime environment for Mozilla Firefox. Several flaws were found in the processing of malformed web content. A web page containing malicious content could cause Firefox to crash or, potentially, execute arbitrary code with the privileges of the user running Firefox.`, vulnerabilities[0].Description)
expectedFeatureVersions := []database.FeatureVersion{
database.FeatureVersion{
{
Feature: database.Feature{
Namespace: database.Namespace{Name: "centos:6"},
Name: "firefox",
},
Version: types.NewVersionUnsafe("38.1.0-1.el6_6"),
},
database.FeatureVersion{
{
Feature: database.Feature{
Namespace: database.Namespace{Name: "centos:7"},
Name: "firefox",

View File

@ -43,30 +43,30 @@ const (
var (
ubuntuIgnoredReleases = map[string]struct{}{
"upstream": struct{}{},
"devel": struct{}{},
"upstream": {},
"devel": {},
"dapper": struct{}{},
"edgy": struct{}{},
"feisty": struct{}{},
"gutsy": struct{}{},
"hardy": struct{}{},
"intrepid": struct{}{},
"jaunty": struct{}{},
"karmic": struct{}{},
"lucid": struct{}{},
"maverick": struct{}{},
"natty": struct{}{},
"oneiric": struct{}{},
"saucy": struct{}{},
"dapper": {},
"edgy": {},
"feisty": {},
"gutsy": {},
"hardy": {},
"intrepid": {},
"jaunty": {},
"karmic": {},
"lucid": {},
"maverick": {},
"natty": {},
"oneiric": {},
"saucy": {},
"vivid/ubuntu-core": struct{}{},
"vivid/stable-phone-overlay": struct{}{},
"vivid/ubuntu-core": {},
"vivid/stable-phone-overlay": {},
// Syntax error
"Patches": struct{}{},
"Patches": {},
// Product
"product": struct{}{},
"product": {},
}
affectsCaptureRegexp = regexp.MustCompile(`(?P<release>.*)_(?P<package>.*): (?P<status>[^\s]*)( \(+(?P<note>[^()]*)\)+)?`)

View File

@ -43,21 +43,21 @@ func TestUbuntuParser(t *testing.T) {
assert.True(t, hasUnkownRelease)
expectedFeatureVersions := []database.FeatureVersion{
database.FeatureVersion{
{
Feature: database.Feature{
Namespace: database.Namespace{Name: "ubuntu:14.04"},
Name: "libmspack",
},
Version: types.MaxVersion,
},
database.FeatureVersion{
{
Feature: database.Feature{
Namespace: database.Namespace{Name: "ubuntu:15.04"},
Name: "libmspack",
},
Version: types.NewVersionUnsafe("0.4-3"),
},
database.FeatureVersion{
{
Feature: database.Feature{
Namespace: database.Namespace{Name: "ubuntu:15.10"},
Name: "libmspack-anotherpkg",

View File

@ -24,18 +24,18 @@ import (
var dpkgPackagesTests = []feature.FeatureVersionTest{
// Test an Ubuntu dpkg status file
feature.FeatureVersionTest{
{
FeatureVersions: []database.FeatureVersion{
// Two packages from this source are installed, it should only appear one time
database.FeatureVersion{
{
Feature: database.Feature{Name: "pam"},
Version: types.NewVersionUnsafe("1.1.8-3.1ubuntu3"),
},
database.FeatureVersion{
{
Feature: database.Feature{Name: "makedev"}, // The source name and the package name are equals
Version: types.NewVersionUnsafe("2.3.1-93ubuntu1"), // The version comes from the "Version:" line
},
database.FeatureVersion{
{
Feature: database.Feature{Name: "gcc-5"},
Version: types.NewVersionUnsafe("5.1.1-12ubuntu1"), // The version comes from the "Source:" line
},

View File

@ -25,15 +25,15 @@ import (
var rpmPackagesTests = []feature.FeatureVersionTest{
// Test a CentOS 7 RPM database
// Memo: Use the following command on a RPM-based system to shrink a database: rpm -qa --qf "%{NAME}\n" |tail -n +3| xargs rpm -e --justdb
feature.FeatureVersionTest{
{
FeatureVersions: []database.FeatureVersion{
// Two packages from this source are installed, it should only appear once
database.FeatureVersion{
{
Feature: database.Feature{Name: "centos-release"},
Version: types.NewVersionUnsafe("7-1.1503.el7.centos.2.8"),
},
// Two packages from this source are installed, it should only appear once
database.FeatureVersion{
{
Feature: database.Feature{Name: "filesystem"},
Version: types.NewVersionUnsafe("3.2-18.el7"),
},

View File

@ -22,7 +22,7 @@ import (
)
var aptSourcesOSTests = []namespace.NamespaceTest{
namespace.NamespaceTest{
{
ExpectedNamespace: database.Namespace{Name: "debian:unstable"},
Data: map[string][]byte{
"etc/os-release": []byte(

View File

@ -22,7 +22,7 @@ import (
)
var lsbReleaseOSTests = []namespace.NamespaceTest{
namespace.NamespaceTest{
{
ExpectedNamespace: database.Namespace{Name: "ubuntu:12.04"},
Data: map[string][]byte{
"etc/lsb-release": []byte(
@ -32,7 +32,7 @@ DISTRIB_CODENAME=precise
DISTRIB_DESCRIPTION="Ubuntu 12.04 LTS"`),
},
},
namespace.NamespaceTest{ // We don't care about the minor version of Debian
{ // We don't care about the minor version of Debian
ExpectedNamespace: database.Namespace{Name: "debian:7"},
Data: map[string][]byte{
"etc/lsb-release": []byte(

View File

@ -22,7 +22,7 @@ import (
)
var osReleaseOSTests = []namespace.NamespaceTest{
namespace.NamespaceTest{
{
ExpectedNamespace: database.Namespace{Name: "debian:8"},
Data: map[string][]byte{
"etc/os-release": []byte(
@ -36,7 +36,7 @@ SUPPORT_URL="http://www.debian.org/support/"
BUG_REPORT_URL="https://bugs.debian.org/"`),
},
},
namespace.NamespaceTest{
{
ExpectedNamespace: database.Namespace{Name: "ubuntu:15.10"},
Data: map[string][]byte{
"etc/os-release": []byte(
@ -51,7 +51,7 @@ SUPPORT_URL="http://help.ubuntu.com/"
BUG_REPORT_URL="http://bugs.launchpad.net/ubuntu/"`),
},
},
namespace.NamespaceTest{ // Doesn't have quotes around VERSION_ID
{ // Doesn't have quotes around VERSION_ID
ExpectedNamespace: database.Namespace{Name: "fedora:20"},
Data: map[string][]byte{
"etc/os-release": []byte(

View File

@ -22,13 +22,13 @@ import (
)
var redhatReleaseTests = []namespace.NamespaceTest{
namespace.NamespaceTest{
{
ExpectedNamespace: database.Namespace{Name: "centos:6"},
Data: map[string][]byte{
"etc/centos-release": []byte(`CentOS release 6.6 (Final)`),
},
},
namespace.NamespaceTest{
{
ExpectedNamespace: database.Namespace{Name: "centos:7"},
Data: map[string][]byte{
"etc/system-release": []byte(`CentOS Linux release 7.1.1503 (Core)`),

View File

@ -63,35 +63,35 @@ func TestProcessWithDistUpgrade(t *testing.T) {
// These FeatureVersions haven't been upgraded.
nonUpgradedFeatureVersions := []database.FeatureVersion{
database.FeatureVersion{
{
Feature: database.Feature{Name: "libtext-wrapi18n-perl"},
Version: types.NewVersionUnsafe("0.06-7"),
},
database.FeatureVersion{
{
Feature: database.Feature{Name: "libtext-charwidth-perl"},
Version: types.NewVersionUnsafe("0.04-7"),
},
database.FeatureVersion{
{
Feature: database.Feature{Name: "libtext-iconv-perl"},
Version: types.NewVersionUnsafe("1.7-5"),
},
database.FeatureVersion{
{
Feature: database.Feature{Name: "mawk"},
Version: types.NewVersionUnsafe("1.3.3-17"),
},
database.FeatureVersion{
{
Feature: database.Feature{Name: "insserv"},
Version: types.NewVersionUnsafe("1.14.0-5"),
},
database.FeatureVersion{
{
Feature: database.Feature{Name: "db"},
Version: types.NewVersionUnsafe("5.1.29-5"),
},
database.FeatureVersion{
{
Feature: database.Feature{Name: "ustr"},
Version: types.NewVersionUnsafe("1.0.4-3"),
},
database.FeatureVersion{
{
Feature: database.Feature{Name: "xz-utils"},
Version: types.NewVersionUnsafe("5.1.1alpha+20120614-2"),
},