diff --git a/Rakefile b/Rakefile index aa85b718645d062a8eea189dadf9ad0238ea5051..672593b599ad7df619fc2c1cad8c75188a523f5b 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 93f5b18c52965c28af569f28e207430868813e3f..5ceb2700493bec9dc6170dced9bb5a2f80476537 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/.golangci.yml b/backend/.golangci.yml index e5490863b83c09a77662a74fc9a34cdc28dba741..b38d1bef50f6301bc6906972917d39d01a63a0b0 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-agent/main.go b/backend/cmd/stork-agent/main.go index 68cd59c9c2522ac8265a9a057fb6225eecc982b5..4231d58ba59160a4f56cb03bdc88733cfbb7582b 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 2d82c2f2fe17b4442e0dcf5aee5afe84ac07adb0..e074f2ddfaa66e0fdbfaaf0e00a1be3b66bda8ff 100644 --- a/backend/cmd/stork-db-migrate/main.go +++ b/backend/cmd/stork-db-migrate/main.go @@ -6,6 +6,7 @@ import ( "github.com/jessevdk/go-flags" log "github.com/sirupsen/logrus" + "isc.org/stork" dbops "isc.org/stork/server/database" ) @@ -30,6 +31,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 42818dfac83b207806c3b0f624120e0b92925e1d..960e33edd6a709043250bf012caf64aed2118848 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 175f3d8464dde26011ab4240bd20767026cabffe..dab54c2bc07505837f77ee61d2c7dc782e8affe3 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 36a8cc95ee86d2b11663206e6db303c83f7454d4..8b84d01a3424f2c19d89857172393e069dfdf0f3 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 0a28a35e119b1c91a3d49a3f27d7935e883d073a..edba19ca2be51d009111d1af2f9dbb5f7d280846 100644 --- a/backend/version.go +++ b/backend/version.go @@ -1,4 +1,5 @@ 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 abd169a2f736e2f2013f1e3970677b26bd644752..3cca35a79113358a305496d23d6485502a9014f7 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 b212e609859d2b1c36c8d821947d15711ac59103..10aed5fee142b9a666356e2c69ff7bd0df20eb2d 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 54e56f4833f554dbc880e2528b8642082e9ee2f8..42ef608efe94faccdbec5661783b096a50174944 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() {