Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
go_version: ['1.24']
go_version: ['1.25']
os: [ubuntu-latest, windows-latest, macos-latest]
env:
OS: ${{ matrix.os }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ jobs:
- name: Set up Go (latest version)
uses: actions/setup-go@v5
with:
go-version: '>=1.24.0'
go-version: '>=1.25.0'
check-latest: true

# Initializes the CodeQL tools for scanning.
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/doc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: ~1.24
go-version: ~1.25

- name: Check configuration snippets in documentation
run: go run ./config/checkdoc -r docs/content -i changelog.md
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: ~1.24
go-version: ~1.25
check-latest: true

- name: Set up QEMU
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release-doc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: ~1.24
go-version: ~1.25

- name: Check configuration snippets in documentation
run: go run ./config/checkdoc -r docs/content -i changelog.md
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: ~1.24
go-version: ~1.25
check-latest: true

- name: Set up QEMU
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/snapshot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: ~1.24
go-version: ~1.25
check-latest: true

- name: Set up QEMU
Expand Down
2 changes: 1 addition & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ linters:
- gocheckcompilerdirectives
- gochecksumtype
# - gocritic
# - godoclint
- godoclint
- goheader
- gomoddirectives
- gosec
Expand Down
2 changes: 1 addition & 1 deletion commands_display.go
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@ func (l *lineLengthWriter) Write(p []byte) (n int, err error) {
n += written + 1

_, _ = l.writer.Write(l.tokens[1:]) // write break (instead of WS at lastWhiteIndex)
for j := 0; j < l.breakLength; j++ {
for range l.breakLength {
_, _ = l.writer.Write(l.tokens[0:1]) // fill spaces for alignment
}

Expand Down
4 changes: 2 additions & 2 deletions darwin/calendar_interval.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func (c *CalendarInterval) clone() *CalendarInterval {
return clone
}

// getCalendarIntervalsFromSchedules converts schedules into launchd calendar events
// GetCalendarIntervalsFromSchedules converts schedules into launchd calendar events
// let's say we've setup these rules:
//
// Mon-Fri *-*-* *:0,30:00 = every half hour
Expand Down Expand Up @@ -114,7 +114,7 @@ func setCalendarIntervalValueFromType(entry *CalendarInterval, value int, typeVa
}
}

// parseCalendarIntervals converts calendar intervals into a single calendar event.
// ParseCalendarIntervals converts calendar intervals into a single calendar event.
// TODO: find a pattern on how to split into multiple events when needed
func ParseCalendarIntervals(intervals []CalendarInterval) []string {
event := calendar.NewEvent(func(e *calendar.Event) {
Expand Down
2 changes: 1 addition & 1 deletion flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func envValueOverride[T any](defaultValue T, keys ...string) T {
v = value
}
if err == nil {
defaultValue = v.(T)
defaultValue = v.(T) //nolint:forcetypeassert
} else {
clog.Errorf("cannot convert env variable %s=%q: %s", key, value, err.Error())
}
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/creativeprojects/resticprofile

go 1.24.7
go 1.25.1

require (
github.com/Masterminds/semver/v3 v3.4.0
Expand Down
28 changes: 16 additions & 12 deletions lock/lock_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -268,53 +268,57 @@ func TestLockWithNoInterruption(t *testing.T) {
}

func TestLockIsRemovedAfterInterruptSignal(t *testing.T) {
t.Parallel()

if platform.IsWindows() {
t.Skip("cannot send a signal to a child process in Windows")
}
t.Parallel()
lockfile := getTempfile(t)

var err error
buffer := &bytes.Buffer{}
cmd := exec.Command(helperBinary, "-wait", "2000", "-lock", lockfile)
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer cancel()

cmd := exec.CommandContext(ctx, helperBinary, "-wait", "2000", "-lock", lockfile)
cmd.Stdout = buffer
cmd.Stderr = buffer

err = cmd.Start()
require.NoError(t, err)
require.NoError(t, err, "starting child process")

time.Sleep(300 * time.Millisecond)
err = cmd.Process.Signal(syscall.SIGINT)
require.NoError(t, err)
require.NoError(t, err, "sending interrupt signal to child process")

err = cmd.Wait()
assert.NoError(t, err)
assert.NoError(t, err, "waiting for child process to finish")
assert.Equal(t, "lock acquired\ntask interrupted\nlock released\n", buffer.String())
}

func TestLockIsRemovedAfterInterruptSignalInsideShell(t *testing.T) {
t.Parallel()

if platform.IsWindows() {
t.Skip("cannot send a signal to a child process in Windows")
}
t.Parallel()
lockfile := getTempfile(t)

var err error
buffer := &bytes.Buffer{}
cmd := exec.Command("sh", "-c", "exec "+helperBinary+" -wait 2000 -lock "+lockfile)
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer cancel()

cmd := exec.CommandContext(ctx, "sh", "-c", "exec "+helperBinary+" -wait 2000 -lock "+lockfile)
cmd.Stdout = buffer
cmd.Stderr = buffer

err = cmd.Start()
require.NoError(t, err)
require.NoError(t, err, "starting child process inside a shell")

time.Sleep(300 * time.Millisecond)
err = cmd.Process.Signal(syscall.SIGINT)
require.NoError(t, err)
require.NoError(t, err, "sending interrupt signal to child process")

err = cmd.Wait()
assert.NoError(t, err)
assert.NoError(t, err, "waiting for child process to finish")
assert.Equal(t, "lock acquired\ntask interrupted\nlock released\n", buffer.String())
}
12 changes: 6 additions & 6 deletions lock/test/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,19 @@ func main() {
flag.StringVar(&lockfile, "lock", "test.lock", "Name of the lock file")
flag.Parse()

// Catch CTR-C key
sigChan := make(chan os.Signal, 2)
signal.Notify(sigChan, os.Interrupt, syscall.SIGTERM, syscall.SIGABRT)
// remove signal catch before leaving
defer signal.Stop(sigChan)

l := lock.NewLock(lockfile)
if l.TryAcquire() {
defer func() {
l.Release()
fmt.Println("lock released")
}()

// Catch CTR-C key
sigChan := make(chan os.Signal, 1)
signal.Notify(sigChan, os.Interrupt, syscall.SIGTERM, syscall.SIGABRT)
// remove signal catch before leaving
defer signal.Stop(sigChan)

fmt.Println("lock acquired")

select {
Expand Down
2 changes: 1 addition & 1 deletion mask/mask.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import "regexp"
const maskReplacement = "×××"

var (
// httpHeaderNames = regexp.MustCompile("(?i)^(Authorization)$")
RepositoryConfidentialPart = regexp.MustCompile("[:/][^:/@]+?:([^:@]+?)@[^:/@]+?") // user:pass@host
// httpHeaderNames = regexp.MustCompile("(?i)^(Authorization)$")
// urlEnvKeys = regexp.MustCompile("(?i)^.+(_AUTH|_URL)$")
// hiddenEnvKeys = regexp.MustCompile("(?i)^(.+_KEY|.+_TOKEN|.*PASSWORD.*|.*SECRET.*)$")
)
Expand Down
2 changes: 1 addition & 1 deletion schedule/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func (s *Config) SetCommand(wd, command string, args []string) {
s.Arguments = NewCommandArguments(args)
}

// Priority is either "background" or "standard"
// GetPriority is either "background" or "standard"
func (s *Config) GetPriority() string {
s.Priority = strings.ToLower(s.Priority)
// default value for priority is "standard"
Expand Down
3 changes: 2 additions & 1 deletion schedule/handler_systemd.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ func (h *HandlerSystemd) DisplaySchedules(profile, command string, schedules []s
return displaySystemdSchedules(profile, command, schedules)
}

// DisplayStatus displays the status of all the timers installed on that profile. Example:
// Timers summary
// ===============
// NEXT LEFT LAST PASSED UNIT ACTIVATES
Expand Down Expand Up @@ -318,7 +319,7 @@ func (h *HandlerSystemd) Scheduled(profileName string) ([]Config, error) {
return configs, nil
}

// detectSchedulePermission returns the permission defined from the configuration,
// DetectSchedulePermission returns the permission defined from the configuration,
// or the best guess considering the current user permission.
// safe specifies whether a guess may lead to a too broad or too narrow file access permission.
func (h *HandlerSystemd) DetectSchedulePermission(p Permission) (Permission, bool) {
Expand Down
4 changes: 2 additions & 2 deletions schedule/handler_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ func (h *HandlerWindows) RemoveJob(job *Config, _ Permission) error {
return nil
}

// DisplayStatus display some information about the task scheduler job
// DisplayJobStatus display some information about the task scheduler job
func (h *HandlerWindows) DisplayJobStatus(job *Config) error {
err := schtasks.Status(job.ProfileName, job.CommandName)
if err != nil {
Expand Down Expand Up @@ -139,7 +139,7 @@ func (h *HandlerWindows) Scheduled(profileName string) ([]Config, error) {
return configs, nil
}

// detectSchedulePermission returns the permission defined from the configuration,
// DetectSchedulePermission returns the permission defined from the configuration,
// or the best guess considering the current user permission.
// safe specifies whether a guess may lead to a too broad or too narrow file access permission.
func (h *HandlerWindows) DetectSchedulePermission(permission Permission) (Permission, bool) {
Expand Down
4 changes: 2 additions & 2 deletions schtasks/principal.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ type Principal struct {
RunLevel RunLevel `xml:"RunLevel,omitempty"`
}

// LongType specifies the security logon method required to run those tasks associated with the principal.
// LogonType specifies the security logon method required to run those tasks associated with the principal.
// https://learn.microsoft.com/en-us/windows/win32/taskschd/taskschedulerschema-logontype-principaltype-element
type LogonType string

Expand All @@ -25,7 +25,7 @@ const (
LogonTypeInteractiveToken LogonType = "InteractiveToken" // User must already be logged on. The task will be run only in an existing interactive session.
)

// The identifier that is used to specify the privilege level that is required to run the tasks that are associated with the principal.
// RunLevel is the identifier that is used to specify the privilege level that is required to run the tasks that are associated with the principal.
// https://learn.microsoft.com/en-us/windows/win32/taskschd/taskschedulerschema-runleveltype-simpletype
type RunLevel string

Expand Down
2 changes: 1 addition & 1 deletion schtasks/settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ type IdleSettings struct {
WaitTimeout period.Period `xml:"WaitTimeout"` // the amount of time that the Task Scheduler will wait for an idle condition to occur
}

// For scripting, gets or sets an integer value that indicates which version of Task Scheduler a task is compatible with.
// Compatibility is an integer value that indicates which version of Task Scheduler a task is compatible with.
type Compatibility int

const (
Expand Down
2 changes: 2 additions & 0 deletions schtasks/taskscheduler.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
//go:build windows

// Package schtasks
//
// Schedule types on Windows:
// ==========================
// 1. one time:
Expand Down
4 changes: 2 additions & 2 deletions shell/arg.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ func (a Arg) Clone() Arg {
}
}

// IsEmpty means the flag is specifically empty, not just a flag without a value
// IsEmptyValue means the flag is specifically empty, not just a flag without a value
// (e.g. --flag="")
func (a Arg) IsEmptyValue() bool {
return a.empty
Expand All @@ -84,7 +84,7 @@ func (a Arg) HasValue() bool {
return a.empty || a.value != ""
}

// IsConfidential returns true if the argument may contain credentials.
// HasConfidentialFilter returns true if the argument may contain credentials.
func (a Arg) HasConfidentialFilter() bool {
return a.confidentialFilter != nil
}
Expand Down
2 changes: 1 addition & 1 deletion term/term.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ func OsStdoutIsTerminal() bool {
return term.IsTerminal(fd)
}

// OsStdoutIsTerminal returns true as os.Stdout is a terminal session
// OsStdoutTerminalSize returns true as os.Stdout is a terminal session
func OsStdoutTerminalSize() (width, height int) {
fd := fdToInt(os.Stdout.Fd())
var err error
Expand Down
Loading