forked from argoproj/argo-cd
-
Notifications
You must be signed in to change notification settings - Fork 0
/
settings.go
61 lines (54 loc) · 1.56 KB
/
settings.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
package settings
import (
"github.com/ghodss/yaml"
"golang.org/x/net/context"
"github.com/argoproj/argo-cd/pkg/apis/application/v1alpha1"
"github.com/argoproj/argo-cd/util/settings"
)
// Server provides a Settings service
type Server struct {
mgr *settings.SettingsManager
}
// NewServer returns a new instance of the Settings service
func NewServer(mgr *settings.SettingsManager) *Server {
return &Server{
mgr: mgr,
}
}
// Get returns Argo CD settings
func (s *Server) Get(ctx context.Context, q *SettingsQuery) (*Settings, error) {
argoCDSettings, err := s.mgr.GetSettings()
if err != nil {
return nil, err
}
overrides := make(map[string]*v1alpha1.ResourceOverride)
for k := range argoCDSettings.ResourceOverrides {
val := argoCDSettings.ResourceOverrides[k]
overrides[k] = &val
}
set := Settings{
URL: argoCDSettings.URL,
AppLabelKey: argoCDSettings.GetAppInstanceLabelKey(),
ResourceOverrides: overrides,
}
if argoCDSettings.DexConfig != "" {
var cfg DexConfig
err = yaml.Unmarshal([]byte(argoCDSettings.DexConfig), &cfg)
if err == nil {
set.DexConfig = &cfg
}
}
if oidcConfig := argoCDSettings.OIDCConfig(); oidcConfig != nil {
set.OIDCConfig = &OIDCConfig{
Name: oidcConfig.Name,
Issuer: oidcConfig.Issuer,
ClientID: oidcConfig.ClientID,
CLIClientID: oidcConfig.CLIClientID,
}
}
return &set, nil
}
// AuthFuncOverride disables authentication for settings service
func (s *Server) AuthFuncOverride(ctx context.Context, fullMethodName string) (context.Context, error) {
return ctx, nil
}