Zanzana: Initial work to run openFGA as embedded or standalone service (#89211)

* Zanana: Initial work to run zanana as ebeddedn or standalone

* Add addr settings for when remote client is used.

* sync dependencies

* Lock mysql driver version
---------

Co-authored-by: Dan Cech <dcech@grafana.com>
This commit is contained in:
Karl Persson
2024-06-18 10:04:18 +02:00
committed by GitHub
parent d0cf8956e2
commit 606a74d0af
20 changed files with 421 additions and 79 deletions

View File

@@ -475,6 +475,8 @@ type Cfg struct {
// RBAC single organization. This configuration option is subject to change.
RBACSingleOrganization bool
Zanzana ZanzanaSettings
// GRPC Server.
GRPCServerNetwork string
GRPCServerAddress string
@@ -1113,6 +1115,9 @@ func (cfg *Cfg) parseINIFile(iniFile *ini.File) error {
readOAuth2ServerSettings(cfg)
readAccessControlSettings(iniFile, cfg)
cfg.readZanzanaSettings()
if err := cfg.readRenderingSettings(iniFile); err != nil {
return err
}

View File

@@ -0,0 +1,37 @@
package setting
import (
"slices"
)
type ZanzanaMode string
const (
ZanzanaModeClient ZanzanaMode = "client"
ZanzanaModeEmbedded ZanzanaMode = "embedded"
)
type ZanzanaSettings struct {
// Addr is only used when mode is set to client
Addr string
// Mode can either be embedded or client
Mode ZanzanaMode
}
func (cfg *Cfg) readZanzanaSettings() {
s := ZanzanaSettings{}
sec := cfg.Raw.Section("zanzana")
s.Mode = ZanzanaMode(sec.Key("mode").MustString("embedded"))
validModes := []ZanzanaMode{ZanzanaModeEmbedded, ZanzanaModeClient}
if !slices.Contains(validModes, s.Mode) {
cfg.Logger.Warn("Invalid zanzana mode", "expected", validModes, "got", s.Mode)
s.Mode = "embedded"
}
s.Addr = sec.Key("address").MustString("")
cfg.Zanzana = s
}