about summary refs log tree commit diff stats
path: root/internal/config/source.go
diff options
context:
space:
mode:
authorAlan Pearce2024-05-16 23:41:57 +0200
committerAlan Pearce2024-05-16 23:41:57 +0200
commita5e758d41c151c17ed03b39454470ba8dd0c3b99 (patch)
tree386333b5020477eabcf490773113b029e47a21ef /internal/config/source.go
parentd558039919b6198a246a6a3fd007276191cb4b2f (diff)
downloadsearchix-a5e758d41c151c17ed03b39454470ba8dd0c3b99.tar.lz
searchix-a5e758d41c151c17ed03b39454470ba8dd0c3b99.tar.zst
searchix-a5e758d41c151c17ed03b39454470ba8dd0c3b99.zip
refactor: separate fetch and import logic
Diffstat (limited to 'internal/config/source.go')
-rw-r--r--internal/config/source.go48
1 files changed, 2 insertions, 46 deletions
diff --git a/internal/config/source.go b/internal/config/source.go
index 9797bb1..1fab61d 100644
--- a/internal/config/source.go
+++ b/internal/config/source.go
@@ -1,59 +1,15 @@
 package config
 
 import (
-	"fmt"
 	"time"
-
-	"github.com/stoewer/go-strcase"
-)
-
-type Type int
-
-const (
-	Unknown = iota
-	Channel
-	ChannelNixpkgs
-	DownloadOptions
 )
 
-func (f Type) String() string {
-	switch f {
-	case Channel:
-		return "channel"
-	case ChannelNixpkgs:
-		return "channel-nixpkgs"
-	case DownloadOptions:
-		return "download-options"
-	}
-
-	return fmt.Sprintf("Fetcher(%d)", f)
-}
-
-func parseType(name string) (Type, error) {
-	switch strcase.KebabCase(name) {
-	case "channel":
-		return Channel, nil
-	case "channel-nixpkgs":
-		return ChannelNixpkgs, nil
-	case "download-options":
-		return DownloadOptions, nil
-	default:
-		return Unknown, fmt.Errorf("unsupported fetcher %s", name)
-	}
-}
-
-func (f *Type) UnmarshalText(text []byte) error {
-	var err error
-	*f, err = parseType(string(text))
-
-	return err
-}
-
 type Source struct {
 	Name          string
 	Key           string
 	Enable        bool
-	Type          Type
+	Fetcher       Fetcher
+	Importer      ImporterType
 	Channel       string
 	URL           string
 	Attribute     string