gitea

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: May 13, 2025 License: MIT Imports: 9 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client represents a Gitea client instance for interacting with the Gitea API.

func New

func New(ctx context.Context, cfg *Config) (*Client, error)

New creates a new Gitea client with the provided configuration and context. Returns a pointer to the Client and an error if initialization fails.

func (*Client) AddCollaborator

func (g *Client) AddCollaborator(org, repo, user string, permission map[string]bool) (*gsdk.Response, error)

AddCollaborator adds a user as a collaborator to the specified repository with the given permissions. Returns the response and an error if the operation fails.

func (*Client) AddTeamMember

func (g *Client) AddTeamMember(id int64, user string) error

AddTeamMember adds a user to the specified team by team ID. Returns an error if the operation fails.

func (*Client) AddTeamRepository

func (g *Client) AddTeamRepository(id int64, org, repo string) error

AddTeamRepository adds a repository to the specified team. Returns an error if the operation fails.

func (*Client) CreateAndGetOrg

func (g *Client) CreateAndGetOrg(opts CreateOrgOption) (*gsdk.Organization, error)

CreateAndGetOrg retrieves an existing organization or creates a new one if it does not exist. Returns a pointer to the Organization and an error if the operation fails.

func (*Client) CreateOrGetTeam

func (g *Client) CreateOrGetTeam(org string, opts CreateTeamOption) (*gsdk.Team, error)

CreateOrGetTeam retrieves an existing team or creates a new one in the specified organization. Returns a pointer to the Team and an error if the operation fails.

func (*Client) CreateOrGetUser

func (g *Client) CreateOrGetUser(opts CreateUserOption) (*gsdk.User, error)

CreateOrGetUser retrieves an existing user or creates a new one if not found. Returns a pointer to the User and an error if the operation fails.

func (*Client) CreateUserPublicKey

func (g *Client) CreateUserPublicKey(username string, opts CreatePublicKeyOption) (*gsdk.PublicKey, error)

CreateUserPublicKey creates an SSH public key for the specified user.

func (*Client) DeleteOrg

func (g *Client) DeleteOrg(opts DeleteOrgOption) error

DeleteOrg deletes an organization from Gitea. Returns an error if the operation fails.

func (*Client) DeleteRepository

func (g *Client) DeleteRepository(opts DeleteRepoOption) error

DeleteRepository deletes a repository from Gitea. Returns an error if the operation fails.

func (*Client) GetCurrentUser

func (g *Client) GetCurrentUser() (*gsdk.User, error)

GetCurrentUser retrieves the current authenticated user's information from Gitea. Returns a pointer to the User and an error if the request fails.

func (*Client) ListOrgRepos

func (g *Client) ListOrgRepos(org string, opts ...gsdk.ListOrgReposOptions) ([]*gsdk.Repository, *gsdk.Response, error)

ListOrgRepos lists all repositories under the specified organization.

func (*Client) MigrateRepo

func (g *Client) MigrateRepo(opts MigrateRepoOption) (*gsdk.Repository, error)

MigrateRepo migrates a repository from a remote source to Gitea. Returns a pointer to the new Repository and an error if the migration fails.

func (*Client) SearchOrgTeams

func (g *Client) SearchOrgTeams(org string, opts *gsdk.SearchTeamsOptions) ([]*gsdk.Team, error)

SearchOrgTeams retrieves a list of teams in the specified organization.

type Config

type Config struct {
	// Server is the Gitea server URL.
	Server string
	// Token is the personal access token for authentication.
	Token string
	// SkipVerify determines whether to skip TLS certificate verification.
	SkipVerify bool
	// SourceID is the authentication source ID for user creation.
	SourceID int64
	// Logger is the logger instance for logging.
	Logger *slog.Logger
}

type CreateOrgOption

type CreateOrgOption struct {
	// Name is the organization name.
	Name string
	// Description is the organization description.
	Description string
	// Visibility sets the visibility of the organization.
	Visibility gsdk.VisibleType
}

CreateOrgOption contains options for creating a Gitea organization.

type CreatePublicKeyOption

type CreatePublicKeyOption struct {
	Title string
	Key   string
}

CreatePublicKeyOption contains options for creating a user's SSH key.

type CreateTeamOption

type CreateTeamOption struct {
	// Name is the team name.
	Name string
	// Description is the team description.
	Description string
	// Permission is the permission level for the team.
	Permission string
}

CreateTeamOption contains options for creating a Gitea team.

type CreateUserOption

type CreateUserOption struct {
	// SourceID is the authentication source ID.
	SourceID int64
	// LoginName is the login name for the user.
	LoginName string
	// Username is the username for the user.
	Username string
	// FullName is the full name of the user.
	FullName string
	// Email is the email address of the user.
	Email string
}

CreateUserOption contains options for creating a Gitea user.

type DeleteOrgOption

type DeleteOrgOption struct {
	// OrgName is the organization name to delete.
	OrgName string
}

DeleteOrgOption contains options for deleting a Gitea organization.

type DeleteRepoOption

type DeleteRepoOption struct {
	// Owner is the owner (user or org) of the repository.
	Owner string
	// Repo is the name of the repository to delete.
	Repo string
}

DeleteRepoOption contains options for deleting a Gitea repository.

type GiteaError

type GiteaError struct {
	// Operation is the name of the Gitea operation that failed.
	Operation string
	// Code is the HTTP status code returned by the Gitea server.
	Code int
	// Message is the error message returned by the Gitea server.
	Message string
}

GiteaError is a custom error type for Gitea operations.

func (*GiteaError) Error

func (e *GiteaError) Error() string

type MigrateRepoOption

type MigrateRepoOption struct {
	// RepoName is the name of the repository to create.
	RepoName string
	// RepoOwner is the owner (user or org) of the new repository.
	RepoOwner string
	// CloneAddr is the source repository clone URL.
	CloneAddr string
	// Private determines if the new repository is private.
	Private bool
	// Description is the repository description.
	Description string
	// AuthUsername is the username for authentication to the source repository.
	AuthUsername string
	// AuthToken is the token/password for authentication to the source repository.
	AuthToken string
}

MigrateRepoOption contains options for migrating a repository to Gitea.

Jump to

Keyboard shortcuts

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