Skip to content

Commit d809dcd

Browse files
committed
Merge branch '401-standard-engine-edition' into 'master'
feat(engine,ui): report the type of subscription in UI (#401) Closes #401 See merge request postgres-ai/database-lab!563
2 parents ea8e275 + f25bb47 commit d809dcd

File tree

9 files changed

+54
-9
lines changed

9 files changed

+54
-9
lines changed

engine/cmd/database-lab/main.go

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -233,10 +233,16 @@ func getEngineProperties(ctx context.Context, dockerCLI *client.Client, cfg *con
233233
return global.EngineProps{}, fmt.Errorf("failed to load instance ID: %w", err)
234234
}
235235

236+
infra := os.Getenv("DLE_COMPUTING_INFRASTRUCTURE")
237+
if infra == "" {
238+
infra = global.LocalInfra
239+
}
240+
236241
engProps := global.EngineProps{
237-
InstanceID: instanceID,
238-
ContainerName: strings.Trim(dleContainer.Name, "/"),
239-
EnginePort: cfg.Server.Port,
242+
InstanceID: instanceID,
243+
ContainerName: strings.Trim(dleContainer.Name, "/"),
244+
Infrastructure: infra,
245+
EnginePort: cfg.Server.Port,
240246
}
241247

242248
return engProps, nil

engine/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ require (
1212
github.com/docker/go-connections v0.4.0
1313
github.com/docker/go-units v0.4.0
1414
github.com/dustin/go-humanize v1.0.0
15+
github.com/golang-jwt/jwt/v4 v4.4.2
1516
github.com/google/go-github/v34 v34.0.0
1617
github.com/gorilla/mux v1.8.0
1718
github.com/gorilla/websocket v1.4.2
@@ -44,7 +45,6 @@ require (
4445
github.com/docker/distribution v2.8.0+incompatible // indirect
4546
github.com/go-ole/go-ole v1.2.5 // indirect
4647
github.com/gogo/protobuf v1.3.2 // indirect
47-
github.com/golang-jwt/jwt/v4 v4.4.2 // indirect
4848
github.com/golang/protobuf v1.5.2 // indirect
4949
github.com/google/go-querystring v1.0.0 // indirect
5050
github.com/google/uuid v1.3.0 // indirect

engine/internal/srv/routes.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -540,6 +540,7 @@ func (s *Server) healthCheck(w http.ResponseWriter, _ *http.Request) {
540540

541541
healthResponse := models.Engine{
542542
Version: version.GetVersion(),
543+
Edition: s.engProps.GetEdition(),
543544
}
544545

545546
if err := json.NewEncoder(w).Encode(healthResponse); err != nil {

engine/pkg/config/global/config.go

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,25 @@ type Telemetry struct {
4949

5050
// EngineProps contains internal Database Lab Engine properties.
5151
type EngineProps struct {
52-
InstanceID string
53-
ContainerName string
54-
EnginePort uint
52+
InstanceID string
53+
ContainerName string
54+
Infrastructure string
55+
EnginePort uint
56+
}
57+
58+
const (
59+
// LocalInfra defines a local infra.
60+
LocalInfra = "local"
61+
62+
communityEdition = "community"
63+
standardEdition = "standard"
64+
)
65+
66+
// GetEdition provides the DLE edition.
67+
func (p *EngineProps) GetEdition() string {
68+
if p.Infrastructure != LocalInfra {
69+
return standardEdition
70+
}
71+
72+
return communityEdition
5573
}

engine/pkg/models/instance_status.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ type Cloning struct {
4444
// Engine represents info about Database Lab Engine instance.
4545
type Engine struct {
4646
Version string `json:"version"`
47+
Edition string `json:"edition"`
4748
StartedAt *LocalTime `json:"startedAt,omitempty"`
4849
Telemetry *bool `json:"telemetry,omitempty"`
4950
}

ui/packages/ce/src/App/Menu/Header/index.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import logoIconUrl from './icons/logo.svg'
1010
import { ReactComponent as StarsIcon } from './icons/stars.svg'
1111

1212
import styles from './styles.module.scss'
13+
import { DLEEdition } from "helpers/edition";
1314

1415
type Props = {
1516
isCollapsed: boolean
@@ -28,7 +29,7 @@ export const Header = (props: Props) => {
2829
<h1 className={styles.title}>
2930
Database Lab
3031
<br />
31-
<span className={styles.name}>Community Edition</span>
32+
<span className={styles.name}>{DLEEdition()}</span>
3233
</h1>
3334
)}
3435
</Link>

ui/packages/ce/src/config/routes.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
export const ROUTES = {
2-
name: 'Database Lab Community Edition',
2+
name: 'Database Lab',
33
path: '/',
44

55
AUTH: {

ui/packages/ce/src/helpers/edition.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import { appStore } from "stores/app";
2+
3+
const communityEdition = 'Community Edition'
4+
const standardEdition = 'Standard Edition'
5+
6+
export const DLEEdition = (): string => {
7+
switch (appStore.engine?.data?.edition) {
8+
case 'standard':
9+
return standardEdition
10+
11+
case 'community':
12+
return communityEdition
13+
14+
default:
15+
return communityEdition
16+
}
17+
}

ui/packages/ce/src/types/api/entities/engine.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
export type EngineDto = {
22
version: string
3+
edition?: string
34
}
45

56
export const formatEngineDto = (dto: EngineDto) => dto

0 commit comments

Comments
 (0)