mirror of
https://github.com/podman-container-tools/podman.git
synced 2026-08-06 00:45:43 +00:00
The linter ensures a common code style. - use switch/case instead of else if - use if instead of switch/case for single case statement - add space between comment and text - detect the use of defer with os.Exit() - use short form var += "..." instead of var = var + "..." - detect problems with append() ``` newSlice := append(orgSlice, val) ``` This could lead to nasty bugs because the orgSlice will be changed in place if it has enough capacity too hold the new elements. Thus we newSlice might not be a copy. Of course most of the changes are just cosmetic and do not cause any logic errors but I think it is a good idea to enforce a common style. This should help maintainability. Signed-off-by: Paul Holzinger <pholzing@redhat.com>
44 lines
1 KiB
Go
44 lines
1 KiB
Go
package utils
|
|
|
|
import "github.com/spf13/pflag"
|
|
|
|
// AliasFlags is a function to handle backwards compatibility with old flags
|
|
func AliasFlags(f *pflag.FlagSet, name string) pflag.NormalizedName {
|
|
switch name {
|
|
case "healthcheck-command":
|
|
name = "health-cmd"
|
|
case "healthcheck-interval":
|
|
name = "health-interval"
|
|
case "healthcheck-retries":
|
|
name = "health-retries"
|
|
case "healthcheck-start-period":
|
|
name = "health-start-period"
|
|
case "healthcheck-timeout":
|
|
name = "health-timeout"
|
|
case "net":
|
|
name = "network"
|
|
case "namespace":
|
|
name = "ns"
|
|
case "storage":
|
|
name = "external"
|
|
case "purge":
|
|
name = "rm"
|
|
case "notruncate":
|
|
name = "no-trunc"
|
|
case "override-arch":
|
|
name = "arch"
|
|
case "override-os":
|
|
name = "os"
|
|
case "override-variant":
|
|
name = "variant"
|
|
}
|
|
return pflag.NormalizedName(name)
|
|
}
|
|
|
|
// TimeoutAliasFlags is a function to handle backwards compatibility with old timeout flags
|
|
func TimeoutAliasFlags(f *pflag.FlagSet, name string) pflag.NormalizedName {
|
|
if name == "timeout" {
|
|
name = "time"
|
|
}
|
|
return pflag.NormalizedName(name)
|
|
}
|