apiserver: remove cached field isEnrolled (#2744)
not worth it just to avoid parsing a string twice
This commit is contained in:
parent
6acbcb0a33
commit
c6e4762f28
|
@ -43,7 +43,6 @@ type APIServer struct {
|
||||||
papi *Papi
|
papi *Papi
|
||||||
httpServerTomb tomb.Tomb
|
httpServerTomb tomb.Tomb
|
||||||
consoleConfig *csconfig.ConsoleConfig
|
consoleConfig *csconfig.ConsoleConfig
|
||||||
isEnrolled bool
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func recoverFromPanic(c *gin.Context) {
|
func recoverFromPanic(c *gin.Context) {
|
||||||
|
@ -226,7 +225,6 @@ func NewServer(config *csconfig.LocalApiServerCfg) (*APIServer, error) {
|
||||||
var (
|
var (
|
||||||
apiClient *apic
|
apiClient *apic
|
||||||
papiClient *Papi
|
papiClient *Papi
|
||||||
isMachineEnrolled = false
|
|
||||||
)
|
)
|
||||||
|
|
||||||
controller.AlertsAddChan = nil
|
controller.AlertsAddChan = nil
|
||||||
|
@ -245,8 +243,6 @@ func NewServer(config *csconfig.LocalApiServerCfg) (*APIServer, error) {
|
||||||
controller.AlertsAddChan = apiClient.AlertsAddChan
|
controller.AlertsAddChan = apiClient.AlertsAddChan
|
||||||
|
|
||||||
if apiClient.apiClient.IsEnrolled() {
|
if apiClient.apiClient.IsEnrolled() {
|
||||||
isMachineEnrolled = true
|
|
||||||
|
|
||||||
log.Infof("Machine is enrolled in the console, Loading PAPI Client")
|
log.Infof("Machine is enrolled in the console, Loading PAPI Client")
|
||||||
|
|
||||||
papiClient, err = NewPAPI(apiClient, dbClient, config.ConsoleConfig, *config.PapiLogLevel)
|
papiClient, err = NewPAPI(apiClient, dbClient, config.ConsoleConfig, *config.PapiLogLevel)
|
||||||
|
@ -279,7 +275,6 @@ func NewServer(config *csconfig.LocalApiServerCfg) (*APIServer, error) {
|
||||||
papi: papiClient,
|
papi: papiClient,
|
||||||
httpServerTomb: tomb.Tomb{},
|
httpServerTomb: tomb.Tomb{},
|
||||||
consoleConfig: config.ConsoleConfig,
|
consoleConfig: config.ConsoleConfig,
|
||||||
isEnrolled: isMachineEnrolled,
|
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -321,7 +316,7 @@ func (s *APIServer) Run(apiReady chan bool) error {
|
||||||
})
|
})
|
||||||
|
|
||||||
//csConfig.API.Server.ConsoleConfig.ShareCustomScenarios
|
//csConfig.API.Server.ConsoleConfig.ShareCustomScenarios
|
||||||
if s.isEnrolled {
|
if s.apic.apiClient.IsEnrolled() {
|
||||||
if s.consoleConfig.ConsoleManagement != nil && *s.consoleConfig.ConsoleManagement {
|
if s.consoleConfig.ConsoleManagement != nil && *s.consoleConfig.ConsoleManagement {
|
||||||
if s.papi.URL != "" {
|
if s.papi.URL != "" {
|
||||||
log.Infof("Starting PAPI decision receiver")
|
log.Infof("Starting PAPI decision receiver")
|
||||||
|
|
Loading…
Reference in a new issue