Skip to content
Open
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
38 changes: 26 additions & 12 deletions cmd/modify.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ package cmd

import (
"fmt"
"strings"

"github.com/apppackio/apppack/stacks"
"github.com/apppackio/apppack/ui"
Expand Down Expand Up @@ -86,32 +87,45 @@ func modifyAppStack(cfg aws.Config, stack *stacks.AppStack, name string, flags *
return nil
}

func askModifyQuestions(cfg aws.Config, stack *stacks.AppStack) error {
var questions []*ui.QuestionExtra

func askModifyQuestions(_ aws.Config, stack *stacks.AppStack) error {
// Repository URL
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DeepSource flagged on this file: modifyAppStack cyclomatic complexity 17 (GO-R1005) and two CRT-P0003 heavy-parameter findings (aws.Config is 696 bytes, passed by value). Both predate this PR — the changes here only added the new form-builder calls — so I wouldn't block on them.

Worth a follow-up ticket: switch aws.Config params to *aws.Config repo-wide and split modifyAppStack into the flag-mode and interactive-mode branches as separate functions. Not in scope here.

questions = append(questions, stacks.BuildRepositoryURLQuestion(&stack.Parameters.RepositoryURL))

if err := ui.AskQuestions(questions, stack.Parameters); err != nil {
repoForm, repoPtr := stacks.AppRepositoryURLForm(stack.Parameters.RepositoryURL)
if err := repoForm.Run(); err != nil {
return err
}

stack.Parameters.RepositoryURL = *repoPtr

if err := stack.Parameters.SetRepositoryType(); err != nil {
return err
}

questions = []*ui.QuestionExtra{}

// Branch and Domains (only for non-pipeline apps)
if !stack.Pipeline {
questions = append(questions, stacks.BuildBranchQuestion(&stack.Parameters.Branch))
questions = append(questions, stacks.BuildDomainsQuestion(&stack.Parameters.Domains))
branchForm, branchPtr := stacks.AppBranchForm(stack.Parameters.Branch)
if err := branchForm.Run(); err != nil {
return err
}

stack.Parameters.Branch = *branchPtr

domainsForm, domainsPtr := stacks.AppDomainsForm(stack.Parameters.Domains)
if err := domainsForm.Run(); err != nil {
return err
}

stack.Parameters.Domains = strings.Split(*domainsPtr, "\n")
}

// Healthcheck path
questions = append(questions, stacks.BuildHealthCheckPathQuestion(&stack.Parameters.HealthCheckPath))
healthForm, healthPtr := stacks.AppHealthCheckPathForm(stack.Parameters.HealthCheckPath)
if err := healthForm.Run(); err != nil {
return err
}

stack.Parameters.HealthCheckPath = *healthPtr

return ui.AskQuestions(questions, stack.Parameters)
return nil
}

// modifyCmd represents the modify command
Expand Down
Loading
Loading