mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Merge pull request #23829 from LK4D4/cleanup_unused
api,daemon: cleanup some unused stuff
This commit is contained in:
commit
506234e3f0
4 changed files with 0 additions and 108 deletions
|
@ -24,11 +24,6 @@ import (
|
||||||
"github.com/spf13/pflag"
|
"github.com/spf13/pflag"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
|
||||||
errCmdNotFound = "not found or does not exist"
|
|
||||||
errCmdCouldNotBeInvoked = "could not be invoked"
|
|
||||||
)
|
|
||||||
|
|
||||||
type runOptions struct {
|
type runOptions struct {
|
||||||
autoRemove bool
|
autoRemove bool
|
||||||
detach bool
|
detach bool
|
||||||
|
|
|
@ -25,7 +25,6 @@ import (
|
||||||
"github.com/docker/docker/cliconfig"
|
"github.com/docker/docker/cliconfig"
|
||||||
"github.com/docker/docker/distribution"
|
"github.com/docker/docker/distribution"
|
||||||
"github.com/docker/docker/pkg/jsonmessage"
|
"github.com/docker/docker/pkg/jsonmessage"
|
||||||
flag "github.com/docker/docker/pkg/mflag"
|
|
||||||
"github.com/docker/docker/reference"
|
"github.com/docker/docker/reference"
|
||||||
"github.com/docker/docker/registry"
|
"github.com/docker/docker/registry"
|
||||||
"github.com/docker/engine-api/types"
|
"github.com/docker/engine-api/types"
|
||||||
|
@ -46,12 +45,6 @@ var (
|
||||||
untrusted bool
|
untrusted bool
|
||||||
)
|
)
|
||||||
|
|
||||||
// addTrustedFlags is the mflag version of AddTrustedFlags
|
|
||||||
func addTrustedFlags(fs *flag.FlagSet, verify bool) {
|
|
||||||
trusted, message := setupTrustedFlag(verify)
|
|
||||||
fs.BoolVar(&untrusted, []string{"-disable-content-trust"}, !trusted, message)
|
|
||||||
}
|
|
||||||
|
|
||||||
// AddTrustedFlags adds content trust flags to the current command flagset
|
// AddTrustedFlags adds content trust flags to the current command flagset
|
||||||
func AddTrustedFlags(fs *pflag.FlagSet, verify bool) {
|
func AddTrustedFlags(fs *pflag.FlagSet, verify bool) {
|
||||||
trusted, message := setupTrustedFlag(verify)
|
trusted, message := setupTrustedFlag(verify)
|
||||||
|
|
|
@ -8,8 +8,6 @@ import (
|
||||||
"github.com/docker/engine-api/types/filters"
|
"github.com/docker/engine-api/types/filters"
|
||||||
)
|
)
|
||||||
|
|
||||||
type filterHandler func([]types.NetworkResource, string) ([]types.NetworkResource, error)
|
|
||||||
|
|
||||||
var (
|
var (
|
||||||
// AcceptedFilters is an acceptable filters for validation
|
// AcceptedFilters is an acceptable filters for validation
|
||||||
AcceptedFilters = map[string]bool{
|
AcceptedFilters = map[string]bool{
|
||||||
|
|
|
@ -1,94 +0,0 @@
|
||||||
package network
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
|
|
||||||
"github.com/docker/docker/runconfig"
|
|
||||||
"github.com/docker/engine-api/types/filters"
|
|
||||||
"github.com/docker/libnetwork"
|
|
||||||
)
|
|
||||||
|
|
||||||
type filterHandler func([]libnetwork.Network, string) ([]libnetwork.Network, error)
|
|
||||||
|
|
||||||
var (
|
|
||||||
// AcceptedFilters is an acceptable filters for validation
|
|
||||||
AcceptedFilters = map[string]bool{
|
|
||||||
"driver": true,
|
|
||||||
"type": true,
|
|
||||||
"name": true,
|
|
||||||
"id": true,
|
|
||||||
"label": true,
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
func filterNetworkByType(nws []libnetwork.Network, netType string) (retNws []libnetwork.Network, err error) {
|
|
||||||
switch netType {
|
|
||||||
case "builtin":
|
|
||||||
for _, nw := range nws {
|
|
||||||
if runconfig.IsPreDefinedNetwork(nw.Name()) {
|
|
||||||
retNws = append(retNws, nw)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
case "custom":
|
|
||||||
for _, nw := range nws {
|
|
||||||
if !runconfig.IsPreDefinedNetwork(nw.Name()) {
|
|
||||||
retNws = append(retNws, nw)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
return nil, fmt.Errorf("Invalid filter: 'type'='%s'", netType)
|
|
||||||
}
|
|
||||||
return retNws, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// FilterNetworks filters network list according to user specified filter
|
|
||||||
// and returns user chosen networks
|
|
||||||
func FilterNetworks(nws []libnetwork.Network, filter filters.Args) ([]libnetwork.Network, error) {
|
|
||||||
// if filter is empty, return original network list
|
|
||||||
if filter.Len() == 0 {
|
|
||||||
return nws, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
var displayNet []libnetwork.Network
|
|
||||||
for _, nw := range nws {
|
|
||||||
if filter.Include("driver") {
|
|
||||||
if !filter.ExactMatch("driver", nw.Type()) {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if filter.Include("name") {
|
|
||||||
if !filter.Match("name", nw.Name()) {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if filter.Include("id") {
|
|
||||||
if !filter.Match("id", nw.ID()) {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if filter.Include("label") {
|
|
||||||
if !filter.MatchKVList("label", nw.Info().Labels()) {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
}
|
|
||||||
displayNet = append(displayNet, nw)
|
|
||||||
}
|
|
||||||
|
|
||||||
if filter.Include("type") {
|
|
||||||
var typeNet []libnetwork.Network
|
|
||||||
errFilter := filter.WalkValues("type", func(fval string) error {
|
|
||||||
passList, err := filterNetworkByType(displayNet, fval)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
typeNet = append(typeNet, passList...)
|
|
||||||
return nil
|
|
||||||
})
|
|
||||||
if errFilter != nil {
|
|
||||||
return nil, errFilter
|
|
||||||
}
|
|
||||||
displayNet = typeNet
|
|
||||||
}
|
|
||||||
|
|
||||||
return displayNet, nil
|
|
||||||
}
|
|
Loading…
Add table
Reference in a new issue