Skip to content

Commit 9a5ab4f

Browse files
committed
feat: update S3 key handling for fleet agent downloads
- Modified the S3 key construction in getFleetAgent functions to use specific package filenames for macOS and Windows, improving clarity and ensuring the correct files are retrieved. - Introduced constants for package filenames to enhance maintainability and readability of the code.
1 parent af9f1c3 commit 9a5ab4f

3 files changed

Lines changed: 9 additions & 3 deletions

File tree

apps/app/src/app/s3.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,14 +137,15 @@ export function extractS3KeyFromUrl(url: string): string {
137137

138138
export async function getFleetAgent({ os }: { os: 'macos' | 'windows' | 'linux' }) {
139139
const fleetBucketName = process.env.FLEET_AGENT_BUCKET_NAME;
140+
const fleetAgentFileName = 'Comp AI Agent-1.0.0-arm64.dmg';
140141

141142
if (!fleetBucketName) {
142143
throw new Error('FLEET_AGENT_BUCKET_NAME is not defined.');
143144
}
144145

145146
const getFleetAgentCommand = new GetObjectCommand({
146147
Bucket: fleetBucketName,
147-
Key: `${os}/fleet-osquery.pkg`,
148+
Key: `${os}/${fleetAgentFileName}`,
148149
});
149150

150151
const response = await s3Client.send(getFleetAgentCommand);

apps/portal/src/app/api/download-agent/route.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,9 @@ export async function GET(req: NextRequest) {
9292

9393
// Get package from S3 and stream it
9494
const packageFilename = getPackageFilename(os);
95-
const packageKey = `${os}/fleet-osquery.${os === 'macos' ? 'pkg' : 'msi'}`;
95+
const macosPackageFilename = 'Comp AI Agent-1.0.0-arm64.dmg';
96+
const windowsPackageFilename = 'fleet-osquery.msi';
97+
const packageKey = `${os}/${os === 'macos' ? macosPackageFilename : windowsPackageFilename}`;
9698

9799
const getObjectCommand = new GetObjectCommand({
98100
Bucket: fleetBucketName,

apps/portal/src/utils/s3.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,9 +132,12 @@ export async function getFleetAgent({ os }: { os: 'macos' | 'windows' }) {
132132
throw new Error(`Unsupported OS: ${os}`);
133133
}
134134

135+
const macosPackageFilename = 'Comp AI Agent-1.0.0-arm64.dmg';
136+
const windowsPackageFilename = 'fleet-osquery.msi';
137+
135138
const getFleetAgentCommand = new GetObjectCommand({
136139
Bucket: fleetBucketName,
137-
Key: `${os}/fleet-osquery.${extension}`,
140+
Key: `${os}/${os === 'macos' ? macosPackageFilename : windowsPackageFilename}`,
138141
});
139142

140143
const response = await s3Client.send(getFleetAgentCommand);

0 commit comments

Comments
 (0)