Skip to content
This repository has been archived by the owner on Aug 6, 2024. It is now read-only.

Commit

Permalink
adds aliases
Browse files Browse the repository at this point in the history
Signed-off-by: Lorenzo Setale <[email protected]>
  • Loading branch information
koalalorenzo committed Nov 15, 2020
1 parent aa4abe5 commit 3554984
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 18 deletions.
5 changes: 3 additions & 2 deletions cmd/pack.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@ import (

// packCmd represents the pack command
var packCmd = &cobra.Command{
Use: "pack [path]",
Short: "Build a Backpack file (pack) from a directory/template",
Use: "pack [path]",
Aliases: []string{"package"},
Short: "Build a Backpack file (pack) from a directory/template",
Long: `Generate a Backpack file (pack) from a directory containing the various
jobs, metadata and documentation.
Expand Down
9 changes: 5 additions & 4 deletions cmd/plan.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@ import (

// planCmd represents the run command
var planCmd = &cobra.Command{
Use: "plan [path]",
Args: cobra.ExactArgs(1),
Short: "Plan and check the changes before running a pack",
Use: "plan [path]",
Aliases: []string{"diff", "dry-run"},
Args: cobra.ExactArgs(1),
Short: "Plan and check the changes before running a pack",
Long: `It allows you to plan ahead before running/registering jobs.
It is useful when combined with existing jobs to validate changes. By default
the output shows you a brief summary of changes, but if you want to see the
Expand Down Expand Up @@ -81,7 +82,7 @@ func planRun(cmd *cobra.Command, args []string) {
}
// For each job file perform the plan! 🚀
for name, hcl := range bts {
job, err := client.GetJob(string(hcl))
job, err := client.GetJobFromCode(string(hcl))
if err != nil {
log.Fatalf("Error obtaining job %s: %s", name, err)
}
Expand Down
9 changes: 5 additions & 4 deletions cmd/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@ import (

// runCmd represents the run command
var runCmd = &cobra.Command{
Use: "run [path]",
Args: cobra.ExactArgs(1),
Short: "Starts the jobs of a pack",
Use: "run [path]",
Aliases: []string{"start", "install"},
Args: cobra.ExactArgs(1),
Short: "Starts the jobs of a pack",
Long: `It allows to run different jobs specified in the pack.
It accepts one argument that is the path or URL of the file, but if the option
--unpacked (or -u is) passed it consider the first argument as the path of an
Expand Down Expand Up @@ -62,7 +63,7 @@ func runRun(cmd *cobra.Command, args []string) {
// then store the job ID in the backpack to show it afterwards.
jIDs := map[string]string{}
for name, hcl := range bts {
job, err := client.GetJob(string(hcl))
job, err := client.GetJobFromCode(string(hcl))
if err != nil {
log.Fatalf("Error obtaining job %s: %s", name, err)
}
Expand Down
9 changes: 5 additions & 4 deletions cmd/unpack.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,11 @@ import (

// unpackCmd represents the unpack command
var unpackCmd = &cobra.Command{
Use: "unpack [file.backpack]",
Args: cobra.ExactArgs(1),
Run: unpackRun,
Short: "Opens a pack file to explore content",
Use: "unpack [file.backpack]",
Aliases: []string{"pull"},
Args: cobra.ExactArgs(1),
Run: unpackRun,
Short: "Opens a pack file to explore content",
Long: `Explodes/Open the pack inside a directory. This is useful to edit a
pack, inspecting it or seeing default values... or if you are looking for
something inside it and you know it is at the bottom of the backpack!
Expand Down
2 changes: 1 addition & 1 deletion conn/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func NewClient() (co *Client, err error) {

// IsValid that is the question!
func (co *Client) IsValid(code string) bool {
job, err := co.GetJob(code)
job, err := co.GetJobFromCode(code)
if err != nil {
return false
}
Expand Down
11 changes: 8 additions & 3 deletions conn/client_job.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,12 @@ import (
"github.com/hashicorp/nomad/api"
)

// Run is parsing the HCL code and registering the Job into Nomad
func (co *Client) GetJob(code string) (*api.Job, error) {
return co.c.Jobs().ParseHCL(code, true)
// GetJobFromCode is parsing the HCL code and providing a api.Job{} pointer
func (co *Client) GetJobFromCode(code string) (*api.Job, error) {
return co.jobs.ParseHCL(code, true)
}

func (co *Client) GetJobStatus(jobId string) (j *api.Job, err error) {
j, _, err = co.jobs.Info(jobId, nil)
return
}

0 comments on commit 3554984

Please sign in to comment.