chore(server): support elasticsearch apiKey (#12405)
Some checks are pending
Build & Test / Optimize CI (push) Waiting to run
Build & Test / Analyze (javascript, affine) (push) Blocked by required conditions
Build & Test / Analyze (javascript, blocksuite) (push) Blocked by required conditions
Build & Test / Analyze (typescript, affine) (push) Blocked by required conditions
Build & Test / Analyze (typescript, blocksuite) (push) Blocked by required conditions
Build & Test / Lint (push) Blocked by required conditions
Build & Test / Typecheck (push) Blocked by required conditions
Build & Test / Lint Rust (push) Blocked by required conditions
Build & Test / Check Git Status (push) Blocked by required conditions
Build & Test / Check yarn binary (push) Blocked by required conditions
Build & Test / E2E BlockSuite Test (1) (push) Blocked by required conditions
Build & Test / E2E BlockSuite Test (10) (push) Blocked by required conditions
Build & Test / E2E BlockSuite Test (2) (push) Blocked by required conditions
Build & Test / E2E BlockSuite Test (3) (push) Blocked by required conditions
Build & Test / E2E BlockSuite Test (4) (push) Blocked by required conditions
Build & Test / E2E BlockSuite Test (5) (push) Blocked by required conditions
Build & Test / E2E BlockSuite Test (6) (push) Blocked by required conditions
Build & Test / E2E BlockSuite Test (7) (push) Blocked by required conditions
Build & Test / E2E BlockSuite Test (8) (push) Blocked by required conditions
Build & Test / E2E BlockSuite Test (9) (push) Blocked by required conditions
Build & Test / E2E BlockSuite Cross Browser Test (chromium, 1) (push) Blocked by required conditions
Build & Test / E2E BlockSuite Cross Browser Test (chromium, 2) (push) Blocked by required conditions
Build & Test / E2E BlockSuite Cross Browser Test (firefox, 1) (push) Blocked by required conditions
Build & Test / E2E BlockSuite Cross Browser Test (firefox, 2) (push) Blocked by required conditions
Build & Test / E2E BlockSuite Cross Browser Test (webkit, 1) (push) Blocked by required conditions
Build & Test / E2E BlockSuite Cross Browser Test (webkit, 2) (push) Blocked by required conditions
Build & Test / E2E Test (1) (push) Blocked by required conditions
Build & Test / E2E Test (10) (push) Blocked by required conditions
Build & Test / E2E Test (2) (push) Blocked by required conditions
Build & Test / E2E Test (3) (push) Blocked by required conditions
Build & Test / E2E Test (4) (push) Blocked by required conditions
Build & Test / E2E Test (5) (push) Blocked by required conditions
Build & Test / E2E Test (6) (push) Blocked by required conditions
Build & Test / E2E Test (7) (push) Blocked by required conditions
Build & Test / E2E Test (8) (push) Blocked by required conditions
Build & Test / E2E Test (9) (push) Blocked by required conditions
Build & Test / E2E Mobile Test (1) (push) Blocked by required conditions
Build & Test / E2E Mobile Test (2) (push) Blocked by required conditions
Build & Test / E2E Mobile Test (3) (push) Blocked by required conditions
Build & Test / E2E Mobile Test (4) (push) Blocked by required conditions
Build & Test / E2E Mobile Test (5) (push) Blocked by required conditions
Build & Test / Unit Test (1) (push) Blocked by required conditions
Build & Test / Unit Test (2) (push) Blocked by required conditions
Build & Test / Unit Test (3) (push) Blocked by required conditions
Build & Test / Unit Test (4) (push) Blocked by required conditions
Build & Test / Unit Test (5) (push) Blocked by required conditions
Build & Test / Build AFFiNE native (${{ matrix.spec.target }}) (map[os:macos-latest target:aarch64-apple-darwin]) (push) Blocked by required conditions
Build & Test / Build AFFiNE native (${{ matrix.spec.target }}) (map[os:macos-latest target:x86_64-apple-darwin]) (push) Blocked by required conditions
Build & Test / Build AFFiNE native (${{ matrix.spec.target }}) (map[os:ubuntu-latest target:x86_64-unknown-linux-gnu]) (push) Blocked by required conditions
Build & Test / Build AFFiNE native (${{ matrix.spec.target }}) (map[os:windows-latest target:aarch64-pc-windows-msvc]) (push) Blocked by required conditions
Build & Test / Build AFFiNE native (${{ matrix.spec.target }}) (map[os:windows-latest target:x86_64-pc-windows-msvc]) (push) Blocked by required conditions
Build & Test / Build Server native (push) Blocked by required conditions
Build & Test / Build @affine/electron renderer (push) Blocked by required conditions
Build & Test / Native Unit Test (push) Blocked by required conditions
Build & Test / Server Test (0, 8) (push) Blocked by required conditions
Build & Test / Server Test (1, 8) (push) Blocked by required conditions
Build & Test / Server Test (2, 8) (push) Blocked by required conditions
Build & Test / Server Test (3, 8) (push) Blocked by required conditions
Build & Test / Server Test (4, 8) (push) Blocked by required conditions
Build & Test / Server Test (5, 8) (push) Blocked by required conditions
Build & Test / Server Test (6, 8) (push) Blocked by required conditions
Build & Test / Server Test (7, 8) (push) Blocked by required conditions
Build & Test / Server Test with Elasticsearch (push) Blocked by required conditions
Build & Test / Server E2E Test (push) Blocked by required conditions
Build & Test / miri code check (push) Blocked by required conditions
Build & Test / loom thread test (push) Blocked by required conditions
Build & Test / fuzzing (push) Blocked by required conditions
Build & Test / y-octo binding test on ${{ matrix.settings.target }} (map[os:macos-13 target:x86_64-apple-darwin]) (push) Blocked by required conditions
Build & Test / y-octo binding test on ${{ matrix.settings.target }} (map[os:macos-latest target:aarch64-apple-darwin]) (push) Blocked by required conditions
Build & Test / y-octo binding test on ${{ matrix.settings.target }} (map[os:ubuntu-24.04-arm target:aarch64-unknown-linux-gnu]) (push) Blocked by required conditions
Build & Test / y-octo binding test on ${{ matrix.settings.target }} (map[os:ubuntu-latest target:x86_64-unknown-linux-gnu]) (push) Blocked by required conditions
Build & Test / y-octo binding test on ${{ matrix.settings.target }} (map[os:windows-11-arm target:aarch64-pc-windows-msvc]) (push) Blocked by required conditions
Build & Test / y-octo binding test on ${{ matrix.settings.target }} (map[os:windows-latest target:x86_64-pc-windows-msvc]) (push) Blocked by required conditions
Build & Test / Run native tests (push) Blocked by required conditions
Build & Test / Server Copilot Api Test (push) Blocked by required conditions
Build & Test / Frontend Copilot E2E Test (1, 8) (push) Blocked by required conditions
Build & Test / Frontend Copilot E2E Test (2, 8) (push) Blocked by required conditions
Build & Test / Frontend Copilot E2E Test (3, 8) (push) Blocked by required conditions
Build & Test / Frontend Copilot E2E Test (4, 8) (push) Blocked by required conditions
Build & Test / Frontend Copilot E2E Test (5, 8) (push) Blocked by required conditions
Build & Test / Frontend Copilot E2E Test (6, 8) (push) Blocked by required conditions
Build & Test / Frontend Copilot E2E Test (7, 8) (push) Blocked by required conditions
Build & Test / Frontend Copilot E2E Test (8, 8) (push) Blocked by required conditions
Build & Test / ${{ matrix.tests.name }} (map[name:Cloud Desktop E2E Test script:yarn affine @affine/electron build:dev # Workaround for Electron apps failing to initialize on Ubuntu 24.04 due to AppArmor restrictions # Disables unprivileged user namespaces restrictio… (push) Blocked by required conditions
Build & Test / ${{ matrix.tests.name }} (map[name:Cloud E2E Test 1/6 script:yarn affine @affine-test/affine-cloud e2e --forbid-only --shard=1/6 shard:1]) (push) Blocked by required conditions
Build & Test / ${{ matrix.tests.name }} (map[name:Cloud E2E Test 2/6 script:yarn affine @affine-test/affine-cloud e2e --forbid-only --shard=2/6 shard:2]) (push) Blocked by required conditions
Build & Test / ${{ matrix.tests.name }} (map[name:Cloud E2E Test 3/6 script:yarn affine @affine-test/affine-cloud e2e --forbid-only --shard=3/6 shard:3]) (push) Blocked by required conditions
Build & Test / ${{ matrix.tests.name }} (map[name:Cloud E2E Test 4/6 script:yarn affine @affine-test/affine-cloud e2e --forbid-only --shard=4/6 shard:4]) (push) Blocked by required conditions
Build & Test / ${{ matrix.tests.name }} (map[name:Cloud E2E Test 5/6 script:yarn affine @affine-test/affine-cloud e2e --forbid-only --shard=5/6 shard:5]) (push) Blocked by required conditions
Build & Test / ${{ matrix.tests.name }} (map[name:Cloud E2E Test 6/6 script:yarn affine @affine-test/affine-cloud e2e --forbid-only --shard=6/6 shard:6]) (push) Blocked by required conditions
Build & Test / Desktop Test (${{ matrix.spec.os }}, ${{ matrix.spec.platform }}, ${{ matrix.spec.arch }}, ${{ matrix.spec.target }}, ${{ matrix.spec.test }}) (map[arch:arm64 os:macos-latest platform:macos target:aarch64-apple-darwin test:true]) (push) Blocked by required conditions
Build & Test / Desktop Test (${{ matrix.spec.os }}, ${{ matrix.spec.platform }}, ${{ matrix.spec.arch }}, ${{ matrix.spec.target }}, ${{ matrix.spec.test }}) (map[arch:x64 os:macos-latest platform:macos target:x86_64-apple-darwin test:false]) (push) Blocked by required conditions
Build & Test / Desktop Test (${{ matrix.spec.os }}, ${{ matrix.spec.platform }}, ${{ matrix.spec.arch }}, ${{ matrix.spec.target }}, ${{ matrix.spec.test }}) (map[arch:x64 os:ubuntu-latest platform:linux target:x86_64-unknown-linux-gnu test:true]) (push) Blocked by required conditions
Build & Test / Desktop Test (${{ matrix.spec.os }}, ${{ matrix.spec.platform }}, ${{ matrix.spec.arch }}, ${{ matrix.spec.target }}, ${{ matrix.spec.test }}) (map[arch:x64 os:windows-latest platform:windows target:x86_64-pc-windows-msvc test:true]) (push) Blocked by required conditions
Build & Test / Desktop bundle check (${{ matrix.spec.os }}, ${{ matrix.spec.platform }}, ${{ matrix.spec.arch }}, ${{ matrix.spec.target }}, ${{ matrix.spec.test }}) (map[arch:arm64 os:macos-latest platform:macos target:aarch64-apple-darwin test:true]) (push) Blocked by required conditions
Build & Test / Desktop bundle check (${{ matrix.spec.os }}, ${{ matrix.spec.platform }}, ${{ matrix.spec.arch }}, ${{ matrix.spec.target }}, ${{ matrix.spec.test }}) (map[arch:x64 os:macos-latest platform:macos target:x86_64-apple-darwin test:false]) (push) Blocked by required conditions
Build & Test / Desktop bundle check (${{ matrix.spec.os }}, ${{ matrix.spec.platform }}, ${{ matrix.spec.arch }}, ${{ matrix.spec.target }}, ${{ matrix.spec.test }}) (map[arch:x64 os:ubuntu-latest platform:linux target:x86_64-unknown-linux-gnu test:true]) (push) Blocked by required conditions
Build & Test / test-build-mobile-app (push) Blocked by required conditions
Build & Test / 3, 2, 1 Launch (push) Blocked by required conditions
Sync I18n with Crowdin / synchronize-with-crowdin (push) Waiting to run
Sync I18n with Crowdin / i18n-codegen (push) Blocked by required conditions

This commit is contained in:
fengmk2 2025-05-21 08:35:51 +00:00
parent ff15779208
commit abfc994180
No known key found for this signature in database
GPG Key ID: 37B94432BAF9FC0E
12 changed files with 36 additions and 29 deletions

View File

@ -825,6 +825,11 @@
"description": "Indexer search service endpoint\n@default \"http://localhost:9308\"\n@environment `AFFINE_INDEXER_SEARCH_ENDPOINT`",
"default": "http://localhost:9308"
},
"provider.apiKey": {
"type": "string",
"description": "Indexer search service api key. Optional for elasticsearch\n@default \"\"\n@environment `AFFINE_INDEXER_SEARCH_API_KEY`\n@link https://www.elastic.co/guide/server/current/api-key.html",
"default": ""
},
"provider.username": {
"type": "string",
"description": "Indexer search service auth username, if not set, basic auth will be disabled. Optional for elasticsearch\n@default \"\"\n@environment `AFFINE_INDEXER_SEARCH_USERNAME`\n@link https://www.elastic.co/guide/en/elasticsearch/reference/current/http-clients.html",

View File

@ -18,8 +18,7 @@ const {
STATIC_IP_NAME,
AFFINE_INDEXER_SEARCH_PROVIDER,
AFFINE_INDEXER_SEARCH_ENDPOINT,
AFFINE_INDEXER_SEARCH_USERNAME,
AFFINE_INDEXER_SEARCH_PASSWORD,
AFFINE_INDEXER_SEARCH_API_KEY,
} = process.env;
const buildType = BUILD_TYPE || 'canary';
@ -88,8 +87,7 @@ const createHelmCommand = ({ isDryRun }) => {
const indexerOptions = [
`--set-string global.indexer.provider="${AFFINE_INDEXER_SEARCH_PROVIDER}"`,
`--set-string global.indexer.endpoint="${AFFINE_INDEXER_SEARCH_ENDPOINT}"`,
`--set-string global.indexer.username="${AFFINE_INDEXER_SEARCH_USERNAME}"`,
`--set-string global.indexer.password="${AFFINE_INDEXER_SEARCH_PASSWORD}"`,
`--set-string global.indexer.apiKey="${AFFINE_INDEXER_SEARCH_API_KEY}"`,
];
const serviceAnnotations = [
`--set-json web.serviceAccount.annotations="{ \\"iam.gke.io/gcp-service-account\\": \\"${APP_IAM_ACCOUNT}\\" }"`,

View File

@ -73,13 +73,11 @@ spec:
value: "{{ .Values.global.indexer.provider }}"
- name: AFFINE_INDEXER_SEARCH_ENDPOINT
value: "{{ .Values.global.indexer.endpoint }}"
- name: AFFINE_INDEXER_SEARCH_USERNAME
value: "{{ .Values.global.indexer.username }}"
- name: AFFINE_INDEXER_SEARCH_PASSWORD
- name: AFFINE_INDEXER_SEARCH_API_KEY
valueFrom:
secretKeyRef:
name: indexer
key: indexer-password
key: indexer-apiKey
- name: AFFINE_SERVER_PORT
value: "{{ .Values.global.docService.port }}"
- name: AFFINE_SERVER_SUB_PATH

View File

@ -71,13 +71,11 @@ spec:
value: "{{ .Values.global.indexer.provider }}"
- name: AFFINE_INDEXER_SEARCH_ENDPOINT
value: "{{ .Values.global.indexer.endpoint }}"
- name: AFFINE_INDEXER_SEARCH_USERNAME
value: "{{ .Values.global.indexer.username }}"
- name: AFFINE_INDEXER_SEARCH_PASSWORD
- name: AFFINE_INDEXER_SEARCH_API_KEY
valueFrom:
secretKeyRef:
name: indexer
key: indexer-password
key: indexer-apiKey
- name: AFFINE_SERVER_PORT
value: "{{ .Values.service.port }}"
- name: AFFINE_SERVER_SUB_PATH

View File

@ -48,13 +48,11 @@ spec:
value: "{{ .Values.global.indexer.provider }}"
- name: AFFINE_INDEXER_SEARCH_ENDPOINT
value: "{{ .Values.global.indexer.endpoint }}"
- name: AFFINE_INDEXER_SEARCH_USERNAME
value: "{{ .Values.global.indexer.username }}"
- name: AFFINE_INDEXER_SEARCH_PASSWORD
- name: AFFINE_INDEXER_SEARCH_API_KEY
valueFrom:
secretKeyRef:
name: indexer
key: indexer-password
key: indexer-apiKey
resources:
requests:
cpu: '100m'

View File

@ -73,13 +73,11 @@ spec:
value: "{{ .Values.global.indexer.provider }}"
- name: AFFINE_INDEXER_SEARCH_ENDPOINT
value: "{{ .Values.global.indexer.endpoint }}"
- name: AFFINE_INDEXER_SEARCH_USERNAME
value: "{{ .Values.global.indexer.username }}"
- name: AFFINE_INDEXER_SEARCH_PASSWORD
- name: AFFINE_INDEXER_SEARCH_API_KEY
valueFrom:
secretKeyRef:
name: indexer
key: indexer-password
key: indexer-apiKey
- name: AFFINE_SERVER_PORT
value: "{{ .Values.service.port }}"
- name: AFFINE_SERVER_SUB_PATH

View File

@ -73,13 +73,11 @@ spec:
value: "{{ .Values.global.indexer.provider }}"
- name: AFFINE_INDEXER_SEARCH_ENDPOINT
value: "{{ .Values.global.indexer.endpoint }}"
- name: AFFINE_INDEXER_SEARCH_USERNAME
value: "{{ .Values.global.indexer.username }}"
- name: AFFINE_INDEXER_SEARCH_PASSWORD
- name: AFFINE_INDEXER_SEARCH_API_KEY
valueFrom:
secretKeyRef:
name: indexer
key: indexer-password
key: indexer-apiKey
- name: AFFINE_SERVER_PORT
value: "{{ .Values.service.port }}"
- name: AFFINE_SERVER_HOST

View File

@ -1,4 +1,4 @@
{{- if .Values.global.indexer.password -}}
{{- if .Values.global.indexer.apiKey -}}
apiVersion: v1
kind: Secret
metadata:
@ -9,5 +9,5 @@ metadata:
"helm.sh/hook-delete-policy": before-hook-creation
type: Opaque
data:
indexer-password: {{ .Values.global.indexer.password | b64enc }}
indexer-apiKey: {{ .Values.global.indexer.apiKey | b64enc }}
{{- end }}

View File

@ -105,8 +105,7 @@ jobs:
STATIC_IP_NAME: ${{ secrets.STATIC_IP_NAME }}
AFFINE_INDEXER_SEARCH_PROVIDER: ${{ secrets.AFFINE_INDEXER_SEARCH_PROVIDER }}
AFFINE_INDEXER_SEARCH_ENDPOINT: ${{ secrets.AFFINE_INDEXER_SEARCH_ENDPOINT }}
AFFINE_INDEXER_SEARCH_USERNAME: ${{ secrets.AFFINE_INDEXER_SEARCH_USERNAME }}
AFFINE_INDEXER_SEARCH_PASSWORD: ${{ secrets.AFFINE_INDEXER_SEARCH_PASSWORD }}
AFFINE_INDEXER_SEARCH_API_KEY: ${{ secrets.AFFINE_INDEXER_SEARCH_API_KEY }}
deploy-done:
needs:

View File

@ -16,6 +16,7 @@ declare global {
provider: {
type: SearchProviderType;
endpoint: string;
apiKey: string;
username: string;
password: string;
};
@ -50,6 +51,12 @@ defineModuleConfig('indexer', {
return z.string().url().safeParse(val);
},
},
'provider.apiKey': {
desc: 'Indexer search service api key. Optional for elasticsearch',
link: 'https://www.elastic.co/guide/server/current/api-key.html',
default: '',
env: ['AFFINE_INDEXER_SEARCH_API_KEY', 'string'],
},
'provider.username': {
desc: 'Indexer search service auth username, if not set, basic auth will be disabled. Optional for elasticsearch',
link: 'https://www.elastic.co/guide/en/elasticsearch/reference/current/http-clients.html',

View File

@ -248,7 +248,9 @@ export class ElasticsearchProvider extends SearchProvider {
const headers = {
'Content-Type': contentType,
} as Record<string, string>;
if (this.config.provider.password) {
if (this.config.provider.apiKey) {
headers.Authorization = `ApiKey ${this.config.provider.apiKey}`;
} else if (this.config.provider.password) {
headers.Authorization = `Basic ${Buffer.from(`${this.config.provider.username}:${this.config.provider.password}`).toString('base64')}`;
}
const response = await fetch(url, {

View File

@ -279,6 +279,12 @@
"desc": "Indexer search service endpoint",
"env": "AFFINE_INDEXER_SEARCH_ENDPOINT"
},
"provider.apiKey": {
"type": "String",
"desc": "Indexer search service api key. Optional for elasticsearch",
"link": "https://www.elastic.co/guide/server/current/api-key.html",
"env": "AFFINE_INDEXER_SEARCH_API_KEY"
},
"provider.username": {
"type": "String",
"desc": "Indexer search service auth username, if not set, basic auth will be disabled. Optional for elasticsearch",