1
0
Fork 0
hscloud/devtools/hackdoc/source/source.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}
}