Skip to content
Merged
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
35 changes: 35 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
---
run:
concurrency: 6
deadline: 5m
linters:
disable-all: true
enable:
- deadcode
- depguard
- gofmt
- typecheck
- varcheck
# - dupl
# - errcheck
# - gochecknoglobals
# - gochecknoinits
# - goconst
# - gocritic
# - gocyclo
# - goimports
# - golint
# - gosec
# - govet
# - ineffassign
# - interfacer
# - lll
# - maligned
# - misspell
# - nakedret
# - prealloc
# - scopelint
# - staticcheck
# - structcheck
# - unconvert
# - unparam
48 changes: 0 additions & 48 deletions .tool/lint

This file was deleted.

16 changes: 6 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,7 @@ endif
touch $@

lint: .gopathok varlink_generate ## Execute the source code linter
@echo "checking lint"
@./.tool/lint
golangci-lint run --build-tags="$(BUILDTAGS)"

gofmt: ## Verify the source code gofmt
find . -name '*.go' ! -path './vendor/*' -exec gofmt -s -w {} \+
Expand Down Expand Up @@ -280,7 +279,7 @@ uninstall:

.PHONY: install.tools

install.tools: .install.gitvalidation .install.gometalinter .install.md2man .install.ginkgo ## Install needed tools
install.tools: .install.gitvalidation .install.golangci-lint .install.md2man .install.ginkgo ## Install needed tools

.install.vndr: .gopathok
$(GO) get -u github.com/LK4D4/vndr
Expand All @@ -295,13 +294,10 @@ install.tools: .install.gitvalidation .install.gometalinter .install.md2man .ins
$(GO) get -u github.com/vbatts/git-validation; \
fi

.install.gometalinter: .gopathok
if [ ! -x "$(GOBIN)/gometalinter" ]; then \
$(GO) get -u github.com/alecthomas/gometalinter; \
cd $(FIRST_GOPATH)/src/github.com/alecthomas/gometalinter; \
git checkout e8d801238da6f0dfd14078d68f9b53fa50a7eeb5; \
$(GO) install github.com/alecthomas/gometalinter; \
$(GOBIN)/gometalinter --install; \
.install.golangci-lint: .gopathok
if [ ! -x "$(GOBIN)/golangci-lint" ]; then \
curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh |\
sh -s -- -b $(GOBIN) v1.15.0 ;\
fi

.install.md2man: .gopathok
Expand Down
6 changes: 1 addition & 5 deletions cmd/podman/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,13 @@ import (
"github.com/containers/libpod/cmd/podman/cliconfig"
"github.com/containers/libpod/libpod"
"github.com/containers/libpod/pkg/rootless"
"github.com/containers/storage"
"github.com/fatih/camelcase"
jsoniter "github.com/json-iterator/go"
"github.com/pkg/errors"
"github.com/spf13/cobra"
)

var (
stores = make(map[storage.Store]struct{})
json = jsoniter.ConfigCompatibleWithStandardLibrary
)
var json = jsoniter.ConfigCompatibleWithStandardLibrary

const (
idTruncLength = 12
Expand Down
15 changes: 0 additions & 15 deletions cmd/podman/common_test.go

This file was deleted.

1 change: 0 additions & 1 deletion cmd/podman/pod_ps.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import (
)

const (
STOPPED = "Stopped"
RUNNING = "Running"
PAUSED = "Paused"
EXITED = "Exited"
Expand Down
14 changes: 0 additions & 14 deletions cmd/podman/pod_stats.go
Original file line number Diff line number Diff line change
Expand Up @@ -298,17 +298,3 @@ func outputJson(stats []*adapter.PodContainerStats) error {
fmt.Println(string(b))
return nil
}

func getPodsByList(podList []string, r *libpod.Runtime) ([]*libpod.Pod, error) {
var (
pods []*libpod.Pod
)
for _, p := range podList {
pod, err := r.LookupPod(p)
if err != nil {
return nil, err
}
pods = append(pods, pod)
}
return pods, nil
}
117 changes: 17 additions & 100 deletions cmd/podman/ps.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,35 +19,31 @@ import (
"github.com/containers/libpod/libpod"
"github.com/containers/libpod/pkg/rootless"
"github.com/containers/libpod/pkg/util"
"github.com/cri-o/ocicni/pkg/ocicni"
"github.com/docker/go-units"
"github.com/opentracing/opentracing-go"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
"github.com/spf13/cobra"
"k8s.io/apimachinery/pkg/fields"
)

const (
mountTruncLength = 12
hid = "CONTAINER ID"
himage = "IMAGE"
hcommand = "COMMAND"
hcreated = "CREATED"
hstatus = "STATUS"
hports = "PORTS"
hnames = "NAMES"
hsize = "SIZE"
hinfra = "IS INFRA"
hpod = "POD"
nspid = "PID"
nscgroup = "CGROUPNS"
nsipc = "IPC"
nsmnt = "MNT"
nsnet = "NET"
nspidns = "PIDNS"
nsuserns = "USERNS"
nsuts = "UTS"
hid = "CONTAINER ID"
himage = "IMAGE"
hcommand = "COMMAND"
hcreated = "CREATED"
hstatus = "STATUS"
hports = "PORTS"
hnames = "NAMES"
hsize = "SIZE"
hpod = "POD"
nspid = "PID"
nscgroup = "CGROUPNS"
nsipc = "IPC"
nsmnt = "MNT"
nsnet = "NET"
nspidns = "PIDNS"
nsuserns = "USERNS"
nsuts = "UTS"
)

type psTemplateParams struct {
Expand All @@ -74,34 +70,6 @@ type psTemplateParams struct {
IsInfra bool
}

// psJSONParams is used as a base structure for the psParams
// If template output is requested, psJSONParams will be converted to
// psTemplateParams.
// psJSONParams will be populated by data from libpod.Container,
// the members of the struct are the sama data types as their sources.
type psJSONParams struct {
ID string `json:"id"`
Image string `json:"image"`
ImageID string `json:"image_id"`
Command []string `json:"command"`
ExitCode int32 `json:"exitCode"`
Exited bool `json:"exited"`
CreatedAt time.Time `json:"createdAt"`
StartedAt time.Time `json:"startedAt"`
ExitedAt time.Time `json:"exitedAt"`
Status string `json:"status"`
PID int `json:"PID"`
Ports []ocicni.PortMapping `json:"ports"`
Size *shared.ContainerSize `json:"size,omitempty"`
Names string `json:"names"`
Labels fields.Set `json:"labels"`
Mounts []string `json:"mounts"`
ContainerRunning bool `json:"ctrRunning"`
Namespaces *shared.Namespace `json:"namespace,omitempty"`
Pod string `json:"pod,omitempty"`
IsInfra bool `json:"infra"`
}

// Type declaration and functions for sorting the PS output
type psSorted []shared.PsContainerOutput

Expand Down Expand Up @@ -447,57 +415,6 @@ func sortPsOutput(sortBy string, psOutput psSorted) (psSorted, error) {
return psOutput, nil
}

// getLabels converts the labels to a string of the form "key=value, key2=value2"
func formatLabels(labels map[string]string) string {
var arr []string
if len(labels) > 0 {
for key, val := range labels {
temp := key + "=" + val
arr = append(arr, temp)
}
return strings.Join(arr, ",")
}
return ""
}

// getMounts converts the volumes mounted to a string of the form "mount1, mount2"
// it truncates it if noTrunc is false
func getMounts(mounts []string, noTrunc bool) string {
return strings.Join(getMountsArray(mounts, noTrunc), ",")
}

func getMountsArray(mounts []string, noTrunc bool) []string {
var arr []string
if len(mounts) == 0 {
return mounts
}
for _, mount := range mounts {
splitArr := strings.Split(mount, ":")
if len(splitArr[0]) > mountTruncLength && !noTrunc {
arr = append(arr, splitArr[0][:mountTruncLength]+"...")
continue
}
arr = append(arr, splitArr[0])
}
return arr
}

// portsToString converts the ports used to a string of the from "port1, port2"
func portsToString(ports []ocicni.PortMapping) string {
var portDisplay []string
if len(ports) == 0 {
return ""
}
for _, v := range ports {
hostIP := v.HostIP
if hostIP == "" {
hostIP = "0.0.0.0"
}
portDisplay = append(portDisplay, fmt.Sprintf("%s:%d->%d/%s", hostIP, v.HostPort, v.ContainerPort, v.Protocol))
}
return strings.Join(portDisplay, ", ")
}

func printFormat(format string, containers []shared.PsContainerOutput) error {
// return immediately if no containers are present
if len(containers) == 0 {
Expand Down
1 change: 0 additions & 1 deletion cmd/podman/run_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import (

var (
sysInfo = sysinfo.New(true)
cmd = []string{"podman", "test", "alpine"}
CLI *cliconfig.PodmanCommand
)

Expand Down
5 changes: 0 additions & 5 deletions cmd/podman/search.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,6 @@ import (
"github.com/spf13/cobra"
)

const (
descriptionTruncLength = 44
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, these seem like they ought to be used - did we start hardcoding them when we have constants?

maxQueries = 25
)

var (
searchCommand cliconfig.SearchValues
searchDescription = `Search registries for a given image. Can search all the default registries or a specific registry.
Expand Down
5 changes: 0 additions & 5 deletions cmd/podman/shared/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,6 @@ import (
"github.com/sirupsen/logrus"
)

// getContext returns a non-nil, empty context
func getContext() context.Context {
return context.TODO()
}

func CreateContainer(ctx context.Context, c *cliconfig.PodmanCommand, runtime *libpod.Runtime) (*libpod.Container, *cc.CreateConfig, error) {
var (
healthCheck *manifest.Schema2HealthConfig
Expand Down
5 changes: 0 additions & 5 deletions cmd/podman/trust_set_show.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"strings"

"github.com/containers/buildah/pkg/formats"
"github.com/containers/image/types"
"github.com/containers/libpod/cmd/podman/cliconfig"
"github.com/containers/libpod/cmd/podman/libpodruntime"
"github.com/containers/libpod/libpod/image"
Expand Down Expand Up @@ -237,10 +236,6 @@ func isValidTrustType(t string) bool {
return false
}

func getDefaultPolicyPath() string {
return trust.DefaultPolicyPath(&types.SystemContext{})
}

func getPolicyJSON(policyContentStruct trust.PolicyContent, systemRegistriesDirPath string) (map[string]map[string]interface{}, error) {
registryConfigs, err := trust.LoadAndMergeConfig(systemRegistriesDirPath)
if err != nil {
Expand Down
Loading