Commit 475caa29 authored by Kamil Trzciński's avatar Kamil Trzciński 💬

Rename setup/delete to register/unregister

parent f68b60c0
......@@ -4,6 +4,7 @@ v 0.3.0
- Support TLS connection with Docker
- Default concurrent limit is set to number of CPUs
- Make most of the config options optional
- Rename setup/delete to register/unregister
v 0.2.0
- Added delete and verify commands
......
......@@ -15,14 +15,14 @@ import (
"github.com/ayufan/gitlab-ci-multi-runner/ssh"
)
type SetupContext struct {
type RegistrationContext struct {
*cli.Context
configFile string
config *common.Config
reader *bufio.Reader
}
func (s *SetupContext) ask(key, prompt string, allowEmptyOptional ...bool) string {
func (s *RegistrationContext) ask(key, prompt string, allowEmptyOptional ...bool) string {
allowEmpty := len(allowEmptyOptional) > 0 && allowEmptyOptional[0]
result := s.String(key)
......@@ -59,7 +59,7 @@ func (s *SetupContext) ask(key, prompt string, allowEmptyOptional ...bool) strin
}
}
func (s *SetupContext) askExecutor() string {
func (s *RegistrationContext) askExecutor() string {
for {
names := common.GetExecutors()
executors := strings.Join(names, ", ")
......@@ -70,7 +70,7 @@ func (s *SetupContext) askExecutor() string {
}
}
func (s *SetupContext) askForDockerService(service string, dockerConfig *common.DockerConfig) bool {
func (s *RegistrationContext) askForDockerService(service string, dockerConfig *common.DockerConfig) bool {
for {
result := s.ask("docker-"+service, "If you want to enable "+service+" please enter version (X.Y) or enter latest?", true)
if len(result) == 0 {
......@@ -88,7 +88,7 @@ func (s *SetupContext) askForDockerService(service string, dockerConfig *common.
}
}
func (s *SetupContext) askDocker(runnerConfig *common.RunnerConfig) {
func (s *RegistrationContext) askDocker(runnerConfig *common.RunnerConfig) {
dockerConfig := &common.DockerConfig{}
dockerConfig.Image = s.ask("docker-image", "Please enter the Docker image (eg. ruby:2.1):")
dockerConfig.Privileged = s.Bool("docker-privileged")
......@@ -106,13 +106,13 @@ func (s *SetupContext) askDocker(runnerConfig *common.RunnerConfig) {
runnerConfig.Docker = dockerConfig
}
func (s *SetupContext) askParallels(runnerConfig *common.RunnerConfig) {
func (s *RegistrationContext) askParallels(runnerConfig *common.RunnerConfig) {
parallelsConfig := &common.ParallelsConfig{}
parallelsConfig.BaseName = s.ask("parallels-vm", "Please enter the Parallels VM (eg. my-vm):")
runnerConfig.Parallels = parallelsConfig
}
func (s *SetupContext) askSSH(runnerConfig *common.RunnerConfig, serverless bool) {
func (s *RegistrationContext) askSSH(runnerConfig *common.RunnerConfig, serverless bool) {
runnerConfig.SSH = &ssh.Config{}
if !serverless {
if host := s.ask("ssh-host", "Please enter the SSH server address (eg. my.server.com):"); host != "" {
......@@ -130,32 +130,32 @@ func (s *SetupContext) askSSH(runnerConfig *common.RunnerConfig, serverless bool
}
}
func (s *SetupContext) touchConfig() {
func (s *RegistrationContext) touchConfig() {
file, _ := os.OpenFile(s.configFile, os.O_APPEND|os.O_CREATE, 0600)
if file != nil {
file.Close()
}
}
func (s *SetupContext) loadConfig() {
func (s *RegistrationContext) loadConfig() {
err := s.config.LoadConfig(s.configFile)
if err != nil {
panic(err)
}
}
func (s *SetupContext) addRunner(runner *common.RunnerConfig) {
func (s *RegistrationContext) addRunner(runner *common.RunnerConfig) {
s.config.Runners = append(s.config.Runners, runner)
}
func (s *SetupContext) saveConfig() {
func (s *RegistrationContext) saveConfig() {
err := s.config.SaveConfig(s.configFile)
if err != nil {
panic(err)
}
}
func (s *SetupContext) askRunner() common.RunnerConfig {
func (s *RegistrationContext) askRunner() common.RunnerConfig {
url := s.ask("url", "Please enter the gitlab-ci coordinator URL (e.g. http://gitlab-ci.org:3000/):")
registrationToken := s.ask("registration-token", "Please enter the gitlab-ci token for this runner:")
description := s.ask("description", "Please enter the gitlab-ci description for this runner:")
......@@ -173,8 +173,8 @@ func (s *SetupContext) askRunner() common.RunnerConfig {
}
}
func runSetup(c *cli.Context) {
s := SetupContext{
func runRegister(c *cli.Context) {
s := RegistrationContext{
Context: c,
config: common.NewConfig(),
configFile: c.String("config"),
......@@ -242,10 +242,9 @@ func getHostname() string {
func init() {
common.RegisterCommand(cli.Command{
Name: "setup",
ShortName: "s",
Usage: "setup a new runner",
Action: runSetup,
Name: "register",
Usage: "register a new runner",
Action: runRegister,
Flags: []cli.Flag{
cli.StringFlag{
Name: "c, config",
......@@ -255,13 +254,13 @@ func init() {
},
cli.BoolFlag{
Name: "n, non-interactive",
Usage: "Run setup unattended",
EnvVar: "SETUP_NON_INTERACTIVE",
Usage: "Run registration unattended",
EnvVar: "REGISTER_NON_INTERACTIVE",
},
cli.BoolFlag{
Name: "leave-runner",
Usage: "Don't remove runner if setup fails",
EnvVar: "SETUP_LEAVE_RUNNER",
Usage: "Don't remove runner if registration fails",
EnvVar: "REGISTER_LEAVE_RUNNER",
},
cli.StringFlag{
......
......@@ -7,7 +7,7 @@ import (
"github.com/ayufan/gitlab-ci-multi-runner/common"
)
func runDelete(c *cli.Context) {
func runUnregister(c *cli.Context) {
runner := common.RunnerConfig{
URL: c.String("url"),
Token: c.String("token"),
......@@ -48,9 +48,9 @@ func runDelete(c *cli.Context) {
func init() {
common.RegisterCommand(cli.Command{
Name: "delete",
Usage: "delete specific runner",
Action: runDelete,
Name: "unregister",
Usage: "unregister specific runner",
Action: runUnregister,
Flags: []cli.Flag{
cli.StringFlag{
Name: "token",
......
## How to configure runner for GitLab CI integration tests (uses confined Docker executor)
### 1. Run the setup
### 1. Register the runner
The registration token can be found at `https://ci.gitlab.com/projects/:id/runners`.
You can export it as a variable and run the command below as is:
```bash
gitlab-ci-multi-runner setup \
gitlab-ci-multi-runner register \
--non-interactive \
--url "https://ci.gitlab.com/" \
--registration-token "REGISTRATION_TOKEN" \
......
## How to configure runner for GitLab CE integration tests (uses confined Docker executor)
### 1. Run the setup
### 1. Register the runner
The registration token can be found at `https://ci.gitlab.com/projects/:id/runners`.
You can export it as a variable and run the command below as is:
```bash
gitlab-ci-multi-runner setup \
gitlab-ci-multi-runner register \
--non-interactive \
--url "https://ci.gitlab.com/" \
--registration-token "REGISTRATION_TOKEN" \
......
......@@ -37,10 +37,10 @@ docker run -d --name multi-runner --restart always \
ayufan/gitlab-ci-multi-runner:latest
```
Setup the runner:
Register the runner:
```bash
docker exec -it multi-runner gitlab-ci-multi-runner setup
docker exec -it multi-runner gitlab-ci-multi-runner register
Please enter the gitlab-ci coordinator URL (e.g. http://gitlab-ci.org:3000/ )
https://ci.gitlab.org/
......
......@@ -29,11 +29,11 @@ sudo useradd --comment 'GitLab Runner' --create-home gitlab_ci_multi_runner --sh
sudo usermod -aG docker gitlab_ci_multi_runner
```
Setup the runner:
Register the runner:
```bash
cd ~gitlab_ci_multi_runner
sudo -u gitlab_ci_multi_runner -H gitlab-ci-multi-runner setup
sudo -u gitlab_ci_multi_runner -H gitlab-ci-multi-runner register
```
Secure `config.toml`:
......
......@@ -28,11 +28,11 @@ apt-get install gitlab-ci-multi-runner
yum install gitlab-ci-multi-runner
```
Setup the runner:
Register the runner:
```bash
cd ~gitlab_ci_multi_runner
gitlab-ci-multi-runner setup
gitlab-ci-multi-runner register
Please enter the gitlab-ci coordinator URL (e.g. http://gitlab-ci.org:3000/ )
https://ci.gitlab.org/
......
......@@ -16,9 +16,9 @@ sudo chmod +x /usr/local/bin/gitlab-ci-multi-runner
**The rest of commands execute as the user who will run the runner.**
Setup the runner:
Register the runner:
```bash
gitlab-ci-multi-runner-linux setup
gitlab-ci-multi-runner-linux register
Please enter the gitlab-ci coordinator URL (e.g. http://gitlab-ci.org:3000/ )
https://ci.gitlab.org/
......@@ -46,7 +46,7 @@ Voila! Runner is installed and will be run after system reboot.
### Update
Stop the service (you need elevated command prompt as before):
Stop the service:
```bash
gitlab-ci-multi-runner stop
......
......@@ -10,11 +10,11 @@ write `Command Prompt` in Windows search field, right click and select
`Run as administrator`. You will be asked to confirm that you want to execute
the elevated command prompt.
Setup the runner:
Register the runner:
```bash
cd C:\Multi-Runner
gitlab-ci-multi-runner-linux setup
gitlab-ci-multi-runner-linux register
Please enter the gitlab-ci coordinator URL (e.g. http://gitlab-ci.org:3000/ )
https://ci.gitlab.com
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment