@@ -95,7 +95,7 @@ def delete_inactive_contributors(self, users_to_delete):
95
95
contributors_yaml ["contributors" ] = [c for c in contributors_yaml ["contributors" ] if c not in users_to_delete ]
96
96
self ._write_yaml_file (path , contributors_yaml )
97
97
98
- def get_inactive_users_msg (self , users_to_delete ):
98
+ def get_inactive_users_msg (self , users_to_delete , tagusers ):
99
99
rfc = (
100
100
"https://github.com/cloudfoundry/community/blob/main/toc/rfc/"
101
101
"rfc-0025-define-criteria-and-removal-process-for-inactive-members.md"
@@ -104,23 +104,41 @@ def get_inactive_users_msg(self, users_to_delete):
104
104
"https://github.com/cloudfoundry/community/blob/main/toc/rfc/rfc-0025-define-"
105
105
"criteria-and-removal-process-for-inactive-members.md#remove-the-membership-to-the-cloud-foundry-github-organization"
106
106
)
107
- users_as_list = "\n " .join (str (s ) for s in users_to_delete )
107
+ user_tagging_prefix = "@" if tagusers else ""
108
+ users_as_list = "\n " .join (str (user_tagging_prefix + s ) for s in users_to_delete )
108
109
return (
109
110
f"According to the rolues for inactivity defined in [RFC-0025]({ rfc } ) following users will be deleted:\n "
110
111
f"{ users_as_list } \n According to the [revocation policy in the RFC]({ rfc_revocation_rules } ), users have"
111
112
" two weeks to refute this revocation, if they wish."
112
113
)
113
114
115
+ @staticmethod
116
+ def _get_bool_env_var (env_var_name , default ):
117
+ return os .getenv (env_var_name , default ).lower () == "true"
118
+
114
119
115
120
if __name__ == "__main__" :
116
121
one_year_back = (datetime .datetime .now () - datetime .timedelta (days = 365 )).strftime ("%Y-%m-%dT%H:%M:%SZ" )
117
122
118
123
parser = argparse .ArgumentParser (description = "Cloud Foundry Org Inactive User Handler" )
119
124
parser .add_argument ("-goid" , "--githuborgid" , default = "O_kgDOAAl8sg" , help = "Cloud Foundry Github org ID" )
120
125
parser .add_argument ("-go" , "--githuborg" , default = "cloudfoundry" , help = "Cloud Foundry Github org name" )
121
- parser .add_argument ("-sd" , "--sincedate" , default = one_year_back , help = "Since when to analyze in format '%Y-%m-%dT%H:%M:%SZ'" )
122
- parser .add_argument ("-gt" , "--githubtoken" , default = "" , help = "Github API access token" )
123
- parser .add_argument ("-dr" , "--dryrun" , default = False , help = "Dry run execution" )
126
+ parser .add_argument ("-sd" , "--sincedate" , default = one_year_back , help = "Since when to analyze in format 'Y-m-dTH:M:SZ'" )
127
+ parser .add_argument (
128
+ "-gt" , "--githubtoken" , default = os .environ .get ("GH_TOKEN" ), help = "Github API access token. Supported also as env var 'GH_TOKEN'"
129
+ )
130
+ parser .add_argument (
131
+ "-dr" ,
132
+ "--dryrun" ,
133
+ default = InactiveUserHandler ._get_bool_env_var ("INACTIVE_USER_MANAGEMENT_DRY_RUN" , "False" ),
134
+ help = "Dry run execution. Supported also as env var 'INACTIVE_USER_MANAGEMENT_DRY_RUN'" ,
135
+ )
136
+ parser .add_argument (
137
+ "-tu" ,
138
+ "--tagusers" ,
139
+ default = InactiveUserHandler ._get_bool_env_var ("INACTIVE_USER_MANAGEMENT_TAG_USERS" , "True" ),
140
+ help = "Tag users to be notified. Supported also as env var 'INACTIVE_USER_MANAGEMENT_TAG_USERS'" ,
141
+ )
124
142
args = parser .parse_args ()
125
143
126
144
print ("Get information about community users" )
@@ -134,7 +152,7 @@ def get_inactive_users_msg(self, users_to_delete):
134
152
135
153
print (f"Inactive users length is { len (inactive_users )} and inactive users are { inactive_users } " )
136
154
users_to_delete = inactive_users - community_members_with_role
137
- inactive_users_msg = userHandler .get_inactive_users_msg (users_to_delete )
155
+ inactive_users_msg = userHandler .get_inactive_users_msg (users_to_delete , args . tagusers )
138
156
if args .dryrun :
139
157
print (f"Dry-run mode.\n Inactive_users_msg is: { inactive_users_msg } " )
140
158
print (f"Following users will be deleted: { inactive_users } " )
0 commit comments