-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added ability to collect logs from server.
- Loading branch information
Showing
7 changed files
with
314 additions
and
9 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,46 @@ | ||
package cmd | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/spf13/cobra" | ||
"go.uber.org/zap" | ||
) | ||
|
||
type CollectLogsOutput []string | ||
|
||
var collectLogsCmd = &cobra.Command{ | ||
Use: "collect-logs [flags] cluster dest-path", | ||
Short: "Gets a connection string to connect to the cluster", | ||
Args: cobra.MinimumNArgs(2), | ||
Run: func(cmd *cobra.Command, args []string) { | ||
helper := CmdHelper{} | ||
logger := helper.GetLogger() | ||
ctx := helper.GetContext() | ||
|
||
outputJson, _ := cmd.Flags().GetBool("json") | ||
|
||
_, deployer, cluster := helper.IdentifyCluster(ctx, args[0]) | ||
destPath := args[1] | ||
|
||
logPaths, err := deployer.CollectLogs(ctx, cluster.GetID(), destPath) | ||
if err != nil { | ||
logger.Fatal("failed to collect logs", zap.Error(err)) | ||
} | ||
|
||
if !outputJson { | ||
fmt.Printf("Collected Files:\n") | ||
for _, path := range logPaths { | ||
fmt.Printf(" %s\n", | ||
path) | ||
} | ||
} else { | ||
var out CollectLogsOutput = logPaths | ||
helper.OutputJson(out) | ||
} | ||
}, | ||
} | ||
|
||
func init() { | ||
rootCmd.AddCommand(collectLogsCmd) | ||
} |
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
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