mirror of https://github.com/containers/podman.git
pkg/util: remove deadcode
Signed-off-by: Paul Holzinger <pholzing@redhat.com>
This commit is contained in:
parent
2ead30e40b
commit
ae543a4dec
2
go.mod
2
go.mod
|
@ -6,7 +6,6 @@ module github.com/containers/podman/v5
|
|||
go 1.23.3
|
||||
|
||||
require (
|
||||
github.com/BurntSushi/toml v1.5.0
|
||||
github.com/Microsoft/go-winio v0.6.2
|
||||
github.com/blang/semver/v4 v4.0.0
|
||||
github.com/checkpoint-restore/checkpointctl v1.3.0
|
||||
|
@ -85,6 +84,7 @@ require (
|
|||
require (
|
||||
dario.cat/mergo v1.0.2 // indirect
|
||||
github.com/Azure/go-ansiterm v0.0.0-20250102033503-faa5f7b0171c // indirect
|
||||
github.com/BurntSushi/toml v1.5.0 // indirect
|
||||
github.com/Microsoft/hcsshim v0.13.0 // indirect
|
||||
github.com/VividCortex/ewma v1.2.0 // indirect
|
||||
github.com/acarl005/stripansi v0.0.0-20180116102854-5a71ef0e047d // indirect
|
||||
|
|
|
@ -16,10 +16,8 @@ import (
|
|||
"syscall"
|
||||
"time"
|
||||
|
||||
"github.com/BurntSushi/toml"
|
||||
"github.com/containers/image/v5/types"
|
||||
"github.com/containers/podman/v5/libpod/define"
|
||||
"github.com/containers/podman/v5/pkg/errorhandling"
|
||||
"github.com/containers/podman/v5/pkg/namespaces"
|
||||
"github.com/containers/podman/v5/pkg/rootless"
|
||||
"github.com/containers/podman/v5/pkg/signal"
|
||||
|
@ -1042,56 +1040,6 @@ func ParseIDMapping(mode namespaces.UsernsMode, uidMapSlice, gidMapSlice []strin
|
|||
return &options, nil
|
||||
}
|
||||
|
||||
type tomlOptionsConfig struct {
|
||||
MountProgram string `toml:"mount_program"`
|
||||
}
|
||||
|
||||
type tomlConfig struct {
|
||||
Storage struct {
|
||||
Driver string `toml:"driver"`
|
||||
RunRoot string `toml:"runroot"`
|
||||
GraphRoot string `toml:"graphroot"`
|
||||
Options struct{ tomlOptionsConfig } `toml:"options"`
|
||||
} `toml:"storage"`
|
||||
}
|
||||
|
||||
func getTomlStorage(storeOptions *stypes.StoreOptions) *tomlConfig {
|
||||
config := new(tomlConfig)
|
||||
|
||||
config.Storage.Driver = storeOptions.GraphDriverName
|
||||
config.Storage.RunRoot = storeOptions.RunRoot
|
||||
config.Storage.GraphRoot = storeOptions.GraphRoot
|
||||
for _, i := range storeOptions.GraphDriverOptions {
|
||||
program, hasPrefix := strings.CutPrefix(i, "overlay.mount_program=")
|
||||
if hasPrefix {
|
||||
config.Storage.Options.MountProgram = program
|
||||
}
|
||||
}
|
||||
|
||||
return config
|
||||
}
|
||||
|
||||
// WriteStorageConfigFile writes the configuration to a file
|
||||
func WriteStorageConfigFile(storageOpts *stypes.StoreOptions, storageConf string) error {
|
||||
if err := os.MkdirAll(filepath.Dir(storageConf), 0755); err != nil {
|
||||
return err
|
||||
}
|
||||
storageFile, err := os.OpenFile(storageConf, os.O_RDWR|os.O_TRUNC, 0600)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
tomlConfiguration := getTomlStorage(storageOpts)
|
||||
defer errorhandling.CloseQuiet(storageFile)
|
||||
enc := toml.NewEncoder(storageFile)
|
||||
if err := enc.Encode(tomlConfiguration); err != nil {
|
||||
if err := os.Remove(storageConf); err != nil {
|
||||
logrus.Error(err)
|
||||
}
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// ParseInputTime takes the users input and to determine if it is valid and
|
||||
// returns a time format and error. The input is compared to known time formats
|
||||
// or a duration which implies no-duration
|
||||
|
@ -1123,33 +1071,6 @@ func ParseInputTime(inputTime string, since bool) (time.Time, error) {
|
|||
return time.Now().Add(duration), nil
|
||||
}
|
||||
|
||||
// OpenExclusiveFile opens a file for writing and ensure it doesn't already exist
|
||||
func OpenExclusiveFile(path string) (*os.File, error) {
|
||||
baseDir := filepath.Dir(path)
|
||||
if baseDir != "" {
|
||||
if err := fileutils.Exists(baseDir); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
return os.OpenFile(path, os.O_RDWR|os.O_CREATE|os.O_EXCL, 0666)
|
||||
}
|
||||
|
||||
// ExitCode reads the error message when failing to executing container process
|
||||
// and then returns 0 if no error, 126 if command does not exist, or 127 for
|
||||
// all other errors
|
||||
func ExitCode(err error) int {
|
||||
if err == nil {
|
||||
return 0
|
||||
}
|
||||
e := strings.ToLower(err.Error())
|
||||
if strings.Contains(e, "file not found") ||
|
||||
strings.Contains(e, "no such file or directory") {
|
||||
return 127
|
||||
}
|
||||
|
||||
return 126
|
||||
}
|
||||
|
||||
func Tmpdir() string {
|
||||
tmpdir := os.Getenv("TMPDIR")
|
||||
if tmpdir == "" {
|
||||
|
|
Loading…
Reference in New Issue