Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tools upgrade #281

Merged
merged 29 commits into from
Nov 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
e282335
Prepare PoC
krystian-panek-vmltech Nov 14, 2024
a4d0b58
Vendor manager introduction
krystian-panek-vmltech Nov 15, 2024
5da9075
Init almost work
krystian-panek-vmltech Nov 15, 2024
4219fc9
Project scaffold etc
krystian-panek-vmltech Nov 15, 2024
15b0e1b
Docs
krystian-panek-vmltech Nov 15, 2024
2a59862
Instance init => validate
krystian-panek-vmltech Nov 15, 2024
64d6910
Bump tools
krystian-panek-vmltech Nov 15, 2024
d0c05fb
Config wrap
krystian-panek-vmltech Nov 15, 2024
6e0797b
Config adjustments
krystian-panek-vmltech Nov 15, 2024
80d0a84
Vendor namespace in config
krystian-panek-vmltech Nov 15, 2024
45d81b6
Java home and project init imprs
krystian-panek-vmltech Nov 15, 2024
5ee3c15
Minor
krystian-panek-vmltech Nov 15, 2024
7f37a91
fixed vault-cli
Nov 17, 2024
069e944
Base opts refactoring
krystian-panek-vmltech Nov 18, 2024
6cffdb7
Merge branch 'tools-upgrade' of github.com:wttech/aemc into tools-upg…
krystian-panek-vmltech Nov 18, 2024
fa3aaba
Base lib config
krystian-panek-vmltech Nov 18, 2024
171f3f8
Missing piece in Java override
krystian-panek-vmltech Nov 18, 2024
8f70bc3
Docker/Podman switch
krystian-panek-vmltech Nov 18, 2024
bf105c7
Merge branch 'main' into tools-upgrade
dominik-przybyl-wttech Nov 18, 2024
5b547b2
Vault using vendored java
krystian-panek-vmltech Nov 19, 2024
6cb8222
Hiding vlt / incubation
krystian-panek-vmltech Nov 19, 2024
bece1c0
Vault CLI removed / to be reverted if needed
krystian-panek-vmltech Nov 19, 2024
cd7a344
Podman check / fix
krystian-panek-vmltech Nov 19, 2024
5832e47
fixed issue that dir name or file name starts with dot character (pro…
Nov 19, 2024
0aaeaf3
fixed scaffold parameters
Nov 19, 2024
faacc82
Eliminate warn
krystian-panek-vmltech Nov 19, 2024
c4d9570
Podman support
krystian-panek-vmltech Nov 19, 2024
673e1bc
Minor
krystian-panek-vmltech Nov 19, 2024
1095209
Minor
krystian-panek-vmltech Nov 19, 2024
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
42 changes: 12 additions & 30 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -138,31 +138,29 @@ Supported project types:

---

Run command below to initialize the AEM Compose tool in your project:
Run command below to install the AEM Compose tool in your project:

```shell
curl https://raw.githubusercontent.com/wttech/aemc/main/project-init.sh | sh
curl https://raw.githubusercontent.com/wttech/aemc/main/project-install.sh | sh
```

and then:

```shell
sh aemw init
```

After successful initialization, remember to always use the tool via wrapper script in the following way:
After successful installation, remember to always use the tool via wrapper script in the following way:

```shell
sh aemw [command]
```

For example:
Next scaffold the AEM Compose files in the project:

```shell
sh aemw version
sh aemw project scaffold
```

Project initialization sets up ready-to-use tasks powered by [Task tool](https://taskfile.dev/) which are aggregating one or many AEM Compose CLI commands into useful procedures.
Project scaffolding:

- sets up ready-to-use tasks powered by [Task tool](https://taskfile.dev/), which aggregate one or many AEM Compose CLI commands into useful procedures.
- provides configuration for provisioning AEM instances (installing service pack, setting replication agents, etc.).
- provides configuration for running AEM Dispatcher on [Podman](https://podman-desktop.io/) or [Docker](https://www.docker.com/products/docker-desktop/).

To list all available tasks, run:

Expand All @@ -176,19 +174,6 @@ For example:
sh taskw setup
```

Some tasks like `aem:build` may accept parameters.
For example, to build AEM application with:

- Applying frontend development mode Maven profile
- Unit tests skipping
- UI tests skipping

Simply run command with appending [task variable](https://taskfile.dev/usage/#variables) to the end:

```shell
sh taskw aem:build AEM_BUILD_ARGS="-PfedDev -DskipTests -pl '!ui.tests'"
```

## IaaC Providers

The tool is designed to be used in Infrastructure as a Code (IaaC) solutions such as [Terraform](https://www.terraform.io/) or [Pulumi](https://www.pulumi.com/).
Expand Down Expand Up @@ -378,7 +363,7 @@ instance:

# Oak Run tool options (offline instance management)
oak_run:
download_url: "https://repo1.maven.org/maven2/org/apache/jackrabbit/oak-run/1.44.0/oak-run-1.44.0.jar"
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"

# Source files
Expand Down Expand Up @@ -458,7 +443,7 @@ java:
# Auto-installed JDK options
download:
# Source URL with template vars support
url: "https://github.com/adoptium/temurin11-binaries/releases/download/jdk-11.0.18%2B10/OpenJDK11U-jdk_[[.Arch]]_[[.Os]]_hotspot_11.0.18_10.[[.ArchiveExt]]"
url: "https://github.com/adoptium/temurin11-binaries/releases/download/jdk-11.0.25%2B9/OpenJDK11U-jdk_[[.Arch]]_[[.Os]]_hotspot_11.0.25_9.[[.ArchiveExt]]"
# Map source URL template vars to be compatible with Adoptium Java
replacements:
# Var 'Os' (GOOS)
Expand All @@ -471,9 +456,6 @@ java:
"arm64": "x64"
"aarch64": "x64"

vault:
"download_url": "https://repo1.maven.org/maven2/org/apache/jackrabbit/vault/vault-cli/3.7.2/vault-cli-3.7.2-bin.tar.gz"

base:
# Location of temporary files (downloaded AEM packages, etc)
tmp_dir: aem/home/tmp
Expand Down
6 changes: 3 additions & 3 deletions cmd/aem/crypto.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package main
import (
"github.com/spf13/cobra"
"github.com/wttech/aemc/pkg"
"github.com/wttech/aemc/pkg/common"
"github.com/wttech/aemc/pkg/common/mapsx"
)

Expand Down Expand Up @@ -59,8 +58,9 @@ func (c *CLI) cryptoSetupCmd() *cobra.Command {
}
},
}
cmd.Flags().String("hmac-file", common.LibDir+"/crypto/data/hmac", "Path to file 'hmac'")
cmd.Flags().String("master-file", common.LibDir+"/crypto/data/master", "Path to file 'master'")
libDir := c.config.Values().GetString("base.lib_dir")
cmd.Flags().String("hmac-file", libDir+"/crypto/data/hmac", "Path to file 'hmac'")
cmd.Flags().String("master-file", libDir+"/crypto/data/master", "Path to file 'master'")
return cmd
}

Expand Down
32 changes: 0 additions & 32 deletions cmd/aem/instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ func (c *CLI) instanceCmd() *cobra.Command {
cmd.AddCommand(c.instanceListCmd())
cmd.AddCommand(c.instanceAwaitCmd())
cmd.AddCommand(c.instanceBackupCmd())
cmd.AddCommand(c.instanceInitCmd())
cmd.AddCommand(c.instanceImportCmd())
return cmd
}
Expand Down Expand Up @@ -334,34 +333,3 @@ func (c *CLI) instanceListCmd() *cobra.Command {
},
}
}

func (c *CLI) instanceInitCmd() *cobra.Command {
return &cobra.Command{
Use: "init",
Aliases: []string{"initialize"},
Short: "Init prerequisites for AEM instance(s)",
Run: func(cmd *cobra.Command, args []string) {
if err := c.aem.InstanceManager().LocalOpts.Initialize(); err != nil {
c.Error(err)
return
}

javaHome, err := c.aem.JavaOpts().FindHomeDir()
if err != nil {
c.Error(err)
return
}
c.SetOutput("javaHome", javaHome)

javaExecutable, err := c.aem.JavaOpts().Executable()
if err != nil {
c.Error(err)
return
}
c.SetOutput("javaExecutable", javaExecutable)

c.SetOutput("initialized", true)
c.Changed("initialized prerequisites for instance(s)")
},
}
}
80 changes: 68 additions & 12 deletions cmd/aem/project.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,26 @@ import (
"strings"
)

func (c *CLI) projectCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "project",
Short: "Manage project files",
Aliases: []string{"prj"},
}
cmd.AddCommand(c.projectInitCmd())
cmd.AddCommand(c.projectScaffoldCmd())

return cmd
}

const projectKindFlag = "project-kind"

func (c *CLI) initCmd() *cobra.Command {
func (c *CLI) projectScaffoldCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "init",
Aliases: []string{"initialize"},
Short: "Initializes AEMC in the project",
Use: "scaffold",
Aliases: []string{"setup"},
Short: "Scaffold required files in the project",
Run: func(cmd *cobra.Command, args []string) {
if err := c.aem.Project().EnsureDirs(); err != nil {
c.Error(err)
return
}
kindName, _ := cmd.Flags().GetString(projectKindFlag)
kind, err := c.aem.Project().KindDetermine(kindName)
if err != nil {
Expand All @@ -29,24 +37,72 @@ func (c *CLI) initCmd() *cobra.Command {
c.Fail(fmt.Sprintf("project kind cannot be determined; specify it with flag '--%s=[%s]'", projectKindFlag, strings.Join(project.KindStrings(), "|")))
return
}
changed, err := c.aem.Project().InitializeWithChanged(kind)

changed, err := c.aem.Project().ScaffoldWithChanged(kind)
if err != nil {
c.Error(err)
return
}

c.SetOutput("gettingStarted", c.aem.Project().ScaffoldGettingStarted())

if changed {
c.Changed("project files scaffolded")
} else {
c.Ok("project files already scaffolded")
}
},
}
cmd.Flags().String(projectKindFlag, project.KindAuto, fmt.Sprintf("Type of AEM to work with (%s)", strings.Join(project.KindStrings(), "|")))
return cmd
}

func (c *CLI) projectInitCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "init",
Aliases: []string{"initialize"},
Short: "Initializes AEMC in the project",
Run: func(cmd *cobra.Command, args []string) {
if !c.aem.Project().IsScaffolded() {
c.Fail(fmt.Sprintf("project need to be scaffolded before running initialization"))
return
}

changed := false

c.SetOutput("gettingStarted", c.aem.Project().InitGettingStartedError())

baseChanged, err := c.aem.BaseOpts().PrepareWithChanged()
changed = changed || baseChanged
if err != nil {
c.Error(err)
return
}
gettingStarted, err := c.aem.Project().GettingStarted(kind)
c.SetOutput("baseChanged", baseChanged)

// Download and prepare vendor tools (including JDK and AEM SDK)
vendorPrepared, err := c.aem.VendorManager().PrepareWithChanged()
changed = changed || vendorPrepared
if err != nil {
c.Error(err)
return
}
c.SetOutput("gettingStarted", gettingStarted)
c.SetOutput("vendorPrepared", vendorPrepared)

// Validate AEM instance files and prepared SDK
if err := c.aem.InstanceManager().LocalOpts.Validate(); err != nil {
c.Error(err)
return
}

c.SetOutput("gettingStarted", c.aem.Project().InitGettingStartedSuccess())

if changed {
c.Changed("project initialized")
} else {
c.Ok("project already initialized")
}
},
}
cmd.Flags().String(projectKindFlag, project.KindAuto, fmt.Sprintf("Type of AEM to work with (%s)", strings.Join(project.KindStrings(), "|")))
return cmd
}
6 changes: 4 additions & 2 deletions cmd/aem/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ func (c *CLI) rootCmd() *cobra.Command {
},
}
cmd.AddCommand(c.versionCmd())
cmd.AddCommand(c.initCmd())
cmd.AddCommand(c.projectCmd())
cmd.AddCommand(c.vendorCmd())
cmd.AddCommand(c.configCmd())
cmd.AddCommand(c.instanceCmd())
cmd.AddCommand(c.osgiCmd())
Expand All @@ -33,8 +34,9 @@ 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)

return cmd
}

Expand Down
30 changes: 0 additions & 30 deletions cmd/aem/vault.go

This file was deleted.

76 changes: 76 additions & 0 deletions cmd/aem/vendor.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
package main

import (
log "github.com/sirupsen/logrus"
"github.com/spf13/cobra"
"os"
)

func (c *CLI) vendorCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "vendor",
Short: "Supportive tools management",
Aliases: []string{"ven"},
}
cmd.AddCommand(c.vendorListCmd())
cmd.AddCommand(c.vendorPrepareCmd())

return cmd
}

func (c *CLI) vendorListCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "list",
Short: "List vendor tools available",
Aliases: []string{"ls"},
Run: func(cmd *cobra.Command, args []string) {
verbose, _ := cmd.Flags().GetBool("verbose")

javaHome, err := c.aem.VendorManager().JavaManager().FindHomeDir()
if err != nil {
javaHome = os.Getenv("JAVA_HOME")
if verbose {
log.Warnf("java home not available: %s", err)
}
}
c.SetOutput("javaHome", javaHome)

javaExecutable, err := c.aem.VendorManager().JavaManager().Executable()
if err != nil {
if verbose {
log.Warnf("java executable not available: %s", err)
}
}
c.SetOutput("javaExecutable", javaExecutable)

oakRunJar := c.aem.VendorManager().OakRun().JarFile()
c.setOutput("oakRunJar", oakRunJar)

c.Ok("vendor tools listed")
},
}
cmd.Flags().BoolP("verbose", "v", false, "Log errors")
return cmd
}

func (c *CLI) vendorPrepareCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "prepare",
Short: "Prepare vendor tools",
Aliases: []string{"prep", "download", "dw"},
Run: func(cmd *cobra.Command, args []string) {
changed, err := c.aem.VendorManager().PrepareWithChanged()
if err != nil {
c.Error(err)
return
}

if changed {
c.Changed("vendor tools prepared")
} else {
c.Ok("vendor tools already prepared")
}
},
}
return cmd
}
Loading
Loading