Skip to content

Commit

Permalink
implement list command
Browse files Browse the repository at this point in the history
  • Loading branch information
ouzu authored and pfandzelter committed Jul 25, 2023
1 parent 893a091 commit 7b264c8
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
8 changes: 8 additions & 0 deletions cmd/manager/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,14 @@ func (s *server) listHandler(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(http.StatusBadRequest)
return
}

l := s.ms.List()

// return success
w.WriteHeader(http.StatusOK)
for _, f := range l {
fmt.Fprintf(w, "%s\n", f)
}
}

func (s *server) wipeHandler(w http.ResponseWriter, r *http.Request) {
Expand Down
9 changes: 9 additions & 0 deletions pkg/manager/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,15 @@ func (ms *ManagementService) LogsFunction(name string) (string, error) {
return fh.Logs()
}

func (ms *ManagementService) List() []string {
list := make([]string, 0, len(ms.functionHandlers))
for name := range ms.functionHandlers {
list = append(list, name)
}

return list
}

func (ms *ManagementService) Wipe() error {
for name := range ms.functionHandlers {
log.Println("destroying function", name)
Expand Down

0 comments on commit 7b264c8

Please sign in to comment.