From 678d6a3a8220765c9d0bad13a940647eb32cff08 Mon Sep 17 00:00:00 2001 From: Megamind <882485+jeff-mccoy@users.noreply.github.com> Date: Mon, 2 Oct 2023 23:04:30 -0500 Subject: [PATCH] fix: require label & field selector values (#18) Fixes #15 --- src/fluent/index.ts | 4 ++-- src/fluent/types.ts | 6 ++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/fluent/index.ts b/src/fluent/index.ts index 4995838..b11af22 100644 --- a/src/fluent/index.ts +++ b/src/fluent/index.ts @@ -34,13 +34,13 @@ export function K8s>(key: P, value = "") { + function WithField

>(key: P, value: string) { filters.fields = filters.fields || {}; filters.fields[key] = value; return withFilters; } - function WithLabel(key: string, value = "") { + function WithLabel(key: string, value: string) { filters.labels = filters.labels || {}; filters.labels[key] = value; return withFilters; diff --git a/src/fluent/types.ts b/src/fluent/types.ts index 89c7909..067c4e3 100644 --- a/src/fluent/types.ts +++ b/src/fluent/types.ts @@ -99,12 +99,14 @@ export type K8sWithFilters = K8sFilteredActions & * ``` * * Will only delete the Deployment if it has the `metadata.name=bar` and `metadata.namespace=qux` fields. + * Not all fields are supported, see https://kubernetes.io/docs/concepts/overview/working-with-objects/field-selectors/#supported-fields, + * but Typescript will limit to only fields that exist on the resource. * * @param key The field key * @param value The field value * @returns */ - WithField:

>(key: P, value?: string) => K8sWithFilters; + WithField:

>(key: P, value: string) => K8sWithFilters; /** * Filter the query by the given label. If no value is specified, the label simply must exist. @@ -122,7 +124,7 @@ export type K8sWithFilters = K8sFilteredActions & * @param key The label key * @param value (optional) The label value */ - WithLabel: (key: string, value?: string) => K8sWithFilters; + WithLabel: (key: string, value: string) => K8sWithFilters; }; export type K8sInit = K8sWithFilters &