feat: added cacerts and some tidying
This commit is contained in:
parent
2112e7eefd
commit
bdd85b01ff
8 changed files with 279 additions and 59 deletions
|
|
@ -190,7 +190,9 @@ func (s *Service) Upload() http.HandlerFunc {
|
|||
)
|
||||
|
||||
// show what we're uploading
|
||||
log.Debug().Str("path", path).Msg("Service.Upload()")
|
||||
log.Debug().
|
||||
Str("path", path).
|
||||
Msg("Service.Upload()")
|
||||
|
||||
// take the provided path and store the file contents
|
||||
dirpath = filepath.Dir(path)
|
||||
|
|
@ -296,7 +298,7 @@ func (s *Service) loadProfiles(profileIDs []string, store storage.KVStore, errs
|
|||
profile *makeshift.Profile
|
||||
err error
|
||||
)
|
||||
if i > DEFAULT_PROFILES_MAX_COUNT {
|
||||
if i > s.ProfilesMaxCount {
|
||||
log.Warn().Msg("max profiles count reached...stopping")
|
||||
return errs
|
||||
}
|
||||
|
|
@ -329,7 +331,7 @@ func (s *Service) loadPlugins(pluginNames []string, store storage.KVStore, args
|
|||
plugin makeshift.Plugin
|
||||
err error
|
||||
)
|
||||
if i > DEFAULT_PLUGINS_MAX_COUNT {
|
||||
if i > s.PluginsMaxCount {
|
||||
log.Warn().Msg("max plugins count reached or exceeded...stopping")
|
||||
return hooks, errs
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,9 +19,10 @@ import (
|
|||
)
|
||||
|
||||
type Service struct {
|
||||
Addr string
|
||||
RootPath string `yaml:"root,omitempty"`
|
||||
Environment map[string]string
|
||||
Addr string
|
||||
RootPath string `yaml:"root,omitempty"`
|
||||
CACertFile string `yaml:"cacert,omitempty"`
|
||||
CACertKeyfile string `yaml:"keyfile,omitempty"`
|
||||
|
||||
// max counts
|
||||
PluginsMaxCount int
|
||||
|
|
@ -32,13 +33,8 @@ type Service struct {
|
|||
// New creates a new Service instance with default values
|
||||
func New() *Service {
|
||||
return &Service{
|
||||
Addr: ":5050",
|
||||
RootPath: "./",
|
||||
Environment: map[string]string{
|
||||
"MAKESHIFT_HOST": "",
|
||||
"MAKESHIFT_ROOT": "",
|
||||
"ACCESS_TOKEN": "",
|
||||
},
|
||||
Addr: ":5050",
|
||||
RootPath: "./",
|
||||
PluginsMaxCount: DEFAULT_PLUGINS_MAX_COUNT,
|
||||
ProfilesMaxCount: DEFAULT_PROFILES_MAX_COUNT,
|
||||
Timeout: DEFAULT_TIMEOUT_IN_SECS,
|
||||
|
|
@ -121,7 +117,11 @@ func (s *Service) Serve() error {
|
|||
|
||||
// always available public routes go here
|
||||
router.HandleFunc("/status", s.GetStatus)
|
||||
return http.ListenAndServe(s.Addr, router)
|
||||
if s.CACertFile != "" && s.CACertKeyfile != "" {
|
||||
return http.ListenAndServeTLS(s.Addr, s.CACertFile, s.CACertKeyfile, router)
|
||||
} else {
|
||||
return http.ListenAndServe(s.Addr, router)
|
||||
}
|
||||
}
|
||||
|
||||
func (s *Service) requireAuth() bool {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue