From d2014942672d9fd7851dec44e106f98379ef4984 Mon Sep 17 00:00:00 2001 From: tomruk <41700170+tomruk@users.noreply.github.com> Date: Thu, 1 Aug 2024 00:49:07 +0300 Subject: [PATCH] Change name to kopyat --- .dockerignore | 10 ++--- .gitignore | 10 ++--- Makefile | 8 ++-- README.md | 12 +++--- cmd/{kopyaship => kopyat}/api.go | 6 +-- cmd/{kopyaship => kopyat}/backup.go | 6 +-- cmd/{kopyaship => kopyat}/doctor.go | 2 +- cmd/{kopyaship => kopyat}/hooks.go | 4 +- cmd/{kopyaship => kopyat}/ifile.go | 2 +- cmd/{kopyaship => kopyat}/init.go | 4 +- cmd/{kopyaship => kopyat}/log.go | 2 +- cmd/{kopyaship => kopyat}/main.go | 28 +++++++------- cmd/{kopyaship => kopyat}/ping.go | 2 +- cmd/{kopyaship => kopyat}/run_script.go | 4 +- cmd/{kopyaship => kopyat}/service.go | 14 +++---- cmd/{kopyaship => kopyat}/watch_job.go | 6 +-- context.go | 4 +- docker-compose.yml | 4 +- docker/build.Dockerfile | 4 +- go.mod | 6 +-- go.sum | 8 ++-- internal/backup/backup.go | 6 +-- internal/backup/backup_test.go | 6 +-- internal/backup/paths.go | 2 +- internal/config/config.go | 14 +++---- internal/ifile/ifile.go | 6 +-- internal/ifile/ifile_test.go | 2 +- internal/ifile/walk.go | 8 ++-- internal/ifile/walk_test.go | 6 +-- internal/ifile/watch.go | 2 +- internal/ifile/watch_test.go | 2 +- internal/scripting/exec.go | 2 +- internal/scripting/scripting.go | 2 +- internal/scripting/shell.go | 2 +- internal/scripting/symbols/stdlib_env.go | 2 +- .../scripting/symbols/symbols_kopyaship.go | 38 ------------------- internal/scripting/symbols/symbols_kopyat.go | 38 +++++++++++++++++++ internal/scripting/yaegi.go | 8 ++-- internal/utils/config.go | 4 +- kopyaship_example.yml => kopyat_example.yml | 12 +++--- scripts/generate.go | 8 ++-- .../{kopyashipd.service => kopyat.service} | 4 +- 42 files changed, 160 insertions(+), 160 deletions(-) rename cmd/{kopyaship => kopyat}/api.go (98%) rename cmd/{kopyaship => kopyat}/backup.go (94%) rename cmd/{kopyaship => kopyat}/doctor.go (97%) rename cmd/{kopyaship => kopyat}/hooks.go (84%) rename cmd/{kopyaship => kopyat}/ifile.go (95%) rename cmd/{kopyaship => kopyat}/init.go (90%) rename cmd/{kopyaship => kopyat}/log.go (97%) rename cmd/{kopyaship => kopyat}/main.go (88%) rename cmd/{kopyaship => kopyat}/ping.go (93%) rename cmd/{kopyaship => kopyat}/run_script.go (83%) rename cmd/{kopyaship => kopyat}/service.go (94%) rename cmd/{kopyaship => kopyat}/watch_job.go (96%) delete mode 100644 internal/scripting/symbols/symbols_kopyaship.go create mode 100644 internal/scripting/symbols/symbols_kopyat.go rename kopyaship_example.yml => kopyat_example.yml (89%) rename scripts/services/{kopyashipd.service => kopyat.service} (89%) diff --git a/.dockerignore b/.dockerignore index 8ee3697..0f421eb 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,10 +1,10 @@ **/.vscode **/__debug_bin* -/kopyaship -/kopyaship.exe -/kopyaship-* -/kopyaship.lock -/kopyaship.yml +/kopyat +/kopyat.exe +/kopyat-* +/kopyat.lock +/kopyat.yml /tmp **/test_ifile* **/test_txtfile* diff --git a/.gitignore b/.gitignore index 2e0f791..60e4c43 100644 --- a/.gitignore +++ b/.gitignore @@ -1,10 +1,10 @@ .vscode __debug_bin* -/kopyaship -/kopyaship.exe -/kopyaship-* -/kopyaship.lock -/kopyaship.yml +/kopyat +/kopyat.exe +/kopyat-* +/kopyat.lock +/kopyat.yml /tmp test_ifile* *.out diff --git a/Makefile b/Makefile index 0489c68..965b061 100644 --- a/Makefile +++ b/Makefile @@ -4,10 +4,10 @@ all: generate build generate: go run ./scripts/generate.go - statik -f -src=. -include=kopyaship_example.yml -dest=./internal + statik -f -src=. -include=kopyat_example.yml -dest=./internal build: - go build -ldflags '-s -w' ./cmd/kopyaship + go build -ldflags '-s -w' ./cmd/kopyat test: go test -v -buildmode=default -race ./... @@ -16,9 +16,9 @@ test-coverage: go test -buildmode=default -coverprofile coverage.out -covermode=atomic ./... install: - mv kopyaship $(PREFIX) + mv kopyat $(PREFIX) clean: - rm -f kopyaship kopyaship.exe ifile/test_ifile_* ifile/test_txtfile_* + rm -f kopyat kopyat.exe ifile/test_ifile_* ifile/test_txtfile_* .PHONY: build generate test test-coverage install clean diff --git a/README.md b/README.md index de78014..1100441 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ -# kopyaship +# kopyat -The name kopyaship comes from 2 words: kopya (Turkish for "copy") and ship -> copyship. It is pronounced as copiaship. +The name kopyat comes from 2 words: kopya (Turkish for "copy") and cat -> copycat. ## Config @@ -8,9 +8,9 @@ The name kopyaship comes from 2 words: kopya (Turkish for "copy") and ship -> co ### Environment variables -- `KOPYASHIP_CONFIG` -- `KOPYASHIP_STATE_DIR` -- `KOPYASHIP_SCRIPT` +- `KOPYAT_CONFIG` +- `KOPYAT_STATE_DIR` +- `KOPYAT_SCRIPT` - Set to `1` only inside Go hooks. ### Hooks (Scripts) @@ -19,7 +19,7 @@ The name kopyaship comes from 2 words: kopya (Turkish for "copy") and ship -> co package x // ^ package name can be anything, including main. -import "github.com/tomruk/kopyaship" +import "github.com/karagenc/kopyat" func init() { diff --git a/cmd/kopyaship/api.go b/cmd/kopyat/api.go similarity index 98% rename from cmd/kopyaship/api.go rename to cmd/kopyat/api.go index 07af39f..29aa793 100644 --- a/cmd/kopyaship/api.go +++ b/cmd/kopyat/api.go @@ -14,10 +14,10 @@ import ( "runtime" "strings" + "github.com/karagenc/finddirs-go" + "github.com/karagenc/kopyat/internal/utils" "github.com/labstack/echo/v4" "github.com/labstack/echo/v4/middleware" - "github.com/tomruk/finddirs-go" - "github.com/tomruk/kopyaship/internal/utils" ) const apiSocketFileName = "api.socket" @@ -53,7 +53,7 @@ func newHTTPClient() (*httpClient, error) { // Unix socket is supported on Windows 10 Insider Build 17063 and later. // For older versions, fall back to HTTP. if listen == "ipc" && runtime.GOOS == "windows" { - tempSocketDir, err := os.MkdirTemp("", "kopyaship_*") + tempSocketDir, err := os.MkdirTemp("", "kopyat_*") if err != nil { return nil, err } diff --git a/cmd/kopyaship/backup.go b/cmd/kopyat/backup.go similarity index 94% rename from cmd/kopyaship/backup.go rename to cmd/kopyat/backup.go index fb40bc7..254cd35 100644 --- a/cmd/kopyaship/backup.go +++ b/cmd/kopyat/backup.go @@ -6,10 +6,10 @@ import ( "fmt" "os" + "github.com/karagenc/kopyat/internal/backup" + _ctx "github.com/karagenc/kopyat/internal/scripting/ctx" + "github.com/karagenc/kopyat/internal/utils" "github.com/spf13/cobra" - "github.com/tomruk/kopyaship/internal/backup" - _ctx "github.com/tomruk/kopyaship/internal/scripting/ctx" - "github.com/tomruk/kopyaship/internal/utils" "golang.org/x/sync/errgroup" ) diff --git a/cmd/kopyaship/doctor.go b/cmd/kopyat/doctor.go similarity index 97% rename from cmd/kopyaship/doctor.go rename to cmd/kopyat/doctor.go index 5b8cdd8..0dd4057 100644 --- a/cmd/kopyaship/doctor.go +++ b/cmd/kopyat/doctor.go @@ -7,8 +7,8 @@ import ( "path/filepath" "github.com/fatih/color" + "github.com/karagenc/kopyat/internal/utils" "github.com/spf13/cobra" - "github.com/tomruk/kopyaship/internal/utils" ) var doctorCmd = &cobra.Command{ diff --git a/cmd/kopyaship/hooks.go b/cmd/kopyat/hooks.go similarity index 84% rename from cmd/kopyaship/hooks.go rename to cmd/kopyat/hooks.go index 6651c49..e533b89 100644 --- a/cmd/kopyaship/hooks.go +++ b/cmd/kopyat/hooks.go @@ -4,8 +4,8 @@ import ( "context" "strings" - "github.com/tomruk/kopyaship/internal/scripting" - "github.com/tomruk/kopyaship/internal/scripting/ctx" + "github.com/karagenc/kopyat/internal/scripting" + "github.com/karagenc/kopyat/internal/scripting/ctx" "golang.org/x/sync/errgroup" ) diff --git a/cmd/kopyaship/ifile.go b/cmd/kopyat/ifile.go similarity index 95% rename from cmd/kopyaship/ifile.go rename to cmd/kopyat/ifile.go index 3fb7d1e..1f781eb 100644 --- a/cmd/kopyaship/ifile.go +++ b/cmd/kopyat/ifile.go @@ -5,8 +5,8 @@ import ( "os" "path/filepath" + "github.com/karagenc/kopyat/internal/ifile" "github.com/spf13/cobra" - "github.com/tomruk/kopyaship/internal/ifile" ) var ( diff --git a/cmd/kopyaship/init.go b/cmd/kopyat/init.go similarity index 90% rename from cmd/kopyaship/init.go rename to cmd/kopyat/init.go index 5038450..df1d023 100644 --- a/cmd/kopyaship/init.go +++ b/cmd/kopyat/init.go @@ -4,9 +4,9 @@ import ( "context" "fmt" + "github.com/karagenc/kopyat/internal/backup" + "github.com/karagenc/kopyat/internal/backup/provider" "github.com/spf13/cobra" - "github.com/tomruk/kopyaship/internal/backup" - "github.com/tomruk/kopyaship/internal/backup/provider" ) var initCmd = &cobra.Command{ diff --git a/cmd/kopyaship/log.go b/cmd/kopyat/log.go similarity index 97% rename from cmd/kopyaship/log.go rename to cmd/kopyat/log.go index 1e31fda..4e7ab08 100644 --- a/cmd/kopyaship/log.go +++ b/cmd/kopyat/log.go @@ -6,7 +6,7 @@ import ( "os" "runtime" - "github.com/tomruk/kopyaship/internal/utils" + "github.com/karagenc/kopyat/internal/utils" "go.uber.org/zap" "go.uber.org/zap/zapcore" ) diff --git a/cmd/kopyaship/main.go b/cmd/kopyat/main.go similarity index 88% rename from cmd/kopyaship/main.go rename to cmd/kopyat/main.go index f0d09f5..4e670fd 100644 --- a/cmd/kopyaship/main.go +++ b/cmd/kopyat/main.go @@ -10,15 +10,15 @@ import ( "syscall" gochoice "github.com/TwiN/go-choice" + "github.com/karagenc/finddirs-go" + _config "github.com/karagenc/kopyat/internal/config" + "github.com/karagenc/kopyat/internal/utils" "github.com/rakyll/statik/fs" "github.com/spf13/cobra" "github.com/spf13/viper" - "github.com/tomruk/finddirs-go" - _config "github.com/tomruk/kopyaship/internal/config" - "github.com/tomruk/kopyaship/internal/utils" "go.uber.org/zap" - _ "github.com/tomruk/kopyaship/internal/statik" + _ "github.com/karagenc/kopyat/internal/statik" ) var ( @@ -31,7 +31,7 @@ var ( debugLog *zap.Logger - rootCmd = &cobra.Command{Use: "kopyaship"} + rootCmd = &cobra.Command{Use: "kopyat"} ) func main() { rootCmd.Execute() } @@ -79,7 +79,7 @@ func init() { exists, extractErr := extractConfigInteractive() if !exists { utils.Red.Print("Error: ") - fmt.Printf("%v: in addition to that, example config is not found within executable. consider fetching it from https://github.com/tomruk/kopyaship\n", err) + fmt.Printf("%v: in addition to that, example config is not found within executable. consider fetching it from https://github.com/karagenc/kopyat\n", err) exit(exitErrAny) } else if extractErr != nil { errPrintln(extractErr) @@ -143,7 +143,7 @@ func extractConfigInteractive() (exists bool, err error) { if err != nil { return false, err } - exampleFile, err := statikFS.Open("/kopyaship_example.yml") + exampleFile, err := statikFS.Open("/kopyat_example.yml") if err != nil { return false, err } @@ -168,7 +168,7 @@ func extractConfigInteractive() (exists bool, err error) { systemAppDirs.ConfigDir, }...) dir, _, err := gochoice.Pick( - "Where to store the config file, kopyaship.yml?\nPick:", + "Where to store the config file, kopyat.yml?\nPick:", dirs, ) if err != nil { @@ -179,23 +179,23 @@ func extractConfigInteractive() (exists bool, err error) { if err != nil { return true, err } - err = os.WriteFile(filepath.Join(dir, "kopyaship.yml"), example, 0644) + err = os.WriteFile(filepath.Join(dir, "kopyat.yml"), example, 0644) if err != nil { return true, err } - utils.Success.Println("Config written. Make sure you've fully read and edited it before running kopyaship") + utils.Success.Println("Config written. Make sure you've fully read and edited it before running kopyat") return true, nil } func initStateDir(systemWide bool, userStateDir, systemStateDir string) (err error) { - stateDir = os.Getenv("KOPYASHIP_STATE_DIR") + stateDir = os.Getenv("KOPYAT_STATE_DIR") if stateDir == "" { if systemWide { stateDir = systemStateDir } else { stateDir = userStateDir } - err = os.Setenv("KOPYASHIP_STATE_DIR", stateDir) + err = os.Setenv("KOPYAT_STATE_DIR", stateDir) if err != nil { return err } @@ -204,14 +204,14 @@ func initStateDir(systemWide bool, userStateDir, systemStateDir string) (err err } func initCacheDir(systemWide bool, userCacheDir, systemCacheDir string) (err error) { - cacheDir = os.Getenv("KOPYASHIP_CACHE") + cacheDir = os.Getenv("KOPYAT_CACHE") if cacheDir == "" { if systemWide { cacheDir = systemCacheDir } else { cacheDir = userCacheDir } - err = os.Setenv("KOPYASHIP_CACHE", cacheDir) + err = os.Setenv("KOPYAT_CACHE", cacheDir) if err != nil { return err } diff --git a/cmd/kopyaship/ping.go b/cmd/kopyat/ping.go similarity index 93% rename from cmd/kopyaship/ping.go rename to cmd/kopyat/ping.go index 8cf2753..ce9ccc5 100644 --- a/cmd/kopyaship/ping.go +++ b/cmd/kopyat/ping.go @@ -4,8 +4,8 @@ import ( "fmt" "io" + "github.com/karagenc/kopyat/internal/utils" "github.com/spf13/cobra" - "github.com/tomruk/kopyaship/internal/utils" ) var pingCmd = &cobra.Command{ diff --git a/cmd/kopyaship/run_script.go b/cmd/kopyat/run_script.go similarity index 83% rename from cmd/kopyaship/run_script.go rename to cmd/kopyat/run_script.go index 5b9e462..1e2fd63 100644 --- a/cmd/kopyaship/run_script.go +++ b/cmd/kopyat/run_script.go @@ -4,9 +4,9 @@ import ( "context" "strings" + "github.com/karagenc/kopyat/internal/scripting" + _ctx "github.com/karagenc/kopyat/internal/scripting/ctx" "github.com/spf13/cobra" - "github.com/tomruk/kopyaship/internal/scripting" - _ctx "github.com/tomruk/kopyaship/internal/scripting/ctx" ) var runScript = &cobra.Command{ diff --git a/cmd/kopyaship/service.go b/cmd/kopyat/service.go similarity index 94% rename from cmd/kopyaship/service.go rename to cmd/kopyat/service.go index acab87a..83447e2 100644 --- a/cmd/kopyaship/service.go +++ b/cmd/kopyat/service.go @@ -13,11 +13,11 @@ import ( "time" "github.com/gofrs/flock" + "github.com/karagenc/kopyat/internal/ifile" + "github.com/karagenc/kopyat/internal/utils" "github.com/kardianos/service" "github.com/labstack/echo/v4" "github.com/spf13/cobra" - "github.com/tomruk/kopyaship/internal/ifile" - "github.com/tomruk/kopyaship/internal/utils" "go.uber.org/zap" ) @@ -25,8 +25,8 @@ var serviceCmd = &cobra.Command{ Use: "service", Run: func(cmd *cobra.Command, args []string) { config := &service.Config{ - Name: "kopyaship", - DisplayName: "Kopyaship service", + Name: "kopyat", + DisplayName: "Kopyat service", } svc := &svc{} @@ -162,14 +162,14 @@ var lockFile = func() string { case "windows": lockDir = os.Getenv("PROGRAMDATA") if lockDir == "" { - lockDir = "C:/ProgramData/kopyaship" + lockDir = "C:/ProgramData/kopyat" } case "plan9": - lockDir = "/lib/kopyaship" + lockDir = "/lib/kopyat" default: // unix lockDir = "/var/lock" } - return filepath.Join(lockDir, "kopyaship_service.lock") + return filepath.Join(lockDir, "kopyat_service.lock") }() func (s *svc) initLock() error { diff --git a/cmd/kopyaship/watch_job.go b/cmd/kopyat/watch_job.go similarity index 96% rename from cmd/kopyaship/watch_job.go rename to cmd/kopyat/watch_job.go index f1c431a..e5d0cfb 100644 --- a/cmd/kopyaship/watch_job.go +++ b/cmd/kopyat/watch_job.go @@ -9,11 +9,11 @@ import ( "path/filepath" "github.com/jedib0t/go-pretty/v6/table" + "github.com/karagenc/kopyat/internal/ifile" + "github.com/karagenc/kopyat/internal/scripting/ctx" + "github.com/karagenc/kopyat/internal/utils" "github.com/labstack/echo/v4" "github.com/spf13/cobra" - "github.com/tomruk/kopyaship/internal/ifile" - "github.com/tomruk/kopyaship/internal/scripting/ctx" - "github.com/tomruk/kopyaship/internal/utils" "golang.org/x/sync/errgroup" ) diff --git a/context.go b/context.go index 55a5f7c..30401d4 100644 --- a/context.go +++ b/context.go @@ -1,6 +1,6 @@ -package kopyaship +package kopyat -import "github.com/tomruk/kopyaship/internal/scripting/ctx" +import "github.com/karagenc/kopyat/internal/scripting/ctx" type ( Context = ctx.Context diff --git a/docker-compose.yml b/docker-compose.yml index c238717..544bbdb 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,8 +1,8 @@ version: '3' services: - kopyaship: + kopyat: build: dockerfile: docker/build.Dockerfile volumes: - - ./kopyaship.yml:/etc/kopyaship.yml + - ./kopyat.yml:/etc/kopyat.yml diff --git a/docker/build.Dockerfile b/docker/build.Dockerfile index f45ef33..d64d8c7 100644 --- a/docker/build.Dockerfile +++ b/docker/build.Dockerfile @@ -16,6 +16,6 @@ RUN apk --no-cache add \ ca-certificates tzdata \ && update-ca-certificates -COPY --from=build /src/kopyaship /usr/local/bin +COPY --from=build /src/kopyat /usr/local/bin -ENTRYPOINT [ "kopyaship", "service" ] +ENTRYPOINT [ "kopyat", "service" ] diff --git a/go.mod b/go.mod index 0612470..fd90f47 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module github.com/tomruk/kopyaship +module github.com/karagenc/kopyat go 1.21 @@ -16,8 +16,8 @@ require ( github.com/spf13/cobra v1.7.0 github.com/spf13/viper v1.15.0 github.com/stretchr/testify v1.9.0 - github.com/tomruk/finddirs-go v0.1.0 - github.com/tomruk/go-pathspec v0.1.0 + github.com/karagenc/finddirs-go v0.1.0 + github.com/karagenc/go-pathspec v0.1.0 github.com/traefik/yaegi v0.16.0 go.uber.org/zap v1.21.0 golang.org/x/sync v0.1.0 diff --git a/go.sum b/go.sum index 8c2c513..4ac2f8f 100644 --- a/go.sum +++ b/go.sum @@ -224,10 +224,10 @@ github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsT github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= github.com/subosito/gotenv v1.4.2 h1:X1TuBLAMDFbaTAChgCBLu3DU3UPyELpnF2jjJ2cz/S8= github.com/subosito/gotenv v1.4.2/go.mod h1:ayKnFf/c6rvx/2iiLrJUk1e6plDbT3edrFNGqEflhK0= -github.com/tomruk/finddirs-go v0.1.0 h1:MBM/3GajJsY0g9UcWYElNWQaIS8xqhycP33aPMXOiYA= -github.com/tomruk/finddirs-go v0.1.0/go.mod h1:laXHQmRm8knPGc9Y0NXkPDauHoc1ZOPiT+k8hf+NBx0= -github.com/tomruk/go-pathspec v0.1.0 h1:Osl8i46JUwYrmsk0PvpSXzJ5voM4gafW3v6RPqBRbdo= -github.com/tomruk/go-pathspec v0.1.0/go.mod h1:1LQlcgO0YJwvCrwRCnjVpKfnBwOUg71slccj0ioZEyw= +github.com/karagenc/finddirs-go v0.1.0 h1:MBM/3GajJsY0g9UcWYElNWQaIS8xqhycP33aPMXOiYA= +github.com/karagenc/finddirs-go v0.1.0/go.mod h1:laXHQmRm8knPGc9Y0NXkPDauHoc1ZOPiT+k8hf+NBx0= +github.com/karagenc/go-pathspec v0.1.0 h1:Osl8i46JUwYrmsk0PvpSXzJ5voM4gafW3v6RPqBRbdo= +github.com/karagenc/go-pathspec v0.1.0/go.mod h1:1LQlcgO0YJwvCrwRCnjVpKfnBwOUg71slccj0ioZEyw= github.com/traefik/yaegi v0.16.0 h1:PdG291d+XKZnfgfnc9vedZ9DcIrAq4EYTy3/TyESn20= github.com/traefik/yaegi v0.16.0/go.mod h1:4eVhbPb3LnD2VigQjhYbEJ69vDRFdT2HQNrXx8eEwUY= github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw= diff --git a/internal/backup/backup.go b/internal/backup/backup.go index ceac3d3..8228f64 100644 --- a/internal/backup/backup.go +++ b/internal/backup/backup.go @@ -9,9 +9,9 @@ import ( "go.uber.org/zap" "golang.org/x/term" - "github.com/tomruk/kopyaship/internal/backup/provider" - "github.com/tomruk/kopyaship/internal/config" - "github.com/tomruk/kopyaship/internal/utils" + "github.com/karagenc/kopyat/internal/backup/provider" + "github.com/karagenc/kopyat/internal/config" + "github.com/karagenc/kopyat/internal/utils" ) type ( diff --git a/internal/backup/backup_test.go b/internal/backup/backup_test.go index 4edd880..f53a96d 100644 --- a/internal/backup/backup_test.go +++ b/internal/backup/backup_test.go @@ -12,11 +12,11 @@ import ( "strings" "testing" + "github.com/karagenc/kopyat/internal/backup/provider" + "github.com/karagenc/kopyat/internal/config" + "github.com/karagenc/kopyat/internal/utils" "github.com/mattn/go-shellwords" "github.com/stretchr/testify/require" - "github.com/tomruk/kopyaship/internal/backup/provider" - "github.com/tomruk/kopyaship/internal/config" - "github.com/tomruk/kopyaship/internal/utils" "go.uber.org/zap" ) diff --git a/internal/backup/paths.go b/internal/backup/paths.go index 9eec49a..f2b4833 100644 --- a/internal/backup/paths.go +++ b/internal/backup/paths.go @@ -7,7 +7,7 @@ import ( "path/filepath" "strings" - "github.com/tomruk/kopyaship/internal/ifile" + "github.com/karagenc/kopyat/internal/ifile" "go.uber.org/zap" "golang.org/x/sync/errgroup" ) diff --git a/internal/config/config.go b/internal/config/config.go index 6b160c3..49cc334 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -47,16 +47,16 @@ func DirsLocal() []string { panic(err) } dirs := []string{ - filepath.Join(home, "kopyaship"), - filepath.Join(home, ".kopyaship"), + filepath.Join(home, "kopyat"), + filepath.Join(home, ".kopyat"), } // Avoid duplicate paths. If $XDG_CONFIG_HOME is the same as ~/.config, - // userConfigDir will be a duplicate of configHome + "/kopyaship" + // userConfigDir will be a duplicate of configHome + "/kopyat" xdgConfigHome := filepath.Clean(os.Getenv("XDG_CONFIG_HOME")) configHome := filepath.Join(home, ".config") if xdgConfigHome != configHome { - dirs = append(dirs, filepath.Join(configHome, "kopyaship")) + dirs = append(dirs, filepath.Join(configHome, "kopyat")) } return dirs } @@ -81,10 +81,10 @@ func Read(configFile, userConfigDir, systemConfigDir string) ( v = viper.New() if configFile != "" { v.SetConfigFile(configFile) - } else if configFileEnv := os.Getenv("KOPYASHIP_CONFIG"); configFileEnv != "" { + } else if configFileEnv := os.Getenv("KOPYAT_CONFIG"); configFileEnv != "" { v.SetConfigFile(configFileEnv) } else { - v.SetConfigName("kopyaship") + v.SetConfigName("kopyat") v.SetConfigType("yml") v.AddConfigPath(".") @@ -109,7 +109,7 @@ func Read(configFile, userConfigDir, systemConfigDir string) ( if err != nil { return } - err = os.Setenv("KOPYASHIP_CONFIG", configFile) + err = os.Setenv("KOPYAT_CONFIG", configFile) if err != nil { return } diff --git a/internal/ifile/ifile.go b/internal/ifile/ifile.go index b7b3f2a..827c021 100644 --- a/internal/ifile/ifile.go +++ b/internal/ifile/ifile.go @@ -9,7 +9,7 @@ import ( "strings" "sync" - pathspec "github.com/tomruk/go-pathspec" + pathspec "github.com/karagenc/go-pathspec" "go.uber.org/zap" ) @@ -45,7 +45,7 @@ type ( const ( // Include file. Paths are absolute. ModeRestic Mode = iota - // Ignore file. Paths are relative to the .gitignore/.ksignore. + // Ignore file. Paths are relative to the .gitignore/.kpignore. ModeSyncthing ) @@ -61,7 +61,7 @@ func (m Mode) String() string { } const ( - generatedBy = "# Generated by kopyaship. DO NOT TOUCH THE LINES BETWEEN I_BEGIN AND I_END." + generatedBy = "# Generated by kopyat. DO NOT TOUCH THE LINES BETWEEN I_BEGIN AND I_END." beginIndicator = "# I_BEGIN" endIndicator = "# I_END" ) diff --git a/internal/ifile/ifile_test.go b/internal/ifile/ifile_test.go index 80ce269..6115357 100644 --- a/internal/ifile/ifile_test.go +++ b/internal/ifile/ifile_test.go @@ -108,7 +108,7 @@ func TestIfileAppend2(t *testing.T) { ` - contentMiddle := `# Generated by kopyaship. DO NOT TOUCH THE LINES BETWEEN I_BEGIN AND I_END. + contentMiddle := `# Generated by kopyat. DO NOT TOUCH THE LINES BETWEEN I_BEGIN AND I_END. # I_BEGIN # I_END` contentEnd := ` diff --git a/internal/ifile/walk.go b/internal/ifile/walk.go index e32a0a7..b0fe06c 100644 --- a/internal/ifile/walk.go +++ b/internal/ifile/walk.go @@ -8,13 +8,13 @@ import ( "strings" "syscall" - pathspec "github.com/tomruk/go-pathspec" - "github.com/tomruk/kopyaship/internal/utils" + pathspec "github.com/karagenc/go-pathspec" + "github.com/karagenc/kopyat/internal/utils" ) const ( gitignore = ".gitignore" - ksignore = ".ksignore" + kpignore = ".kpignore" // We need to be fast while walking, and this is faster than // comparing strings every time we need to check whether we're @@ -135,7 +135,7 @@ func addIgnoreIfExists(ignorefiles *[]*ignorefile, dir string) error { }) } - path = filepath.Join(dir, ksignore) + path = filepath.Join(dir, kpignore) if f, err := os.Stat(path); err == nil && f.Mode().Type().IsRegular() { p, err := pathspec.FromFile(path) if err != nil { diff --git a/internal/ifile/walk_test.go b/internal/ifile/walk_test.go index e79d443..1289f1b 100644 --- a/internal/ifile/walk_test.go +++ b/internal/ifile/walk_test.go @@ -33,7 +33,7 @@ func TestSyncthingWalkInCurrentProject(t *testing.T) { for _, line := range strings.Split(string(content), "\n") { require.NotContains(t, line, "README.md") require.NotContains(t, line, "Makefile") - require.NotContains(t, line, "cmd/kopyaship") + require.NotContains(t, line, "cmd/kopyat") require.NotContains(t, line, "scripts") require.NotContains(t, line, "LICENSE") require.NotRegexp(t, regexp.MustCompile("^/.gitignore$"), line) @@ -101,7 +101,7 @@ func TestSyncthingWalkInCurrentProjectAppend(t *testing.T) { found1 := true found2 := true for _, line := range strings.Split(string(content), "\n") { - find1 := filepath.Join(path, "cmd/kopyaship/watch.go") + find1 := filepath.Join(path, "cmd/kopyat/watch.go") if line == find1 { if found1 { t.Fatalf("this occurs more than once: %s", find1) @@ -142,7 +142,7 @@ func TestResticWalkInCurrentProject(t *testing.T) { for _, line := range strings.Split(string(content), "\n") { require.NotContains(t, line, "tmp") - require.NotContains(t, line, "kopyaship.yml") + require.NotContains(t, line, "kopyat.yml") require.NotContains(t, line, "test_file") } } diff --git a/internal/ifile/watch.go b/internal/ifile/watch.go index f8d0ff0..18bd049 100644 --- a/internal/ifile/watch.go +++ b/internal/ifile/watch.go @@ -258,7 +258,7 @@ func watch(root string) (watcher *fsnotify.Watcher, eventChan chan string, err e eventChan <- event.Name } else if event.Has(fsnotify.Write) { base := filepath.Base(event.Name) - if base == gitignore || base == ksignore { + if base == gitignore || base == kpignore { eventChan <- event.Name } } diff --git a/internal/ifile/watch_test.go b/internal/ifile/watch_test.go index 54d1c5a..17dc104 100644 --- a/internal/ifile/watch_test.go +++ b/internal/ifile/watch_test.go @@ -10,8 +10,8 @@ import ( "testing" "time" + "github.com/karagenc/kopyat/internal/utils" "github.com/stretchr/testify/require" - "github.com/tomruk/kopyaship/internal/utils" "go.uber.org/zap" ) diff --git a/internal/scripting/exec.go b/internal/scripting/exec.go index 7a6d32d..aa99be4 100644 --- a/internal/scripting/exec.go +++ b/internal/scripting/exec.go @@ -5,7 +5,7 @@ import ( "os" "os/exec" - "github.com/tomruk/kopyaship/internal/scripting/ctx" + "github.com/karagenc/kopyat/internal/scripting/ctx" ) type Exec struct { diff --git a/internal/scripting/scripting.go b/internal/scripting/scripting.go index 5cf64b6..5670f0c 100644 --- a/internal/scripting/scripting.go +++ b/internal/scripting/scripting.go @@ -7,8 +7,8 @@ import ( "os" "path/filepath" + "github.com/karagenc/kopyat/internal/scripting/ctx" "github.com/mattn/go-shellwords" - "github.com/tomruk/kopyaship/internal/scripting/ctx" ) type Script interface { diff --git a/internal/scripting/shell.go b/internal/scripting/shell.go index 028fc89..ca1e284 100644 --- a/internal/scripting/shell.go +++ b/internal/scripting/shell.go @@ -5,7 +5,7 @@ import ( "os" "os/exec" - "github.com/tomruk/kopyaship/internal/scripting/ctx" + "github.com/karagenc/kopyat/internal/scripting/ctx" ) type ShellScript struct { diff --git a/internal/scripting/symbols/stdlib_env.go b/internal/scripting/symbols/stdlib_env.go index 94aac4b..11da712 100644 --- a/internal/scripting/symbols/stdlib_env.go +++ b/internal/scripting/symbols/stdlib_env.go @@ -19,7 +19,7 @@ func init() { return value } ) - env["KOPYASHIP_SCRIPT"] = "1" + env["KOPYAT_SCRIPT"] = "1" stdlib.Symbols["os/os"]["Clearenv"] = reflect.ValueOf(func() { mu.Lock() diff --git a/internal/scripting/symbols/symbols_kopyaship.go b/internal/scripting/symbols/symbols_kopyaship.go deleted file mode 100644 index 7115a97..0000000 --- a/internal/scripting/symbols/symbols_kopyaship.go +++ /dev/null @@ -1,38 +0,0 @@ -// Code generated by 'yaegi extract github.com/tomruk/kopyaship'. DO NOT EDIT. - -package symbols - -import ( - "github.com/tomruk/kopyaship" - "github.com/tomruk/kopyaship/internal/scripting/ctx" - "reflect" -) - -func init() { - Symbols["github.com/tomruk/kopyaship/kopyaship"] = map[string]reflect.Value{ - // function, constant and variable definitions - "GetContext": reflect.ValueOf(kopyaship.GetContext), - - // type definitions - "BackupContext": reflect.ValueOf((*kopyaship.BackupContext)(nil)), - "Context": reflect.ValueOf((*kopyaship.Context)(nil)), - "IfileGenerationContext": reflect.ValueOf((*kopyaship.IfileGenerationContext)(nil)), - - // interface wrapper definitions - "_Context": reflect.ValueOf((*_github_com_tomruk_kopyaship_Context)(nil)), - } -} - -// _github_com_tomruk_kopyaship_Context is an interface wrapper for Context type -type _github_com_tomruk_kopyaship_Context struct { - IValue interface{} - WBackup func() (c *ctx.BackupContext, ok bool) - WIfileGeneration func() (c *ctx.IfileGenerationContext, ok bool) -} - -func (W _github_com_tomruk_kopyaship_Context) Backup() (c *ctx.BackupContext, ok bool) { - return W.WBackup() -} -func (W _github_com_tomruk_kopyaship_Context) IfileGeneration() (c *ctx.IfileGenerationContext, ok bool) { - return W.WIfileGeneration() -} diff --git a/internal/scripting/symbols/symbols_kopyat.go b/internal/scripting/symbols/symbols_kopyat.go new file mode 100644 index 0000000..9ce8eb9 --- /dev/null +++ b/internal/scripting/symbols/symbols_kopyat.go @@ -0,0 +1,38 @@ +// Code generated by 'yaegi extract github.com/karagenc/kopyat'. DO NOT EDIT. + +package symbols + +import ( + "github.com/karagenc/kopyat" + "github.com/karagenc/kopyat/internal/scripting/ctx" + "reflect" +) + +func init() { + Symbols["github.com/karagenc/kopyat/kopyat"] = map[string]reflect.Value{ + // function, constant and variable definitions + "GetContext": reflect.ValueOf(kopyat.GetContext), + + // type definitions + "BackupContext": reflect.ValueOf((*kopyat.BackupContext)(nil)), + "Context": reflect.ValueOf((*kopyat.Context)(nil)), + "IfileGenerationContext": reflect.ValueOf((*kopyat.IfileGenerationContext)(nil)), + + // interface wrapper definitions + "_Context": reflect.ValueOf((*_github_com_karagenc_kopyat_Context)(nil)), + } +} + +// _github_com_karagenc_kopyat_Context is an interface wrapper for Context type +type _github_com_karagenc_kopyat_Context struct { + IValue interface{} + WBackup func() (c *ctx.BackupContext, ok bool) + WIfileGeneration func() (c *ctx.IfileGenerationContext, ok bool) +} + +func (W _github_com_karagenc_kopyat_Context) Backup() (c *ctx.BackupContext, ok bool) { + return W.WBackup() +} +func (W _github_com_karagenc_kopyat_Context) IfileGeneration() (c *ctx.IfileGenerationContext, ok bool) { + return W.WIfileGeneration() +} diff --git a/internal/scripting/yaegi.go b/internal/scripting/yaegi.go index 7128788..a99729b 100644 --- a/internal/scripting/yaegi.go +++ b/internal/scripting/yaegi.go @@ -5,10 +5,10 @@ import ( "fmt" "reflect" + "github.com/karagenc/kopyat" + "github.com/karagenc/kopyat/internal/scripting/ctx" + "github.com/karagenc/kopyat/internal/scripting/symbols" "github.com/mitchellh/go-homedir" - "github.com/tomruk/kopyaship" - "github.com/tomruk/kopyaship/internal/scripting/ctx" - "github.com/tomruk/kopyaship/internal/scripting/symbols" "github.com/traefik/yaegi/interp" "github.com/traefik/yaegi/stdlib" ) @@ -44,7 +44,7 @@ func newYaegiScript(ctx context.Context, sw ...string) (*YaegiScript, error) { } symbols := symbols.Clone() - symbols["github.com/tomruk/kopyaship/kopyaship"]["GetContext"] = reflect.ValueOf(func() kopyaship.Context { + symbols["github.com/karagenc/kopyat/kopyat"]["GetContext"] = reflect.ValueOf(func() kopyat.Context { return s.getContext() }) err = i.Use(symbols) diff --git a/internal/utils/config.go b/internal/utils/config.go index 78d64b3..b7050d2 100644 --- a/internal/utils/config.go +++ b/internal/utils/config.go @@ -1,9 +1,9 @@ package utils -import "github.com/tomruk/finddirs-go" +import "github.com/karagenc/finddirs-go" var FindDirsConfig = finddirs.AppConfig{ - Subdir: "kopyaship", + Subdir: "kopyat", SubdirCache: "cache", } diff --git a/kopyaship_example.yml b/kopyat_example.yml similarity index 89% rename from kopyaship_example.yml rename to kopyat_example.yml index f9b9167..d304f59 100644 --- a/kopyaship_example.yml +++ b/kopyat_example.yml @@ -15,10 +15,10 @@ backups: #password: # Generate and use ifile. - # This is the primary functionality of Kopyaship. If this is set to true, - # Kopyaship will read .gitignore and .ksignore files and generate an ifile + # This is the primary functionality of Kopyat. If this is set to true, + # Kopyat will read .gitignore and .kpignore files and generate an ifile # from them. Then your backup program will read that ifile and backup files - # that are not ignored by .gitignore or .ksignore files. If you disable this, + # that are not ignored by .gitignore or .kpignore files. If you disable this, # backups will be done as usual. (Backup program will include all files and # directories specified by `paths`.) use_ifile: true @@ -53,7 +53,7 @@ backups: ifile_generation: run: - # Path to .stignore. Its directory and subdirectories will be scanned for files, - # .gitignore's, and .ksignore's to generate this ifile. + # .gitignore's, and .kpignore's to generate this ifile. ifile: $PHOTOS_PATH/.stignore # What type of ifile are we generating? (For now, only valid option is `syncthing`). type: syncthing @@ -72,10 +72,10 @@ env: PHOTOS_PATH: $HOME/photos service: - # By default, Kopyaship service logs to stdout. + # By default, Kopyat service logs to stdout. # Uncomment this if you would like to log to a file. # Set this to "disabled" to disable logging to both stdout and file. - #log: /var/log/kopyaship.log + #log: /var/log/kopyat.log api: enabled: true diff --git a/scripts/generate.go b/scripts/generate.go index 07b5aa9..715519a 100644 --- a/scripts/generate.go +++ b/scripts/generate.go @@ -27,7 +27,7 @@ outer: } } - err := extractKopyashipPkg() + err := extractKopyatPkg() if err != nil { log.Fatalln(err) } @@ -52,19 +52,19 @@ func extractGitHubPkg(gitHubPath string) error { return os.WriteFile("./internal/scripting/symbols/symbols_"+gitHubSuffix+".go", b.Bytes(), 0644) } -func extractKopyashipPkg() error { +func extractKopyatPkg() error { var ( ext = extract.Extractor{Dest: "symbols"} b = bytes.Buffer{} ) - _, err := ext.Extract(".", "github.com/tomruk/kopyaship", &b) + _, err := ext.Extract(".", "github.com/karagenc/kopyat", &b) if err != nil { return nil } buf := b.Bytes() buf = bytes.Replace(buf, []byte(" \".\"\n"), nil, 1) - return os.WriteFile("./internal/scripting/symbols/symbols_kopyaship.go", buf, 0644) + return os.WriteFile("./internal/scripting/symbols/symbols_kopyat.go", buf, 0644) } func gitHubSuffix(path string) string { diff --git a/scripts/services/kopyashipd.service b/scripts/services/kopyat.service similarity index 89% rename from scripts/services/kopyashipd.service rename to scripts/services/kopyat.service index 69e8a78..dbf7e31 100644 --- a/scripts/services/kopyashipd.service +++ b/scripts/services/kopyat.service @@ -1,10 +1,10 @@ [Unit] -Description=Kopyaship Service +Description=Kopyat Service After=multi-user.target [Service] Type=Simple -ExecStart=kopyaship +ExecStart=kopyat Restart=always LimitNOFILE=infinity User=root