Skip to content

Commit

Permalink
feat: add digitalocean_monitor_alert resource
Browse files Browse the repository at this point in the history
Signed-off-by: Yordis Prieto <[email protected]>
  • Loading branch information
yordis committed Apr 27, 2024
1 parent 1eb1de3 commit fbe436e
Show file tree
Hide file tree
Showing 8 changed files with 150 additions and 28 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ open an [issue](https://github.com/straw-hat-team/provider-digitalocean/issues).
- [ ] digitalocean_spaces_bucket_policy
- [ ] digitalocean_ssh_key
- [x] digitalocean_tag
- [ ] digitalocean_uptime_alert
- [x] digitalocean_uptime_alert
- [ ] digitalocean_uptime_check
- [ ] digitalocean_volume
- [ ] digitalocean_volume_attachment
Expand Down
13 changes: 9 additions & 4 deletions apis/monitor/v1alpha1/zz_alert_types.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 13 additions & 11 deletions apis/monitor/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

40 changes: 40 additions & 0 deletions apis/monitor/v1alpha1/zz_generated.resolvers.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions config/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,13 @@ func GetProvider() *ujconfig.Provider {
ExternalNameConfigurations(),
))

pc.AddResourceConfigurator("digitalocean_monitor_alert", func(r *ujconfig.Resource) {
r.UseAsync = false
r.References["entities"] = ujconfig.Reference{
Type: referenceType(pc, "compute", "v1alpha1", "Droplet"),
TerraformName: "digitalocean_droplet",
}
})
pc.AddResourceConfigurator("digitalocean_reserved_ip", func(r *ujconfig.Resource) {
r.ShortGroup = networkingGroup
r.UseAsync = false
Expand Down
4 changes: 2 additions & 2 deletions examples-generated/monitor/alert.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ spec:
compare: GreaterThan
description: Alert about CPU usage
enabled: true
entities:
- ${digitalocean_droplet.web.id}
entitiesRefs:
- name: web
type: v1/insights/droplet/cpu
value: 95
window: 5m
Expand Down
5 changes: 1 addition & 4 deletions internal/controller/monitor/alert/zz_controller.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

83 changes: 77 additions & 6 deletions package/crds/monitor.digitalocean.crossplane.io_alerts.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,83 @@ spec:
items:
type: string
type: array
entitiesRefs:
description: References to Droplet in compute to populate entities.
items:
description: A Reference to a named object.
properties:
name:
description: Name of the referenced object.
type: string
policy:
description: Policies for referencing.
properties:
resolution:
default: Required
description: Resolution specifies whether resolution
of this reference is required. The default is 'Required',
which means the reconcile will fail if the reference
cannot be resolved. 'Optional' means this reference
will be a no-op if it cannot be resolved.
enum:
- Required
- Optional
type: string
resolve:
description: Resolve specifies when this reference should
be resolved. The default is 'IfNotPresent', which
will attempt to resolve the reference only when the
corresponding field is not present. Use 'Always' to
resolve the reference on every reconcile.
enum:
- Always
- IfNotPresent
type: string
type: object
required:
- name
type: object
type: array
entitiesSelector:
description: Selector for a list of Droplet in compute to populate
entities.
properties:
matchControllerRef:
description: MatchControllerRef ensures an object with the
same controller reference as the selecting object is selected.
type: boolean
matchLabels:
additionalProperties:
type: string
description: MatchLabels ensures an object with matching labels
is selected.
type: object
policy:
description: Policies for selection.
properties:
resolution:
default: Required
description: Resolution specifies whether resolution of
this reference is required. The default is 'Required',
which means the reconcile will fail if the reference
cannot be resolved. 'Optional' means this reference
will be a no-op if it cannot be resolved.
enum:
- Required
- Optional
type: string
resolve:
description: Resolve specifies when this reference should
be resolved. The default is 'IfNotPresent', which will
attempt to resolve the reference only when the corresponding
field is not present. Use 'Always' to resolve the reference
on every reconcile.
enum:
- Always
- IfNotPresent
type: string
type: object
type: object
tags:
description: A list of tags. When an included tag is added to
a resource, the alert policy will apply to it.
Expand Down Expand Up @@ -193,12 +270,6 @@ spec:
enabled:
description: The status of the alert.
type: boolean
entities:
description: A list of IDs for the resources to which the alert
policy applies. The droplets to apply the alert policy to
items:
type: string
type: array
tags:
description: A list of tags. When an included tag is added to
a resource, the alert policy will apply to it.
Expand Down

0 comments on commit fbe436e

Please sign in to comment.