Skip to content

Instantly share code, notes, and snippets.

@ekohl
Created October 14, 2022 17:19
Show Gist options
  • Save ekohl/cd9e9fdfb2e3bb374cb04474141de3c1 to your computer and use it in GitHub Desktop.
Save ekohl/cd9e9fdfb2e3bb374cb04474141de3c1 to your computer and use it in GitHub Desktop.
Foreman Plugins
[
{
"url": "https://github.com/ATIX-AG/foreman_acd",
"last_commit": "2022-09-26T06:28:14"
},
{
"url": "https://github.com/ATIX-AG/foreman_scc_manager",
"last_commit": "2022-09-21T08:20:46"
},
{
"url": "https://github.com/ATIX-AG/foreman_snapshot_management",
"last_commit": "2022-10-07T08:50:25"
},
{
"url": "https://github.com/theforeman/foreman_column_view",
"last_commit": "2018-05-28T12:49:39"
},
{
"url": "https://github.com/ananace/foreman_hyperv",
"last_commit": "2020-09-02T07:22:53"
},
{
"url": "https://github.com/ananace/foreman_wds",
"last_commit": "2022-09-02T12:55:33"
},
{
"url": "https://github.com/dm-drogeriemarkt/foreman_dlm",
"last_commit": "2022-03-02T10:05:23"
},
{
"url": "https://github.com/dm-drogeriemarkt/foreman_git_templates",
"last_commit": "2021-06-14T13:04:42"
},
{
"url": "https://github.com/dm-drogeriemarkt/foreman_rescue",
"last_commit": "2021-06-10T11:04:05"
},
{
"url": "https://github.com/dm-drogeriemarkt/foreman_spacewalk",
"archived": true
},
{
"url": "https://github.com/dm-drogeriemarkt/foreman_vault",
"last_commit": "2022-08-18T09:38:00"
},
{
"url": "https://github.com/dm-drogeriemarkt/foreman_wreckingball",
"last_commit": "2021-11-30T16:25:58"
},
{
"url": "https://github.com/grizzthedj/foreman_ipam",
"last_commit": "2020-12-09T14:39:06"
},
{
"url": "https://github.com/isratrade/foreman_radiator",
"last_commit": "2013-05-30T20:54:59"
},
{
"url": "https://github.com/Katello/bastion",
"archived": true
},
{
"url": "https://github.com/theforeman/foreman-digitalocean",
"last_commit": "2018-09-18T14:36:12"
},
{
"url": "https://github.com/theforeman/foreman-tasks",
"last_commit": "2022-08-22T09:54:31"
},
{
"url": "https://github.com/theforeman/foreman-xen",
"last_commit": "2020-02-02T14:21:04"
},
{
"url": "https://github.com/theforeman/foreman_abrt",
"last_commit": "2020-03-02T14:29:39"
},
{
"url": "https://github.com/theforeman/foreman_ansible",
"last_commit": "2022-10-13T11:17:38"
},
{
"url": "https://github.com/theforeman/foreman_azure_rm",
"last_commit": "2022-10-05T13:52:38"
},
{
"url": "https://github.com/theforeman/foreman_bootdisk",
"last_commit": "2022-09-26T08:41:45"
},
{
"url": "https://github.com/theforeman/foreman_chef",
"last_commit": "2021-07-23T11:00:24"
},
{
"url": "https://github.com/theforeman/foreman_datacenter",
"last_commit": "2020-04-28T09:56:19"
},
{
"url": "https://github.com/theforeman/foreman_default_hostgroup",
"last_commit": "2022-03-02T14:01:05"
},
{
"url": "https://github.com/theforeman/foreman_dhcp_browser",
"last_commit": "2018-09-01T18:23:31"
},
{
"url": "https://github.com/theforeman/foreman_discovery",
"last_commit": "2022-09-02T08:09:23"
},
{
"url": "https://github.com/theforeman/foreman_docker",
"archived": true
},
{
"url": "https://github.com/theforeman/foreman_expire_hosts",
"last_commit": "2021-02-02T08:57:16"
},
{
"url": "https://github.com/theforeman/foreman_fog_proxmox",
"last_commit": "2021-07-23T15:37:29"
},
{
"url": "https://github.com/theforeman/foreman_hooks",
"last_commit": "2020-11-18T14:12:40"
},
{
"url": "https://github.com/theforeman/foreman_host_extra_validator",
"last_commit": "2020-04-17T19:57:38"
},
{
"url": "https://github.com/theforeman/foreman_memcache",
"last_commit": "2018-09-18T14:35:36"
},
{
"url": "https://github.com/theforeman/foreman_monitoring",
"last_commit": "2020-12-01T13:16:21"
},
{
"url": "https://github.com/theforeman/foreman_omaha",
"last_commit": "2022-05-24T11:10:29"
},
{
"url": "https://github.com/theforeman/foreman_openscap",
"last_commit": "2022-04-28T11:58:31"
},
{
"url": "https://github.com/theforeman/foreman_remote_execution",
"last_commit": "2022-10-11T07:55:33"
},
{
"url": "https://github.com/theforeman/foreman_salt",
"last_commit": "2022-05-03T08:30:02"
},
{
"url": "https://github.com/theforeman/foreman_scaleway",
"last_commit": "2018-01-01T20:26:02"
},
{
"url": "https://github.com/theforeman/foreman_setup",
"last_commit": "2022-03-22T13:19:43"
},
{
"url": "https://github.com/theforeman/foreman_templates",
"last_commit": "2022-05-16T12:15:15"
},
{
"url": "https://github.com/theforeman/puppetdb_foreman",
"last_commit": "2022-10-14T13:57:14"
}
]
#!/usr/bin/env python3
import json
import logging
import os
from argparse import ArgumentParser, FileType
from urllib.parse import urlparse
from github import Github
def process_plugins(file, token):
data = json.load(file)
file.close()
github = Github(token)
for plugin in data:
if plugin.get('archived'):
continue
parsed = urlparse(plugin['url'])
name = parsed.path.lstrip('/')
try:
repo = github.get_repo(name)
except Exception as e:
logging.error('Could not find repo %s: %s', name, e)
else:
if repo.full_name != name:
logging.info('Repo %s has moved to %s', repo, repo.full_name)
print(repo.html_url)
plugin['url'] = repo.html_url
if repo.archived:
plugin['archived'] = repo.archived
else:
try:
commit = repo.get_commits()[0]
except IndexError:
pass
else:
plugin['last_commit'] = commit.commit.committer.date.isoformat()
with open(file.name, 'w', encoding='UTF-8') as f:
json.dump(data, f)
def main():
parser = ArgumentParser(description='Set Github repository topics based on repository content')
parser.add_argument('--file', '-f', help='Filename with plugins',
type=FileType('r', encoding='UTF-8'))
parser.add_argument('--verbose', '-v', help='Show debug output', action='store_true')
args = parser.parse_args()
log_level = logging.DEBUG if args.verbose else logging.INFO
logging.basicConfig(level=log_level)
try:
token = os.environ['GITHUB_TOKEN']
except KeyError:
raise SystemExit('Set the GITHUB_TOKEN environment variable to a valid Github token')
try:
process_plugins(args.file, token)
except KeyboardInterrupt:
pass
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment