Skip to content

Commit

Permalink
merge main
Browse files Browse the repository at this point in the history
Signed-off-by: gaobinlong <gbinlong@amazon.com>
  • Loading branch information
gaobinlong committed Apr 3, 2024
2 parents 007042f + 7352365 commit accfda0
Show file tree
Hide file tree
Showing 39 changed files with 1,100 additions and 122 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
- [Workspace] Add update workspace page ([#6270](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/6270))
- [Multiple Datasource] Make sure customer always have a default datasource ([#6237](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/6237))
- [Workspace] Add workspace list page ([#6182](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/6182))

- [Workspace] Add workspaces column to saved objects page ([#6225](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/6225))
- [Multiple Datasource] Add multi data source support to sample vega visualizations ([#6218](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/6218))

### 🐛 Bug Fixes

Expand All @@ -93,6 +94,8 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
- [BUG][Multiple Datasource] Fix data source filter bug and add tests ([#6152](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/6152))
- [BUG][Multiple Datasource] Fix obsolete snapshots for test within data source management plugin ([#6185](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/6185))
- [Workspace] Add base path when parse url in http service ([#6233](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/6233))
- [Multiple Datasource] Fix sslConfig for multiple datasource to handle when certificateAuthorities is unset ([#6282](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/6282))
- [BUG][Multiple Datasource]Fix bug in data source aggregated view to change it to depend on displayAllCompatibleDataSources property to show the badge value ([#6291](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/6291))

### 🚞 Infrastructure

Expand Down Expand Up @@ -124,6 +127,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
### 🪛 Refactoring

- Remove unused Sass in `tile_map` plugin ([#4110](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/4110))
- [Multiple Datasource] Move data source selectable to its own folder, fix test and a few type errors for data source selectable component ([#6287](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/6287))

### 🔩 Tests

Expand Down
2 changes: 2 additions & 0 deletions src/core/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,8 @@ export {
importSavedObjectsFromStream,
resolveSavedObjectsImportErrors,
SavedObjectsDeleteByWorkspaceOptions,
updateDataSourceNameInVegaSpec,
extractVegaSpecFromSavedObject,
} from './saved_objects';

export {
Expand Down
1 change: 1 addition & 0 deletions src/core/server/saved_objects/import/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,4 @@ export {
SavedObjectsResolveImportErrorsOptions,
SavedObjectsImportRetry,
} from './types';
export { updateDataSourceNameInVegaSpec, extractVegaSpecFromSavedObject } from './utils';
12 changes: 11 additions & 1 deletion src/core/server/saved_objects/import/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,24 @@
import { parse, stringify } from 'hjson';
import { SavedObject, SavedObjectsClientContract } from '../types';

/**
* Given a Vega spec, the new datasource (by name), and spacing, update the Vega spec to add the new datasource name to each local cluster query
*
* @param {string} spec - the stringified Vega spec (HJSON or JSON)
* @param {string} newDataSourceName - the datasource name to append
* @param {number} [spacing=2] - how large the indenting should be after updating the spec (should be set to > 0 for a readable spec)
*/
export interface UpdateDataSourceNameInVegaSpecProps {
spec: string;
newDataSourceName: string;
spacing?: number;
}

export const updateDataSourceNameInVegaSpec = (
props: UpdateDataSourceNameInVegaSpecProps
): string => {
const { spec } = props;
const { spec, spacing } = props;
const stringifiedSpacing = spacing || 2;

let parsedSpec = parseJSONSpec(spec);
const isJSONString = !!parsedSpec;
Expand All @@ -39,6 +48,7 @@ export const updateDataSourceNameInVegaSpec = (
: stringify(parsedSpec, {
bracesSameLine: true,
keepWsc: true,
space: stringifiedSpacing,
});
};

Expand Down
29 changes: 28 additions & 1 deletion src/plugins/data_source/server/client/client_config.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ describe('parseClientOptions', () => {
ssl: {
requestCert: true,
rejectUnauthorized: false,
ca: [],
ca: undefined,
},
})
);
Expand Down Expand Up @@ -109,4 +109,31 @@ describe('parseClientOptions', () => {
})
);
});

test('test ssl config with verification mode set to full with no ca list', () => {
const config = {
enabled: true,
ssl: {
verificationMode: 'full',
},
clientPool: {
size: 5,
},
} as DataSourcePluginConfigType;
mockReadFileSync.mockReset();
mockReadFileSync.mockImplementation((path: string) => `content-of-${path}`);
const parsedConfig = parseClientOptions(config, TEST_DATA_SOURCE_ENDPOINT);
expect(mockReadFileSync).toHaveBeenCalledTimes(0);
mockReadFileSync.mockClear();
expect(parsedConfig).toEqual(
expect.objectContaining({
node: TEST_DATA_SOURCE_ENDPOINT,
ssl: {
requestCert: true,
rejectUnauthorized: true,
ca: undefined,
},
})
);
});
});
2 changes: 1 addition & 1 deletion src/plugins/data_source/server/client/client_config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export function parseClientOptions(
config.ssl?.certificateAuthorities
);

sslConfig.ca = certificateAuthorities || [];
sslConfig.ca = certificateAuthorities;
}

const clientOptions: ClientOptions = {
Expand Down
28 changes: 27 additions & 1 deletion src/plugins/data_source/server/legacy/client_config.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ describe('parseClientOptions', () => {
host: TEST_DATA_SOURCE_ENDPOINT,
ssl: {
rejectUnauthorized: false,
ca: [],
ca: undefined,
},
})
);
Expand Down Expand Up @@ -105,4 +105,30 @@ describe('parseClientOptions', () => {
})
);
});

test('test ssl config with verification mode set to full with no ca list', () => {
const config = {
enabled: true,
ssl: {
verificationMode: 'full',
},
clientPool: {
size: 5,
},
} as DataSourcePluginConfigType;
mockReadFileSync.mockReset();
mockReadFileSync.mockImplementation((path: string) => `content-of-${path}`);
const parsedConfig = parseClientOptions(config, TEST_DATA_SOURCE_ENDPOINT);
expect(mockReadFileSync).toHaveBeenCalledTimes(0);
mockReadFileSync.mockClear();
expect(parsedConfig).toEqual(
expect.objectContaining({
host: TEST_DATA_SOURCE_ENDPOINT,
ssl: {
rejectUnauthorized: true,
ca: undefined,
},
})
);
});
});
2 changes: 1 addition & 1 deletion src/plugins/data_source/server/legacy/client_config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export function parseClientOptions(
config.ssl?.certificateAuthorities
);

sslConfig.ca = certificateAuthorities || [];
sslConfig.ca = certificateAuthorities;
}

const configOptions: ConfigOptions = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ describe('readCertificateAuthorities', () => {
expect(mockReadFileSync).toHaveBeenCalledTimes(0);
mockReadFileSync.mockClear();
expect(certificateAuthorities).toEqual({
certificateAuthorities: [],
certificateAuthorities: undefined,
});
});

Expand All @@ -52,7 +52,7 @@ describe('readCertificateAuthorities', () => {
expect(mockReadFileSync).toHaveBeenCalledTimes(0);
mockReadFileSync.mockClear();
expect(certificateAuthorities).toEqual({
certificateAuthorities: [],
certificateAuthorities: undefined,
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { readFileSync } from 'fs';
export const readCertificateAuthorities = (
listOfCertificateAuthorities: string | string[] | undefined
) => {
let certificateAuthorities: string[] | undefined = [];
let certificateAuthorities: string[] | undefined;

const addCertificateAuthorities = (ca: string[]) => {
if (ca && ca.length) {
Expand Down
Loading

0 comments on commit accfda0

Please sign in to comment.