Skip to content

Commit

Permalink
[APM] Ensure APM deprecation documentationUrl point to correct doc br…
Browse files Browse the repository at this point in the history
…anch (elastic#115401) (elastic#115482)

* using branch in the url

* fixing TS

Co-authored-by: Cauê Marcondes <[email protected]>
  • Loading branch information
kibanamachine and cauemarcondes authored Oct 19, 2021
1 parent b4f1db4 commit 635859f
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
5 changes: 4 additions & 1 deletion x-pack/plugins/apm/server/deprecations/deprecations.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const deprecationContext = {
describe('getDeprecations', () => {
describe('when fleet is disabled', () => {
it('returns no deprecations', async () => {
const deprecationsCallback = getDeprecations({});
const deprecationsCallback = getDeprecations({ branch: 'master' });
const deprecations = await deprecationsCallback(deprecationContext);
expect(deprecations).toEqual([]);
});
Expand All @@ -28,6 +28,7 @@ describe('getDeprecations', () => {
describe('when running on cloud with legacy apm-server', () => {
it('returns deprecations', async () => {
const deprecationsCallback = getDeprecations({
branch: 'master',
cloudSetup: { isCloudEnabled: true } as unknown as CloudSetup,
fleet: {
start: () => ({
Expand All @@ -43,6 +44,7 @@ describe('getDeprecations', () => {
describe('when running on cloud with fleet', () => {
it('returns no deprecations', async () => {
const deprecationsCallback = getDeprecations({
branch: 'master',
cloudSetup: { isCloudEnabled: true } as unknown as CloudSetup,
fleet: {
start: () => ({
Expand All @@ -58,6 +60,7 @@ describe('getDeprecations', () => {
describe('when running on prem', () => {
it('returns no deprecations', async () => {
const deprecationsCallback = getDeprecations({
branch: 'master',
cloudSetup: { isCloudEnabled: false } as unknown as CloudSetup,
fleet: {
start: () => ({ agentPolicyService: { get: () => undefined } }),
Expand Down
5 changes: 3 additions & 2 deletions x-pack/plugins/apm/server/deprecations/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,11 @@ import { APMRouteHandlerResources } from '../';
export function getDeprecations({
cloudSetup,
fleet,
branch,
}: {
cloudSetup?: CloudSetup;
fleet?: APMRouteHandlerResources['plugins']['fleet'];
branch: string;
}) {
return async ({
savedObjectsClient,
Expand Down Expand Up @@ -46,8 +48,7 @@ export function getDeprecations({
defaultMessage:
'Running the APM Server binary directly is considered a legacy option and is deprecated since 7.16. Switch to APM Server managed by an Elastic Agent instead. Read our documentation to learn more.',
}),
documentationUrl:
'https://www.elastic.co/guide/en/apm/server/current/apm-integration.html',
documentationUrl: `https://www.elastic.co/guide/en/apm/server/${branch}/apm-integration.html`,
level: 'warning',
correctiveActions: {
manualSteps: [
Expand Down
2 changes: 2 additions & 0 deletions x-pack/plugins/apm/server/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -215,10 +215,12 @@ export class APMPlugin
);
})();
});

core.deprecations.registerDeprecations({
getDeprecations: getDeprecations({
cloudSetup: plugins.cloud,
fleet: resourcePlugins.fleet,
branch: this.initContext.env.packageInfo.branch,
}),
});

Expand Down

0 comments on commit 635859f

Please sign in to comment.