diff --git a/pkg/apiserver/apiserver.go b/pkg/apiserver/apiserver.go index a85cffcf5..b1724784c 100644 --- a/pkg/apiserver/apiserver.go +++ b/pkg/apiserver/apiserver.go @@ -245,12 +245,14 @@ func NewServer(config *csconfig.LocalApiServerCfg) (*APIServer, error) { if apiClient.apiClient.IsEnrolled() { log.Infof("Machine is enrolled in the console, Loading PAPI Client") - papiClient, err = NewPAPI(apiClient, dbClient, config.ConsoleConfig, *config.PapiLogLevel) - if err != nil { - return nil, err - } + if config.ConsoleConfig.IsPAPIEnabled() { + papiClient, err = NewPAPI(apiClient, dbClient, config.ConsoleConfig, *config.PapiLogLevel) + if err != nil { + return nil, err + } - controller.DecisionDeleteChan = papiClient.Channels.DeleteDecisionChannel + controller.DecisionDeleteChan = papiClient.Channels.DeleteDecisionChannel + } } else { log.Errorf("Machine is not enrolled in the console, can't synchronize with the console") } @@ -317,7 +319,7 @@ func (s *APIServer) Run(apiReady chan bool) error { //csConfig.API.Server.ConsoleConfig.ShareCustomScenarios if s.apic.apiClient.IsEnrolled() { - if s.consoleConfig.ConsoleManagement != nil && *s.consoleConfig.ConsoleManagement { + if s.consoleConfig.IsPAPIEnabled() { if s.papi.URL != "" { log.Infof("Starting PAPI decision receiver") s.papi.pullTomb.Go(func() error { diff --git a/pkg/csconfig/console.go b/pkg/csconfig/console.go index c8e83dcd8..9e3b1e5ac 100644 --- a/pkg/csconfig/console.go +++ b/pkg/csconfig/console.go @@ -30,6 +30,13 @@ type ConsoleConfig struct { ShareContext *bool `yaml:"share_context"` } +func (c *ConsoleConfig) IsPAPIEnabled() bool { + if c == nil || c.ConsoleManagement == nil { + return false + } + return *c.ConsoleManagement +} + func (c *LocalApiServerCfg) LoadConsoleConfig() error { c.ConsoleConfig = &ConsoleConfig{} if _, err := os.Stat(c.ConsoleConfigPath); err != nil && os.IsNotExist(err) {