Fix lint issues

This commit is contained in:
Christopher Meng
2026-06-24 15:26:02 -04:00
committed by Christopher Meng
parent d5e0c2bb89
commit 6b0571b598
2 changed files with 9 additions and 12 deletions
+7 -10
View File
@@ -302,14 +302,11 @@ func buildArgsForConfig(c *cli.Context, log *zerolog.Logger) ([]string, error) {
return err == nil && val != ""
}
if src.TunnelID == "" || !configPresent(tunnel.CredFileFlag) {
return nil, fmt.Errorf(`Configuration file %s must contain entries for the tunnel to run and its associated credentials:
tunnel: TUNNEL-UUID
credentials-file: CREDENTIALS-FILE
`, src.Source())
return nil, fmt.Errorf("configuration file %s must contain entries for the tunnel to run and its associated credentials (tunnel: TUNNEL-UUID, credentials-file: CREDENTIALS-FILE)", src.Source())
}
if src.Source() != serviceConfigPath {
if exists, err := config.FileExists(serviceConfigPath); err != nil || exists {
return nil, fmt.Errorf("Possible conflicting configuration in %[1]s and %[2]s. Either remove %[2]s or run `cloudflared --config %[2]s service install`", src.Source(), serviceConfigPath)
return nil, fmt.Errorf("possible conflicting configuration in %[1]s and %[2]s. Either remove %[2]s or run `cloudflared --config %[2]s service install`", src.Source(), serviceConfigPath)
}
if err := copyFile(src.Source(), serviceConfigPath); err != nil {
@@ -527,25 +524,25 @@ func uninstallOpenRC(log *zerolog.Logger) error {
func ensureConfigDirExists(configDir string) error {
ok, err := config.FileExists(configDir)
if !ok && err == nil {
err = os.Mkdir(configDir, 0o755)
err = os.Mkdir(configDir, 0o755) //nolint:gosec // config dir must be traversable by a non-root service user
}
return err
}
func copyFile(src, dest string) error {
srcFile, err := os.Open(src)
srcFile, err := os.Open(src) //nolint:gosec // operator-provided service config path
if err != nil {
return err
}
defer srcFile.Close()
defer func() { _ = srcFile.Close() }()
destFile, err := os.Create(dest)
destFile, err := os.Create(dest) //nolint:gosec // operator-provided service config path
if err != nil {
return err
}
ok := false
defer func() {
destFile.Close()
_ = destFile.Close()
if !ok {
_ = os.Remove(dest)
}
+2 -2
View File
@@ -112,10 +112,10 @@ func CheckForUpdate(options updateOptions) (CheckResult, error) {
func encodeWindowsPath(path string) string {
// We do this because Windows allows spaces in directories such as
// Program Files but does not allow these directories to be spaced in batch files.
targetPath := strings.Replace(path, "Program Files (x86)", "PROGRA~2", -1)
targetPath := strings.ReplaceAll(path, "Program Files (x86)", "PROGRA~2")
// This is to do the same in 32 bit systems. We do this second so that the first
// replace is for x86 dirs.
targetPath = strings.Replace(targetPath, "Program Files", "PROGRA~1", -1)
targetPath = strings.ReplaceAll(targetPath, "Program Files", "PROGRA~1")
return targetPath
}