diff --git a/Dockerfile b/Dockerfile --- a/Dockerfile +++ b/Dockerfile @@ -4,7 +4,8 @@ apt-get install -y \ cl-quicklisp \ default-libmysqlclient-dev \ - git + git \ + kubernetes-client RUN mkdir -p /srv/phabricator /opt/forgerie RUN useradd -md /srv/forgerie -s /bin/bash forgerie @@ -25,3 +26,12 @@ # install quicklisp and pulls core dependencies for it to run properly RUN sbcl --quit + +# # for debugging purposes +# USER root +# RUN mkdir -p /srv/phabricator +# RUN export DEBIAN_FRONTEND=noninteractive && \ +# apt-get install -y \ +# telnet iproute2 + +# USER forgerie diff --git a/bin/build-config-tmpl b/bin/build-config-tmpl --- a/bin/build-config-tmpl +++ b/bin/build-config-tmpl @@ -66,7 +66,7 @@ forgerie-gitlab:*default-project* forgerie-gitlab:*ssh-public-key* forgerie-gitlab:*default-group* - forgerie-gitlab:*rails-console-ssh-args* + forgerie-gitlab:*rails-command-args* forgerie-gitlab:*merge-request-suffix* forgerie-gitlab:*ticket-suffix* forgerie-gitlab:*limit-to-active-users*)))) diff --git a/config/config.lisp.tmpl b/config/config.lisp.tmpl --- a/config/config.lisp.tmpl +++ b/config/config.lisp.tmpl @@ -56,7 +56,7 @@ ; ; Where the KEY is the database id of the project, and the SLUG is which repository that this ; project should be a primary project of. Then the project will be removed from all other -; repositories it might be assigned to. The ramification of this is that tasks that are +; repositories it mgiht be assigned to. The ramification of this is that tasks that are ; part of this project, for instance, will be assigned to the repository in various forgeries ; that link project and repository. (setf forgerie-phabricator:*project-assignment-overrides* nil) @@ -137,22 +137,28 @@ ; top level. (setf forgerie-gitlab:*default-group* nil) -; A tuple of the form '(HOST COMMAND) that informs the gitlab forgerie -; how to run rails commands over ssh. It will always use SSH, even if -; set up to run on localhost, so keys must be installed to ssh to localhost. +; By default, using ssh, a tuple of the form '(HOST COMMAND) that informs the gitlab +; forgerie how to run rails commands over ssh. It will always use SSH, even if set up to +; run on localhost, so keys must be installed to ssh to localhost. When overriden to +; another command like kubectl, a list '(COMMAND) for the necessary extra args that the +; command requires to run. ; -; An example for a server using docker might be: +; When using ssh, an example for a server using docker might be: ; ; '("ssh.gitlab.yourdomain.tld" "docker exec -i gitlab /opt/gitlab/bin/gitlab-rails c") ; -; A useful thing to do is to run ssh on the server for non git purposes on port 2222, and then -; set up your .ssh/config to have the following: +; A useful thing to do is to run ssh on the server for non git purposes on port 2222, and +; then set up your .ssh/config to have the following: ; ; Host ssh.gitlab.yourdomain.tld ; User ; Port 2222 ; IdentityFile ~/.ssh/your_identity_file -(setf forgerie-gitlab:*rails-console-ssh-args* nil) +; +; When using kube, an example might be: +; +; '("exec -ti -n gitlab-system deployment/gitlab-toolbox -- /srv/gitlab/bin/rails console") +(setf forgerie-gitlab:*rails-command-args* nil) ; A function that takes an argument of a forgerie-core:merge-request and ; returns a string that will be appended to the description of created merge requests. @@ -169,3 +175,4 @@ ; If non nil, will only add users to the gitlab instance if they are active in the ; items also coming over for processing. Useful when doing piecemeal conversions. (setf forgerie-gitlab:*limit-to-active-users* nil) + diff --git a/src/main/gitlab/base.lisp b/src/main/gitlab/base.lisp --- a/src/main/gitlab/base.lisp +++ b/src/main/gitlab/base.lisp @@ -31,25 +31,36 @@ ; to do with the project with the name provided. (defvar *single-project* nil) -; The args (host and command are normal) for the ssh command to -; boot the rails console. Sometimes this is localhost. Keys -; have to be set up. -(defvar *rails-console-ssh-args* nil - "A tuple of the form '(HOST COMMAND) that informs the gitlab forgerie - how to run rails commands over ssh. It will always use SSH, even if - set up to run on localhost, so keys must be installed to ssh to localhost. +; The default rails-command to execute the rails console. +(defvar *rails-command* "/usr/bin/ssh" + "The rails command to execute, by default this uses ssh. But one could use kubectl or +docker instead.") - An example for a server using docker might be: +; The required args for the *rails-command*. +(defvar *rails-command-args* nil + "By default, using ssh, a tuple of the form '(HOST COMMAND) that informs the gitlab + forgerie how to run rails commands over ssh. It will always use SSH, even if set up to + run on localhost, so keys must be installed to ssh to localhost. When overriden to + another command like kubectl, a list '(COMMAND) for the necessary extra args that the + command requires to run. + + When using ssh, an example for a server using docker might be: '(\"ssh.gitlab.yourdomain.tld\" \"docker exec -i gitlab /opt/gitlab/bin/gitlab-rails c\") - A useful thing to do is to run ssh on the server for non git purposes on port 2222, and then - set up your .ssh/config to have the following: + A useful thing to do is to run ssh on the server for non git purposes on port 2222, and + then set up your .ssh/config to have the following: Host ssh.gitlab.yourdomain.tld User Port 2222 - IdentityFile ~/.ssh/your_identity_file") + IdentityFile ~/.ssh/your_identity_file + + When using kube, an example might be: + + '(\"exec -ti -n gitlab-system deployment/gitlab-toolbox -- /srv/gitlab/bin/rails console\") + +") (defvar *merge-request-suffix* nil "A function that takes an argument of a forgerie-core:merge-request and diff --git a/src/main/gitlab/package.lisp b/src/main/gitlab/package.lisp --- a/src/main/gitlab/package.lisp +++ b/src/main/gitlab/package.lisp @@ -1,5 +1,5 @@ (defpackage #:forgerie-gitlab (:use :cl) (:export #:*private-token* #:*server-address* #:*default-project* #:*ssh-public-key* - #:*default-group* #:*single-project* #:*rails-console-ssh-args* #:*merge-request-suffix* - #:*ticket-suffix* #:*limit-to-active-users*)) + #:*default-group* #:*single-project* #:*rails-command* #:*rails-command-args* + #:*merge-request-suffix* #:*ticket-suffix* #:*limit-to-active-users*)) diff --git a/src/main/gitlab/utils.lisp b/src/main/gitlab/utils.lisp --- a/src/main/gitlab/utils.lisp +++ b/src/main/gitlab/utils.lisp @@ -223,7 +223,7 @@ (when (not *rails-connection*) (setf *rails-connection* - (sb-ext:run-program "/usr/bin/ssh" *rails-console-ssh-args* + (sb-ext:run-program *rails-command* *rails-command-args* :input :stream :output :stream :wait nil))