新しいトリガーフィルタ¶
フラグ名: new-apiserversource-filters
ステージ: アルファ、デフォルトで無効
トラッキングイシュー: #7791
概要¶
この機能は、CloudEvents Subscriptions API
で定義されているフィルタAPIフィールドに準拠した、APIServerSourceに新しいfilters
フィールドを有効にします。これにより、ユーザーは強力なフィルタ式セットを指定できます。各式は、各イベントに対してtrueまたはfalseのいずれかの値を評価します。
次の例は、新しいfilters
フィールドを使用するAPIServerSourceを示しています。
---
apiVersion: sources.knative.dev/v1
kind: ApiServerSource
metadata:
name: my-apiserversource
namespace: default
spec:
filters:
- any:
- exact:
type: dev.knative.apiserver.ref.add
serviceAccountName: apiserversource
mode: Reference
resources: ...
sink: ...
フィルタフィールドについて¶
- trueまたはfalseを評価するフィルタ式の配列です。配列内のいずれかのフィルタ式がfalseと評価された場合、イベントは
sink
に送信されません。 - 各フィルタ式は、フィルタの種類と、フィルタ式内で許可される追加プロパティのセットを定義する方言に従います。
サポートされているフィルタ方言¶
filters
フィールドは、次の方言をサポートしています。
exact
¶
CloudEvent 属性の文字列値は、指定された文字列値と完全に一致する必要があります。一致は、大文字と小文字が区別されます。
apiVersion: sources.knative.dev/v1
kind: APIServerSource
metadata:
...
spec:
...
filters:
- exact:
type: com.github.push
prefix
¶
CloudEvent 属性の文字列値は、指定された文字列値で始まる必要があります。一致は、大文字と小文字が区別されます。
apiVersion: sources.knative.dev/v1
kind: APIServerSource
metadata:
...
spec:
...
filters:
- prefix:
type: com.github.
suffix
¶
CloudEvent 属性の文字列値は、指定された文字列値で終わる必要があります。一致は、大文字と小文字が区別されます。
apiVersion: sources.knative.dev/v1
kind: APIServerSource
metadata:
...
spec:
...
filters:
- suffix:
type: .created
all
¶
すべてのネストされたフィルタ式がtrueと評価される必要があります。
apiVersion: sources.knative.dev/v1
kind: APIServerSource
metadata:
...
spec:
...
filters:
- all:
- exact:
type: com.github.push
- exact:
subject: https://github.com/cloudevents/spec
any
¶
少なくとも1つのネストされたフィルタ式がtrueと評価される必要があります。
apiVersion: sources.knative.dev/v1
kind: APIServerSource
metadata:
...
spec:
...
filters:
- any:
- exact:
type: com.github.push
- exact:
subject: https://github.com/cloudevents/spec
not
¶
評価されるネストされた式はfalseと評価される必要があります。
apiVersion: sources.knative.dev/v1
kind: APIServerSource
metadata:
...
spec:
...
filters:
- not:
exact:
type: com.github.push
cesql
¶
提供されたCloudEvents SQL式はtrueと評価される必要があります。
apiVersion: sources.knative.dev/v1
kind: APIServerSource
metadata:
...
spec:
...
filters:
- cesql: "source LIKE '%commerce%' AND type IN ('order.created', 'order.updated', 'order.canceled')"
FAQ¶
APIServerSource が提供するイベントタイプはどれですか?¶
dev.knative.apiserver.resource.add
dev.knative.apiserver.resource.update
dev.knative.apiserver.resource.delete
dev.knative.apiserver.ref.add
dev.knative.apiserver.ref.update
dev.knative.apiserver.ref.delete