Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[pull] main from elastic:main #833

Merged
merged 13 commits into from
Dec 30, 2024
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
apiVersion: backstage.io/v1alpha1
kind: Resource
metadata:
name: bk-kibana-package-registry-promote
name: bk-kibana-package-registry-verify-and-promote
description: Promote package-registry/distribution:lite
links:
- url: 'https://buildkite.com/elastic/kibana-package-registry-promote'
- url: 'https://buildkite.com/elastic/kibana-package-registry-verify-and-promote'
title: Pipeline link
spec:
type: buildkite-pipeline
Expand All @@ -15,18 +15,21 @@ spec:
apiVersion: buildkite.elastic.dev/v1
kind: Pipeline
metadata:
name: kibana / package registry promote
description: Promote package-registry/distribution:lite
name: kibana / package registry verify and promote
description: Verify and promote docker.elastic.co/package-registry/distribution:lite
spec:
env:
SLACK_NOTIFICATIONS_CHANNEL: "#kibana-operations-alerts"
ELASTIC_SLACK_NOTIFICATIONS_ENABLED: "false"
ELASTIC_SLACK_NOTIFICATIONS_ENABLED: "true"
repository: elastic/kibana
branch_configuration: main
default_branch: main
pipeline_file: ".buildkite/pipelines/fleet/package_registry.yml"
provider_settings:
trigger_mode: none
schedules:
Daily promotion:
cronline: 0 22 * * * America/New_York
teams:
everyone:
access_level: BUILD_AND_READ
Expand Down
70 changes: 69 additions & 1 deletion .buildkite/pipelines/fleet/package_registry.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,70 @@
env:
IGNORE_SHIP_CI_STATS_ERROR: 'true'
steps:
- command: echo "Placeholder"
- command: .buildkite/scripts/lifecycle/pre_build.sh
label: Pre-Build
timeout_in_minutes: 10
agents:
image: family/kibana-ubuntu-2004
imageProject: elastic-images-prod
provider: gcp
machineType: n2-standard-2

- wait

- command: .buildkite/scripts/steps/build_kibana.sh
label: Build Kibana Distribution
agents:
image: family/kibana-ubuntu-2004
imageProject: elastic-images-prod
provider: gcp
machineType: n2-standard-8
preemptible: true
key: build
if: "build.env('KIBANA_BUILD_ID') == null || build.env('KIBANA_BUILD_ID') == ''"
timeout_in_minutes: 60
retry:
automatic:
- exit_status: '-1'
limit: 3

- command: .buildkite/scripts/steps/test/pick_test_group_run_order.sh
label: 'Pick Test Group Run Order'
agents:
image: family/kibana-ubuntu-2004
imageProject: elastic-images-prod
provider: gcp
machineType: n2-standard-2
timeout_in_minutes: 10
env:
JEST_UNIT_SCRIPT: '.buildkite/scripts/steps/test/jest.sh'
JEST_INTEGRATION_SCRIPT: '.buildkite/scripts/steps/test/jest_integration.sh'
FTR_CONFIGS_SCRIPT: '.buildkite/scripts/steps/test/ftr_configs.sh'
LIMIT_CONFIG_TYPE: integration,functional
retry:
automatic:
- exit_status: '*'
limit: 1

- command: .buildkite/scripts/steps/fleet/promote_package_registry.sh
label: Promote docker.elastic.co/package-registry/distribution:lite
agents:
image: family/kibana-ubuntu-2004
imageProject: elastic-images-prod
provider: gcp
machineType: n2-standard-2
depends_on:
- ftr-configs
- jest-integration

- wait: ~
continue_on_failure: true

- command: .buildkite/scripts/lifecycle/post_build.sh
label: Post-Build
timeout_in_minutes: 10
agents:
image: family/kibana-ubuntu-2004
imageProject: elastic-images-prod
provider: gcp
machineType: n2-standard-2
22 changes: 22 additions & 0 deletions .buildkite/scripts/steps/fleet/promote_package_registry.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/bash

set -euo pipefail

PACKAGE_REGISTRY_BASE_IMAGE='docker.elastic.co/package-registry/distribution:lite'
PACKAGE_REGISTRY_TARGET_IMAGE='docker.elastic.co/kibana-ci/package-registry-distribution:lite'

if [[ "$BUILDKITE_BRANCH" == "main" ]]; then
docker buildx imagetools create -t "$PACKAGE_REGISTRY_TARGET_IMAGE" "$PACKAGE_REGISTRY_BASE_IMAGE"
cat << EOF | buildkite-agent pipeline upload
steps:
- label: "Update cache for EPR image"
trigger: kibana-vm-images
async: true
build:
env:
IMAGES_CONFIG="kibana/images.yml"
RETRY="1"
EOF
else
echo "Skipping promotion for untracked branch $BUILDKITE_BRANCH"
fi
4 changes: 2 additions & 2 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ jobs:
echo "CHECKOUT_SHA=$(git rev-parse HEAD)" >> "$GITHUB_ENV"

- name: Set experimental environment variable for 8.x branch
if: env.CHECKOUT_REF == 'refs/heads/8.x'
run: echo "CODEQL_EXTRACTOR_JAVASCRIPT_OPTION_SKIP_TYPES=true" >> "$GITHUB_ENV"
if: env.CHECKOUT_REF == 'refs/heads/8.x'
run: echo "CODEQL_EXTRACTOR_JAVASCRIPT_OPTION_SKIP_TYPES=true" >> "$GITHUB_ENV"

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@883d8588e56d1753a8a58c1c86e88976f0c23449 # v3.26.3
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,13 @@

import type { HttpStart } from '@kbn/core-http-browser';
import type { UsageCollectionStart } from '@kbn/usage-collection-plugin/public';
import type { UserProfileServiceStart } from '@kbn/core-user-profile-browser';
import type {
GetFavoritesResponse as GetFavoritesResponseServer,
AddFavoriteResponse,
GetFavoritesResponse as GetFavoritesResponseServer,
RemoveFavoriteResponse,
} from '@kbn/content-management-favorites-server';
import { firstValueFrom } from 'rxjs';

export interface GetFavoritesResponse<Metadata extends object | void = void>
extends GetFavoritesResponseServer {
Expand All @@ -29,6 +31,7 @@ export interface FavoritesClientPublic<Metadata extends object | void = void> {
addFavorite(params: AddFavoriteRequest<Metadata>): Promise<AddFavoriteResponse>;
removeFavorite(params: { id: string }): Promise<RemoveFavoriteResponse>;

isAvailable(): Promise<boolean>;
getFavoriteType(): string;
reportAddFavoriteClick(): void;
reportRemoveFavoriteClick(): void;
Expand All @@ -40,21 +43,37 @@ export class FavoritesClient<Metadata extends object | void = void>
constructor(
private readonly appName: string,
private readonly favoriteObjectType: string,
private readonly deps: { http: HttpStart; usageCollection?: UsageCollectionStart }
private readonly deps: {
http: HttpStart;
userProfile: UserProfileServiceStart;
usageCollection?: UsageCollectionStart;
}
) {}

public async isAvailable(): Promise<boolean> {
return firstValueFrom(this.deps.userProfile.getEnabled$());
}

private async ifAvailablePreCheck() {
if (!(await this.isAvailable()))
throw new Error('Favorites service is not available for current user');
}

public async getFavorites(): Promise<GetFavoritesResponse<Metadata>> {
await this.ifAvailablePreCheck();
return this.deps.http.get(`/internal/content_management/favorites/${this.favoriteObjectType}`);
}

public async addFavorite(params: AddFavoriteRequest<Metadata>): Promise<AddFavoriteResponse> {
await this.ifAvailablePreCheck();
return this.deps.http.post(
`/internal/content_management/favorites/${this.favoriteObjectType}/${params.id}/favorite`,
{ body: 'metadata' in params ? JSON.stringify({ metadata: params.metadata }) : undefined }
);
}

public async removeFavorite({ id }: { id: string }): Promise<RemoveFavoriteResponse> {
await this.ifAvailablePreCheck();
return this.deps.http.post(
`/internal/content_management/favorites/${this.favoriteObjectType}/${id}/unfavorite`
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,6 @@
"@kbn/content-management-favorites-server",
"@kbn/i18n-react",
"@kbn/usage-collection-plugin",
"@kbn/core-user-profile-browser",
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export const getMockServices = (overrides?: Partial<Services & UserProfilesServi
getTagManagementUrl: () => '',
getTagIdsFromReferences: () => [],
isTaggingEnabled: () => true,
isFavoritesEnabled: () => false,
isFavoritesEnabled: () => Promise.resolve(false),
bulkGetUserProfiles: async () => [],
getUserProfile: async () => ({ uid: '', enabled: true, data: {}, user: { username: '' } }),
isKibanaVersioningEnabled: false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ export const getStoryServices = (params: Params, action: ActionFn = () => {}) =>
getTagManagementUrl: () => '',
getTagIdsFromReferences: () => [],
isTaggingEnabled: () => true,
isFavoritesEnabled: () => false,
isFavoritesEnabled: () => Promise.resolve(false),
isKibanaVersioningEnabled: false,
...params,
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export interface Services {
/** Predicate to indicate if tagging features is enabled */
isTaggingEnabled: () => boolean;
/** Predicate to indicate if favorites features is enabled */
isFavoritesEnabled: () => boolean;
isFavoritesEnabled: () => Promise<boolean>;
/** Predicate function to indicate if some of the saved object references are tags */
itemHasTags: (references: SavedObjectsReference[]) => boolean;
/** Handler to return the url to navigate to the kibana tags management */
Expand Down Expand Up @@ -288,7 +288,7 @@ export const TableListViewKibanaProvider: FC<
currentAppId$={application.currentAppId$}
navigateToUrl={application.navigateToUrl}
isTaggingEnabled={() => Boolean(savedObjectsTagging)}
isFavoritesEnabled={() => Boolean(services.favorites)}
isFavoritesEnabled={async () => services.favorites?.isAvailable() ?? false}
getTagList={getTagList}
TagList={TagList}
itemHasTags={itemHasTags}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

import React, { useReducer, useCallback, useEffect, useRef, useMemo } from 'react';
import useDebounce from 'react-use/lib/useDebounce';
import useAsync from 'react-use/lib/useAsync';
import {
EuiBasicTableColumn,
EuiButton,
Expand Down Expand Up @@ -379,6 +380,8 @@ function TableListViewTableComp<T extends UserContentCommonSchema>({
isKibanaVersioningEnabled,
} = useServices();

const favoritesEnabled = useAsync(isFavoritesEnabled, [])?.value ?? false;

const openContentEditor = useOpenContentEditor();
const contentInsightsServices = useContentInsightsServices();

Expand Down Expand Up @@ -621,7 +624,7 @@ function TableListViewTableComp<T extends UserContentCommonSchema>({
}
}}
searchTerm={searchQuery.text}
isFavoritesEnabled={isFavoritesEnabled()}
isFavoritesEnabled={favoritesEnabled}
/>
);
},
Expand Down Expand Up @@ -754,7 +757,7 @@ function TableListViewTableComp<T extends UserContentCommonSchema>({
tableItemsRowActions,
inspectItem,
entityName,
isFavoritesEnabled,
favoritesEnabled,
isKibanaVersioningEnabled,
]);

Expand Down Expand Up @@ -1218,7 +1221,7 @@ function TableListViewTableComp<T extends UserContentCommonSchema>({
addOrRemoveExcludeTagFilter={addOrRemoveExcludeTagFilter}
clearTagSelection={clearTagSelection}
createdByEnabled={createdByEnabled}
favoritesEnabled={isFavoritesEnabled()}
favoritesEnabled={favoritesEnabled}
/>

{/* Delete modal */}
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading