Skip to content

Commit ff0630c

Browse files
jpinsonneaumemodi
andauthored
NETOBSERV-1942 config / status views + NETOBSERV-1945 resource calculator (#763)
* wip * resource calculator * set sampling from consumption step * added estimation & recommendation * fix style * Update web/src/components/forms/consumption.tsx Co-authored-by: Mehul Modi <[email protected]> * hide filters from forms * add scrolls and fit pipeline view * status selections * custom widget for secondary interfaces * checkboxes for features * removed unecessary fields in the setup and improve display --------- Co-authored-by: Mehul Modi <[email protected]>
1 parent d298583 commit ff0630c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+11982
-372
lines changed

.mk/static.mk

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
##@ Static
2+
3+
.PHONY: build-frontend-static
4+
build-frontend-static: install-frontend fmt-frontend ## Run npm install, format and build static frontend
5+
@echo "### Building static frontend"
6+
cd web && npm run build:static

Dockerfile.cypress

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ COPY mocks mocks
1919
WORKDIR /opt/app-root/web
2020
RUN npm run format-all
2121
RUN npm run build$BUILDSCRIPT
22+
RUN npm run build:static
2223

2324
FROM --platform=$BUILDPLATFORM docker.io/library/golang:1.24 as go-builder
2425

Dockerfile.downstream

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ COPY --chown=default mocks mocks
1717
WORKDIR /opt/app-root/web
1818
RUN npm run format-all
1919
RUN npm run build
20+
RUN npm run build:static
2021

2122
FROM brew.registry.redhat.io/rh-osbs/openshift-golang-builder:v1.24 as go-builder
2223

Dockerfile.front

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ COPY mocks mocks
1717
WORKDIR /opt/app-root/web
1818
RUN npm run format-all
1919
RUN npm run build$BUILDSCRIPT
20+
RUN npm run build:static
2021

2122
FROM scratch
2223

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,3 +228,4 @@ endif
228228
include .mk/cypress.mk
229229
include .mk/shortcuts.mk
230230
include .mk/standalone.mk
231+
include .mk/static.mk

pkg/config/config.go

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -144,12 +144,15 @@ type Config struct {
144144
Frontend Frontend `yaml:"frontend" json:"frontend"`
145145
Server Server `yaml:"server,omitempty" json:"server,omitempty"`
146146
Path string `yaml:"-" json:"-"`
147+
Static bool
147148
}
148149

149150
func ReadFile(version, date, filename string) (*Config, error) {
151+
isStatic := len(filename) == 0
150152
// set default values
151153
cfg := Config{
152-
Path: filename,
154+
Path: filename,
155+
Static: isStatic,
153156
Server: Server{
154157
Port: 9001,
155158
MetricsPort: 9002,
@@ -191,7 +194,10 @@ func ReadFile(version, date, filename string) (*Config, error) {
191194
PromLabels: []string{},
192195
},
193196
}
194-
if len(filename) == 0 {
197+
if isStatic {
198+
// Force TLS
199+
cfg.Server.CertPath = "/var/serving-cert/tls.crt"
200+
cfg.Server.KeyPath = "/var/serving-cert/tls.key"
195201
return &cfg, nil
196202
}
197203
yamlFile, err := os.ReadFile(filename)
@@ -241,7 +247,7 @@ func (c *Config) IsPromEnabled() bool {
241247
}
242248

243249
func (c *Config) Validate() error {
244-
if !c.IsLokiEnabled() && !c.IsPromEnabled() {
250+
if !c.Static && !c.IsLokiEnabled() && !c.IsPromEnabled() {
245251
return errors.New("neither Loki nor Prometheus is configured; at least one of them should have a URL defined")
246252
}
247253

pkg/server/routes.go

Lines changed: 26 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -41,31 +41,37 @@ func setupRoutes(ctx context.Context, cfg *config.Config, authChecker auth.Check
4141
})
4242
})
4343

44-
// Server status
44+
// Server status and config
4545
api.HandleFunc("/status", h.Status(ctx))
46+
api.HandleFunc("/frontend-config", h.GetFrontendConfig())
4647

47-
// Loki endpoints
48-
api.HandleFunc("/loki/ready", h.LokiReady())
49-
api.HandleFunc("/loki/metrics", forceCheckAdmin(authChecker, h.LokiMetrics()))
50-
api.HandleFunc("/loki/buildinfo", forceCheckAdmin(authChecker, h.LokiBuildInfos()))
51-
api.HandleFunc("/loki/config/limits", forceCheckAdmin(authChecker, h.LokiLimits()))
52-
api.HandleFunc("/loki/flow/records", h.GetFlows(ctx))
53-
api.HandleFunc("/loki/export", h.ExportFlows(ctx))
48+
if cfg.Static {
49+
// Expose static files only
50+
r.PathPrefix("/").Handler(http.FileServer(http.Dir("./web/dist/static")))
51+
} else {
52+
// Loki endpoints
53+
api.HandleFunc("/loki/ready", h.LokiReady())
54+
api.HandleFunc("/loki/metrics", forceCheckAdmin(authChecker, h.LokiMetrics()))
55+
api.HandleFunc("/loki/buildinfo", forceCheckAdmin(authChecker, h.LokiBuildInfos()))
56+
api.HandleFunc("/loki/config/limits", forceCheckAdmin(authChecker, h.LokiLimits()))
57+
api.HandleFunc("/loki/flow/records", h.GetFlows(ctx))
58+
api.HandleFunc("/loki/export", h.ExportFlows(ctx))
5459

55-
// Common endpoints
56-
api.HandleFunc("/flow/metrics", h.GetTopology(ctx))
57-
api.HandleFunc("/resources/clusters", h.GetClusters(ctx))
58-
api.HandleFunc("/resources/udns", h.GetUDNs(ctx))
59-
api.HandleFunc("/resources/zones", h.GetZones(ctx))
60-
api.HandleFunc("/resources/namespaces", h.GetNamespaces(ctx))
61-
api.HandleFunc("/resources/names", h.GetNames(ctx))
60+
// Common endpoints
61+
api.HandleFunc("/flow/metrics", h.GetTopology(ctx))
62+
api.HandleFunc("/resources/clusters", h.GetClusters(ctx))
63+
api.HandleFunc("/resources/udns", h.GetUDNs(ctx))
64+
api.HandleFunc("/resources/zones", h.GetZones(ctx))
65+
api.HandleFunc("/resources/namespaces", h.GetNamespaces(ctx))
66+
api.HandleFunc("/resources/names", h.GetNames(ctx))
6267

63-
// K8S endpoints
64-
api.HandleFunc("/k8s/resources/udnIds", h.GetUDNIdss(ctx))
68+
// K8S endpoints
69+
api.HandleFunc("/k8s/resources/udnIds", h.GetUDNIdss(ctx))
70+
71+
// Frontend files
72+
r.PathPrefix("/").Handler(http.FileServer(http.Dir("./web/dist/")))
73+
}
6574

66-
// Frontend files
67-
api.HandleFunc("/frontend-config", h.GetFrontendConfig())
68-
r.PathPrefix("/").Handler(http.FileServer(http.Dir("./web/dist/")))
6975
return r
7076
}
7177

0 commit comments

Comments
 (0)