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
13 changes: 11 additions & 2 deletions pkg/common/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"strings"
"time"

"github.com/google/uuid"
"github.com/pkg/browser"
"github.com/urfave/cli"

Expand Down Expand Up @@ -190,12 +191,20 @@ func HandleImport(c *cli.Context) error {
return nil
}

func IsUUIDv4(input string) bool {
_, err := uuid.Parse(input)
return err == nil
}

func GetIdAndName(input string) (id, name *string) {
if strings.HasPrefix(input, "@") {
switch {
case strings.HasPrefix(input, "@"):
h := strings.Trim(input, "@")
name = &h
} else {
case IsUUIDv4(input):
id = &input
default:
name = &input
}
return
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/common/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func checkRecency() error {

if Version == versionPlaceholder || strings.Contains(Version, "-") {
utils.Warn("\nThis is a development version, which can be significantly different from official releases")
utils.Warn("\nYou can download latest release from https://github.com/pluralsh/plural-cli/releases/latest\n")
utils.Warn("\nYou can download the latest release from https://github.com/pluralsh/plural-cli/releases/latest\n")
return nil
}

Expand Down
7 changes: 6 additions & 1 deletion pkg/up/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,18 @@ func (ctx *Context) Generate(gitRef string) (dir string, err error) {
{from: ctx.path(fmt.Sprintf("templates/providers/bootstrap/%s.tf", prov)), to: "terraform/mgmt/provider.tf"},
{from: ctx.path(fmt.Sprintf("templates/setup/providers/%s.tf", prov)), to: "terraform/mgmt/mgmt.tf"},
{from: ctx.path("templates/setup/console.tf"), to: "terraform/mgmt/console.tf", cloudless: true},
{from: ctx.path("templates/setup/config-secrets.tf"), to: "terraform/mgmt/config-secrets.tf", cloudless: true},
{from: ctx.path(fmt.Sprintf("templates/providers/apps/%s.tf", prov)), to: "terraform/apps/provider.tf", cloudless: true},
{from: ctx.path("templates/providers/apps/cloud.tf"), to: "terraform/apps/provider.tf", cloud: true},
{from: ctx.path("templates/setup/cd.tf"), to: "terraform/apps/cd.tf"},
{from: ctx.path("README.md"), to: "README.md", overwrite: true},
}

if prov == api.ProviderGCP {
tpls = append(tpls, templatePair{from: ctx.path("templates/setup/config_secrets_gcp.tf"), to: "terraform/mgmt/config_secrets.tf", cloudless: true})
} else {
tpls = append(tpls, templatePair{from: ctx.path("templates/setup/config_secrets.tf"), to: "terraform/mgmt/config_secrets.tf", cloudless: true})
}

for _, tpl := range tpls {
if utils.Exists(tpl.to) && !tpl.overwrite {
fmt.Printf("%s already exists, skipping for now...\n", tpl.to)
Expand Down
20 changes: 4 additions & 16 deletions pkg/up/prune.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"os"
"os/exec"

"github.com/pluralsh/plural-cli/pkg/api"
"github.com/pluralsh/plural-cli/pkg/utils"
"github.com/pluralsh/plural-cli/pkg/utils/git"
)
Expand All @@ -30,20 +29,9 @@ func (ctx *Context) Prune() error {
"helm_release.flux",
"helm_release.runtime",
"helm_release.console",
}

if ctx.Provider.Name() == api.ProviderGCP {
toRemove = append(toRemove,
"kubernetes_namespace.infra_gcp",
"kubernetes_secret.runtime_config_gcp",
"kubernetes_secret.console_config_gcp",
)
} else {
toRemove = append(toRemove,
"kubernetes_namespace.infra",
"kubernetes_secret.runtime_config",
"kubernetes_secret.console_config",
)
"kubernetes_namespace.infra",
"kubernetes_secret.runtime_config",
"kubernetes_secret.console_config",
}

for _, field := range toRemove {
Expand All @@ -57,7 +45,7 @@ func (ctx *Context) Prune() error {
}

_ = os.Remove("./terraform/mgmt/console.tf")
_ = os.Remove("./terraform/mgmt/config-secrets.tf")
_ = os.Remove("./terraform/mgmt/config_secrets.tf")
_ = os.RemoveAll("./temp")
_ = os.RemoveAll("./terraform/apps")
_ = os.Remove("./context.yaml")
Expand Down
Loading