diff options
Diffstat (limited to 'cmd/podman/main.go')
-rw-r--r-- | cmd/podman/main.go | 32 |
1 files changed, 25 insertions, 7 deletions
diff --git a/cmd/podman/main.go b/cmd/podman/main.go index a22b01f24..5134448da 100644 --- a/cmd/podman/main.go +++ b/cmd/podman/main.go @@ -6,6 +6,7 @@ import ( "os" "path" + "github.com/containers/common/pkg/config" "github.com/containers/libpod/cmd/podman/cliconfig" "github.com/containers/libpod/libpod" "github.com/containers/libpod/libpod/define" @@ -81,9 +82,12 @@ var rootCmd = &cobra.Command{ SilenceErrors: true, } -var MainGlobalOpts cliconfig.MainFlags +var ( + MainGlobalOpts cliconfig.MainFlags + defaultContainerConfig = getDefaultContainerConfig() +) -func init() { +func initCobra() { cobra.OnInitialize(initConfig) rootCmd.TraverseChildren = true rootCmd.Version = version.Version @@ -94,16 +98,20 @@ func init() { rootCmd.AddCommand(getMainCommands()...) } -func initConfig() { - // we can do more stuff in here. -} - -func before(cmd *cobra.Command, args []string) error { +func init() { if err := libpod.SetXdgDirs(); err != nil { logrus.Errorf(err.Error()) os.Exit(1) } + initBuild() + initCobra() +} +func initConfig() { + // we can do more stuff in here. +} + +func before(cmd *cobra.Command, args []string) error { // Set log level; if not log-level is provided, default to error logLevel := MainGlobalOpts.LogLevel if logLevel == "" { @@ -134,6 +142,7 @@ func before(cmd *cobra.Command, args []string) error { logrus.Info("running as rootless") } setUMask() + return profileOn(cmd) } @@ -170,3 +179,12 @@ func main() { CheckForRegistries() os.Exit(exitCode) } + +func getDefaultContainerConfig() *config.Config { + defaultContainerConfig, err := config.Default() + if err != nil { + logrus.Error(err) + os.Exit(1) + } + return defaultContainerConfig +} |