Skip to content

Commit

Permalink
document receivers.spec.resources.matchLabels in v1 API
Browse files Browse the repository at this point in the history
This functionality has been implemented in #482 but we only want to
expose it in v1 of the API.

Signed-off-by: Max Jonas Werner <[email protected]>
  • Loading branch information
Max Jonas Werner committed Mar 27, 2023
1 parent 467359e commit d558ae3
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 5 deletions.
2 changes: 2 additions & 0 deletions api/v1/reference_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ type CrossNamespaceObjectReference struct {
Kind string `json:"kind,omitempty"`

// Name of the referent
// If multiple resources are targeted `*` may be set.
// +kubebuilder:validation:MinLength=1
// +kubebuilder:validation:MaxLength=53
// +required
Expand All @@ -44,6 +45,7 @@ type CrossNamespaceObjectReference struct {
// MatchLabels is a map of {key,value} pairs. A single {key,value} in the matchLabels
// map is equivalent to an element of matchExpressions, whose key field is "key", the
// operator is "In", and the values array contains only "value". The requirements are ANDed.
// MatchLabels requires the name to be set to `*`.
// +optional
MatchLabels map[string]string `json:"matchLabels,omitempty"`
}
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,11 @@ spec:
{key,value} in the matchLabels map is equivalent to an element
of matchExpressions, whose key field is "key", the operator
is "In", and the values array contains only "value". The requirements
are ANDed.
are ANDed. MatchLabels requires the name to be set to `*`.
type: object
name:
description: Name of the referent
description: Name of the referent If multiple resources are
targeted `*` may be set.
maxLength: 53
minLength: 1
type: string
Expand Down
6 changes: 4 additions & 2 deletions docs/api/v1/notification.md
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,8 @@ string
</em>
</td>
<td>
<p>Name of the referent</p>
<p>Name of the referent
If multiple resources are targeted <code>*</code> may be set.</p>
</td>
</tr>
<tr>
Expand All @@ -241,7 +242,8 @@ map[string]string
<em>(Optional)</em>
<p>MatchLabels is a map of {key,value} pairs. A single {key,value} in the matchLabels
map is equivalent to an element of matchExpressions, whose key field is &ldquo;key&rdquo;, the
operator is &ldquo;In&rdquo;, and the values array contains only &ldquo;value&rdquo;. The requirements are ANDed.</p>
operator is &ldquo;In&rdquo;, and the values array contains only &ldquo;value&rdquo;. The requirements are ANDed.
MatchLabels requires the name to be set to <code>*</code>.</p>
</td>
</tr>
</tbody>
Expand Down
27 changes: 26 additions & 1 deletion docs/spec/v1/receivers.md
Original file line number Diff line number Diff line change
Expand Up @@ -637,10 +637,35 @@ A resource entry contains the following fields:
`GitRepository`, `Kustomization`, `HelmRelease`, `HelmChart`,
`HelmRepository`, `ImageRepository`, `ImagePolicy`, `ImageUpdateAutomation`
and `OCIRepository`.
- `name`: The Flux Custom Resource `.metadata.name`.
- `name`: The Flux Custom Resource `.metadata.name` or `*` (if `matchLabels` is specified)
- `namespace` (Optional): The Flux Custom Resource `.metadata.namespace`.
When not specified, the Receiver's `.metadata.namespace` is used instead.
- `matchLabels` (Optional): Annotate Flux Custom Resources with specific labels.
The `name` field must be set to `*` when using `matchLabels`

#### Annotate objects by name

To annotate single Flux object, set the `kind`, `name` and `namespace`:

```yaml
resources:
- apiVersion: image.toolkit.fluxcd.io/v1beta1
kind: ImageRepository
name: podinfo
```

#### Annotate objects by label

To annotate Flux objects of a particular kind with specific labels:

```yaml
resources:
- apiVersion: image.toolkit.fluxcd.io/v1beta1
kind: ImageRepository
name: "*"
matchLabels:
app: podinfo
```

**Note:** Cross-namespace references [can be disabled for security
reasons](#disabling-cross-namespace-selectors).
Expand Down

0 comments on commit d558ae3

Please sign in to comment.