From 73c7f87acd51d2def50e99a51510ef1c7d6f75c1 Mon Sep 17 00:00:00 2001 From: Jen Huang Date: Sun, 9 Feb 2025 00:20:00 -0800 Subject: [PATCH] [UII] Update install snippets to include all platforms (#210249) ## Summary Resolves [#167592](https://github.com/elastic/kibana/issues/167592). This PR expands Fleet's enrollment/install snippets so that all platforms & architectures are available: **Fleet server instructions** ![image](https://github.com/user-attachments/assets/85db0e78-4100-42e7-9298-5645e1100145) **Managed agent instructions** ![image](https://github.com/user-attachments/assets/82a41273-331c-4655-9984-f48c01a82d82) **Standalone agent instructions** (with policy that includes K8, so K8 yml and platform is selected by default) ![image](https://github.com/user-attachments/assets/5e7ddfb1-9f34-418a-9077-addee703ed71) ### Checklist Check the PR satisfies following conditions. Reviewers should verify this PR satisfies this list as well. - [x] Any text added follows [EUI's writing guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses sentence case text and includes [i18n support](https://github.com/elastic/kibana/blob/main/src/platform/packages/shared/kbn-i18n/README.md) - [x] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios - [x] The PR description includes the appropriate Release Notes section, and the correct `release_note:*` label is applied per the [guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process) --- .../translations/translations/fr-FR.json | 2 - .../translations/translations/ja-JP.json | 2 - .../translations/translations/zh-CN.json | 2 - .../fleet/cypress/e2e/agent_policy.cy.ts | 1 + .../shared/fleet/cypress/screens/fleet.ts | 1 + .../steps/install_fleet_server.tsx | 54 +- .../utils/install_command_utils.test.ts | 1058 +++++++++++++---- .../utils/install_command_utils.ts | 46 +- .../installation_message.tsx | 2 +- .../install_section.tsx | 7 +- .../enrollment_instructions/manual/index.tsx | 38 +- .../standalone/index.tsx | 36 +- .../public/components/platform_selector.tsx | 148 ++- .../fleet/public/hooks/use_platform.tsx | 92 +- 14 files changed, 1075 insertions(+), 414 deletions(-) diff --git a/x-pack/platform/plugins/private/translations/translations/fr-FR.json b/x-pack/platform/plugins/private/translations/translations/fr-FR.json index 3602bed972a40..4cb41aacb995b 100644 --- a/x-pack/platform/plugins/private/translations/translations/fr-FR.json +++ b/x-pack/platform/plugins/private/translations/translations/fr-FR.json @@ -18383,14 +18383,12 @@ "xpack.fleet.enrollmentInstructions.k8sInstallationMessage": "Le manifeste ci-dessous a été généré automatiquement. Il inclut les informations d'identification de cette instance de l'agent Elastic qui doivent être gérées de façon centrale avec Fleet dès son exécution dans votre cluster Kubernetes.", "xpack.fleet.enrollmentInstructions.macCallout": "Nous déconseillons de déployer cette intégration sous Mac, car elle est incompatible pour l’instant.", "xpack.fleet.enrollmentInstructions.placeHolderCallout": "Nous déconseillons fortement de déployer CSPM au sein d’un cluster Kubernetes. Cela peut entraîner une redondance dans la récupération des données, ce qui peut augmenter les coûts de consommation au sein de votre compte Elastic et potentiellement déclencher une restriction du taux d’API dans votre ou vos comptes cloud.", - "xpack.fleet.enrollmentInstructions.platformButtons.googleCloudShell": "Script Google Cloud Shell", "xpack.fleet.enrollmentInstructions.platformButtons.kubernetes": "Kubernetes", "xpack.fleet.enrollmentInstructions.platformButtons.linux": "Linux Tar", "xpack.fleet.enrollmentInstructions.platformButtons.linux.deb": "DEB", "xpack.fleet.enrollmentInstructions.platformButtons.linux.rpm": "RPM", "xpack.fleet.enrollmentInstructions.platformButtons.mac": "Mac", "xpack.fleet.enrollmentInstructions.platformButtons.windows": "Windows", - "xpack.fleet.enrollmentInstructions.platformSelectAriaLabel": "Plateforme", "xpack.fleet.enrollmentInstructions.troubleshootingLink": "guide de résolution des problèmes", "xpack.fleet.enrollmentInstructions.troubleshootingText": "Si vous rencontrez des difficultés pour vous connecter, consultez notre {link}.", "xpack.fleet.enrollmentStepAgentPolicy.addPolicyButton": "Créer une stratégie d'agent", diff --git a/x-pack/platform/plugins/private/translations/translations/ja-JP.json b/x-pack/platform/plugins/private/translations/translations/ja-JP.json index dcf2ce786f0d4..4a7eb89cac7f1 100644 --- a/x-pack/platform/plugins/private/translations/translations/ja-JP.json +++ b/x-pack/platform/plugins/private/translations/translations/ja-JP.json @@ -18243,14 +18243,12 @@ "xpack.fleet.enrollmentInstructions.k8sInstallationMessage": "次のマニフェストは自動的に生成されました。また、マニフェストには、このElasticエージェントのインスタンスが、Kubernetesで実行された後に、Fleetを使用して一元的に管理するための資格情報が含まれています。", "xpack.fleet.enrollmentInstructions.macCallout": "この統合は現在サポートされていないため、Macにデプロイしないことをお勧めします。", "xpack.fleet.enrollmentInstructions.placeHolderCallout": "Kubernetesクラスター内にCSPMをデプロイしないことを強くお勧めします。そのようにすると、冗長なデータ取得が発生し、Elasticアカウントの消費コストが増加したり、クラウドアカウントのAPIレート制限を引き起こしたりする可能性があります。", - "xpack.fleet.enrollmentInstructions.platformButtons.googleCloudShell": "Google Cloud Shell Script", "xpack.fleet.enrollmentInstructions.platformButtons.kubernetes": "Kubernetes", "xpack.fleet.enrollmentInstructions.platformButtons.linux": "Linux Tar", "xpack.fleet.enrollmentInstructions.platformButtons.linux.deb": "DEB", "xpack.fleet.enrollmentInstructions.platformButtons.linux.rpm": "1分あたりリクエスト数", "xpack.fleet.enrollmentInstructions.platformButtons.mac": "Mac", "xpack.fleet.enrollmentInstructions.platformButtons.windows": "Windows", - "xpack.fleet.enrollmentInstructions.platformSelectAriaLabel": "プラットフォーム", "xpack.fleet.enrollmentInstructions.troubleshootingLink": "トラブルシューティングガイド", "xpack.fleet.enrollmentInstructions.troubleshootingText": "接続の問題が発生している場合は、{link}を参照してください。", "xpack.fleet.enrollmentStepAgentPolicy.addPolicyButton": "新しいエージェントポリシーの作成", diff --git a/x-pack/platform/plugins/private/translations/translations/zh-CN.json b/x-pack/platform/plugins/private/translations/translations/zh-CN.json index 4522fc3857570..a600876bcd5cd 100644 --- a/x-pack/platform/plugins/private/translations/translations/zh-CN.json +++ b/x-pack/platform/plugins/private/translations/translations/zh-CN.json @@ -17951,14 +17951,12 @@ "xpack.fleet.enrollmentInstructions.k8sInstallationMessage": "已自动生成以下清单,并在其中包括此 Elastic 代理实例的凭据,一旦该实例在您的 Kubernetes 集群中运行,将使用 Fleet 对其进行集中管理。", "xpack.fleet.enrollmentInstructions.macCallout": "我们建议不要在 Mac 中部署此集成,因为当前尚不支持该集成。", "xpack.fleet.enrollmentInstructions.placeHolderCallout": "我们强烈建议不要在 Kubernetes 集群中部署 CSPM。那样做可能导致冗余数据提取,这会造成 Elastic 帐户内的消耗成本增加,并有可能在您的云帐户中触发 API 速率限制。", - "xpack.fleet.enrollmentInstructions.platformButtons.googleCloudShell": "Google Cloud Shell 脚本", "xpack.fleet.enrollmentInstructions.platformButtons.kubernetes": "Kubernetes", "xpack.fleet.enrollmentInstructions.platformButtons.linux": "Linux Tar", "xpack.fleet.enrollmentInstructions.platformButtons.linux.deb": "DEB", "xpack.fleet.enrollmentInstructions.platformButtons.linux.rpm": "RPM", "xpack.fleet.enrollmentInstructions.platformButtons.mac": "Mac", "xpack.fleet.enrollmentInstructions.platformButtons.windows": "Windows", - "xpack.fleet.enrollmentInstructions.platformSelectAriaLabel": "平台", "xpack.fleet.enrollmentInstructions.troubleshootingLink": "故障排除指南", "xpack.fleet.enrollmentInstructions.troubleshootingText": "如果有连接问题,请参阅我们的{link}。", "xpack.fleet.enrollmentStepAgentPolicy.addPolicyButton": "创建新代理策略", diff --git a/x-pack/platform/plugins/shared/fleet/cypress/e2e/agent_policy.cy.ts b/x-pack/platform/plugins/shared/fleet/cypress/e2e/agent_policy.cy.ts index 6422f3307e93d..a193ab3ee80e0 100644 --- a/x-pack/platform/plugins/shared/fleet/cypress/e2e/agent_policy.cy.ts +++ b/x-pack/platform/plugins/shared/fleet/cypress/e2e/agent_policy.cy.ts @@ -139,6 +139,7 @@ describe('Edit agent policy', () => { visit('/app/fleet/policies/policy-1'); cy.getBySel(AGENT_POLICY_DETAILS_PAGE.ADD_AGENT_LINK).click(); + cy.getBySel(AGENT_FLYOUT.PLATFORM_SELECTOR_EXTENDED).click(); cy.getBySel(AGENT_FLYOUT.KUBERNETES_PLATFORM_TYPE).click(); cy.contains('https://xxx.yyy.zzz:443'); cy.contains('this-is-the-api-key'); diff --git a/x-pack/platform/plugins/shared/fleet/cypress/screens/fleet.ts b/x-pack/platform/plugins/shared/fleet/cypress/screens/fleet.ts index 0bd449652a800..10cd96f3949c8 100644 --- a/x-pack/platform/plugins/shared/fleet/cypress/screens/fleet.ts +++ b/x-pack/platform/plugins/shared/fleet/cypress/screens/fleet.ts @@ -91,6 +91,7 @@ export const AGENT_FLYOUT = { MANAGED_TAB: 'managedTab', CONFIRM_AGENT_ENROLLMENT_BUTTON: 'ConfirmAgentEnrollmentButton', INCOMING_DATA_CONFIRMED_CALL_OUT: 'IncomingDataConfirmedCallOut', + PLATFORM_SELECTOR_EXTENDED: 'platformSelectorExtended', KUBERNETES_PLATFORM_TYPE: 'platformTypeKubernetes', }; diff --git a/x-pack/platform/plugins/shared/fleet/public/applications/fleet/components/fleet_server_instructions/steps/install_fleet_server.tsx b/x-pack/platform/plugins/shared/fleet/public/applications/fleet/components/fleet_server_instructions/steps/install_fleet_server.tsx index a7631deb88b80..91afce50806ae 100644 --- a/x-pack/platform/plugins/shared/fleet/public/applications/fleet/components/fleet_server_instructions/steps/install_fleet_server.tsx +++ b/x-pack/platform/plugins/shared/fleet/public/applications/fleet/components/fleet_server_instructions/steps/install_fleet_server.tsx @@ -71,26 +71,35 @@ const InstallFleetServerStepContent: React.FunctionComponent<{ : null ); - const installCommands = (['linux', 'mac', 'windows', 'deb', 'rpm'] as PLATFORM_TYPE[]).reduce( - (acc, platform) => { - acc[platform] = getInstallCommandForPlatform({ - platform, - esOutputHost: esOutput?.hosts?.[0] ?? '', - esOutputProxy, - serviceToken: serviceToken ?? '', - policyId: fleetServerPolicyId, - fleetServerHost, - isProductionDeployment: deploymentMode === 'production', - sslCATrustedFingerprint: esOutput?.ca_trusted_fingerprint ?? undefined, - kibanaVersion, - downloadSource, - downloadSourceProxy, - }); + const installCommands = ( + [ + 'linux_aarch64', + 'linux_x86_64', + 'mac_aarch64', + 'mac_x86_64', + 'windows', + 'rpm_aarch64', + 'rpm_x86_64', + 'deb_aarch64', + 'deb_x86_64', + ] as PLATFORM_TYPE[] + ).reduce((acc, platform) => { + acc[platform] = getInstallCommandForPlatform({ + platform, + esOutputHost: esOutput?.hosts?.[0] ?? '', + esOutputProxy, + serviceToken: serviceToken ?? '', + policyId: fleetServerPolicyId, + fleetServerHost, + isProductionDeployment: deploymentMode === 'production', + sslCATrustedFingerprint: esOutput?.ca_trusted_fingerprint ?? undefined, + kibanaVersion, + downloadSource, + downloadSourceProxy, + }); - return acc; - }, - {} as Record - ); + return acc; + }, {} as Record); return ( <> @@ -114,12 +123,7 @@ const InstallFleetServerStepContent: React.FunctionComponent<{ { describe('without policy id', () => { it('should return the correct command if the the policyId is not set for linux', () => { - const res = getInstallCommandForPlatform({ - platform: 'linux', - esOutputHost: 'http://elasticsearch:9200', - serviceToken: 'service-token-1', - }); + expect( + getInstallCommandForPlatform({ + platform: 'linux_aarch64', + kibanaVersion: '9.0.0', + esOutputHost: 'http://elasticsearch:9200', + serviceToken: 'service-token-1', + }) + ).toMatchInlineSnapshot(` + "curl -L -O https://artifacts.elastic.co/downloads/beats/elastic-agent/elastic-agent-9.0.0-linux-arm64.tar.gz + tar xzvf elastic-agent-9.0.0-linux-arm64.tar.gz + cd elastic-agent-9.0.0-linux-arm64 + sudo ./elastic-agent install \\\\ + --fleet-server-es=http://elasticsearch:9200 \\\\ + --fleet-server-service-token=service-token-1 \\\\ + --fleet-server-port=8220" + `); - expect(res).toMatchInlineSnapshot(` - "curl -L -O https://artifacts.elastic.co/downloads/beats/elastic-agent/elastic-agent--linux-x86_64.tar.gz - tar xzvf elastic-agent--linux-x86_64.tar.gz - cd elastic-agent--linux-x86_64 + expect( + getInstallCommandForPlatform({ + platform: 'linux_x86_64', + kibanaVersion: '9.0.0', + esOutputHost: 'http://elasticsearch:9200', + serviceToken: 'service-token-1', + }) + ).toMatchInlineSnapshot(` + "curl -L -O https://artifacts.elastic.co/downloads/beats/elastic-agent/elastic-agent-9.0.0-linux-x86_64.tar.gz + tar xzvf elastic-agent-9.0.0-linux-x86_64.tar.gz + cd elastic-agent-9.0.0-linux-x86_64 sudo ./elastic-agent install \\\\ --fleet-server-es=http://elasticsearch:9200 \\\\ --fleet-server-service-token=service-token-1 \\\\ @@ -28,16 +46,34 @@ describe('getInstallCommandForPlatform', () => { }); it('should return the correct command if the the policyId is not set for mac', () => { - const res = getInstallCommandForPlatform({ - platform: 'mac', - esOutputHost: 'http://elasticsearch:9200', - serviceToken: 'service-token-1', - }); + expect( + getInstallCommandForPlatform({ + platform: 'mac_aarch64', + kibanaVersion: '9.0.0', + esOutputHost: 'http://elasticsearch:9200', + serviceToken: 'service-token-1', + }) + ).toMatchInlineSnapshot(` + "curl -L -O https://artifacts.elastic.co/downloads/beats/elastic-agent/elastic-agent-9.0.0-darwin-aarch64.tar.gz + tar xzvf elastic-agent-9.0.0-darwin-aarch64.tar.gz + cd elastic-agent-9.0.0-darwin-aarch64 + sudo ./elastic-agent install \\\\ + --fleet-server-es=http://elasticsearch:9200 \\\\ + --fleet-server-service-token=service-token-1 \\\\ + --fleet-server-port=8220" + `); - expect(res).toMatchInlineSnapshot(` - "curl -L -O https://artifacts.elastic.co/downloads/beats/elastic-agent/elastic-agent--darwin-aarch64.tar.gz - tar xzvf elastic-agent--darwin-aarch64.tar.gz - cd elastic-agent--darwin-aarch64 + expect( + getInstallCommandForPlatform({ + platform: 'mac_x86_64', + kibanaVersion: '9.0.0', + esOutputHost: 'http://elasticsearch:9200', + serviceToken: 'service-token-1', + }) + ).toMatchInlineSnapshot(` + "curl -L -O https://artifacts.elastic.co/downloads/beats/elastic-agent/elastic-agent-9.0.0-darwin-x86_64.tar.gz + tar xzvf elastic-agent-9.0.0-darwin-x86_64.tar.gz + cd elastic-agent-9.0.0-darwin-x86_64 sudo ./elastic-agent install \\\\ --fleet-server-es=http://elasticsearch:9200 \\\\ --fleet-server-service-token=service-token-1 \\\\ @@ -65,15 +101,34 @@ describe('getInstallCommandForPlatform', () => { }); it('should return the correct command if the the policyId is not set for rpm', () => { - const res = getInstallCommandForPlatform({ - platform: 'rpm', - esOutputHost: 'http://elasticsearch:9200', - serviceToken: 'service-token-1', - }); + expect( + getInstallCommandForPlatform({ + platform: 'rpm_aarch64', + kibanaVersion: '9.0.0', + esOutputHost: 'http://elasticsearch:9200', + serviceToken: 'service-token-1', + }) + ).toMatchInlineSnapshot(` + "curl -L -O https://artifacts.elastic.co/downloads/beats/elastic-agent/elastic-agent-9.0.0-aarch64.rpm + sudo rpm -vi elastic-agent-9.0.0-aarch64.rpm + sudo systemctl enable elastic-agent + sudo systemctl start elastic-agent + sudo elastic-agent enroll \\\\ + --fleet-server-es=http://elasticsearch:9200 \\\\ + --fleet-server-service-token=service-token-1 \\\\ + --fleet-server-port=8220" + `); - expect(res).toMatchInlineSnapshot(` - "curl -L -O https://artifacts.elastic.co/downloads/beats/elastic-agent/elastic-agent--x86_64.rpm - sudo rpm -vi elastic-agent--x86_64.rpm + expect( + getInstallCommandForPlatform({ + platform: 'rpm_x86_64', + kibanaVersion: '9.0.0', + esOutputHost: 'http://elasticsearch:9200', + serviceToken: 'service-token-1', + }) + ).toMatchInlineSnapshot(` + "curl -L -O https://artifacts.elastic.co/downloads/beats/elastic-agent/elastic-agent-9.0.0-x86_64.rpm + sudo rpm -vi elastic-agent-9.0.0-x86_64.rpm sudo systemctl enable elastic-agent sudo systemctl start elastic-agent sudo elastic-agent enroll \\\\ @@ -84,15 +139,34 @@ describe('getInstallCommandForPlatform', () => { }); it('should return the correct command if the the policyId is not set for deb', () => { - const res = getInstallCommandForPlatform({ - platform: 'deb', - esOutputHost: 'http://elasticsearch:9200', - serviceToken: 'service-token-1', - }); + expect( + getInstallCommandForPlatform({ + platform: 'deb_aarch64', + kibanaVersion: '9.0.0', + esOutputHost: 'http://elasticsearch:9200', + serviceToken: 'service-token-1', + }) + ).toMatchInlineSnapshot(` + "curl -L -O https://artifacts.elastic.co/downloads/beats/elastic-agent/elastic-agent-9.0.0-arm64.deb + sudo dpkg -i elastic-agent-9.0.0-arm64.deb + sudo systemctl enable elastic-agent + sudo systemctl start elastic-agent + sudo elastic-agent enroll \\\\ + --fleet-server-es=http://elasticsearch:9200 \\\\ + --fleet-server-service-token=service-token-1 \\\\ + --fleet-server-port=8220" + `); - expect(res).toMatchInlineSnapshot(` - "curl -L -O https://artifacts.elastic.co/downloads/beats/elastic-agent/elastic-agent--amd64.deb - sudo dpkg -i elastic-agent--amd64.deb + expect( + getInstallCommandForPlatform({ + platform: 'deb_x86_64', + kibanaVersion: '9.0.0', + esOutputHost: 'http://elasticsearch:9200', + serviceToken: 'service-token-1', + }) + ).toMatchInlineSnapshot(` + "curl -L -O https://artifacts.elastic.co/downloads/beats/elastic-agent/elastic-agent-9.0.0-amd64.deb + sudo dpkg -i elastic-agent-9.0.0-amd64.deb sudo systemctl enable elastic-agent sudo systemctl start elastic-agent sudo elastic-agent enroll \\\\ @@ -104,7 +178,7 @@ describe('getInstallCommandForPlatform', () => { it('should return the correct command sslCATrustedFingerprint option is passed', () => { const res = getInstallCommandForPlatform({ - platform: 'linux', + platform: 'linux_x86_64', esOutputHost: 'http://elasticsearch:9200', serviceToken: 'service-token-1', sslCATrustedFingerprint: 'fingerprint123456', @@ -125,17 +199,37 @@ describe('getInstallCommandForPlatform', () => { describe('with policy id', () => { it('should return the correct command if the the policyId is set for linux', () => { - const res = getInstallCommandForPlatform({ - platform: 'linux', - esOutputHost: 'http://elasticsearch:9200', - serviceToken: 'service-token-1', - policyId: 'policy-1', - }); + expect( + getInstallCommandForPlatform({ + platform: 'linux_aarch64', + kibanaVersion: '9.0.0', + esOutputHost: 'http://elasticsearch:9200', + serviceToken: 'service-token-1', + policyId: 'policy-1', + }) + ).toMatchInlineSnapshot(` + "curl -L -O https://artifacts.elastic.co/downloads/beats/elastic-agent/elastic-agent-9.0.0-linux-arm64.tar.gz + tar xzvf elastic-agent-9.0.0-linux-arm64.tar.gz + cd elastic-agent-9.0.0-linux-arm64 + sudo ./elastic-agent install \\\\ + --fleet-server-es=http://elasticsearch:9200 \\\\ + --fleet-server-service-token=service-token-1 \\\\ + --fleet-server-policy=policy-1 \\\\ + --fleet-server-port=8220" + `); - expect(res).toMatchInlineSnapshot(` - "curl -L -O https://artifacts.elastic.co/downloads/beats/elastic-agent/elastic-agent--linux-x86_64.tar.gz - tar xzvf elastic-agent--linux-x86_64.tar.gz - cd elastic-agent--linux-x86_64 + expect( + getInstallCommandForPlatform({ + platform: 'linux_x86_64', + kibanaVersion: '9.0.0', + esOutputHost: 'http://elasticsearch:9200', + serviceToken: 'service-token-1', + policyId: 'policy-1', + }) + ).toMatchInlineSnapshot(` + "curl -L -O https://artifacts.elastic.co/downloads/beats/elastic-agent/elastic-agent-9.0.0-linux-x86_64.tar.gz + tar xzvf elastic-agent-9.0.0-linux-x86_64.tar.gz + cd elastic-agent-9.0.0-linux-x86_64 sudo ./elastic-agent install \\\\ --fleet-server-es=http://elasticsearch:9200 \\\\ --fleet-server-service-token=service-token-1 \\\\ @@ -145,17 +239,37 @@ describe('getInstallCommandForPlatform', () => { }); it('should return the correct command if the the policyId is set for mac', () => { - const res = getInstallCommandForPlatform({ - platform: 'mac', - esOutputHost: 'http://elasticsearch:9200', - serviceToken: 'service-token-1', - policyId: 'policy-1', - }); + expect( + getInstallCommandForPlatform({ + platform: 'mac_aarch64', + kibanaVersion: '9.0.0', + esOutputHost: 'http://elasticsearch:9200', + serviceToken: 'service-token-1', + policyId: 'policy-1', + }) + ).toMatchInlineSnapshot(` + "curl -L -O https://artifacts.elastic.co/downloads/beats/elastic-agent/elastic-agent-9.0.0-darwin-aarch64.tar.gz + tar xzvf elastic-agent-9.0.0-darwin-aarch64.tar.gz + cd elastic-agent-9.0.0-darwin-aarch64 + sudo ./elastic-agent install \\\\ + --fleet-server-es=http://elasticsearch:9200 \\\\ + --fleet-server-service-token=service-token-1 \\\\ + --fleet-server-policy=policy-1 \\\\ + --fleet-server-port=8220" + `); - expect(res).toMatchInlineSnapshot(` - "curl -L -O https://artifacts.elastic.co/downloads/beats/elastic-agent/elastic-agent--darwin-aarch64.tar.gz - tar xzvf elastic-agent--darwin-aarch64.tar.gz - cd elastic-agent--darwin-aarch64 + expect( + getInstallCommandForPlatform({ + platform: 'mac_x86_64', + kibanaVersion: '9.0.0', + esOutputHost: 'http://elasticsearch:9200', + serviceToken: 'service-token-1', + policyId: 'policy-1', + }) + ).toMatchInlineSnapshot(` + "curl -L -O https://artifacts.elastic.co/downloads/beats/elastic-agent/elastic-agent-9.0.0-darwin-x86_64.tar.gz + tar xzvf elastic-agent-9.0.0-darwin-x86_64.tar.gz + cd elastic-agent-9.0.0-darwin-x86_64 sudo ./elastic-agent install \\\\ --fleet-server-es=http://elasticsearch:9200 \\\\ --fleet-server-service-token=service-token-1 \\\\ @@ -186,16 +300,37 @@ describe('getInstallCommandForPlatform', () => { }); it('should return the correct command if the the policyId is set for rpm', () => { - const res = getInstallCommandForPlatform({ - platform: 'rpm', - esOutputHost: 'http://elasticsearch:9200', - serviceToken: 'service-token-1', - policyId: 'policy-1', - }); + expect( + getInstallCommandForPlatform({ + platform: 'rpm_aarch64', + kibanaVersion: '9.0.0', + esOutputHost: 'http://elasticsearch:9200', + serviceToken: 'service-token-1', + policyId: 'policy-1', + }) + ).toMatchInlineSnapshot(` + "curl -L -O https://artifacts.elastic.co/downloads/beats/elastic-agent/elastic-agent-9.0.0-aarch64.rpm + sudo rpm -vi elastic-agent-9.0.0-aarch64.rpm + sudo systemctl enable elastic-agent + sudo systemctl start elastic-agent + sudo elastic-agent enroll \\\\ + --fleet-server-es=http://elasticsearch:9200 \\\\ + --fleet-server-service-token=service-token-1 \\\\ + --fleet-server-policy=policy-1 \\\\ + --fleet-server-port=8220" + `); - expect(res).toMatchInlineSnapshot(` - "curl -L -O https://artifacts.elastic.co/downloads/beats/elastic-agent/elastic-agent--x86_64.rpm - sudo rpm -vi elastic-agent--x86_64.rpm + expect( + getInstallCommandForPlatform({ + platform: 'rpm_x86_64', + kibanaVersion: '9.0.0', + esOutputHost: 'http://elasticsearch:9200', + serviceToken: 'service-token-1', + policyId: 'policy-1', + }) + ).toMatchInlineSnapshot(` + "curl -L -O https://artifacts.elastic.co/downloads/beats/elastic-agent/elastic-agent-9.0.0-x86_64.rpm + sudo rpm -vi elastic-agent-9.0.0-x86_64.rpm sudo systemctl enable elastic-agent sudo systemctl start elastic-agent sudo elastic-agent enroll \\\\ @@ -207,16 +342,37 @@ describe('getInstallCommandForPlatform', () => { }); it('should return the correct command if the the policyId is set for deb', () => { - const res = getInstallCommandForPlatform({ - platform: 'deb', - esOutputHost: 'http://elasticsearch:9200', - serviceToken: 'service-token-1', - policyId: 'policy-1', - }); + expect( + getInstallCommandForPlatform({ + platform: 'deb_aarch64', + kibanaVersion: '9.0.0', + esOutputHost: 'http://elasticsearch:9200', + serviceToken: 'service-token-1', + policyId: 'policy-1', + }) + ).toMatchInlineSnapshot(` + "curl -L -O https://artifacts.elastic.co/downloads/beats/elastic-agent/elastic-agent-9.0.0-arm64.deb + sudo dpkg -i elastic-agent-9.0.0-arm64.deb + sudo systemctl enable elastic-agent + sudo systemctl start elastic-agent + sudo elastic-agent enroll \\\\ + --fleet-server-es=http://elasticsearch:9200 \\\\ + --fleet-server-service-token=service-token-1 \\\\ + --fleet-server-policy=policy-1 \\\\ + --fleet-server-port=8220" + `); - expect(res).toMatchInlineSnapshot(` - "curl -L -O https://artifacts.elastic.co/downloads/beats/elastic-agent/elastic-agent--amd64.deb - sudo dpkg -i elastic-agent--amd64.deb + expect( + getInstallCommandForPlatform({ + platform: 'deb_x86_64', + kibanaVersion: '9.0.0', + esOutputHost: 'http://elasticsearch:9200', + serviceToken: 'service-token-1', + policyId: 'policy-1', + }) + ).toMatchInlineSnapshot(` + "curl -L -O https://artifacts.elastic.co/downloads/beats/elastic-agent/elastic-agent-9.0.0-amd64.deb + sudo dpkg -i elastic-agent-9.0.0-amd64.deb sudo systemctl enable elastic-agent sudo systemctl start elastic-agent sudo elastic-agent enroll \\\\ @@ -231,7 +387,7 @@ describe('getInstallCommandForPlatform', () => { describe('with policy id and downloadSource', () => { it('should return the correct command if the the policyId is set for linux', () => { const res = getInstallCommandForPlatform({ - platform: 'linux', + platform: 'linux_x86_64', esOutputHost: 'http://elasticsearch:9200', serviceToken: 'service-token-1', policyId: 'policy-1', @@ -258,19 +414,45 @@ describe('getInstallCommandForPlatform', () => { describe('with policy id and fleet server host and production deployment', () => { it('should return the correct command if the the policyId is set for linux', () => { - const res = getInstallCommandForPlatform({ - platform: 'linux', - esOutputHost: 'http://elasticsearch:9200', - serviceToken: 'service-token-1', - policyId: 'policy-1', - fleetServerHost: 'http://fleetserver:8220', - isProductionDeployment: true, - }); + expect( + getInstallCommandForPlatform({ + platform: 'linux_aarch64', + kibanaVersion: '9.0.0', + esOutputHost: 'http://elasticsearch:9200', + serviceToken: 'service-token-1', + policyId: 'policy-1', + fleetServerHost: 'http://fleetserver:8220', + isProductionDeployment: true, + }) + ).toMatchInlineSnapshot(` + "curl -L -O https://artifacts.elastic.co/downloads/beats/elastic-agent/elastic-agent-9.0.0-linux-arm64.tar.gz + tar xzvf elastic-agent-9.0.0-linux-arm64.tar.gz + cd elastic-agent-9.0.0-linux-arm64 + sudo ./elastic-agent install --url=http://fleetserver:8220 \\\\ + --fleet-server-es=http://elasticsearch:9200 \\\\ + --fleet-server-service-token=service-token-1 \\\\ + --fleet-server-policy=policy-1 \\\\ + --certificate-authorities= \\\\ + --fleet-server-es-ca= \\\\ + --fleet-server-cert= \\\\ + --fleet-server-cert-key= \\\\ + --fleet-server-port=8220" + `); - expect(res).toMatchInlineSnapshot(` - "curl -L -O https://artifacts.elastic.co/downloads/beats/elastic-agent/elastic-agent--linux-x86_64.tar.gz - tar xzvf elastic-agent--linux-x86_64.tar.gz - cd elastic-agent--linux-x86_64 + expect( + getInstallCommandForPlatform({ + platform: 'linux_x86_64', + kibanaVersion: '9.0.0', + esOutputHost: 'http://elasticsearch:9200', + serviceToken: 'service-token-1', + policyId: 'policy-1', + fleetServerHost: 'http://fleetserver:8220', + isProductionDeployment: true, + }) + ).toMatchInlineSnapshot(` + "curl -L -O https://artifacts.elastic.co/downloads/beats/elastic-agent/elastic-agent-9.0.0-linux-x86_64.tar.gz + tar xzvf elastic-agent-9.0.0-linux-x86_64.tar.gz + cd elastic-agent-9.0.0-linux-x86_64 sudo ./elastic-agent install --url=http://fleetserver:8220 \\\\ --fleet-server-es=http://elasticsearch:9200 \\\\ --fleet-server-service-token=service-token-1 \\\\ @@ -284,19 +466,45 @@ describe('getInstallCommandForPlatform', () => { }); it('should return the correct command if the the policyId is set for mac', () => { - const res = getInstallCommandForPlatform({ - platform: 'mac', - esOutputHost: 'http://elasticsearch:9200', - serviceToken: 'service-token-1', - policyId: 'policy-1', - fleetServerHost: 'http://fleetserver:8220', - isProductionDeployment: true, - }); + expect( + getInstallCommandForPlatform({ + platform: 'mac_aarch64', + kibanaVersion: '9.0.0', + esOutputHost: 'http://elasticsearch:9200', + serviceToken: 'service-token-1', + policyId: 'policy-1', + fleetServerHost: 'http://fleetserver:8220', + isProductionDeployment: true, + }) + ).toMatchInlineSnapshot(` + "curl -L -O https://artifacts.elastic.co/downloads/beats/elastic-agent/elastic-agent-9.0.0-darwin-aarch64.tar.gz + tar xzvf elastic-agent-9.0.0-darwin-aarch64.tar.gz + cd elastic-agent-9.0.0-darwin-aarch64 + sudo ./elastic-agent install --url=http://fleetserver:8220 \\\\ + --fleet-server-es=http://elasticsearch:9200 \\\\ + --fleet-server-service-token=service-token-1 \\\\ + --fleet-server-policy=policy-1 \\\\ + --certificate-authorities= \\\\ + --fleet-server-es-ca= \\\\ + --fleet-server-cert= \\\\ + --fleet-server-cert-key= \\\\ + --fleet-server-port=8220" + `); - expect(res).toMatchInlineSnapshot(` - "curl -L -O https://artifacts.elastic.co/downloads/beats/elastic-agent/elastic-agent--darwin-aarch64.tar.gz - tar xzvf elastic-agent--darwin-aarch64.tar.gz - cd elastic-agent--darwin-aarch64 + expect( + getInstallCommandForPlatform({ + platform: 'mac_x86_64', + kibanaVersion: '9.0.0', + esOutputHost: 'http://elasticsearch:9200', + serviceToken: 'service-token-1', + policyId: 'policy-1', + fleetServerHost: 'http://fleetserver:8220', + isProductionDeployment: true, + }) + ).toMatchInlineSnapshot(` + "curl -L -O https://artifacts.elastic.co/downloads/beats/elastic-agent/elastic-agent-9.0.0-darwin-x86_64.tar.gz + tar xzvf elastic-agent-9.0.0-darwin-x86_64.tar.gz + cd elastic-agent-9.0.0-darwin-x86_64 sudo ./elastic-agent install --url=http://fleetserver:8220 \\\\ --fleet-server-es=http://elasticsearch:9200 \\\\ --fleet-server-service-token=service-token-1 \\\\ @@ -337,18 +545,45 @@ describe('getInstallCommandForPlatform', () => { }); it('should return the correct command if the the policyId is set for rpm', () => { - const res = getInstallCommandForPlatform({ - platform: 'rpm', - esOutputHost: 'http://elasticsearch:9200', - serviceToken: 'service-token-1', - policyId: 'policy-1', - fleetServerHost: 'http://fleetserver:8220', - isProductionDeployment: true, - }); + expect( + getInstallCommandForPlatform({ + platform: 'rpm_aarch64', + kibanaVersion: '9.0.0', + esOutputHost: 'http://elasticsearch:9200', + serviceToken: 'service-token-1', + policyId: 'policy-1', + fleetServerHost: 'http://fleetserver:8220', + isProductionDeployment: true, + }) + ).toMatchInlineSnapshot(` + "curl -L -O https://artifacts.elastic.co/downloads/beats/elastic-agent/elastic-agent-9.0.0-aarch64.rpm + sudo rpm -vi elastic-agent-9.0.0-aarch64.rpm + sudo systemctl enable elastic-agent + sudo systemctl start elastic-agent + sudo elastic-agent enroll --url=http://fleetserver:8220 \\\\ + --fleet-server-es=http://elasticsearch:9200 \\\\ + --fleet-server-service-token=service-token-1 \\\\ + --fleet-server-policy=policy-1 \\\\ + --certificate-authorities= \\\\ + --fleet-server-es-ca= \\\\ + --fleet-server-cert= \\\\ + --fleet-server-cert-key= \\\\ + --fleet-server-port=8220" + `); - expect(res).toMatchInlineSnapshot(` - "curl -L -O https://artifacts.elastic.co/downloads/beats/elastic-agent/elastic-agent--x86_64.rpm - sudo rpm -vi elastic-agent--x86_64.rpm + expect( + getInstallCommandForPlatform({ + platform: 'rpm_x86_64', + kibanaVersion: '9.0.0', + esOutputHost: 'http://elasticsearch:9200', + serviceToken: 'service-token-1', + policyId: 'policy-1', + fleetServerHost: 'http://fleetserver:8220', + isProductionDeployment: true, + }) + ).toMatchInlineSnapshot(` + "curl -L -O https://artifacts.elastic.co/downloads/beats/elastic-agent/elastic-agent-9.0.0-x86_64.rpm + sudo rpm -vi elastic-agent-9.0.0-x86_64.rpm sudo systemctl enable elastic-agent sudo systemctl start elastic-agent sudo elastic-agent enroll --url=http://fleetserver:8220 \\\\ @@ -364,18 +599,45 @@ describe('getInstallCommandForPlatform', () => { }); it('should return the correct command if the the policyId is set for deb', () => { - const res = getInstallCommandForPlatform({ - platform: 'deb', - esOutputHost: 'http://elasticsearch:9200', - serviceToken: 'service-token-1', - policyId: 'policy-1', - fleetServerHost: 'http://fleetserver:8220', - isProductionDeployment: true, - }); + expect( + getInstallCommandForPlatform({ + platform: 'deb_aarch64', + kibanaVersion: '9.0.0', + esOutputHost: 'http://elasticsearch:9200', + serviceToken: 'service-token-1', + policyId: 'policy-1', + fleetServerHost: 'http://fleetserver:8220', + isProductionDeployment: true, + }) + ).toMatchInlineSnapshot(` + "curl -L -O https://artifacts.elastic.co/downloads/beats/elastic-agent/elastic-agent-9.0.0-arm64.deb + sudo dpkg -i elastic-agent-9.0.0-arm64.deb + sudo systemctl enable elastic-agent + sudo systemctl start elastic-agent + sudo elastic-agent enroll --url=http://fleetserver:8220 \\\\ + --fleet-server-es=http://elasticsearch:9200 \\\\ + --fleet-server-service-token=service-token-1 \\\\ + --fleet-server-policy=policy-1 \\\\ + --certificate-authorities= \\\\ + --fleet-server-es-ca= \\\\ + --fleet-server-cert= \\\\ + --fleet-server-cert-key= \\\\ + --fleet-server-port=8220" + `); - expect(res).toMatchInlineSnapshot(` - "curl -L -O https://artifacts.elastic.co/downloads/beats/elastic-agent/elastic-agent--amd64.deb - sudo dpkg -i elastic-agent--amd64.deb + expect( + getInstallCommandForPlatform({ + platform: 'deb_x86_64', + kibanaVersion: '9.0.0', + esOutputHost: 'http://elasticsearch:9200', + serviceToken: 'service-token-1', + policyId: 'policy-1', + fleetServerHost: 'http://fleetserver:8220', + isProductionDeployment: true, + }) + ).toMatchInlineSnapshot(` + "curl -L -O https://artifacts.elastic.co/downloads/beats/elastic-agent/elastic-agent-9.0.0-amd64.deb + sudo dpkg -i elastic-agent-9.0.0-amd64.deb sudo systemctl enable elastic-agent sudo systemctl start elastic-agent sudo elastic-agent enroll --url=http://fleetserver:8220 \\\\ @@ -393,37 +655,78 @@ describe('getInstallCommandForPlatform', () => { describe('with simple proxy settings', () => { it('should return the correct command if proxies are set for linux', () => { - const res = getInstallCommandForPlatform({ - platform: 'linux', - esOutputHost: 'http://elasticsearch:9200', - esOutputProxy: { - id: 'es-proxy', - name: 'es-proxy', - url: 'http://es-proxy:1111', - is_preconfigured: false, - }, - serviceToken: 'service-token-1', - policyId: 'policy-1', - fleetServerHost: 'http://fleetserver:8220', - downloadSource: { - id: 'download-src', - name: 'download-src', - host: 'https://download-src/8.12.0-test/', - is_default: false, - proxy_id: 'download-proxy', - }, - downloadSourceProxy: { - id: 'download-src-proxy', - name: 'download-src-proxy', - url: 'http://download-src-proxy:2222', - is_preconfigured: false, - }, - }); + expect( + getInstallCommandForPlatform({ + platform: 'linux_aarch64', + kibanaVersion: '9.0.0', + esOutputHost: 'http://elasticsearch:9200', + esOutputProxy: { + id: 'es-proxy', + name: 'es-proxy', + url: 'http://es-proxy:1111', + is_preconfigured: false, + }, + serviceToken: 'service-token-1', + policyId: 'policy-1', + fleetServerHost: 'http://fleetserver:8220', + downloadSource: { + id: 'download-src', + name: 'download-src', + host: 'https://download-src/8.12.0-test/', + is_default: false, + proxy_id: 'download-proxy', + }, + downloadSourceProxy: { + id: 'download-src-proxy', + name: 'download-src-proxy', + url: 'http://download-src-proxy:2222', + is_preconfigured: false, + }, + }) + ).toMatchInlineSnapshot(` + "curl -L -O https://download-src/8.12.0-test/beats/elastic-agent/elastic-agent-9.0.0-linux-arm64.tar.gz --proxy http://download-src-proxy:2222 + tar xzvf elastic-agent-9.0.0-linux-arm64.tar.gz + cd elastic-agent-9.0.0-linux-arm64 + sudo ./elastic-agent install \\\\ + --fleet-server-es=http://elasticsearch:9200 \\\\ + --fleet-server-service-token=service-token-1 \\\\ + --fleet-server-policy=policy-1 \\\\ + --fleet-server-port=8220 \\\\ + --proxy-url=http://es-proxy:1111" + `); - expect(res).toMatchInlineSnapshot(` - "curl -L -O https://download-src/8.12.0-test/beats/elastic-agent/elastic-agent--linux-x86_64.tar.gz --proxy http://download-src-proxy:2222 - tar xzvf elastic-agent--linux-x86_64.tar.gz - cd elastic-agent--linux-x86_64 + expect( + getInstallCommandForPlatform({ + platform: 'linux_x86_64', + kibanaVersion: '9.0.0', + esOutputHost: 'http://elasticsearch:9200', + esOutputProxy: { + id: 'es-proxy', + name: 'es-proxy', + url: 'http://es-proxy:1111', + is_preconfigured: false, + }, + serviceToken: 'service-token-1', + policyId: 'policy-1', + fleetServerHost: 'http://fleetserver:8220', + downloadSource: { + id: 'download-src', + name: 'download-src', + host: 'https://download-src/8.12.0-test/', + is_default: false, + proxy_id: 'download-proxy', + }, + downloadSourceProxy: { + id: 'download-src-proxy', + name: 'download-src-proxy', + url: 'http://download-src-proxy:2222', + is_preconfigured: false, + }, + }) + ).toMatchInlineSnapshot(` + "curl -L -O https://download-src/8.12.0-test/beats/elastic-agent/elastic-agent-9.0.0-linux-x86_64.tar.gz --proxy http://download-src-proxy:2222 + tar xzvf elastic-agent-9.0.0-linux-x86_64.tar.gz + cd elastic-agent-9.0.0-linux-x86_64 sudo ./elastic-agent install \\\\ --fleet-server-es=http://elasticsearch:9200 \\\\ --fleet-server-service-token=service-token-1 \\\\ @@ -434,37 +737,78 @@ describe('getInstallCommandForPlatform', () => { }); it('should return the correct command if proxies are set for mac', () => { - const res = getInstallCommandForPlatform({ - platform: 'mac', - esOutputHost: 'http://elasticsearch:9200', - esOutputProxy: { - id: 'es-proxy', - name: 'es-proxy', - url: 'http://es-proxy:1111', - is_preconfigured: false, - }, - serviceToken: 'service-token-1', - policyId: 'policy-1', - fleetServerHost: 'http://fleetserver:8220', - downloadSource: { - id: 'download-src', - name: 'download-src', - host: 'https://download-src/8.12.0-test/', - is_default: false, - proxy_id: 'download-proxy', - }, - downloadSourceProxy: { - id: 'download-src-proxy', - name: 'download-src-proxy', - url: 'http://download-src-proxy:2222', - is_preconfigured: false, - }, - }); + expect( + getInstallCommandForPlatform({ + platform: 'mac_aarch64', + kibanaVersion: '9.0.0', + esOutputHost: 'http://elasticsearch:9200', + esOutputProxy: { + id: 'es-proxy', + name: 'es-proxy', + url: 'http://es-proxy:1111', + is_preconfigured: false, + }, + serviceToken: 'service-token-1', + policyId: 'policy-1', + fleetServerHost: 'http://fleetserver:8220', + downloadSource: { + id: 'download-src', + name: 'download-src', + host: 'https://download-src/8.12.0-test/', + is_default: false, + proxy_id: 'download-proxy', + }, + downloadSourceProxy: { + id: 'download-src-proxy', + name: 'download-src-proxy', + url: 'http://download-src-proxy:2222', + is_preconfigured: false, + }, + }) + ).toMatchInlineSnapshot(` + "curl -L -O https://download-src/8.12.0-test/beats/elastic-agent/elastic-agent-9.0.0-darwin-aarch64.tar.gz --proxy http://download-src-proxy:2222 + tar xzvf elastic-agent-9.0.0-darwin-aarch64.tar.gz + cd elastic-agent-9.0.0-darwin-aarch64 + sudo ./elastic-agent install \\\\ + --fleet-server-es=http://elasticsearch:9200 \\\\ + --fleet-server-service-token=service-token-1 \\\\ + --fleet-server-policy=policy-1 \\\\ + --fleet-server-port=8220 \\\\ + --proxy-url=http://es-proxy:1111" + `); - expect(res).toMatchInlineSnapshot(` - "curl -L -O https://download-src/8.12.0-test/beats/elastic-agent/elastic-agent--darwin-aarch64.tar.gz --proxy http://download-src-proxy:2222 - tar xzvf elastic-agent--darwin-aarch64.tar.gz - cd elastic-agent--darwin-aarch64 + expect( + getInstallCommandForPlatform({ + platform: 'mac_x86_64', + kibanaVersion: '9.0.0', + esOutputHost: 'http://elasticsearch:9200', + esOutputProxy: { + id: 'es-proxy', + name: 'es-proxy', + url: 'http://es-proxy:1111', + is_preconfigured: false, + }, + serviceToken: 'service-token-1', + policyId: 'policy-1', + fleetServerHost: 'http://fleetserver:8220', + downloadSource: { + id: 'download-src', + name: 'download-src', + host: 'https://download-src/8.12.0-test/', + is_default: false, + proxy_id: 'download-proxy', + }, + downloadSourceProxy: { + id: 'download-src-proxy', + name: 'download-src-proxy', + url: 'http://download-src-proxy:2222', + is_preconfigured: false, + }, + }) + ).toMatchInlineSnapshot(` + "curl -L -O https://download-src/8.12.0-test/beats/elastic-agent/elastic-agent-9.0.0-darwin-x86_64.tar.gz --proxy http://download-src-proxy:2222 + tar xzvf elastic-agent-9.0.0-darwin-x86_64.tar.gz + cd elastic-agent-9.0.0-darwin-x86_64 sudo ./elastic-agent install \\\\ --fleet-server-es=http://elasticsearch:9200 \\\\ --fleet-server-service-token=service-token-1 \\\\ @@ -517,36 +861,78 @@ describe('getInstallCommandForPlatform', () => { }); it('should return the correct command if proxies are set for rpm', () => { - const res = getInstallCommandForPlatform({ - platform: 'rpm', - esOutputHost: 'http://elasticsearch:9200', - esOutputProxy: { - id: 'es-proxy', - name: 'es-proxy', - url: 'http://es-proxy:1111', - is_preconfigured: false, - }, - serviceToken: 'service-token-1', - policyId: 'policy-1', - fleetServerHost: 'http://fleetserver:8220', - downloadSource: { - id: 'download-src', - name: 'download-src', - host: 'https://download-src/8.12.0-test/', - is_default: false, - proxy_id: 'download-proxy', - }, - downloadSourceProxy: { - id: 'download-src-proxy', - name: 'download-src-proxy', - url: 'http://download-src-proxy:2222', - is_preconfigured: false, - }, - }); + expect( + getInstallCommandForPlatform({ + platform: 'rpm_aarch64', + kibanaVersion: '9.0.0', + esOutputHost: 'http://elasticsearch:9200', + esOutputProxy: { + id: 'es-proxy', + name: 'es-proxy', + url: 'http://es-proxy:1111', + is_preconfigured: false, + }, + serviceToken: 'service-token-1', + policyId: 'policy-1', + fleetServerHost: 'http://fleetserver:8220', + downloadSource: { + id: 'download-src', + name: 'download-src', + host: 'https://download-src/8.12.0-test/', + is_default: false, + proxy_id: 'download-proxy', + }, + downloadSourceProxy: { + id: 'download-src-proxy', + name: 'download-src-proxy', + url: 'http://download-src-proxy:2222', + is_preconfigured: false, + }, + }) + ).toMatchInlineSnapshot(` + "curl -L -O https://download-src/8.12.0-test/beats/elastic-agent/elastic-agent-9.0.0-aarch64.rpm --proxy http://download-src-proxy:2222 + sudo rpm -vi elastic-agent-9.0.0-aarch64.rpm + sudo systemctl enable elastic-agent + sudo systemctl start elastic-agent + sudo elastic-agent enroll \\\\ + --fleet-server-es=http://elasticsearch:9200 \\\\ + --fleet-server-service-token=service-token-1 \\\\ + --fleet-server-policy=policy-1 \\\\ + --fleet-server-port=8220 \\\\ + --proxy-url=http://es-proxy:1111" + `); - expect(res).toMatchInlineSnapshot(` - "curl -L -O https://download-src/8.12.0-test/beats/elastic-agent/elastic-agent--x86_64.rpm --proxy http://download-src-proxy:2222 - sudo rpm -vi elastic-agent--x86_64.rpm + expect( + getInstallCommandForPlatform({ + platform: 'rpm_x86_64', + kibanaVersion: '9.0.0', + esOutputHost: 'http://elasticsearch:9200', + esOutputProxy: { + id: 'es-proxy', + name: 'es-proxy', + url: 'http://es-proxy:1111', + is_preconfigured: false, + }, + serviceToken: 'service-token-1', + policyId: 'policy-1', + fleetServerHost: 'http://fleetserver:8220', + downloadSource: { + id: 'download-src', + name: 'download-src', + host: 'https://download-src/8.12.0-test/', + is_default: false, + proxy_id: 'download-proxy', + }, + downloadSourceProxy: { + id: 'download-src-proxy', + name: 'download-src-proxy', + url: 'http://download-src-proxy:2222', + is_preconfigured: false, + }, + }) + ).toMatchInlineSnapshot(` + "curl -L -O https://download-src/8.12.0-test/beats/elastic-agent/elastic-agent-9.0.0-x86_64.rpm --proxy http://download-src-proxy:2222 + sudo rpm -vi elastic-agent-9.0.0-x86_64.rpm sudo systemctl enable elastic-agent sudo systemctl start elastic-agent sudo elastic-agent enroll \\\\ @@ -559,36 +945,78 @@ describe('getInstallCommandForPlatform', () => { }); it('should return the correct command if proxies are set for deb', () => { - const res = getInstallCommandForPlatform({ - platform: 'deb', - esOutputHost: 'http://elasticsearch:9200', - esOutputProxy: { - id: 'es-proxy', - name: 'es-proxy', - url: 'http://es-proxy:1111', - is_preconfigured: false, - }, - serviceToken: 'service-token-1', - policyId: 'policy-1', - fleetServerHost: 'http://fleetserver:8220', - downloadSource: { - id: 'download-src', - name: 'download-src', - host: 'https://download-src/8.12.0-test/', - is_default: false, - proxy_id: 'download-proxy', - }, - downloadSourceProxy: { - id: 'download-src-proxy', - name: 'download-src-proxy', - url: 'http://download-src-proxy:2222', - is_preconfigured: false, - }, - }); + expect( + getInstallCommandForPlatform({ + platform: 'deb_aarch64', + kibanaVersion: '9.0.0', + esOutputHost: 'http://elasticsearch:9200', + esOutputProxy: { + id: 'es-proxy', + name: 'es-proxy', + url: 'http://es-proxy:1111', + is_preconfigured: false, + }, + serviceToken: 'service-token-1', + policyId: 'policy-1', + fleetServerHost: 'http://fleetserver:8220', + downloadSource: { + id: 'download-src', + name: 'download-src', + host: 'https://download-src/8.12.0-test/', + is_default: false, + proxy_id: 'download-proxy', + }, + downloadSourceProxy: { + id: 'download-src-proxy', + name: 'download-src-proxy', + url: 'http://download-src-proxy:2222', + is_preconfigured: false, + }, + }) + ).toMatchInlineSnapshot(` + "curl -L -O https://download-src/8.12.0-test/beats/elastic-agent/elastic-agent-9.0.0-arm64.deb --proxy http://download-src-proxy:2222 + sudo dpkg -i elastic-agent-9.0.0-arm64.deb + sudo systemctl enable elastic-agent + sudo systemctl start elastic-agent + sudo elastic-agent enroll \\\\ + --fleet-server-es=http://elasticsearch:9200 \\\\ + --fleet-server-service-token=service-token-1 \\\\ + --fleet-server-policy=policy-1 \\\\ + --fleet-server-port=8220 \\\\ + --proxy-url=http://es-proxy:1111" + `); - expect(res).toMatchInlineSnapshot(` - "curl -L -O https://download-src/8.12.0-test/beats/elastic-agent/elastic-agent--amd64.deb --proxy http://download-src-proxy:2222 - sudo dpkg -i elastic-agent--amd64.deb + expect( + getInstallCommandForPlatform({ + platform: 'deb_x86_64', + kibanaVersion: '9.0.0', + esOutputHost: 'http://elasticsearch:9200', + esOutputProxy: { + id: 'es-proxy', + name: 'es-proxy', + url: 'http://es-proxy:1111', + is_preconfigured: false, + }, + serviceToken: 'service-token-1', + policyId: 'policy-1', + fleetServerHost: 'http://fleetserver:8220', + downloadSource: { + id: 'download-src', + name: 'download-src', + host: 'https://download-src/8.12.0-test/', + is_default: false, + proxy_id: 'download-proxy', + }, + downloadSourceProxy: { + id: 'download-src-proxy', + name: 'download-src-proxy', + url: 'http://download-src-proxy:2222', + is_preconfigured: false, + }, + }) + ).toMatchInlineSnapshot(` + "curl -L -O https://download-src/8.12.0-test/beats/elastic-agent/elastic-agent-9.0.0-amd64.deb --proxy http://download-src-proxy:2222 + sudo dpkg -i elastic-agent-9.0.0-amd64.deb sudo systemctl enable elastic-agent sudo systemctl start elastic-agent sudo elastic-agent enroll \\\\ @@ -603,8 +1031,7 @@ describe('getInstallCommandForPlatform', () => { describe('with full proxy settings', () => { it('should return the correct command if proxies are set for linux', () => { - const res = getInstallCommandForPlatform({ - platform: 'linux', + const args = { esOutputHost: 'http://elasticsearch:9200', esOutputProxy: { id: 'es-proxy', @@ -636,12 +1063,38 @@ describe('getInstallCommandForPlatform', () => { }, is_preconfigured: false, }, - }); + }; - expect(res).toMatchInlineSnapshot(` - "curl -L -O https://download-src/8.12.0-test/beats/elastic-agent/elastic-agent--linux-x86_64.tar.gz --proxy http://download-src-proxy:2222 --proxy-header \\"Accept-Language=en-US,en;q=0.5\\" --proxy-header \\"second-header=second-value\\" - tar xzvf elastic-agent--linux-x86_64.tar.gz - cd elastic-agent--linux-x86_64 + expect( + getInstallCommandForPlatform({ + ...args, + platform: 'linux_aarch64', + kibanaVersion: '9.0.0', + }) + ).toMatchInlineSnapshot(` + "curl -L -O https://download-src/8.12.0-test/beats/elastic-agent/elastic-agent-9.0.0-linux-arm64.tar.gz --proxy http://download-src-proxy:2222 --proxy-header \\"Accept-Language=en-US,en;q=0.5\\" --proxy-header \\"second-header=second-value\\" + tar xzvf elastic-agent-9.0.0-linux-arm64.tar.gz + cd elastic-agent-9.0.0-linux-arm64 + sudo ./elastic-agent install \\\\ + --fleet-server-es=http://elasticsearch:9200 \\\\ + --fleet-server-service-token=service-token-1 \\\\ + --fleet-server-policy=policy-1 \\\\ + --fleet-server-port=8220 \\\\ + --proxy-url=http://es-proxy:1111 \\\\ + --proxy-header=\\"X-Forwarded-For=forwarded-value\\" \\\\ + --proxy-header=\\"test-header=test-value\\"" + `); + + expect( + getInstallCommandForPlatform({ + ...args, + platform: 'linux_x86_64', + kibanaVersion: '9.0.0', + }) + ).toMatchInlineSnapshot(` + "curl -L -O https://download-src/8.12.0-test/beats/elastic-agent/elastic-agent-9.0.0-linux-x86_64.tar.gz --proxy http://download-src-proxy:2222 --proxy-header \\"Accept-Language=en-US,en;q=0.5\\" --proxy-header \\"second-header=second-value\\" + tar xzvf elastic-agent-9.0.0-linux-x86_64.tar.gz + cd elastic-agent-9.0.0-linux-x86_64 sudo ./elastic-agent install \\\\ --fleet-server-es=http://elasticsearch:9200 \\\\ --fleet-server-service-token=service-token-1 \\\\ @@ -654,8 +1107,7 @@ describe('getInstallCommandForPlatform', () => { }); it('should return the correct command if proxies are set for mac', () => { - const res = getInstallCommandForPlatform({ - platform: 'mac', + const args = { esOutputHost: 'http://elasticsearch:9200', esOutputProxy: { id: 'es-proxy', @@ -687,12 +1139,38 @@ describe('getInstallCommandForPlatform', () => { }, is_preconfigured: false, }, - }); + }; - expect(res).toMatchInlineSnapshot(` - "curl -L -O https://download-src/8.12.0-test/beats/elastic-agent/elastic-agent--darwin-aarch64.tar.gz --proxy http://download-src-proxy:2222 --proxy-header \\"Accept-Language=en-US,en;q=0.5\\" --proxy-header \\"second-header=second-value\\" - tar xzvf elastic-agent--darwin-aarch64.tar.gz - cd elastic-agent--darwin-aarch64 + expect( + getInstallCommandForPlatform({ + ...args, + platform: 'mac_aarch64', + kibanaVersion: '9.0.0', + }) + ).toMatchInlineSnapshot(` + "curl -L -O https://download-src/8.12.0-test/beats/elastic-agent/elastic-agent-9.0.0-darwin-aarch64.tar.gz --proxy http://download-src-proxy:2222 --proxy-header \\"Accept-Language=en-US,en;q=0.5\\" --proxy-header \\"second-header=second-value\\" + tar xzvf elastic-agent-9.0.0-darwin-aarch64.tar.gz + cd elastic-agent-9.0.0-darwin-aarch64 + sudo ./elastic-agent install \\\\ + --fleet-server-es=http://elasticsearch:9200 \\\\ + --fleet-server-service-token=service-token-1 \\\\ + --fleet-server-policy=policy-1 \\\\ + --fleet-server-port=8220 \\\\ + --proxy-url=http://es-proxy:1111 \\\\ + --proxy-header=\\"X-Forwarded-For=forwarded-value\\" \\\\ + --proxy-header=\\"test-header=test-value\\"" + `); + + expect( + getInstallCommandForPlatform({ + ...args, + platform: 'mac_x86_64', + kibanaVersion: '9.0.0', + }) + ).toMatchInlineSnapshot(` + "curl -L -O https://download-src/8.12.0-test/beats/elastic-agent/elastic-agent-9.0.0-darwin-x86_64.tar.gz --proxy http://download-src-proxy:2222 --proxy-header \\"Accept-Language=en-US,en;q=0.5\\" --proxy-header \\"second-header=second-value\\" + tar xzvf elastic-agent-9.0.0-darwin-x86_64.tar.gz + cd elastic-agent-9.0.0-darwin-x86_64 sudo ./elastic-agent install \\\\ --fleet-server-es=http://elasticsearch:9200 \\\\ --fleet-server-service-token=service-token-1 \\\\ @@ -757,8 +1235,7 @@ describe('getInstallCommandForPlatform', () => { }); it('should return the correct command if proxies are set for rpm', () => { - const res = getInstallCommandForPlatform({ - platform: 'rpm', + const args = { esOutputHost: 'http://elasticsearch:9200', esOutputProxy: { id: 'es-proxy', @@ -790,11 +1267,38 @@ describe('getInstallCommandForPlatform', () => { }, is_preconfigured: false, }, - }); + }; - expect(res).toMatchInlineSnapshot(` - "curl -L -O https://download-src/8.12.0-test/beats/elastic-agent/elastic-agent--x86_64.rpm --proxy http://download-src-proxy:2222 --proxy-header \\"Accept-Language=en-US,en;q=0.5\\" --proxy-header \\"second-header=second-value\\" - sudo rpm -vi elastic-agent--x86_64.rpm + expect( + getInstallCommandForPlatform({ + ...args, + platform: 'rpm_aarch64', + kibanaVersion: '9.0.0', + }) + ).toMatchInlineSnapshot(` + "curl -L -O https://download-src/8.12.0-test/beats/elastic-agent/elastic-agent-9.0.0-aarch64.rpm --proxy http://download-src-proxy:2222 --proxy-header \\"Accept-Language=en-US,en;q=0.5\\" --proxy-header \\"second-header=second-value\\" + sudo rpm -vi elastic-agent-9.0.0-aarch64.rpm + sudo systemctl enable elastic-agent + sudo systemctl start elastic-agent + sudo elastic-agent enroll \\\\ + --fleet-server-es=http://elasticsearch:9200 \\\\ + --fleet-server-service-token=service-token-1 \\\\ + --fleet-server-policy=policy-1 \\\\ + --fleet-server-port=8220 \\\\ + --proxy-url=http://es-proxy:1111 \\\\ + --proxy-header=\\"X-Forwarded-For=forwarded-value\\" \\\\ + --proxy-header=\\"test-header=test-value\\"" + `); + + expect( + getInstallCommandForPlatform({ + ...args, + platform: 'rpm_x86_64', + kibanaVersion: '9.0.0', + }) + ).toMatchInlineSnapshot(` + "curl -L -O https://download-src/8.12.0-test/beats/elastic-agent/elastic-agent-9.0.0-x86_64.rpm --proxy http://download-src-proxy:2222 --proxy-header \\"Accept-Language=en-US,en;q=0.5\\" --proxy-header \\"second-header=second-value\\" + sudo rpm -vi elastic-agent-9.0.0-x86_64.rpm sudo systemctl enable elastic-agent sudo systemctl start elastic-agent sudo elastic-agent enroll \\\\ @@ -809,8 +1313,7 @@ describe('getInstallCommandForPlatform', () => { }); it('should return the correct command if proxies are set for deb', () => { - const res = getInstallCommandForPlatform({ - platform: 'deb', + const args = { esOutputHost: 'http://elasticsearch:9200', esOutputProxy: { id: 'es-proxy', @@ -842,11 +1345,38 @@ describe('getInstallCommandForPlatform', () => { }, is_preconfigured: false, }, - }); + }; - expect(res).toMatchInlineSnapshot(` - "curl -L -O https://download-src/8.12.0-test/beats/elastic-agent/elastic-agent--amd64.deb --proxy http://download-src-proxy:2222 --proxy-header \\"Accept-Language=en-US,en;q=0.5\\" --proxy-header \\"second-header=second-value\\" - sudo dpkg -i elastic-agent--amd64.deb + expect( + getInstallCommandForPlatform({ + ...args, + platform: 'deb_aarch64', + kibanaVersion: '9.0.0', + }) + ).toMatchInlineSnapshot(` + "curl -L -O https://download-src/8.12.0-test/beats/elastic-agent/elastic-agent-9.0.0-arm64.deb --proxy http://download-src-proxy:2222 --proxy-header \\"Accept-Language=en-US,en;q=0.5\\" --proxy-header \\"second-header=second-value\\" + sudo dpkg -i elastic-agent-9.0.0-arm64.deb + sudo systemctl enable elastic-agent + sudo systemctl start elastic-agent + sudo elastic-agent enroll \\\\ + --fleet-server-es=http://elasticsearch:9200 \\\\ + --fleet-server-service-token=service-token-1 \\\\ + --fleet-server-policy=policy-1 \\\\ + --fleet-server-port=8220 \\\\ + --proxy-url=http://es-proxy:1111 \\\\ + --proxy-header=\\"X-Forwarded-For=forwarded-value\\" \\\\ + --proxy-header=\\"test-header=test-value\\"" + `); + + expect( + getInstallCommandForPlatform({ + ...args, + platform: 'deb_x86_64', + kibanaVersion: '9.0.0', + }) + ).toMatchInlineSnapshot(` + "curl -L -O https://download-src/8.12.0-test/beats/elastic-agent/elastic-agent-9.0.0-amd64.deb --proxy http://download-src-proxy:2222 --proxy-header \\"Accept-Language=en-US,en;q=0.5\\" --proxy-header \\"second-header=second-value\\" + sudo dpkg -i elastic-agent-9.0.0-amd64.deb sudo systemctl enable elastic-agent sudo systemctl start elastic-agent sudo elastic-agent enroll \\\\ diff --git a/x-pack/platform/plugins/shared/fleet/public/applications/fleet/components/fleet_server_instructions/utils/install_command_utils.ts b/x-pack/platform/plugins/shared/fleet/public/applications/fleet/components/fleet_server_instructions/utils/install_command_utils.ts index 0264adc879907..9dac831898b97 100644 --- a/x-pack/platform/plugins/shared/fleet/public/applications/fleet/components/fleet_server_instructions/utils/install_command_utils.ts +++ b/x-pack/platform/plugins/shared/fleet/public/applications/fleet/components/fleet_server_instructions/utils/install_command_utils.ts @@ -34,20 +34,34 @@ function getArtifact( : ''; const artifactMap: Record = { - linux: { + linux_aarch64: { + downloadCommand: [ + `curl -L -O ${ARTIFACT_BASE_URL}/elastic-agent-${kibanaVersion}-linux-arm64.tar.gz${appendCurlDownloadSourceProxyArgs}`, + `tar xzvf elastic-agent-${kibanaVersion}-linux-arm64.tar.gz`, + `cd elastic-agent-${kibanaVersion}-linux-arm64`, + ].join(`\n`), + }, + linux_x86_64: { downloadCommand: [ `curl -L -O ${ARTIFACT_BASE_URL}/elastic-agent-${kibanaVersion}-linux-x86_64.tar.gz${appendCurlDownloadSourceProxyArgs}`, `tar xzvf elastic-agent-${kibanaVersion}-linux-x86_64.tar.gz`, `cd elastic-agent-${kibanaVersion}-linux-x86_64`, ].join(`\n`), }, - mac: { + mac_aarch64: { downloadCommand: [ `curl -L -O ${ARTIFACT_BASE_URL}/elastic-agent-${kibanaVersion}-darwin-aarch64.tar.gz${appendCurlDownloadSourceProxyArgs}`, `tar xzvf elastic-agent-${kibanaVersion}-darwin-aarch64.tar.gz`, `cd elastic-agent-${kibanaVersion}-darwin-aarch64`, ].join(`\n`), }, + mac_x86_64: { + downloadCommand: [ + `curl -L -O ${ARTIFACT_BASE_URL}/elastic-agent-${kibanaVersion}-darwin-x86_64.tar.gz${appendCurlDownloadSourceProxyArgs}`, + `tar xzvf elastic-agent-${kibanaVersion}-darwin-x86_64.tar.gz`, + `cd elastic-agent-${kibanaVersion}-darwin-x86_64`, + ].join(`\n`), + }, windows: { downloadCommand: [ `$ProgressPreference = 'SilentlyContinue'`, @@ -56,13 +70,25 @@ function getArtifact( `cd elastic-agent-${kibanaVersion}-windows-x86_64`, ].join(`\n`), }, - deb: { + deb_aarch64: { + downloadCommand: [ + `curl -L -O ${ARTIFACT_BASE_URL}/elastic-agent-${kibanaVersion}-arm64.deb${appendCurlDownloadSourceProxyArgs}`, + `sudo dpkg -i elastic-agent-${kibanaVersion}-arm64.deb`, + ].join(`\n`), + }, + deb_x86_64: { downloadCommand: [ `curl -L -O ${ARTIFACT_BASE_URL}/elastic-agent-${kibanaVersion}-amd64.deb${appendCurlDownloadSourceProxyArgs}`, `sudo dpkg -i elastic-agent-${kibanaVersion}-amd64.deb`, ].join(`\n`), }, - rpm: { + rpm_aarch64: { + downloadCommand: [ + `curl -L -O ${ARTIFACT_BASE_URL}/elastic-agent-${kibanaVersion}-aarch64.rpm${appendCurlDownloadSourceProxyArgs}`, + `sudo rpm -vi elastic-agent-${kibanaVersion}-aarch64.rpm`, + ].join(`\n`), + }, + rpm_x86_64: { downloadCommand: [ `curl -L -O ${ARTIFACT_BASE_URL}/elastic-agent-${kibanaVersion}-x86_64.rpm${appendCurlDownloadSourceProxyArgs}`, `sudo rpm -vi elastic-agent-${kibanaVersion}-x86_64.rpm`, @@ -151,11 +177,15 @@ export function getInstallCommandForPlatform({ .trim(); const commands = { - linux: `${artifact.downloadCommand}\nsudo ./elastic-agent install ${commandArgumentsStr}`, - mac: `${artifact.downloadCommand}\nsudo ./elastic-agent install ${commandArgumentsStr}`, + linux_aarch64: `${artifact.downloadCommand}\nsudo ./elastic-agent install ${commandArgumentsStr}`, + linux_x86_64: `${artifact.downloadCommand}\nsudo ./elastic-agent install ${commandArgumentsStr}`, + mac_aarch64: `${artifact.downloadCommand}\nsudo ./elastic-agent install ${commandArgumentsStr}`, + mac_x86_64: `${artifact.downloadCommand}\nsudo ./elastic-agent install ${commandArgumentsStr}`, windows: `${artifact.downloadCommand}\n.\\elastic-agent.exe install ${commandArgumentsStr}`, - deb: `${artifact.downloadCommand}\nsudo systemctl enable elastic-agent\nsudo systemctl start elastic-agent\nsudo elastic-agent enroll ${commandArgumentsStr}`, - rpm: `${artifact.downloadCommand}\nsudo systemctl enable elastic-agent\nsudo systemctl start elastic-agent\nsudo elastic-agent enroll ${commandArgumentsStr}`, + deb_aarch64: `${artifact.downloadCommand}\nsudo systemctl enable elastic-agent\nsudo systemctl start elastic-agent\nsudo elastic-agent enroll ${commandArgumentsStr}`, + deb_x86_64: `${artifact.downloadCommand}\nsudo systemctl enable elastic-agent\nsudo systemctl start elastic-agent\nsudo elastic-agent enroll ${commandArgumentsStr}`, + rpm_aarch64: `${artifact.downloadCommand}\nsudo systemctl enable elastic-agent\nsudo systemctl start elastic-agent\nsudo elastic-agent enroll ${commandArgumentsStr}`, + rpm_x86_64: `${artifact.downloadCommand}\nsudo systemctl enable elastic-agent\nsudo systemctl start elastic-agent\nsudo elastic-agent enroll ${commandArgumentsStr}`, kubernetes: '', cloudFormation: '', googleCloudShell: '', diff --git a/x-pack/platform/plugins/shared/fleet/public/components/agent_enrollment_flyout/installation_message.tsx b/x-pack/platform/plugins/shared/fleet/public/components/agent_enrollment_flyout/installation_message.tsx index 94cf484cb627a..fd1dfb115f3d2 100644 --- a/x-pack/platform/plugins/shared/fleet/public/components/agent_enrollment_flyout/installation_message.tsx +++ b/x-pack/platform/plugins/shared/fleet/public/components/agent_enrollment_flyout/installation_message.tsx @@ -39,7 +39,7 @@ export const InstallationMessage: React.FunctionComponent = ({ = ({ = ({ - linuxCommand, - macCommand, - windowsCommand, - linuxDebCommand, - linuxRpmCommand, - k8sCommand, + installCommand, hasK8sIntegration, cloudSecurityIntegration, hasK8sIntegrationMultiPage, @@ -64,30 +63,27 @@ export const PlatformSelector: React.FunctionComponent = ({ fullCopyButton, onCopy, }) => { - const getInitialPlatform = useCallback(() => { + const { platform, setPlatform } = usePlatform(); + const [showExtendedPlatforms, setShowExtendedPlatforms] = useState(false); + + useEffect(() => { if ( hasK8sIntegration || (cloudSecurityIntegration?.integrationType === FLEET_CLOUD_SECURITY_POSTURE_KSPM_POLICY_TEMPLATE && isManaged) - ) - return 'kubernetes'; - - return 'linux'; - }, [hasK8sIntegration, cloudSecurityIntegration?.integrationType, isManaged]); - - const { platform, setPlatform } = usePlatform(getInitialPlatform()); + ) { + setPlatform('kubernetes'); + } + }, [hasK8sIntegration, cloudSecurityIntegration, isManaged, setPlatform]); - // In case of fleet server installation or standalone agent without - // Kubernetes integration in the policy use reduced platform options - // If it has Cloud Shell URL, then it should show platform options with Cloudshell in it - const isReduced = hasFleetServer || (!isManaged && !hasK8sIntegration); - - const getPlatformOptions = useCallback(() => { - const platformOptions = isReduced ? REDUCED_PLATFORM_OPTIONS : PLATFORM_OPTIONS; - - return platformOptions; - }, [isReduced]); + // Show K8 as a platform option if policy has K8s integration or is managed + const showK8 = !hasFleetServer && (isManaged || hasK8sIntegration); + const extendedPlatformOptions = [ + ...(showK8 ? [KUBERNETES_PLATFORM_OPTION] : []), + ...EXTENDED_PLATFORM_OPTIONS, + ]; + const extendedPlatforms = extendedPlatformOptions.map((option) => option.id); const [copyButtonClicked, setCopyButtonClicked] = useState(false); @@ -135,14 +131,6 @@ export const PlatformSelector: React.FunctionComponent = ({ /> ); - const commandsByPlatform: Record = { - linux: linuxCommand, - mac: macCommand, - windows: windowsCommand, - deb: linuxDebCommand, - rpm: linuxRpmCommand, - kubernetes: k8sCommand, - }; const onTextAreaClick = () => { if (onCopy) onCopy(); }; @@ -156,23 +144,75 @@ export const PlatformSelector: React.FunctionComponent = ({ <> <> {!hasK8sIntegrationMultiPage && ( - setPlatform(id as PLATFORM_TYPE)} - legend={i18n.translate('xpack.fleet.enrollmentInstructions.platformSelectAriaLabel', { - defaultMessage: 'Platform', + + > + {VISIBLE_PALFORM_OPTIONS.map((option) => ( + setPlatform(option.id)} + data-test-subj={option['data-test-subj']} + > + {option.label} + + ))} + setShowExtendedPlatforms(!showExtendedPlatforms)} + isSelected={showExtendedPlatforms} + hasActiveFilters={extendedPlatforms.includes(platform)} + numActiveFilters={extendedPlatforms.includes(platform) ? 1 : 0} + css={css` + .euiFilterButton__text { + min-inline-size: 0; + } + `} + > + … + + } + isOpen={showExtendedPlatforms} + closePopover={() => setShowExtendedPlatforms(false)} + panelPaddingSize="none" + repositionOnScroll={true} + > + ({ + key: option.id, + label: option.label, + checked: platform === option.id ? 'on' : undefined, + 'data-test-subj': option['data-test-subj'], + }))} + onChange={(_allOptions, _event, option) => setPlatform(option.key)} + style={{ width: 150 }} + listProps={{ paddingSize: 'none', onFocusBadge: false }} + > + {(list) => list} + + + )} - - {(platform === 'deb' || platform === 'rpm') && ( + + {['deb_aarch64', 'deb_x86_64', 'rpm_aarch64', 'rpm_x86_64'].includes(platform) && ( <> {systemPackageCallout} )} - {platform === 'mac' && + {['mac_aarch64', 'mac_x86_64'].includes(platform) && (cloudSecurityIntegration?.integrationType === FLEET_CLOUD_SECURITY_POSTURE_CSPM_POLICY_TEMPLATE || cloudSecurityIntegration?.integrationType === @@ -230,12 +270,12 @@ export const PlatformSelector: React.FunctionComponent = ({ `} whiteSpace="pre" > - {commandsByPlatform[platform]} + {installCommand[platform]} {fullCopyButton && ( - + {(copy) => ( = [ +} + +export const VISIBLE_PALFORM_OPTIONS: PLATFORM_OPTION[] = [ { - id: 'linux', + id: 'linux_aarch64', label: i18n.translate('xpack.fleet.enrollmentInstructions.platformButtons.linux', { - defaultMessage: 'Linux Tar', + defaultMessage: 'Linux aarch64', }), 'data-test-subj': 'platformTypeLinux', }, { - id: 'mac', + id: 'mac_aarch64', label: i18n.translate('xpack.fleet.enrollmentInstructions.platformButtons.mac', { - defaultMessage: 'Mac', + defaultMessage: 'MacOS aarch64', }), 'data-test-subj': 'platformTypeMac', }, { - id: 'windows', - label: i18n.translate('xpack.fleet.enrollmentInstructions.platformButtons.windows', { - defaultMessage: 'Windows', + id: 'deb_aarch64', + label: i18n.translate('xpack.fleet.enrollmentInstructions.platformButtons.linux.deb', { + defaultMessage: 'DEB aarch64', }), - 'data-test-subj': 'platformTypeWindows', + 'data-test-subj': 'platformTypeLinuxDeb', }, { - id: 'rpm', + id: 'rpm_aarch64', label: i18n.translate('xpack.fleet.enrollmentInstructions.platformButtons.linux.rpm', { - defaultMessage: 'RPM', + defaultMessage: 'RPM aarch64', }), 'data-test-subj': 'platformTypeLinuxRpm', }, +]; + +export const EXTENDED_PLATFORM_OPTIONS: PLATFORM_OPTION[] = [ { - id: 'deb', - label: i18n.translate('xpack.fleet.enrollmentInstructions.platformButtons.linux.deb', { - defaultMessage: 'DEB', + id: 'windows', + label: i18n.translate('xpack.fleet.enrollmentInstructions.platformButtons.windows', { + defaultMessage: 'Windows x86_64', }), - 'data-test-subj': 'platformTypeLinuxDeb', }, -]; - -export const PLATFORM_OPTIONS = [ - ...REDUCED_PLATFORM_OPTIONS, { - id: 'kubernetes', - label: i18n.translate('xpack.fleet.enrollmentInstructions.platformButtons.kubernetes', { - defaultMessage: 'Kubernetes', + id: 'linux_x86_64', + label: i18n.translate('xpack.fleet.enrollmentInstructions.platformButtons.linux', { + defaultMessage: 'Linux x86_64', }), - 'data-test-subj': 'platformTypeKubernetes', }, -]; - -export const PLATFORM_OPTIONS_CLOUD_SHELL = [ - ...PLATFORM_OPTIONS, { - id: 'googleCloudShell', - label: i18n.translate('xpack.fleet.enrollmentInstructions.platformButtons.googleCloudShell', { - defaultMessage: 'Google Cloud Shell Script', + id: 'mac_x86_64', + label: i18n.translate('xpack.fleet.enrollmentInstructions.platformButtons.mac', { + defaultMessage: 'MacOS x86_64', + }), + }, + { + id: 'deb_x86_64', + label: i18n.translate('xpack.fleet.enrollmentInstructions.platformButtons.linux.deb', { + defaultMessage: 'DEB x86_64', + }), + }, + { + id: 'rpm_x86_64', + label: i18n.translate('xpack.fleet.enrollmentInstructions.platformButtons.linux.rpm', { + defaultMessage: 'RPM x86_64', }), - 'data-test-subj': 'platformTypeGoogleCloudShellScript', }, ]; -export function usePlatform(initialPlatform: PLATFORM_TYPE = 'linux') { +export const KUBERNETES_PLATFORM_OPTION: PLATFORM_OPTION = { + id: 'kubernetes', + label: i18n.translate('xpack.fleet.enrollmentInstructions.platformButtons.kubernetes', { + defaultMessage: 'Kubernetes', + }), + 'data-test-subj': 'platformTypeKubernetes', +}; + +export function usePlatform(initialPlatform: PLATFORM_TYPE = 'linux_aarch64') { const [platform, setPlatform] = useState(initialPlatform); return {