From 4208355c3d7d3d69fc7d7182830e19facc827705 Mon Sep 17 00:00:00 2001 From: Michal Nowikowski Date: Fri, 10 Jan 2020 10:08:11 +0100 Subject: [PATCH 1/3] [#133] added build date and presenting it in UI - added build date to Go compilation - adjusted ReST API to build date - added displaying version and build date of stork agent, server and db-migrate startup - added presenting version and build date in UI as tooltip to stork logo --- Rakefile | 11 ++++++++--- api/swagger.yaml | 5 ----- backend/cmd/stork-agent/main.go | 3 +++ backend/cmd/stork-db-migrate/main.go | 4 ++++ backend/cmd/stork-server/main.go | 2 ++ backend/server/restservice/restimpl.go | 9 ++------- backend/server/restservice/restimpl_test.go | 2 +- backend/version.go | 2 +- webui/src/app/app.component.html | 7 ++++++- webui/src/app/app.component.sass | 20 +++++++++++++++++++- webui/src/app/app.component.ts | 15 ++++++++++++++- 11 files changed, 60 insertions(+), 20 deletions(-) diff --git a/Rakefile b/Rakefile index aa85b7186..672593b59 100644 --- a/Rakefile +++ b/Rakefile @@ -81,6 +81,11 @@ ENV['PATH'] = "#{TOOLS_DIR}/node-v#{NODE_VER}-#{NODE_SUFFIX}/bin:#{ENV['PATH']}" ENV['PATH'] = "#{GO_DIR}/go/bin:#{ENV['PATH']}" ENV['PATH'] = "#{GOBIN}:#{ENV['PATH']}" +# build date +build_date = Time.now.strftime("%Y-%m-%d %H:%M") +puts "Stork build date: #{build_date}" +go_build_date_opt = "-ldflags=\"-X 'isc.org/stork.BuildDate=#{build_date}'\"" + # Documentation SPHINXOPTS = "-v -E -a -W -j 2" @@ -125,7 +130,7 @@ end desc 'Compile server part' task :build_server => [GO, :gen_server, :gen_agent] do sh 'rm -f backend/server/agentcomm/api_mock.go' - sh "cd backend/cmd/stork-server/ && #{GO} build" + sh "cd backend/cmd/stork-server/ && #{GO} build #{go_build_date_opt}" end file PROTOC do @@ -174,7 +179,7 @@ task :gen_agent => [AGENT_PB_GO_FILE] desc 'Compile agent part' file :build_agent => [GO, AGENT_PB_GO_FILE] do - sh "cd backend/cmd/stork-agent/ && #{GO} build" + sh "cd backend/cmd/stork-agent/ && #{GO} build #{go_build_date_opt}" end desc 'Run agent' @@ -216,7 +221,7 @@ end desc 'Compile database migrations tool' task :build_migrations => [GO] do - sh "cd backend/cmd/stork-db-migrate/ && #{GO} build" + sh "cd backend/cmd/stork-db-migrate/ && #{GO} build #{go_build_date_opt}" end desc 'Compile whole backend: server, migrations and agent' diff --git a/api/swagger.yaml b/api/swagger.yaml index 93f5b18c5..5ceb27004 100644 --- a/api/swagger.yaml +++ b/api/swagger.yaml @@ -566,16 +566,11 @@ definitions: required: - version - date - - type properties: version: type: string date: type: string - format: date-time - type: - type: string - enum: [stable, release-candidate, development] Machine: type: object diff --git a/backend/cmd/stork-agent/main.go b/backend/cmd/stork-agent/main.go index 68cd59c9c..4231d58ba 100644 --- a/backend/cmd/stork-agent/main.go +++ b/backend/cmd/stork-agent/main.go @@ -4,7 +4,9 @@ import ( "os" flags "github.com/jessevdk/go-flags" + log "github.com/sirupsen/logrus" + "isc.org/stork" "isc.org/stork/agent" storkutil "isc.org/stork/util" ) @@ -12,6 +14,7 @@ import ( func main() { // Setup logging storkutil.SetupLogging() + log.Printf("Starting Stork Agent, version %s, build date %s", stork.Version, stork.BuildDate) // Start app monitor storkAgent := agent.NewStorkAgent() diff --git a/backend/cmd/stork-db-migrate/main.go b/backend/cmd/stork-db-migrate/main.go index 2d82c2f2f..7c2f5460a 100644 --- a/backend/cmd/stork-db-migrate/main.go +++ b/backend/cmd/stork-db-migrate/main.go @@ -7,6 +7,8 @@ import ( "github.com/jessevdk/go-flags" log "github.com/sirupsen/logrus" dbops "isc.org/stork/server/database" + "isc.org/stork" + "isc.org/stork/server/database" ) // Structure defining options for all commands except "up". @@ -30,6 +32,8 @@ type Opts struct { } func main() { + log.Printf("Starting Stork Database Migration Tool, version %s, build date %s", stork.Version, stork.BuildDate) + // Parse command line options and commands. opts := Opts{} parser := flags.NewParser(&opts, flags.Default) diff --git a/backend/cmd/stork-server/main.go b/backend/cmd/stork-server/main.go index 42818dfac..960e33edd 100644 --- a/backend/cmd/stork-server/main.go +++ b/backend/cmd/stork-server/main.go @@ -3,6 +3,7 @@ package main import ( log "github.com/sirupsen/logrus" + "isc.org/stork" "isc.org/stork/server" storkutil "isc.org/stork/util" ) @@ -10,6 +11,7 @@ import ( func main() { // Setup logging storkutil.SetupLogging() + log.Printf("Starting Stork Server, version %s, build date %s", stork.Version, stork.BuildDate) // Initialize global state of Stork Server storkServer, err := server.NewStorkServer() diff --git a/backend/server/restservice/restimpl.go b/backend/server/restservice/restimpl.go index 175f3d846..dab54c2bc 100644 --- a/backend/server/restservice/restimpl.go +++ b/backend/server/restservice/restimpl.go @@ -23,15 +23,10 @@ import ( // Get version of Stork server. func (r *RestAPI) GetVersion(ctx context.Context, params general.GetVersionParams) middleware.Responder { - d, err := strfmt.ParseDateTime("0001-01-01T00:00:00.000Z") - if err != nil { - fmt.Printf("problem\n") - } - bt := stork.BuildType + bd := stork.BuildDate v := stork.Version ver := models.Version{ - Date: &d, - Type: &bt, + Date: &bd, Version: &v, } return general.NewGetVersionOK().WithPayload(&ver) diff --git a/backend/server/restservice/restimpl_test.go b/backend/server/restservice/restimpl_test.go index 36a8cc95e..8b84d01a3 100644 --- a/backend/server/restservice/restimpl_test.go +++ b/backend/server/restservice/restimpl_test.go @@ -30,8 +30,8 @@ func TestGetVersion(t *testing.T) { rsp := rapi.GetVersion(ctx, params) p := rsp.(*general.GetVersionOK).Payload - require.Equal(t, "unstable", *p.Type) require.Regexp(t, `^\d+.\d+.\d+$`, *p.Version) + require.Equal(t, "unset", *p.Date) } func TestGetMachineState(t *testing.T) { diff --git a/backend/version.go b/backend/version.go index 0a28a35e1..c1a6cd838 100644 --- a/backend/version.go +++ b/backend/version.go @@ -1,4 +1,4 @@ package stork const Version = "0.3.0" -const BuildType = "unstable" +var BuildDate = "unset" diff --git a/webui/src/app/app.component.html b/webui/src/app/app.component.html index abd169a2f..3cca35a79 100644 --- a/webui/src/app/app.component.html +++ b/webui/src/app/app.component.html @@ -2,7 +2,12 @@ *ngIf="currentUser" style="background-color: #005B9F; margin: -8px -8px 0 -8px; display: flex; justify-content: space-between; align-items: center;" > - +
Stork
diff --git a/webui/src/app/app.component.sass b/webui/src/app/app.component.sass index b212e6098..10aed5fee 100644 --- a/webui/src/app/app.component.sass +++ b/webui/src/app/app.component.sass @@ -1,3 +1,4 @@ +// improve look of topbar menu :host ::ng-deep .stork-menubar background-color: #005B9F border-width: 0px @@ -12,9 +13,26 @@ color: black - @keyframes ui-progress-spinner-color 0% stroke: #fff 100% stroke: #fff + + +// fix position and look of stork version tooltip +::ng-deep .stork-version-tooltip + left: 44px !important + +// make it wider +::ng-deep .ui-tooltip.stork-version-tooltip + max-width: 600px + +// hide arrow +::ng-deep .stork-version-tooltip .ui-tooltip-arrow + display: none + +// set nice look of stork version tooltip +::ng-deep body .ui-tooltip.stork-version-tooltip .ui-tooltip-text + background-color: #c6c6c6 + color: #000 diff --git a/webui/src/app/app.component.ts b/webui/src/app/app.component.ts index 54e56f483..42ef608ef 100644 --- a/webui/src/app/app.component.ts +++ b/webui/src/app/app.component.ts @@ -4,6 +4,7 @@ import { Observable } from 'rxjs' import { MenuItem } from 'primeng/api' +import { GeneralService } from './backend/api/api' import { AuthService } from './auth.service' import { LoadingService } from './loading.service' @@ -14,12 +15,19 @@ import { LoadingService } from './loading.service' }) export class AppComponent implements OnInit { title = 'Stork' + storkVersion = 'unknown' + storkBuildDate = 'unknown' currentUser = null loadingInProgress = new Observable() menuItems: MenuItem[] - constructor(private router: Router, private auth: AuthService, private loadingService: LoadingService) { + constructor( + private router: Router, + protected generalApi: GeneralService, + private auth: AuthService, + private loadingService: LoadingService + ) { this.auth.currentUser.subscribe(x => { this.currentUser = x this.initMenuItems() @@ -82,6 +90,11 @@ export class AppComponent implements OnInit { ngOnInit() { this.initMenuItems() + + this.generalApi.getVersion().subscribe(data => { + this.storkVersion = data.version + this.storkBuildDate = data.date + }) } signOut() { -- GitLab From 46a73392c99c84968f97654895406a9c7ed242bc Mon Sep 17 00:00:00 2001 From: Tomek Mrugalski Date: Tue, 14 Jan 2020 13:42:19 +0100 Subject: [PATCH 2/3] [#133] Fixed broken rebase --- backend/cmd/stork-db-migrate/main.go | 1 - 1 file changed, 1 deletion(-) diff --git a/backend/cmd/stork-db-migrate/main.go b/backend/cmd/stork-db-migrate/main.go index 7c2f5460a..697c097e2 100644 --- a/backend/cmd/stork-db-migrate/main.go +++ b/backend/cmd/stork-db-migrate/main.go @@ -8,7 +8,6 @@ import ( log "github.com/sirupsen/logrus" dbops "isc.org/stork/server/database" "isc.org/stork" - "isc.org/stork/server/database" ) // Structure defining options for all commands except "up". -- GitLab From 879ba1621e63f0917591e297182b3d538773adf3 Mon Sep 17 00:00:00 2001 From: Michal Nowikowski Date: Wed, 15 Jan 2020 11:48:27 +0100 Subject: [PATCH 3/3] [#133] review changes and lint fixes - added ChangeLog entry - added ignoring globals from version.go - fixed import order --- backend/.golangci.yml | 4 ++++ backend/cmd/stork-db-migrate/main.go | 2 +- backend/version.go | 1 + 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/backend/.golangci.yml b/backend/.golangci.yml index e5490863b..b38d1bef5 100644 --- a/backend/.golangci.yml +++ b/backend/.golangci.yml @@ -38,6 +38,10 @@ issues: - gochecknoinits - gochecknoglobals + - path: version.go + linters: + - gochecknoglobals + - path: server/database/settings.go linters: - gochecknoinits diff --git a/backend/cmd/stork-db-migrate/main.go b/backend/cmd/stork-db-migrate/main.go index 697c097e2..e074f2ddf 100644 --- a/backend/cmd/stork-db-migrate/main.go +++ b/backend/cmd/stork-db-migrate/main.go @@ -6,8 +6,8 @@ import ( "github.com/jessevdk/go-flags" log "github.com/sirupsen/logrus" - dbops "isc.org/stork/server/database" "isc.org/stork" + dbops "isc.org/stork/server/database" ) // Structure defining options for all commands except "up". diff --git a/backend/version.go b/backend/version.go index c1a6cd838..edba19ca2 100644 --- a/backend/version.go +++ b/backend/version.go @@ -1,4 +1,5 @@ package stork const Version = "0.3.0" + var BuildDate = "unset" -- GitLab