Skip to content

Commit

Permalink
feat: Remove validator.go
Browse files Browse the repository at this point in the history
  • Loading branch information
codablock committed Jul 5, 2023
1 parent 892dda1 commit 711717e
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 328 deletions.
19 changes: 0 additions & 19 deletions pkg/webui/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,6 @@ func (h *eventsHandler) startEventsWatcher() error {
return err
}

initialValidations, validationsCh, _ := h.server.vam.watch()

ctx := h.server.ctx

buildMsg := func(event results.WatchCommandResultSummaryEvent) string {
Expand All @@ -141,21 +139,10 @@ func (h *eventsHandler) startEventsWatcher() error {
return x
}
}
buildValidationMsg := func(event validationEvent) string {
x := yaml.WriteJsonStringMust(map[string]any{
"type": "validate_result",
"key": event.key,
"result": event.r,
})
return x
}

for _, x := range initial {
h.updateEvent(x.Id, ProjectTargetKey{Project: x.ProjectKey, Target: x.TargetKey}, buildMsg(results.WatchCommandResultSummaryEvent{Summary: x}), nil)
}
for _, x := range initialValidations {
h.updateEvent(uuid.NewString(), x.key, buildValidationMsg(x), &expireValidations)
}

go func() {
cleanupTimer := time.After(5 * time.Second)
Expand All @@ -171,12 +158,6 @@ func (h *eventsHandler) startEventsWatcher() error {
expireIn = &expireDeletions
}
h.updateEvent(event.Summary.Id, ProjectTargetKey{Project: event.Summary.ProjectKey, Target: event.Summary.TargetKey}, buildMsg(event), expireIn)
case event, ok := <-validationsCh:
if !ok {
status.Error(h.server.ctx, "validations channel closed unexpectedly")
return
}
h.updateEvent(uuid.NewString(), event.key, buildValidationMsg(event), &expireValidations)
case <-cleanupTimer:
h.cleanupEvents()
cleanupTimer = time.After(5 * time.Second)
Expand Down
15 changes: 7 additions & 8 deletions pkg/webui/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,15 @@ import (

const webuiManager = "kluctl-webui"

type ProjectTargetKey struct {
Project result.ProjectKey `json:"project"`
Target result.TargetKey `json:"target"`
}

type CommandResultsServer struct {
ctx context.Context
store results.ResultStore
cam *clusterAccessorManager
vam *validatorManager

// this is the client for the k8s cluster where the server runs on
serverClient client.Client
Expand Down Expand Up @@ -71,8 +75,6 @@ func NewCommandResultsServer(ctx context.Context, store *results.ResultsCollecto
ret.cam.add(config)
}

ret.vam = newValidatorManager(ctx, store, ret.cam, adminUser)

return ret
}

Expand Down Expand Up @@ -101,7 +103,6 @@ func (s *CommandResultsServer) Run(host string, port int) error {
}()

s.cam.start()
s.vam.start()

router := gin.Default()

Expand Down Expand Up @@ -332,10 +333,8 @@ func (s *CommandResultsServer) validateNow(c *gin.Context) {
Target: params.Target,
}

if !s.vam.validateNow(key) {
_ = c.AbortWithError(http.StatusNotFound, err)
return
}
_ = key
// TODO

c.Status(http.StatusOK)
}
Expand Down
301 changes: 0 additions & 301 deletions pkg/webui/validator.go

This file was deleted.

0 comments on commit 711717e

Please sign in to comment.