all repos — searchix @ e062ca72b222b890e345548bd8422d5df98e9fef

Search engine for NixOS, nix-darwin, home-manager and NUR users

feat: import sources from configuration in go code and index options

Alan Pearce
commit

e062ca72b222b890e345548bd8422d5df98e9fef

parent

967f6fdf5c1693d3aa27079b3ae28768fb7356c6

1 file changed, 44 insertions(+), 0 deletions(-)

changed files
A internal/importer/repository.go
@@ -0,0 +1,44 @@
+package importer + +import ( + "fmt" + "strings" +) + +type RepoType int + +const ( + GitHub = iota + 1 +) + +type Repository struct { + Type string `default:"github"` + Owner string + Repo string + Revision string +} + +func (f RepoType) String() string { + switch f { + case GitHub: + return "github" + default: + return fmt.Sprintf("RepoType(%d)", f) + } +} + +func parseRepoType(name string) (RepoType, error) { + switch strings.ToLower(name) { + case "github": + return GitHub, nil + default: + return Unknown, fmt.Errorf("unsupported repo type %s", name) + } +} + +func (f *RepoType) UnmarshalText(text []byte) error { + var err error + *f, err = parseRepoType(string(text)) + + return err +}