scm

package
v0.0.0-...-4c964c4 Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2025 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNoDefaultBranch = errors.New("no default branch")
)

WireSet provides a wire set for this package.

Functions

This section is empty.

Types

type Branch

type Branch struct {
	Name string `json:"name"`
	SHA  string `json:"sha"`
}

type BranchFilter

type BranchFilter struct {
	SpaceID    int64  `json:"space_id"`
	Repository string `json:"repo"`
	Query      string `json:"query"`
	Page       int    `json:"page"`
	Size       int    `json:"size"`
	RepoURL    string `json:"repo_url"`
}

type CodeRepositoryRequest

type CodeRepositoryRequest struct {
	URL            string
	RepoType       enum.GitspaceCodeRepoType
	UserIdentifier string
	UserID         int64
	SpacePath      string
}

type CodeRepositoryResponse

type CodeRepositoryResponse struct {
	URL               string `json:"url"`
	Branch            string `json:"branch,omitempty"`
	CodeRepoIsPrivate bool   `json:"is_private"`
}

type Credentials

type Credentials struct {
	Email    string
	Name     string
	Password string
}

Credentials contains login and initialization information used by an automated login process.

type Factory

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

func NewFactory

func NewFactory(gitnessProvider *GitnessSCM, genericSCM *GenericSCM) Factory

func NewFactoryWithProviders

func NewFactoryWithProviders(providers map[enum.GitspaceCodeRepoType]Provider) Factory

func ProvideFactory

func ProvideFactory(gitness *GitnessSCM, genericSCM *GenericSCM) Factory

func (*Factory) GetSCMProvider

func (f *Factory) GetSCMProvider(providerType enum.GitspaceCodeRepoType) (Provider, error)

type GenericSCM

type GenericSCM struct {
}

func NewGenericSCM

func NewGenericSCM() *GenericSCM

func ProvideGenericSCM

func ProvideGenericSCM() *GenericSCM

func (GenericSCM) GetFileContent

func (s GenericSCM) GetFileContent(ctx context.Context,
	gitspaceConfig types.GitspaceConfig,
	filePath string,
	_ *ResolvedCredentials,
) ([]byte, error)

func (*GenericSCM) ListBranches

func (s *GenericSCM) ListBranches(_ context.Context,
	_ *BranchFilter,
	_ *ResolvedCredentials) ([]Branch, error)

ListBranches implements Provider.

func (*GenericSCM) ListReporisotries

func (s *GenericSCM) ListReporisotries(_ context.Context,
	_ *RepositoryFilter,
	_ *ResolvedCredentials) ([]Repository, error)

ListReporisotries implements Provider.

func (GenericSCM) ResolveCredentials

func (s GenericSCM) ResolveCredentials(
	_ context.Context,
	gitspaceConfig types.GitspaceConfig,
) (*ResolvedCredentials, error)

type GitnessSCM

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

func NewGitnessSCM

func NewGitnessSCM(repoStore store.RepoStore, git git.Interface,
	tokenStore store.TokenStore,
	principalStore store.PrincipalStore,
	urlProvider urlprovider.Provider) *GitnessSCM

func ProvideGitnessSCM

func ProvideGitnessSCM(repoStore store.RepoStore,
	rpcClient git.Interface,
	tokenStore store.TokenStore,
	principalStore store.PrincipalStore,
	urlProvider urlprovider.Provider,
) *GitnessSCM

func (GitnessSCM) GetFileContent

func (s GitnessSCM) GetFileContent(ctx context.Context,
	gitspaceConfig types.GitspaceConfig,
	filePath string,
	_ *ResolvedCredentials,
) ([]byte, error)

func (*GitnessSCM) ListBranches

func (s *GitnessSCM) ListBranches(ctx context.Context,
	filter *BranchFilter,
	_ *ResolvedCredentials) ([]Branch, error)

ListBranches implements Provider.

func (*GitnessSCM) ListReporisotries

func (s *GitnessSCM) ListReporisotries(ctx context.Context,
	filter *RepositoryFilter,
	_ *ResolvedCredentials) ([]Repository, error)

ListReporisotries implements Provider.

func (GitnessSCM) ResolveCredentials

func (s GitnessSCM) ResolveCredentials(
	ctx context.Context,
	gitspaceConfig types.GitspaceConfig,
) (*ResolvedCredentials, error)

type Provider

type Provider interface {
	ResolveCredentials(ctx context.Context, gitspaceConfig types.GitspaceConfig) (*ResolvedCredentials, error)
	GetFileContent(
		ctx context.Context,
		gitspaceConfig types.GitspaceConfig,
		filePath string,
		credentials *ResolvedCredentials,
	) ([]byte, error)
	ListReporisotries(ctx context.Context,
		filter *RepositoryFilter,
		credentials *ResolvedCredentials) ([]Repository, error)
	ListBranches(ctx context.Context,
		filter *BranchFilter,
		credentials *ResolvedCredentials) ([]Branch, error)
}

type Repository

type Repository struct {
	Name          string `json:"name"`
	DefaultBranch string `json:"default_branch"`
	// git urls
	GitURL    string `json:"git_url"`
	GitSSHURL string `json:"git_ssh_url,omitempty"`
}

type RepositoryFilter

type RepositoryFilter struct {
	SpaceID int64  `json:"space_id"`
	Page    int    `json:"page"`
	Size    int    `json:"size"`
	Query   string `json:"query"`
	User    string `json:"user"`
}

type ResolvedCredentials

type ResolvedCredentials struct {
	Branch      string
	CloneURL    string
	Credentials *Credentials
	RepoName    string
}

type ResolvedDetails

type ResolvedDetails struct {
	*ResolvedCredentials
	DevcontainerConfig *types.DevcontainerConfig
}

type SCM

type SCM interface {
	// GetSCMRepoDetails fetches repository name, credentials & devcontainer config file from the given repo and branch.
	GetSCMRepoDetails(
		ctx context.Context,
		gitspaceConfig types.GitspaceConfig,
	) (*ResolvedDetails, error)

	// CheckValidCodeRepo checks if the current URL is a valid and accessible code repo,
	// input can be connector info, user token etc.
	CheckValidCodeRepo(ctx context.Context, request CodeRepositoryRequest) (*CodeRepositoryResponse, error)
}

func NewSCM

func NewSCM(factory Factory) SCM

func ProvideSCM

func ProvideSCM(factory Factory) SCM

Jump to

Keyboard shortcuts

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