Skip to content

Instantly share code, notes, and snippets.

@mszostok
Last active January 24, 2023 14:27
const (
logsTailLines = 150
defaultNamespace = "default"
)
// Execute returns a given command as a response.
func (e *GHExecutor) Execute(ctx context.Context, in executor.ExecuteInput) (executor.ExecuteOutput, error) {
// ...
issueDetails, _ := getIssueDetails(ctx, cmd.Create.Issue.Namespace, cmd.Create.Issue.Type)
// ...
}
// IssueDetails holds all available information about a given issue.
type IssueDetails struct {
Type string
Namespace string
Logs string
Version string
}
func getIssueDetails(ctx context.Context, namespace, name string) (IssueDetails, error) {
if namespace == "" {
namespace = defaultNamespace
}
logs, _ := pluginx.ExecuteCommand(ctx, fmt.Sprintf("kubectl logs %s -n %s --tail %d", name, namespace, logsTailLines))
ver, _ := pluginx.ExecuteCommand(ctx, "kubectl version -o yaml")
return IssueDetails{
Type: name,
Namespace: namespace,
Logs: logs,
Version: ver,
}, nil
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment