blob: 71dc3a5270e1184d8c0aa41c345c41baa782b796 [file] [log] [blame]
Sergiusz Bazanskic881cf32020-04-08 20:03:12 +02001package source
2
Sergiusz Bazanskif157b4d2020-04-10 17:39:43 +02003import "context"
Sergiusz Bazanskic881cf32020-04-08 20:03:12 +02004
Sergiusz Bazanskif157b4d2020-04-10 17:39:43 +02005var (
Serge Bazanskibc0d3cb2021-03-06 20:49:00 +00006 FlagGitwebURLPattern = "https://cs.hackerspace.pl/hscloud@%s/-/blob/%s"
Sergiusz Bazanskif157b4d2020-04-10 17:39:43 +02007)
8
9type Source interface {
10 IsFile(ctx context.Context, path string) (bool, error)
11 ReadFile(ctx context.Context, path string) ([]byte, error)
12 IsDirectory(ctx context.Context, path string) (bool, error)
13 WebLinks(fpath string) []WebLink
14}
15
16type WebLink struct {
17 Kind string
18 LinkLabel string
19 LinkURL string
20}
21
22type SourceProvider interface {
23 Source(ctx context.Context, rev string) (Source, error)
24}
25
26type singleRefProvider struct {
27 source Source
28}
29
30func (s *singleRefProvider) Source(ctx context.Context, rev string) (Source, error) {
31 return s.source, nil
32}
33
34func NewSingleRefProvider(s Source) SourceProvider {
35 return &singleRefProvider{s}
Sergiusz Bazanskic881cf32020-04-08 20:03:12 +020036}