fix new lint warnings
Some checks are pending
Code scanning - action / CodeQL-Build (push) Waiting to run
CI / Build Linux packages (amd64, ubuntu:18.04, latest, amd64) (push) Waiting to run
CI / Build Linux packages (armv7, ubuntu18.04, latest, arm7) (push) Waiting to run
CI / Test and deploy (1.22, macos-latest, true) (push) Waiting to run
CI / Test and deploy (1.22, ubuntu-latest, true) (push) Waiting to run
CI / Test and deploy (1.22, windows-latest, false) (push) Waiting to run
CI / Test build flags (push) Waiting to run
CI / Test with PgSQL/MySQL/Cockroach (push) Waiting to run
CI / Build Linux packages (aarch64, ubuntu18.04, latest, arm64) (push) Waiting to run
CI / Build Linux packages (ppc64le, ubuntu18.04, latest, ppc64le) (push) Waiting to run
CI / golangci-lint (push) Waiting to run
Docker / Build (alpine, false, ubuntu-latest) (push) Waiting to run
Docker / Build (alpine, true, ubuntu-latest) (push) Waiting to run
Docker / Build (debian, false, ubuntu-latest) (push) Waiting to run
Docker / Build (debian, true, ubuntu-latest) (push) Waiting to run
Docker / Build (debian-plugins, true, ubuntu-latest) (push) Waiting to run
Docker / Build (distroless, false, ubuntu-latest) (push) Waiting to run

Signed-off-by: Nicola Murino <nicola.murino@gmail.com>
This commit is contained in:
Nicola Murino 2024-08-14 08:46:18 +02:00
parent 6f8bc59756
commit 121d5ae34d
No known key found for this signature in database
GPG key ID: 935D2952DEC4EECF
9 changed files with 25 additions and 26 deletions

View file

@ -269,7 +269,7 @@ func (c *RetentionCheck) cleanupFolder(folderPath string, recursion int) error {
return nil
}
result.Error = fmt.Sprintf("unable to get lister for directory %q", folderPath)
c.conn.Log(logger.LevelError, result.Error)
c.conn.Log(logger.LevelError, "%s", result.Error)
return err
}
defer lister.Close()

View file

@ -9314,7 +9314,7 @@ func printLatestLogs(maxNumberOfLines int) {
return
}
for _, line := range lines {
logger.DebugToConsole(line)
logger.DebugToConsole("%s", line)
}
}

View file

@ -2568,9 +2568,8 @@ func createProvider(basePath string) error {
return initializeBoltProvider(basePath)
case MemoryDataProviderName:
if err := initializeMemoryProvider(basePath); err != nil {
msg := fmt.Sprintf("provider initialized but data loading failed: %v", err)
logger.Warn(logSender, "", msg)
logger.WarnToConsole(msg)
logger.Warn(logSender, "", "provider initialized but data loading failed: %v", err)
logger.WarnToConsole("provider initialized but data loading failed: %v", err)
}
return nil
default:

View file

@ -2544,14 +2544,14 @@ func TestRename(t *testing.T) {
assert.NoError(t, err)
err = client.MakeDir(path.Join(otherDir, testDir))
assert.NoError(t, err)
code, response, err := client.SendCommand(fmt.Sprintf("SITE CHMOD 0001 %v", otherDir))
code, response, err := client.SendCommand("SITE CHMOD 0001 %v", otherDir)
assert.NoError(t, err)
assert.Equal(t, ftp.StatusCommandOK, code)
assert.Equal(t, "SITE CHMOD command successful", response)
err = client.Rename(testDir, path.Join(otherDir, testDir))
assert.Error(t, err)
code, response, err = client.SendCommand(fmt.Sprintf("SITE CHMOD 755 %v", otherDir))
code, response, err = client.SendCommand("SITE CHMOD 755 %v", otherDir)
assert.NoError(t, err)
assert.Equal(t, ftp.StatusCommandOK, code)
assert.Equal(t, "SITE CHMOD command successful", response)
@ -2611,7 +2611,7 @@ func TestSymlink(t *testing.T) {
assert.NoError(t, err)
err = ftpUploadFile(testFilePath, testFileName, testFileSize, client, 0)
assert.NoError(t, err)
code, _, err := client.SendCommand(fmt.Sprintf("SITE SYMLINK %v %v", testFileName, testFileName+".link"))
code, _, err := client.SendCommand("SITE SYMLINK %v %v", testFileName, testFileName+".link")
assert.NoError(t, err)
assert.Equal(t, ftp.StatusCommandOK, code)
@ -2622,15 +2622,15 @@ func TestSymlink(t *testing.T) {
assert.NoError(t, err)
err = client.MakeDir(path.Join(otherDir, testDir))
assert.NoError(t, err)
code, response, err := client.SendCommand(fmt.Sprintf("SITE CHMOD 0001 %v", otherDir))
code, response, err := client.SendCommand("SITE CHMOD 0001 %v", otherDir)
assert.NoError(t, err)
assert.Equal(t, ftp.StatusCommandOK, code)
assert.Equal(t, "SITE CHMOD command successful", response)
code, _, err = client.SendCommand(fmt.Sprintf("SITE SYMLINK %v %v", testDir, path.Join(otherDir, testDir)))
code, _, err = client.SendCommand("SITE SYMLINK %v %v", testDir, path.Join(otherDir, testDir))
assert.NoError(t, err)
assert.Equal(t, ftp.StatusFileUnavailable, code)
code, response, err = client.SendCommand(fmt.Sprintf("SITE CHMOD 755 %v", otherDir))
code, response, err = client.SendCommand("SITE CHMOD 755 %v", otherDir)
assert.NoError(t, err)
assert.Equal(t, ftp.StatusCommandOK, code)
assert.Equal(t, "SITE CHMOD command successful", response)
@ -3051,7 +3051,7 @@ func TestChtimes(t *testing.T) {
assert.NoError(t, err)
mtime := time.Now().Format("20060102150405")
code, response, err := client.SendCommand(fmt.Sprintf("MFMT %v %v", mtime, testFileName))
code, response, err := client.SendCommand("MFMT %v %v", mtime, testFileName)
assert.NoError(t, err)
assert.Equal(t, ftp.StatusFile, code)
assert.Equal(t, fmt.Sprintf("Modify=%v; %v", mtime, testFileName), response)
@ -3128,7 +3128,7 @@ func TestSTAT(t *testing.T) {
assert.NoError(t, err)
err = ftpUploadFile(testFilePath, path.Join(testDir, testFileName+"_1"), testFileSize, client, 0)
assert.NoError(t, err)
code, response, err := client.SendCommand(fmt.Sprintf("STAT %s", testDir))
code, response, err := client.SendCommand("STAT %s", testDir)
assert.NoError(t, err)
assert.Equal(t, ftp.StatusDirectory, code)
assert.Contains(t, response, fmt.Sprintf("STAT %s", testDir))
@ -3162,7 +3162,7 @@ func TestChown(t *testing.T) {
assert.NoError(t, err)
err = ftpUploadFile(testFilePath, testFileName, testFileSize, client, 0)
assert.NoError(t, err)
code, response, err := client.SendCommand(fmt.Sprintf("SITE CHOWN 1000:1000 %v", testFileName))
code, response, err := client.SendCommand("SITE CHOWN 1000:1000 %v", testFileName)
assert.NoError(t, err)
assert.Equal(t, ftp.StatusFileUnavailable, code)
assert.Equal(t, "Couldn't chown: operation unsupported", response)
@ -3200,7 +3200,7 @@ func TestChmod(t *testing.T) {
err = ftpUploadFile(testFilePath, testFileName, testFileSize, client, 0)
assert.NoError(t, err)
code, response, err := client.SendCommand(fmt.Sprintf("SITE CHMOD 600 %v", testFileName))
code, response, err := client.SendCommand("SITE CHMOD 600 %v", testFileName)
assert.NoError(t, err)
assert.Equal(t, ftp.StatusCommandOK, code)
assert.Equal(t, "SITE CHMOD command successful", response)
@ -3363,12 +3363,12 @@ func TestHASH(t *testing.T) {
err = f.Close()
assert.NoError(t, err)
code, response, err := client.SendCommand(fmt.Sprintf("XSHA256 %v", testFileName))
code, response, err := client.SendCommand("XSHA256 %v", testFileName)
assert.NoError(t, err)
assert.Equal(t, ftp.StatusRequestedFileActionOK, code)
assert.Contains(t, response, hash)
code, response, err = client.SendCommand(fmt.Sprintf("HASH %v", testFileName))
code, response, err = client.SendCommand("HASH %v", testFileName)
assert.NoError(t, err)
assert.Equal(t, ftp.StatusFile, code)
assert.Contains(t, response, hash)
@ -3424,7 +3424,7 @@ func TestCombine(t *testing.T) {
err = ftpUploadFile(testFilePath, testFileName+".2", testFileSize, client, 0)
assert.NoError(t, err)
code, response, err := client.SendCommand(fmt.Sprintf("COMB %v %v %v", testFileName, testFileName+".1", testFileName+".2"))
code, response, err := client.SendCommand("COMB %v %v %v", testFileName, testFileName+".1", testFileName+".2")
assert.NoError(t, err)
if user.Username == defaultUsername {
assert.Equal(t, ftp.StatusRequestedFileActionOK, code)

View file

@ -28,10 +28,10 @@ type LegoAdapter struct {
// Fatal emits a log at Error level
func (l *LegoAdapter) Fatal(args ...any) {
if l.LogToConsole {
ErrorToConsole(fmt.Sprint(args...))
ErrorToConsole("%s", fmt.Sprint(args...))
return
}
Log(LevelError, legoLogSender, "", fmt.Sprint(args...))
Log(LevelError, legoLogSender, "", "%s", fmt.Sprint(args...))
}
// Fatalln is the same as Fatal
@ -51,10 +51,10 @@ func (l *LegoAdapter) Fatalf(format string, args ...any) {
// Print emits a log at Info level
func (l *LegoAdapter) Print(args ...any) {
if l.LogToConsole {
InfoToConsole(fmt.Sprint(args...))
InfoToConsole("%s", fmt.Sprint(args...))
return
}
Log(LevelInfo, legoLogSender, "", fmt.Sprint(args...))
Log(LevelInfo, legoLogSender, "", "%s", fmt.Sprint(args...))
}
// Println is the same as Print

View file

@ -284,7 +284,7 @@ func (l *StdLoggerWrapper) Write(p []byte) (n int, err error) {
p = p[0 : n-1]
}
Log(LevelError, l.Sender, "", bytesToString(p))
Log(LevelError, l.Sender, "", "%s", bytesToString(p))
return
}

View file

@ -104,7 +104,7 @@ func (s *Service) Start(disableAWSInstallationCode bool) error {
}
}
if !config.HasServicesToStart() {
infoString := "no service configured, nothing to do"
const infoString = "no service configured, nothing to do"
logger.Info(logSender, "", infoString)
logger.InfoToConsole(infoString)
return errors.New(infoString)

View file

@ -11785,7 +11785,7 @@ func printLatestLogs(maxNumberOfLines int) {
return
}
for _, line := range lines {
logger.DebugToConsole(line)
logger.DebugToConsole("%s", line)
}
}

View file

@ -3547,6 +3547,6 @@ func printLatestLogs(maxNumberOfLines int) {
return
}
for _, line := range lines {
logger.DebugToConsole(line)
logger.DebugToConsole("%s", line)
}
}