Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

doc(kustomize/replacements): add select and reject explanation #360

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,51 @@ but the source selection must resolve to a single resource.
Replacements will be applied to all targets that are matched by the `select` field and
are NOT matched by the `reject` field, and will be applied to all listed `fieldPaths`.

##### Select
You can use any of the following fields to select the targets to replace:
`group`, `version`, `kind`, `name`, `namespace`

For example, the following will select all the Deployments as targets of replacement.

```yaml
select:
kind: Deployment
```

Also, you can use multiple fields together to select only the resources that match all the conditions.
For example, the following will select only the Deployments that are named my-deploy:

```yaml
select:
- kind: Deployment
name: my-deploy
```

Moreover, when the selected target is going to be transformed during the kustomization process,
you can use either the original or the transformed resource id to select it.

For example, the name of the target could be changed because of the `namePrefix` field, as below:

```yaml
namePrefix: my-
```

In this case, below will be enough if we wanted to select all the targets that were originally named deploy:

```yaml
select:
- name: deploy
```

Alternatively, using the transformed name with the prefix will produce the same behaviour.
So the following case will select all the resources that *will be* named my-deploy,
along with all the resources that *were* originally named my-deploy.

```yaml
select:
- name: my-deploy
```

##### Reject
The reject field is a selector that drops targets selected by select, overruling their selection.

Expand Down Expand Up @@ -142,6 +187,29 @@ reject:
- kind: StatefulSet
```

Moreover, when the selected target is going to be transformed during the kustomization process,
Copy link
Contributor

@natasha41575 natasha41575 Aug 16, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Above, somewhere it says:

Replacements will be applied to all targets that are matched by the `select` field and
are NOT matched by the `reject` field, and will be applied to all listed `fieldPaths`.

Could you add another example, after this sentence, similar to the one you added here for reject, but with a ####Select header, to show that you can also use select with a previous or current id?

Copy link
Member Author

@bugoverdose bugoverdose Aug 17, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

68a0cef

  1. It felt kinda random to explain only about the behavior I fixed, so I added a bit more info about the functionality of select field in general so that it matches reject.
  2. I used namePrefix for explaining select because I already used nameSuffix at reject.

you can use either the original or the transformed resource id to reject it.

For example, the name of the target could be changed because of the `nameSuffix` field, as below:

```yaml
nameSuffix: -dev
```

You can use the original target name to prevent it from going through any replacement.

```yaml
reject:
- name: my-deploy
```

Alternatively, using the transformed name with the suffix will produce the same behaviour.

```yaml
reject:
- name: my-deploy-dev
```

#### Delimiter

This field is intended to be used in conjunction with the `index` field for partial string replacement.
Expand Down