inline some conditionals

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
This commit is contained in:
Paul Holzinger
2025-09-09 13:41:23 +02:00
parent 8631032556
commit 78e5a521b0
3 changed files with 4 additions and 10 deletions

View File

@ -445,7 +445,6 @@ func configHook() {
}
func loggingHook() {
var found bool
if debug {
if logLevel != defaultLogLevel {
fmt.Fprintf(os.Stderr, "Setting --log-level and --debug is not allowed\n")
@ -453,10 +452,8 @@ func loggingHook() {
}
logLevel = "debug"
}
if slices.Contains(common.LogLevels, strings.ToLower(logLevel)) {
found = true
}
if !found {
if !slices.Contains(common.LogLevels, strings.ToLower(logLevel)) {
fmt.Fprintf(os.Stderr, "Log Level %q is not supported, choose from: %s\n", logLevel, strings.Join(common.LogLevels, ", "))
os.Exit(1)
}

View File

@ -131,8 +131,7 @@ func (c *Container) Commit(ctx context.Context, destImage string, options Contai
// Only include anonymous named volumes added by the user by
// default.
for _, v := range c.config.NamedVolumes {
include := slices.Contains(c.config.UserVolumes, v.Dest)
if include {
if slices.Contains(c.config.UserVolumes, v.Dest) {
vol, err := c.runtime.GetVolume(v.Name)
if err != nil {
return nil, fmt.Errorf("volume %s used in container %s has been removed: %w", v.Name, c.ID(), err)

View File

@ -107,9 +107,7 @@ func validatePlugin(newPlugin *VolumePlugin) error {
return fmt.Errorf("unmarshalling plugin %s activation response: %w", newPlugin.Name, err)
}
foundVolume := slices.Contains(respStruct.Implements, volumePluginType)
if !foundVolume {
if !slices.Contains(respStruct.Implements, volumePluginType) {
return fmt.Errorf("plugin %s does not implement volume plugin, instead provides %s: %w", newPlugin.Name, strings.Join(respStruct.Implements, ", "), ErrNotVolumePlugin)
}