diff --git a/main.go b/main.go index c4f55bb..6acce82 100644 --- a/main.go +++ b/main.go @@ -170,6 +170,7 @@ func main() { e.GET(a.config.BasePath+"/", a.dispatchRequest) e.GET(a.config.BasePath+"/*", a.dispatchRequest) e.GET(a.config.BasePath+"/events", a.viewLog) + e.GET(a.config.BasePath+"/invalidate_cache", a.invalidateCache) // Protected event listener. p := e.Group(a.config.BasePath + "/api") @@ -208,6 +209,11 @@ func (a *apiClient) dispatchRequest(c echo.Context) error { } } +func (a *apiClient) invalidateCache(c echo.Context) error { + a.client.InvalidateCache() + return c.Redirect(http.StatusSeeOther, a.config.BasePath+"/") +} + func (a *apiClient) listRepo(c echo.Context, repoPath string) error { tags := a.client.Tags(repoPath) repos := a.client.RepositoriesList(true) diff --git a/registry/client.go b/registry/client.go index bee36f2..b5ea499 100644 --- a/registry/client.go +++ b/registry/client.go @@ -152,6 +152,11 @@ func (c *Client) callRegistry(uri, scope, manifestFormat string) (string, gorequ return data, resp } +func (c *Client) InvalidateCache() { + c.logger.Info("Cache invalidated") + c.repos = []string{} +} + func (c *Client) RepositoriesList(useCache bool) []string { // Return from cache if available. if len(c.repos) > 0 && useCache { diff --git a/templates/base.html b/templates/base.html index 10692a8..607ec87 100644 --- a/templates/base.html +++ b/templates/base.html @@ -16,6 +16,7 @@