Skip to content

Commit

Permalink
feat: BREAKING moved business service to cluster scoped
Browse files Browse the repository at this point in the history
  • Loading branch information
mattgialelis committed Jul 3, 2024
1 parent 542e471 commit 53a4f0d
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 5 deletions.
1 change: 0 additions & 1 deletion PROJECT
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ repo: github.com/mattgialelis/dutycontroller
resources:
- api:
crdVersion: v1
namespaced: true
controller: true
domain: dutycontroller.io
group: pagerduty
Expand Down
2 changes: 2 additions & 0 deletions api/v1beta1/businessservice_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ type BusinessServiceStatus struct {

// +kubebuilder:object:root=true
// +kubebuilder:subresource:status
// +kubebuilder:resource:scope=Cluster

// BusinessService is the Schema for the businessservices API
type BusinessService struct {
metav1.TypeMeta `json:",inline"`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ spec:
listKind: BusinessServiceList
plural: businessservices
singular: businessservice
scope: Namespaced
scope: Cluster
versions:
- name: v1beta1
schema:
Expand Down
2 changes: 1 addition & 1 deletion config/samples/pagerduty_v1beta1_services.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ metadata:
spec:
acknowledgeTimeout: 300
autoResolveTimeout: 600
businessService: "example-businessservice"
businessService: "businessservice-sample"
description: "My services"
escalationPolicy: "test1-ep"
status: "Active"
Original file line number Diff line number Diff line change
Expand Up @@ -93,13 +93,15 @@ func (r *BusinessServiceReconciler) Reconcile(ctx context.Context, req ctrl.Requ
}

businesService.Status.ID = id
log.Info("Created BusinessService", "ID", id, "Name", businesService.Name)
return ctrl.Result{}, nil
}

err = r.PagerClient.UpdateBusinessService(pagerbusinesService)
if err != nil {
return ctrl.Result{}, fmt.Errorf("could not update business service: %w", err)
}
log.Info("Updated BusinessService", "ID", businesService.Status.ID, "Name", businesService.Name)

// Check if the BusinessService instance is marked for deletion
if businesService.DeletionTimestamp.IsZero() {
Expand Down
3 changes: 1 addition & 2 deletions pkg/controller/pagerduty/services/services_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,8 +171,7 @@ func (r *ServicesReconciler) getBusinessServiceId(ctx context.Context, service *
if service.Spec.BusinessService != "" {
var businessService pagerdutyv1beta1.BusinessService
if err := r.Get(ctx, client.ObjectKey{
Namespace: service.Namespace,
Name: service.Spec.BusinessService,
Name: service.Spec.BusinessService,
}, &businessService); err != nil {
if apierrors.IsNotFound(err) {
log.Info("BusinessService not found in cluster, fetching from PagerDuty", "namespace", service.Namespace, "name", service.Spec.BusinessService)
Expand Down

0 comments on commit 53a4f0d

Please sign in to comment.