Skip to content

Instantly share code, notes, and snippets.

@mszostok
Last active January 26, 2023 17:00
package main
import (
"context"
"fmt"
"github.com/kubeshop/botkube/pkg/api/executor"
"github.com/kubeshop/botkube/pkg/pluginx"
)
// Execute returns a given command as a response.
func (e *GHExecutor) Execute(ctx context.Context, in executor.ExecuteInput) (executor.ExecuteOutput, error) {
// ...
title := fmt.Sprintf("The `%s` malfunctions", cmd.Create.Issue.Type)
issueURL, _ := createGitHubIssue(cfg, title, mdBody)
return executor.ExecuteOutput{
Data: fmt.Sprintf("New issue created successfully! 🎉\n\nIssue URL: %s", issueURL),
}, nil
}
func createGitHubIssue(cfg Config, title, mdBody string) (string, error) {
cmd := fmt.Sprintf("gh issue create --title %q --body '%s' --label bug -R %s", title, mdBody, cfg.GitHub.Repository)
envs := map[string]string{
"GH_TOKEN": cfg.GitHub.Token,
}
return pluginx.ExecuteCommandWithEnvs(context.Background(), cmd, envs)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment