*: fix lint issues

Signed-off-by: Antonio Murdaca <runcom@redhat.com>
This commit is contained in:
Antonio Murdaca 2017-08-22 12:35:19 +02:00
parent d56bf090ce
commit 8088d7a1e2
No known key found for this signature in database
GPG key ID: B2BEAD150DE936B9
10 changed files with 43 additions and 41 deletions

View file

@ -4,20 +4,31 @@ set -o errexit
set -o nounset set -o nounset
set -o pipefail set -o pipefail
for d in $(find . -type d -not -iwholename '*.git*' -a -not -iname '.tool' -a -not -iwholename '*vendor*' -a -not -iwholename '*.artifacts*' -a -not -iwholename '*contrib*' -a -not -iwholename '*test*' -a -not -iwholename '*logo*' -a -not -iwholename '*conmon*' -a -not -iwholename '*completions*' -a -not -iwholename '*docs*' -a -not -iwholename '*pause*'); do PKGS=$(find . -type d -not -path . -a -not -iwholename '*.git*' -a -not -iname '.tool' -a -not -iwholename '*vendor*' -a -not -iname 'hack' -a -not -iwholename '*.artifacts*' -a -not -iwholename '*contrib*' -a -not -iwholename '*test*' -a -not -iwholename '*logo*' -a -not -iwholename '*conmon*' -a -not -iwholename '*completions*' -a -not -iwholename '*docs*' -a -not -iwholename '*pause*')
${GOPATH}/bin/gometalinter \ ${GOPATH}/bin/gometalinter \
--exclude='error return value not checked.*(Close|Log|Print|RemoveAll).*\(errcheck\)$' \ --concurrency=4\
--enable-gc\
--vendored-linters\
--deadline=600s --disable-all\
--enable=deadcode\
--enable=errcheck\
--enable=goconst\
--enable=gofmt\
--enable=golint\
--enable=ineffassign\
--enable=interfacer\
--enable=megacheck\
--enable=misspell\
--enable=structcheck\
--enable=varcheck\
--enable=vet\
--enable=vetshadow\
--exclude='error return value not checked.*\(errcheck\)$'\
--exclude='declaration of.*err.*shadows declaration.*\(vetshadow\)$'\ --exclude='declaration of.*err.*shadows declaration.*\(vetshadow\)$'\
--exclude='.*_test\.go:.*error return value not checked.*\(errcheck\)$'\ --exclude='.*_test\.go:.*error return value not checked.*\(errcheck\)$'\
--exclude='duplicate of.*_test.go.*\(dupl\)$'\ --exclude='duplicate of.*_test.go.*\(dupl\)$'\
--exclude='cmd\/client\/.*\.go.*\(dupl\)$'\ --exclude='cmd\/client\/.*\.go.*\(dupl\)$'\
--exclude='vendor\/.*'\ --exclude='vendor\/.*'\
--exclude='server\/seccomp\/.*\.go.*$'\ --exclude='server\/seccomp\/.*\.go.*$'\
--disable=aligncheck \ ${PKGS[@]}
--disable=gotype \
--disable=gas \
--cyclo-over=80 \
--dupl-threshold=100 \
--tests \
--deadline=600s "${d}"
done

View file

@ -30,7 +30,7 @@ var basicFunctions = template.FuncMap{
// HeaderFunctions are used to created headers of a table. // HeaderFunctions are used to created headers of a table.
// This is a replacement of basicFunctions for header generation // This is a replacement of basicFunctions for header generation
// because we want the header to remain intact. // because we want the header to remain intact.
// Some functions like `split` are irrevelant so not added. // Some functions like `split` are irrelevant so not added.
var headerFunctions = template.FuncMap{ var headerFunctions = template.FuncMap{
"json": func(v string) string { "json": func(v string) string {
return v return v

View file

@ -85,14 +85,14 @@ func inspectCmd(c *cli.Context) error {
return errors.Wrapf(err, "error parsing container data") return errors.Wrapf(err, "error parsing container data")
} }
case inspectTypeImage: case inspectTypeImage:
data, err = libkpodimage.GetImageData(server.Store(), name) data, err = libkpodimage.GetData(server.Store(), name)
if err != nil { if err != nil {
return errors.Wrapf(err, "error parsing image data") return errors.Wrapf(err, "error parsing image data")
} }
case inspectAll: case inspectAll:
ctrData, err := server.GetContainerData(name, size) ctrData, err := server.GetContainerData(name, size)
if err != nil { if err != nil {
imgData, err := libkpodimage.GetImageData(server.Store(), name) imgData, err := libkpodimage.GetData(server.Store(), name)
if err != nil { if err != nil {
return errors.Wrapf(err, "error parsing container or image data") return errors.Wrapf(err, "error parsing container or image data")
} }

View file

@ -8,9 +8,6 @@ import (
"github.com/urfave/cli" "github.com/urfave/cli"
) )
//Version of kpod
const Version string = "0.0.1"
func main() { func main() {
if reexec.Init() { if reexec.Init() {
return return
@ -19,7 +16,7 @@ func main() {
app := cli.NewApp() app := cli.NewApp()
app.Name = "kpod" app.Name = "kpod"
app.Usage = "manage pods and images" app.Usage = "manage pods and images"
app.Version = Version app.Version = "0.0.1"
app.Commands = []cli.Command{ app.Commands = []cli.Command{
diffCommand, diffCommand,

View file

@ -17,7 +17,7 @@ var (
// versionCmd gets and prints version info for version command // versionCmd gets and prints version info for version command
func versionCmd(c *cli.Context) error { func versionCmd(c *cli.Context) error {
fmt.Println("Version: ", Version) fmt.Println("Version: ", c.App.Version)
fmt.Println("Go Version: ", runtime.Version()) fmt.Println("Go Version: ", runtime.Version())
if gitCommit != "" { if gitCommit != "" {
fmt.Println("Git Commit: ", gitCommit) fmt.Println("Git Commit: ", gitCommit)

View file

@ -77,7 +77,7 @@ func (c *ContainerServer) GetContainerData(name string, size bool) (*ContainerDa
if container.ImageID == "" { if container.ImageID == "" {
return nil, errors.Errorf("error reading container image data: container is not based on an image") return nil, errors.Errorf("error reading container image data: container is not based on an image")
} }
imageData, err := libkpodimage.GetImageData(c.store, container.ImageID) imageData, err := libkpodimage.GetData(c.store, container.ImageID)
if err != nil { if err != nil {
return nil, errors.Wrapf(err, "error reading container image data") return nil, errors.Wrapf(err, "error reading container image data")
} }

View file

@ -122,19 +122,13 @@ func matchesLabel(info *types.ImageInspectInfo, store storage.Store, label strin
// Returns true if the image was created since the filter image. Returns // Returns true if the image was created since the filter image. Returns
// false otherwise // false otherwise
func matchesBeforeImage(info *types.ImageInspectInfo, name string, params *FilterParams) bool { func matchesBeforeImage(info *types.ImageInspectInfo, name string, params *FilterParams) bool {
if info.Created.Before(params.beforeImage) { return info.Created.Before(params.beforeImage)
return true
}
return false
} }
// Returns true if the image was created since the filter image. Returns // Returns true if the image was created since the filter image. Returns
// false otherwise // false otherwise
func matchesSinceImage(info *types.ImageInspectInfo, name string, params *FilterParams) bool { func matchesSinceImage(info *types.ImageInspectInfo, name string, params *FilterParams) bool {
if info.Created.After(params.sinceImage) { return info.Created.After(params.sinceImage)
return true
}
return false
} }
// MatchesID returns true if argID is a full or partial match for id // MatchesID returns true if argID is a full or partial match for id

View file

@ -13,9 +13,9 @@ import (
"github.com/pkg/errors" "github.com/pkg/errors"
) )
// ImageData handles the data used when inspecting a container // Data handles the data used when inspecting a container
// nolint // nolint
type ImageData struct { type Data struct {
ID string ID string
Tags []string Tags []string
Digests []string Digests []string
@ -75,8 +75,8 @@ func annotations(manifest []byte, manifestType string) map[string]string {
return annotations return annotations
} }
// GetImageData gets the ImageData for a container with the given name in the given store. // GetData gets the Data for a container with the given name in the given store.
func GetImageData(store storage.Store, name string) (*ImageData, error) { func GetData(store storage.Store, name string) (*Data, error) {
img, err := FindImage(store, name) img, err := FindImage(store, name)
if err != nil { if err != nil {
return nil, errors.Wrapf(err, "error reading image %q", name) return nil, errors.Wrapf(err, "error reading image %q", name)
@ -140,7 +140,7 @@ func GetImageData(store storage.Store, name string) (*ImageData, error) {
historyCreatedBy = config.History[len(config.History)-1].CreatedBy historyCreatedBy = config.History[len(config.History)-1].CreatedBy
} }
return &ImageData{ return &Data{
ID: img.ID, ID: img.ID,
Tags: tags, Tags: tags,
Digests: digests, Digests: digests,

View file

@ -42,7 +42,7 @@ func (c *ContainerServer) GetLogs(container string, logChan chan string, opts Lo
t, err := tail.TailFile(logsFile, tail.Config{Follow: false, ReOpen: false, Location: seekInfo}) t, err := tail.TailFile(logsFile, tail.Config{Follow: false, ReOpen: false, Location: seekInfo})
for line := range t.Lines { for line := range t.Lines {
if since, err := logSinceTime(opts.SinceTime, line.Text); err != nil || since == false { if since, err := logSinceTime(opts.SinceTime, line.Text); err != nil || !since {
continue continue
} }
logMessage := line.Text[secondSpaceIndex(line.Text):] logMessage := line.Text[secondSpaceIndex(line.Text):]

View file

@ -269,7 +269,7 @@ func (svc *imageService) isSecureIndex(indexName string) bool {
for _, addr := range addrs { for _, addr := range addrs {
for _, ipnet := range svc.insecureRegistryCIDRs { for _, ipnet := range svc.insecureRegistryCIDRs {
// check if the addr falls in the subnet // check if the addr falls in the subnet
if (*net.IPNet)(ipnet).Contains(addr) { if ipnet.Contains(addr) {
return false return false
} }
} }