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

[7.x] [ML] Fix check for watcher being enabled (#43025) #43036

Merged
merged 1 commit into from
Aug 9, 2019
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,21 @@

import expect from '@kbn/expect';
import { xpackInfo } from '../../../../xpack_main/public/services/xpack_info';
import { LICENSE_STATUS_VALID } from '../../../../../common/constants/license_status';
import {
xpackFeatureAvailable,
} from '../check_license';

const initialInfo = {
features: {
watcher: {
isAvailable: true
status: LICENSE_STATUS_VALID
}
}
};

describe('ML - check license', () => {
describe('xpackFeatureProvider', () => {
describe('xpackFeatureAvailable', () => {
beforeEach(() => {
xpackInfo.setAll(initialInfo);
});
Expand Down
15 changes: 14 additions & 1 deletion x-pack/legacy/plugins/ml/public/license/check_license.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import React from 'react';
import { xpackInfo } from '../../../xpack_main/public/services/xpack_info';
import { banners, addAppRedirectMessageToUrl } from 'ui/notify';
import { LICENSE_TYPE } from '../../common/constants/license';
import { LICENSE_STATUS_VALID } from '../../../../common/constants/license_status';

import chrome from 'ui/chrome';
import { EuiCallOut } from '@elastic/eui';
Expand Down Expand Up @@ -119,5 +120,17 @@ export function isFullLicense() {
}

export function xpackFeatureAvailable(feature) {
return xpackInfo.get(`features.${feature}.isAvailable`, false);
// each plugin can register their own set of features.
// so we need specific checks for each one.
// this list can grow if we need to check other plugin's features.
switch (feature) {
case 'watcher':
// watcher only has a license status feature
// if watcher is disabled in kibana.yml, the feature is completely missing from xpackInfo
return xpackInfo.get(`features.${feature}.status`, false) === LICENSE_STATUS_VALID;
default:
// historically plugins have used `isAvailable` as a catch all for
// license and feature enabled checks
return xpackInfo.get(`features.${feature}.isAvailable`, false);
}
}