diff --git a/config/crd/kustomization.yaml b/config/crd/kustomization.yaml index 14a7d4fe..7fb6e26c 100644 --- a/config/crd/kustomization.yaml +++ b/config/crd/kustomization.yaml @@ -11,11 +11,8 @@ resources: - bases/core.humio.com_humioactions.yaml - bases/core.humio.com_humioalerts.yaml - bases/core.humio.com_humiofilteralerts.yaml -<<<<<<< HEAD - bases/core.humio.com_humioscheduledsearches.yaml -======= - bases/core.humio.com_humioaggregatealerts.yaml ->>>>>>> 461e66a (Created AggregateAlerts Support) # +kubebuilder:scaffold:crdkustomizeresource patchesStrategicMerge: @@ -30,11 +27,8 @@ patchesStrategicMerge: #- patches/webhook_in_humioactions.yaml #- patches/webhook_in_humioalerts.yaml #- patches/webhook_in_humiofilteralerts.yaml -<<<<<<< HEAD #- patches/webhook_in_humioscheduledsearches.yaml -======= #- patches/webhook_in_humioaggregatealerts.yaml ->>>>>>> 461e66a (Created AggregateAlerts Support) # +kubebuilder:scaffold:crdkustomizewebhookpatch # [CERTMANAGER] To enable webhook, uncomment all the sections with [CERTMANAGER] prefix. @@ -48,11 +42,8 @@ patchesStrategicMerge: #- patches/cainjection_in_humioactions.yaml #- patches/cainjection_in_humioalerts.yaml #- patches/cainjection_in_humiofilteralerts.yaml -<<<<<<< HEAD #- patches/cainjection_in_humioscheduledsearches.yaml -======= #- patches/cainjection_in_humioaggregatealerts.yaml ->>>>>>> 461e66a (Created AggregateAlerts Support) # +kubebuilder:scaffold:crdkustomizecainjectionpatch # the following config is for teaching kustomize how to do kustomization for CRDs. diff --git a/controllers/suite/resources/humioresources_controller_test.go b/controllers/suite/resources/humioresources_controller_test.go index 905b7f92..4e24b3b6 100644 --- a/controllers/suite/resources/humioresources_controller_test.go +++ b/controllers/suite/resources/humioresources_controller_test.go @@ -3233,200 +3233,201 @@ var _ = Describe("Humio Resources Controllers", func() { suite.UsingClusterBy(clusterKey.Name, "HumioAggregateAlert: Creating the invalid aggregate alert") Expect(k8sClient.Create(ctx, toCreateInvalidAggregateAlert)).Should(Not(Succeed())) }) + }) - Context("Humio Scheduled Search", func() { - It("should handle scheduled search action correctly", func() { - ctx := context.Background() - suite.UsingClusterBy(clusterKey.Name, "HumioScheduledSearch: Should handle scheduled search correctly") - dependentEmailActionSpec := humiov1alpha1.HumioActionSpec{ - ManagedClusterName: clusterKey.Name, - Name: "example-email-action2", - ViewName: testRepo.Spec.Name, - EmailProperties: &humiov1alpha1.HumioActionEmailProperties{ - Recipients: []string{"example@example.com"}, - }, - } - - actionKey := types.NamespacedName{ - Name: "humioaction2", - Namespace: clusterKey.Namespace, - } - - toCreateDependentAction := &humiov1alpha1.HumioAction{ - ObjectMeta: metav1.ObjectMeta{ - Name: actionKey.Name, - Namespace: actionKey.Namespace, - }, - Spec: dependentEmailActionSpec, + Context("Humio Scheduled Search", func() { + It("should handle scheduled search action correctly", func() { + ctx := context.Background() + suite.UsingClusterBy(clusterKey.Name, "HumioScheduledSearch: Should handle scheduled search correctly") + dependentEmailActionSpec := humiov1alpha1.HumioActionSpec{ + ManagedClusterName: clusterKey.Name, + Name: "example-email-action2", + ViewName: testRepo.Spec.Name, + EmailProperties: &humiov1alpha1.HumioActionEmailProperties{ + Recipients: []string{"example@example.com"}, + }, + } + + actionKey := types.NamespacedName{ + Name: "humioaction2", + Namespace: clusterKey.Namespace, + } + + toCreateDependentAction := &humiov1alpha1.HumioAction{ + ObjectMeta: metav1.ObjectMeta{ + Name: actionKey.Name, + Namespace: actionKey.Namespace, + }, + Spec: dependentEmailActionSpec, + } + + suite.UsingClusterBy(clusterKey.Name, "HumioScheduledSearch: Creating the action required by the scheduled search successfully") + Expect(k8sClient.Create(ctx, toCreateDependentAction)).Should(Succeed()) + + fetchedAction := &humiov1alpha1.HumioAction{} + Eventually(func() string { + k8sClient.Get(ctx, actionKey, fetchedAction) + return fetchedAction.Status.State + }, testTimeout, suite.TestInterval).Should(Equal(humiov1alpha1.HumioActionStateExists)) + + scheduledSearchSpec := humiov1alpha1.HumioScheduledSearchSpec{ + ManagedClusterName: clusterKey.Name, + Name: "example-scheduled-search", + ViewName: testRepo.Spec.Name, + QueryString: "#repo = humio | error = true", + QueryStart: "1h", + QueryEnd: "now", + Schedule: "0 * * * *", + TimeZone: "UTC", + BackfillLimit: 3, + Enabled: true, + Description: "humio scheduled search", + Actions: []string{toCreateDependentAction.Spec.Name}, + Labels: []string{"some-label"}, + } + + key := types.NamespacedName{ + Name: "humio-scheduled-search", + Namespace: clusterKey.Namespace, + } + + toCreateScheduledSearch := &humiov1alpha1.HumioScheduledSearch{ + ObjectMeta: metav1.ObjectMeta{ + Name: key.Name, + Namespace: key.Namespace, + }, + Spec: scheduledSearchSpec, + } + + suite.UsingClusterBy(clusterKey.Name, "HumioScheduledSearch: Creating the scheduled search successfully") + Expect(k8sClient.Create(ctx, toCreateScheduledSearch)).Should(Succeed()) + + fetchedScheduledSearch := &humiov1alpha1.HumioScheduledSearch{} + Eventually(func() string { + k8sClient.Get(ctx, key, fetchedScheduledSearch) + return fetchedScheduledSearch.Status.State + }, testTimeout, suite.TestInterval).Should(Equal(humiov1alpha1.HumioScheduledSearchStateExists)) + + var scheduledSearch *humioapi.ScheduledSearch + Eventually(func() error { + scheduledSearch, err = humioClient.GetScheduledSearch(sharedCluster.Config(), reconcile.Request{NamespacedName: clusterKey}, toCreateScheduledSearch) + return err + }, testTimeout, suite.TestInterval).Should(Succeed()) + Expect(scheduledSearch).ToNot(BeNil()) + + Eventually(func() error { + return humioClient.ValidateActionsForScheduledSearch(sharedCluster.Config(), reconcile.Request{NamespacedName: clusterKey}, toCreateScheduledSearch) + }, testTimeout, suite.TestInterval).Should(Succeed()) + + originalScheduledSearch, err := humio.ScheduledSearchTransform(toCreateScheduledSearch) + Expect(err).To(BeNil()) + Expect(scheduledSearch.Name).To(Equal(originalScheduledSearch.Name)) + Expect(scheduledSearch.Description).To(Equal(originalScheduledSearch.Description)) + Expect(scheduledSearch.ActionNames).To(Equal(originalScheduledSearch.ActionNames)) + Expect(scheduledSearch.Labels).To(Equal(originalScheduledSearch.Labels)) + Expect(scheduledSearch.Enabled).To(Equal(originalScheduledSearch.Enabled)) + Expect(scheduledSearch.QueryString).To(Equal(originalScheduledSearch.QueryString)) + Expect(scheduledSearch.QueryStart).To(Equal(originalScheduledSearch.QueryStart)) + Expect(scheduledSearch.QueryEnd).To(Equal(originalScheduledSearch.QueryEnd)) + Expect(scheduledSearch.Schedule).To(Equal(originalScheduledSearch.Schedule)) + Expect(scheduledSearch.TimeZone).To(Equal(originalScheduledSearch.TimeZone)) + Expect(scheduledSearch.BackfillLimit).To(Equal(originalScheduledSearch.BackfillLimit)) + + createdScheduledSearch := toCreateScheduledSearch + err = humio.ScheduledSearchHydrate(createdScheduledSearch, scheduledSearch) + Expect(err).To(BeNil()) + Expect(createdScheduledSearch.Spec).To(Equal(toCreateScheduledSearch.Spec)) + + suite.UsingClusterBy(clusterKey.Name, "HumioScheduledSearch: Updating the scheduled search successfully") + updatedScheduledSearch := toCreateScheduledSearch + updatedScheduledSearch.Spec.QueryString = "#repo = humio | updated_field = true | error = true" + updatedScheduledSearch.Spec.QueryStart = "2h" + updatedScheduledSearch.Spec.QueryEnd = "30m" + updatedScheduledSearch.Spec.Schedule = "0 0 * * *" + updatedScheduledSearch.Spec.TimeZone = "UTC-01" + updatedScheduledSearch.Spec.BackfillLimit = 5 + updatedScheduledSearch.Spec.Enabled = false + updatedScheduledSearch.Spec.Description = "updated humio scheduled search" + updatedScheduledSearch.Spec.Actions = []string{toCreateDependentAction.Spec.Name} + + suite.UsingClusterBy(clusterKey.Name, "HumioScheduledSearch: Waiting for the scheduled search to be updated") + Eventually(func() error { + k8sClient.Get(ctx, key, fetchedScheduledSearch) + fetchedScheduledSearch.Spec.QueryString = updatedScheduledSearch.Spec.QueryString + fetchedScheduledSearch.Spec.QueryStart = updatedScheduledSearch.Spec.QueryStart + fetchedScheduledSearch.Spec.QueryEnd = updatedScheduledSearch.Spec.QueryEnd + fetchedScheduledSearch.Spec.Schedule = updatedScheduledSearch.Spec.Schedule + fetchedScheduledSearch.Spec.TimeZone = updatedScheduledSearch.Spec.TimeZone + fetchedScheduledSearch.Spec.BackfillLimit = updatedScheduledSearch.Spec.BackfillLimit + fetchedScheduledSearch.Spec.Enabled = updatedScheduledSearch.Spec.Enabled + fetchedScheduledSearch.Spec.Description = updatedScheduledSearch.Spec.Description + return k8sClient.Update(ctx, fetchedScheduledSearch) + }, testTimeout, suite.TestInterval).Should(Succeed()) + + suite.UsingClusterBy(clusterKey.Name, "HumioScheduledSearch: Verifying the scheduled search update succeeded") + var expectedUpdatedScheduledSearch *humioapi.ScheduledSearch + Eventually(func() error { + expectedUpdatedScheduledSearch, err = humioClient.GetScheduledSearch(sharedCluster.Config(), reconcile.Request{NamespacedName: clusterKey}, fetchedScheduledSearch) + return err + }, testTimeout, suite.TestInterval).Should(Succeed()) + Expect(expectedUpdatedScheduledSearch).ToNot(BeNil()) + + suite.UsingClusterBy(clusterKey.Name, "HumioScheduledSearch: Verifying the scheduled search matches the expected") + verifiedScheduledSearch, err := humio.ScheduledSearchTransform(updatedScheduledSearch) + verifiedScheduledSearch.ID = "" + verifiedScheduledSearch.RunAsUserID = "" + + Expect(err).To(BeNil()) + Eventually(func() humioapi.ScheduledSearch { + updatedScheduledSearch, err := humioClient.GetScheduledSearch(sharedCluster.Config(), reconcile.Request{NamespacedName: clusterKey}, fetchedScheduledSearch) + if err != nil { + return *updatedScheduledSearch } - - suite.UsingClusterBy(clusterKey.Name, "HumioScheduledSearch: Creating the action required by the scheduled search successfully") - Expect(k8sClient.Create(ctx, toCreateDependentAction)).Should(Succeed()) - - fetchedAction := &humiov1alpha1.HumioAction{} - Eventually(func() string { - k8sClient.Get(ctx, actionKey, fetchedAction) - return fetchedAction.Status.State - }, testTimeout, suite.TestInterval).Should(Equal(humiov1alpha1.HumioActionStateExists)) - - scheduledSearchSpec := humiov1alpha1.HumioScheduledSearchSpec{ + + // Ignore the ID and RunAsUserID + updatedScheduledSearch.ID = "" + updatedScheduledSearch.RunAsUserID = "" + + return *updatedScheduledSearch + }, testTimeout, suite.TestInterval).Should(Equal(*verifiedScheduledSearch)) + + suite.UsingClusterBy(clusterKey.Name, "HumioScheduledSearch: Successfully deleting the scheduled search") + Expect(k8sClient.Delete(ctx, fetchedScheduledSearch)).To(Succeed()) + Eventually(func() bool { + err := k8sClient.Get(ctx, key, fetchedScheduledSearch) + return k8serrors.IsNotFound(err) + }, testTimeout, suite.TestInterval).Should(BeTrue()) + + suite.UsingClusterBy(clusterKey.Name, "HumioScheduledSearch: Successfully deleting the action") + Expect(k8sClient.Delete(ctx, fetchedAction)).To(Succeed()) + Eventually(func() bool { + err := k8sClient.Get(ctx, actionKey, fetchedAction) + return k8serrors.IsNotFound(err) + }, testTimeout, suite.TestInterval).Should(BeTrue()) + }) + + It("HumioScheduledSearch: Should deny improperly configured scheduled search with missing required values", func() { + ctx := context.Background() + key := types.NamespacedName{ + Name: "humio-scheduled-search", + Namespace: clusterKey.Namespace, + } + toCreateInvalidScheduledSearch := &humiov1alpha1.HumioScheduledSearch{ + ObjectMeta: metav1.ObjectMeta{ + Name: key.Name, + Namespace: key.Namespace, + }, + Spec: humiov1alpha1.HumioScheduledSearchSpec{ ManagedClusterName: clusterKey.Name, - Name: "example-scheduled-search", + Name: "example-invalid-scheduled-search", ViewName: testRepo.Spec.Name, - QueryString: "#repo = humio | error = true", - QueryStart: "1h", - QueryEnd: "now", - Schedule: "0 * * * *", - TimeZone: "UTC", - BackfillLimit: 3, - Enabled: true, - Description: "humio scheduled search", - Actions: []string{toCreateDependentAction.Spec.Name}, - Labels: []string{"some-label"}, - } - - key := types.NamespacedName{ - Name: "humio-scheduled-search", - Namespace: clusterKey.Namespace, - } - - toCreateScheduledSearch := &humiov1alpha1.HumioScheduledSearch{ - ObjectMeta: metav1.ObjectMeta{ - Name: key.Name, - Namespace: key.Namespace, - }, - Spec: scheduledSearchSpec, - } - - suite.UsingClusterBy(clusterKey.Name, "HumioScheduledSearch: Creating the scheduled search successfully") - Expect(k8sClient.Create(ctx, toCreateScheduledSearch)).Should(Succeed()) - - fetchedScheduledSearch := &humiov1alpha1.HumioScheduledSearch{} - Eventually(func() string { - k8sClient.Get(ctx, key, fetchedScheduledSearch) - return fetchedScheduledSearch.Status.State - }, testTimeout, suite.TestInterval).Should(Equal(humiov1alpha1.HumioScheduledSearchStateExists)) - - var scheduledSearch *humioapi.ScheduledSearch - Eventually(func() error { - scheduledSearch, err = humioClient.GetScheduledSearch(sharedCluster.Config(), reconcile.Request{NamespacedName: clusterKey}, toCreateScheduledSearch) - return err - }, testTimeout, suite.TestInterval).Should(Succeed()) - Expect(scheduledSearch).ToNot(BeNil()) - - Eventually(func() error { - return humioClient.ValidateActionsForScheduledSearch(sharedCluster.Config(), reconcile.Request{NamespacedName: clusterKey}, toCreateScheduledSearch) - }, testTimeout, suite.TestInterval).Should(Succeed()) - - originalScheduledSearch, err := humio.ScheduledSearchTransform(toCreateScheduledSearch) - Expect(err).To(BeNil()) - Expect(scheduledSearch.Name).To(Equal(originalScheduledSearch.Name)) - Expect(scheduledSearch.Description).To(Equal(originalScheduledSearch.Description)) - Expect(scheduledSearch.ActionNames).To(Equal(originalScheduledSearch.ActionNames)) - Expect(scheduledSearch.Labels).To(Equal(originalScheduledSearch.Labels)) - Expect(scheduledSearch.Enabled).To(Equal(originalScheduledSearch.Enabled)) - Expect(scheduledSearch.QueryString).To(Equal(originalScheduledSearch.QueryString)) - Expect(scheduledSearch.QueryStart).To(Equal(originalScheduledSearch.QueryStart)) - Expect(scheduledSearch.QueryEnd).To(Equal(originalScheduledSearch.QueryEnd)) - Expect(scheduledSearch.Schedule).To(Equal(originalScheduledSearch.Schedule)) - Expect(scheduledSearch.TimeZone).To(Equal(originalScheduledSearch.TimeZone)) - Expect(scheduledSearch.BackfillLimit).To(Equal(originalScheduledSearch.BackfillLimit)) - - createdScheduledSearch := toCreateScheduledSearch - err = humio.ScheduledSearchHydrate(createdScheduledSearch, scheduledSearch) - Expect(err).To(BeNil()) - Expect(createdScheduledSearch.Spec).To(Equal(toCreateScheduledSearch.Spec)) - - suite.UsingClusterBy(clusterKey.Name, "HumioScheduledSearch: Updating the scheduled search successfully") - updatedScheduledSearch := toCreateScheduledSearch - updatedScheduledSearch.Spec.QueryString = "#repo = humio | updated_field = true | error = true" - updatedScheduledSearch.Spec.QueryStart = "2h" - updatedScheduledSearch.Spec.QueryEnd = "30m" - updatedScheduledSearch.Spec.Schedule = "0 0 * * *" - updatedScheduledSearch.Spec.TimeZone = "UTC-01" - updatedScheduledSearch.Spec.BackfillLimit = 5 - updatedScheduledSearch.Spec.Enabled = false - updatedScheduledSearch.Spec.Description = "updated humio scheduled search" - updatedScheduledSearch.Spec.Actions = []string{toCreateDependentAction.Spec.Name} - - suite.UsingClusterBy(clusterKey.Name, "HumioScheduledSearch: Waiting for the scheduled search to be updated") - Eventually(func() error { - k8sClient.Get(ctx, key, fetchedScheduledSearch) - fetchedScheduledSearch.Spec.QueryString = updatedScheduledSearch.Spec.QueryString - fetchedScheduledSearch.Spec.QueryStart = updatedScheduledSearch.Spec.QueryStart - fetchedScheduledSearch.Spec.QueryEnd = updatedScheduledSearch.Spec.QueryEnd - fetchedScheduledSearch.Spec.Schedule = updatedScheduledSearch.Spec.Schedule - fetchedScheduledSearch.Spec.TimeZone = updatedScheduledSearch.Spec.TimeZone - fetchedScheduledSearch.Spec.BackfillLimit = updatedScheduledSearch.Spec.BackfillLimit - fetchedScheduledSearch.Spec.Enabled = updatedScheduledSearch.Spec.Enabled - fetchedScheduledSearch.Spec.Description = updatedScheduledSearch.Spec.Description - return k8sClient.Update(ctx, fetchedScheduledSearch) - }, testTimeout, suite.TestInterval).Should(Succeed()) - - suite.UsingClusterBy(clusterKey.Name, "HumioScheduledSearch: Verifying the scheduled search update succeeded") - var expectedUpdatedScheduledSearch *humioapi.ScheduledSearch - Eventually(func() error { - expectedUpdatedScheduledSearch, err = humioClient.GetScheduledSearch(sharedCluster.Config(), reconcile.Request{NamespacedName: clusterKey}, fetchedScheduledSearch) - return err - }, testTimeout, suite.TestInterval).Should(Succeed()) - Expect(expectedUpdatedScheduledSearch).ToNot(BeNil()) - - suite.UsingClusterBy(clusterKey.Name, "HumioScheduledSearch: Verifying the scheduled search matches the expected") - verifiedScheduledSearch, err := humio.ScheduledSearchTransform(updatedScheduledSearch) - verifiedScheduledSearch.ID = "" - verifiedScheduledSearch.RunAsUserID = "" - - Expect(err).To(BeNil()) - Eventually(func() humioapi.ScheduledSearch { - updatedScheduledSearch, err := humioClient.GetScheduledSearch(sharedCluster.Config(), reconcile.Request{NamespacedName: clusterKey}, fetchedScheduledSearch) - if err != nil { - return *updatedScheduledSearch - } - - // Ignore the ID and RunAsUserID - updatedScheduledSearch.ID = "" - updatedScheduledSearch.RunAsUserID = "" - - return *updatedScheduledSearch - }, testTimeout, suite.TestInterval).Should(Equal(*verifiedScheduledSearch)) - - suite.UsingClusterBy(clusterKey.Name, "HumioScheduledSearch: Successfully deleting the scheduled search") - Expect(k8sClient.Delete(ctx, fetchedScheduledSearch)).To(Succeed()) - Eventually(func() bool { - err := k8sClient.Get(ctx, key, fetchedScheduledSearch) - return k8serrors.IsNotFound(err) - }, testTimeout, suite.TestInterval).Should(BeTrue()) - - suite.UsingClusterBy(clusterKey.Name, "HumioScheduledSearch: Successfully deleting the action") - Expect(k8sClient.Delete(ctx, fetchedAction)).To(Succeed()) - Eventually(func() bool { - err := k8sClient.Get(ctx, actionKey, fetchedAction) - return k8serrors.IsNotFound(err) - }, testTimeout, suite.TestInterval).Should(BeTrue()) - }) - - It("HumioScheduledSearch: Should deny improperly configured scheduled search with missing required values", func() { - ctx := context.Background() - key := types.NamespacedName{ - Name: "humio-scheduled-search", - Namespace: clusterKey.Namespace, - } - toCreateInvalidScheduledSearch := &humiov1alpha1.HumioScheduledSearch{ - ObjectMeta: metav1.ObjectMeta{ - Name: key.Name, - Namespace: key.Namespace, - }, - Spec: humiov1alpha1.HumioScheduledSearchSpec{ - ManagedClusterName: clusterKey.Name, - Name: "example-invalid-scheduled-search", - ViewName: testRepo.Spec.Name, - }, - } - - suite.UsingClusterBy(clusterKey.Name, "HumioScheduledSearch: Creating the invalid scheduled search") - Expect(k8sClient.Create(ctx, toCreateInvalidScheduledSearch)).Should(Not(Succeed())) - }) - + }, + } + + suite.UsingClusterBy(clusterKey.Name, "HumioScheduledSearch: Creating the invalid scheduled search") + Expect(k8sClient.Create(ctx, toCreateInvalidScheduledSearch)).Should(Not(Succeed())) + }) + }) }) diff --git a/go.mod b/go.mod index a60e983a..3fe91fa0 100644 --- a/go.mod +++ b/go.mod @@ -11,8 +11,8 @@ require ( github.com/go-logr/zapr v1.3.0 github.com/google/go-cmp v0.6.0 github.com/humio/cli v0.36.0 - github.com/onsi/ginkgo/v2 v2.17.1 - github.com/onsi/gomega v1.32.0 + github.com/onsi/ginkgo/v2 v2.19.0 + github.com/onsi/gomega v1.34.1 github.com/prometheus/client_golang v1.19.0 go.uber.org/zap v1.27.0 k8s.io/api v0.29.5 @@ -32,13 +32,13 @@ require ( github.com/go-openapi/jsonpointer v0.21.0 // indirect github.com/go-openapi/jsonreference v0.21.0 // indirect github.com/go-openapi/swag v0.23.0 // indirect - github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 // indirect + github.com/go-task/slim-sprig/v3 v3.0.0 // indirect github.com/gogo/protobuf v1.3.2 // indirect github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect github.com/golang/protobuf v1.5.4 // indirect github.com/google/gnostic-models v0.6.8 // indirect github.com/google/gofuzz v1.2.0 // indirect - github.com/google/pprof v0.0.0-20240415144954-be81aee2d733 // indirect + github.com/google/pprof v0.0.0-20240424215950-a892ee059fd6 // indirect github.com/google/uuid v1.6.0 // indirect github.com/imdario/mergo v0.3.16 // indirect github.com/josharian/intern v1.0.0 // indirect @@ -53,17 +53,18 @@ require ( github.com/prometheus/procfs v0.13.0 // indirect github.com/spf13/pflag v1.0.5 // indirect go.uber.org/multierr v1.11.0 // indirect - golang.org/x/crypto v0.24.0 // indirect - golang.org/x/net v0.26.0 // indirect + golang.org/x/crypto v0.25.0 // indirect + golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56 // indirect + golang.org/x/net v0.27.0 // indirect golang.org/x/oauth2 v0.19.0 // indirect golang.org/x/sync v0.7.0 // indirect - golang.org/x/sys v0.21.0 // indirect - golang.org/x/term v0.21.0 // indirect + golang.org/x/sys v0.22.0 // indirect + golang.org/x/term v0.22.0 // indirect golang.org/x/text v0.16.0 // indirect golang.org/x/time v0.5.0 // indirect - golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d // indirect + golang.org/x/tools v0.23.0 // indirect gomodules.xyz/jsonpatch/v2 v2.4.0 // indirect - google.golang.org/protobuf v1.33.0 // indirect + google.golang.org/protobuf v1.34.1 // indirect gopkg.in/inf.v0 v0.9.1 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect diff --git a/pkg/humio/aggregatealert_transform.go b/pkg/humio/aggregatealert_transform.go index c92a69f6..70245bcf 100644 --- a/pkg/humio/aggregatealert_transform.go +++ b/pkg/humio/aggregatealert_transform.go @@ -21,7 +21,6 @@ func AggregateAlertTransform(haa *humiov1alpha1.HumioAggregateAlert) (*humioapi. Enabled: haa.Spec.Enabled, ActionNames: haa.Spec.Actions, Labels: haa.Spec.Labels, - QueryOwnershipType: QueryOwnershipTypeDefault, } if _, ok := haa.ObjectMeta.Annotations[AggregatedAlertIdentifierAnnotation]; ok { diff --git a/pkg/humio/client.go b/pkg/humio/client.go index fd4abe57..515ccc35 100644 --- a/pkg/humio/client.go +++ b/pkg/humio/client.go @@ -597,7 +597,7 @@ func (h *ClientConfig) InstallLicense(config *humioapi.Config, req reconcile.Req func (h *ClientConfig) GetAlert(config *humioapi.Config, req reconcile.Request, ha *humiov1alpha1.HumioAlert) (*humioapi.Alert, error) { err := h.validateView(config, req, ha.Spec.ViewName) if err != nil { - return &humioapi.Alert{}, fmt.Errorf("problem getting view for action %s: %w", ha.Spec.Name, err) + return &humioapi.Alert{}, fmt.Errorf("problem getting view for alert %s: %w", ha.Spec.Name, err) } alert, err := h.GetHumioClient(config, req).Alerts().Get(ha.Spec.ViewName, ha.Spec.Name) @@ -665,7 +665,7 @@ func (h *ClientConfig) DeleteAlert(config *humioapi.Config, req reconcile.Reques func (h *ClientConfig) GetFilterAlert(config *humioapi.Config, req reconcile.Request, hfa *humiov1alpha1.HumioFilterAlert) (*humioapi.FilterAlert, error) { err := h.validateView(config, req, hfa.Spec.ViewName) if err != nil { - return &humioapi.FilterAlert{}, fmt.Errorf("problem getting view for action %s: %w", hfa.Spec.Name, err) + return &humioapi.FilterAlert{}, fmt.Errorf("problem getting view for filter alert %s: %w", hfa.Spec.Name, err) } var filterAlertId string @@ -867,12 +867,15 @@ func (h *ClientConfig) ValidateActionsForFilterAlert(config *humioapi.Config, re return nil } -<<<<<<< HEAD func (h *ClientConfig) ValidateActionsForScheduledSearch(config *humioapi.Config, req reconcile.Request, hss *humiov1alpha1.HumioScheduledSearch) error { for _, actionNameForScheduledSearch := range hss.Spec.Actions { if _, err := h.getAndValidateAction(config, req, actionNameForScheduledSearch, hss.Spec.ViewName); err != nil { return fmt.Errorf("problem getting action for scheduled search %s: %w", hss.Spec.Name, err) -======= + } + } + return nil +} + func (h *ClientConfig) AddAggregateAlert(config *humioapi.Config, req reconcile.Request, haa *humiov1alpha1.HumioAggregateAlert) (*humioapi.AggregateAlert, error) { err := h.validateView(config, req, haa.Spec.ViewName) if err != nil { @@ -960,7 +963,6 @@ func (h *ClientConfig) ValidateActionsForAggregateAlert(config *humioapi.Config, for _, actionNameForAlert := range haa.Spec.Actions { if _, err := h.getAndValidateAction(config, req, actionNameForAlert, haa.Spec.ViewName); err != nil { return fmt.Errorf("problem getting action for aggregate alert %s: %w", haa.Spec.Name, err) ->>>>>>> 461e66a (Created AggregateAlerts Support) } } return nil diff --git a/pkg/humio/client_mock.go b/pkg/humio/client_mock.go index df761f7a..f51f0507 100644 --- a/pkg/humio/client_mock.go +++ b/pkg/humio/client_mock.go @@ -408,5 +408,6 @@ func (h *MockClientConfig) ClearHumioClientConnections() { h.apiClient.Action = humioapi.Action{} h.apiClient.Alert = humioapi.Alert{} h.apiClient.FilterAlert = humioapi.FilterAlert{} + h.apiClient.AggregateAlert = humioapi.AggregateAlert{} h.apiClient.ScheduledSearch = humioapi.ScheduledSearch{} }