mirror of
https://github.com/mudler/luet.git
synced 2025-09-03 08:14:46 +00:00
@@ -109,10 +109,12 @@ func init() {
|
||||
pflags := RootCmd.PersistentFlags()
|
||||
pflags.StringVar(&cfgFile, "config", "", "config file (default is $HOME/.luet.yaml)")
|
||||
pflags.BoolVarP(&Verbose, "verbose", "v", false, "verbose output")
|
||||
pflags.Bool("fatal", false, "Enables Warnings to exit")
|
||||
pflags.Int("concurrency", runtime.NumCPU(), "Concurrency")
|
||||
|
||||
config.LuetCfg.Viper.BindPFlag("general.debug", pflags.Lookup("verbose"))
|
||||
config.LuetCfg.Viper.BindPFlag("general.concurrency", pflags.Lookup("concurrency"))
|
||||
config.LuetCfg.Viper.BindPFlag("general.fatal_warnings", pflags.Lookup("fatal"))
|
||||
}
|
||||
|
||||
// initConfig reads in config file and ENV variables if set.
|
||||
|
@@ -32,6 +32,9 @@
|
||||
# Define spinner charset. See https://github.com/briandowns/spinner
|
||||
# spinner_charset: 22
|
||||
#
|
||||
# Enable warnings to exit
|
||||
# fatal_warnings: false
|
||||
#
|
||||
# ---------------------------------------------
|
||||
# System configuration section:
|
||||
# ---------------------------------------------
|
||||
|
@@ -335,13 +335,11 @@ func (cs *LuetCompiler) compileWithImage(image, buildertaggedImage, packageImage
|
||||
// TODO: Handle caching and optionally do not remove things
|
||||
err = cs.Backend.RemoveImage(builderOpts)
|
||||
if err != nil {
|
||||
// TODO: Have a --fatal flag which enables Warnings to exit.
|
||||
Warning("Could not remove image ", builderOpts.ImageName)
|
||||
// return nil, errors.Wrap(err, "Could not remove image")
|
||||
}
|
||||
err = cs.Backend.RemoveImage(runnerOpts)
|
||||
if err != nil {
|
||||
// TODO: Have a --fatal flag which enables Warnings to exit.
|
||||
Warning("Could not remove image ", builderOpts.ImageName)
|
||||
// return nil, errors.Wrap(err, "Could not remove image")
|
||||
}
|
||||
@@ -433,7 +431,6 @@ func (cs *LuetCompiler) packageFromImage(p CompilationSpec, tag string, keepPerm
|
||||
// TODO: Handle caching and optionally do not remove things
|
||||
err = cs.Backend.RemoveImage(builderOpts)
|
||||
if err != nil {
|
||||
// TODO: Have a --fatal flag which enables Warnings to exit.
|
||||
Warning("Could not remove image ", builderOpts.ImageName)
|
||||
// return nil, errors.Wrap(err, "Could not remove image")
|
||||
}
|
||||
|
@@ -38,6 +38,7 @@ type LuetGeneralConfig struct {
|
||||
ShowBuildOutput bool `mapstructure:"show_build_output"`
|
||||
SpinnerMs int `mapstructure:"spinner_ms"`
|
||||
SpinnerCharset int `mapstructure:"spinner_charset"`
|
||||
FatalWarns bool `mapstructure:"fatal_warnings"`
|
||||
}
|
||||
|
||||
type LuetSystemConfig struct {
|
||||
@@ -109,6 +110,7 @@ func GenDefault(viper *v.Viper) {
|
||||
viper.SetDefault("general.show_build_output", false)
|
||||
viper.SetDefault("general.spinner_ms", 100)
|
||||
viper.SetDefault("general.spinner_charset", 22)
|
||||
viper.SetDefault("general.fatal_warnings", false)
|
||||
|
||||
viper.SetDefault("system.database_engine", "boltdb")
|
||||
viper.SetDefault("system.database_path", "/var/cache/luet")
|
||||
@@ -140,9 +142,10 @@ func (c *LuetGeneralConfig) String() string {
|
||||
general:
|
||||
concurrency: %d
|
||||
debug: %t
|
||||
fatal_warnings: %t
|
||||
show_build_output: %t
|
||||
spinner_ms: %d
|
||||
spinner_charset: %d`, c.Concurrency, c.Debug, c.ShowBuildOutput,
|
||||
spinner_charset: %d`, c.Concurrency, c.Debug, c.FatalWarns, c.ShowBuildOutput,
|
||||
c.SpinnerMs, c.SpinnerCharset)
|
||||
|
||||
return ans
|
||||
|
@@ -164,6 +164,9 @@ func msg(level string, msg ...interface{}) {
|
||||
|
||||
func Warning(mess ...interface{}) {
|
||||
msg("warning", mess...)
|
||||
if LuetCfg.GetGeneral().FatalWarns {
|
||||
os.Exit(2)
|
||||
}
|
||||
}
|
||||
|
||||
func Debug(mess ...interface{}) {
|
||||
|
Reference in New Issue
Block a user