-
Notifications
You must be signed in to change notification settings - Fork 8.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add warnings for legacy 3rd party plugins
- Loading branch information
1 parent
60901b3
commit d585216
Showing
8 changed files
with
197 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
90 changes: 90 additions & 0 deletions
90
src/core/server/legacy/plugins/log_legacy_plugins_warning.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
/* | ||
* Licensed to Elasticsearch B.V. under one or more contributor | ||
* license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright | ||
* ownership. Elasticsearch B.V. licenses this file to you 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 { loggerMock } from '../../logging/logger.mock'; | ||
import { logLegacyThirdPartyPluginDeprecationWarning } from './log_legacy_plugins_warning'; | ||
import { LegacyPluginSpec } from '../types'; | ||
|
||
const createPluginSpec = ({ id, path }: { id: string; path: string }): LegacyPluginSpec => { | ||
return { | ||
getId: () => id, | ||
getExpectedKibanaVersion: () => 'kibana', | ||
getConfigPrefix: () => 'plugin.config', | ||
getDeprecationsProvider: () => undefined, | ||
getPack: () => ({ | ||
getPath: () => path, | ||
}), | ||
}; | ||
}; | ||
|
||
describe('logLegacyThirdPartyPluginDeprecationWarning', () => { | ||
let log: ReturnType<typeof loggerMock.create>; | ||
|
||
beforeEach(() => { | ||
log = loggerMock.create(); | ||
}); | ||
|
||
it('logs warning for third party plugins', () => { | ||
logLegacyThirdPartyPluginDeprecationWarning({ | ||
specs: [createPluginSpec({ id: 'plugin', path: '/some-external-path' })], | ||
log, | ||
}); | ||
expect(log.warn).toHaveBeenCalledTimes(1); | ||
expect(log.warn.mock.calls[0]).toMatchInlineSnapshot(` | ||
Array [ | ||
"Some installed third party plugin(s) [plugin] are using the legacy plugin format and will no longer work after version 8.0. Please refer to https://github.com/elastic/kibana/blob/master/docs/migration/migrate_8_0.asciidoc for a list of breaking changes and https://github.com/elastic/kibana/blob/master/src/core/MIGRATION.md for documentation on how to migrate legacy plugins.", | ||
] | ||
`); | ||
}); | ||
|
||
it('lists all the deprecated plugins and only log once', () => { | ||
logLegacyThirdPartyPluginDeprecationWarning({ | ||
specs: [ | ||
createPluginSpec({ id: 'pluginA', path: '/abs/path/to/pluginA' }), | ||
createPluginSpec({ id: 'pluginB', path: '/abs/path/to/pluginB' }), | ||
createPluginSpec({ id: 'pluginC', path: '/abs/path/to/pluginC' }), | ||
], | ||
log, | ||
}); | ||
expect(log.warn).toHaveBeenCalledTimes(1); | ||
expect(log.warn.mock.calls[0]).toMatchInlineSnapshot(` | ||
Array [ | ||
"Some installed third party plugin(s) [pluginA, pluginB, pluginC] are using the legacy plugin format and will no longer work after version 8.0. Please refer to https://github.com/elastic/kibana/blob/master/docs/migration/migrate_8_0.asciidoc for a list of breaking changes and https://github.com/elastic/kibana/blob/master/src/core/MIGRATION.md for documentation on how to migrate legacy plugins.", | ||
] | ||
`); | ||
}); | ||
|
||
it('does not log warning for internal legacy plugins', () => { | ||
logLegacyThirdPartyPluginDeprecationWarning({ | ||
specs: [ | ||
createPluginSpec({ | ||
id: 'plugin', | ||
path: '/absolute/path/to/kibana/src/legacy/core_plugins', | ||
}), | ||
createPluginSpec({ | ||
id: 'plugin', | ||
path: '/absolute/path/to/kibana/x-pack', | ||
}), | ||
], | ||
log, | ||
}); | ||
|
||
expect(log.warn).not.toHaveBeenCalled(); | ||
}); | ||
}); |
52 changes: 52 additions & 0 deletions
52
src/core/server/legacy/plugins/log_legacy_plugins_warning.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/* | ||
* Licensed to Elasticsearch B.V. under one or more contributor | ||
* license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright | ||
* ownership. Elasticsearch B.V. licenses this file to you 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 { Logger } from '../../logging'; | ||
import { LegacyPluginSpec } from '../types'; | ||
|
||
const internalPaths = ['/src/legacy/core_plugins', '/x-pack']; | ||
|
||
const breakingChangesUrl = | ||
'https://github.com/elastic/kibana/blob/master/docs/migration/migrate_8_0.asciidoc'; | ||
const migrationGuideUrl = 'https://github.com/elastic/kibana/blob/master/src/core/MIGRATION.md'; | ||
|
||
export const logLegacyThirdPartyPluginDeprecationWarning = ({ | ||
specs, | ||
log, | ||
}: { | ||
specs: LegacyPluginSpec[]; | ||
log: Logger; | ||
}) => { | ||
const thirdPartySpecs = specs.filter(isThirdPartyPluginSpec); | ||
if (thirdPartySpecs.length > 0) { | ||
const pluginIds = thirdPartySpecs.map(spec => spec.getId()); | ||
log.warn( | ||
`Some installed third party plugin(s) [${pluginIds.join( | ||
', ' | ||
)}] are using the legacy plugin format and will no longer work after version 8.0. ` + | ||
`Please refer to ${breakingChangesUrl} for a list of breaking changes ` + | ||
`and ${migrationGuideUrl} for documentation on how to migrate legacy plugins.` | ||
); | ||
} | ||
}; | ||
|
||
const isThirdPartyPluginSpec = (spec: LegacyPluginSpec): boolean => { | ||
const pluginPath = spec.getPack().getPath(); | ||
return !internalPaths.some(internalPath => pluginPath.indexOf(internalPath) > -1); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters