diff --git a/configs/config.test.yaml b/configs/config.test.yaml deleted file mode 100644 index ba85153..0000000 --- a/configs/config.test.yaml +++ /dev/null @@ -1,12 +0,0 @@ -# Sets network type (could be tcp{,4,6}, unix) -# and address:port or /path/to/unix.sock to -# listen on. -listen_on: "tcp 127.0.0.1:16387" -icecast: - # URL to Icecast's status-json.xsl - url: "http://radio.arav.home.arpa/status-json.xsl" - playlist_path: "playlist.log" -filelist_path: "/srv/radio/filelist.html" -most_listened_song_file_path: "/mnt/data/appdata/mostlistenedsong" -# How much songs to list on a page -list_last_n_songs: 10 \ No newline at end of file diff --git a/configs/config.yaml b/configs/config.yaml deleted file mode 100644 index e51728f..0000000 --- a/configs/config.yaml +++ /dev/null @@ -1,12 +0,0 @@ -# Sets network type (could be tcp{,4,6}, unix) -# and address:port or /path/to/unix.sock to -# listen on. -listen_on: "unix /var/run/dwelling-radio/sock" -icecast: - # URL to Icecast's status-json.xsl - url: "http://radio.arav.home.arpa/status-json.xsl" - playlist_path: "/var/log/icecast/playlist.log" -filelist_path: "/srv/radio/filelist.html" -most_listened_song_file_path: "/mnt/data/appdata/mostlistenedsong" -# How much songs to list on a page -list_last_n_songs: 10 \ No newline at end of file diff --git a/internal/configuration/configuration.go b/internal/configuration/configuration.go deleted file mode 100644 index 5e51eb4..0000000 --- a/internal/configuration/configuration.go +++ /dev/null @@ -1,44 +0,0 @@ -package configuration - -import ( - "os" - "strings" - - "github.com/pkg/errors" - "gopkg.in/yaml.v3" -) - -type Configuration struct { - ListenOn string `yaml:"listen_on"` - Icecast struct { - URL string `yaml:"url"` - Playlist string `yaml:"playlist_path"` - } `yaml:"icecast"` - FilelistPath string `yaml:"filelist_path"` - MostListenedSongPath string `yaml:"most_listened_song_file_path"` - ListLastNSongs int `yaml:"list_last_n_songs"` -} - -// Load reads a YAML file that stores configuration of a service. -func Load(path string) (*Configuration, error) { - configFile, err := os.Open(path) - if err != nil { - return nil, errors.Wrap(err, "failed to open configuration file") - } - defer configFile.Close() - - config := &Configuration{} - - if err := yaml.NewDecoder(configFile).Decode(config); err != nil { - return nil, errors.Wrap(err, "failed to parse configuration file") - } - - return config, nil -} - -// SplitNetworkAddress splits ListenOn option into network type (e.g. tcp, unix, -// udp) and address:port or /path/to/service.socket to listen on. -func (c *Configuration) SplitNetworkAddress() (string, string) { - s := strings.Split(c.ListenOn, " ") - return s[0], s[1] -}