diff --git a/pkg/command/add.go b/pkg/command/add.go index b6bdd74..fce0567 100644 --- a/pkg/command/add.go +++ b/pkg/command/add.go @@ -53,7 +53,7 @@ func addFiles(cmd *cobra.Command, addPath string, dryRun, errorOnAction bool) er } // Load config - cfg, err := util.ReadConfigFromFile(DefaultConfigFile) + cfg, err := vault.ReadConfigFromFile(DefaultConfigFile) if err != nil { return err } @@ -78,7 +78,7 @@ func addFiles(cmd *cobra.Command, addPath string, dryRun, errorOnAction bool) er pw.AppendTracker(tracker) - inFilesRel, err := util.ListFilesRel(pw.Log, addPath, tracker.Increment, cfg.SkipPermissionDenied) + inFilesRel, err := vault.ListFilesRel(pw.Log, addPath, tracker.Increment, cfg.SkipPermissionDenied) if err != nil { return err } @@ -94,7 +94,7 @@ func addFiles(cmd *cobra.Command, addPath string, dryRun, errorOnAction bool) er pw.AppendTracker(tracker) - inFilesRel = util.FilterIgnore(inFilesRel, cfg.Ignore, tracker.Increment) + inFilesRel = vault.FilterIgnore(inFilesRel, cfg.Ignore, tracker.Increment) tracker.MarkAsDone() @@ -102,7 +102,7 @@ func addFiles(cmd *cobra.Command, addPath string, dryRun, errorOnAction bool) er pw.Log("Linking sidecar files") - inFilesRelLinked := util.LinkSidecars(cfg.SidecarExtensions, inFilesRel) + inFilesRelLinked := vault.LinkSidecars(cfg.SidecarExtensions, inFilesRel) // 4. Shuffle files @@ -130,17 +130,17 @@ func addFiles(cmd *cobra.Command, addPath string, dryRun, errorOnAction bool) er for _, f := range inFilesRelLinked { // Copy main file - info, err := util.ExtractMetadata(et, addPath, f.Path) + info, err := vault.ExtractMetadata(et, addPath, f.Path) if err != nil { return fmt.Errorf("failed to extract metadata for %s: %w", f.Path, err) } - targetPath, err := util.RenderTemplate(cfg.Template, info) + targetPath, err := vault.RenderTemplate(cfg.Template, info) if err != nil { return fmt.Errorf("failed to render template for %s: %w", f.Path, err) } - err = util.SmartCopyFile( + err = vault.SmartCopyFile( pw.Log, path.Join(addPath, f.Path), path.Join(libPath, targetPath), @@ -155,9 +155,9 @@ func addFiles(cmd *cobra.Command, addPath string, dryRun, errorOnAction bool) er for _, sidecar := range f.Sidecars { // Use the same name as the main file, but with the sidecar extension sidecarPath := replaceExtension(targetPath, filepath.Ext(sidecar)) - err = util.SmartCopyFile( + err = vault.SmartCopyFile( pw.Log, - path.Join(addPath, sidecarPath), + path.Join(addPath, sidecar), path.Join(libPath, sidecarPath), dryRun, errorOnAction, diff --git a/pkg/command/info.go b/pkg/command/info.go index 30d3fd2..0ea9e53 100644 --- a/pkg/command/info.go +++ b/pkg/command/info.go @@ -33,7 +33,7 @@ func showFileInfo(cmd *cobra.Command, target string) error { return err } - infos, err := util.ExtractMetadata(et, dir, target) + infos, err := vault.ExtractMetadata(et, dir, target) if err != nil { return err } diff --git a/pkg/command/init.go b/pkg/command/init.go index 9e779f2..2df3289 100644 --- a/pkg/command/init.go +++ b/pkg/command/init.go @@ -26,7 +26,7 @@ func GetInitCmd() *cobra.Command { } func ensureLibraryInitialized(cmd *cobra.Command) error { - cfgExists, err := util.IsConfigExists(DefaultConfigFile) + cfgExists, err := vault.IsConfigExists(DefaultConfigFile) if err != nil { return err } @@ -75,7 +75,7 @@ func initLibrary(cmd *cobra.Command) error { } // Write default config to file - err = util.WriteDefaultConfigToFile(DefaultConfigFile) + err = vault.WriteDefaultConfigToFile(DefaultConfigFile) if err != nil { return err } diff --git a/pkg/vault/compare.go b/pkg/vault/compare.go index f06fe8a..acceb60 100644 --- a/pkg/vault/compare.go +++ b/pkg/vault/compare.go @@ -1,4 +1,4 @@ -package util +package vault import ( "bytes" diff --git a/pkg/vault/compare_test.go b/pkg/vault/compare_test.go index 6b74967..3089ca4 100644 --- a/pkg/vault/compare_test.go +++ b/pkg/vault/compare_test.go @@ -1,4 +1,4 @@ -package util +package vault import ( "os" diff --git a/pkg/vault/config.go b/pkg/vault/config.go index 8fc71d7..a94ba2b 100644 --- a/pkg/vault/config.go +++ b/pkg/vault/config.go @@ -1,4 +1,4 @@ -package util +package vault import ( "encoding/json" @@ -43,9 +43,9 @@ ignore: # sidecarExtensions: List of file extensions for sidecar files. sidecarExtensions: - - "*.xmp" - - "*.yaml" - - "*.json" + - ".xmp" + - ".yaml" + - ".json" ` ) diff --git a/pkg/vault/config_test.go b/pkg/vault/config_test.go index 7ef622a..106946d 100644 --- a/pkg/vault/config_test.go +++ b/pkg/vault/config_test.go @@ -1,4 +1,4 @@ -package util +package vault import ( "testing" diff --git a/pkg/vault/copy.go b/pkg/vault/copy.go index 9133e77..28cd4e8 100644 --- a/pkg/vault/copy.go +++ b/pkg/vault/copy.go @@ -1,4 +1,4 @@ -package util +package vault import ( "errors" diff --git a/pkg/vault/copy_test.go b/pkg/vault/copy_test.go index 7ca39ba..7b15763 100644 --- a/pkg/vault/copy_test.go +++ b/pkg/vault/copy_test.go @@ -1,4 +1,4 @@ -package util +package vault import ( "os" diff --git a/pkg/vault/filter.go b/pkg/vault/filter.go index 35a0c2e..5c692de 100644 --- a/pkg/vault/filter.go +++ b/pkg/vault/filter.go @@ -1,4 +1,4 @@ -package util +package vault import ( ignore "github.com/sabhiram/go-gitignore" diff --git a/pkg/vault/filter_test.go b/pkg/vault/filter_test.go index 63a478b..fa865de 100644 --- a/pkg/vault/filter_test.go +++ b/pkg/vault/filter_test.go @@ -1,4 +1,4 @@ -package util +package vault import ( "testing" diff --git a/pkg/vault/list.go b/pkg/vault/list.go index 357db93..a378316 100644 --- a/pkg/vault/list.go +++ b/pkg/vault/list.go @@ -1,4 +1,4 @@ -package util +package vault import ( "os" diff --git a/pkg/vault/list_test.go b/pkg/vault/list_test.go index f0d4ade..1b66815 100644 --- a/pkg/vault/list_test.go +++ b/pkg/vault/list_test.go @@ -1,4 +1,4 @@ -package util +package vault import ( "testing" diff --git a/pkg/vault/metadata.go b/pkg/vault/metadata.go index d1b953e..7f87884 100644 --- a/pkg/vault/metadata.go +++ b/pkg/vault/metadata.go @@ -1,4 +1,4 @@ -package util +package vault import ( "crypto/md5" diff --git a/pkg/vault/metadata_test.go b/pkg/vault/metadata_test.go index 875a03c..ad32554 100644 --- a/pkg/vault/metadata_test.go +++ b/pkg/vault/metadata_test.go @@ -1,4 +1,4 @@ -package util +package vault import ( "testing" diff --git a/pkg/vault/sidecar.go b/pkg/vault/sidecar.go index 966c7ac..12eb9f6 100644 --- a/pkg/vault/sidecar.go +++ b/pkg/vault/sidecar.go @@ -1,4 +1,4 @@ -package util +package vault import ( "path/filepath" @@ -18,7 +18,7 @@ func LinkSidecars( ) []FileWithSidecars { // helper functions - sidecarExts := lo.Associate(sidecarExtensions, func(item string) (string, any) { + sidecarExts := lo.Associate(sidecarExtensions, func(item string) (string, bool) { return strings.ToLower(item), true }) diff --git a/pkg/vault/sidecar_test.go b/pkg/vault/sidecar_test.go index f8ce46c..ca6845c 100644 --- a/pkg/vault/sidecar_test.go +++ b/pkg/vault/sidecar_test.go @@ -1,4 +1,4 @@ -package util +package vault import ( "testing" diff --git a/pkg/vault/template.go b/pkg/vault/template.go index 74a38ae..e52db36 100644 --- a/pkg/vault/template.go +++ b/pkg/vault/template.go @@ -1,4 +1,4 @@ -package util +package vault import ( "bytes" diff --git a/pkg/vault/template_test.go b/pkg/vault/template_test.go index b6f67f2..6cd9fb9 100644 --- a/pkg/vault/template_test.go +++ b/pkg/vault/template_test.go @@ -1,4 +1,4 @@ -package util +package vault import ( "testing"