You've already forked focalboard
							
							
				mirror of
				https://github.com/mattermost/focalboard.git
				synced 2025-10-31 00:17:42 +02:00 
			
		
		
		
	[GH-3410] Healthcheck Endpoint with Server Metadata (#4151)
* add ping endpoint and tests * remove unnecessary newlines * fix: invalid Swagger YAML comment blocks * refactor and add 'suite' SKU * generate swagger docs Co-authored-by: Mattermod <mattermod@users.noreply.github.com> Co-authored-by: Paul Esch-Laurent <paul.esch-laurent@mattermost.com>
This commit is contained in:
		
							
								
								
									
										42
									
								
								server/app/server_metadata.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										42
									
								
								server/app/server_metadata.go
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,42 @@ | ||||
| package app | ||||
|  | ||||
| import ( | ||||
| 	"runtime" | ||||
|  | ||||
| 	"github.com/mattermost/focalboard/server/model" | ||||
| ) | ||||
|  | ||||
| type ServerMetadata struct { | ||||
| 	Version     string `json:"version"` | ||||
| 	BuildNumber string `json:"build_number"` | ||||
| 	BuildDate   string `json:"build_date"` | ||||
| 	Commit      string `json:"commit"` | ||||
| 	Edition     string `json:"edition"` | ||||
| 	DBType      string `json:"db_type"` | ||||
| 	DBVersion   string `json:"db_version"` | ||||
| 	OSType      string `json:"os_type"` | ||||
| 	OSArch      string `json:"os_arch"` | ||||
| 	SKU         string `json:"sku"` | ||||
| } | ||||
|  | ||||
| func (a *App) GetServerMetadata() *ServerMetadata { | ||||
| 	var dbType string | ||||
| 	var dbVersion string | ||||
| 	if a != nil && a.store != nil { | ||||
| 		dbType = a.store.DBType() | ||||
| 		dbVersion = a.store.DBVersion() | ||||
| 	} | ||||
|  | ||||
| 	return &ServerMetadata{ | ||||
| 		Version:     model.CurrentVersion, | ||||
| 		BuildNumber: model.BuildNumber, | ||||
| 		BuildDate:   model.BuildDate, | ||||
| 		Commit:      model.BuildHash, | ||||
| 		Edition:     model.Edition, | ||||
| 		DBType:      dbType, | ||||
| 		DBVersion:   dbVersion, | ||||
| 		OSType:      runtime.GOOS, | ||||
| 		OSArch:      runtime.GOARCH, | ||||
| 		SKU:         "personal_server", | ||||
| 	} | ||||
| } | ||||
							
								
								
									
										37
									
								
								server/app/server_metadata_test.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										37
									
								
								server/app/server_metadata_test.go
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,37 @@ | ||||
| package app | ||||
|  | ||||
| import ( | ||||
| 	"reflect" | ||||
| 	"runtime" | ||||
| 	"testing" | ||||
|  | ||||
| 	"github.com/mattermost/focalboard/server/model" | ||||
| ) | ||||
|  | ||||
| func TestGetServerMetadata(t *testing.T) { | ||||
| 	th, tearDown := SetupTestHelper(t) | ||||
| 	defer tearDown() | ||||
|  | ||||
| 	th.Store.EXPECT().DBType().Return("TEST_DB_TYPE") | ||||
| 	th.Store.EXPECT().DBVersion().Return("TEST_DB_VERSION") | ||||
|  | ||||
| 	t.Run("Get Server Metadata", func(t *testing.T) { | ||||
| 		got := th.App.GetServerMetadata() | ||||
| 		want := &ServerMetadata{ | ||||
| 			Version:     model.CurrentVersion, | ||||
| 			BuildNumber: model.BuildNumber, | ||||
| 			BuildDate:   model.BuildDate, | ||||
| 			Commit:      model.BuildHash, | ||||
| 			Edition:     model.Edition, | ||||
| 			DBType:      "TEST_DB_TYPE", | ||||
| 			DBVersion:   "TEST_DB_VERSION", | ||||
| 			OSType:      runtime.GOOS, | ||||
| 			OSArch:      runtime.GOARCH, | ||||
| 			SKU:         "personal_server", | ||||
| 		} | ||||
|  | ||||
| 		if !reflect.DeepEqual(got, want) { | ||||
| 			t.Errorf("got: %q, want: %q", got, want) | ||||
| 		} | ||||
| 	}) | ||||
| } | ||||
		Reference in New Issue
	
	Block a user