From 78f0329b98d076c4efdbc7939babd4b40edc9b64 Mon Sep 17 00:00:00 2001 From: Gabe Cook Date: Wed, 17 Apr 2024 02:38:36 -0500 Subject: [PATCH] chore(monitor): `friendlyName` -> `name`, `httpMethod` -> `method` --- api/v1/monitor_types.go | 8 ++--- .../uptime-robot.clevyr.com_monitors.yaml | 33 +++++++++---------- config/samples/uptime-robot_v1_monitor.yaml | 2 +- internal/controller/ingress_controller.go | 2 +- internal/uptimerobot/client.go | 6 ++-- 5 files changed, 25 insertions(+), 26 deletions(-) diff --git a/api/v1/monitor_types.go b/api/v1/monitor_types.go index f19558c..a4ab1a1 100644 --- a/api/v1/monitor_types.go +++ b/api/v1/monitor_types.go @@ -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"` @@ -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"` diff --git a/config/crd/bases/uptime-robot.clevyr.com_monitors.yaml b/config/crd/bases/uptime-robot.clevyr.com_monitors.yaml index 6f2a3a5..1694ff5 100644 --- a/config/crd/bases/uptime-robot.clevyr.com_monitors.yaml +++ b/config/crd/bases/uptime-robot.clevyr.com_monitors.yaml @@ -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. @@ -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. @@ -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: diff --git a/config/samples/uptime-robot_v1_monitor.yaml b/config/samples/uptime-robot_v1_monitor.yaml index 2719393..e111d15 100644 --- a/config/samples/uptime-robot_v1_monitor.yaml +++ b/config/samples/uptime-robot_v1_monitor.yaml @@ -9,6 +9,6 @@ spec: interval: 24h prune: true monitor: - friendlyName: Example + name: Example url: https://example.com interval: 5m diff --git a/internal/controller/ingress_controller.go b/internal/controller/ingress_controller.go index 7f1163e..de3876e 100644 --- a/internal/controller/ingress_controller.go +++ b/internal/controller/ingress_controller.go @@ -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 diff --git a/internal/uptimerobot/client.go b/internal/uptimerobot/client.go index 5d689a4..c602adb 100644 --- a/internal/uptimerobot/client.go +++ b/internal/uptimerobot/client.go @@ -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 {