Skip to content

Commit

Permalink
Adding a team name flag for #122
Browse files Browse the repository at this point in the history
  • Loading branch information
gm3dmo committed Oct 20, 2023
1 parent a7f78fb commit cd6af24
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
15 changes: 13 additions & 2 deletions configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,8 @@ def main(args):
### [Team](https://docs.github.com/en/rest/teams)
# https://docs.github.com/en/organizations/organizing-members-into-teams/about-teams
team="Justice League"
team_slug="justice-league"
team="${team_name}"
team_slug="${team_slug}"
team_id=
team_members="${team_members}"
team_admin="${team_admin}"
Expand Down Expand Up @@ -365,6 +365,8 @@ def main(args):

assert thepower.token_validator(args.token), "Invalid format: token should have a valid prefix, or should be 40 characters string."

if args.team_name != "":
args.team_slug = thepower.slugify(args.team_name)

if args.org != "":
logger.info(f"Org = {args.org}")
Expand Down Expand Up @@ -438,6 +440,8 @@ def main(args):
"admin_password": args.admin_password,
"mgmt_password": args.mgmt_password,
"mgmt_port": args.mgmt_port,
"team_name": args.team_name,
"team_slug": args.team_slug,
"team_members": args.team_members,
"team_admin": args.team_admin,
"org_owner": args.org_owner,
Expand Down Expand Up @@ -619,6 +623,13 @@ def main(args):
default="list-user.sh",
help="The name of a primer script which will be executed when configuration is complete",
)
parser.add_argument(
"--team-name",
action="store",
dest="team_name",
default="Justice League",
help="The name of a team to create.",
)
parser.add_argument(
"--private-pem-file",
action="store",
Expand Down
8 changes: 8 additions & 0 deletions thepower.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,14 @@
import re


def slugify(s):
s = s.lower().strip()
s = re.sub(r'[^\w\s-]', '', s)
s = re.sub(r'[\s_-]+', '-', s)
s = re.sub(r'^-+|-+$', '', s)
return s


def ghe2json(text):
"""Converts the text output from gheboot to json"""
lexer = shlex.shlex(text)
Expand Down

0 comments on commit cd6af24

Please sign in to comment.