mirror of
https://github.com/empayre/fleet.git
synced 2024-11-07 01:15:22 +00:00
def24499b5
moves web address config to datastore so that it can be configured by a user in the Web UI. rename OrgInfo struct to AppConfig. For #363 For #378
46 lines
1.2 KiB
Go
46 lines
1.2 KiB
Go
package service
|
|
|
|
import (
|
|
"github.com/kolide/kolide-ose/server/kolide"
|
|
"golang.org/x/net/context"
|
|
)
|
|
|
|
func (svc service) NewAppConfig(ctx context.Context, p kolide.AppConfigPayload) (*kolide.AppConfig, error) {
|
|
newConfig, err := svc.ds.NewAppConfig(fromPayload(p, kolide.AppConfig{}))
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return newConfig, nil
|
|
}
|
|
|
|
func (svc service) AppConfig(ctx context.Context) (*kolide.AppConfig, error) {
|
|
return svc.ds.AppConfig()
|
|
}
|
|
|
|
func (svc service) ModifyAppConfig(ctx context.Context, p kolide.AppConfigPayload) (*kolide.AppConfig, error) {
|
|
config, err := svc.ds.AppConfig()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
updated := fromPayload(p, *config)
|
|
|
|
if err := svc.ds.SaveAppConfig(updated); err != nil {
|
|
return nil, err
|
|
}
|
|
return config, nil
|
|
}
|
|
|
|
func fromPayload(p kolide.AppConfigPayload, config kolide.AppConfig) *kolide.AppConfig {
|
|
if p.OrgInfo != nil && p.OrgInfo.OrgLogoURL != nil {
|
|
config.OrgLogoURL = *p.OrgInfo.OrgLogoURL
|
|
}
|
|
if p.OrgInfo != nil && p.OrgInfo.OrgName != nil {
|
|
config.OrgName = *p.OrgInfo.OrgName
|
|
}
|
|
if p.ServerSettings != nil && p.ServerSettings.KolideServerURL != nil {
|
|
config.KolideServerURL = *p.ServerSettings.KolideServerURL
|
|
}
|
|
return &config
|
|
}
|