Skip to content

Commit

Permalink
Merge branch 'main' into seanstory/4333-fix-multiple-pipeline-flow
Browse files Browse the repository at this point in the history
  • Loading branch information
seanstory authored Apr 25, 2023
2 parents 0acf51a + bfe5aee commit b881d4d
Show file tree
Hide file tree
Showing 164 changed files with 3,647 additions and 793 deletions.
1 change: 1 addition & 0 deletions .buildkite/scripts/build_kibana.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ if is_pr_with_label "ci:build-cloud-image"; then
--docker-push \
--skip-docker-ubi \
--skip-docker-ubuntu \
--skip-docker-serverless \
--skip-docker-contexts
docker logout docker.elastic.co

Expand Down
5 changes: 3 additions & 2 deletions .buildkite/scripts/steps/artifacts/docker_image.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,18 @@ node scripts/build \
--docker-images \
--docker-namespace="kibana-ci" \
--docker-tag="git-$GIT_ABBREV_COMMIT" \
--skip-docker-ubuntu \
--skip-docker-ubi \
--skip-docker-cloud \
--skip-docker-contexts

echo "--- Tag images"
docker rmi "$KIBANA_IMAGE"
docker load < "target/kibana-$BASE_VERSION-docker-image.tar.gz"
docker load < "target/kibana-serverless-$BASE_VERSION-docker-image.tar.gz"
docker tag "$KIBANA_IMAGE" "$KIBANA_IMAGE-amd64"

docker rmi "$KIBANA_IMAGE"
docker load < "target/kibana-$BASE_VERSION-docker-image-aarch64.tar.gz"
docker load < "target/kibana-serverless-$BASE_VERSION-docker-image-aarch64.tar.gz"
docker tag "$KIBANA_IMAGE" "$KIBANA_IMAGE-arm64"

echo "--- Push images"
Expand Down
1 change: 1 addition & 0 deletions .buildkite/scripts/steps/cloud/build_and_deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ else
--docker-push \
--skip-docker-ubi \
--skip-docker-ubuntu \
--skip-docker-serverless \
--skip-docker-contexts
fi

Expand Down
2 changes: 1 addition & 1 deletion .buildkite/scripts/steps/demo_env/kibana.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ source "$(dirname "${0}")/config.sh"
export KIBANA_IMAGE="gcr.io/elastic-kibana-184716/demo/kibana:$DEPLOYMENT_NAME-$(git rev-parse HEAD)"

echo '--- Build Kibana'
node scripts/build --debug --docker-images --example-plugins --skip-docker-ubi --skip-docker-cloud --skip-docker-contexts
node scripts/build --debug --docker-images --example-plugins --skip-docker-ubi --skip-docker-cloud --skip-docker-serverless --skip-docker-contexts

echo '--- Build Docker image with example plugins'
cd target/example_plugins
Expand Down
2 changes: 1 addition & 1 deletion .buildkite/scripts/steps/package_testing/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ set -euo pipefail

.buildkite/scripts/bootstrap.sh

node scripts/build --all-platforms --debug --skip-docker-cloud --skip-docker-ubi --skip-docker-contexts
node scripts/build --all-platforms --debug --skip-docker-cloud --skip-docker-serverless --skip-docker-ubi --skip-docker-contexts

DOCKER_FILE="kibana-$KIBANA_PKG_VERSION-SNAPSHOT-docker-image.tar.gz"

Expand Down
3 changes: 3 additions & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,9 @@ packages/core/usage-data/core-usage-data-base-server-internal @elastic/kibana-co
packages/core/usage-data/core-usage-data-server @elastic/kibana-core
packages/core/usage-data/core-usage-data-server-internal @elastic/kibana-core
packages/core/usage-data/core-usage-data-server-mocks @elastic/kibana-core
packages/core/user-settings/core-user-settings-server @elastic/platform-security
packages/core/user-settings/core-user-settings-server-internal @elastic/platform-security
packages/core/user-settings/core-user-settings-server-mocks @elastic/platform-security
x-pack/plugins/cross_cluster_replication @elastic/platform-deployment-management
packages/kbn-crypto @elastic/kibana-security
packages/kbn-crypto-browser @elastic/kibana-core
Expand Down
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,9 @@
"@kbn/core-usage-data-base-server-internal": "link:packages/core/usage-data/core-usage-data-base-server-internal",
"@kbn/core-usage-data-server": "link:packages/core/usage-data/core-usage-data-server",
"@kbn/core-usage-data-server-internal": "link:packages/core/usage-data/core-usage-data-server-internal",
"@kbn/core-user-settings-server": "link:packages/core/user-settings/core-user-settings-server",
"@kbn/core-user-settings-server-internal": "link:packages/core/user-settings/core-user-settings-server-internal",
"@kbn/core-user-settings-server-mocks": "link:packages/core/user-settings/core-user-settings-server-mocks",
"@kbn/cross-cluster-replication-plugin": "link:x-pack/plugins/cross_cluster_replication",
"@kbn/crypto": "link:packages/kbn-crypto",
"@kbn/crypto-browser": "link:packages/kbn-crypto-browser",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import type { InternalStatusServiceSetup } from '@kbn/core-status-server-interna
import type { InternalUiSettingsServiceSetup } from '@kbn/core-ui-settings-server-internal';
import type { InternalCoreUsageDataSetup } from '@kbn/core-usage-data-base-server-internal';
import type { InternalCustomBrandingSetup } from '@kbn/core-custom-branding-server-internal';
import type { InternalUserSettingsServiceSetup } from '@kbn/core-user-settings-server-internal';

/** @internal */
export interface InternalCoreSetup {
Expand All @@ -47,4 +48,5 @@ export interface InternalCoreSetup {
deprecations: InternalDeprecationsServiceSetup;
coreUsageData: InternalCoreUsageDataSetup;
customBranding: InternalCustomBrandingSetup;
userSettings: InternalUserSettingsServiceSetup;
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@
"@kbn/core-usage-data-base-server-internal",
"@kbn/core-usage-data-server",
"@kbn/core-custom-branding-server-internal",
"@kbn/core-custom-branding-server"
"@kbn/core-custom-branding-server",
"@kbn/core-user-settings-server-internal"
],
"exclude": [
"target/**/*",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import { executionContextServiceMock } from '@kbn/core-execution-context-server-
import { coreUsageDataServiceMock } from '@kbn/core-usage-data-server-mocks';
import { customBrandingServiceMock } from '@kbn/core-custom-branding-server-mocks';
import { createCoreStartMock } from './core_start.mock';
import { userSettingsServiceMock } from '@kbn/core-user-settings-server-mocks';

type CoreSetupMockType = MockedKeys<CoreSetup> & {
elasticsearch: ReturnType<typeof elasticsearchServiceMock.createSetup>;
Expand Down Expand Up @@ -53,6 +54,7 @@ export function createCoreSetupMock({
analytics: analyticsServiceMock.createAnalyticsServiceSetup(),
capabilities: capabilitiesServiceMock.createSetupContract(),
customBranding: customBrandingServiceMock.createSetupContract(),
userSettings: userSettingsServiceMock.createSetupContract(),
docLinks: docLinksServiceMock.createSetupContract(),
elasticsearch: elasticsearchServiceMock.createSetup(),
http: httpMock,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import { statusServiceMock } from '@kbn/core-status-server-mocks';
import { uiSettingsServiceMock } from '@kbn/core-ui-settings-server-mocks';
import { coreUsageDataServiceMock } from '@kbn/core-usage-data-server-mocks';
import { customBrandingServiceMock } from '@kbn/core-custom-branding-server-mocks';
import { userSettingsServiceMock } from '@kbn/core-user-settings-server-mocks';

export function createInternalCoreSetupMock() {
const setupDeps = {
Expand All @@ -47,6 +48,7 @@ export function createInternalCoreSetupMock() {
executionContext: executionContextServiceMock.createInternalSetupContract(),
coreUsageData: coreUsageDataServiceMock.createSetupContract(),
customBranding: customBrandingServiceMock.createSetupContract(),
userSettings: userSettingsServiceMock.createSetupContract(),
};
return setupDeps;
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
"@kbn/core-http-request-handler-context-server",
"@kbn/core-logging-server-mocks",
"@kbn/core-custom-branding-server-mocks",
"@kbn/core-user-settings-server-mocks",
],
"exclude": [
"target/**/*",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import { StatusServiceSetup } from '@kbn/core-status-server';
import { UiSettingsServiceSetup } from '@kbn/core-ui-settings-server';
import { CoreUsageDataSetup } from '@kbn/core-usage-data-server';
import { CustomBrandingSetup } from '@kbn/core-custom-branding-server';
import { UserSettingsServiceSetup } from '@kbn/core-user-settings-server';
import { CoreStart } from './core_start';

/**
Expand Down Expand Up @@ -64,6 +65,8 @@ export interface CoreSetup<TPluginsStart extends object = object, TStart = unkno
status: StatusServiceSetup;
/** {@link UiSettingsServiceSetup} */
uiSettings: UiSettingsServiceSetup;
/** {@link UserSettingsServiceSetup} */
userSettings: UserSettingsServiceSetup;
/** {@link DeprecationsServiceSetup} */
deprecations: DeprecationsServiceSetup;
/** {@link StartServicesAccessor} */
Expand Down
3 changes: 2 additions & 1 deletion packages/core/lifecycle/core-lifecycle-server/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@
"@kbn/core-status-server",
"@kbn/core-ui-settings-server",
"@kbn/core-usage-data-server",
"@kbn/core-custom-branding-server"
"@kbn/core-custom-branding-server",
"@kbn/core-user-settings-server"
],
"exclude": [
"target/**/*",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,9 @@ export function createPluginSetupContext<TPlugin, TPluginDependencies>(
register: deps.uiSettings.register,
registerGlobal: deps.uiSettings.registerGlobal,
},
userSettings: {
setUserProfileSettings: deps.userSettings.setUserProfileSettings,
},
getStartServices: () => plugin.startDependencies,
deprecations: deps.deprecations.getRegistry(plugin.name),
coreUsageData: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import type { UiPlugins } from '@kbn/core-plugins-base-server-internal';
import { httpServiceMock, httpServerMock } from '@kbn/core-http-server-mocks';
import { uiSettingsServiceMock } from '@kbn/core-ui-settings-server-mocks';
import { bootstrapRendererFactory, BootstrapRenderer } from './bootstrap_renderer';
import { userSettingsServiceMock } from '@kbn/core-user-settings-server-mocks';

const createPackageInfo = (parts: Partial<PackageInfo> = {}): PackageInfo => ({
branch: 'master',
Expand All @@ -41,12 +42,14 @@ describe('bootstrapRenderer', () => {
let renderer: BootstrapRenderer;
let uiPlugins: UiPlugins;
let packageInfo: PackageInfo;
let userSettingsService: ReturnType<typeof userSettingsServiceMock.createSetupContract>;

beforeEach(() => {
auth = httpServiceMock.createAuth();
uiSettingsClient = uiSettingsServiceMock.createClient();
uiPlugins = createUiPlugins();
packageInfo = createPackageInfo();
userSettingsService = userSettingsServiceMock.createSetupContract();

getThemeTagMock.mockReturnValue('v8light');
getPluginsBundlePathsMock.mockReturnValue(new Map());
Expand Down Expand Up @@ -88,7 +91,7 @@ describe('bootstrapRenderer', () => {
expect(uiSettingsClient.get).toHaveBeenCalledWith('theme:darkMode');
});

it('calls getThemeTag with the correct parameters', async () => {
it('calls getThemeTag with the values from the UiSettingsClient when the UserSettingsService is not provided', async () => {
uiSettingsClient.get.mockResolvedValue(true);

const request = httpServerMock.createKibanaRequest();
Expand All @@ -104,6 +107,58 @@ describe('bootstrapRenderer', () => {
darkMode: true,
});
});

it('calls getThemeTag with values from the UserSettingsService when provided', async () => {
userSettingsService.getUserSettingDarkMode.mockReturnValueOnce(true);

renderer = bootstrapRendererFactory({
auth,
packageInfo,
uiPlugins,
serverBasePath: '/base-path',
userSettingsService,
});

uiSettingsClient.get.mockResolvedValue(false);
const request = httpServerMock.createKibanaRequest();

await renderer({
request,
uiSettingsClient,
});

expect(getThemeTagMock).toHaveBeenCalledTimes(1);
expect(getThemeTagMock).toHaveBeenCalledWith({
themeVersion: 'v8',
darkMode: true,
});
});

it('calls getThemeTag with values from the UiSettingsClient when values from UserSettingsService are `undefined`', async () => {
userSettingsService.getUserSettingDarkMode.mockReturnValueOnce(undefined);

renderer = bootstrapRendererFactory({
auth,
packageInfo,
uiPlugins,
serverBasePath: '/base-path',
userSettingsService,
});

uiSettingsClient.get.mockResolvedValue(false);
const request = httpServerMock.createKibanaRequest();

await renderer({
request,
uiSettingsClient,
});

expect(getThemeTagMock).toHaveBeenCalledTimes(1);
expect(getThemeTagMock).toHaveBeenCalledWith({
themeVersion: 'v8',
darkMode: false,
});
});
});

describe('when the auth status is `unknown`', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { ThemeVersion } from '@kbn/ui-shared-deps-npm';
import type { KibanaRequest, HttpAuth } from '@kbn/core-http-server';
import type { IUiSettingsClient } from '@kbn/core-ui-settings-server';
import type { UiPlugins } from '@kbn/core-plugins-base-server-internal';
import { InternalUserSettingsServiceSetup } from '@kbn/core-user-settings-server-internal';
import { getPluginsBundlePaths } from './get_plugin_bundle_paths';
import { getJsDependencyPaths } from './get_js_dependency_paths';
import { getThemeTag } from './get_theme_tag';
Expand All @@ -25,6 +26,7 @@ interface FactoryOptions {
packageInfo: PackageInfo;
uiPlugins: UiPlugins;
auth: HttpAuth;
userSettingsService?: InternalUserSettingsServiceSetup;
}

interface RenderedOptions {
Expand All @@ -43,6 +45,7 @@ export const bootstrapRendererFactory: BootstrapRendererFactory = ({
serverBasePath,
uiPlugins,
auth,
userSettingsService,
}) => {
const isAuthenticated = (request: KibanaRequest) => {
const { status: authStatus } = auth.get(request);
Expand All @@ -56,7 +59,16 @@ export const bootstrapRendererFactory: BootstrapRendererFactory = ({

try {
const authenticated = isAuthenticated(request);
darkMode = authenticated ? await uiSettingsClient.get('theme:darkMode') : false;

if (authenticated) {
const userSettingDarkMode = await userSettingsService?.getUserSettingDarkMode(request);

if (userSettingDarkMode) {
darkMode = userSettingDarkMode;
} else {
darkMode = await uiSettingsClient.get('theme:darkMode');
}
}
} catch (e) {
// just use the default values in case of connectivity issues with ES
}
Expand Down
Loading

0 comments on commit b881d4d

Please sign in to comment.