Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 12 additions & 5 deletions tools/integration/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -646,6 +646,7 @@ async function handleImport(argv: any) {
}

const defaultFolders = ['dashboards'];
const defaultEventsFolders = ['events'];

// Create an axios instance with a custom httpsAgent to ignore self-signed certificate errors
const axiosInstance = axios.create({
Expand All @@ -654,7 +655,7 @@ async function handleImport(argv: any) {
})
});

async function importIntegration(searchPattern: string) {
async function importIntegration(searchPattern: string, apiPath: string) {
const files = globSync(searchPattern);

logger.info(`Start to import the integration package from ${searchPattern}`);
Expand Down Expand Up @@ -694,10 +695,12 @@ async function handleImport(argv: any) {
continue; // Continue with the next file
}

ensureAccessRules(jsonContent)
if (apiPath === 'api/custom-dashboard') {
ensureAccessRules(jsonContent)
}

try {
const url = `https://${server}/api/custom-dashboard`
const url = `https://${server}/${apiPath}`
logger.info(`Applying the dashboard to ${url} ...`);

const response = await axiosInstance.post(url, jsonContent, {
Expand Down Expand Up @@ -727,11 +730,15 @@ async function handleImport(argv: any) {

if (includePattern) {
const searchPattern = path.join(packagePath, includePattern);
await importIntegration(searchPattern);
await importIntegration(searchPattern, "api/custom-dashboard");
} else {
for (const defaultFolder of defaultFolders) {
const searchPattern = path.join(packagePath, defaultFolder, '**/*.json');
await importIntegration(searchPattern);
await importIntegration(searchPattern, "api/custom-dashboard");
}
for (const defaultFolder of defaultEventsFolders) {
const searchPattern = path.join(packagePath, defaultFolder, '**/*.json');
await importIntegration(searchPattern, "api/events/settings/event-specifications/custom");
}
}
}
Expand Down