Skip to content

Commit f11ffc0

Browse files
Use new split config secrets format (#707)
This should make it easier to model the conditional logic across clouds
1 parent 274ab39 commit f11ffc0

4 files changed

Lines changed: 22 additions & 20 deletions

File tree

pkg/common/common.go

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"strings"
1010
"time"
1111

12+
"github.com/google/uuid"
1213
"github.com/pkg/browser"
1314
"github.com/urfave/cli"
1415

@@ -190,12 +191,20 @@ func HandleImport(c *cli.Context) error {
190191
return nil
191192
}
192193

194+
func IsUUIDv4(input string) bool {
195+
_, err := uuid.Parse(input)
196+
return err == nil
197+
}
198+
193199
func GetIdAndName(input string) (id, name *string) {
194-
if strings.HasPrefix(input, "@") {
200+
switch {
201+
case strings.HasPrefix(input, "@"):
195202
h := strings.Trim(input, "@")
196203
name = &h
197-
} else {
204+
case IsUUIDv4(input):
198205
id = &input
206+
default:
207+
name = &input
199208
}
200209
return
201210
}

pkg/common/version.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ func checkRecency() error {
2727

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

pkg/up/generate.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,18 @@ func (ctx *Context) Generate(gitRef string) (dir string, err error) {
4343
{from: ctx.path(fmt.Sprintf("templates/providers/bootstrap/%s.tf", prov)), to: "terraform/mgmt/provider.tf"},
4444
{from: ctx.path(fmt.Sprintf("templates/setup/providers/%s.tf", prov)), to: "terraform/mgmt/mgmt.tf"},
4545
{from: ctx.path("templates/setup/console.tf"), to: "terraform/mgmt/console.tf", cloudless: true},
46-
{from: ctx.path("templates/setup/config-secrets.tf"), to: "terraform/mgmt/config-secrets.tf", cloudless: true},
4746
{from: ctx.path(fmt.Sprintf("templates/providers/apps/%s.tf", prov)), to: "terraform/apps/provider.tf", cloudless: true},
4847
{from: ctx.path("templates/providers/apps/cloud.tf"), to: "terraform/apps/provider.tf", cloud: true},
4948
{from: ctx.path("templates/setup/cd.tf"), to: "terraform/apps/cd.tf"},
5049
{from: ctx.path("README.md"), to: "README.md", overwrite: true},
5150
}
5251

52+
if prov == api.ProviderGCP {
53+
tpls = append(tpls, templatePair{from: ctx.path("templates/setup/config_secrets_gcp.tf"), to: "terraform/mgmt/config_secrets.tf", cloudless: true})
54+
} else {
55+
tpls = append(tpls, templatePair{from: ctx.path("templates/setup/config_secrets.tf"), to: "terraform/mgmt/config_secrets.tf", cloudless: true})
56+
}
57+
5358
for _, tpl := range tpls {
5459
if utils.Exists(tpl.to) && !tpl.overwrite {
5560
fmt.Printf("%s already exists, skipping for now...\n", tpl.to)

pkg/up/prune.go

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import (
44
"os"
55
"os/exec"
66

7-
"github.com/pluralsh/plural-cli/pkg/api"
87
"github.com/pluralsh/plural-cli/pkg/utils"
98
"github.com/pluralsh/plural-cli/pkg/utils/git"
109
)
@@ -30,20 +29,9 @@ func (ctx *Context) Prune() error {
3029
"helm_release.flux",
3130
"helm_release.runtime",
3231
"helm_release.console",
33-
}
34-
35-
if ctx.Provider.Name() == api.ProviderGCP {
36-
toRemove = append(toRemove,
37-
"kubernetes_namespace.infra_gcp",
38-
"kubernetes_secret.runtime_config_gcp",
39-
"kubernetes_secret.console_config_gcp",
40-
)
41-
} else {
42-
toRemove = append(toRemove,
43-
"kubernetes_namespace.infra",
44-
"kubernetes_secret.runtime_config",
45-
"kubernetes_secret.console_config",
46-
)
32+
"kubernetes_namespace.infra",
33+
"kubernetes_secret.runtime_config",
34+
"kubernetes_secret.console_config",
4735
}
4836

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

5947
_ = os.Remove("./terraform/mgmt/console.tf")
60-
_ = os.Remove("./terraform/mgmt/config-secrets.tf")
48+
_ = os.Remove("./terraform/mgmt/config_secrets.tf")
6149
_ = os.RemoveAll("./temp")
6250
_ = os.RemoveAll("./terraform/apps")
6351
_ = os.Remove("./context.yaml")

0 commit comments

Comments
 (0)