Skip to content
Snippets Groups Projects
Select Git revision
  • 9e40068103e7eec7cc52f67c48e5acd742ce7304
  • master default protected
  • 11-9-stable-plus-mr-1022-kube-exec-svc-alias
  • 11-7-stable-plus-mr-1022-kube-exec-svc-alias
  • 11-5-stable-plus-mr-1022-kube-exec-svc-alias
  • 11-4-stable-plus-mr-936-add-service-resolution-support-to-k8s-executor
  • 11-4-stable-plus-mr-1022-kube-exec-svc-alias
  • notify-dep-status-failures-on-slack
  • 3467-change-docker-executor-container-mangement-like-k8s
  • 11-4-stable
  • 11-2-stable
  • 11-3-stable
  • 3637-terminal-session-not-killed-when-user-cancel-build
  • generate-junit-report-file-for-tests
  • tm-3639-follow-up-from-resolve-add-docker-support-for-interactive-web-terminal
  • docs-ck-fix-alignment-runner-index
  • refactor-app-initialization
  • log-body-of-requests-sent-from-runner-to-gitlab
  • 3578-randomly-failing-test-introduced-with-web-terminal-initial-support
  • prepare-build-current-docker-make-target
  • fix/windows-cache-extractor
  • v11.4.2
  • v11.4.1
  • v11.3.2
  • v11.2.2
  • v11.4.0
  • v11.4.0-rc1
  • v11.3.1
  • v11.2.1
  • v11.1.1
  • v11.3.0
  • v11.3.0-rc1
  • v11.2.0
  • v11.2.0-rc2
  • v11.2.0-rc1
  • v11.1.0
  • v11.0.2
  • v10.8.2
  • v10.7.4
  • v10.7.3
  • v10.8.1
41 results

name.go

Blame
  • user avatar
    Kamil Trzciński authored and Tomasz Maczukin committed
    Make new runner tokens compatible with docker-machine executor
    
    Closes #3883
    
    See merge request gitlab-org/gitlab-runner!1144
    9e400681
    History
    Code owners
    Assign users and groups as approvers for specific file changes. Learn more.
    name.go 1.10 KiB
    package machine
    
    import (
    	"crypto/rand"
    	"fmt"
    	"strings"
    	"time"
    
    	"gitlab.com/gitlab-org/gitlab-runner/common"
    	"gitlab.com/gitlab-org/gitlab-runner/helpers/dns"
    )
    
    func machineFormat(runner string, template string) string {
    	if runner != "" {
    		return "runner-" + strings.ToLower(runner) + "-" + template
    	}
    	return template
    }
    
    func machineFilter(config *common.RunnerConfig) string {
    	return machineFormat(dns.MakeRFC1123Compatible(config.ShortDescription()), config.Machine.MachineName)
    }
    
    func matchesMachineFilter(name, filter string) bool {
    	var query string
    	if n, _ := fmt.Sscanf(name, filter, &query); n == 1 {
    		return true
    	}
    	return false
    }
    
    func filterMachineList(machines []string, filter string) (newMachines []string) {
    	newMachines = make([]string, 0, len(machines))
    	for _, machine := range machines {
    		if matchesMachineFilter(machine, filter) {
    			newMachines = append(newMachines, machine)
    		}
    	}
    	return
    }
    
    func newMachineName(config *common.RunnerConfig) string {
    	r := make([]byte, 4)
    	rand.Read(r)
    	t := time.Now().Unix()
    	return fmt.Sprintf(machineFilter(config), fmt.Sprintf("%d-%x", t, r))
    }