Skip to content

Commit 48da39b

Browse files
authored
fix(vcs): remove UI URL from config, get it by API call (#5936)
Signed-off-by: francois samin <[email protected]>
1 parent dd638c1 commit 48da39b

File tree

2 files changed

+19
-12
lines changed

2 files changed

+19
-12
lines changed

engine/vcs/types.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,18 @@ type Service struct {
1616
Cfg Configuration
1717
Router *api.Router
1818
Cache cache.Store
19+
UI struct {
20+
HTTP struct {
21+
URL string
22+
}
23+
}
1924
}
2025

2126
// Configuration is the vcs configuration structure
2227
type Configuration struct {
23-
Name string `toml:"name" comment:"Name of this CDS VCS Service\n Enter a name to enable this service" json:"name"`
24-
HTTP service.HTTPRouterConfiguration `toml:"http" comment:"######################\n CDS VCS HTTP Configuration \n######################" json:"http"`
25-
URL string `default:"http://localhost:8084" json:"url"`
26-
UI struct {
27-
HTTP struct {
28-
URL string `toml:"url" default:"http://localhost:8080" json:"url"`
29-
} `toml:"http" json:"http"`
30-
} `toml:"ui" json:"ui"`
28+
Name string `toml:"name" comment:"Name of this CDS VCS Service\n Enter a name to enable this service" json:"name"`
29+
HTTP service.HTTPRouterConfiguration `toml:"http" comment:"######################\n CDS VCS HTTP Configuration \n######################" json:"http"`
30+
URL string `default:"http://localhost:8084" json:"url"`
3131
API service.APIServiceConfiguration `toml:"api" comment:"######################\n CDS API Settings \n######################" json:"api"`
3232
Cache struct {
3333
TTL int `toml:"ttl" default:"60" json:"ttl"`

engine/vcs/vcs.go

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ func (s *Service) getConsumer(name string) (sdk.VCSServer, error) {
9393
serverCfg.URL,
9494
serverCfg.Github.APIURL,
9595
s.Cfg.API.HTTP.URL,
96-
s.Cfg.UI.HTTP.URL,
96+
s.UI.HTTP.URL,
9797
serverCfg.Github.ProxyWebhook,
9898
serverCfg.Github.Username,
9999
serverCfg.Github.Token,
@@ -107,7 +107,7 @@ func (s *Service) getConsumer(name string) (sdk.VCSServer, error) {
107107
[]byte(serverCfg.Bitbucket.PrivateKey),
108108
serverCfg.URL,
109109
s.Cfg.API.HTTP.URL,
110-
s.Cfg.UI.HTTP.URL,
110+
s.UI.HTTP.URL,
111111
serverCfg.Bitbucket.ProxyWebhook,
112112
serverCfg.Bitbucket.Username,
113113
serverCfg.Bitbucket.Token,
@@ -119,7 +119,7 @@ func (s *Service) getConsumer(name string) (sdk.VCSServer, error) {
119119
return bitbucketcloud.New(serverCfg.BitbucketCloud.ClientID,
120120
serverCfg.BitbucketCloud.ClientSecret,
121121
serverCfg.URL,
122-
s.Cfg.UI.HTTP.URL,
122+
s.UI.HTTP.URL,
123123
serverCfg.BitbucketCloud.ProxyWebhook,
124124
s.Cache,
125125
serverCfg.BitbucketCloud.Status.Disable,
@@ -131,7 +131,7 @@ func (s *Service) getConsumer(name string) (sdk.VCSServer, error) {
131131
serverCfg.Gitlab.Secret,
132132
serverCfg.URL,
133133
serverCfg.Gitlab.CallbackURL,
134-
s.Cfg.UI.HTTP.URL,
134+
s.UI.HTTP.URL,
135135
serverCfg.Gitlab.ProxyWebhook,
136136
s.Cache,
137137
serverCfg.Gitlab.Status.Disable,
@@ -156,6 +156,13 @@ func (s *Service) Serve(c context.Context) error {
156156
log.Info(c, "VCS> Starting service %s %s...", s.Cfg.Name, sdk.VERSION)
157157
s.StartupTime = time.Now()
158158

159+
// Retrieve UI URL from API
160+
cfgUser, err := s.Client.ConfigUser()
161+
if err != nil {
162+
return err
163+
}
164+
s.UI.HTTP.URL = cfgUser.URLUI
165+
159166
//Init the cache
160167
var errCache error
161168
s.Cache, errCache = cache.New(s.Cfg.Cache.Redis.Host, s.Cfg.Cache.Redis.Password, s.Cfg.Cache.TTL)

0 commit comments

Comments
 (0)