Skip to content

Commit

Permalink
Change configs from json to yaml (kyma-project#1932)
Browse files Browse the repository at this point in the history
* move sidecars from json to yaml

* remove cherry:

* add configs yaml

* change json config to yamls with docker and makefile, nginix and deployments

* bump web and backend

* add js-yaml to backend, fix yq command

* try to fix Dockerfile

* try to fix Dockerfile second time

* fix kubekonfig id test

* bring old sideracs

* fix sidecars

* align tests

* remove jq from dockerfile
  • Loading branch information
mrCherry97 authored Oct 14, 2022
1 parent 3013a78 commit f7597c7
Show file tree
Hide file tree
Showing 23 changed files with 139 additions and 146 deletions.
12 changes: 5 additions & 7 deletions Dockerfile.local
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ FROM alpine:3.15.0
WORKDIR /app

RUN apk --no-cache upgrade && \
apk --no-cache add nginx && \
apk add --update nodejs npm jq
apk --no-cache add nginx && \
apk add --update nodejs npm yq
WORKDIR /app

COPY --from=builder /app/core/src /app/core
Expand All @@ -51,12 +51,10 @@ RUN mv /app/core/assets/extensions/extensions.yaml /app/extensions.yaml
RUN npm ci --only=production

# use sessionStorage as default
RUN sed -i 's/"storage": "localStorage",/"storage": "sessionStorage",/g' core/assets/defaultConfig.json
# enable OBSERVABILITY & SHOW_KYMA_VERSION for production
RUN cat core/assets/defaultConfig.json \
| jq '.config.features.OBSERVABILITY.isEnabled = true' \
| jq '.config.features.SHOW_KYMA_VERSION.isEnabled = true' \
| tee core/assets/defaultConfig.json > /dev/null
RUN yq eval -i '.config.features.OBSERVABILITY.isEnabled = true' core/assets/defaultConfig.yaml
RUN yq eval -i '.config.features.SHOW_KYMA_VERSION.isEnabled = true' core/assets/defaultConfig.yaml
RUN yq eval -i '.config.defaultStorage = "sessionStorage"' core/assets/defaultConfig.yaml

EXPOSE 3001
ENV NODE_ENV=production ADDRESS=0.0.0.0 IS_DOCKER=true
Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ release: build-image push-image
release-local: build-image-local push-image-local build-image-kyma-dashboard push-image-kyma-dashboard

build-image:
sed -i '/version/c\ \"version\" : \"$(TAG)\"' core/src/assets/version.json
sed -i 's/version: dev/version: ${TAG}/' core/src/assets/version.yaml
docker build -t $(IMG_NAME) -f Dockerfile .

build-image-local:
sed -i '/version/c\ \"version\" : \"$(TAG)\"' core/src/assets/version.json
sed -i 's/version: dev/version: ${TAG}/' core/src/assets/version.yaml
docker build -t $(LOCAL_IMG_NAME) -f Dockerfile.local .

build-image-kyma-dashboard:
Expand Down
1 change: 0 additions & 1 deletion backend/config/config.json

This file was deleted.

File renamed without changes.
7 changes: 4 additions & 3 deletions backend/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,19 @@ const merge = require('lodash.merge');

import { makeHandleRequest, serveStaticApp, serveMonaco } from './common';
import { handleTracking } from './tracking.js';
import jsyaml from 'js-yaml';
//import { requestLogger } from './utils/other'; //uncomment this to log the outgoing traffic
const { setupJWTCheck } = require('./jwtCheck');

global.config = {};

try {
// config from the copnfiguration file
const defaultConfig = JSON.parse(
fs.readFileSync('./settings/defaultConfig.json'),
const defaultConfig = jsyaml.load(
fs.readFileSync('./settings/defaultConfig.yaml'),
);
// config retrieved from busola's config map
const configFromMap = JSON.parse(fs.readFileSync('./config/config.json'));
const configFromMap = jsyaml.load(fs.readFileSync('./config/config.yaml'));

global.config = merge(defaultConfig, configFromMap).config;
} catch (e) {
Expand Down
30 changes: 30 additions & 0 deletions backend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"express-jwt": "^6.1.1",
"https": "^1.0.0",
"jose": "^2.0.6",
"js-yaml": "^4.1.0",
"jwks-rsa": "^2.0.5",
"lodash.merge": "^4.6.2",
"pino-http": "^5.7.0",
Expand Down
19 changes: 0 additions & 19 deletions backend/settings/defaultConfig.json

This file was deleted.

11 changes: 11 additions & 0 deletions backend/settings/defaultConfig.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
config:
features:
JWT_CHECK_CONFIG:
isEnabled: false
config:
issuer: https://apskyxzcl.accounts400.ondemand.com
jwksUri: https://apskyxzcl.accounts400.ondemand.com/oauth2/certs
GZIP:
isEnabled: true
TRACKING:
isEnabled: false
1 change: 1 addition & 0 deletions core/src/assets/config/config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
94 changes: 0 additions & 94 deletions core/src/assets/defaultConfig.json

This file was deleted.

63 changes: 63 additions & 0 deletions core/src/assets/defaultConfig.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
config:
defaultStorage: localStorage
features:
LEGAL_LINKS:
config:
legal-disclosure:
default: https://www.sap.com/corporate/en/legal/impressum.html
de: https://www.sap.com/corporate/de/legal/impressum.html
privacy:
default: https://help.sap.com/viewer/82bdf2271c6041f79387c122147cf774/Cloud/en-US
copyright:
default: https://www.sap.com/corporate/en/legal/copyright.html
de: https://www.sap.com/corporate/de/legal/copyright.html
trademark:
default: https://www.sap.com/corporate/en/legal/trademark.html
de: https://www.sap.com/corporate/de/legal/trademark.html
SSO_LOGIN:
isEnabled: false
config:
issuerUrl: https://apskyxzcl.accounts400.ondemand.com
scope: openid
clientId: d0316c58-b0fe-45cd-9960-0fea0708355a
KUBECONFIG_ID:
isEnabled: true
config:
kubeconfigUrl: /kubeconfig
SENTRY:
isEnabled: true
selectors: []
config:
dsn: ''
OBSERVABILITY:
isEnabled: false
config:
links:
- label: Grafana
path: apis/networking.istio.io/v1beta1/namespaces/kyma-system/virtualservices/monitoring-grafana
- label: Kiali
path: apis/networking.istio.io/v1beta1/namespaces/kyma-system/virtualservices/kiali
- label: Jaeger
path: apis/networking.istio.io/v1beta1/namespaces/kyma-system/virtualservices/tracing
HIDDEN_NAMESPACES:
isEnabled: true
config:
namespaces:
- compass-system
- istio-system
- knative-eventing
- knative-serving
- kube-system
- kyma-backup
- kyma-installer
- kyma-integration
- kyma-system
- natss
- kube-node-lease
- serverless-system
VISUAL_RESOURCES:
isEnabled: true
EXTENSIBILITY:
isEnabled: false
TRACKING:
isEnabled: false
3 changes: 0 additions & 3 deletions core/src/assets/version.json

This file was deleted.

1 change: 1 addition & 0 deletions core/src/assets/version.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
version: dev
9 changes: 5 additions & 4 deletions core/src/luigi-config/busola-cluster-params.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { merge } from 'lodash';
import { convertStaticFeatures } from './feature-discovery';
import jsyaml from 'js-yaml';

let params = null;

Expand All @@ -8,14 +9,14 @@ export async function getBusolaClusterParams() {
try {
const cacheBuster = '?cache-buster=' + Date.now();
const defaultConfigResponse = await fetch(
'/assets/defaultConfig.json' + cacheBuster,
'/assets/defaultConfig.yaml' + cacheBuster,
);
const configMapResponse = await fetch(
'/assets/config/config.json' + cacheBuster,
'/assets/config/config.yaml' + cacheBuster,
);

const defaultParams = await defaultConfigResponse.json();
const mapParams = await configMapResponse.json();
const defaultParams = jsyaml.load(await defaultConfigResponse.text());
const mapParams = jsyaml.load(await configMapResponse.text());

if (defaultParams.config?.features)
defaultParams.config.features = convertStaticFeatures(
Expand Down
7 changes: 4 additions & 3 deletions core/src/luigi-config/nav-footer.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import i18next from 'i18next';
import jsyaml from 'js-yaml';
import { getBusolaClusterParams } from './busola-cluster-params';

function elementReady(selector) {
Expand Down Expand Up @@ -42,9 +43,9 @@ export async function setNavFooterText() {
}

async function getBusolaVersion() {
return await fetch('/assets/version.json')
.then(response => response.json())
.then(json => json.version)
return await fetch('/assets/version.yaml')
.then(response => response.text())
.then(text => jsyaml.load(text).version)
.catch(() => 'unknown');
}

Expand Down
Loading

0 comments on commit f7597c7

Please sign in to comment.