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
4 changes: 3 additions & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ linters:
- gocheckcompilerdirectives
- gochecksumtype
- gocognit
- goconst
- gocritic
- gocyclo
- godoclint
Expand Down Expand Up @@ -125,6 +124,7 @@ linters:
- funlen
- gochecknoglobals
- gochecknoinits
- goconst
- lll
- mirror
- mnd
Expand Down Expand Up @@ -153,6 +153,8 @@ linters:
- 'utils.+'
gosec:
confidence: medium
excludes:
- G704
varnamelen:
check-type-param: true
ignore-type-assert-ok: true
Expand Down
7 changes: 6 additions & 1 deletion cmd/automation.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"path/filepath"
"strconv"
"strings"
"time"

"github.com/pulumi/pulumi/sdk/v3/go/auto"
"github.com/pulumi/pulumi/sdk/v3/go/auto/optdestroy"
Expand Down Expand Up @@ -182,7 +183,11 @@ func stackExists(ctx context.Context, fqsn string) bool {
req.Header.Add("Accept", "application/json")
req.Header.Add("Authorization", auth)

res, err := http.DefaultClient.Do(req)
httpAPIClient := &http.Client{
Timeout: time.Second * 30,
}

res, err := httpAPIClient.Do(req)
if err != nil {
logger.Error("client http request: " + err.Error())
}
Expand Down
1 change: 1 addition & 0 deletions cmd/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ var createCmd = &cobra.Command{
if err != nil {
logger.Error("generate age keys: " + err.Error())
}

ageKeyMap := map[string]any{
"publicKey": ageKeys.Recipient().String(),
"privateKey": FnSecret(ageKeys.String()),
Expand Down
1 change: 1 addition & 0 deletions cmd/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ var deployCmd = &cobra.Command{
}

var idx int

for k, i := range stacks {
i.Path = filepath.Join(paths.Projects, platform.Name, "cmd", i.Name)
i.GetFullName(ctx)
Expand Down
5 changes: 5 additions & 0 deletions cmd/destroy.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,14 @@ var destroyCmd = &cobra.Command{

addPrePostRun := func(action, s string, b bool, i int) {
funcs := make([]string, 0)

switch action {
case "pre":
funcs = destroyStacks[i].PreRun
case "post":
funcs = destroyStacks[i].PostRun
}

if b {
funcs = append(funcs, s)
if action == "pre" {
Expand All @@ -53,18 +55,21 @@ var destroyCmd = &cobra.Command{
if destroyTarget != "apl" {
if !purgeObj {
prompt := "WARNING: purge data in app platform obj buckets? (type YES to confirm)"

purgeObj = InputPrompt("warn", "YES", prompt)
if !purgeObj {
logger.Warn("line:ignoring obj buckets")
}
}

addPrePostRun("pre", "deleteObj", purgeObj, 2)
}
},
Run: func(cmd *cobra.Command, args []string) {
ctx := context.Background()

var idx int

for k, i := range destroyStacks {
i.Path = filepath.Join(paths.Projects, platform.Name, "cmd", i.Name)
i.GetFullName(ctx)
Expand Down
1 change: 1 addition & 0 deletions cmd/rclone.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ type PurgeRequest struct {
RmDirs bool `json:"rmdirs,omitempty"` // add --rmDirs flag to rclone delete command
}

//nolint:gosec
type s3Remote struct {
AccessKeyId string `json:"accessKey,omitempty"`
Acl string `json:"acl,omitempty"`
Expand Down
2 changes: 2 additions & 0 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ var initCmd = &cobra.Command{
Short: "Initialize a new aplcli environment",
PreRunE: func(cmd *cobra.Command, args []string) error {
path := projPath()

err := os.MkdirAll(path.Projects, 0754)
if err != nil {
logger.Error("project directory creation: " + err.Error())
Expand Down Expand Up @@ -112,6 +113,7 @@ var initCmd = &cobra.Command{
fsDir := "templates/values"
exTpl := "values-example.tpl"
fname := filepath.Join(paths.Values, exTpl)

v, err := templates.ReadFile(fsDir + "/" + exTpl)
if err != nil {
msg := fmt.Sprintf("read %s: %s", exTpl, err.Error())
Expand Down
15 changes: 13 additions & 2 deletions cmd/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package cmd
import (
"bufio"
"context"
"encoding/json"
"errors"
"fmt"
"os"
Expand All @@ -12,6 +13,10 @@ import (
"time"
)

type PulumiUser struct {
User string `json:"user"`
}

func missingToken(tokenVar string) {
var (
envTxt string
Expand Down Expand Up @@ -81,7 +86,7 @@ func GetPulumiUser() string {
logger.Error("skip update check: " + err.Error())
}

cmd := exec.CommandContext(ctx, "pulumi", "whoami", "--non-interactive")
cmd := exec.CommandContext(ctx, "pulumi", "whoami", "--non-interactive", "--json")

stdout, err := cmd.CombinedOutput()
if err != nil {
Expand All @@ -94,7 +99,13 @@ func GetPulumiUser() string {
}
}

return string(stdout)
var pulumiUser PulumiUser

if err := json.Unmarshal(stdout, &pulumiUser); err != nil {
logger.Error("json unmarshal data from `pulumi whoami` command: " + err.Error())
}

return pulumiUser.User
}

func SetupPrompt(promptStr string) string {
Expand Down
4 changes: 3 additions & 1 deletion cmd/templates/ci/golangci.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ linters:
- gocheckcompilerdirectives
- gochecksumtype
- gocognit
- goconst
- gocritic
- gocyclo
- godoclint
Expand Down Expand Up @@ -125,6 +124,7 @@ linters:
- funlen
- gochecknoglobals
- gochecknoinits
- goconst
- lll
- mirror
- mnd
Expand Down Expand Up @@ -153,6 +153,8 @@ linters:
- 'utils.+'
gosec:
confidence: medium
excludes:
- G704
varnamelen:
check-type-param: true
ignore-type-assert-ok: true
Expand Down
Loading