Skip to content

Commit c2637d8

Browse files
committed
add CHANGELOG.md FrameworkClient breaking change and DeleteAllOf() example to doc/user/client.md
1 parent 1cf87bc commit c2637d8

File tree

2 files changed

+41
-10
lines changed

2 files changed

+41
-10
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
}
4242
err = r.client.List(context.TODO(), podList, listOpts...)
4343
```
44+
- [`pkg/test.FrameworkClient`][./pkg/test#L33] methods `List()` and `Delete()` have new signatures corresponding to the homonymous methods of `sigs.k8s.io/controller-runtime/pkg/client.Client`.
4445
- CRD file names were previously of the form `<group>_<version>_<kind>_crd.yaml`. Now that CRD manifest `spec.version` is deprecated in favor of `spec.versions`, i.e. multiple versions can be specified in one CRD, CRD file names have the form `<full group>_<resource>_crd.yaml`. `<full group>` is the full group name of your CRD while `<group>` is the last subdomain of `<full group>`, ex. `foo.bar.com` vs `foo`. `<resource>` is the plural lower-case CRD Kind found at `spec.names.plural`.
4546

4647
### Deprecated

doc/user/client.md

Lines changed: 40 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -169,9 +169,9 @@ func (r *ReconcileApp) Reconcile(request reconcile.Request) (reconcile.Result, e
169169
```
170170

171171
[list-options]:https://godoc.org/sigs.k8s.io/controller-runtime/pkg/client#ListOptions
172-
[matchinglabels]:https://godoc.org/sigs.k8s.io/controller-runtime/pkg/client#MatchingLabels
173-
[matchingfields]:https://godoc.org/sigs.k8s.io/controller-runtime/pkg/client#MatchingFields
174-
[innamespace]:https://godoc.org/sigs.k8s.io/controller-runtime/pkg/client#InNamespace
172+
[matching-labels]:https://godoc.org/sigs.k8s.io/controller-runtime/pkg/client#MatchingLabels
173+
[matching-fields]:https://godoc.org/sigs.k8s.io/controller-runtime/pkg/client#MatchingFields
174+
[in-namespace]:https://godoc.org/sigs.k8s.io/controller-runtime/pkg/client#InNamespace
175175

176176
#### Create
177177

@@ -217,7 +217,7 @@ func (r *ReconcileApp) Reconcile(request reconcile.Request) (reconcile.Result, e
217217
func (c Client) Update(ctx context.Context, obj runtime.Object, opts ...client.UpdateOption) error
218218
```
219219

220-
A `client.UpdateOption` is an interface that sets [`client.UpdateOptions`][update-options] fields. A `client.UpdateOption` is created by using one of the provided implementations: [`DryRunAll`][dryrunall], [`ForceOwnership`][forceownership]. Generally these options are not needed.
220+
A `client.UpdateOption` is an interface that sets [`client.UpdateOptions`][update-options] fields. A `client.UpdateOption` is created by using one of the provided implementations: [`DryRunAll`][dryrun-all], [`ForceOwnership`][force-ownership]. Generally these options are not needed.
221221

222222
Example:
223223

@@ -254,7 +254,7 @@ func (r *ReconcileApp) Reconcile(request reconcile.Request) (reconcile.Result, e
254254
func (c Client) Patch(ctx context.Context, obj runtime.Object, patch client.Patch, opts ...client.UpdateOption) error
255255
```
256256

257-
A `client.PatchOption` is an interface that sets [`client.PatchOptions`][patch-options] fields. A `client.PatchOption` is created by using one of the provided implementations: [`DryRunAll`][dryrunall], [`ForceOwnership`][forceownership]. Generally these options are not needed.
257+
A `client.PatchOption` is an interface that sets [`client.PatchOptions`][patch-options] fields. A `client.PatchOption` is created by using one of the provided implementations: [`DryRunAll`][dryrun-all], [`ForceOwnership`][force-ownership]. Generally these options are not needed.
258258

259259
Example:
260260

@@ -285,8 +285,8 @@ func (r *ReconcileApp) Reconcile(request reconcile.Request) (reconcile.Result, e
285285
```
286286

287287
[patch-options]:https://godoc.org/sigs.k8s.io/controller-runtime/pkg/client#PatchOption
288-
[dryrunall]:https://godoc.org/sigs.k8s.io/controller-runtime/pkg/client#DryRunAll
289-
[forceownership]:https://godoc.org/sigs.k8s.io/controller-runtime/pkg/client#ForceOwnership
288+
[dryrun-all]:https://godoc.org/sigs.k8s.io/controller-runtime/pkg/client#DryRunAll
289+
[force-ownership]:https://godoc.org/sigs.k8s.io/controller-runtime/pkg/client#ForceOwnership
290290

291291
##### Updating Status Subresource
292292

@@ -342,7 +342,7 @@ func (r *ReconcileApp) Reconcile(request reconcile.Request) (reconcile.Result, e
342342
func (c Client) Delete(ctx context.Context, obj runtime.Object, opts ...client.DeleteOption) error
343343
```
344344

345-
A `client.DeleteOption` is an interface that sets [`client.DeleteOptions`][delete-opts] fields. A `client.DeleteOption` is created by using one of the provided implementations: [`GracePeriodSeconds`][graceperiodseconds], [`Preconditions`][preconditions], [`PropagationPolicy`][propagationpolicy].
345+
A `client.DeleteOption` is an interface that sets [`client.DeleteOptions`][delete-opts] fields. A `client.DeleteOption` is created by using one of the provided implementations: [`GracePeriodSeconds`][grace-period-seconds], [`Preconditions`][preconditions], [`PropagationPolicy`][propagation-policy].
346346

347347
Example:
348348

@@ -374,9 +374,9 @@ func (r *ReconcileApp) Reconcile(request reconcile.Request) (reconcile.Result, e
374374
```
375375

376376
[delete-opts]:https://godoc.org/sigs.k8s.io/controller-runtime/pkg/client#DeleteOptions
377-
[graceperiodseconds]:https://godoc.org/sigs.k8s.io/controller-runtime/pkg/client#GracePeriodSeconds
377+
[grace-period-seconds]:https://godoc.org/sigs.k8s.io/controller-runtime/pkg/client#GracePeriodSeconds
378378
[preconditions]:https://godoc.org/sigs.k8s.io/controller-runtime/pkg/client#Preconditions
379-
[propagationpolicy]:https://godoc.org/sigs.k8s.io/controller-runtime/pkg/client#PropagationPolicy
379+
[propagation-policy]:https://godoc.org/sigs.k8s.io/controller-runtime/pkg/client#PropagationPolicy
380380

381381
#### DeleteAllOf
382382

@@ -387,6 +387,36 @@ func (c Client) DeleteAllOf(ctx context.Context, obj runtime.Object, opts ...cli
387387

388388
A `client.DeleteAllOfOption` is an interface that sets [`client.DeleteAllOfOptions`][deleteallof-opts] fields. A `client.DeleteAllOfOption` wraps a [`client.ListOption`](#list) and [`client.DeleteOption`](#delete).
389389

390+
Example:
391+
392+
```Go
393+
import (
394+
"context"
395+
"fmt"
396+
"k8s.io/api/core/v1"
397+
"sigs.k8s.io/controller-runtime/pkg/client"
398+
"sigs.k8s.io/controller-runtime/pkg/reconcile"
399+
)
400+
401+
func (r *ReconcileApp) Reconcile(request reconcile.Request) (reconcile.Result, error) {
402+
...
403+
404+
// Delete all pods in the request namespace with a label of `app=<name>`
405+
// and phase `Failed`.
406+
pod := &v1.Pod{}
407+
opts := []client.DeleteAllOfOption{
408+
client.InNamespace(request.NamespacedName.Namespace),
409+
client.MatchingLabels{"app", request.NamespacedName.Name},
410+
client.MatchingFields{"status.phase": "Failed"},
411+
client.GracePeriodSeconds(5),
412+
}
413+
ctx := context.TODO()
414+
err := r.client.DeleteAllOf(ctx, pod, opts...)
415+
416+
...
417+
}
418+
```
419+
390420
[deleteallof-opts]:https://godoc.org/sigs.k8s.io/controller-runtime/pkg/client#DeleteAllOfOptions
391421

392422
### Example usage

0 commit comments

Comments
 (0)