Skip to content

Commit

Permalink
examples/wait_for_resources: fix Go code indentation in README
Browse files Browse the repository at this point in the history
Consistently use tabs to indent, so the code examples are rendered with
consistent indentation.
  • Loading branch information
tklauser committed Jun 29, 2022
1 parent 38158f3 commit ce742cf
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions examples/wait_for_resources/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ Additionally, it is easy to wait for changes to any resource type with the `Reso

```go
func TestResourceMatch(t *testing.T) {
...
deployment := appsv1.Deployment{ObjectMeta: metav1.ObjectMeta{Name: "deploy-name"}}
...
deployment := appsv1.Deployment{ObjectMeta: metav1.ObjectMeta{Name: "deploy-name"}}
err = wait.For(conditions.New(client.Resources()).ResourceMatch(deployment, func(object k8s.Object) bool {
d := object.(*appsv1.Deployment)
return d.Status.AvailableReplicas == 2 && d.Status.ReadyReplicas == 2
Expand All @@ -40,15 +40,15 @@ It is common to need to check for the existence of a set of objects by name:

```go
func TestResourcesFound(t *testing.T) {
...
...
pods := &v1.PodList{
Items: []v1.Pod{
{ObjectMeta: metav1.ObjectMeta{Name: "p9", Namespace: namespace}},
{ObjectMeta: metav1.ObjectMeta{Name: "p10", Namespace: namespace}},
{ObjectMeta: metav1.ObjectMeta{Name: "p11", Namespace: namespace}},
},
}
// wait for the set of pods to exist
// wait for the set of pods to exist
err = wait.For(conditions.New(client.Resources()).ResourcesFound(pods))
if err != nil {
t.Error(err)
Expand All @@ -61,26 +61,26 @@ Or to check for their absence:

```go
func TestResourcesDeleted(t *testing.T) {
...
...
pods := &v1.PodList{}
// wait for 1 pod with the label `"app": "d5"`
// wait for 1 pod with the label `"app": "d5"`
err = wait.For(conditions.New(client.Resources()).ResourceListN(
pods,
1,
resources.WithLabelSelector(labels.FormatLabels(map[string]string{"app": "d5"}))),
)
pods,
1,
resources.WithLabelSelector(labels.FormatLabels(map[string]string{"app": "d5"}))),
)
if err != nil {
t.Error(err)
}
err = client.Resources().Delete(context.Background(), deployment)
if err != nil {
t.Error(err)
}
// wait for the set of pods to finish deleting
// wait for the set of pods to finish deleting
err = wait.For(conditions.New(client.Resources()).ResourcesDeleted(pods))
if err != nil {
t.Error(err)
}
...
...
}
```

0 comments on commit ce742cf

Please sign in to comment.