Skip to content

Commit

Permalink
fix: adds global GracefulPanic and checks to deploy TUI (#542)
Browse files Browse the repository at this point in the history
  • Loading branch information
UncleGedd authored Apr 1, 2024
1 parent 6726b8f commit e333eac
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 22 deletions.
2 changes: 2 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,15 @@ import (
"embed"

"github.com/defenseunicorns/uds-cli/src/cmd"
"github.com/defenseunicorns/uds-cli/src/pkg/utils"
"github.com/defenseunicorns/zarf/src/pkg/packager/lint"
)

//go:embed zarf.schema.json
var zarfSchema embed.FS

func main() {
defer utils.GracefulPanic()
lint.ZarfSchema = zarfSchema
cmd.Execute()
}
40 changes: 20 additions & 20 deletions src/cmd/uds.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,26 +112,6 @@ var deployCmd = &cobra.Command{
},
}

func deployWithoutTea(bndlClient *bundle.Bundle) {
_, _, _, err := bndlClient.PreDeployValidation()
if err != nil {
message.Fatalf(err, "Failed to validate bundle: %s", err.Error())
}
// confirm deployment
if ok := bndlClient.ConfirmBundleDeploy(); !ok {
message.Fatal(nil, "bundle deployment cancelled")
}
// create an empty program and kill it, this makes Program.Send a no-op
deploy.Program = tea.NewProgram(nil)
deploy.Program.Kill()

// deploy the bundle
if err := bndlClient.Deploy(); err != nil {
bndlClient.ClearPaths()
message.Fatalf(err, "Failed to deploy bundle: %s", err.Error())
}
}

var inspectCmd = &cobra.Command{
Use: "inspect [BUNDLE_TARBALL|OCI_REF]",
Aliases: []string{"i"},
Expand Down Expand Up @@ -357,3 +337,23 @@ func chooseBundle(args []string) string {

return path
}

func deployWithoutTea(bndlClient *bundle.Bundle) {
_, _, _, err := bndlClient.PreDeployValidation()
if err != nil {
message.Fatalf(err, "Failed to validate bundle: %s", err.Error())
}
// confirm deployment
if ok := bndlClient.ConfirmBundleDeploy(); !ok {
message.Fatal(nil, "bundle deployment cancelled")
}
// create an empty program and kill it, this makes Program.Send a no-op
deploy.Program = tea.NewProgram(nil)
deploy.Program.Kill()

// deploy the bundle
if err := bndlClient.Deploy(); err != nil {
bndlClient.ClearPaths()
message.Fatalf(err, "Failed to deploy bundle: %s", err.Error())
}
}
4 changes: 2 additions & 2 deletions src/pkg/bundle/tui/deploy/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ func (m *Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
case tea.KeyMsg:
switch msg.String() {
case "y", "Y":
if !m.confirmed {
if !m.validatingBundle && !m.confirmed {
m.confirmed = true
m.inProgress = true
}
Expand All @@ -201,7 +201,7 @@ func (m *Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
}

case "n", "N":
if !m.confirmed && !m.inProgress {
if !m.validatingBundle && !m.confirmed && !m.inProgress {
m.done = true
quitMsg := tea.Println(tui.IndentStyle.Render("\n👋 Deployment cancelled"))
return m, tea.Sequence(quitMsg, tea.Println(), tea.Quit)
Expand Down

0 comments on commit e333eac

Please sign in to comment.