github.com/wtfutil/wtf@v0.43.0/modules/cds/favorites/settings.go (about)

     1  package cdsfavorites
     2  
     3  import (
     4  	"os"
     5  
     6  	"github.com/olebedev/config"
     7  	"github.com/wtfutil/wtf/cfg"
     8  	"github.com/wtfutil/wtf/utils"
     9  )
    10  
    11  const (
    12  	defaultFocusable = true
    13  	defaultTitle     = "CDS Favorites"
    14  )
    15  
    16  // Settings defines the configuration properties for this module
    17  type Settings struct {
    18  	*cfg.Common
    19  
    20  	token    string `help:"Your CDS API token."`
    21  	apiURL   string `help:"Your CDS API URL."`
    22  	uiURL    string
    23  	hideTags []string `help:"Hide some workflow tags."`
    24  }
    25  
    26  // NewSettingsFromYAML creates a new settings instance from a YAML config block
    27  func NewSettingsFromYAML(name string, ymlConfig *config.Config, globalConfig *config.Config) *Settings {
    28  	settings := Settings{
    29  		Common: cfg.NewCommonSettingsFromModule(name, defaultTitle, defaultFocusable, ymlConfig, globalConfig),
    30  
    31  		token:    ymlConfig.UString("token", ymlConfig.UString("token", os.Getenv("CDS_TOKEN"))),
    32  		apiURL:   ymlConfig.UString("apiURL", os.Getenv("CDS_API_URL")),
    33  		hideTags: utils.ToStrs(ymlConfig.UList("hideTags")),
    34  	}
    35  
    36  	settings.SetDocumentationPath("cds/favorites")
    37  
    38  	return &settings
    39  }