Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Blocked] Query-Service config and runtime configuration of URL path-prefix #151

Closed
wants to merge 7 commits into from
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
21 changes: 11 additions & 10 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -47,16 +47,17 @@
}],

/* import */
"import/prefer-default-export": 1,
"import/no-named-default": 0,
"import/extensions": 0,

"new-cap": [2, {
"capIsNewExceptions": [
"Immutable.Map",
"Immutable.List",
"Immutable.Set"
]
}]
"import/no-extraneous-dependencies": [
"error",
{
"devDependencies": [
"**/*.test.js",
"*.js"
]
}
],
"import/no-named-default": 0,
"import/prefer-default-export": 1
}
}
6 changes: 1 addition & 5 deletions config-overrides.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,13 @@
// See the License for the specific language governing permissions and
// limitations under the License.

/* eslint-disable import/no-extraneous-dependencies */

const fs = require('fs');
const { injectBabelPlugin } = require('react-app-rewired');
const rewireLess = require('react-app-rewire-less');
const lessToJs = require('less-vars-to-js');

// Read the less file in as string
// convert the Ant Design var overrides to JS
const loadedVarOverrides = fs.readFileSync('config-overrides-ant-variables.less', 'utf8');

// Pass in file contents
const modifyVars = lessToJs(loadedVarOverrides);

module.exports = function override(_config, env) {
Expand Down
21 changes: 15 additions & 6 deletions public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,22 @@
<script>
// Jaeger UI config data is embedded by the query-service. This is
// later merged with defaults into the redux `state.config` via
// src/utils/config/get-config.js. The default provided by the query
// service should be an empty object or it can leave `DEFAULT_CONFIG`
// unchanged.
// src/utils/config#getUiConfig. The default provided by the query
// service should be an empty object or it can leave
// `__INJECTED_UI_CONFIG__` unchanged.
function getJaegerUiConfig() {
const DEFAULT_CONFIG = null;
const JAEGER_CONFIG = DEFAULT_CONFIG;
return JAEGER_CONFIG;
const __INJECTED_UI_CONFIG__ = null;
return __INJECTED_UI_CONFIG__;
}

// Query-service config data is embedded by the query-service. This is
// later merged with defaults into the redux `state.config.queryService`
// via src/utils/config#getQuerySvcConfig. The default provided by the
// query service should be an empty object or it can leave
// `__INJECTED_QS_CONFIG__` unchanged.
function getJaegerQuerySvcConfig() {
const __INJECTED_QS_CONFIG__ = null;
return __INJECTED_QS_CONFIG__;
}
</script>
</head>
Expand Down
3 changes: 2 additions & 1 deletion src/components/App/Page.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

import * as React from 'react';
import { Layout } from 'antd';
import _get from 'lodash/get';
import Helmet from 'react-helmet';
import { connect } from 'react-redux';
import type { Location } from 'react-router-dom';
Expand Down Expand Up @@ -54,7 +55,7 @@ export class PageImpl extends React.Component<PageProps> {

render() {
const { children, config, location } = this.props;
const menu = config && config.menu;
const menu = _get(config, 'ui.menu');
return (
<div>
<Helmet title="Jaeger UI" />
Expand Down
4 changes: 2 additions & 2 deletions src/components/App/TopNav.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import { Link } from 'react-router-dom';

import TraceIDSearchInput from './TraceIDSearchInput';
import type { ConfigMenuItem, ConfigMenuGroup } from '../../types/config';
import getConfig from '../../utils/config/get-config';
import { getUiConfig } from '../../utils/config';
import prefixUrl from '../../utils/prefix-url';

type TopNavProps = {
Expand All @@ -36,7 +36,7 @@ const NAV_LINKS = [
},
];

if (_get(getConfig(), 'dependencies.menuEnabled')) {
if (_get(getUiConfig(), 'dependencies.menuEnabled')) {
NAV_LINKS.push({
to: prefixUrl('/dependencies'),
text: 'Dependencies',
Expand Down
4 changes: 2 additions & 2 deletions src/components/DependencyGraph/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import * as jaegerApiActions from '../../actions/jaeger-api';
import { FALLBACK_DAG_MAX_NUM_SERVICES } from '../../constants';
import { nodesPropTypes, linksPropTypes } from '../../propTypes/dependencies';
import { formatDependenciesAsNodesAndLinks } from '../../selectors/dependencies';
import getConfig from '../../utils/config/get-config';
import { getUiConfig } from '../../utils/config';

import './index.css';

Expand All @@ -40,7 +40,7 @@ export const GRAPH_TYPES = {
};

const dagMaxNumServices =
_get(getConfig(), 'dependencies.dagMaxNumServices') || FALLBACK_DAG_MAX_NUM_SERVICES;
_get(getUiConfig(), 'dependencies.dagMaxNumServices') || FALLBACK_DAG_MAX_NUM_SERVICES;

export default class DependencyGraphPage extends Component {
static propTypes = {
Expand Down
21 changes: 21 additions & 0 deletions src/constants/default-query-svc-config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// Copyright (c) 2017 Uber Technologies, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

import deepFreeze from 'deep-freeze';

export default deepFreeze({
pathPrefix: null,
});

export const deprecations = [];
File renamed without changes.
7 changes: 5 additions & 2 deletions src/reducers/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,14 @@
// See the License for the specific language governing permissions and
// limitations under the License.

import getConfig from '../utils/config/get-config';
import { getQuerySvcConfig, getUiConfig } from '../utils/config';

export default function reduceConfig(state) {
if (state === undefined) {
return getConfig();
return {
queryService: getQuerySvcConfig(),
ui: getUiConfig(),
};
}
return state;
}
44 changes: 0 additions & 44 deletions src/utils/config/get-config.js

This file was deleted.

87 changes: 0 additions & 87 deletions src/utils/config/get-config.test.js

This file was deleted.

75 changes: 75 additions & 0 deletions src/utils/config/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
// @flow

// Copyright (c) 2017 Uber Technologies, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

import processDeprecation from './process-deprecation';
import defaultQuerySvcConfig, {
deprecations as querySvcDeprecations,
} from '../../constants/default-query-svc-config';
import defaultUiConfig, { deprecations as uiDeprecations } from '../../constants/default-ui-config';

const CONFIG_NAME_UI = 'UI';
const CONFIG_NAME_QS = 'query-service';

const haveWarnedFactoryFn = {
[CONFIG_NAME_UI]: false,
[CONFIG_NAME_QS]: false,
};

const haveWarnedDeprecations = {
[CONFIG_NAME_UI]: false,
[CONFIG_NAME_QS]: false,
};

function getConfig(name, factoryFn, defaults, deprecations) {
if (typeof factoryFn !== 'function') {
if (!haveWarnedFactoryFn[name]) {
// eslint-disable-next-line no-console
console.warn(`Embedded ${name} config is not available`);
haveWarnedFactoryFn[name] = true;
}
return { ...defaults };
}
const embedded = factoryFn();
// check for (and move) deprecated config values
if (embedded && Array.isArray(deprecations) && deprecations.length) {
deprecations.forEach(deprecation =>
processDeprecation(embedded, deprecation, !haveWarnedDeprecations[name])
);
haveWarnedDeprecations[name] = true;
}
return { ...defaults, ...embedded };
}

/**
* Merge the embedded query-service config from the query service (if present)
* with the default config from `../../constants/default-query-svc-config`.
*/
export function getQuerySvcConfig() {
return getConfig(
CONFIG_NAME_QS,
window.getJaegerQuerySvcConfig,
defaultQuerySvcConfig,
querySvcDeprecations
);
}

/**
* Merge the embedded UI config from the query service (if present) with the
* default config from `../../constants/default-ui-config`.
*/
export function getUiConfig() {
return getConfig(CONFIG_NAME_UI, window.getJaegerUiConfig, defaultUiConfig, uiDeprecations);
}
Loading