forked from hswaw/hscloud
37 lines
771 B
Go
37 lines
771 B
Go
package source
|
|
|
|
import "context"
|
|
|
|
var (
|
|
FlagGitwebURLPattern = "https://cs.hackerspace.pl/hscloud@%s/-/blob/%s"
|
|
)
|
|
|
|
type Source interface {
|
|
IsFile(ctx context.Context, path string) (bool, error)
|
|
ReadFile(ctx context.Context, path string) ([]byte, error)
|
|
IsDirectory(ctx context.Context, path string) (bool, error)
|
|
WebLinks(fpath string) []WebLink
|
|
}
|
|
|
|
type WebLink struct {
|
|
Kind string
|
|
LinkLabel string
|
|
LinkURL string
|
|
}
|
|
|
|
type SourceProvider interface {
|
|
Source(ctx context.Context, rev string) (Source, error)
|
|
}
|
|
|
|
type singleRefProvider struct {
|
|
source Source
|
|
}
|
|
|
|
func (s *singleRefProvider) Source(ctx context.Context, rev string) (Source, error) {
|
|
return s.source, nil
|
|
}
|
|
|
|
func NewSingleRefProvider(s Source) SourceProvider {
|
|
return &singleRefProvider{s}
|
|
}
|