From f8603425d199547ce2de4a7a6b59508404a140a2 Mon Sep 17 00:00:00 2001 From: Skye J Date: Thu, 11 Jan 2024 12:52:23 -0500 Subject: [PATCH 1/8] Update installation.md to add AUR back (#348) I have been maintaining the AUR package, so it is no longer deprecated. --- docs/pages/installation.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/pages/installation.md b/docs/pages/installation.md index 244d5c8..21952be 100644 --- a/docs/pages/installation.md +++ b/docs/pages/installation.md @@ -30,4 +30,4 @@ Fedora users can install the [autorestic](https://src.fedoraproject.org/rpms/aut ### AUR -~~If you are on Arch there is an [AUR Package](https://aur.archlinux.org/packages/autorestic-bin/) (looking for maintainers).~~ - Deprecated +If you are on Arch there is an [AUR Package](https://aur.archlinux.org/packages/autorestic-bin/) From 046c79fd151c29d0c6e8ae5c65f07a535e256b28 Mon Sep 17 00:00:00 2001 From: Matthias Liffers Date: Fri, 12 Jan 2024 01:56:35 +0800 Subject: [PATCH 2/8] Add curl to docker image (#344) --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 5a7598b..55f1a77 100644 --- a/Dockerfile +++ b/Dockerfile @@ -7,7 +7,7 @@ COPY . . RUN go build FROM restic/restic:0.16.0 -RUN apk add --no-cache rclone bash +RUN apk add --no-cache rclone bash curl COPY --from=builder /app/autorestic /usr/bin/autorestic ENTRYPOINT [] CMD [ "autorestic" ] From ce9140fa1e1e36070a2dedf6dfa0ac0d8def2f3c Mon Sep 17 00:00:00 2001 From: Christoph Loy Date: Thu, 11 Jan 2024 19:01:59 +0100 Subject: [PATCH 3/8] Fix handling of `XDG_CONFIG_HOME` (#347) --- cmd/root.go | 38 ++++++++++++++++++++------------------ cmd/root_test.go | 36 ++++++++++++++++++++++++++++++++++++ docs/pages/config.md | 3 ++- 3 files changed, 58 insertions(+), 19 deletions(-) create mode 100644 cmd/root_test.go diff --git a/cmd/root.go b/cmd/root.go index fd367a1..3da9e25 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -59,24 +59,7 @@ func initConfig() { os.Exit(1) } } else { - configPaths := []string{"."} - - // Home - if home, err := homedir.Dir(); err == nil { - configPaths = append(configPaths, home) - } - - // XDG_CONFIG_HOME - { - prefix, found := os.LookupEnv("XDG_CONFIG_HOME") - if !found { - if home, err := homedir.Dir(); err != nil { - prefix = filepath.Join(home, ".config") - } - } - xdgConfig := filepath.Join(prefix, "autorestic") - configPaths = append(configPaths, xdgConfig) - } + configPaths := getConfigPaths() for _, cfgPath := range configPaths { viper.AddConfigPath(cfgPath) } @@ -88,3 +71,22 @@ func initConfig() { viper.AutomaticEnv() } } + +func getConfigPaths() []string { + result := []string{"."} + if home, err := homedir.Dir(); err == nil { + result = append(result, home) + } + + { + xdgConfigHome, found := os.LookupEnv("XDG_CONFIG_HOME") + if !found { + if home, err := homedir.Dir(); err == nil { + xdgConfigHome = filepath.Join(home, ".config") + } + } + xdgConfig := filepath.Join(xdgConfigHome, "autorestic") + result = append(result, xdgConfig) + } + return result +} diff --git a/cmd/root_test.go b/cmd/root_test.go new file mode 100644 index 0000000..feabb1b --- /dev/null +++ b/cmd/root_test.go @@ -0,0 +1,36 @@ +package cmd + +import ( + "github.com/mitchellh/go-homedir" + "os" + "path/filepath" + "slices" + "testing" +) + +const xdgConfigHome = "XDG_CONFIG_HOME" + +func assertContains(t *testing.T, array []string, element string) { + if !slices.Contains(array, element) { + t.Errorf("Expected %s to be contained in %s", element, array) + } +} + +func TestConfigResolving(t *testing.T) { + t.Run("~/.config/autorestic is used if XDG_CONFIG_HOME is not set", func(t *testing.T) { + // Override env using testing so that env gets restored after test + t.Setenv(xdgConfigHome, "") + _ = os.Unsetenv("XDG_CONFIG_HOME") + configPaths := getConfigPaths() + homeDir, _ := homedir.Dir() + expectedConfigPath := filepath.Join(homeDir, ".config/autorestic") + assertContains(t, configPaths, expectedConfigPath) + }) + + t.Run("XDG_CONFIG_HOME is respected if set", func(t *testing.T) { + t.Setenv(xdgConfigHome, "/foo/bar") + + configPaths := getConfigPaths() + assertContains(t, configPaths, filepath.Join("/", "foo", "bar", "autorestic")) + }) +} diff --git a/docs/pages/config.md b/docs/pages/config.md index 749fd6c..ce5aec5 100644 --- a/docs/pages/config.md +++ b/docs/pages/config.md @@ -2,10 +2,11 @@ ## Path -By default autorestic searches for a `.autorestic.yml` file in the current directory and your home folder. +By default autorestic searches for a `.autorestic.yml` file in the current directory, your home folder and your XDG config folder (`~/.config/` by default): - `./.autorestic.yml` - `~/.autorestic.yml` +- `~/.config/autorestic/.autorestic.yml` You can also specify a custom file with the `-c path/to/some/config.yml` From ced20801c18d8c1316d00fd99c8d8c19af2afc47 Mon Sep 17 00:00:00 2001 From: Niccolo Borgioli Date: Thu, 11 Jan 2024 19:17:53 +0100 Subject: [PATCH 4/8] bump version --- internal/config.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/config.go b/internal/config.go index 3d8eac4..c223710 100644 --- a/internal/config.go +++ b/internal/config.go @@ -17,7 +17,7 @@ import ( "github.com/spf13/viper" ) -const VERSION = "1.7.9" +const VERSION = "1.7.10" type OptionMap map[string][]interface{} type Options map[string]OptionMap From 24220f6b6291c4f5bb1bbc5d13de02b2a8af372a Mon Sep 17 00:00:00 2001 From: Alexander Zhang <97085527+bkrl@users.noreply.github.com> Date: Fri, 9 Feb 2024 05:18:06 -0800 Subject: [PATCH 5/8] Fix broken link in docs (#350) --- docs/pages/cli/forget.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/pages/cli/forget.md b/docs/pages/cli/forget.md index e3d9f6f..29e7d69 100644 --- a/docs/pages/cli/forget.md +++ b/docs/pages/cli/forget.md @@ -4,7 +4,7 @@ autorestic forget [-l, --location] [-a, --all] [--dry-run] [--prune] ``` -This will prune and remove old data form the backends according to the [keep policy you have specified for the location](/location/forget). +This will prune and remove old data form the backends according to the [keep policy you have specified for the location](/location/options/forget). The `--dry-run` flag will do a dry run showing what would have been deleted, but won't touch the actual data. From b5604b8b9ffc8136df7edf95b0a87e3e9322d872 Mon Sep 17 00:00:00 2001 From: Nicco Date: Fri, 9 Feb 2024 14:18:24 +0100 Subject: [PATCH 6/8] update deps (#353) --- .github/workflows/build.yml | 4 ++-- Dockerfile | 4 ++-- go.mod | 2 +- internal/config.go | 2 +- main.go | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index b39c71a..43258ca 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -3,7 +3,7 @@ name: Main on: push: tags: - - "v*.*.*" + - 'v*.*.*' jobs: docker: @@ -40,7 +40,7 @@ jobs: - uses: actions/checkout@v3 - uses: actions/setup-go@v3 with: - go-version: "^1.20" + go-version: '^1.21' - name: Build run: go run build/build.go - name: Release diff --git a/Dockerfile b/Dockerfile index 55f1a77..c4d9cff 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM golang:1.20-alpine as builder +FROM golang:1.21-alpine as builder WORKDIR /app COPY go.* . @@ -6,7 +6,7 @@ RUN go mod download COPY . . RUN go build -FROM restic/restic:0.16.0 +FROM restic/restic:0.16.4 RUN apk add --no-cache rclone bash curl COPY --from=builder /app/autorestic /usr/bin/autorestic ENTRYPOINT [] diff --git a/go.mod b/go.mod index 98000f5..7c6bfdc 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/cupcakearmy/autorestic -go 1.20 +go 1.21 require ( github.com/blang/semver/v4 v4.0.0 diff --git a/internal/config.go b/internal/config.go index c223710..46b7956 100644 --- a/internal/config.go +++ b/internal/config.go @@ -17,7 +17,7 @@ import ( "github.com/spf13/viper" ) -const VERSION = "1.7.10" +const VERSION = "1.7.11" type OptionMap map[string][]interface{} type Options map[string]OptionMap diff --git a/main.go b/main.go index 66b47bf..ae644c3 100644 --- a/main.go +++ b/main.go @@ -5,7 +5,7 @@ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 + http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, From 48487029297e3e68081c712e603aac58ccb57bd4 Mon Sep 17 00:00:00 2001 From: rdelaage Date: Thu, 15 Feb 2024 14:23:43 +0100 Subject: [PATCH 7/8] Use options on exec command (#253) Co-authored-by: Romain de Laage --- internal/backend.go | 1 + 1 file changed, 1 insertion(+) diff --git a/internal/backend.go b/internal/backend.go index 1742fda..3241d2b 100644 --- a/internal/backend.go +++ b/internal/backend.go @@ -143,6 +143,7 @@ func (b Backend) Exec(args []string) error { return err } options := ExecuteOptions{Envs: env} + args = append(args, combineBackendOptions("exec", b)...) _, out, err := ExecuteResticCommand(options, args...) if err != nil { colors.Error.Println(out) From b3440cd87c5a529a01efe7b0f63161bd23a9323e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 15 Feb 2024 14:24:17 +0100 Subject: [PATCH 8/8] Bump golang from 1.21-alpine to 1.22-alpine (#355) Bumps golang from 1.21-alpine to 1.22-alpine. --- updated-dependencies: - dependency-name: golang dependency-type: direct:production ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index c4d9cff..ac26fa7 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM golang:1.21-alpine as builder +FROM golang:1.22-alpine as builder WORKDIR /app COPY go.* .