Skip to content

Commit

Permalink
Merge pull request #358 from MUzairS15/MUzairS15/events
Browse files Browse the repository at this point in the history
Add status and filter opts for `events`
  • Loading branch information
MUzairS15 committed Sep 2, 2023
2 parents ae6e13e + a593a0d commit 6467f33
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 16 deletions.
17 changes: 15 additions & 2 deletions models/events/build.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
package events

import (
"encoding/json"
"time"

"github.com/gofrs/uuid"
"gorm.io/gorm"
)

func (e *Event) BeforeCreate(tx *gorm.DB) (err error) {
e.ID, _ = uuid.NewV4()
return
}

type EventBuilder struct {
event Event
}
Expand Down Expand Up @@ -40,8 +47,9 @@ func (e *EventBuilder) WithAction(eventAction string) *EventBuilder {
return e
}

func (e *EventBuilder) WithMetadata(metadata interface{}) *EventBuilder {
e.event.Metadata = metadata
func (e *EventBuilder) WithMetadata(metadata map[string]interface{}) *EventBuilder {
b, _ := json.Marshal(metadata)
e.event.Metadata = b
return e
}

Expand All @@ -50,6 +58,11 @@ func (e *EventBuilder) WithSeverity(severity EventSeverity) *EventBuilder {
return e
}

func (e *EventBuilder) WithStatus(status string) *EventBuilder {
e.event.Status = status
return e
}

func (e *EventBuilder) FromUser(id uuid.UUID) *EventBuilder {
e.event.UserID = &id
return e
Expand Down
30 changes: 21 additions & 9 deletions models/events/events.go

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

9 changes: 4 additions & 5 deletions models/meshmodel/registry/host.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package registry
import (
"errors"
"fmt"
"strings"
"time"

"github.com/google/uuid"
Expand Down Expand Up @@ -67,15 +66,15 @@ func (ah ArtifactHub) HandleDependents(comp v1alpha1.Component, kc *kubernetes.C
})
if err != nil {
if !isDeploy {
summary = fmt.Sprintf("error undeploying dependent resources for %s, please proceed with manual uninstall or try again: %s", strings.TrimSuffix(comp.Spec.Type, ".K8s"), comp.Name)
summary = fmt.Sprintf("error undeploying dependent helm chart for %s, please proceed with manual uninstall or try again", comp.Name)
} else {
summary = fmt.Sprintf("error deploying dependent resources for %s, please procced with manual install or try again: %s", strings.TrimSuffix(comp.Spec.Type, ".K8s"), comp.Name)
summary = fmt.Sprintf("error deploying dependent helm chart for %s, please procced with manual install or try again", comp.Name)
}
} else {
if !isDeploy {
summary = fmt.Sprintf("Undeployed helm chart%s: %s", strings.TrimSuffix(comp.Spec.Type, ".K8s"), comp.Name)
summary = fmt.Sprintf("Undeployed dependent helm chart for %s", comp.Name)
} else {
summary = fmt.Sprintf("Deployed helm chart%s: %s", strings.TrimSuffix(comp.Spec.Type, ".K8s"), comp.Name)
summary = fmt.Sprintf("Deployed dependent helm chart for %s", comp.Name)
}
}
}
Expand Down

0 comments on commit 6467f33

Please sign in to comment.