Skip to content

Commit

Permalink
make state method consistent (#135)
Browse files Browse the repository at this point in the history
  • Loading branch information
Louis DeLosSantos authored Mar 5, 2020
1 parent ad81962 commit 22cafb9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
9 changes: 8 additions & 1 deletion libindex/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,15 @@ func NewHandler(l *Libindex) *HTTP {
}

func (h *HTTP) State(w http.ResponseWriter, r *http.Request) {
ctx := r.Context()
log := zerolog.Ctx(ctx).With().
Str("method", "index").
Logger()
ctx = log.WithContext(ctx)

w.Header().Set("content-type", "text/plain")
fmt.Fprintln(w, h.l.State())
s, _ := h.l.State(ctx)
fmt.Fprintln(w, s)
}

func (h *HTTP) Index(w http.ResponseWriter, r *http.Request) {
Expand Down
4 changes: 2 additions & 2 deletions libindex/libindex.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,8 @@ func (l *Libindex) Index(ctx context.Context, manifest *claircore.Manifest) (*cl
//
// If the identifier has changed, clients should arrange for layers to be
// re-indexed.
func (l *Libindex) State() string {
return l.state
func (l *Libindex) State(ctx context.Context) (string, error) {
return l.state, nil
}

func (l *Libindex) index(ctx context.Context, s *controller.Controller, m *claircore.Manifest) *claircore.IndexReport {
Expand Down

0 comments on commit 22cafb9

Please sign in to comment.