@@ -175,66 +175,13 @@ def configure_forgejo(argocd: ArgoCD,
175175 # wait for all the forgejo apps to come up, give it extra time
176176 argocd .sync_app (app = 'forgejo-web-app' , sleep_time = 4 )
177177 argocd .wait_for_app ('forgejo-web-app' )
178-
179- # create admin credentials
180- password = create_user (forgejo_admin_username ,
181- forgejo_admin_email ,
182- cfg ['argo' ]['namespace' ])
183- if bitwarden :
184- sub_header ("Creating secrets in Bitwarden" )
185- bitwarden .create_login (
186- name = 'forgejo-admin-credentials' ,
187- item_url = forgejo_hostname ,
188- user = forgejo_admin_username ,
189- password = password ,
190- fields = [create_custom_field ("email" , forgejo_admin_email )]
191- )
192178 else :
193179 log .info ("forgejo already installed 🎉" )
194180
195181 if bitwarden and init_enabled :
196182 refresh_bweso (argocd , forgejo_hostname , bitwarden )
197183
198184
199- def create_user (user : str , email : str , pod_namespace : str ) -> str :
200- """
201- given a username, email, and namespace of the forgejo pod, we'll create a
202- new forgejo user using a kubectl exec command and then we return
203- their autogenerated password
204- """
205- sub_header (f"Creating a forgejo user for: { user } " )
206- # first, go get the exact name of the pod we need to exec a command on
207- pod_cmd = (
208- f"kubectl get pods -n { pod_namespace } "
209- "-l app.kubernetes.io/instance=forgejo-web-app,app.kubernetes.io/component=web"
210- " --no-headers "
211- "-o custom-columns=NAME:.metadata.name"
212- )
213- pod = subproc ([pod_cmd ]).rstrip ()
214- log .info (f"forgejo web app pod is: { pod } " )
215-
216- # generate a random password
217- password = create_password ()
218-
219- # then run the user creation command
220- cmd = (f'kubectl exec -n { pod_namespace } { pod } -- /bin/sh -c "./forgejo '
221- '--config-path ../config/config.yaml admin account create '
222- f'--username { user } --email { email } --password \' { password } \' "' )
223-
224- # then process the output from the command
225- subproc ([cmd ], shell = True , universal_newlines = True )
226-
227- # then run the user promotion (to admin) command
228- cmd = (f'kubectl exec -n { pod_namespace } { pod } -- /bin/sh -c '
229- '"./forgejo --config-path ../config/config.yaml admin '
230- f'account promote --username { user } "' )
231-
232- # then process the output from the command
233- subproc ([cmd ], shell = True , universal_newlines = True ).split ()[3 ]
234-
235- return password
236-
237-
238185def refresh_bweso (argocd : ArgoCD ,
239186 forgejo_hostname : str ,
240187 bitwarden : BwCLI ) -> None :
0 commit comments