diff --git a/README.md b/README.md index 66487bc4..642e7f3b 100644 --- a/README.md +++ b/README.md @@ -456,9 +456,6 @@ java: "arm64": "x64" "aarch64": "x64" -vault: - "download_url": "https://repo1.maven.org/maven2/org/apache/jackrabbit/vault/vault-cli/3.8.2/vault-cli-3.8.2-bin.tar.gz" - base: # Location of temporary files (downloaded AEM packages, etc) tmp_dir: aem/home/tmp diff --git a/cmd/aem/root.go b/cmd/aem/root.go index c0e0a460..2149ae1f 100644 --- a/cmd/aem/root.go +++ b/cmd/aem/root.go @@ -34,7 +34,6 @@ func (c *CLI) rootCmd() *cobra.Command { cmd.AddCommand(c.fileCmd()) cmd.AddCommand(c.authCmd()) cmd.AddCommand(c.contentCmd()) - cmd.AddCommand(c.vaultCmd()) c.rootFlags(cmd) diff --git a/cmd/aem/vault.go b/cmd/aem/vault.go deleted file mode 100644 index c688c660..00000000 --- a/cmd/aem/vault.go +++ /dev/null @@ -1,30 +0,0 @@ -package main - -import ( - "github.com/spf13/cobra" - "github.com/wttech/aemc/pkg" -) - -func (c *CLI) vaultCmd() *cobra.Command { - cmd := &cobra.Command{ - Use: "vlt", - Short: "Executes Vault commands", - Hidden: true, - Run: func(cmd *cobra.Command, args []string) { - if err := c.aem.VendorManager().VaultCLI().CommandShell(args); err != nil { - c.Fail("command failed") - return - } - c.Ok("command run") - }, - Args: cobra.ArbitraryArgs, - FParseErrWhitelist: cobra.FParseErrWhitelist{ - UnknownFlags: true, - }, - } - cmd.SetHelpFunc(func(cmd *cobra.Command, args []string) { - aem := pkg.NewAEM(c.config) // c.onStart() not yet called - _ = aem.VendorManager().VaultCLI().CommandShell(args[1:]) - }) - return cmd -} diff --git a/cmd/aem/vendor.go b/cmd/aem/vendor.go index e86acae6..b4913e1d 100644 --- a/cmd/aem/vendor.go +++ b/cmd/aem/vendor.go @@ -43,9 +43,6 @@ func (c *CLI) vendorListCmd() *cobra.Command { } c.SetOutput("javaExecutable", javaExecutable) - vaultExecutable := c.aem.VendorManager().VaultCLI().VltFile() - c.setOutput("vaultExecutable", vaultExecutable) - oakRunJar := c.aem.VendorManager().OakRun().JarFile() c.setOutput("oakRunJar", oakRunJar) diff --git a/examples/docker/src/aem/default/etc/aem.yml b/examples/docker/src/aem/default/etc/aem.yml index 7684057e..f2301d1c 100755 --- a/examples/docker/src/aem/default/etc/aem.yml +++ b/examples/docker/src/aem/default/etc/aem.yml @@ -265,9 +265,6 @@ vendor: "arm64": "x64" "aarch64": "x64" - vault: - download_url: "https://repo1.maven.org/maven2/org/apache/jackrabbit/vault/vault-cli/3.8.2/vault-cli-3.8.2-bin.tar.gz" - # Oak Run tool options (offline instance management) oak_run: download_url: "https://repo1.maven.org/maven2/org/apache/jackrabbit/oak-run/1.72.0/oak-run-1.72.0.jar" diff --git a/pkg/project/app_classic/aem/default/etc/aem.yml b/pkg/project/app_classic/aem/default/etc/aem.yml index 484d3905..2b8e739f 100755 --- a/pkg/project/app_classic/aem/default/etc/aem.yml +++ b/pkg/project/app_classic/aem/default/etc/aem.yml @@ -272,10 +272,6 @@ vendor: download_url: "https://repo1.maven.org/maven2/org/apache/jackrabbit/oak-run/1.72.0/oak-run-1.72.0.jar" store_path: "crx-quickstart/repository/segmentstore" - # Jackrabbit Vault tool (repository content management tool) - vault: - download_url: "https://repo1.maven.org/maven2/org/apache/jackrabbit/vault/vault-cli/3.8.2/vault-cli-3.8.2-bin.tar.gz" - # Content-related options content: clean: diff --git a/pkg/project/app_cloud/aem/default/etc/aem.yml b/pkg/project/app_cloud/aem/default/etc/aem.yml index f5620401..238cb2f6 100755 --- a/pkg/project/app_cloud/aem/default/etc/aem.yml +++ b/pkg/project/app_cloud/aem/default/etc/aem.yml @@ -272,10 +272,6 @@ vendor: download_url: "https://repo1.maven.org/maven2/org/apache/jackrabbit/oak-run/1.72.0/oak-run-1.72.0.jar" store_path: "crx-quickstart/repository/segmentstore" - # Jackrabbit Vault tool (repository content management tool) - vault: - download_url: "https://repo1.maven.org/maven2/org/apache/jackrabbit/vault/vault-cli/3.8.2/vault-cli-3.8.2-bin.tar.gz" - # Content-related options content: clean: diff --git a/pkg/project/instance/aem/default/etc/aem.yml b/pkg/project/instance/aem/default/etc/aem.yml index e32f4dd8..3cd58084 100755 --- a/pkg/project/instance/aem/default/etc/aem.yml +++ b/pkg/project/instance/aem/default/etc/aem.yml @@ -267,10 +267,6 @@ vendor: download_url: "https://repo1.maven.org/maven2/org/apache/jackrabbit/oak-run/1.72.0/oak-run-1.72.0.jar" store_path: "crx-quickstart/repository/segmentstore" - # Jackrabbit Vault tool (repository content management tool) - vault: - download_url: "https://repo1.maven.org/maven2/org/apache/jackrabbit/vault/vault-cli/3.8.2/vault-cli-3.8.2-bin.tar.gz" - # Content-related options content: clean: diff --git a/pkg/vault_cli.go b/pkg/vault_cli.go deleted file mode 100644 index ebbb5f08..00000000 --- a/pkg/vault_cli.go +++ /dev/null @@ -1,118 +0,0 @@ -package pkg - -import ( - "fmt" - log "github.com/sirupsen/logrus" - "github.com/wttech/aemc/pkg/common/execx" - "github.com/wttech/aemc/pkg/common/filex" - "github.com/wttech/aemc/pkg/common/httpx" - "github.com/wttech/aemc/pkg/common/osx" - "github.com/wttech/aemc/pkg/common/pathx" - "os" - "path/filepath" - "strings" -) - -func NewVaultCLI(vendorManager *VendorManager) *VaultCLI { - cv := vendorManager.aem.Config().Values() - - return &VaultCLI{ - vendorManager: vendorManager, - - DownloadURL: cv.GetString("vendor.vault.download_url"), - } -} - -type VaultCLI struct { - vendorManager *VendorManager - - DownloadURL string -} - -type VaultCLILock struct { - DownloadURL string `yaml:"download_url"` -} - -func (v VaultCLI) dir() string { - if v.vendorManager.aem.Detached() { - return filepath.Join(os.TempDir(), "vault-cli") - } - return filepath.Join(v.vendorManager.aem.baseOpts.ToolDir, "vault-cli") -} - -func (v VaultCLI) VltFile() string { - vaultDir, _, _ := strings.Cut(filepath.Base(v.DownloadURL), "-bin") - execDir := filepath.Join(v.dir(), vaultDir, "bin") - if osx.IsWindows() { - return pathx.Canonical(execDir + "/vlt.bat") - } - return pathx.Canonical(execDir + "/vlt") -} - -func (v VaultCLI) lock() osx.Lock[VaultCLILock] { - return osx.NewLock(v.dir()+"/lock/create.yml", func() (VaultCLILock, error) { return VaultCLILock{DownloadURL: v.DownloadURL}, nil }) -} - -func (v VaultCLI) PrepareWithChanged() (bool, error) { - lock := v.lock() - check, err := lock.State() - if err != nil { - return false, err - } - if check.UpToDate { - log.Debugf("existing Vault '%s' is up-to-date", v.DownloadURL) - return false, nil - } - log.Infof("preparing new Vault '%s'", v.DownloadURL) - if err = v.prepare(); err != nil { - return false, err - } - if err = lock.Lock(); err != nil { - return false, err - } - log.Infof("prepared new Vault '%s'", v.DownloadURL) - - return true, nil -} - -func (v VaultCLI) archiveFile() string { - return pathx.Canonical(fmt.Sprintf("%s/%s", v.dir(), filepath.Base(v.DownloadURL))) -} - -func (v VaultCLI) prepare() error { - if err := pathx.DeleteIfExists(v.dir()); err != nil { - return err - } - archiveFile := v.archiveFile() - log.Infof("downloading Vault from URL '%s' to file '%s'", v.DownloadURL, archiveFile) - if err := httpx.DownloadOnce(v.DownloadURL, archiveFile); err != nil { - return err - } - log.Infof("downloaded Vault from URL '%s' to file '%s'", v.DownloadURL, archiveFile) - - log.Infof("unarchiving Vault from file '%s'", archiveFile) - if err := filex.Unarchive(archiveFile, v.dir()); err != nil { - return err - } - log.Infof("unarchived Vault from file '%s'", archiveFile) - return nil -} - -func (v VaultCLI) CommandShell(args []string) error { - _, err := v.PrepareWithChanged() - if err != nil { - return fmt.Errorf("cannot prepare Vault before running command: %w", err) - } - vaultCliArgs := append([]string{v.VltFile()}, args...) - cmd := execx.CommandShell(vaultCliArgs) - env, err := v.vendorManager.JavaManager().Env() - if err != nil { - return err - } - cmd.Env = env - v.vendorManager.aem.CommandOutput(cmd) - if err = cmd.Run(); err != nil { - return fmt.Errorf("cannot run Vault command: %w", err) - } - return nil -} diff --git a/pkg/vendor_manager.go b/pkg/vendor_manager.go index 726b4d9e..2be9d19a 100644 --- a/pkg/vendor_manager.go +++ b/pkg/vendor_manager.go @@ -8,7 +8,6 @@ type VendorManager struct { oakRun *OakRun quickstart *Quickstart sdk *SDK - vaultCLI *VaultCLI } func NewVendorManager(aem *AEM) *VendorManager { @@ -17,7 +16,6 @@ func NewVendorManager(aem *AEM) *VendorManager { result.sdk = NewSDK(result) result.quickstart = NewQuickstart(result) result.oakRun = NewOakRun(result) - result.vaultCLI = NewVaultCLI(result) return result } @@ -59,12 +57,6 @@ func (vm *VendorManager) PrepareWithChanged() (bool, error) { return changed, err } - vaultCLIChanged, err := vm.vaultCLI.PrepareWithChanged() - changed = changed || vaultCLIChanged - if err != nil { - return changed, err - } - return changed, nil } @@ -83,7 +75,3 @@ func (vm *VendorManager) Quickstart() *Quickstart { func (vm *VendorManager) SDK() *SDK { return vm.sdk } - -func (vm *VendorManager) VaultCLI() *VaultCLI { - return vm.vaultCLI -}