Skip to content

Commit

Permalink
added option to disable default app categories
Browse files Browse the repository at this point in the history
  • Loading branch information
yusing committed Nov 3, 2024
1 parent 5ff27b9 commit cf1ecbc
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 11 deletions.
2 changes: 1 addition & 1 deletion cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,5 +168,5 @@ func printJSON(obj any) {
logging.Fatal().Err(err).Send()
}
rawLogger := log.New(os.Stdout, "", 0)
rawLogger.Printf("%s", j) // raw output for convenience using "jq"
rawLogger.Print(string(j)) // raw output for convenience using "jq"
}
10 changes: 8 additions & 2 deletions config.example.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,19 @@ providers:
# - my.site
# - node1.my.app

# homepage config
#
homepage:
# use default app categories detected from alias or docker image name
use_default_categories: true

# Below are fixed options (non hot-reloadable)

# timeout for shutdown (in seconds)
#
# timeout_shutdown: 5
timeout_shutdown: 5

# global setting redirect http requests to https (if https available, otherwise this will be ignored)
# proxy.<alias>.middlewares.redirect_http will override this
#
# redirect_to_https: false
redirect_to_https: false
16 changes: 9 additions & 7 deletions internal/config/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,15 +69,17 @@ func HomepageConfig() homepage.Config {
)
}

if en.Container != nil && item.Category == "" {
if category, ok := homepage.PredefinedCategories[en.Container.ImageName]; ok {
item.Category = category
if instance.value.Homepage.UseDefaultCategories {
if en.Container != nil && item.Category == "" {
if category, ok := homepage.PredefinedCategories[en.Container.ImageName]; ok {
item.Category = category
}
}
}

if item.Category == "" {
if category, ok := homepage.PredefinedCategories[strings.ToLower(alias)]; ok {
item.Category = category
if item.Category == "" {
if category, ok := homepage.PredefinedCategories[strings.ToLower(alias)]; ok {
item.Category = category
}
}
}

Expand Down
5 changes: 4 additions & 1 deletion internal/config/types/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ type (
AutoCert AutoCertConfig `json:"autocert" yaml:",flow"`
ExplicitOnly bool `json:"explicit_only" yaml:"explicit_only"`
MatchDomains []string `json:"match_domains" yaml:"match_domains"`
Homepage HomepageConfig `json:"homepage" yaml:"homepage"`
TimeoutShutdown int `json:"timeout_shutdown" yaml:"timeout_shutdown"`
RedirectToHTTPS bool `json:"redirect_to_https" yaml:"redirect_to_https"`
}
Expand All @@ -18,8 +19,10 @@ type (

func DefaultConfig() *Config {
return &Config{
Providers: Providers{},
TimeoutShutdown: 3,
Homepage: HomepageConfig{
UseDefaultCategories: true,
},
RedirectToHTTPS: false,
}
}
5 changes: 5 additions & 0 deletions internal/config/types/homepage_config.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package types

type HomepageConfig struct {
UseDefaultCategories bool `json:"use_default_categories" yaml:"use_default_categories"`
}

0 comments on commit cf1ecbc

Please sign in to comment.