Skip to content

Commit

Permalink
[APM] Make fleet plugin dependency optional (elastic#104967)
Browse files Browse the repository at this point in the history
* fixing tutorial when fleet plugin is disabled

* addressing PR comments
  • Loading branch information
cauemarcondes authored Jul 9, 2021
1 parent 5b207d8 commit d2ce8d5
Show file tree
Hide file tree
Showing 12 changed files with 384 additions and 149 deletions.
11 changes: 7 additions & 4 deletions x-pack/plugins/apm/kibana.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
"data",
"embeddable",
"features",
"fleet",
"infra",
"licensing",
"observability",
Expand All @@ -24,11 +23,15 @@
"security",
"spaces",
"taskManager",
"usageCollection"
"usageCollection",
"fleet"
],
"server": true,
"ui": true,
"configPath": ["xpack", "apm"],
"configPath": [
"xpack",
"apm"
],
"requiredBundles": [
"fleet",
"home",
Expand All @@ -38,4 +41,4 @@
"ml",
"observability"
]
}
}
33 changes: 17 additions & 16 deletions x-pack/plugins/apm/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ export interface ApmPluginStartDeps {
ml?: MlPluginStart;
triggersActionsUi: TriggersAndActionsUIPublicPluginStart;
observability: ObservabilityPublicStart;
fleet: FleetStart;
fleet?: FleetStart;
}

export class ApmPlugin implements Plugin<ApmPluginSetup, ApmPluginStart> {
Expand Down Expand Up @@ -311,20 +311,21 @@ export class ApmPlugin implements Plugin<ApmPluginSetup, ApmPluginStart> {
}
public start(core: CoreStart, plugins: ApmPluginStartDeps) {
const { fleet } = plugins;

const agentEnrollmentExtensionData = getApmEnrollmentFlyoutData();

fleet.registerExtension({
package: 'apm',
view: 'agent-enrollment-flyout',
title: agentEnrollmentExtensionData.title,
Component: agentEnrollmentExtensionData.Component,
});

fleet.registerExtension({
package: 'apm',
view: 'package-detail-assets',
Component: LazyApmCustomAssetsExtension,
});
if (fleet) {
const agentEnrollmentExtensionData = getApmEnrollmentFlyoutData();

fleet.registerExtension({
package: 'apm',
view: 'agent-enrollment-flyout',
title: agentEnrollmentExtensionData.title,
Component: agentEnrollmentExtensionData.Component,
});

fleet.registerExtension({
package: 'apm',
view: 'package-detail-assets',
Component: LazyApmCustomAssetsExtension,
});
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ interface Args {
onPrem: boolean;
hasFleetPoliciesWithApmIntegration: boolean;
hasCloudPolicyWithApmIntegration: boolean;
isFleetEnabled: boolean;
}

const policyElasticAgentOnCloudAgent: APIResponseType['fleetAgents'][0] = {
Expand Down Expand Up @@ -47,6 +48,7 @@ function Wrapper({
apmAgent,
onPrem,
hasCloudPolicyWithApmIntegration,
isFleetEnabled,
}: Args) {
const http = ({
get: () => ({
Expand All @@ -56,6 +58,7 @@ function Wrapper({
? [policyElasticAgentOnCloudAgent]
: []),
],
isFleetEnabled,
cloudStandaloneSetup: {
apmServerUrl: 'cloud_url',
secretToken: 'foo',
Expand All @@ -80,6 +83,7 @@ Integration.args = {
onPrem: true,
hasFleetPoliciesWithApmIntegration: false,
hasCloudPolicyWithApmIntegration: false,
isFleetEnabled: true,
};

export default {
Expand Down Expand Up @@ -113,5 +117,8 @@ export default {
hasCloudPolicyWithApmIntegration: {
control: { type: 'boolean', options: [true, false] },
},
isFleetEnabled: {
control: { type: 'boolean', options: [true, false], defaultValue: true },
},
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ describe('getPolicyOptions', () => {
apmServerUrl: 'cloud_url',
secretToken: 'cloud_token',
},
isFleetEnabled: true,
};
const options = getPolicyOptions({
isCloudEnabled: true,
Expand All @@ -65,6 +66,7 @@ describe('getPolicyOptions', () => {
apmServerUrl: 'cloud_url',
secretToken: 'cloud_token',
},
isFleetEnabled: true,
};
const options = getPolicyOptions({
isCloudEnabled: true,
Expand Down Expand Up @@ -109,6 +111,7 @@ describe('getPolicyOptions', () => {
apmServerUrl: 'cloud_url',
secretToken: 'cloud_token',
},
isFleetEnabled: true,
};
const options = getPolicyOptions({
isCloudEnabled: true,
Expand Down Expand Up @@ -151,6 +154,7 @@ describe('getPolicyOptions', () => {
const data: APIResponseType = {
fleetAgents: [],
cloudStandaloneSetup: undefined,
isFleetEnabled: true,
};
const options = getPolicyOptions({
isCloudEnabled: true,
Expand All @@ -173,6 +177,7 @@ describe('getPolicyOptions', () => {
const data: APIResponseType = {
fleetAgents,
cloudStandaloneSetup: undefined,
isFleetEnabled: true,
};
const options = getPolicyOptions({
isCloudEnabled: true,
Expand Down Expand Up @@ -213,6 +218,7 @@ describe('getPolicyOptions', () => {
const data: APIResponseType = {
fleetAgents: [policyElasticAgentOnCloudAgent, ...fleetAgents],
cloudStandaloneSetup: undefined,
isFleetEnabled: true,
};
const options = getPolicyOptions({
isCloudEnabled: true,
Expand Down Expand Up @@ -256,6 +262,7 @@ describe('getPolicyOptions', () => {
const data: APIResponseType = {
fleetAgents: [],
cloudStandaloneSetup: undefined,
isFleetEnabled: true,
};
const options = getPolicyOptions({
isCloudEnabled: false,
Expand All @@ -278,6 +285,7 @@ describe('getPolicyOptions', () => {
const data: APIResponseType = {
fleetAgents,
cloudStandaloneSetup: undefined,
isFleetEnabled: true,
};
const options = getPolicyOptions({
isCloudEnabled: false,
Expand Down
Loading

0 comments on commit d2ce8d5

Please sign in to comment.