summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThom May <thom@chef.io>2015-09-07 15:11:48 +0100
committerThom May <thom@chef.io>2015-09-07 15:11:48 +0100
commitd7ce09f91e298457448b212f7ccb547de2d1a5af (patch)
treeb56d3799babb5d839d335eaa358feae1784ccb65
parentbc890071b8b1e0eba9aa04fa51a36311848ab1cc (diff)
downloadchef-tm/sync_gh_maintainers.tar.gz
sync maintainers with githubtm/sync_gh_maintainers
-rw-r--r--Gemfile10
-rw-r--r--MAINTAINERS.md40
-rw-r--r--MAINTAINERS.toml28
-rw-r--r--tasks/maintainers.rb169
4 files changed, 226 insertions, 21 deletions
diff --git a/Gemfile b/Gemfile
index 6aae2c5b9e..edbd853c47 100644
--- a/Gemfile
+++ b/Gemfile
@@ -10,11 +10,19 @@ gem 'chef-config', path: "chef-config"
gem "chef-zero", "~> 4.2.3"
group(:docgen) do
- gem "tomlrb"
gem "yard"
end
+group(:maintenance) do
+ gem "tomlrb"
+
+ # To sync maintainers with github
+ gem "octokit"
+ gem "netrc"
+end
+
group(:development, :test) do
+
gem "simplecov"
gem 'rack', "~> 1.5.1"
diff --git a/MAINTAINERS.md b/MAINTAINERS.md
index 3c777366f8..aeaebd251d 100644
--- a/MAINTAINERS.md
+++ b/MAINTAINERS.md
@@ -22,6 +22,8 @@ Handles the core parts of the Chef DSL, base resource and provider
infrastructure, the Chef applications and [omnibus-chef](https://github.com/chef/omnibus-chef). Includes anything not covered by
another component.
+To mention the team, use @chef/client-core
+
### Lieutenant
* [Thom May](https://github.com/thommay)
@@ -33,7 +35,7 @@ another component.
* [Daniel DeLeo](https://github.com/danielsdeleo)
* [AJ Christensen](https://github.com/fujin)
* [Phil Dibowitz](https://github.com/jaymzh)
-* [Jay Mundrawala](https://github.com/jdmundrawala)
+* [Jay Mundrawala](https://github.com/jaym)
* [Jon Cowie](https://github.com/jonlives)
* [Lamont Granquist](https://github.com/lamont-granquist)
* [Claire McQuin](https://github.com/mcquin)
@@ -44,6 +46,8 @@ another component.
## Dev Tools
Chef Zero, Knife, Chef Apply and Chef Shell.
+To mention the team, use @chef/client-dev-tools
+
### Maintainers
* [Daniel DeLeo](https://github.com/danielsdeleo)
@@ -54,6 +58,8 @@ Chef Zero, Knife, Chef Apply and Chef Shell.
## Test Tools
ChefSpec
+To mention the team, use @chef/client-test-tools
+
### Lieutenant
* [Seth Vargo](https://github.com/sethvargo)
@@ -70,6 +76,8 @@ The specific components of Chef related to a given platform - including (but not
## Enterprise Linux
+To mention the team, use @chef/client-enterprise-linux
+
### Lieutenant
* [Jon Cowie](https://github.com/jonlives)
@@ -81,6 +89,8 @@ The specific components of Chef related to a given platform - including (but not
## Ubuntu
+To mention the team, use @chef/client-ubuntu
+
### Lieutenant
* [Ranjib Dey](https://github.com/ranjib)
@@ -92,19 +102,23 @@ The specific components of Chef related to a given platform - including (but not
## Windows
+To mention the team, use @chef/client-windows
+
### Lieutenant
* [Bryan McLellan](https://github.com/btm)
### Maintainers
-* [Jay Mundrawala](https://github.com/jdmundrawala)
+* [Jay Mundrawala](https://github.com/jaym)
* [Kartik Cating-Subramanian](https://github.com/ksubrama)
* [Steven Murawski](https://github.com/smurawski)
* [Salim Alam](https://github.com/chefsalim)
## Solaris
+To mention the team, use @chef/client-solaris
+
### Lieutenant
* [Thom May](https://github.com/thommay)
@@ -115,12 +129,16 @@ The specific components of Chef related to a given platform - including (but not
## AIX
+To mention the team, use @chef/client-aix
+
### Lieutenant
* [Lamont Granquist](https://github.com/lamont-granquist)
## Mac OS X
+To mention the team, use @chef/client-os-x
+
### Lieutenant
* [Joshua Timberman](https://github.com/jtimberman)
@@ -131,6 +149,8 @@ The specific components of Chef related to a given platform - including (but not
## Debian
+To mention the team, use @chef/client-debian
+
### Lieutenant
* [Thom May](https://github.com/thommay)
@@ -141,24 +161,32 @@ The specific components of Chef related to a given platform - including (but not
## Fedora
+To mention the team, use @chef/client-fedora
+
### Maintainers
* [Lamont Granquist](https://github.com/lamont-granquist)
## openSUSE
+To mention the team, use @chef/client-opensuse
+
### Maintainers
* [Lamont Granquist](https://github.com/lamont-granquist)
## SUSE Enterprise Linux Server
+To mention the team, use @chef/client-suse
+
### Maintainers
* [Lamont Granquist](https://github.com/lamont-granquist)
## FreeBSD
+To mention the team, use @chef/client-freebsd
+
### Lieutenant
* [Aaron Kalin](https://github.com/martinisoft)
@@ -170,24 +198,32 @@ The specific components of Chef related to a given platform - including (but not
## OpenBSD
+To mention the team, use @chef/client-openbsd
+
### Lieutenant
* [Joe Miller](https://github.com/joemiller)
## Gentoo
+To mention the team, use @chef/client-gentoo
+
### Maintainers
* [Lamont Granquist](https://github.com/lamont-granquist)
## OmniOS
+To mention the team, use @chef/client-omnios
+
### Maintainers
* [Thom May](https://github.com/thommay)
## ArchLinux
+To mention the team, use @chef/client-archlinux
+
### Maintainers
* [Lamont Granquist](https://github.com/lamont-granquist)
diff --git a/MAINTAINERS.toml b/MAINTAINERS.toml
index 61c75c1a30..d72b9b316c 100644
--- a/MAINTAINERS.toml
+++ b/MAINTAINERS.toml
@@ -1,5 +1,7 @@
#
# This file is structured to be consumed by both humans and computers.
+# To update the generated Markdown, run `bundle exec rake maintainers:generate`
+# To synchronize the maintainers with the github teams, run `bundle exec rake maintainers:synchronize`
# It is a TOML document containing Markdown
#
[Preamble]
@@ -24,6 +26,7 @@ a maintainer, lieutenant, or the project lead.
[Org.Components.Core]
title = "Chef Core"
+ team = "client-core"
text = """
Handles the core parts of the Chef DSL, base resource and provider
infrastructure, the Chef applications and [omnibus-chef](https://github.com/chef/omnibus-chef). Includes anything not covered by
@@ -38,7 +41,7 @@ another component.
"danielsdeleo",
"fujin",
"jaymzh",
- "jdmundrawala",
+ "jaym",
"jonlives",
"lamont-granquist",
"mcquin",
@@ -49,6 +52,7 @@ another component.
[Org.Components.DevTools]
title = "Dev Tools"
+ team = "client-dev-tools"
text = "Chef Zero, Knife, Chef Apply and Chef Shell."
paths = [
@@ -68,6 +72,7 @@ another component.
[Org.Components.TestTools]
title = "Test Tools"
+ team = "client-test-tools"
text = "ChefSpec"
lieutenant = "sethvargo"
@@ -86,6 +91,7 @@ The specific components of Chef related to a given platform - including (but not
[Org.Components.Subsystems."Enterprise Linux"]
title = "Enterprise Linux"
+ team = "client-enterprise-linux"
lieutenant = "jonlives"
@@ -96,6 +102,7 @@ The specific components of Chef related to a given platform - including (but not
[Org.Components.Subsystems.Ubuntu]
title = "Ubuntu"
+ team = "client-ubuntu"
lieutenant = "ranjib"
@@ -106,10 +113,11 @@ The specific components of Chef related to a given platform - including (but not
[Org.Components.Subsystems.Windows]
title = "Windows"
+ team = "client-windows"
lieutenant = "btm"
maintainers = [
- "jdmundrawala",
+ "jaym",
"ksubrama",
"smurawski",
"chefsalim"
@@ -117,6 +125,7 @@ The specific components of Chef related to a given platform - including (but not
[Org.Components.Subsystems.Solaris]
title = "Solaris"
+ team = "client-solaris"
lieutenant = "thommay"
@@ -126,11 +135,13 @@ The specific components of Chef related to a given platform - including (but not
[Org.Components.Subsystems.AIX]
title = "AIX"
+ team = "client-aix"
lieutenant = "lamont-granquist"
[Org.Components.Subsystems."Mac OS X"]
title = "Mac OS X"
+ team = "client-os-x"
lieutenant = "jtimberman"
@@ -140,6 +151,7 @@ The specific components of Chef related to a given platform - including (but not
[Org.Components.Subsystems.Debian]
title = "Debian"
+ team = "client-debian"
lieutenant = "thommay"
@@ -149,6 +161,7 @@ The specific components of Chef related to a given platform - including (but not
[Org.Components.Subsystems.Fedora]
title = "Fedora"
+ team = "client-fedora"
maintainers = [
"lamont-granquist"
@@ -156,6 +169,7 @@ The specific components of Chef related to a given platform - including (but not
[Org.Components.Subsystems.openSUSE]
title = "openSUSE"
+ team = "client-opensuse"
maintainers = [
"lamont-granquist"
@@ -163,6 +177,7 @@ The specific components of Chef related to a given platform - including (but not
[Org.Components.Subsystems."SUSE Enterprise Linux"]
title = "SUSE Enterprise Linux Server"
+ team = "client-suse"
maintainers = [
"lamont-granquist"
@@ -170,6 +185,7 @@ The specific components of Chef related to a given platform - including (but not
[Org.Components.Subsystems.FreeBSD]
title = "FreeBSD"
+ team = "client-freebsd"
lieutenant = "martinisoft"
@@ -180,11 +196,13 @@ The specific components of Chef related to a given platform - including (but not
[Org.Components.Subsystems.OpenBSD]
title = "OpenBSD"
+ team = "client-openbsd"
lieutenant = "joemiller"
[Org.Components.Subsystems.Gentoo]
title = "Gentoo"
+ team = "client-gentoo"
maintainers = [
"lamont-granquist"
@@ -192,6 +210,7 @@ The specific components of Chef related to a given platform - including (but not
[Org.Components.Subsystems.OmniOS]
title = "OmniOS"
+ team = "client-omnios"
maintainers = [
"thommay"
@@ -199,6 +218,7 @@ The specific components of Chef related to a given platform - including (but not
[Org.Components.Subsystems.ArchLinux]
title = "ArchLinux"
+ team = "client-archlinux"
maintainers = [
"lamont-granquist",
@@ -230,9 +250,9 @@ The specific components of Chef related to a given platform - including (but not
Name = "Phil Dibowitz"
GitHub = "jaymzh"
- [people.jdmundrawala]
+ [people.jaym]
Name = "Jay Mundrawala"
- GitHub = "jdmundrawala"
+ GitHub = "jaym"
[people.jonlives]
Name = "Jon Cowie"
diff --git a/tasks/maintainers.rb b/tasks/maintainers.rb
index 5a2c8d9c2d..73a422fc61 100644
--- a/tasks/maintainers.rb
+++ b/tasks/maintainers.rb
@@ -20,50 +20,191 @@ require 'rake'
SOURCE = File.join(File.dirname(__FILE__), "..", "MAINTAINERS.toml")
TARGET = File.join(File.dirname(__FILE__), "..", "MAINTAINERS.md")
+# The list of repositories that teams should own
+REPOSITORIES = ["chef/chef", "chef/chef-census", "chef/chef-repo",
+ "chef/client-docs", "chef/ffi-yajl", "chef/libyajl2-gem",
+ "chef/mixlib-authentication", "chef/mixlib-cli",
+ "chef/mixlib-config", "chef/mixlib-install", "chef/mixlib-log",
+ "chef/mixlib-shellout", "chef/ohai", "chef/omnibus-chef"]
+
begin
require 'tomlrb'
+ require 'octokit'
+ require 'pp'
task :default => :generate
namespace :maintainers do
desc "Generate MarkDown version of MAINTAINERS file"
task :generate do
- maintainers = Tomlrb.load_file SOURCE
out = "<!-- This is a generated file. Please do not edit directly -->\n\n"
- out << "# " + maintainers["Preamble"]["title"] + "\n\n"
- out << maintainers["Preamble"]["text"] + "\n"
- out << "# " + maintainers["Org"]["Lead"]["title"] + "\n\n"
- out << person(maintainers["people"], maintainers["Org"]["Lead"]["person"]) + "\n\n"
- out << components(maintainers["people"], maintainers["Org"]["Components"])
+ out << "# " + source["Preamble"]["title"] + "\n\n"
+ out << source["Preamble"]["text"] + "\n"
+
+ # The project lead is a special case
+ out << "# " + source["Org"]["Lead"]["title"] + "\n\n"
+ out << format_person(source["Org"]["Lead"]["person"]) + "\n\n"
+
+ out << format_components(source["Org"]["Components"])
File.open(TARGET, "w") { |fn|
fn.write out
}
end
+
+ desc "Synchronize GitHub teams"
+ # there's a special @chef/client-maintainers team that's everyone
+ # and then there's a team per component
+ task :synchronize do
+ Octokit.auto_paginate = true
+ get_github_teams
+ prepare_teams(source["Org"]["Components"].dup)
+ sync_teams!
+ end
+ end
+
+ def github
+ @github ||= Octokit::Client.new(:netrc => true)
+ end
+
+ def source
+ @source ||= Tomlrb.load_file SOURCE
end
- def components(list, cmp)
+ def teams
+ @teams ||= {"client-maintainers" => {"title" => "Client Maintainers"}}
+ end
+
+ def add_members(team, name)
+ teams["client-maintainers"]["members"] ||= []
+ teams["client-maintainers"]["members"] << name
+ teams[team] ||= {}
+ teams[team]["members"] ||= []
+ teams[team]["members"] << name
+ end
+
+ def set_team_title(team, title)
+ teams[team] ||= {}
+ teams[team]["title"] = title
+ end
+
+ def gh_teams
+ @gh_teams ||= {}
+ end
+
+ # we have to resolve team names to ids. While we're at it, we can get the privacy
+ # setting, so we know whether we need to update it
+ def get_github_teams
+ github.org_teams("chef").each do |team|
+ gh_teams[team[:slug]] = {"id" => team[:id], "privacy" => team[:privacy]}
+ end
+ end
+
+ def get_github_team(team)
+ github.team_members(gh_teams[team]["id"]).map do |member|
+ member[:login]
+ end.sort.uniq.map(&:downcase)
+ rescue
+ []
+ end
+
+ def create_team(team)
+ puts "creating new github team: #{team} with title: #{teams[team]["title"]} "
+ t = github.create_team("chef", name: team, description: teams[team]["title"],
+ privacy: "closed", repo_names: REPOSITORIES,
+ accept: "application/vnd.github.ironman-preview+json")
+ gh_teams[team] = { "id" => t[:id], "privacy" => t[:privacy] }
+ end
+
+ def compare_teams(current, desired)
+ # additions are the subtraction of the current state from the desired state
+ # deletions are the subtraction of the desired state from the current state
+ [desired - current, current - desired]
+ end
+
+ def prepare_teams(cmp)
+ %w(text paths).each { |k| cmp.delete(k) }
+ if cmp.key?("team")
+ team = cmp.delete("team")
+ add_members(team, cmp.delete("lieutenant")) if cmp.key?("lieutenant")
+ add_members(team, cmp.delete("maintainers")) if cmp.key?("maintainers")
+ set_team_title(team, cmp.delete("title"))
+ else
+ %w(maintainers lieutenant title).each { |k| cmp.delete(k) }
+ end
+ cmp.each { |_k, v| prepare_teams(v) }
+ end
+
+ def update_team(team, additions, deletions)
+ create_team(team) unless gh_teams.key?(team)
+ update_team_privacy(team)
+ add_team_members(team, additions)
+ remove_team_members(team, deletions)
+ rescue
+ puts "failed for #{team}"
+ end
+
+ def update_team_privacy(team)
+ return if gh_teams[team]["privacy"] == "closed"
+ puts "Setting #{team} privacy to closed from #{gh_teams[team]["privacy"]}"
+ github.update_team(gh_teams[team]["id"], privacy: "closed",
+ accept: "application/vnd.github.ironman-preview+json")
+ end
+
+ def add_team_members(team, additions)
+ additions.each do |member|
+ puts "Adding #{member} to #{team}"
+ github.add_team_membership(gh_teams[team]["id"], member, role: "member",
+ accept: "application/vnd.github.ironman-preview+json")
+ end
+ end
+
+ def remove_team_members(team, deletions)
+ deletions.each do |member|
+ puts "Removing #{member} from #{team}"
+ github.remove_team_membership(gh_teams[team]["id"], member,
+ accept: "application/vnd.github.ironman-preview+json")
+ end
+ end
+
+ def sync_teams!
+ teams.each do |name, details|
+ current = get_github_team(name)
+ desired = details["members"].flatten.sort.uniq.map(&:downcase)
+ additions, deletions = compare_teams(current, desired)
+ update_team(name, additions, deletions)
+ end
+ end
+
+ def get_person(person)
+ source["people"][person]
+ end
+
+ def format_components(cmp)
out = "## " + cmp.delete("title") + "\n\n"
out << cmp.delete("text") + "\n" if cmp.has_key?("text")
+ out << "To mention the team, use @chef/#{cmp.delete("team")}\n\n" if cmp.has_key?("team")
if cmp.has_key?("lieutenant")
out << "### Lieutenant\n\n"
- out << person(list, cmp.delete("lieutenant")) + "\n\n"
+ out << format_person(cmp.delete("lieutenant")) + "\n\n"
end
- out << maintainers(list, cmp.delete("maintainers")) + "\n" if cmp.has_key?("maintainers")
+ out << format_maintainers(cmp.delete("maintainers")) + "\n" if cmp.has_key?("maintainers")
cmp.delete("paths")
- cmp.each {|k,v| out << components(list, v) }
+ cmp.each {|k,v| out << format_components(v) }
out
end
- def maintainers(list, people)
+ def format_maintainers(people)
o = "### Maintainers\n\n"
people.each do |p|
- o << person(list, p) + "\n"
+ o << format_person(p) + "\n"
end
o
end
- def person(list, person)
- "* [#{list[person]["Name"]}](https://github.com/#{list[person]["GitHub"]})"
+ def format_person(person)
+ mnt = get_person(person)
+ "* [#{mnt["Name"]}](https://github.com/#{mnt["GitHub"]})"
end
+
rescue LoadError
STDERR.puts "\n*** TomlRb not available.\n\n"
end