githubapp

package
v0.0.0-...-385a09e Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 15, 2026 License: MIT Imports: 20 Imported by: 0

Documentation

Overview

Package githubapp provides order template creation helpers.

Package githubapp provides gitshop.yaml creation and management.

Index

Constants

View Source
const DefaultGitShopYAML = `` /* 584-byte string literal not displayed */

Variables

This section is empty.

Functions

func ReadWebhookPayload

func ReadWebhookPayload(r *http.Request, secret string) ([]byte, error)

func ValidateWebhookSignature

func ValidateWebhookSignature(payload []byte, signature, secret string) error

Types

type Auth

type Auth struct {
	// contains filtered or unexported fields
}

func NewAuth

func NewAuth(appIDStr, privateKeyBase64 string) (*Auth, error)

func (*Auth) CreateJWT

func (a *Auth) CreateJWT() (string, error)

func (*Auth) GetInstallationToken

func (a *Auth) GetInstallationToken(ctx context.Context, installationID int64) (*oauth2.Token, error)

type Client

type Client struct {
	// contains filtered or unexported fields
}

func NewClient

func NewClient(auth *Auth, logger *slog.Logger) *Client

func (*Client) AddLabels

func (c *Client) AddLabels(ctx context.Context, repoFullName string, issueNumber int, labels []string) error

func (*Client) AssignIssue

func (c *Client) AssignIssue(ctx context.Context, repoFullName string, issueNumber int, assignees []string) error

func (*Client) CheckPermission

func (c *Client) CheckPermission(ctx context.Context, repoFullName, username string) (bool, error)

func (*Client) CloseIssue

func (c *Client) CloseIssue(ctx context.Context, repoFullName string, issueNumber int) error

func (*Client) CreateComment

func (c *Client) CreateComment(ctx context.Context, repoFullName string, issueNumber int, body string) error

func (*Client) CreateIssue

func (c *Client) CreateIssue(ctx context.Context, repoFullName string, title, body string, labels []string, assignees []string) error

func (*Client) CreateOrUpdateFile

func (c *Client) CreateOrUpdateFile(ctx context.Context, repoFullName, path, content, message string) error

func (*Client) CreateOrUpdateFileWithPR

func (c *Client) CreateOrUpdateFileWithPR(ctx context.Context, owner, repo, path, content, message, prTitle, prBody, branchName string) (*FileCreationResult, error)

func (*Client) CreateOrUpdateOrderTemplate

func (c *Client) CreateOrUpdateOrderTemplate(ctx context.Context, owner, repo, templateContent string) (*FileCreationResult, error)

func (*Client) DeleteComment

func (c *Client) DeleteComment(ctx context.Context, repoFullName string, commentID int64) error

func (*Client) EnsureGitShopYAML

func (c *Client) EnsureGitShopYAML(ctx context.Context, client *github.Client, owner, repo, shopName string) (*YAMLCreationResult, error)

EnsureGitShopYAML checks if gitshop.yaml exists in the repo and creates it if not. It attempts to commit directly first, and falls back to creating a PR if the branch is protected.

func (*Client) EnsureGitShopYAMLForRepo

func (c *Client) EnsureGitShopYAMLForRepo(ctx context.Context, owner, repo, shopName string) (*YAMLCreationResult, error)

func (*Client) EnsureLabels

func (c *Client) EnsureLabels(ctx context.Context, repoFullName string, labels []LabelDefinition) error

func (*Client) EnsureOrderTemplate

func (c *Client) EnsureOrderTemplate(ctx context.Context, owner, repo, templateContent string) (*FileCreationResult, error)

func (*Client) GetFile

func (c *Client) GetFile(ctx context.Context, repoFullName, path, ref string) ([]byte, error)

func (*Client) GetFileStatus

func (c *Client) GetFileStatus(ctx context.Context, repoFullName, path string) (*FileStatus, error)

func (*Client) GetInstallation

func (c *Client) GetInstallation(ctx context.Context, userAccessToken string, installationID int64) (*Installation, error)

func (*Client) ListComments

func (c *Client) ListComments(ctx context.Context, repoFullName string, issueNumber int) ([]*github.IssueComment, error)

func (*Client) ListDirectory

func (c *Client) ListDirectory(ctx context.Context, repoFullName, path string) ([]RepoFile, error)

func (*Client) ListLabels

func (c *Client) ListLabels(ctx context.Context, repoFullName string) (map[string]github.Label, error)

func (*Client) RemoveLabel

func (c *Client) RemoveLabel(ctx context.Context, repoFullName string, issueNumber int, label string) error

func (*Client) UpdateIssueTitle

func (c *Client) UpdateIssueTitle(ctx context.Context, repoFullName string, issueNumber int, title string) error

func (*Client) WithInstallation

func (c *Client) WithInstallation(installationID int64) *Client

type FileCreationResult

type FileCreationResult struct {
	Created      bool
	Method       string // "commit", "pr", or "exists"
	URL          string
	PRNumber     int
	ErrorMessage string
}

type FileStatus

type FileStatus struct {
	Exists      bool
	HTMLURL     string
	LastUpdated time.Time
}

type Installation

type Installation struct {
	ID           int64
	AccountID    int64
	AccountLogin string
	AccountType  string
	AvatarURL    string
	Permissions  map[string]string
}

type LabelDefinition

type LabelDefinition struct {
	Name        string
	Color       string
	Description string
}

type RepoFile

type RepoFile struct {
	Name    string
	Path    string
	HTMLURL string
}

type YAMLCreationResult

type YAMLCreationResult struct {
	Created      bool
	Method       string // "commit", "pr", or "exists"
	URL          string
	PRNumber     int
	ErrorMessage string
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL