Skip to content

Commit

Permalink
Updated integration configs to json5
Browse files Browse the repository at this point in the history
  • Loading branch information
devesh-2002 committed Apr 30, 2024
1 parent cdba076 commit 5c93001
Show file tree
Hide file tree
Showing 5 changed files with 106 additions and 217 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
{
name: "apache",
version: "1.0.0",
displayName: "Apache Access Logs",
description: "Insights on applications using the standard Apache access log format.",
license: "Apache-2.0",
type: "logs_apache",
labels: ["Observability", "Logs", "Flint S3"],
author: "OpenSearch",
sourceUrl: "https://github.com/opensearch-project/dashboards-observability/tree/main/server/adaptors/integrations/__data__/repository/apache/info",
workflows: [
{
name: "queries",
label: "Queries (recommended)",
description: "Tables and pre-written queries for quickly getting insights on your data.",
enabled_by_default: true
},
{
name: "dashboards",
label: "Dashboards & Visualizations",
description: "Dashboards and indices that enable you to easily visualize important metrics.",
enabled_by_default: false
}
],
statics: {
logo: {
annotation: "Apache Logo",
path: "logo.png"
},
gallery: [
{
annotation: "Apache Dashboard",
path: "dashboard1.png"
}
]
},
components: [
{ name: "communication", version: "1.0.0" },
{ name: "http", version: "1.0.0" },
{ name: "logs_apache", version: "1.0.0" }
],
assets: [
{ name: "apache", version: "1.0.0", extension: "ndjson", type: "savedObjectBundle", workflows: ["dashboards"] },
{ name: "example_queries", version: "1.0.0", extension: "ndjson", type: "savedObjectBundle", workflows: ["queries"] },
{ name: "create_table", version: "1.0.0", extension: "sql", type: "query" },
{ name: "create_mv", version: "1.0.0", extension: "sql", type: "query", workflows: ["dashboards"] }
],
sampleData: {
path: "sample.json"
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
{
name: "nginx",
version: "1.0.0",
displayName: "Nginx",
description: "Analyze Nginx access logs.",
license: "Apache-2.0",
type: "logs",
labels: ["Observability", "Logs", "Flint S3"],
author: "OpenSearch",
sourceUrl: "https://github.com/opensearch-project/dashboards-observability/tree/main/server/adaptors/integrations/__data__/repository/nginx/info",
workflows: [
{
name: "queries",
label: "Queries (recommended)",
description: "Tables and pre-written queries for quickly getting insights on your data.",
enabled_by_default: true
},
{
name: "dashboards",
label: "Dashboards & Visualizations",
description: "Dashboards and indices that enable you to easily visualize important metrics.",
enabled_by_default: false
}
],
statics: {
logo: {
annotation: "NginX Logo",
path: "logo.svg"
},
gallery: [
{
annotation: "NginX Dashboard",
path: "dashboard1.png"
},
{
annotation: "NginX Dashboard view",
path: "dashboard2.png"
}
]
},
components: [
{ name: "communication", version: "1.0.0" },
{ name: "http", version: "1.0.0" },
{ name: "logs", version: "1.0.0" }
],
assets: [
{ name: "nginx", version: "1.0.0", extension: "ndjson", type: "savedObjectBundle", workflows: ["dashboards"] },
{ name: "create_table", version: "1.0.0", extension: "sql", type: "query" },
{ name: "create_mv", version: "1.0.0", extension: "sql", type: "query", workflows: ["dashboards"] },
{ name: "example_queries", version: "1.0.0", extension: "ndjson", type: "savedObjectBundle", workflows: ["queries"] }
],
sampleData: {
path: "sample.json"
}
}
47 changes: 0 additions & 47 deletions server/adaptors/integrations/__test__/local_fs_repository.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,50 +68,3 @@ describe('Local Nginx Integration', () => {
);
});
});
describe('JSON5 Integration', () => {
const dataDirectory: string = path.join(__dirname, '../__data__/repository');
const fileSystemAdaptor: FileSystemDataAdaptor = new FileSystemDataAdaptor(dataDirectory);
let files: string[];

beforeAll(async () => {
files = await fs.readdir(dataDirectory);
});

it('Should parse valid JSON5 content without errors', async () => {
if (!files) {
throw new Error('File list not initialized');
}

await Promise.all(
files.map(async (filename: string) => {
const filePath: string = path.join(dataDirectory, filename);
try {
const result = await fileSystemAdaptor.readFile(filename);
expect(result.ok).toBe(true);
expect(result.value).toEqual({ key: 'value' });
} catch (error) {
console.error(`Error reading file ${filePath}:`, error);
}
})
);
});

it('Should handle errors when parsing invalid JSON5 content', async () => {
if (!files) {
throw new Error('File list not initialized');
}

await Promise.all(
files.map(async (filename: string) => {
const filePath: string = path.join(dataDirectory, filename);
try {
const result = await fileSystemAdaptor.readFile(filename);
expect(result.ok).toBe(false);
expect(result.error).toBeDefined();
} catch (error) {
console.error(`Error reading file ${filePath}:`, error);
}
})
);
});
});

0 comments on commit 5c93001

Please sign in to comment.