Use containers/storage/pkg/regexp in place of regexp

This is a cleaner solution and guarantees the variables
will be used before they are initialized.

[NO NEW TESTS NEEDED]

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
This commit is contained in:
Daniel J Walsh
2023-01-12 18:31:19 -05:00
parent c433982d18
commit c2b36beb40
4 changed files with 10 additions and 35 deletions

View File

@ -6,9 +6,7 @@ import (
"net"
"os"
"path/filepath"
"regexp"
"strings"
"sync"
"syscall"
"github.com/containers/buildah/pkg/parse"
@ -25,15 +23,13 @@ import (
"github.com/containers/podman/v4/pkg/util"
"github.com/containers/storage"
"github.com/containers/storage/pkg/idtools"
"github.com/containers/storage/pkg/regexp"
"github.com/opencontainers/runtime-spec/specs-go"
"github.com/opencontainers/runtime-tools/generate"
"github.com/sirupsen/logrus"
)
var (
umaskRegex *regexp.Regexp
onceRegex sync.Once
)
var umaskRegex = regexp.Delayed(`^[0-7]{1,4}$`)
// WithStorageConfig uses the given configuration to set up container storage.
// If this is not specified, the system default configuration will be used
@ -1797,9 +1793,6 @@ func WithTimezone(path string) CtrCreateOption {
// WithUmask sets the umask in the container
func WithUmask(umask string) CtrCreateOption {
onceRegex.Do(func() {
umaskRegex = regexp.MustCompile(`^[0-7]{1,4}$`)
})
return func(ctr *Container) error {
if ctr.valid {
return define.ErrCtrFinalized