-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes #107 This is a big change that does the following: - replaces the bespoke exec implementation with an impl inspired from the nomad cli, using the client directly - add a wander exec command - therefore tls is supported - improves general exec experience (can move cursor, does not strip ansi escape sequences, etc) - BREAKAGE: exec with wander serve breaks. Unfortunately with this impl, tea.ExecProcess is used, which is currently charmbracelet/wish#196
- Loading branch information
1 parent
82af204
commit 312277a
Showing
20 changed files
with
557 additions
and
392 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package cmd | ||
|
||
import ( | ||
"fmt" | ||
"github.com/robinovitch61/wander/internal/tui/nomad" | ||
"github.com/spf13/cobra" | ||
"os" | ||
) | ||
|
||
var ( | ||
execCmd = &cobra.Command{ | ||
Use: "exec", | ||
Short: "Exec into a running task", | ||
Long: `Exec into a running nomad task`, | ||
Example: ` | ||
# specify job and task, assuming single allocation | ||
wander exec alright_stop --task redis echo "hi" | ||
# specify allocation, assuming single task | ||
wander exec 3dca0982 echo "hi" | ||
# use prefixes of jobs or allocation ids | ||
wander exec al echo "hi" | ||
wander exec 3d echo "hi" | ||
# specify flags for the exec command with -- | ||
wander exec alright_stop --task redis -- echo -n "hi" | ||
`, | ||
Run: execEntrypoint, | ||
PersistentPreRunE: func(cmd *cobra.Command, args []string) error { return nil }, | ||
} | ||
) | ||
|
||
func execEntrypoint(cmd *cobra.Command, args []string) { | ||
task := cmd.Flags().Lookup("task").Value.String() | ||
client, err := getConfig(cmd, "").Client() | ||
if err != nil { | ||
fmt.Println(fmt.Errorf("could not get client: %v", err)) | ||
os.Exit(1) | ||
} | ||
allocID := args[0] | ||
execArgs := args[1:] | ||
if len(execArgs) == 0 { | ||
fmt.Println("no command specified") | ||
os.Exit(1) | ||
} | ||
_, err = nomad.AllocExec(client, allocID, task, execArgs) | ||
if err != nil { | ||
fmt.Println(fmt.Errorf("could not exec into task: %v", err)) | ||
os.Exit(1) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.