From 24acdc00f4372418e00cd6b479668e05ac4626f1 Mon Sep 17 00:00:00 2001 From: Gabe Cook Date: Mon, 28 Aug 2023 02:17:43 -0500 Subject: [PATCH] feat: Add deprecation warnings for castsponsorskip envs --- internal/config/intervals.go | 10 ++++++++-- internal/config/sponsorblock.go | 7 +++++-- internal/config/youtube.go | 3 +++ 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/internal/config/intervals.go b/internal/config/intervals.go index 398e25f..9bb6795 100644 --- a/internal/config/intervals.go +++ b/internal/config/intervals.go @@ -1,6 +1,8 @@ package config import ( + "fmt" + "log/slog" "os" "strconv" "time" @@ -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) } } } @@ -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) } } } diff --git a/internal/config/sponsorblock.go b/internal/config/sponsorblock.go index 5ecdc19..927a098 100644 --- a/internal/config/sponsorblock.go +++ b/internal/config/sponsorblock.go @@ -2,6 +2,8 @@ package config import ( "encoding/json" + "fmt" + "log/slog" "net/http" "os" "strings" @@ -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) } } diff --git a/internal/config/youtube.go b/internal/config/youtube.go index 5eeaf09..7e94f6c 100644 --- a/internal/config/youtube.go +++ b/internal/config/youtube.go @@ -1,6 +1,8 @@ package config import ( + "fmt" + "log/slog" "os" "github.com/spf13/cobra" @@ -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) } }