Last active
January 24, 2023 14:27
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
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