mirror of
https://github.com/containrrr/watchtower.git
synced 2026-01-12 20:18:50 +01:00
Extract function to match digests, use for update check instead of pulling new images
This commit is contained in:
parent
cdde01709c
commit
4b494ded86
2 changed files with 58 additions and 19 deletions
|
|
@ -63,20 +63,32 @@ func (handle *Handler) HandlePost(w http.ResponseWriter, r *http.Request) {
|
|||
return
|
||||
}
|
||||
|
||||
stale, newestImage, created, err := client.IsContainerStale(container)
|
||||
hasUpdate := false
|
||||
newVersion := ""
|
||||
newVersionCreated := ""
|
||||
|
||||
matches, err := client.ContainerDigestMatchesWithRegistry(container)
|
||||
hasUpdate = !matches
|
||||
|
||||
if err != nil {
|
||||
log.Error(err)
|
||||
w.WriteHeader(http.StatusInternalServerError)
|
||||
w.Write([]byte(err.Error()))
|
||||
return
|
||||
stale, newestImage, created, err := client.IsContainerStale(container)
|
||||
hasUpdate = stale
|
||||
newVersion = newestImage.ShortID()
|
||||
newVersionCreated = created
|
||||
|
||||
if err != nil {
|
||||
log.Error(err)
|
||||
w.WriteHeader(http.StatusInternalServerError)
|
||||
w.Write([]byte(err.Error()))
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
data := checkResponse{
|
||||
ContainerID: request.ContainerID,
|
||||
HasUpdate: stale,
|
||||
NewVersion: newestImage.ShortID(),
|
||||
NewVersionCreated: created,
|
||||
HasUpdate: hasUpdate,
|
||||
NewVersion: newVersion,
|
||||
NewVersionCreated: newVersionCreated,
|
||||
}
|
||||
|
||||
jsonData, err := json.Marshal(data)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue