mirror of
https://github.com/containers/podman.git
synced 2025-06-20 17:13:43 +08:00
build: move initialization after SetXdgDirs
otherwise it triggers the config file initialization from vendor/github.com/containers/common/pkg/config before the init() in main.go can set correctly XDG_RUNTIME_DIR and DBUS_SESSION_BUS_ADDRESS when they are missing. commit 96de762eedd1470dfbe73cf424eea848589268d7 introduced the regression. Closes: https://github.com/containers/libpod/issues/5314 Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
This commit is contained in:
@ -53,13 +53,12 @@ var (
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func initBuild() {
|
||||||
buildCommand.Command = _buildCommand
|
buildCommand.Command = _buildCommand
|
||||||
buildCommand.SetHelpTemplate(HelpTemplate())
|
buildCommand.SetHelpTemplate(HelpTemplate())
|
||||||
buildCommand.SetUsageTemplate(UsageTemplate())
|
buildCommand.SetUsageTemplate(UsageTemplate())
|
||||||
flags := buildCommand.Flags()
|
flags := buildCommand.Flags()
|
||||||
flags.SetInterspersed(true)
|
flags.SetInterspersed(true)
|
||||||
|
|
||||||
budFlags := buildahcli.GetBudFlags(&budFlagsValues)
|
budFlags := buildahcli.GetBudFlags(&budFlagsValues)
|
||||||
flag := budFlags.Lookup("pull")
|
flag := budFlags.Lookup("pull")
|
||||||
if err := flag.Value.Set("true"); err != nil {
|
if err := flag.Value.Set("true"); err != nil {
|
||||||
|
@ -83,7 +83,7 @@ var rootCmd = &cobra.Command{
|
|||||||
|
|
||||||
var MainGlobalOpts cliconfig.MainFlags
|
var MainGlobalOpts cliconfig.MainFlags
|
||||||
|
|
||||||
func init() {
|
func initCobra() {
|
||||||
cobra.OnInitialize(initConfig)
|
cobra.OnInitialize(initConfig)
|
||||||
rootCmd.TraverseChildren = true
|
rootCmd.TraverseChildren = true
|
||||||
rootCmd.Version = version.Version
|
rootCmd.Version = version.Version
|
||||||
@ -94,16 +94,20 @@ func init() {
|
|||||||
rootCmd.AddCommand(getMainCommands()...)
|
rootCmd.AddCommand(getMainCommands()...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
if err := libpod.SetXdgDirs(); err != nil {
|
||||||
|
logrus.Errorf(err.Error())
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
|
initBuild()
|
||||||
|
initCobra()
|
||||||
|
}
|
||||||
|
|
||||||
func initConfig() {
|
func initConfig() {
|
||||||
// we can do more stuff in here.
|
// we can do more stuff in here.
|
||||||
}
|
}
|
||||||
|
|
||||||
func before(cmd *cobra.Command, args []string) error {
|
func before(cmd *cobra.Command, args []string) error {
|
||||||
if err := libpod.SetXdgDirs(); err != nil {
|
|
||||||
logrus.Errorf(err.Error())
|
|
||||||
os.Exit(1)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Set log level; if not log-level is provided, default to error
|
// Set log level; if not log-level is provided, default to error
|
||||||
logLevel := MainGlobalOpts.LogLevel
|
logLevel := MainGlobalOpts.LogLevel
|
||||||
if logLevel == "" {
|
if logLevel == "" {
|
||||||
|
Reference in New Issue
Block a user