Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(ui): engine start ui #4552

Merged
merged 22 commits into from
Aug 29, 2019
1 change: 1 addition & 0 deletions engine/api/services/const.go
Original file line number Diff line number Diff line change
@@ -7,6 +7,7 @@ const (
TypeElasticsearch = "elasticsearch"
TypeVCS = "vcs"
TypeAPI = "api"
TypeUI = "ui"
TypeHatchery = "hatchery"
TypeDBMigrate = "dbmigrate"
)
9 changes: 9 additions & 0 deletions engine/config.go
Original file line number Diff line number Diff line change
@@ -23,6 +23,7 @@ import (
"github.com/ovh/cds/engine/hooks"
"github.com/ovh/cds/engine/migrateservice"
"github.com/ovh/cds/engine/repositories"
"github.com/ovh/cds/engine/ui"
"github.com/ovh/cds/engine/vcs"
"github.com/ovh/cds/sdk"
)
@@ -37,6 +38,9 @@ func configSetDefaults() {
if conf.API != nil {
defaults.SetDefaults(conf.API)
}
if conf.UI != nil {
defaults.SetDefaults(conf.UI)
}
if conf.DatabaseMigrate != nil {
defaults.SetDefaults(conf.DatabaseMigrate)
}
@@ -107,6 +111,10 @@ func configBootstrap(args []string) {
if conf.API == nil {
conf.API = &api.Configuration{}
}
case "ui":
if conf.UI == nil {
conf.UI = &ui.Configuration{}
}
case "migrate":
if conf.DatabaseMigrate == nil {
conf.DatabaseMigrate = &migrateservice.Configuration{}
@@ -161,6 +169,7 @@ func configBootstrap(args []string) {
conf.Debug = &DebugConfiguration{}
conf.Tracing = &observability.Configuration{}
conf.API = &api.Configuration{}
conf.UI = &ui.Configuration{}
conf.DatabaseMigrate = &migrateservice.Configuration{}
conf.Hatchery = &HatcheryConfiguration{}
conf.Hatchery.Local = &local.HatcheryConfiguration{}
23 changes: 21 additions & 2 deletions engine/main.go
Original file line number Diff line number Diff line change
@@ -29,6 +29,7 @@ import (
"github.com/ovh/cds/engine/migrateservice"
"github.com/ovh/cds/engine/repositories"
"github.com/ovh/cds/engine/service"
"github.com/ovh/cds/engine/ui"
"github.com/ovh/cds/engine/vcs"
"github.com/ovh/cds/sdk"
"github.com/ovh/cds/sdk/doc"
@@ -148,7 +149,7 @@ For advanced usage, Debug and Tracing section can be generated as:
$ engine config new debug tracing [µService(s)...]

All options
$ engine config new [debug] [tracing] [api] [hatchery:local] [hatchery:marathon] [hatchery:openstack] [hatchery:swarm] [hatchery:vsphere] [elasticsearch] [hooks] [vcs] [repositories] [migrate]
$ engine config new [debug] [tracing] [api] [ui] [hatchery:local] [hatchery:marathon] [hatchery:openstack] [hatchery:swarm] [hatchery:vsphere] [elasticsearch] [hooks] [vcs] [repositories] [migrate]

`,
Run: func(cmd *cobra.Command, args []string) {
@@ -201,6 +202,10 @@ All options
}
}

if conf.UI != nil {
conf.UI.API.Token = sharedInfraToken
}

if conf.Hooks != nil {
conf.Hooks.API.Token = sharedInfraToken
}
@@ -319,6 +324,14 @@ var configCheckCmd = &cobra.Command{
}
}

if conf.UI != nil && conf.UI.API.HTTP.URL != "" {
fmt.Printf("checking UI configuration...\n")
if err := ui.New().CheckConfiguration(*conf.UI); err != nil {
fmt.Printf("ui Configuration: %v\n", err)
hasError = true
}
}

if conf.VCS != nil && conf.VCS.API.HTTP.URL != "" {
fmt.Printf("checking vcs configuration...\n")
if err := vcs.New().CheckConfiguration(*conf.VCS); err != nil {
@@ -351,6 +364,9 @@ Start CDS Engine Services

This is the core component of CDS.

#### UI

This is the CDS Web UI.

#### Hatcheries

@@ -373,7 +389,7 @@ This component operates CDS VCS connectivity

Start all of this with a single command:

$ engine start [api] [hatchery:local] [hatchery:marathon] [hatchery:openstack] [hatchery:swarm] [hatchery:vsphere] [elasticsearch] [hooks] [vcs] [repositories] [migrate]
$ engine start [api] [hatchery:local] [hatchery:marathon] [hatchery:openstack] [hatchery:swarm] [hatchery:vsphere] [elasticsearch] [hooks] [vcs] [repositories] [migrate] [ui]

All the services are using the same configuration file format.

@@ -445,6 +461,9 @@ See $ engine config command for more details.
case "api":
services = append(services, serviceConf{arg: a, service: api.New(), cfg: *conf.API})
names = append(names, instance)
case "ui":
services = append(services, serviceConf{arg: a, service: ui.New(), cfg: *conf.UI})
names = append(names, instance)
case "migrate":
services = append(services, serviceConf{arg: a, service: migrateservice.New(), cfg: *conf.DatabaseMigrate})
names = append(names, conf.DatabaseMigrate.Name)
2 changes: 2 additions & 0 deletions engine/types.go
Original file line number Diff line number Diff line change
@@ -13,6 +13,7 @@ import (
"github.com/ovh/cds/engine/hooks"
"github.com/ovh/cds/engine/migrateservice"
"github.com/ovh/cds/engine/repositories"
"github.com/ovh/cds/engine/ui"
"github.com/ovh/cds/engine/vcs"
)

@@ -30,6 +31,7 @@ type Configuration struct {
} `toml:"log" comment:"#####################\n CDS Logs Settings \n####################"`
Debug *DebugConfiguration `toml:"debug" comment:"#####################\n Debug with gops \n####################" json:"debug"`
API *api.Configuration `toml:"api" comment:"#####################\n API Configuration \n####################" json:"api"`
UI *ui.Configuration `toml:"ui" comment:"#####################\n UI Configuration \n####################" json:"ui"`
Hatchery *HatcheryConfiguration `toml:"hatchery" json:"hatchery"`
Hooks *hooks.Configuration `toml:"hooks" comment:"######################\n CDS Hooks Settings \n######################" json:"hooks"`
VCS *vcs.Configuration `toml:"vcs" comment:"######################\n CDS VCS Settings \n######################" json:"vcs"`
29 changes: 29 additions & 0 deletions engine/ui/types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package ui

import (
"github.com/ovh/cds/engine/api"
"github.com/ovh/cds/engine/service"
)

// Service is the stuct representing a ui µService
type Service struct {
service.Common
Cfg Configuration
Router *api.Router
HTMLDir string
}

// Configuration is the ui configuration structure
type Configuration struct {
Name string `toml:"name" comment:"Name of this CDS UI Service\n Enter a name to enable this service" json:"name"`
Staticdir string `toml:"staticdir" default:"./ui_static_files" comment:"This directory must contains index.html file and other ui files (css, js...) from ui.tar.gz artifact." json:"staticdir"`
BaseURL string `toml:"baseURL" default:"/" comment:"Base URL. If you expose CDS UI with https://your-domain.com/ui, enter the value '/ui'" json:"baseURL"`
SentryURL string `toml:"sentryURL" default:"" comment:"Sentry URL. Optional" json:"sentryURL"`
HTTP struct {
Addr string `toml:"addr" default:"" commented:"true" comment:"Listen address without port, example: 127.0.0.1" json:"addr"`
Port int `toml:"port" default:"8080" json:"port"`
} `toml:"http" comment:"######################\n CDS UI HTTP Configuration \n######################" json:"http"`
URL string `toml:"url" comment:"URL of this UI service" default:"http://localhost:8080" json:"url"`
API service.APIServiceConfiguration `toml:"api" comment:"######################\n CDS API Settings \n######################" json:"api"`
HooksURL string `toml:"hooksURL" comment:"Hooks µService URL" default:"http://localhost:8083" json:"hooksURL"`
}
Loading