Fixup issues found by golint

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
This commit is contained in:
Daniel J Walsh
2020-06-09 16:47:30 -04:00
parent fbe09d78e9
commit 4bb43b898d
56 changed files with 100 additions and 105 deletions

View File

@ -7,6 +7,7 @@ run:
- contrib - contrib
- dependencies - dependencies
- test - test
- pkg/spec
- pkg/varlink - pkg/varlink
- pkg/varlinkapi - pkg/varlinkapi
skip-files: skip-files:
@ -21,7 +22,6 @@ linters:
- gochecknoinits - gochecknoinits
- goconst - goconst
- gocyclo - gocyclo
- golint
- gosec - gosec
- lll - lll
- maligned - maligned

View File

@ -16,5 +16,5 @@ var (
// DefaultImageVolume default value // DefaultImageVolume default value
DefaultImageVolume = "bind" DefaultImageVolume = "bind"
// Pull in configured json library // Pull in configured json library
json = registry.JsonLibrary() json = registry.JSONLibrary()
) )

View File

@ -669,7 +669,7 @@ func makeHealthCheckFromCli(inCmd, interval string, retries uint, timeout, start
hc.Interval = intervalDuration hc.Interval = intervalDuration
if retries < 1 { if retries < 1 {
return nil, errors.New("healthcheck-retries must be greater than 0.") return nil, errors.New("healthcheck-retries must be greater than 0")
} }
hc.Retries = int(retries) hc.Retries = int(retries)
timeoutDuration, err := time.ParseDuration(timeout) timeoutDuration, err := time.ParseDuration(timeout)

View File

@ -10,7 +10,7 @@ import (
var ( var (
// Pull in configured json library // Pull in configured json library
json = registry.JsonLibrary() json = registry.JSONLibrary()
// Command: podman _container_ // Command: podman _container_
containerCmd = &cobra.Command{ containerCmd = &cobra.Command{

View File

@ -87,13 +87,13 @@ func init() {
func checkStatOptions(cmd *cobra.Command, args []string) error { func checkStatOptions(cmd *cobra.Command, args []string) error {
opts := 0 opts := 0
if statsOptions.All { if statsOptions.All {
opts += 1 opts++
} }
if statsOptions.Latest { if statsOptions.Latest {
opts += 1 opts++
} }
if len(args) > 0 { if len(args) > 0 {
opts += 1 opts++
} }
if opts > 1 { if opts > 1 {
return errors.Errorf("--all, --latest and containers cannot be used together") return errors.Errorf("--all, --latest and containers cannot be used together")

View File

@ -9,7 +9,7 @@ import (
var ( var (
// Pull in configured json library // Pull in configured json library
json = registry.JsonLibrary() json = registry.JSONLibrary()
// Command: podman _image_ // Command: podman _image_
imageCmd = &cobra.Command{ imageCmd = &cobra.Command{

View File

@ -100,7 +100,7 @@ func images(cmd *cobra.Command, args []string) error {
switch { switch {
case listFlag.quiet: case listFlag.quiet:
return writeId(summaries) return writeID(summaries)
case cmd.Flag("format").Changed && listFlag.format == "json": case cmd.Flag("format").Changed && listFlag.format == "json":
return writeJSON(summaries) return writeJSON(summaries)
default: default:
@ -108,7 +108,7 @@ func images(cmd *cobra.Command, args []string) error {
} }
} }
func writeId(imageS []*entities.ImageSummary) error { func writeID(imageS []*entities.ImageSummary) error {
var ids = map[string]struct{}{} var ids = map[string]struct{}{}
for _, e := range imageS { for _, e := range imageS {
i := "sha256:" + e.ID i := "sha256:" + e.ID

View File

@ -33,8 +33,8 @@ var (
var ( var (
networkListOptions entities.NetworkListOptions networkListOptions entities.NetworkListOptions
headers string = "NAME\tVERSION\tPLUGINS\n" headers = "NAME\tVERSION\tPLUGINS\n"
defaultListRow string = "{{.Name}}\t{{.Version}}\t{{.Plugins}}\n" defaultListRow = "{{.Name}}\t{{.Version}}\t{{.Plugins}}\n"
) )
func networkListFlags(flags *pflag.FlagSet) { func networkListFlags(flags *pflag.FlagSet) {
@ -57,7 +57,7 @@ func init() {
func networkList(cmd *cobra.Command, args []string) error { func networkList(cmd *cobra.Command, args []string) error {
var ( var (
nlprs []NetworkListPrintReports nlprs []ListPrintReports
) )
// validate the filter pattern. // validate the filter pattern.
@ -83,7 +83,7 @@ func networkList(cmd *cobra.Command, args []string) error {
} }
for _, r := range responses { for _, r := range responses {
nlprs = append(nlprs, NetworkListPrintReports{r}) nlprs = append(nlprs, ListPrintReports{r})
} }
row := networkListOptions.Format row := networkListOptions.Format
@ -125,14 +125,14 @@ func jsonOut(responses []*entities.NetworkListReport) error {
return nil return nil
} }
type NetworkListPrintReports struct { type ListPrintReports struct {
*entities.NetworkListReport *entities.NetworkListReport
} }
func (n NetworkListPrintReports) Version() string { func (n ListPrintReports) Version() string {
return n.CNIVersion return n.CNIVersion
} }
func (n NetworkListPrintReports) Plugins() string { func (n ListPrintReports) Plugins() string {
return network.GetCNIPlugins(n.NetworkConfigList) return network.GetCNIPlugins(n.NetworkConfigList)
} }

View File

@ -10,7 +10,7 @@ import (
var ( var (
// Pull in configured json library // Pull in configured json library
json = registry.JsonLibrary() json = registry.JSONLibrary()
// Command: podman _pod_ // Command: podman _pod_
podCmd = &cobra.Command{ podCmd = &cobra.Command{

View File

@ -71,7 +71,7 @@ func stats(cmd *cobra.Command, args []string) error {
} }
format := statsOptions.Format format := statsOptions.Format
doJson := strings.ToLower(format) == formats.JSONString doJSON := strings.ToLower(format) == formats.JSONString
header := getPodStatsHeader(format) header := getPodStatsHeader(format)
for { for {
@ -80,7 +80,7 @@ func stats(cmd *cobra.Command, args []string) error {
return err return err
} }
// Print the stats in the requested format and configuration. // Print the stats in the requested format and configuration.
if doJson { if doJSON {
if err := printJSONPodStats(reports); err != nil { if err := printJSONPodStats(reports); err != nil {
return err return err
} }

View File

@ -11,8 +11,8 @@ var (
jsonSync sync.Once jsonSync sync.Once
) )
// JsonLibrary provides a "encoding/json" compatible API // JSONLibrary provides a "encoding/json" compatible API
func JsonLibrary() jsoniter.API { func JSONLibrary() jsoniter.API {
jsonSync.Do(func() { jsonSync.Do(func() {
json = jsoniter.ConfigCompatibleWithStandardLibrary json = jsoniter.ConfigCompatibleWithStandardLibrary
}) })

View File

@ -3,4 +3,4 @@ package report
import "github.com/containers/libpod/cmd/podman/registry" import "github.com/containers/libpod/cmd/podman/registry"
// Pull in configured json library // Pull in configured json library
var json = registry.JsonLibrary() var json = registry.JSONLibrary()

View File

@ -119,10 +119,10 @@ func persistentPreRunE(cmd *cobra.Command, args []string) error {
} }
if cmd.Flag("cpu-profile").Changed { if cmd.Flag("cpu-profile").Changed {
f, err := os.Create(cfg.CpuProfile) f, err := os.Create(cfg.CPUProfile)
if err != nil { if err != nil {
return errors.Wrapf(err, "unable to create cpu profiling file %s", return errors.Wrapf(err, "unable to create cpu profiling file %s",
cfg.CpuProfile) cfg.CPUProfile)
} }
if err := pprof.StartCPUProfile(f); err != nil { if err := pprof.StartCPUProfile(f); err != nil {
return err return err
@ -212,13 +212,13 @@ func rootFlags(opts *entities.PodmanConfig, flags *pflag.FlagSet) {
// V2 flags // V2 flags
flags.BoolVarP(&opts.Remote, "remote", "r", false, "Access remote Podman service (default false)") flags.BoolVarP(&opts.Remote, "remote", "r", false, "Access remote Podman service (default false)")
// TODO Read uri from containers.config when available // TODO Read uri from containers.config when available
flags.StringVar(&opts.Uri, "url", registry.DefaultAPIAddress(), "URL to access Podman service (CONTAINER_HOST)") flags.StringVar(&opts.URI, "url", registry.DefaultAPIAddress(), "URL to access Podman service (CONTAINER_HOST)")
flags.StringSliceVar(&opts.Identities, "identity", []string{}, "path to SSH identity file, (CONTAINER_SSHKEY)") flags.StringSliceVar(&opts.Identities, "identity", []string{}, "path to SSH identity file, (CONTAINER_SSHKEY)")
flags.StringVar(&opts.PassPhrase, "passphrase", "", "passphrase for identity file (not secure, CONTAINER_PASSPHRASE), ssh-agent always supported") flags.StringVar(&opts.PassPhrase, "passphrase", "", "passphrase for identity file (not secure, CONTAINER_PASSPHRASE), ssh-agent always supported")
cfg := opts.Config cfg := opts.Config
flags.StringVar(&cfg.Engine.CgroupManager, "cgroup-manager", cfg.Engine.CgroupManager, "Cgroup manager to use (\"cgroupfs\"|\"systemd\")") flags.StringVar(&cfg.Engine.CgroupManager, "cgroup-manager", cfg.Engine.CgroupManager, "Cgroup manager to use (\"cgroupfs\"|\"systemd\")")
flags.StringVar(&opts.CpuProfile, "cpu-profile", "", "Path for the cpu profiling results") flags.StringVar(&opts.CPUProfile, "cpu-profile", "", "Path for the cpu profiling results")
flags.StringVar(&opts.ConmonPath, "conmon", "", "Path of the conmon binary") flags.StringVar(&opts.ConmonPath, "conmon", "", "Path of the conmon binary")
flags.StringVar(&cfg.Engine.NetworkCmdPath, "network-cmd-path", cfg.Engine.NetworkCmdPath, "Path to the command for configuring the network") flags.StringVar(&cfg.Engine.NetworkCmdPath, "network-cmd-path", cfg.Engine.NetworkCmdPath, "Path to the command for configuring the network")
flags.StringVar(&cfg.Network.NetworkConfigDir, "cni-config-dir", cfg.Network.NetworkConfigDir, "Path of the configuration directory for CNI networks") flags.StringVar(&cfg.Network.NetworkConfigDir, "cni-config-dir", cfg.Network.NetworkConfigDir, "Path of the configuration directory for CNI networks")

View File

@ -63,7 +63,7 @@ func printSummary(reports *entities.SystemDfReport, userFormat string) error {
dfSummaries []*dfSummary dfSummaries []*dfSummary
active int active int
size, reclaimable int64 size, reclaimable int64
format string = "{{.Type}}\t{{.Total}}\t{{.Active}}\t{{.Size}}\t{{.Reclaimable}}\n" format = "{{.Type}}\t{{.Total}}\t{{.Active}}\t{{.Size}}\t{{.Reclaimable}}\n"
w io.Writer = os.Stdout w io.Writer = os.Stdout
) )
@ -74,7 +74,7 @@ func printSummary(reports *entities.SystemDfReport, userFormat string) error {
for _, i := range reports.Images { for _, i := range reports.Images {
if i.Containers > 0 { if i.Containers > 0 {
active += 1 active++
} }
size += i.Size size += i.Size
if i.Containers < 1 { if i.Containers < 1 {
@ -99,7 +99,7 @@ func printSummary(reports *entities.SystemDfReport, userFormat string) error {
) )
for _, c := range reports.Containers { for _, c := range reports.Containers {
if c.Status == "running" { if c.Status == "running" {
conActive += 1 conActive++
} else { } else {
conReclaimable += c.RWSize conReclaimable += c.RWSize
} }

View File

@ -64,7 +64,7 @@ func aliasTimeoutFlag(_ *pflag.FlagSet, name string) pflag.NormalizedName {
} }
func service(cmd *cobra.Command, args []string) error { func service(cmd *cobra.Command, args []string) error {
apiURI, err := resolveApiURI(args) apiURI, err := resolveAPIURI(args)
if err != nil { if err != nil {
return err return err
} }
@ -103,7 +103,7 @@ func service(cmd *cobra.Command, args []string) error {
return restService(opts, cmd.Flags(), registry.PodmanConfig()) return restService(opts, cmd.Flags(), registry.PodmanConfig())
} }
func resolveApiURI(_url []string) (string, error) { func resolveAPIURI(_url []string) (string, error) {
// When determining _*THE*_ listening endpoint -- // When determining _*THE*_ listening endpoint --
// 1) User input wins always // 1) User input wins always
// 2) systemd socket activation // 2) systemd socket activation

View File

@ -9,7 +9,7 @@ import (
var ( var (
// Pull in configured json library // Pull in configured json library
json = registry.JsonLibrary() json = registry.JSONLibrary()
// Command: podman _system_ // Command: podman _system_
systemCmd = &cobra.Command{ systemCmd = &cobra.Command{

View File

@ -9,7 +9,7 @@ import (
var ( var (
// Pull in configured json library // Pull in configured json library
json = registry.JsonLibrary() json = registry.JSONLibrary()
// Command: podman _volume_ // Command: podman _volume_
volumeCmd = &cobra.Command{ volumeCmd = &cobra.Command{

View File

@ -57,13 +57,13 @@ func GeneratePodFilterFunc(filter, filterValue string) (
return nil, errors.Errorf("%s is not a valid status", filterValue) return nil, errors.Errorf("%s is not a valid status", filterValue)
} }
return func(p *libpod.Pod) bool { return func(p *libpod.Pod) bool {
ctr_statuses, err := p.Status() ctrStatuses, err := p.Status()
if err != nil { if err != nil {
return false return false
} }
for _, ctr_status := range ctr_statuses { for _, ctrStatus := range ctrStatuses {
state := ctr_status.String() state := ctrStatus.String()
if ctr_status == define.ContainerStateConfigured { if ctrStatus == define.ContainerStateConfigured {
state = "created" state = "created"
} }
if state == filterValue { if state == filterValue {

View File

@ -102,8 +102,8 @@ func ReferenceFilter(ctx context.Context, referenceFilter string) ResultFilter {
} }
} }
// IdFilter allows you to filter by image Id // IDFilter allows you to filter by image Id
func IdFilter(idFilter string) ResultFilter { func IDFilter(idFilter string) ResultFilter {
return func(i *Image) bool { return func(i *Image) bool {
return i.ID() == idFilter return i.ID() == idFilter
} }
@ -172,7 +172,7 @@ func (ir *Runtime) createFilterFuncs(filters []string, img *Image) ([]ResultFilt
case "reference": case "reference":
filterFuncs = append(filterFuncs, ReferenceFilter(ctx, splitFilter[1])) filterFuncs = append(filterFuncs, ReferenceFilter(ctx, splitFilter[1]))
case "id": case "id":
filterFuncs = append(filterFuncs, IdFilter(splitFilter[1])) filterFuncs = append(filterFuncs, IDFilter(splitFilter[1]))
default: default:
return nil, errors.Errorf("invalid filter %s ", splitFilter[0]) return nil, errors.Errorf("invalid filter %s ", splitFilter[0])
} }

View File

@ -177,7 +177,7 @@ func getContainersState(r *libpod.Runtime) map[define.ContainerStatus]int {
if err != nil { if err != nil {
continue continue
} }
states[state] += 1 states[state]++
} }
} }
return states return states

View File

@ -20,10 +20,6 @@ import (
"github.com/pkg/errors" "github.com/pkg/errors"
) )
type CompatInspectNetwork struct {
types.NetworkResource
}
func InspectNetwork(w http.ResponseWriter, r *http.Request) { func InspectNetwork(w http.ResponseWriter, r *http.Request) {
runtime := r.Context().Value("runtime").(*libpod.Runtime) runtime := r.Context().Value("runtime").(*libpod.Runtime)

View File

@ -31,11 +31,11 @@ func PodCreate(w http.ResponseWriter, r *http.Request) {
} }
pod, err := generate.MakePod(&psg, runtime) pod, err := generate.MakePod(&psg, runtime)
if err != nil { if err != nil {
http_code := http.StatusInternalServerError httpCode := http.StatusInternalServerError
if errors.Cause(err) == define.ErrPodExists { if errors.Cause(err) == define.ErrPodExists {
http_code = http.StatusConflict httpCode = http.StatusConflict
} }
utils.Error(w, "Something went wrong.", http_code, err) utils.Error(w, "Something went wrong.", httpCode, err)
return return
} }
utils.WriteResponse(w, http.StatusCreated, handlers.IDResponse{ID: pod.ID()}) utils.WriteResponse(w, http.StatusCreated, handlers.IDResponse{ID: pod.ID()})

View File

@ -46,7 +46,7 @@ func CreateVolume(w http.ResponseWriter, r *http.Request) {
volumeOptions = append(volumeOptions, libpod.WithVolumeLabels(input.Label)) volumeOptions = append(volumeOptions, libpod.WithVolumeLabels(input.Label))
} }
if len(input.Options) > 0 { if len(input.Options) > 0 {
parsedOptions, err := parse.ParseVolumeOptions(input.Options) parsedOptions, err := parse.VolumeOptions(input.Options)
if err != nil { if err != nil {
utils.InternalServerError(w, err) utils.InternalServerError(w, err)
return return

View File

@ -62,7 +62,7 @@ func WaitContainer(w http.ResponseWriter, r *http.Request) (int32, error) {
func CreateContainer(ctx context.Context, w http.ResponseWriter, runtime *libpod.Runtime, cc *createconfig.CreateConfig) { func CreateContainer(ctx context.Context, w http.ResponseWriter, runtime *libpod.Runtime, cc *createconfig.CreateConfig) {
var pod *libpod.Pod var pod *libpod.Pod
ctr, err := createconfig.CreateContainerFromCreateConfig(runtime, cc, ctx, pod) ctr, err := createconfig.CreateContainerFromCreateConfig(ctx, runtime, cc, pod)
if err != nil { if err != nil {
Error(w, "Something went wrong.", http.StatusInternalServerError, errors.Wrap(err, "CreateContainerFromCreateConfig()")) Error(w, "Something went wrong.", http.StatusInternalServerError, errors.Wrap(err, "CreateContainerFromCreateConfig()"))
return return

View File

@ -34,9 +34,9 @@ func (s *APIServer) APIHandler(h http.HandlerFunc) http.HandlerFunc {
} }
// TODO: Use r.ConnContext when ported to go 1.13 // TODO: Use r.ConnContext when ported to go 1.13
c := context.WithValue(r.Context(), "decoder", s.Decoder) c := context.WithValue(r.Context(), "decoder", s.Decoder) //nolint
c = context.WithValue(c, "runtime", s.Runtime) c = context.WithValue(c, "runtime", s.Runtime) //nolint
c = context.WithValue(c, "shutdownFunc", s.Shutdown) c = context.WithValue(c, "shutdownFunc", s.Shutdown) //nolint
r = r.WithContext(c) r = r.WithContext(c)
h(w, r) h(w, r)

View File

@ -257,7 +257,7 @@ func (t *IdleTracker) ConnState(conn net.Conn, state http.ConnState) {
if oldActive == 0 { if oldActive == 0 {
t.timer.Stop() t.timer.Stop()
} }
t.total += 1 t.total++
case http.StateIdle, http.StateClosed: case http.StateIdle, http.StateClosed:
delete(t.active, conn) delete(t.active, conn)
// Restart the timer if we've become idle // Restart the timer if we've become idle

View File

@ -5,7 +5,6 @@
// This package exposes a series of methods that allow users to firstly // This package exposes a series of methods that allow users to firstly
// create their connection with the API endpoints. Once the connection // create their connection with the API endpoints. Once the connection
// is established, users can then manage the Podman container runtime. // is established, users can then manage the Podman container runtime.
package bindings package bindings
import ( import (
@ -28,7 +27,7 @@ var (
pFalse = false pFalse = false
PFalse = &pFalse PFalse = &pFalse
// _*YES*- podman will fail to run if this value is wrong // APIVersion - podman will fail to run if this value is wrong
APIVersion = semver.MustParse("1.0.0") APIVersion = semver.MustParse("1.0.0")
) )

View File

@ -41,7 +41,7 @@ type APIResponse struct {
} }
type Connection struct { type Connection struct {
Uri *url.URL URI *url.URL
Client *http.Client Client *http.Client
} }
@ -137,7 +137,7 @@ func NewConnectionWithIdentity(ctx context.Context, uri string, passPhrase strin
func tcpClient(_url *url.URL) (Connection, error) { func tcpClient(_url *url.URL) (Connection, error) {
connection := Connection{ connection := Connection{
Uri: _url, URI: _url,
} }
connection.Client = &http.Client{ connection.Client = &http.Client{
Transport: &http.Transport{ Transport: &http.Transport{
@ -246,7 +246,7 @@ func sshClient(_url *url.URL, secure bool, passPhrase string, identities ...stri
return Connection{}, errors.Wrapf(err, "Connection to bastion host (%s) failed.", _url.String()) return Connection{}, errors.Wrapf(err, "Connection to bastion host (%s) failed.", _url.String())
} }
connection := Connection{Uri: _url} connection := Connection{URI: _url}
connection.Client = &http.Client{ connection.Client = &http.Client{
Transport: &http.Transport{ Transport: &http.Transport{
DialContext: func(ctx context.Context, _, _ string) (net.Conn, error) { DialContext: func(ctx context.Context, _, _ string) (net.Conn, error) {
@ -257,7 +257,7 @@ func sshClient(_url *url.URL, secure bool, passPhrase string, identities ...stri
} }
func unixClient(_url *url.URL) (Connection, error) { func unixClient(_url *url.URL) (Connection, error) {
connection := Connection{Uri: _url} connection := Connection{URI: _url}
connection.Client = &http.Client{ connection.Client = &http.Client{
Transport: &http.Transport{ Transport: &http.Transport{
DialContext: func(ctx context.Context, _, _ string) (net.Conn, error) { DialContext: func(ctx context.Context, _, _ string) (net.Conn, error) {

View File

@ -10,7 +10,7 @@ import (
"github.com/containers/libpod/pkg/domain/entities" "github.com/containers/libpod/pkg/domain/entities"
) )
func GenerateKube(ctx context.Context, nameOrID string, options entities.GenerateKubeOptions) (*entities.GenerateKubeReport, error) { func Kube(ctx context.Context, nameOrID string, options entities.GenerateKubeOptions) (*entities.GenerateKubeReport, error) {
conn, err := bindings.GetClient(ctx) conn, err := bindings.GetClient(ctx)
if err != nil { if err != nil {
return nil, err return nil, err

View File

@ -13,7 +13,7 @@ import (
"github.com/containers/libpod/pkg/domain/entities" "github.com/containers/libpod/pkg/domain/entities"
) )
func PlayKube(ctx context.Context, path string, options entities.PlayKubeOptions) (*entities.PlayKubeReport, error) { func Kube(ctx context.Context, path string, options entities.PlayKubeOptions) (*entities.PlayKubeReport, error) {
var report entities.PlayKubeReport var report entities.PlayKubeReport
conn, err := bindings.GetClient(ctx) conn, err := bindings.GetClient(ctx)
if err != nil { if err != nil {

View File

@ -39,7 +39,7 @@ type PodmanConfig struct {
CGroupUsage string // rootless code determines Usage message CGroupUsage string // rootless code determines Usage message
ConmonPath string // --conmon flag will set Engine.ConmonPath ConmonPath string // --conmon flag will set Engine.ConmonPath
CpuProfile string // Hidden: Should CPU profile be taken CPUProfile string // Hidden: Should CPU profile be taken
EngineMode EngineMode // ABI or Tunneling mode EngineMode EngineMode // ABI or Tunneling mode
Identities []string // ssh identities for connecting to server Identities []string // ssh identities for connecting to server
MaxWorks int // maximum number of parallel threads MaxWorks int // maximum number of parallel threads
@ -52,7 +52,7 @@ type PodmanConfig struct {
SpanCtx context.Context // context to use when tracing SpanCtx context.Context // context to use when tracing
Syslog bool // write to StdOut and Syslog, not supported when tunneling Syslog bool // write to StdOut and Syslog, not supported when tunneling
Trace bool // Hidden: Trace execution Trace bool // Hidden: Trace execution
Uri string // URI to RESTful API Service URI string // URI to RESTful API Service
Runroot string Runroot string
StorageDriver string StorageDriver string

View File

@ -299,7 +299,7 @@ type ShowTrustReport struct {
Raw []byte Raw []byte
SystemRegistriesDirPath string SystemRegistriesDirPath string
JSONOutput []byte JSONOutput []byte
Policies []*trust.TrustPolicy Policies []*trust.Policy
} }
// SetTrustOptions describes the CLI options for setting trust // SetTrustOptions describes the CLI options for setting trust

View File

@ -162,7 +162,7 @@ func (ic *ContainerEngine) ContainerStop(ctx context.Context, namesOrIds []strin
if err != nil && !(options.Ignore && errors.Cause(err) == define.ErrNoSuchCtr) { if err != nil && !(options.Ignore && errors.Cause(err) == define.ErrNoSuchCtr) {
return nil, err return nil, err
} }
errMap, err := parallel.ParallelContainerOp(ctx, ctrs, func(c *libpod.Container) error { errMap, err := parallel.ContainerOp(ctx, ctrs, func(c *libpod.Container) error {
var err error var err error
if options.Timeout != nil { if options.Timeout != nil {
err = c.StopWithTimeout(*options.Timeout) err = c.StopWithTimeout(*options.Timeout)
@ -323,7 +323,7 @@ func (ic *ContainerEngine) ContainerRm(ctx context.Context, namesOrIds []string,
return reports, nil return reports, nil
} }
errMap, err := parallel.ParallelContainerOp(ctx, ctrs, func(c *libpod.Container) error { errMap, err := parallel.ContainerOp(ctx, ctrs, func(c *libpod.Container) error {
err := ic.Libpod.RemoveContainer(ctx, c, options.Force, options.Volumes) err := ic.Libpod.RemoveContainer(ctx, c, options.Force, options.Volumes)
if err != nil { if err != nil {
if options.Ignore && errors.Cause(err) == define.ErrNoSuchCtr { if options.Ignore && errors.Cause(err) == define.ErrNoSuchCtr {

View File

@ -12,7 +12,7 @@ import (
// Handle volume options from CLI. // Handle volume options from CLI.
// Parse "o" option to find UID, GID. // Parse "o" option to find UID, GID.
func ParseVolumeOptions(opts map[string]string) ([]libpod.VolumeCreateOption, error) { func VolumeOptions(opts map[string]string) ([]libpod.VolumeCreateOption, error) {
libpodOptions := []libpod.VolumeCreateOption{} libpodOptions := []libpod.VolumeCreateOption{}
volumeOptions := make(map[string]string) volumeOptions := make(map[string]string)

View File

@ -243,7 +243,7 @@ func (ic *ContainerEngine) PlayKube(ctx context.Context, path string, options en
if err != nil { if err != nil {
return nil, err return nil, err
} }
ctr, err := createconfig.CreateContainerFromCreateConfig(ic.Libpod, conf, ctx, pod) ctr, err := createconfig.CreateContainerFromCreateConfig(ctx, ic.Libpod, conf, pod)
if err != nil { if err != nil {
return nil, err return nil, err
} }

View File

@ -338,7 +338,7 @@ func (ic *ContainerEngine) SystemDf(ctx context.Context, options entities.System
} }
for _, viu := range inUse { for _, viu := range inUse {
if util.StringInSlice(viu, runningContainers) { if util.StringInSlice(viu, runningContainers) {
consInUse += 1 consInUse++
} }
} }
report := entities.SystemDfVolumeReport{ report := entities.SystemDfVolumeReport{
@ -376,12 +376,12 @@ func (se *SystemEngine) Renumber(ctx context.Context, flags *pflag.FlagSet, conf
return nil return nil
} }
func (s SystemEngine) Migrate(ctx context.Context, flags *pflag.FlagSet, config *entities.PodmanConfig, options entities.SystemMigrateOptions) error { func (se SystemEngine) Migrate(ctx context.Context, flags *pflag.FlagSet, config *entities.PodmanConfig, options entities.SystemMigrateOptions) error {
return nil return nil
} }
func (s SystemEngine) Shutdown(ctx context.Context) { func (se SystemEngine) Shutdown(ctx context.Context) {
if err := s.Libpod.Shutdown(false); err != nil { if err := se.Libpod.Shutdown(false); err != nil {
logrus.Error(err) logrus.Error(err)
} }
} }

View File

@ -112,8 +112,8 @@ func (ir *ImageEngine) SetTrust(ctx context.Context, args []string, options enti
return ioutil.WriteFile(policyPath, data, 0644) return ioutil.WriteFile(policyPath, data, 0644)
} }
func getPolicyShowOutput(policyContentStruct trust.PolicyContent, systemRegistriesDirPath string) ([]*trust.TrustPolicy, error) { func getPolicyShowOutput(policyContentStruct trust.PolicyContent, systemRegistriesDirPath string) ([]*trust.Policy, error) {
var output []*trust.TrustPolicy var output []*trust.Policy
registryConfigs, err := trust.LoadAndMergeConfig(systemRegistriesDirPath) registryConfigs, err := trust.LoadAndMergeConfig(systemRegistriesDirPath)
if err != nil { if err != nil {
@ -121,7 +121,7 @@ func getPolicyShowOutput(policyContentStruct trust.PolicyContent, systemRegistri
} }
if len(policyContentStruct.Default) > 0 { if len(policyContentStruct.Default) > 0 {
defaultPolicyStruct := trust.TrustPolicy{ defaultPolicyStruct := trust.Policy{
Name: "* (default)", Name: "* (default)",
RepoName: "default", RepoName: "default",
Type: trustTypeDescription(policyContentStruct.Default[0].Type), Type: trustTypeDescription(policyContentStruct.Default[0].Type),
@ -130,7 +130,7 @@ func getPolicyShowOutput(policyContentStruct trust.PolicyContent, systemRegistri
} }
for _, transval := range policyContentStruct.Transports { for _, transval := range policyContentStruct.Transports {
for repo, repoval := range transval { for repo, repoval := range transval {
tempTrustShowOutput := trust.TrustPolicy{ tempTrustShowOutput := trust.Policy{
Name: repo, Name: repo,
RepoName: repo, RepoName: repo,
Type: repoval[0].Type, Type: repoval[0].Type,

View File

@ -24,7 +24,7 @@ func (ic *ContainerEngine) VolumeCreate(ctx context.Context, opts entities.Volum
volumeOptions = append(volumeOptions, libpod.WithVolumeLabels(opts.Label)) volumeOptions = append(volumeOptions, libpod.WithVolumeLabels(opts.Label))
} }
if len(opts.Options) > 0 { if len(opts.Options) > 0 {
parsedOptions, err := parse.ParseVolumeOptions(opts.Options) parsedOptions, err := parse.VolumeOptions(opts.Options)
if err != nil { if err != nil {
return nil, err return nil, err
} }

View File

@ -20,7 +20,7 @@ func NewContainerEngine(facts *entities.PodmanConfig) (entities.ContainerEngine,
r, err := NewLibpodRuntime(facts.FlagSet, facts) r, err := NewLibpodRuntime(facts.FlagSet, facts)
return r, err return r, err
case entities.TunnelMode: case entities.TunnelMode:
ctx, err := bindings.NewConnectionWithIdentity(context.Background(), facts.Uri, facts.PassPhrase, facts.Identities...) ctx, err := bindings.NewConnectionWithIdentity(context.Background(), facts.URI, facts.PassPhrase, facts.Identities...)
return &tunnel.ContainerEngine{ClientCxt: ctx}, err return &tunnel.ContainerEngine{ClientCxt: ctx}, err
} }
return nil, fmt.Errorf("runtime mode '%v' is not supported", facts.EngineMode) return nil, fmt.Errorf("runtime mode '%v' is not supported", facts.EngineMode)
@ -33,7 +33,7 @@ func NewImageEngine(facts *entities.PodmanConfig) (entities.ImageEngine, error)
r, err := NewLibpodImageRuntime(facts.FlagSet, facts) r, err := NewLibpodImageRuntime(facts.FlagSet, facts)
return r, err return r, err
case entities.TunnelMode: case entities.TunnelMode:
ctx, err := bindings.NewConnectionWithIdentity(context.Background(), facts.Uri, facts.PassPhrase, facts.Identities...) ctx, err := bindings.NewConnectionWithIdentity(context.Background(), facts.URI, facts.PassPhrase, facts.Identities...)
return &tunnel.ImageEngine{ClientCxt: ctx}, err return &tunnel.ImageEngine{ClientCxt: ctx}, err
} }
return nil, fmt.Errorf("runtime mode '%v' is not supported", facts.EngineMode) return nil, fmt.Errorf("runtime mode '%v' is not supported", facts.EngineMode)

View File

@ -16,7 +16,7 @@ func NewContainerEngine(facts *entities.PodmanConfig) (entities.ContainerEngine,
case entities.ABIMode: case entities.ABIMode:
return nil, fmt.Errorf("direct runtime not supported") return nil, fmt.Errorf("direct runtime not supported")
case entities.TunnelMode: case entities.TunnelMode:
ctx, err := bindings.NewConnectionWithIdentity(context.Background(), facts.Uri, facts.PassPhrase, facts.Identities...) ctx, err := bindings.NewConnectionWithIdentity(context.Background(), facts.URI, facts.PassPhrase, facts.Identities...)
return &tunnel.ContainerEngine{ClientCxt: ctx}, err return &tunnel.ContainerEngine{ClientCxt: ctx}, err
} }
return nil, fmt.Errorf("runtime mode '%v' is not supported", facts.EngineMode) return nil, fmt.Errorf("runtime mode '%v' is not supported", facts.EngineMode)
@ -28,7 +28,7 @@ func NewImageEngine(facts *entities.PodmanConfig) (entities.ImageEngine, error)
case entities.ABIMode: case entities.ABIMode:
return nil, fmt.Errorf("direct image runtime not supported") return nil, fmt.Errorf("direct image runtime not supported")
case entities.TunnelMode: case entities.TunnelMode:
ctx, err := bindings.NewConnectionWithIdentity(context.Background(), facts.Uri, facts.PassPhrase, facts.Identities...) ctx, err := bindings.NewConnectionWithIdentity(context.Background(), facts.URI, facts.PassPhrase, facts.Identities...)
return &tunnel.ImageEngine{ClientCxt: ctx}, err return &tunnel.ImageEngine{ClientCxt: ctx}, err
} }
return nil, fmt.Errorf("runtime mode '%v' is not supported", facts.EngineMode) return nil, fmt.Errorf("runtime mode '%v' is not supported", facts.EngineMode)

View File

@ -233,7 +233,7 @@ func (ic *ContainerEngine) ContainerTop(ctx context.Context, options entities.To
func (ic *ContainerEngine) ContainerCommit(ctx context.Context, nameOrId string, options entities.CommitOptions) (*entities.CommitReport, error) { func (ic *ContainerEngine) ContainerCommit(ctx context.Context, nameOrId string, options entities.CommitOptions) (*entities.CommitReport, error) {
var ( var (
repo string repo string
tag string = "latest" tag = "latest"
) )
if len(options.ImageName) > 0 { if len(options.ImageName) > 0 {
ref, err := reference.Parse(options.ImageName) ref, err := reference.Parse(options.ImageName)

View File

@ -13,5 +13,5 @@ func (ic *ContainerEngine) GenerateSystemd(ctx context.Context, nameOrID string,
} }
func (ic *ContainerEngine) GenerateKube(ctx context.Context, nameOrID string, options entities.GenerateKubeOptions) (*entities.GenerateKubeReport, error) { func (ic *ContainerEngine) GenerateKube(ctx context.Context, nameOrID string, options entities.GenerateKubeOptions) (*entities.GenerateKubeReport, error) {
return generate.GenerateKube(ic.ClientCxt, nameOrID, options) return generate.Kube(ic.ClientCxt, nameOrID, options)
} }

View File

@ -8,5 +8,5 @@ import (
) )
func (ic *ContainerEngine) PlayKube(ctx context.Context, path string, options entities.PlayKubeOptions) (*entities.PlayKubeReport, error) { func (ic *ContainerEngine) PlayKube(ctx context.Context, path string, options entities.PlayKubeOptions) (*entities.PlayKubeReport, error) {
return play.PlayKube(ic.ClientCxt, path, options) return play.Kube(ic.ClientCxt, path, options)
} }

View File

@ -87,7 +87,7 @@ func (ic *ContainerEngine) PodUnpause(ctx context.Context, namesOrIds []string,
func (ic *ContainerEngine) PodStop(ctx context.Context, namesOrIds []string, options entities.PodStopOptions) ([]*entities.PodStopReport, error) { func (ic *ContainerEngine) PodStop(ctx context.Context, namesOrIds []string, options entities.PodStopOptions) ([]*entities.PodStopReport, error) {
var ( var (
reports []*entities.PodStopReport reports []*entities.PodStopReport
timeout int = -1 timeout = -1
) )
foundPods, err := getPodsByContext(ic.ClientCxt, options.All, namesOrIds) foundPods, err := getPodsByContext(ic.ClientCxt, options.All, namesOrIds)
if err != nil && !(options.Ignore && errors.Cause(err) == define.ErrNoSuchPod) { if err != nil && !(options.Ignore && errors.Cause(err) == define.ErrNoSuchPod) {

View File

@ -31,7 +31,7 @@ func ToLibpodFilters(f url.Values) (filters []string) {
return return
} }
func ToUrlValues(f []string) (filters url.Values) { func ToURLValues(f []string) (filters url.Values) {
filters = make(url.Values) filters = make(url.Values)
for _, v := range f { for _, v := range f {
t := strings.SplitN(v, "=", 2) t := strings.SplitN(v, "=", 2)

View File

@ -14,7 +14,7 @@ import (
) )
// DefaultNetworkDriver is the default network type used // DefaultNetworkDriver is the default network type used
var DefaultNetworkDriver string = "bridge" var DefaultNetworkDriver = "bridge"
// SupportedNetworkDrivers describes the list of supported drivers // SupportedNetworkDrivers describes the list of supported drivers
var SupportedNetworkDrivers = []string{DefaultNetworkDriver} var SupportedNetworkDrivers = []string{DefaultNetworkDriver}

View File

@ -9,11 +9,11 @@ import (
"github.com/sirupsen/logrus" "github.com/sirupsen/logrus"
) )
// ParallelContainerOp performs the given function on the given set of // ContainerOp performs the given function on the given set of
// containers, using a number of parallel threads. // containers, using a number of parallel threads.
// If no error is returned, each container specified in ctrs will have an entry // If no error is returned, each container specified in ctrs will have an entry
// in the resulting map; containers with no error will be set to nil. // in the resulting map; containers with no error will be set to nil.
func ParallelContainerOp(ctx context.Context, ctrs []*libpod.Container, applyFunc func(*libpod.Container) error) (map[*libpod.Container]error, error) { func ContainerOp(ctx context.Context, ctrs []*libpod.Container, applyFunc func(*libpod.Container) error) (map[*libpod.Container]error, error) {
jobControlLock.RLock() jobControlLock.RLock()
defer jobControlLock.RUnlock() defer jobControlLock.RUnlock()
@ -22,7 +22,7 @@ func ParallelContainerOp(ctx context.Context, ctrs []*libpod.Container, applyFun
// The expectation is that most of the time is spent in applyFunc // The expectation is that most of the time is spent in applyFunc
// anyways. // anyways.
var ( var (
errMap map[*libpod.Container]error = make(map[*libpod.Container]error) errMap = make(map[*libpod.Container]error)
errLock sync.Mutex errLock sync.Mutex
allDone sync.WaitGroup allDone sync.WaitGroup
) )

View File

@ -399,7 +399,7 @@ func AddPrivilegedDevices(g *generate.Generator) error {
return addPrivilegedDevices(g) return addPrivilegedDevices(g)
} }
func CreateContainerFromCreateConfig(r *libpod.Runtime, createConfig *CreateConfig, ctx context.Context, pod *libpod.Pod) (*libpod.Container, error) { func CreateContainerFromCreateConfig(ctx context.Context, r *libpod.Runtime, createConfig *CreateConfig, pod *libpod.Pod) (*libpod.Container, error) {
runtimeSpec, options, err := createConfig.MakeContainerConfig(r, pod) runtimeSpec, options, err := createConfig.MakeContainerConfig(r, pod)
if err != nil { if err != nil {
return nil, err return nil, err

View File

@ -10,7 +10,7 @@ import (
var ( var (
// ErrInvalidSpecConfig describes an error that the given SpecGenerator is invalid // ErrInvalidSpecConfig describes an error that the given SpecGenerator is invalid
ErrInvalidSpecConfig error = errors.New("invalid configuration") ErrInvalidSpecConfig = errors.New("invalid configuration")
// SystemDValues describes the only values that SystemD can be // SystemDValues describes the only values that SystemD can be
SystemDValues = []string{"true", "false", "always"} SystemDValues = []string{"true", "false", "always"}
// ImageVolumeModeValues describes the only values that ImageVolumeMode can be // ImageVolumeModeValues describes the only values that ImageVolumeMode can be

View File

@ -230,7 +230,7 @@ func createContainerOptions(ctx context.Context, rt *libpod.Runtime, s *specgen.
options = append(options, libpod.WithPrivileged(s.Privileged)) options = append(options, libpod.WithPrivileged(s.Privileged))
// Get namespace related options // Get namespace related options
namespaceOptions, err := GenerateNamespaceOptions(ctx, s, rt, pod, img) namespaceOptions, err := namespaceOptions(ctx, s, rt, pod, img)
if err != nil { if err != nil {
return nil, err return nil, err
} }

View File

@ -72,13 +72,13 @@ func GetDefaultNamespaceMode(nsType string, cfg *config.Config, pod *libpod.Pod)
return toReturn, errors.Wrapf(define.ErrInvalidArg, "invalid namespace type %q passed", nsType) return toReturn, errors.Wrapf(define.ErrInvalidArg, "invalid namespace type %q passed", nsType)
} }
// GenerateNamespaceOptions generates container creation options for all // namespaceOptions generates container creation options for all
// namespaces in a SpecGenerator. // namespaces in a SpecGenerator.
// Pod is the pod the container will join. May be nil is the container is not // Pod is the pod the container will join. May be nil is the container is not
// joining a pod. // joining a pod.
// TODO: Consider grouping options that are not directly attached to a namespace // TODO: Consider grouping options that are not directly attached to a namespace
// elsewhere. // elsewhere.
func GenerateNamespaceOptions(ctx context.Context, s *specgen.SpecGenerator, rt *libpod.Runtime, pod *libpod.Pod, img *image.Image) ([]libpod.CtrCreateOption, error) { func namespaceOptions(ctx context.Context, s *specgen.SpecGenerator, rt *libpod.Runtime, pod *libpod.Pod, img *image.Image) ([]libpod.CtrCreateOption, error) {
toReturn := []libpod.CtrCreateOption{} toReturn := []libpod.CtrCreateOption{}
// If pod is not nil, get infra container. // If pod is not nil, get infra container.

View File

@ -7,7 +7,7 @@ import (
var ( var (
// ErrInvalidPodSpecConfig describes an error given when the podspecgenerator is invalid // ErrInvalidPodSpecConfig describes an error given when the podspecgenerator is invalid
ErrInvalidPodSpecConfig error = errors.New("invalid pod spec") ErrInvalidPodSpecConfig = errors.New("invalid pod spec")
// containerConfig has the default configurations defined in containers.conf // containerConfig has the default configurations defined in containers.conf
containerConfig = util.DefaultContainerConfig() containerConfig = util.DefaultContainerConfig()
) )

View File

@ -170,7 +170,7 @@ Type=forking
[Install] [Install]
WantedBy=multi-user.target default.target` WantedBy=multi-user.target default.target`
goodIdNew := `# container-639c53578af4d84b8800b4635fa4e680ee80fd67e0e6a2d4eea48d1e3230f401.service goodIDNew := `# container-639c53578af4d84b8800b4635fa4e680ee80fd67e0e6a2d4eea48d1e3230f401.service
# autogenerated by Podman CI # autogenerated by Podman CI
[Unit] [Unit]
@ -323,7 +323,7 @@ WantedBy=multi-user.target default.target`
New: true, New: true,
CreateCommand: []string{"I'll get stripped", "container", "run", "awesome-image:latest"}, CreateCommand: []string{"I'll get stripped", "container", "run", "awesome-image:latest"},
}, },
goodIdNew, goodIDNew,
false, false,
}, },
} }

View File

@ -1,7 +1,7 @@
package trust package trust
// Trust Policy describes a basic trust policy configuration // Policy describes a basic trust policy configuration
type TrustPolicy struct { type Policy struct {
Name string `json:"name"` Name string `json:"name"`
RepoName string `json:"repo_name,omitempty"` RepoName string `json:"repo_name,omitempty"`
Keys []string `json:"keys,omitempty"` Keys []string `json:"keys,omitempty"`

View File

@ -220,7 +220,7 @@ func CreateContainer(ctx context.Context, c *GenericCLIResults, runtime *libpod.
} }
} }
ctr, err := CreateContainerFromCreateConfig(runtime, createConfig, ctx, pod) ctr, err := CreateContainerFromCreateConfig(ctx, runtime, createConfig, pod)
if err != nil { if err != nil {
return nil, nil, err return nil, nil, err
} }
@ -909,7 +909,7 @@ func ParseCreateOpts(ctx context.Context, c *GenericCLIResults, runtime *libpod.
return config, nil return config, nil
} }
func CreateContainerFromCreateConfig(r *libpod.Runtime, createConfig *cc.CreateConfig, ctx context.Context, pod *libpod.Pod) (*libpod.Container, error) { func CreateContainerFromCreateConfig(ctx context.Context, r *libpod.Runtime, createConfig *cc.CreateConfig, pod *libpod.Pod) (*libpod.Container, error) {
runtimeSpec, options, err := createConfig.MakeContainerConfig(r, pod) runtimeSpec, options, err := createConfig.MakeContainerConfig(r, pod)
if err != nil { if err != nil {
return nil, err return nil, err

View File

@ -25,7 +25,7 @@ func (i *VarlinkAPI) VolumeCreate(call iopodman.VarlinkCall, options iopodman.Vo
volumeOptions = append(volumeOptions, libpod.WithVolumeLabels(options.Labels)) volumeOptions = append(volumeOptions, libpod.WithVolumeLabels(options.Labels))
} }
if len(options.Options) > 0 { if len(options.Options) > 0 {
parsedOptions, err := parse.ParseVolumeOptions(options.Options) parsedOptions, err := parse.VolumeOptions(options.Options)
if err != nil { if err != nil {
return call.ReplyErrorOccurred(err.Error()) return call.ReplyErrorOccurred(err.Error())
} }