aboutsummaryrefslogtreecommitdiff
path: root/cmd
diff options
context:
space:
mode:
authorDaniel J Walsh <dwalsh@redhat.com>2017-12-16 09:38:55 -0500
committerAtomic Bot <atomic-devel@projectatomic.io>2017-12-18 16:46:05 +0000
commitde3468e120d489d046c08dad72ba2262e222ccb1 (patch)
tree8956f751c460baf23f95b5bfd9a441bd71d8f5dd /cmd
parentf2f9fdf12674623dd0d38b32408083cccdad5e66 (diff)
downloadpodman-de3468e120d489d046c08dad72ba2262e222ccb1.tar.gz
podman-de3468e120d489d046c08dad72ba2262e222ccb1.tar.bz2
podman-de3468e120d489d046c08dad72ba2262e222ccb1.zip
CleanUp problems found my make lint.
Remove or comment out unused functions. Signed-off-by: Daniel J Walsh <dwalsh@redhat.com> Closes: #145 Approved by: umohnani8
Diffstat (limited to 'cmd')
-rw-r--r--cmd/kpod/common.go17
-rw-r--r--cmd/kpod/create.go52
-rw-r--r--cmd/kpod/create_cli.go36
-rw-r--r--cmd/kpod/inspect.go12
-rw-r--r--cmd/kpod/ps.go82
-rw-r--r--cmd/kpod/spec.go28
-rw-r--r--cmd/kpod/top.go4
7 files changed, 68 insertions, 163 deletions
diff --git a/cmd/kpod/common.go b/cmd/kpod/common.go
index 046ea4509..99685107b 100644
--- a/cmd/kpod/common.go
+++ b/cmd/kpod/common.go
@@ -6,7 +6,6 @@ import (
"regexp"
"strings"
- is "github.com/containers/image/storage"
"github.com/containers/storage"
"github.com/fatih/camelcase"
"github.com/pkg/errors"
@@ -21,22 +20,6 @@ var (
const crioConfigPath = "/etc/crio/crio.conf"
-func getStore(c *libkpod.Config) (storage.Store, error) {
- options := storage.DefaultStoreOptions
- options.GraphRoot = c.Root
- options.RunRoot = c.RunRoot
- options.GraphDriverName = c.Storage
- options.GraphDriverOptions = c.StorageOptions
-
- store, err := storage.GetStore(options)
- if err != nil {
- return nil, err
- }
- is.Transport.SetStore(store)
- stores[store] = struct{}{}
- return store, nil
-}
-
func getRuntime(c *cli.Context) (*libpod.Runtime, error) {
config, err := getConfig(c)
diff --git a/cmd/kpod/create.go b/cmd/kpod/create.go
index 3548ad7df..afed70eaa 100644
--- a/cmd/kpod/create.go
+++ b/cmd/kpod/create.go
@@ -39,14 +39,14 @@ var (
type createResourceConfig struct {
BlkioWeight uint16 // blkio-weight
BlkioWeightDevice []string // blkio-weight-device
- CpuPeriod uint64 // cpu-period
- CpuQuota int64 // cpu-quota
- CpuRtPeriod uint64 // cpu-rt-period
- CpuRtRuntime int64 // cpu-rt-runtime
- CpuShares uint64 // cpu-shares
- Cpus string // cpus
- CpusetCpus string
- CpusetMems string // cpuset-mems
+ CPUPeriod uint64 // cpu-period
+ CPUQuota int64 // cpu-quota
+ CPURtPeriod uint64 // cpu-rt-period
+ CPURtRuntime int64 // cpu-rt-runtime
+ CPUShares uint64 // cpu-shares
+ CPUs string // cpus
+ CPUsetCPUs string
+ CPUsetMems string // cpuset-mems
DeviceReadBps []string // device-read-bps
DeviceReadIOps []string // device-read-iops
DeviceWriteBps []string // device-write-bps
@@ -73,9 +73,9 @@ type createConfig struct {
Command []string
Detach bool // detach
Devices []*pb.Device // device
- DnsOpt []string //dns-opt
- DnsSearch []string //dns-search
- DnsServers []string //dns
+ DNSOpt []string //dns-opt
+ DNSSearch []string //dns-search
+ DNSServers []string //dns
Entrypoint string //entrypoint
Env map[string]string //env
Expose []string //expose
@@ -84,8 +84,8 @@ type createConfig struct {
Image string
Interactive bool //interactive
IpcMode container.IpcMode //ipc
- Ip6Address string //ipv6
- IpAddress string //ip
+ IP6Address string //ipv6
+ IPAddress string //ip
Labels map[string]string //label
LinkLocalIP []string // link-local-ip
LogDriver string // log-driver
@@ -419,9 +419,9 @@ func parseCreateOpts(c *cli.Context, runtime *libpod.Runtime) (*createConfig, er
CgroupParent: c.String("cgroup-parent"),
Command: command,
Detach: c.Bool("detach"),
- DnsOpt: c.StringSlice("dns-opt"),
- DnsSearch: c.StringSlice("dns-search"),
- DnsServers: c.StringSlice("dns"),
+ DNSOpt: c.StringSlice("dns-opt"),
+ DNSSearch: c.StringSlice("dns-search"),
+ DNSServers: c.StringSlice("dns"),
Entrypoint: c.String("entrypoint"),
Env: env,
Expose: c.StringSlice("expose"),
@@ -429,8 +429,8 @@ func parseCreateOpts(c *cli.Context, runtime *libpod.Runtime) (*createConfig, er
Hostname: c.String("hostname"),
Image: image,
Interactive: c.Bool("interactive"),
- Ip6Address: c.String("ipv6"),
- IpAddress: c.String("ip"),
+ IP6Address: c.String("ipv6"),
+ IPAddress: c.String("ip"),
Labels: labels,
LinkLocalIP: c.StringSlice("link-local-ip"),
LogDriver: c.String("log-driver"),
@@ -451,14 +451,14 @@ func parseCreateOpts(c *cli.Context, runtime *libpod.Runtime) (*createConfig, er
Resources: createResourceConfig{
BlkioWeight: blkioWeight,
BlkioWeightDevice: c.StringSlice("blkio-weight-device"),
- CpuShares: c.Uint64("cpu-shares"),
- CpuPeriod: c.Uint64("cpu-period"),
- CpusetCpus: c.String("cpu-period"),
- CpusetMems: c.String("cpuset-mems"),
- CpuQuota: c.Int64("cpu-quota"),
- CpuRtPeriod: c.Uint64("cpu-rt-period"),
- CpuRtRuntime: c.Int64("cpu-rt-runtime"),
- Cpus: c.String("cpus"),
+ CPUShares: c.Uint64("cpu-shares"),
+ CPUPeriod: c.Uint64("cpu-period"),
+ CPUsetCPUs: c.String("cpu-period"),
+ CPUsetMems: c.String("cpuset-mems"),
+ CPUQuota: c.Int64("cpu-quota"),
+ CPURtPeriod: c.Uint64("cpu-rt-period"),
+ CPURtRuntime: c.Int64("cpu-rt-runtime"),
+ CPUs: c.String("cpus"),
DeviceReadBps: c.StringSlice("device-read-bps"),
DeviceReadIOps: c.StringSlice("device-read-iops"),
DeviceWriteBps: c.StringSlice("device-write-bps"),
diff --git a/cmd/kpod/create_cli.go b/cmd/kpod/create_cli.go
index a162cb319..0cc265e92 100644
--- a/cmd/kpod/create_cli.go
+++ b/cmd/kpod/create_cli.go
@@ -170,43 +170,43 @@ func verifyContainerResources(config *createConfig, update bool) ([]string, erro
config.Resources.PidsLimit = 0
}
- if config.Resources.CpuShares > 0 && !sysInfo.CPUShares {
+ if config.Resources.CPUShares > 0 && !sysInfo.CPUShares {
warnings = addWarning(warnings, "Your kernel does not support CPU shares or the cgroup is not mounted. Shares discarded.")
- config.Resources.CpuShares = 0
+ config.Resources.CPUShares = 0
}
- if config.Resources.CpuPeriod > 0 && !sysInfo.CPUCfsPeriod {
+ if config.Resources.CPUPeriod > 0 && !sysInfo.CPUCfsPeriod {
warnings = addWarning(warnings, "Your kernel does not support CPU cfs period or the cgroup is not mounted. Period discarded.")
- config.Resources.CpuPeriod = 0
+ config.Resources.CPUPeriod = 0
}
- if config.Resources.CpuPeriod != 0 && (config.Resources.CpuPeriod < 1000 || config.Resources.CpuPeriod > 1000000) {
+ if config.Resources.CPUPeriod != 0 && (config.Resources.CPUPeriod < 1000 || config.Resources.CPUPeriod > 1000000) {
return warnings, fmt.Errorf("CPU cfs period can not be less than 1ms (i.e. 1000) or larger than 1s (i.e. 1000000)")
}
- if config.Resources.CpuQuota > 0 && !sysInfo.CPUCfsQuota {
+ if config.Resources.CPUQuota > 0 && !sysInfo.CPUCfsQuota {
warnings = addWarning(warnings, "Your kernel does not support CPU cfs quota or the cgroup is not mounted. Quota discarded.")
- config.Resources.CpuQuota = 0
+ config.Resources.CPUQuota = 0
}
- if config.Resources.CpuQuota > 0 && config.Resources.CpuQuota < 1000 {
+ if config.Resources.CPUQuota > 0 && config.Resources.CPUQuota < 1000 {
return warnings, fmt.Errorf("CPU cfs quota can not be less than 1ms (i.e. 1000)")
}
// cpuset subsystem checks and adjustments
- if (config.Resources.CpusetCpus != "" || config.Resources.CpusetMems != "") && !sysInfo.Cpuset {
- warnings = addWarning(warnings, "Your kernel does not support cpuset or the cgroup is not mounted. Cpuset discarded.")
- config.Resources.CpusetCpus = ""
- config.Resources.CpusetMems = ""
+ if (config.Resources.CPUsetCPUs != "" || config.Resources.CPUsetMems != "") && !sysInfo.Cpuset {
+ warnings = addWarning(warnings, "Your kernel does not support cpuset or the cgroup is not mounted. CPUset discarded.")
+ config.Resources.CPUsetCPUs = ""
+ config.Resources.CPUsetMems = ""
}
- cpusAvailable, err := sysInfo.IsCpusetCpusAvailable(config.Resources.CpusetCpus)
+ cpusAvailable, err := sysInfo.IsCpusetCpusAvailable(config.Resources.CPUsetCPUs)
if err != nil {
- return warnings, fmt.Errorf("invalid value %s for cpuset cpus", config.Resources.CpusetCpus)
+ return warnings, fmt.Errorf("invalid value %s for cpuset cpus", config.Resources.CPUsetCPUs)
}
if !cpusAvailable {
- return warnings, fmt.Errorf("requested CPUs are not available - requested %s, available: %s", config.Resources.CpusetCpus, sysInfo.Cpus)
+ return warnings, fmt.Errorf("requested CPUs are not available - requested %s, available: %s", config.Resources.CPUsetCPUs, sysInfo.Cpus)
}
- memsAvailable, err := sysInfo.IsCpusetMemsAvailable(config.Resources.CpusetMems)
+ memsAvailable, err := sysInfo.IsCpusetMemsAvailable(config.Resources.CPUsetMems)
if err != nil {
- return warnings, fmt.Errorf("invalid value %s for cpuset mems", config.Resources.CpusetMems)
+ return warnings, fmt.Errorf("invalid value %s for cpuset mems", config.Resources.CPUsetMems)
}
if !memsAvailable {
- return warnings, fmt.Errorf("requested memory nodes are not available - requested %s, available: %s", config.Resources.CpusetMems, sysInfo.Mems)
+ return warnings, fmt.Errorf("requested memory nodes are not available - requested %s, available: %s", config.Resources.CPUsetMems, sysInfo.Mems)
}
// blkio subsystem checks and adjustments
diff --git a/cmd/kpod/inspect.go b/cmd/kpod/inspect.go
index e3387841b..3f9da8d83 100644
--- a/cmd/kpod/inspect.go
+++ b/cmd/kpod/inspect.go
@@ -165,7 +165,7 @@ func getCtrInspectInfo(ctr *libpod.Container, ctrInspectData *libpod.ContainerIn
CPUQuota: quota,
CPURealtimePeriod: realtimePeriod,
CPURealtimeRuntime: realtimeRuntime,
- CPUSetCpus: cpus,
+ CPUSetCPUs: cpus,
CPUSetMems: mems,
Devices: spec.Linux.Devices,
KernelMemory: memKernel,
@@ -187,9 +187,9 @@ func getCtrInspectInfo(ctr *libpod.Container, ctrInspectData *libpod.ContainerIn
AutoRemove: createArtifact.Rm,
CapAdd: createArtifact.CapAdd,
CapDrop: createArtifact.CapDrop,
- DNS: createArtifact.DnsServers,
- DNSOptions: createArtifact.DnsOpt,
- DNSSearch: createArtifact.DnsSearch,
+ DNS: createArtifact.DNSServers,
+ DNSOptions: createArtifact.DNSOpt,
+ DNSSearch: createArtifact.DNSSearch,
PidMode: string(createArtifact.PidMode),
CgroupParent: createArtifact.CgroupParent,
ShmSize: createArtifact.Resources.ShmSize,
@@ -312,7 +312,7 @@ type HostConfig struct {
Isolation string `json:"Isolation"` //TODO
CPUShares *uint64 `json:"CPUSShares"`
Memory int64 `json:"Memory"`
- NanoCpus int `json:"NanoCpus"` //check type, TODO
+ NanoCPUs int `json:"NanoCPUs"` //check type, TODO
CgroupParent string `json:"CgroupParent"`
BlkioWeight *uint16 `json:"BlkioWeight"`
BlkioWeightDevice []specs.LinuxWeightDevice `json:"BlkioWeightDevice"`
@@ -324,7 +324,7 @@ type HostConfig struct {
CPUQuota *int64 `json:"CPUQuota"`
CPURealtimePeriod *uint64 `json:"CPURealtimePeriod"`
CPURealtimeRuntime *int64 `json:"CPURealtimeRuntime"`
- CPUSetCpus string `json:"CPUSetCpus"`
+ CPUSetCPUs string `json:"CPUSetCPUs"`
CPUSetMems string `json:"CPUSetMems"`
Devices []specs.LinuxDevice `json:"Devices"`
DiskQuota int `json:"DiskQuota"` //check type, TODO
diff --git a/cmd/kpod/ps.go b/cmd/kpod/ps.go
index 89fed991f..6b807671e 100644
--- a/cmd/kpod/ps.go
+++ b/cmd/kpod/ps.go
@@ -557,17 +557,6 @@ func getStrFromSquareBrackets(cmd string) string {
return strings.Join(arr, ",")
}
-// getImageName shortens the image name
-func getImageName(img string) string {
- arr := strings.Split(img, "/")
- if arr[0] == "docker.io" && arr[1] == "library" {
- img = strings.Join(arr[2:], "/")
- } else if arr[0] == "docker.io" {
- img = strings.Join(arr[1:], "/")
- }
- return img
-}
-
// getLabels converts the labels to a string of the form "key=value, key2=value2"
func formatLabels(labels map[string]string) string {
var arr []string
@@ -581,6 +570,7 @@ func formatLabels(labels map[string]string) string {
return ""
}
+/*
// getMounts converts the volumes mounted to a string of the form "mount1, mount2"
// it truncates it if noTrunc is false
func getMounts(mounts []specs.Mount, noTrunc bool) string {
@@ -602,7 +592,6 @@ func getMounts(mounts []specs.Mount, noTrunc bool) string {
}
return strings.Join(arr, ",")
}
-
// getPorts converts the ports used to a string of the from "port1, port2"
func getPorts(ports map[string]struct{}) string {
var arr []string
@@ -614,71 +603,4 @@ func getPorts(ports map[string]struct{}) string {
}
return strings.Join(arr, ",")
}
-
-// FilterParamsPS contains the filter options for ps
-type FilterParamsPS struct {
- id string
- label string
- name string
- exited int32
- status string
- ancestor string
- before time.Time
- since time.Time
- volume string
-}
-
-// parseFilter takes a filter string and a list of containers and filters it
-func parseFilter(filter string, containers []*libpod.Container) (*FilterParamsPS, error) {
- params := new(FilterParamsPS)
- allFilters := strings.Split(filter, ",")
-
- for _, param := range allFilters {
- pair := strings.SplitN(param, "=", 2)
- switch strings.TrimSpace(pair[0]) {
- case "id":
- params.id = pair[1]
- case "label":
- params.label = pair[1]
- case "name":
- params.name = pair[1]
- case "exited":
- exitedCode, err := strconv.ParseInt(pair[1], 10, 32)
- if err != nil {
- return nil, errors.Errorf("exited code out of range %q", pair[1])
- }
- params.exited = int32(exitedCode)
- case "status":
- params.status = pair[1]
- case "ancestor":
- params.ancestor = pair[1]
- case "before":
- if ctr, err := findContainer(containers, pair[1]); err == nil {
- params.before = ctr.Config().CreatedTime
- } else {
- return nil, errors.Wrapf(err, "no such container %q", pair[1])
- }
- case "since":
- if ctr, err := findContainer(containers, pair[1]); err == nil {
- params.before = ctr.Config().CreatedTime
- } else {
- return nil, errors.Wrapf(err, "no such container %q", pair[1])
- }
- case "volume":
- params.volume = pair[1]
- default:
- return nil, errors.Errorf("invalid filter %q", pair[0])
- }
- }
- return params, nil
-}
-
-// findContainer finds a container with a specific name or id from a list of containers
-func findContainer(containers []*libpod.Container, ref string) (*libpod.Container, error) {
- for _, ctr := range containers {
- if strings.HasPrefix(ctr.ID(), ref) || ctr.Name() == ref {
- return ctr, nil
- }
- }
- return nil, errors.Errorf("could not find container")
-}
+*/
diff --git a/cmd/kpod/spec.go b/cmd/kpod/spec.go
index 29ed8d40f..adfdf7347 100644
--- a/cmd/kpod/spec.go
+++ b/cmd/kpod/spec.go
@@ -211,26 +211,26 @@ func createConfigToOCISpec(config *createConfig) (*spec.Spec, error) {
// RESOURCES - CPU
- if config.Resources.CpuShares != 0 {
- g.SetLinuxResourcesCPUShares(config.Resources.CpuShares)
+ if config.Resources.CPUShares != 0 {
+ g.SetLinuxResourcesCPUShares(config.Resources.CPUShares)
}
- if config.Resources.CpuQuota != 0 {
- g.SetLinuxResourcesCPUQuota(config.Resources.CpuQuota)
+ if config.Resources.CPUQuota != 0 {
+ g.SetLinuxResourcesCPUQuota(config.Resources.CPUQuota)
}
- if config.Resources.CpuPeriod != 0 {
- g.SetLinuxResourcesCPUPeriod(config.Resources.CpuPeriod)
+ if config.Resources.CPUPeriod != 0 {
+ g.SetLinuxResourcesCPUPeriod(config.Resources.CPUPeriod)
}
- if config.Resources.CpuRtRuntime != 0 {
- g.SetLinuxResourcesCPURealtimeRuntime(config.Resources.CpuRtRuntime)
+ if config.Resources.CPURtRuntime != 0 {
+ g.SetLinuxResourcesCPURealtimeRuntime(config.Resources.CPURtRuntime)
}
- if config.Resources.CpuRtPeriod != 0 {
- g.SetLinuxResourcesCPURealtimePeriod(config.Resources.CpuRtPeriod)
+ if config.Resources.CPURtPeriod != 0 {
+ g.SetLinuxResourcesCPURealtimePeriod(config.Resources.CPURtPeriod)
}
- if config.Resources.Cpus != "" {
- g.SetLinuxResourcesCPUCpus(config.Resources.Cpus)
+ if config.Resources.CPUs != "" {
+ g.SetLinuxResourcesCPUCpus(config.Resources.CPUs)
}
- if config.Resources.CpusetMems != "" {
- g.SetLinuxResourcesCPUMems(config.Resources.CpusetMems)
+ if config.Resources.CPUsetMems != "" {
+ g.SetLinuxResourcesCPUMems(config.Resources.CPUsetMems)
}
// SECURITY OPTS
diff --git a/cmd/kpod/top.go b/cmd/kpod/top.go
index 9c2fcd34e..0c1eabbdb 100644
--- a/cmd/kpod/top.go
+++ b/cmd/kpod/top.go
@@ -164,8 +164,8 @@ func psDataToPSParams(data []string, headers []string) ([]PSParams, error) {
//PSParams is a list of options that the command line ps recognizes
type PSParams struct {
- CPU string `json: "%CPU"`
- MEM string `json: "%MEM"`
+ CPU string
+ MEM string
COMMAND string
BLOCKED string
START string