mirror of
https://github.com/onedr0p/exportarr.git
synced 2026-02-06 10:57:32 +00:00
Additional Compatibility Measures (#122)
This commit is contained in:
parent
e4441056ab
commit
6ec2c40dc2
@ -174,7 +174,7 @@ Visit http://127.0.0.1:9711/metrics to see Readarr metrics
|
||||
|:----------------------------:|--------------------------------|----------------------------------------------------------------|-----------|:--------:|
|
||||
| `PORT` | `--port` or `-p` | The port exportarr will listen on | | ✅ |
|
||||
| `URL` | `--url` or `-u` | The full URL to Sonarr, Radarr, or Lidarr | | ✅ |
|
||||
| `APIKEY` | `--api-key` or `-a` | API Key for Sonarr, Radarr or Lidarr | | ❌ |
|
||||
| `API_KEY` | `--api-key` or `-a` | API Key for Sonarr, Radarr or Lidarr | | ❌ |
|
||||
| `API_KEY_FILE` | `--api-key-file` | API Key file location for Sonarr, Radarr or Lidarr | | ❌ |
|
||||
| `CONFIG` | `--config` or `-c` | Path to Sonarr, Radarr or Lidarr's `config.xml` (advanced) | | ❌ |
|
||||
| `INTERFACE` | `--interface` or `-i` | The interface IP exportarr will listen on | `0.0.0.0` | ❌ |
|
||||
|
||||
@ -16,9 +16,10 @@ func init() {
|
||||
}
|
||||
|
||||
var prowlarrCmd = &cobra.Command{
|
||||
Use: "prowlarr",
|
||||
Short: "Prometheus Exporter for Prowlarr",
|
||||
Long: "Prometheus Exporter for Prowlarr.",
|
||||
Use: "prowlarr",
|
||||
Aliases: []string{"p"},
|
||||
Short: "Prometheus Exporter for Prowlarr",
|
||||
Long: "Prometheus Exporter for Prowlarr.",
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
conf.Arr = "prowlarr"
|
||||
conf.ApiVersion = "v1"
|
||||
|
||||
@ -13,9 +13,10 @@ func init() {
|
||||
}
|
||||
|
||||
var radarrCmd = &cobra.Command{
|
||||
Use: "radarr",
|
||||
Short: "Prometheus Exporter for Radarr",
|
||||
Long: "Prometheus Exporter for Radarr.",
|
||||
Use: "radarr",
|
||||
Aliases: []string{"r"},
|
||||
Short: "Prometheus Exporter for Radarr",
|
||||
Long: "Prometheus Exporter for Radarr.",
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
conf.Arr = "radarr"
|
||||
serveHttp(func(r *prometheus.Registry) {
|
||||
|
||||
@ -13,9 +13,10 @@ func init() {
|
||||
}
|
||||
|
||||
var readarrCmd = &cobra.Command{
|
||||
Use: "readarr",
|
||||
Short: "Prometheus Exporter for Readarr",
|
||||
Long: "Prometheus Exporter for Readarr.",
|
||||
Use: "readarr",
|
||||
Aliases: []string{"b"},
|
||||
Short: "Prometheus Exporter for Readarr",
|
||||
Long: "Prometheus Exporter for Readarr.",
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
conf.Arr = "readarr"
|
||||
conf.ApiVersion = "v1"
|
||||
|
||||
@ -13,9 +13,10 @@ func init() {
|
||||
}
|
||||
|
||||
var sonarrCmd = &cobra.Command{
|
||||
Use: "sonarr",
|
||||
Short: "Prometheus Exporter for Sonarr",
|
||||
Long: "Prometheus Exporter for Sonarr.",
|
||||
Use: "sonarr",
|
||||
Aliases: []string{"s"},
|
||||
Short: "Prometheus Exporter for Sonarr",
|
||||
Long: "Prometheus Exporter for Sonarr.",
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
conf.Arr = "sonarr"
|
||||
serveHttp(func(r *prometheus.Registry) {
|
||||
|
||||
@ -178,6 +178,8 @@ func backwardsCompatibilityTransforms(s string) string {
|
||||
switch s {
|
||||
case "apikey-file":
|
||||
return "api-key-file"
|
||||
case "apikey":
|
||||
return "api-key"
|
||||
case "basic-auth-username":
|
||||
return "auth-username"
|
||||
case "basic-auth-password":
|
||||
|
||||
@ -109,7 +109,7 @@ func TestLoadConfig_Environment(t *testing.T) {
|
||||
require.Equal("v3", config.ApiVersion)
|
||||
}
|
||||
|
||||
func TestLoadConfig_BackwardsCompatibility(t *testing.T) {
|
||||
func TestLoadConfig_BackwardsCompatibility_ApiKeyFile(t *testing.T) {
|
||||
require := require.New(t)
|
||||
|
||||
// Set environment variables
|
||||
@ -127,6 +127,19 @@ func TestLoadConfig_BackwardsCompatibility(t *testing.T) {
|
||||
require.Equal("pass", config.AuthPassword)
|
||||
}
|
||||
|
||||
func TestLoadConfig_BackwardsCompatibility_ApiKey(t *testing.T) {
|
||||
require := require.New(t)
|
||||
|
||||
// Set environment variables
|
||||
t.Setenv("URL", "http://localhost:8989")
|
||||
t.Setenv("APIKEY", "abcdef0123456789abcdef0123456780")
|
||||
t.Setenv("PORT", "1234")
|
||||
|
||||
config, err := LoadConfig(&pflag.FlagSet{})
|
||||
require.NoError(err)
|
||||
|
||||
require.Equal("abcdef0123456789abcdef0123456780", config.ApiKey)
|
||||
}
|
||||
func TestLoadConfig_XMLConfig(t *testing.T) {
|
||||
flags := testFlagSet()
|
||||
flags.Set("config", "test_fixtures/config.test_xml")
|
||||
|
||||
Loading…
Reference in New Issue
Block a user