Skip to content

Commit 678d6a3

Browse files
authored
fix: require label & field selector values (#18)
Fixes #15
1 parent 3a29afe commit 678d6a3

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

src/fluent/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,13 @@ export function K8s<T extends GenericClass, K extends KubernetesObject = Instanc
3434
return withFilters;
3535
}
3636

37-
function WithField<P extends Paths<K>>(key: P, value = "") {
37+
function WithField<P extends Paths<K>>(key: P, value: string) {
3838
filters.fields = filters.fields || {};
3939
filters.fields[key] = value;
4040
return withFilters;
4141
}
4242

43-
function WithLabel(key: string, value = "") {
43+
function WithLabel(key: string, value: string) {
4444
filters.labels = filters.labels || {};
4545
filters.labels[key] = value;
4646
return withFilters;

src/fluent/types.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,12 +99,14 @@ export type K8sWithFilters<K extends KubernetesObject> = K8sFilteredActions<K> &
9999
* ```
100100
*
101101
* Will only delete the Deployment if it has the `metadata.name=bar` and `metadata.namespace=qux` fields.
102+
* Not all fields are supported, see https://kubernetes.io/docs/concepts/overview/working-with-objects/field-selectors/#supported-fields,
103+
* but Typescript will limit to only fields that exist on the resource.
102104
*
103105
* @param key The field key
104106
* @param value The field value
105107
* @returns
106108
*/
107-
WithField: <P extends Paths<K>>(key: P, value?: string) => K8sWithFilters<K>;
109+
WithField: <P extends Paths<K>>(key: P, value: string) => K8sWithFilters<K>;
108110

109111
/**
110112
* Filter the query by the given label. If no value is specified, the label simply must exist.
@@ -122,7 +124,7 @@ export type K8sWithFilters<K extends KubernetesObject> = K8sFilteredActions<K> &
122124
* @param key The label key
123125
* @param value (optional) The label value
124126
*/
125-
WithLabel: (key: string, value?: string) => K8sWithFilters<K>;
127+
WithLabel: (key: string, value: string) => K8sWithFilters<K>;
126128
};
127129

128130
export type K8sInit<K extends KubernetesObject> = K8sWithFilters<K> &

0 commit comments

Comments
 (0)