mirror of
https://github.com/containers/podman.git
synced 2025-11-30 10:07:33 +08:00
run modernize -fix ./...
Using golang.org/x/tools/gopls/internal/analysis/modernize/cmd/modernize + some manual cleanup in libpod/lock/shm/shm_lock_test.go as it generated an unused variable + restored one removed comment Signed-off-by: Paul Holzinger <pholzing@redhat.com>
This commit is contained in:
@@ -38,7 +38,7 @@ func ExitWithErrorRegex(expectExitCode int, expectStderrRegex string) *ExitMatch
|
||||
}
|
||||
|
||||
// Match follows gexec.Matcher interface.
|
||||
func (matcher *ExitMatcher) Match(actual interface{}) (success bool, err error) {
|
||||
func (matcher *ExitMatcher) Match(actual any) (success bool, err error) {
|
||||
session, ok := actual.(podmanSession)
|
||||
if !ok {
|
||||
return false, fmt.Errorf("ExitWithError must be passed a gexec.Exiter (Missing method ExitCode() int) Got:\n#{format.Object(actual, 1)}")
|
||||
@@ -83,15 +83,15 @@ func (matcher *ExitMatcher) Match(actual interface{}) (success bool, err error)
|
||||
return true, nil
|
||||
}
|
||||
|
||||
func (matcher *ExitMatcher) FailureMessage(_ interface{}) (message string) {
|
||||
func (matcher *ExitMatcher) FailureMessage(_ any) (message string) {
|
||||
return matcher.msg
|
||||
}
|
||||
|
||||
func (matcher *ExitMatcher) NegatedFailureMessage(_ interface{}) (message string) {
|
||||
func (matcher *ExitMatcher) NegatedFailureMessage(_ any) (message string) {
|
||||
panic("There is no conceivable reason to call Not(ExitWithError) !")
|
||||
}
|
||||
|
||||
func (matcher *ExitMatcher) MatchMayChangeInTheFuture(actual interface{}) bool {
|
||||
func (matcher *ExitMatcher) MatchMayChangeInTheFuture(actual any) bool {
|
||||
session, ok := actual.(*gexec.Session)
|
||||
if ok {
|
||||
return session.ExitCode() == -1
|
||||
@@ -109,7 +109,7 @@ type exitCleanlyMatcher struct {
|
||||
msg string
|
||||
}
|
||||
|
||||
func (matcher *exitCleanlyMatcher) Match(actual interface{}) (success bool, err error) {
|
||||
func (matcher *exitCleanlyMatcher) Match(actual any) (success bool, err error) {
|
||||
session, ok := actual.(podmanSession)
|
||||
if !ok {
|
||||
return false, fmt.Errorf("ExitCleanly must be passed a PodmanSession; Got:\n %+v\n%q", actual, format.Object(actual, 1))
|
||||
@@ -134,11 +134,11 @@ func (matcher *exitCleanlyMatcher) Match(actual interface{}) (success bool, err
|
||||
return true, nil
|
||||
}
|
||||
|
||||
func (matcher *exitCleanlyMatcher) FailureMessage(_ interface{}) (message string) {
|
||||
func (matcher *exitCleanlyMatcher) FailureMessage(_ any) (message string) {
|
||||
return matcher.msg
|
||||
}
|
||||
|
||||
func (matcher *exitCleanlyMatcher) NegatedFailureMessage(_ interface{}) (message string) {
|
||||
func (matcher *exitCleanlyMatcher) NegatedFailureMessage(_ any) (message string) {
|
||||
// FIXME - I see no situation in which we could ever want this?
|
||||
return matcher.msg + " (NOT!)"
|
||||
}
|
||||
@@ -151,23 +151,23 @@ func BeValidJSON() *ValidJSONMatcher {
|
||||
return &ValidJSONMatcher{}
|
||||
}
|
||||
|
||||
func (matcher *ValidJSONMatcher) Match(actual interface{}) (success bool, err error) {
|
||||
func (matcher *ValidJSONMatcher) Match(actual any) (success bool, err error) {
|
||||
s, ok := actual.(string)
|
||||
if !ok {
|
||||
return false, fmt.Errorf("ValidJSONMatcher expects a string, not %q", actual)
|
||||
}
|
||||
|
||||
var i interface{}
|
||||
var i any
|
||||
if err := json.Unmarshal([]byte(s), &i); err != nil {
|
||||
return false, err
|
||||
}
|
||||
return true, nil
|
||||
}
|
||||
|
||||
func (matcher *ValidJSONMatcher) FailureMessage(actual interface{}) (message string) {
|
||||
func (matcher *ValidJSONMatcher) FailureMessage(actual any) (message string) {
|
||||
return format.Message(actual, "to be valid JSON")
|
||||
}
|
||||
|
||||
func (matcher *ValidJSONMatcher) NegatedFailureMessage(actual interface{}) (message string) {
|
||||
func (matcher *ValidJSONMatcher) NegatedFailureMessage(actual any) (message string) {
|
||||
return format.Message(actual, "to _not_ be valid JSON")
|
||||
}
|
||||
|
||||
@@ -165,7 +165,7 @@ func (p *PodmanTest) PodmanExecBaseWithOptions(args []string, options PodmanExec
|
||||
|
||||
// WaitForContainer waits on a started container
|
||||
func (p *PodmanTest) WaitForContainer() bool {
|
||||
for i := 0; i < 10; i++ {
|
||||
for range 10 {
|
||||
if p.NumberOfContainersRunning() > 0 {
|
||||
return true
|
||||
}
|
||||
@@ -376,7 +376,7 @@ func (s *PodmanSession) LineInOutputContainsTag(repo, tag string) bool {
|
||||
// IsJSONOutputValid attempts to unmarshal the session buffer
|
||||
// and if successful, returns true, else false
|
||||
func (s *PodmanSession) IsJSONOutputValid() bool {
|
||||
var i interface{}
|
||||
var i any
|
||||
if err := json.Unmarshal(s.Out.Contents(), &i); err != nil {
|
||||
GinkgoWriter.Println(err)
|
||||
return false
|
||||
@@ -438,7 +438,7 @@ func tagOutputToMap(imagesOutput []string) map[string]map[string]bool {
|
||||
// iterate over output but skip the header
|
||||
for _, i := range imagesOutput[1:] {
|
||||
tmp := []string{}
|
||||
for _, x := range strings.Split(i, " ") {
|
||||
for x := range strings.SplitSeq(i, " ") {
|
||||
if x != "" {
|
||||
tmp = append(tmp, x)
|
||||
}
|
||||
@@ -487,7 +487,7 @@ func IsCommandAvailable(command string) bool {
|
||||
|
||||
// WriteJSONFile write json format data to a json file
|
||||
func WriteJSONFile(data []byte, filePath string) error {
|
||||
var jsonData map[string]interface{}
|
||||
var jsonData map[string]any
|
||||
if err := json.Unmarshal(data, &jsonData); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user