Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
149 additions
and
121 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import { getIsCloudEnabled } from './is_cloud_enabled'; | ||
|
||
const MOCK_CLOUD_ID_STAGING = | ||
'staging:dXMtZWFzdC0xLmF3cy5mb3VuZC5pbyRjZWM2ZjI2MWE3NGJmMjRjZTMzYmI4ODExYjg0Mjk0ZiRjNmMyY2E2ZDA0MjI0OWFmMGNjN2Q3YTllOTYyNTc0Mw=='; | ||
const MOCK_CLOUD_ID_PROD = | ||
'dXMtZWFzdC0xLmF3cy5mb3VuZC5pbyRjZWM2ZjI2MWE3NGJmMjRjZTMzYmI4ODExYjg0Mjk0ZiRjNmMyY2E2ZDA0MjI0OWFmMGNjN2Q3YTllOTYyNTc0Mw=='; | ||
|
||
describe('getIsCloudEnabled', () => { | ||
it('returns `false` if `id` is not undefined', async () => { | ||
const cloudId = undefined; | ||
const isCloudEnabled = getIsCloudEnabled(cloudId); | ||
expect(isCloudEnabled).toBe(false); | ||
}); | ||
|
||
it('returns `false` if `id` is not a string', async () => { | ||
const cloudId = 123 as any; | ||
const isCloudEnabled = getIsCloudEnabled(cloudId); | ||
expect(isCloudEnabled).toBe(false); | ||
}); | ||
|
||
it('returns `true` if `id` is a string', async () => { | ||
const isCloudEnabledStaging = getIsCloudEnabled(MOCK_CLOUD_ID_STAGING); | ||
const isCloudEnabledProd = getIsCloudEnabled(MOCK_CLOUD_ID_PROD); | ||
expect(isCloudEnabledStaging).toBe(true); | ||
expect(isCloudEnabledProd).toBe(true); | ||
}); | ||
}); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
export function getIsCloudEnabled(cloudId?: string) { | ||
return typeof cloudId === 'string'; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import { PluginInitializerContext } from '../../../../src/core/public'; | ||
import { CloudPlugin } from './plugin'; | ||
|
||
export { CloudSetup } from './plugin'; | ||
export function plugin(initializerContext: PluginInitializerContext) { | ||
return new CloudPlugin(initializerContext); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import { | ||
CoreSetup, | ||
Plugin, | ||
PluginInitializerContext, | ||
} from 'src/core/public'; | ||
import { getIsCloudEnabled } from '../common/is_cloud_enabled'; | ||
|
||
interface CloudConfigType { | ||
id?: string; | ||
} | ||
|
||
export interface CloudSetup { | ||
cloudId?: string; | ||
isCloudEnabled: boolean; | ||
} | ||
|
||
export class CloudPlugin implements Plugin<CloudSetup> { | ||
constructor(private readonly initializerContext: PluginInitializerContext) {} | ||
|
||
public async setup(core: CoreSetup) { | ||
const { id } = this.initializerContext.config.get<CloudConfigType>(); | ||
const isCloudEnabled = getIsCloudEnabled(id); | ||
|
||
return { | ||
cloudId: id, | ||
isCloudEnabled, | ||
} | ||
} | ||
|
||
public start() {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters