Skip to content
This repository was archived by the owner on Feb 8, 2021. It is now read-only.

Commit 4398108

Browse files
author
Erik Hollensbe
committed
Move parsing functions to pkg/parsers and the specific kernel handling
functions to pkg/parsers/kernel, and parsing filters to pkg/parsers/filter. Adjust imports and package references. Docker-DCO-1.1-Signed-off-by: Erik Hollensbe <github@hollensbe.org> (github: erikh)
1 parent 335e82f commit 4398108

File tree

28 files changed

+400
-363
lines changed

28 files changed

+400
-363
lines changed

api/client/commands.go

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,14 @@ import (
2828
"github.com/docker/docker/engine"
2929
"github.com/docker/docker/nat"
3030
"github.com/docker/docker/opts"
31+
"github.com/docker/docker/pkg/parsers"
32+
"github.com/docker/docker/pkg/parsers/filters"
3133
"github.com/docker/docker/pkg/signal"
3234
"github.com/docker/docker/pkg/term"
3335
"github.com/docker/docker/pkg/units"
3436
"github.com/docker/docker/registry"
3537
"github.com/docker/docker/runconfig"
3638
"github.com/docker/docker/utils"
37-
"github.com/docker/docker/utils/filters"
3839
)
3940

4041
const (
@@ -204,7 +205,7 @@ func (cli *DockerCli) CmdBuild(args ...string) error {
204205

205206
//Check if the given image name can be resolved
206207
if *tag != "" {
207-
repository, _ := utils.ParseRepositoryTag(*tag)
208+
repository, _ := parsers.ParseRepositoryTag(*tag)
208209
if _, _, err := registry.ResolveRepositoryName(repository); err != nil {
209210
return err
210211
}
@@ -1137,7 +1138,7 @@ func (cli *DockerCli) CmdPush(args ...string) error {
11371138

11381139
cli.LoadConfigFile()
11391140

1140-
remote, tag := utils.ParseRepositoryTag(name)
1141+
remote, tag := parsers.ParseRepositoryTag(name)
11411142

11421143
// Resolve the Repository name from fqn to hostname + name
11431144
hostname, _, err := registry.ResolveRepositoryName(remote)
@@ -1210,7 +1211,7 @@ func (cli *DockerCli) CmdPull(args ...string) error {
12101211
v.Set("tag", *tag)
12111212
}
12121213

1213-
remote, _ = utils.ParseRepositoryTag(remote)
1214+
remote, _ = parsers.ParseRepositoryTag(remote)
12141215
// Resolve the Repository name from fqn to hostname + name
12151216
hostname, _, err := registry.ResolveRepositoryName(remote)
12161217
if err != nil {
@@ -1393,7 +1394,7 @@ func (cli *DockerCli) CmdImages(args ...string) error {
13931394
for _, out := range outs.Data {
13941395
for _, repotag := range out.GetList("RepoTags") {
13951396

1396-
repo, tag := utils.ParseRepositoryTag(repotag)
1397+
repo, tag := parsers.ParseRepositoryTag(repotag)
13971398
outID := out.Get("Id")
13981399
if !*noTrunc {
13991400
outID = utils.TruncateID(outID)
@@ -1594,7 +1595,7 @@ func (cli *DockerCli) CmdCommit(args ...string) error {
15941595

15951596
var (
15961597
name = cmd.Arg(0)
1597-
repository, tag = utils.ParseRepositoryTag(cmd.Arg(1))
1598+
repository, tag = parsers.ParseRepositoryTag(cmd.Arg(1))
15981599
)
15991600

16001601
if name == "" || len(cmd.Args()) > 2 {
@@ -1918,7 +1919,7 @@ func (cli *DockerCli) CmdTag(args ...string) error {
19181919
}
19191920

19201921
var (
1921-
repository, tag = utils.ParseRepositoryTag(cmd.Arg(1))
1922+
repository, tag = parsers.ParseRepositoryTag(cmd.Arg(1))
19221923
v = url.Values{}
19231924
)
19241925

@@ -1941,7 +1942,7 @@ func (cli *DockerCli) CmdTag(args ...string) error {
19411942

19421943
func (cli *DockerCli) pullImage(image string) error {
19431944
v := url.Values{}
1944-
repos, tag := utils.ParseRepositoryTag(image)
1945+
repos, tag := parsers.ParseRepositoryTag(image)
19451946
// pull only the image tagged 'latest' if no tag was specified
19461947
if tag == "" {
19471948
tag = "latest"

api/common.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"strings"
77

88
"github.com/docker/docker/engine"
9+
"github.com/docker/docker/pkg/parsers"
910
"github.com/docker/docker/pkg/version"
1011
"github.com/docker/docker/utils"
1112
)
@@ -17,7 +18,7 @@ const (
1718
)
1819

1920
func ValidateHost(val string) (string, error) {
20-
host, err := utils.ParseHost(DEFAULTHTTPHOST, DEFAULTUNIXSOCKET, val)
21+
host, err := parsers.ParseHost(DEFAULTHTTPHOST, DEFAULTUNIXSOCKET, val)
2122
if err != nil {
2223
return val, err
2324
}

api/server/server.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import (
2525
"github.com/docker/docker/api"
2626
"github.com/docker/docker/engine"
2727
"github.com/docker/docker/pkg/listenbuffer"
28+
"github.com/docker/docker/pkg/parsers"
2829
"github.com/docker/docker/pkg/systemd"
2930
"github.com/docker/docker/pkg/user"
3031
"github.com/docker/docker/pkg/version"
@@ -484,7 +485,7 @@ func postImagesCreate(eng *engine.Engine, version version.Version, w http.Respon
484485
}
485486
if image != "" { //pull
486487
if tag == "" {
487-
image, tag = utils.ParseRepositoryTag(image)
488+
image, tag = parsers.ParseRepositoryTag(image)
488489
}
489490
metaHeaders := map[string][]string{}
490491
for k, v := range r.Header {
@@ -498,7 +499,7 @@ func postImagesCreate(eng *engine.Engine, version version.Version, w http.Respon
498499
job.SetenvJson("authConfig", authConfig)
499500
} else { //import
500501
if tag == "" {
501-
repo, tag = utils.ParseRepositoryTag(repo)
502+
repo, tag = parsers.ParseRepositoryTag(repo)
502503
}
503504
job = eng.Job("import", r.Form.Get("fromSrc"), repo, tag)
504505
job.Stdin.Add(r.Body)

builder/builder.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import (
2323
"github.com/docker/docker/daemon"
2424
"github.com/docker/docker/engine"
2525
"github.com/docker/docker/nat"
26+
"github.com/docker/docker/pkg/parsers"
2627
"github.com/docker/docker/pkg/symlink"
2728
"github.com/docker/docker/pkg/system"
2829
"github.com/docker/docker/registry"
@@ -86,7 +87,7 @@ func (b *buildFile) CmdFrom(name string) error {
8687
image, err := b.daemon.Repositories().LookupImage(name)
8788
if err != nil {
8889
if b.daemon.Graph().IsNotExist(err) {
89-
remote, tag := utils.ParseRepositoryTag(name)
90+
remote, tag := parsers.ParseRepositoryTag(name)
9091
pullRegistryAuth := b.authConfig
9192
if len(b.configFile.Configs) > 0 {
9293
// The request came with a full auth config file, we prefer to use that

builtins/builtins.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ import (
88
"github.com/docker/docker/daemon/networkdriver/bridge"
99
"github.com/docker/docker/dockerversion"
1010
"github.com/docker/docker/engine"
11+
"github.com/docker/docker/pkg/parsers/kernel"
1112
"github.com/docker/docker/registry"
1213
"github.com/docker/docker/server"
13-
"github.com/docker/docker/utils"
1414
)
1515

1616
func Register(eng *engine.Engine) error {
@@ -68,7 +68,7 @@ func dockerVersion(job *engine.Job) engine.Status {
6868
v.Set("GoVersion", runtime.Version())
6969
v.Set("Os", runtime.GOOS)
7070
v.Set("Arch", runtime.GOARCH)
71-
if kernelVersion, err := utils.GetKernelVersion(); err == nil {
71+
if kernelVersion, err := kernel.GetKernelVersion(); err == nil {
7272
v.Set("KernelVersion", kernelVersion.String())
7373
}
7474
if _, err := v.WriteTo(job.Stdout); err != nil {

daemon/daemon.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import (
2828
"github.com/docker/docker/pkg/graphdb"
2929
"github.com/docker/docker/pkg/namesgenerator"
3030
"github.com/docker/docker/pkg/networkfs/resolvconf"
31+
"github.com/docker/docker/pkg/parsers"
3132
"github.com/docker/docker/pkg/sysinfo"
3233
"github.com/docker/docker/pkg/truncindex"
3334
"github.com/docker/docker/runconfig"
@@ -724,7 +725,7 @@ func (daemon *Daemon) RegisterLink(parent, child *Container, alias string) error
724725
func (daemon *Daemon) RegisterLinks(container *Container, hostConfig *runconfig.HostConfig) error {
725726
if hostConfig != nil && hostConfig.Links != nil {
726727
for _, l := range hostConfig.Links {
727-
parts, err := utils.PartParser("name:alias", l)
728+
parts, err := parsers.PartParser("name:alias", l)
728729
if err != nil {
729730
return err
730731
}

daemon/graphdriver/devmapper/deviceset.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import (
1919
"time"
2020

2121
"github.com/docker/docker/daemon/graphdriver"
22+
"github.com/docker/docker/pkg/parsers"
2223
"github.com/docker/docker/pkg/units"
2324
"github.com/docker/docker/utils"
2425
"github.com/docker/libcontainer/label"
@@ -1166,7 +1167,7 @@ func NewDeviceSet(root string, doInit bool, options []string) (*DeviceSet, error
11661167

11671168
foundBlkDiscard := false
11681169
for _, option := range options {
1169-
key, val, err := utils.ParseKeyValueOpt(option)
1170+
key, val, err := parsers.ParseKeyValueOpt(option)
11701171
if err != nil {
11711172
return nil, err
11721173
}

daemon/networkdriver/bridge/driver.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import (
1515
"github.com/docker/docker/engine"
1616
"github.com/docker/docker/pkg/iptables"
1717
"github.com/docker/docker/pkg/networkfs/resolvconf"
18+
"github.com/docker/docker/pkg/parsers/kernel"
1819
"github.com/docker/docker/utils"
1920
"github.com/docker/libcontainer/netlink"
2021
)
@@ -306,7 +307,7 @@ func createBridge(bridgeIP string) error {
306307
}
307308

308309
func createBridgeIface(name string) error {
309-
kv, err := utils.GetKernelVersion()
310+
kv, err := kernel.GetKernelVersion()
310311
// only set the bridge's mac address if the kernel version is > 3.3
311312
// before that it was not supported
312313
setBridgeMacAddr := err == nil && (kv.Kernel >= 3 && kv.Major >= 3)

docker/docker.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import (
1919
"github.com/docker/docker/engine"
2020
"github.com/docker/docker/opts"
2121
flag "github.com/docker/docker/pkg/mflag"
22+
"github.com/docker/docker/pkg/parsers/kernel"
2223
"github.com/docker/docker/sysinit"
2324
"github.com/docker/docker/utils"
2425
)
@@ -292,10 +293,10 @@ func checkKernelAndArch() error {
292293
// without actually causing a kernel panic, so we need this workaround until
293294
// the circumstances of pre-3.8 crashes are clearer.
294295
// For details see http://github.com/docker/docker/issues/407
295-
if k, err := utils.GetKernelVersion(); err != nil {
296+
if k, err := kernel.GetKernelVersion(); err != nil {
296297
log.Printf("WARNING: %s\n", err)
297298
} else {
298-
if utils.CompareKernelVersion(k, &utils.KernelVersionInfo{Kernel: 3, Major: 8, Minor: 0}) < 0 {
299+
if kernel.CompareKernelVersion(k, &kernel.KernelVersionInfo{Kernel: 3, Major: 8, Minor: 0}) < 0 {
299300
if os.Getenv("DOCKER_NOWARN_KERNEL_VERSION") == "" {
300301
log.Printf("WARNING: You are running linux kernel version %s, which might be unstable running docker. Please upgrade your kernel to 3.8.0.", k.String())
301302
}

graph/service.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55

66
"github.com/docker/docker/engine"
77
"github.com/docker/docker/image"
8+
"github.com/docker/docker/pkg/parsers"
89
"github.com/docker/docker/utils"
910
)
1011

@@ -78,7 +79,7 @@ func (s *TagStore) CmdTag(job *engine.Job) engine.Status {
7879
newName = job.Args[0]
7980
oldName = job.Args[1]
8081
)
81-
newRepo, newTag := utils.ParseRepositoryTag(newName)
82+
newRepo, newTag := parsers.ParseRepositoryTag(newName)
8283
// FIXME: Set should either parse both old and new name, or neither.
8384
// the current prototype is inconsistent.
8485
if err := s.Set(newRepo, newTag, oldName, true); err != nil {

0 commit comments

Comments
 (0)