Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add status and filter opts for events #358

Merged
merged 2 commits into from
Sep 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading