Skip to content

Commit

Permalink
chore(monitor): friendlyName -> name, httpMethod -> method
Browse files Browse the repository at this point in the history
  • Loading branch information
gabe565 committed Apr 17, 2024
1 parent 41d1809 commit 78f0329
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 26 deletions.
8 changes: 4 additions & 4 deletions api/v1/monitor_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ type Monitor struct {
//+kubebuilder:validation:XValidation:rule="self.type != 'Port' || has(self.port)", message="Port config is required if type is Port"

type MonitorValues struct {
// FriendlyName sets the name that is shown in Uptime Robot.
FriendlyName string `json:"friendlyName"`
// Name sets the name that is shown in Uptime Robot.
Name string `json:"name"`

// URL is the URL or IP to monitor, including the scheme.
URL string `json:"url"`
Expand All @@ -101,9 +101,9 @@ type MonitorValues struct {
//+kubebuilder:default:="30s"
Timeout *metav1.Duration `json:"timeout,omitempty"`

// HTTPMethod defines the HTTP verb to use.
// Method defines the HTTP verb to use.
//+kubebuilder:default:="HEAD"
HTTPMethod urtypes.HTTPMethod `json:"httpMethod,omitempty"`
Method urtypes.HTTPMethod `json:"method,omitempty"`

// POST configures POST, PUT, PATCH, DELETE, and OPTIONS requests.
POST *MonitorPOST `json:"post,omitempty"`
Expand Down
33 changes: 16 additions & 17 deletions config/crd/bases/uptime-robot.clevyr.com_monitors.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -119,22 +119,6 @@ spec:
required:
- type
type: object
friendlyName:
description: FriendlyName sets the name that is shown in Uptime
Robot.
type: string
httpMethod:
default: HEAD
description: HTTPMethod defines the HTTP verb to use.
enum:
- HEAD
- GET
- POST
- PUT
- PATCH
- DELETE
- OPTIONS
type: string
interval:
default: 60s
description: Interval is the monitoring interval.
Expand All @@ -157,6 +141,21 @@ spec:
- type
- value
type: object
method:
default: HEAD
description: Method defines the HTTP verb to use.
enum:
- HEAD
- GET
- POST
- PUT
- PATCH
- DELETE
- OPTIONS
type: string
name:
description: Name sets the name that is shown in Uptime Robot.
type: string
port:
description: Port provides configuration for the Port monitor
type.
Expand Down Expand Up @@ -228,7 +227,7 @@ spec:
description: URL is the URL or IP to monitor, including the scheme.
type: string
required:
- friendlyName
- name
- url
type: object
x-kubernetes-validations:
Expand Down
2 changes: 1 addition & 1 deletion config/samples/uptime-robot_v1_monitor.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ spec:
interval: 24h
prune: true
monitor:
friendlyName: Example
name: Example
url: https://example.com
interval: 5m
2 changes: 1 addition & 1 deletion internal/controller/ingress_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ func (r *IngressReconciler) getMatchingAnnotations(ingress *networkingv1.Ingress
}

func (r *IngressReconciler) updateValues(ingress *networkingv1.Ingress, monitor *uptimerobotv1.Monitor, annotations map[string]string) error {
monitor.Spec.Monitor.FriendlyName = ingress.Name
monitor.Spec.Monitor.Name = ingress.Name
if _, ok := annotations["monitor.url"]; !ok {
if len(ingress.Spec.Rules) != 0 {
var u url.URL
Expand Down
6 changes: 3 additions & 3 deletions internal/uptimerobot/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,14 +70,14 @@ func (c Client) Do(ctx context.Context, endpoint string, form url.Values) (*http
}

func (c Client) MonitorValues(monitor uptimerobotv1.MonitorValues, form url.Values, contacts uptimerobotv1.MonitorContacts) url.Values {
form.Set("friendly_name", monitor.FriendlyName)
form.Set("friendly_name", monitor.Name)
form.Set("url", monitor.URL)
form.Set("type", strconv.Itoa(int(monitor.Type)))
form.Set("interval", strconv.Itoa(int(monitor.Interval.Seconds())))
form.Set("timeout", strconv.Itoa(int(monitor.Timeout.Seconds())))
form.Set("alert_contacts", contacts.String())
form.Set("http_method", strconv.Itoa(int(monitor.HTTPMethod)))
switch monitor.HTTPMethod {
form.Set("http_method", strconv.Itoa(int(monitor.Method)))
switch monitor.Method {
case urtypes.MethodHEAD, urtypes.MethodGET:
default:
if monitor.POST != nil {
Expand Down

0 comments on commit 78f0329

Please sign in to comment.