Skip to content

Commit

Permalink
feat: Add deprecation warnings for castsponsorskip envs
Browse files Browse the repository at this point in the history
  • Loading branch information
gabe565 committed Aug 28, 2023
1 parent b19f79f commit 24acdc0
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
10 changes: 8 additions & 2 deletions internal/config/intervals.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package config

import (
"fmt"
"log/slog"
"os"
"strconv"
"time"
Expand All @@ -24,7 +26,9 @@ func (c *Config) RegisterDiscoverInterval(cmd *cobra.Command) {
if env := os.Getenv("SBCSCANINTERVAL"); env != "" {
parsed, err := strconv.Atoi(env)
if err == nil {
viper.SetDefault(key, (time.Duration(parsed) * time.Second).String())
val := (time.Duration(parsed) * time.Second).String()
slog.Warn(fmt.Sprintf(`SBCSCANINTERVAL is deprecated. Please set %q instead.`, "CSS_DISCOVER_INTERVAL="+val))
viper.SetDefault(key, val)
}
}
}
Expand Down Expand Up @@ -57,7 +61,9 @@ func (c *Config) RegisterPlayingInterval(cmd *cobra.Command) {
if env := os.Getenv("SBCPOLLINTERVAL"); env != "" {
parsed, err := strconv.Atoi(env)
if err == nil {
viper.SetDefault(key, (time.Duration(parsed) * time.Second).String())
val := (time.Duration(parsed) * time.Second).String()
slog.Warn(fmt.Sprintf(`SBCPOLLINTERVAL is deprecated. Please set %q instead.`, "CSS_PLAYING_INTERVAL="+val))
viper.SetDefault(key, val)
}
}
}
7 changes: 5 additions & 2 deletions internal/config/sponsorblock.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ package config

import (
"encoding/json"
"fmt"
"log/slog"
"net/http"
"os"
"strings"
Expand All @@ -21,8 +23,9 @@ func (c *Config) RegisterCategories(cmd *cobra.Command) {
}

if env := os.Getenv("SBCCATEGORIES"); env != "" {
env := strings.Split(env, " ")
viper.SetDefault(key, env)
val := strings.Split(env, " ")
slog.Warn(fmt.Sprintf(`SBCCATEGORIES is deprecated. Please set %q instead.`, "CSS_CATEGORIES="+strings.Join(val, ",")))
viper.SetDefault(key, val)
}
}

Expand Down
3 changes: 3 additions & 0 deletions internal/config/youtube.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package config

import (
"fmt"
"log/slog"
"os"

"github.com/spf13/cobra"
Expand All @@ -15,6 +17,7 @@ func (c *Config) RegisterYouTubeAPIKey(cmd *cobra.Command) {
}

if env := os.Getenv("SBCYOUTUBEAPIKEY"); env != "" {
slog.Warn(fmt.Sprintf(`SBCYOUTUBEAPIKEY is deprecated. Please set %q instead.`, "CSS_YOUTUBE_API_KEY="+env))
viper.SetDefault(key, env)
}
}
Expand Down

0 comments on commit 24acdc0

Please sign in to comment.