Skip to content

Commit 2a59862

Browse files
Instance init => validate
1 parent 15b0e1b commit 2a59862

File tree

3 files changed

+24
-17
lines changed

3 files changed

+24
-17
lines changed

cmd/aem/instance.go

+8-8
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ func (c *CLI) instanceCmd() *cobra.Command {
2323
cmd.AddCommand(c.instanceListCmd())
2424
cmd.AddCommand(c.instanceAwaitCmd())
2525
cmd.AddCommand(c.instanceBackupCmd())
26-
cmd.AddCommand(c.instanceInitCmd())
26+
cmd.AddCommand(c.instanceValidateCmd())
2727
cmd.AddCommand(c.instanceImportCmd())
2828
return cmd
2929
}
@@ -335,19 +335,19 @@ func (c *CLI) instanceListCmd() *cobra.Command {
335335
}
336336
}
337337

338-
func (c *CLI) instanceInitCmd() *cobra.Command {
338+
func (c *CLI) instanceValidateCmd() *cobra.Command {
339339
return &cobra.Command{
340-
Use: "init",
341-
Aliases: []string{"initialize"},
342-
Short: "Init prerequisites for AEM instance(s)",
340+
Use: "validate",
341+
Aliases: []string{"verify"},
342+
Short: "Validate prerequisites for AEM instance(s)",
343343
Run: func(cmd *cobra.Command, args []string) {
344-
if err := c.aem.InstanceManager().LocalOpts.Initialize(); err != nil {
344+
if err := c.aem.InstanceManager().LocalOpts.Validate(); err != nil {
345345
c.Error(err)
346346
return
347347
}
348348

349-
c.SetOutput("initialized", true)
350-
c.Changed("initialized prerequisites for instance(s)")
349+
c.SetOutput("validated", true)
350+
c.Changed("Validated prerequisites for instance(s)")
351351
},
352352
}
353353
}

cmd/aem/vendor.go

+13-6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package main
22

33
import (
4+
log "github.com/sirupsen/logrus"
45
"github.com/spf13/cobra"
56
)
67

@@ -19,20 +20,22 @@ func (c *CLI) vendorCmd() *cobra.Command {
1920
func (c *CLI) vendorListCmd() *cobra.Command {
2021
cmd := &cobra.Command{
2122
Use: "list",
22-
Short: "List all prepared vendors",
23+
Short: "List vendor tools available",
2324
Aliases: []string{"ls"},
2425
Run: func(cmd *cobra.Command, args []string) {
26+
errored := false
27+
2528
javaHome, err := c.aem.VendorManager().JavaManager().FindHomeDir()
2629
if err != nil {
27-
c.Error(err)
28-
return
30+
errored = true
31+
log.Warnf("java home not available: %s", err)
2932
}
3033
c.SetOutput("javaHome", javaHome)
3134

3235
javaExecutable, err := c.aem.VendorManager().JavaManager().Executable()
3336
if err != nil {
34-
c.Error(err)
35-
return
37+
errored = true
38+
log.Warnf("java executable not available: %s", err)
3639
}
3740
c.SetOutput("javaExecutable", javaExecutable)
3841

@@ -42,7 +45,11 @@ func (c *CLI) vendorListCmd() *cobra.Command {
4245
oakRunJar := c.aem.VendorManager().OakRun().JarFile()
4346
c.setOutput("oakRunJar", oakRunJar)
4447

45-
c.Ok("vendors listed")
48+
if errored {
49+
c.Fail("vendor tool listed with errors")
50+
} else {
51+
c.Ok("vendor tools listed")
52+
}
4653
},
4754
}
4855
return cmd

pkg/local_instance_manager.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ func NewLocalOpts(manager *InstanceManager) *LocalOpts {
4646
return result
4747
}
4848

49-
func (o *LocalOpts) Initialize() error {
49+
func (o *LocalOpts) Validate() error {
5050
// validate phase (fast feedback)
5151
if err := o.validateUnpackDir(); err != nil {
5252
return err
@@ -127,7 +127,7 @@ func (im *InstanceManager) CreateAll() ([]Instance, error) {
127127

128128
func (im *InstanceManager) Create(instances []Instance) ([]Instance, error) {
129129
created := []Instance{}
130-
if err := im.LocalOpts.Initialize(); err != nil {
130+
if err := im.LocalOpts.Validate(); err != nil {
131131
return created, err
132132
}
133133
log.Info(InstancesMsg(instances, "creating"))
@@ -202,7 +202,7 @@ func (im *InstanceManager) Start(instances []Instance) ([]Instance, error) {
202202
log.Debugf("no instances to start")
203203
return []Instance{}, nil
204204
}
205-
if err := im.LocalOpts.Initialize(); err != nil {
205+
if err := im.LocalOpts.Validate(); err != nil {
206206
return []Instance{}, err
207207
}
208208

0 commit comments

Comments
 (0)