Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ install-frontend:

.PHONY: install-frontend-ci
install-frontend-ci:
cd web && npm ci
cd web && npm ci --ignore-scripts

.PHONY: install-frontend-ci-clean
install-frontend-ci-clean: install-frontend-ci
Expand Down Expand Up @@ -40,6 +40,10 @@ install-backend:
build-backend:
go build $(BUILD_OPTS) -mod=readonly -o plugin-backend -mod=readonly cmd/plugin-backend.go

.PHONY: build-backend-dev
build-backend-dev:
GOARCH=amd64 GOOS=linux go build -mod=readonly -o plugin-backend -mod=readonly cmd/plugin-backend.go

.PHONY: test-unit-backend
test-unit-backend:
go test ./...
Expand Down
45 changes: 45 additions & 0 deletions config/clear-extensions.patch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
[
{
"op": "replace",
"path": "/extensions",
"value": [
{
"type": "console.page/route",
"properties": {
"exact": true,
"path": "/monitoring/logs",
"component": {
"$codeRef": "LogsPage"
}
}
},
{
"type": "console.navigation/href",
"properties": {
"id": "monitoring-logs",
"name": "Logs",
"href": "/monitoring/logs",
"perspective": "admin",
"section": "observe"
}
},
{
"type": "console.tab/horizontalNav",
"properties": {
"page": {
"name": "%plugin__logging-view-plugin~Aggregated Logs%",
"href": "aggregated-logs"
},
"model": {
"group": "core",
"version": "v1",
"kind": "Pod"
},
"component": {
"$codeRef": "LogsDetailPage"
}
}
}
]
}
]
48 changes: 0 additions & 48 deletions config/plugin-manifest.json

This file was deleted.

2 changes: 2 additions & 0 deletions logging-view-plugin-resources.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ spec:
- "-cert=/var/serving-cert/tls.crt"
- "-key=/var/serving-cert/tls.key"
- "-plugin-config-path=/etc/plugin/config.yaml"
- "-static-path=/opt/app-root/web/dist"
- "-config-path=/opt/app-root/config"
securityContext:
allowPrivilegeEscalation: false
capabilities:
Expand Down
33 changes: 22 additions & 11 deletions pkg/server/manifest_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,35 +13,46 @@ import (
var mlog = logrus.WithField("module", "manifest")

func manifestHandler(cfg *Config) http.HandlerFunc {
baseManifestData, err := os.ReadFile(filepath.Join(cfg.ConfigPath, "plugin-manifest.json"))
baseManifestData, err := os.ReadFile(filepath.Join(cfg.StaticPath, "plugin-manifest.json"))
if err != nil {
mlog.WithError(err).Error("cannot read base manifest file")
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
http.Error(w, err.Error(), http.StatusInternalServerError)
})
}

patchedManifest := patchManifest(baseManifestData, cfg)

return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "application/json")
w.Header().Set("Cache-Control", "no-cache, no-store, must-revalidate")
w.Header().Set("Expires", "0")

w.Write(patchedManifest)
})
}

func patchManifest(baseManifestData []byte, cfg *Config) []byte {
if len(cfg.Features) == 0 {
return baseManifestData
}

patchedManifest := baseManifestData
patchedManifest = performPatch(baseManifestData, filepath.Join(cfg.ConfigPath, "clear-extensions.patch.json"))

// Add alert charts if any of the alert features are enabled
if cfg.Features["alerts"] || cfg.Features["dev-alerts"] {
patchedManifest = patchManifest(patchedManifest, filepath.Join(cfg.ConfigPath, "alerts-charts.patch.json"))
patchedManifest = performPatch(patchedManifest, filepath.Join(cfg.ConfigPath, "alerts-charts.patch.json"))
}

for k := range cfg.Features {
patchedManifest = patchManifest(patchedManifest, filepath.Join(cfg.ConfigPath, fmt.Sprintf("%s.patch.json", k)))
patchedManifest = performPatch(patchedManifest, filepath.Join(cfg.ConfigPath, fmt.Sprintf("%s.patch.json", k)))
}

return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "application/json")
w.Header().Set("Cache-Control", "no-cache, no-store, must-revalidate")
w.Header().Set("Expires", "0")

w.Write(patchedManifest)
})
return []byte(patchedManifest)
}

func patchManifest(originalData []byte, patchFilePath string) []byte {
func performPatch(originalData []byte, patchFilePath string) []byte {
patchData, err := os.ReadFile(patchFilePath)
if err != nil {
mlog.WithField("reason", err).Warnf("cannot read patch file %s", patchFilePath)
Expand Down