-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add configuration struct and more configuration options
- Loading branch information
Showing
19 changed files
with
1,560 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package config | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/sethvargo/go-envconfig" | ||
) | ||
|
||
type Config struct { | ||
LastFM struct { | ||
Endpoint string `env:"LASTFM_ENDPOINT,required"` | ||
APIKey string `env:"LASTFM_API_KEY,required"` | ||
} | ||
Spotify struct { | ||
ClientId string `env:"SPOTIFY_CLIENT_ID"` | ||
ClientSecret string `env:"SPOTIFY_CLIENT_SECRET"` | ||
} | ||
MaxImages struct { | ||
Albums int `env:"MAX_ALBUM_IMAGES,default=400"` | ||
Artists int `env:"MAX_ARTIST_IMAGES,default=100"` | ||
Tracks int `env:"MAX_TRACK_IMAGES,default=25"` | ||
} | ||
ImageSizeCutoffs struct { | ||
ExtraLarge int `env:"IMAGE_SIZE_CUTOFF_EXTRA_LARGE,default=100"` | ||
Large int `env:"IMAGE_SIZE_CUTOFF_LARGE,default=1000"` | ||
Medium int `env:"IMAGE_SIZE_CUTOFF_MEDIUM,default=2000"` | ||
} | ||
} | ||
|
||
var config *Config | ||
|
||
func GetConfig() *Config { | ||
return config | ||
} | ||
|
||
func InitConfig() error { | ||
ctx := context.Background() | ||
|
||
config = &Config{} | ||
|
||
if err := envconfig.Process(ctx, config); err != nil { | ||
return err | ||
} | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.