Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
19 changes: 19 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@

version: 2
jobs:
release:
docker:
- image: circleci/golang:1.12
steps:
- checkout
- run: curl -sL https://git.io/goreleaser | bash
workflows:
version: 2
release:
jobs:
- release:
filters:
branches:
ignore: /.*/
tags:
only: /v[0-9]+(\.[0-9]+)*(-.*)*/
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,9 @@

# Built Go Packages
shift
dist

# Configfiles
# Config files
config.json
shift.json

Expand Down
25 changes: 25 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
project_name: shift-cli

before:
hooks:
- go mod download
- go generate ./...
builds:
- env:
- CGO_ENABLED=0
archives:
- replacements:
darwin: Darwin
linux: Linux
386: i386
amd64: x86_64
checksum:
name_template: 'checksums.txt'
snapshot:
name_template: "{{ .Tag }}-next"
changelog:
sort: asc
filters:
exclude:
- '^docs:'
- '^test:'
35 changes: 16 additions & 19 deletions cli/internals/destroy/destroy.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package destroy
import (
"errors"
"path/filepath"
"strings"

"github.com/AlecAivazis/survey/v2"
"github.com/leapfrogtechnology/shift/core/services/storage"
Expand All @@ -12,10 +11,10 @@ import (
"github.com/leapfrogtechnology/shift/infrastructure/internals/terraform"
)

func askConfirmation(environment, projectName string) string {
confirmation := ""
prompt := &survey.Input{
Message: "Are you sure you want to destroy " + environment + " environment from " + projectName + " ?(Y/N): ",
func askConfirmation(environment, projectName string) bool {
confirmation := false
prompt := &survey.Confirm{
Message: "Are you sure you want to destroy " + environment + " environment from " + projectName + " ?",
}
survey.AskOne(prompt, &confirmation)

Expand All @@ -32,24 +31,22 @@ func Run(environment string) {
exit.Error(errors.New(message+"'"+environment+"'"), "Error")
}

confirmation := askConfirmation(environment, project.Name)
confirm := askConfirmation(environment, project.Name)

if strings.EqualFold(confirmation, "Y") || strings.EqualFold(confirmation, "yes") {

workspaceRoot := "/tmp"
workspaceDir := filepath.Join(workspaceRoot, project.Name, project.Type, environment)
terraformFile := workspaceDir + "/infrastructure.tf"
if !confirm {
const message = "Operation aborted"
exit.Error(errors.New(message), "Cancelled")
}

exists := file.Exists(terraformFile)
workspaceRoot := "/tmp"
workspaceDir := filepath.Join(workspaceRoot, project.Name, project.Type, environment)
terraformFile := workspaceDir + "/infrastructure.tf"

if exists {
terraform.DestroyInfrastructure(workspaceDir)
} else {
terraform.MakeTempAndDestroy(project, environment, workspaceDir)
}
exists := file.Exists(terraformFile)

if exists {
terraform.DestroyInfrastructure(workspaceDir)
} else {
const message = "Operation aborted"
exit.Error(errors.New(message), "Cancelled")
terraform.MakeTempAndDestroy(project, environment, workspaceDir)
}
}