def isInstalledImageUpToDate(installedImage,checkForUpdatesExternally=False): """ Returns True if the installed image(including all of its dependencies, is up to date. False otherwise. """ try: topImageSource = installedImage.getUser().getRegistry().getRepositories()[installedImage.getSourceRepoId()][installedImage.getImageSourceName()] except KeyError: # Image source not found, therefore updating would be pointless. return True # Check for updates to image sources sourceLineage = getImageSourceLineage(topImageSource) installedImageLineage = installedImage.getImageLineage() if not compareSourceLineageAndInstalledImageLineage(installedImage.getUser(),sourceLineage,installedImageLineage): return False # Check for updates externally using the images' built in check-for-updates script. if checkForUpdatesExternally: if installedImage.checkForUpdates(): return False return True
def isUpToDate(self,imageSource): installedImage = imageSource.getLatestInstalledImage() if installedImage is None: return False if not installedImage.isDockerImageThere(): return False targetLineage = getTargetLineage(imageSource) installedLineage = installedImage.getImageLineage() if not (len(targetLineage) == len(installedLineage)): return False sideBySideLineages = zip(installedLineage,targetLineage) for installed,target in sideBySideLineages: if target in self.__outOfDateImageSources: return False if not installed.getImageId() == target.getLatestInstalledImage().getImageId(): return False if not installedImage.getImageSourceHash() == imageSource.getHash(): return False if self.checkForUpdatesExternally and installedImage.checkForUpdates(): return False return True