gist

package
v0.5.1-alpha.0 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2025 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	GITHUB_GIST_API_URL = "https://api.github.com/gists"
	GITHUB_USER_API_URL = "https://api.github.com/user"
)

Variables

This section is empty.

Functions

func CheckGitHubTokenGistPermissions

func CheckGitHubTokenGistPermissions(token GitHubAPIToken) (bool, error)

func CreateGistForBinaryContent

func CreateGistForBinaryContent(l *zerolog.Logger, description string, filePath string, isPublic bool, token GitHubAPIToken) (string, error)

func CreateGistForDirectory

func CreateGistForDirectory(l *zerolog.Logger, description string, workflowPath string, isPublic bool, token GitHubAPIToken) (string, error)

CreateGistForDirectory creates a Gist for the directory containing the source code files. It will only include Go files and go.mod. It will return Gist URL for the provided file path where the main function resides.

func CreateGistForTextualContent

func CreateGistForTextualContent(l *zerolog.Logger, description string, filePath string, isPublic bool, token GitHubAPIToken) (string, error)

func Fetch

func Fetch(url string, maxUrlLength int, maxDataSize int) ([]byte, error)

func GetURLWithoutRevision

func GetURLWithoutRevision(revisionGistURL string) (string, error)

func HasGistPermissions

func HasGistPermissions(token GitHubAPIToken) bool

func IsGistBinaryContent

func IsGistBinaryContent(l *zerolog.Logger, gistID string, token GitHubAPIToken) (bool, error)

func IsValidGistID

func IsValidGistID(gistID string) bool

func SetupCreateGistAPIMock

func SetupCreateGistAPIMock(t *testing.T, wasmFileName, configFileName string)

SetupCreateGistAPIMock configures mock responses for GitHub Gist creation API.

func SetupGistAPIMock

func SetupGistAPIMock(t *testing.T, validTokens ...string)

SetupGistAPIMock configures mock responses for GitHub Gist listing API.

func SetupGitHubAPIMocks

func SetupGitHubAPIMocks(t *testing.T, userName string, validTokens ...string)

SetupGitHubAPIMocks configures mock responses for GitHub API endpoints. The provided tokens will be treated as valid.

func SetupUserAPIMock

func SetupUserAPIMock(t *testing.T, userName string, validTokens ...string)

SetupUserAPIMock configures mock responses for GitHub User API.

func UpdateGistForBinaryContent

func UpdateGistForBinaryContent(l *zerolog.Logger, gistID string, description string, filePath string, isPublic bool, token GitHubAPIToken) (string, error)

func UpdateGistForTextualContent

func UpdateGistForTextualContent(l *zerolog.Logger, gistID string, description string, filePath string, isPublic bool, token GitHubAPIToken) (string, error)

Types

type GistFile

type GistFile struct {
	Content string `json:"content"`
}

type GistRequest

type GistRequest struct {
	Description string              `json:"description"`
	Public      bool                `json:"public"`
	Files       map[string]GistFile `json:"files"`
}

type GistResponse

type GistResponse struct {
	Files map[string]struct {
		RawURL   string `json:"raw_url"`
		FileName string `json:"filename"`
		Type     string `json:"type"`
		Encoding string `json:"encoding"`
	} `json:"files"`
	GitPullURL string `json:"git_pull_url"`
}

type GitHubAPIToken

type GitHubAPIToken string

func (GitHubAPIToken) MarshalJSON

func (t GitHubAPIToken) MarshalJSON() ([]byte, error)

func (GitHubAPIToken) MarshalZerologObject

func (t GitHubAPIToken) MarshalZerologObject(e *zerolog.Event)

func (GitHubAPIToken) RawValue

func (t GitHubAPIToken) RawValue() string

func (GitHubAPIToken) String

func (t GitHubAPIToken) String() string

type GitHubUser

type GitHubUser struct {
	Login string `json:"login"` // GitHub username
}

Jump to

Keyboard shortcuts

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