Skip to content

Commit 7536c59

Browse files
committed
feat: show scion version info on admin server config page
Add scion_version, scion_commit, and scion_build_time fields to the ServerConfigResponse so the admin UI can display the server's build information. The General tab now shows a "Scion Server Version" section at the top with version, git commit, and build time.
1 parent 906a88d commit 7536c59

File tree

2 files changed

+92
-1
lines changed

2 files changed

+92
-1
lines changed

pkg/hub/admin_settings.go

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,18 @@ import (
2121
"path/filepath"
2222

2323
"github.com/GoogleCloudPlatform/scion/pkg/config"
24+
"github.com/GoogleCloudPlatform/scion/pkg/version"
2425
yamlv3 "gopkg.in/yaml.v3"
2526
)
2627

2728
// ServerConfigResponse is the API representation of the server settings file.
2829
// It mirrors the on-disk settings.yaml structure, omitting sensitive fields.
2930
type ServerConfigResponse struct {
31+
// Read-only server build info (not persisted in settings.yaml).
32+
ScionVersion string `json:"scion_version,omitempty"`
33+
ScionCommit string `json:"scion_commit,omitempty"`
34+
ScionBuildTime string `json:"scion_build_time,omitempty"`
35+
3036
SchemaVersion string `json:"schema_version"`
3137
ActiveProfile string `json:"active_profile,omitempty"`
3238
DefaultTemplate string `json:"default_template,omitempty"`
@@ -88,7 +94,12 @@ func (s *Server) handleGetServerConfig(w http.ResponseWriter) {
8894
if err != nil {
8995
if os.IsNotExist(err) {
9096
// Return empty/default response if no settings file exists
91-
writeJSON(w, http.StatusOK, ServerConfigResponse{SchemaVersion: "1"})
97+
writeJSON(w, http.StatusOK, ServerConfigResponse{
98+
ScionVersion: version.Short(),
99+
ScionCommit: version.Commit,
100+
ScionBuildTime: version.BuildTime,
101+
SchemaVersion: "1",
102+
})
92103
return
93104
}
94105
writeError(w, http.StatusInternalServerError, ErrCodeInternalError, "Failed to read settings file", nil)
@@ -103,6 +114,9 @@ func (s *Server) handleGetServerConfig(w http.ResponseWriter) {
103114

104115
// Mask sensitive fields before sending to the client
105116
resp := ServerConfigResponse{
117+
ScionVersion: version.Short(),
118+
ScionCommit: version.Commit,
119+
ScionBuildTime: version.BuildTime,
106120
SchemaVersion: vs.SchemaVersion,
107121
ActiveProfile: vs.ActiveProfile,
108122
DefaultTemplate: vs.DefaultTemplate,

web/src/components/pages/admin-server-config.ts

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,9 @@ interface V1RuntimeConfig {
167167
}
168168

169169
interface ServerConfigResponse {
170+
scion_version?: string;
171+
scion_commit?: string;
172+
scion_build_time?: string;
170173
schema_version: string;
171174
active_profile?: string;
172175
default_template?: string;
@@ -195,6 +198,11 @@ export class ScionPageAdminServerConfig extends LitElement {
195198
@state() private activeTab = 'general';
196199
@state() private reloadResult: ReloadResult | null = null;
197200

201+
// ── Read-only server build info ──
202+
@state() private scionVersion = '';
203+
@state() private scionCommit = '';
204+
@state() private scionBuildTime = '';
205+
198206
// ── Form state (mirrors settings.yaml) ──
199207

200208
// General
@@ -372,6 +380,40 @@ export class ScionPageAdminServerConfig extends LitElement {
372380
color: var(--scion-text-muted, #64748b);
373381
}
374382
383+
.version-info {
384+
display: flex;
385+
flex-wrap: wrap;
386+
gap: 1.5rem;
387+
}
388+
389+
.version-item {
390+
display: flex;
391+
flex-direction: column;
392+
gap: 0.125rem;
393+
}
394+
395+
.version-label {
396+
font-size: 0.75rem;
397+
font-weight: 500;
398+
color: var(--scion-text-muted, #64748b);
399+
text-transform: uppercase;
400+
letter-spacing: 0.025em;
401+
}
402+
403+
.version-value {
404+
font-size: 0.875rem;
405+
color: var(--scion-text, #1e293b);
406+
}
407+
408+
.version-value code {
409+
font-family: var(--sl-font-mono, monospace);
410+
font-size: 0.8125rem;
411+
background: var(--scion-bg, #f8fafc);
412+
padding: 0.125rem 0.375rem;
413+
border-radius: 0.25rem;
414+
border: 1px solid var(--scion-border, #e2e8f0);
415+
}
416+
375417
sl-input::part(base),
376418
sl-select::part(combobox),
377419
sl-textarea::part(base) {
@@ -474,6 +516,11 @@ export class ScionPageAdminServerConfig extends LitElement {
474516
}
475517

476518
private populateForm(data: ServerConfigResponse): void {
519+
// Server build info
520+
this.scionVersion = data.scion_version || '';
521+
this.scionCommit = data.scion_commit || '';
522+
this.scionBuildTime = data.scion_build_time || '';
523+
477524
// General
478525
this.activeProfile = data.active_profile || '';
479526
this.defaultTemplate = data.default_template || '';
@@ -817,8 +864,38 @@ export class ScionPageAdminServerConfig extends LitElement {
817864

818865
// ── Tab renderers ──
819866

867+
private renderVersionInfo() {
868+
if (!this.scionVersion && !this.scionCommit) return nothing;
869+
return html`
870+
<div class="section">
871+
<h3 class="section-title">Scion Server Version</h3>
872+
<div class="version-info">
873+
${this.scionVersion
874+
? html`<div class="version-item">
875+
<span class="version-label">Version</span>
876+
<span class="version-value">${this.scionVersion}</span>
877+
</div>`
878+
: nothing}
879+
${this.scionCommit
880+
? html`<div class="version-item">
881+
<span class="version-label">Git Commit</span>
882+
<span class="version-value"><code>${this.scionCommit}</code></span>
883+
</div>`
884+
: nothing}
885+
${this.scionBuildTime
886+
? html`<div class="version-item">
887+
<span class="version-label">Build Time</span>
888+
<span class="version-value">${this.scionBuildTime}</span>
889+
</div>`
890+
: nothing}
891+
</div>
892+
</div>
893+
`;
894+
}
895+
820896
private renderGeneralTab() {
821897
return html`
898+
${this.renderVersionInfo()}
822899
<div class="section">
823900
<h3 class="section-title">General Settings</h3>
824901
<div class="form-grid">

0 commit comments

Comments
 (0)