# On a webpage you may not have all versions so don't warn if not expected try: current_idx = versions.index(version) except ValueError: if all_versions: print("WARNING: version {3} not in versions for {0}, pattern {1} and with {2}".format( url, filter_pattern, checkers.describe_filter(**kwargs)), version) current_idx = -1 latest = versions[0] return current_idx == 0, latest, "page URL: {0}".format(url) checkers.register('scrape', scrape) def apple_store(version, *, productid): if not isinstance(productid, str): productid = str(productid) url = "https://itunes.apple.com/lookup?id=" + str(productid) # Data will be JSON data = fetch_page(url) data = json.loads(data) if ('resultCount' not in data or 'results' not in data): raise Exception('Error while loading Apple informations') count = data['resultCount']
def git_commit(version, *, repository, branch): refs = fetch_refs(repository) ref_name = 'refs/heads/{0}'.format(branch) obj = refs.get(ref_name, None) if obj is None: raise Exception("Invalid branch {1} specified for {0}".format( repository, branch)) return obj == version, obj, "repository URL: {0}, branch {1}".format( repository, branch) checkers.register('git commit', git_commit) def git_tag(version, *, repository, **kwargs): refs = fetch_refs(repository) matching_refs = list(refs.keys()) refs = None # Remove refs/tag prefix matching_refs = checkers.filter_versions(matching_refs, prefix='refs/tags/') # Apply user filters, change delimiter and sort matching_refs = checkers.prepare_versions(matching_refs, **kwargs)
obj, tagname = line.split(b' ', maxsplit=1) # Last tag override older ones (file is append only) refs[tagname.decode('utf-8')] = obj.decode('ascii') return refs def hg_commit(version, *, repository, branch, context=None): obj = lookup(repository, branch, context) shortobj = obj if len(version) > 0 and len(version) < len(obj): shortobj = obj[:len(version)] return shortobj == version, obj, "repository URL: {0}, branch {1}".format(repository, branch) checkers.register('hg commit', hg_commit) def hg_tag(version, *, repository, head="tip", context=None, **kwargs): refs = tags(repository, head, context) matching_refs = list(refs.keys()) refs = None # Apply user filters, change delimiter and sort matching_refs = checkers.prepare_versions(matching_refs, **kwargs) if len(matching_refs) == 0: print("WARNING: no matching references for {0} with {1}".format( repository, checkers.describe_filter(**kwargs))) return True, 'none', "repository URL: {0}".format(repository)
def svn_commit(version, *, repository): parts = urlp.urlsplit(repository, allow_fragments=False) if parts.scheme.lower() == 'svn': online_version = svn_get_version(repository) elif parts.scheme.lower() in ('http', 'https'): online_version = dav_get_version(repository) else: raise Exception( "Scheme {0} not supported as SVN protocol for {1}".format( parts.scheme.lower(), repository)) return online_version == version, online_version, "repository URL: {0}".format( repository) checkers.register('svn commit', svn_commit) def svn_tag(version, *, repository, **kwargs): parts = urlp.urlsplit(repository, allow_fragments=False) if parts.scheme.lower() == 'svn': names = svn_list_tags(repository) elif parts.scheme.lower() in ('http', 'https'): names = dav_list_tags(repository) else: raise Exception( "Scheme {0} not supported as SVN protocol for {1}".format( parts.scheme.lower(), repository)) # Apply user filters, change delimiter and sort matching_tags = checkers.prepare_versions(names, **kwargs)
image_name, reference='latest', tag_format=None, **kwargs): # Fetch monitored refence first latest_digest = fetch_digest(registry, image_name, reference, **kwargs) # Build the tag name from the version in the file if tag_format is not None: version = tag_format.format(version) # Now fetch its digest file_digest = fetch_digest(registry, image_name, version, **kwargs) return latest_digest == file_digest, reference, "Registry URL: {0}, image {1}".format( registry, image_name) checkers.register('docker tag', docker_tag) if __name__ == "__main__": print( fetch_digest('https://registry-1.docker.io', 'gitlab/gitlab-ce', 'latest')) print( fetch_digest('https://registry-1.docker.io', 'library/docker', 'latest', architecture='amd64', os='linux'))