summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel J Walsh <dwalsh@redhat.com>2020-05-21 12:07:46 -0400
committerDaniel J Walsh <dwalsh@redhat.com>2020-05-21 12:09:01 -0400
commit0d0565f55ee3399f5c2c4e4b73acb732b424f3db (patch)
treea7345295b565e93eda9e353479e1334eb9bdcc05
parenta852afab2f37026fa8a45d115c61cd77fb3e7ef1 (diff)
downloadpodman-0d0565f55ee3399f5c2c4e4b73acb732b424f3db.tar.gz
podman-0d0565f55ee3399f5c2c4e4b73acb732b424f3db.tar.bz2
podman-0d0565f55ee3399f5c2c4e4b73acb732b424f3db.zip
Remove github.com/libpod/libpod from cmd/pkg/podman
By moving a couple of variables from libpod/libpod to libpod/libpod/define I am able shrink the podman-remote-* executables by another megabyte. Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
-rw-r--r--cmd/podman/networks/create.go6
-rw-r--r--libpod/define/config.go10
-rw-r--r--libpod/options.go26
3 files changed, 21 insertions, 21 deletions
diff --git a/cmd/podman/networks/create.go b/cmd/podman/networks/create.go
index 10973e6bf..5d28c7140 100644
--- a/cmd/podman/networks/create.go
+++ b/cmd/podman/networks/create.go
@@ -5,7 +5,7 @@ import (
"net"
"github.com/containers/libpod/cmd/podman/registry"
- "github.com/containers/libpod/libpod"
+ "github.com/containers/libpod/libpod/define"
"github.com/containers/libpod/pkg/domain/entities"
"github.com/containers/libpod/pkg/network"
"github.com/pkg/errors"
@@ -65,8 +65,8 @@ func networkCreate(cmd *cobra.Command, args []string) error {
if len(args) > 1 {
return errors.Errorf("only one network can be created at a time")
}
- if len(args) > 0 && !libpod.NameRegex.MatchString(args[0]) {
- return libpod.RegexError
+ if len(args) > 0 && !define.NameRegex.MatchString(args[0]) {
+ return define.RegexError
}
if len(args) > 0 {
diff --git a/libpod/define/config.go b/libpod/define/config.go
index 692eafb04..5ca4da4af 100644
--- a/libpod/define/config.go
+++ b/libpod/define/config.go
@@ -3,6 +3,9 @@ package define
import (
"bufio"
"io"
+ "regexp"
+
+ "github.com/pkg/errors"
)
var (
@@ -10,6 +13,13 @@ var (
DefaultSHMLockPath = "/libpod_lock"
// DefaultRootlessSHMLockPath is the default path for rootless SHM locks
DefaultRootlessSHMLockPath = "/libpod_rootless_lock"
+
+ // NameRegex is a regular expression to validate container/pod names.
+ // This must NOT be changed from outside of Libpod. It should be a
+ // constant, but Go won't let us do that.
+ NameRegex = regexp.MustCompile("^[a-zA-Z0-9][a-zA-Z0-9_.-]*$")
+ // RegexError is thrown in presence of an invalid container/pod name.
+ RegexError = errors.Wrapf(ErrInvalidArg, "names must match [a-zA-Z0-9][a-zA-Z0-9_.-]*")
)
const (
diff --git a/libpod/options.go b/libpod/options.go
index 05241baf3..ff5e29335 100644
--- a/libpod/options.go
+++ b/libpod/options.go
@@ -4,7 +4,6 @@ import (
"net"
"os"
"path/filepath"
- "regexp"
"syscall"
"github.com/containers/common/pkg/config"
@@ -20,15 +19,6 @@ import (
"github.com/pkg/errors"
)
-var (
- // NameRegex is a regular expression to validate container/pod names.
- // This must NOT be changed from outside of Libpod. It should be a
- // constant, but Go won't let us do that.
- NameRegex = regexp.MustCompile("^[a-zA-Z0-9][a-zA-Z0-9_.-]*$")
- // RegexError is thrown in presence of an invalid container/pod name.
- RegexError = errors.Wrapf(define.ErrInvalidArg, "names must match [a-zA-Z0-9][a-zA-Z0-9_.-]*")
-)
-
// Runtime Creation Options
// WithStorageConfig uses the given configuration to set up container storage.
@@ -665,8 +655,8 @@ func WithName(name string) CtrCreateOption {
}
// Check the name against a regex
- if !NameRegex.MatchString(name) {
- return RegexError
+ if !define.NameRegex.MatchString(name) {
+ return define.RegexError
}
ctr.config.Name = name
@@ -1383,8 +1373,8 @@ func WithVolumeName(name string) VolumeCreateOption {
}
// Check the name against a regex
- if !NameRegex.MatchString(name) {
- return RegexError
+ if !define.NameRegex.MatchString(name) {
+ return define.RegexError
}
volume.config.Name = name
@@ -1502,8 +1492,8 @@ func WithPodName(name string) PodCreateOption {
}
// Check the name against a regex
- if !NameRegex.MatchString(name) {
- return RegexError
+ if !define.NameRegex.MatchString(name) {
+ return define.RegexError
}
pod.config.Name = name
@@ -1520,8 +1510,8 @@ func WithPodHostname(hostname string) PodCreateOption {
}
// Check the hostname against a regex
- if !NameRegex.MatchString(hostname) {
- return RegexError
+ if !define.NameRegex.MatchString(hostname) {
+ return define.RegexError
}
pod.config.Hostname = hostname