Skip to content
This repository was archived by the owner on Sep 18, 2021. It is now read-only.

Commit bdc26d7

Browse files
committed
fix(cli): require project definition for destroy
1 parent 5cf48c0 commit bdc26d7

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

commands/deploy.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import (
1414
// DeployApplication is a command object for Cobra that provides the deploy command
1515
var DeployApplication = &cobra.Command{
1616
Use: "deploy [path to project definition] [ipv4 address]",
17-
Example: "deploy ./my_project_definition.yml 192.168.178.14",
17+
Example: "deploy ./my_project.yml 192.168.178.14",
1818
Short: "Deploy a project onto the target server",
1919
Long: `deploy will deploy the given project onto the server`,
2020
Args: cobra.ExactArgs(2),

commands/destroy.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ package commands
33
import (
44
"fmt"
55
"os"
6+
"path/filepath"
7+
"strings"
68
"sync"
79

810
"github.com/spf13/cobra"
@@ -13,8 +15,8 @@ import (
1315

1416
// DestroyApplication is a command object for Cobra that provides the destroy command
1517
var DestroyApplication = &cobra.Command{
16-
Use: "destroy [project name] [ipv4 address]",
17-
Example: "destroy my_project_name 192.168.178.14",
18+
Use: "destroy [path to project definition] [ipv4 address]",
19+
Example: "destroy ./my_project.yml 192.168.178.14",
1820
Short: "Destroy a deployed project on a target server",
1921
Long: `destroy will tear down the given project that has been deployed onto the server`,
2022
Args: cobra.ExactArgs(2),
@@ -27,11 +29,13 @@ var DestroyApplication = &cobra.Command{
2729
// Generate Inventory file
2830
inventoryFile, err := ansible.CreateInventoryFile(
2931
ansible.IPAddress(args[1]),
32+
ansible.ProjectDefinitionFile(args[0]),
3033
)
34+
3135
if err == nil {
3236
defer os.Remove(inventoryFile)
3337
options := make(map[string]string)
34-
options["project_name"] = args[0]
38+
options["project_name"] = strings.TrimSuffix(strings.TrimSuffix(filepath.Base(args[0]), ".yml"), ".yaml")
3539
err = routines.ExecAnsiblePlaybook("application-destroy", inventoryFile, options)
3640
}
3741

0 commit comments

Comments
 (0)