Skip to content
This repository was archived by the owner on Aug 21, 2025. It is now read-only.

Commit 1cd2398

Browse files
committed
compile domain regex only once
1 parent 392ae33 commit 1cd2398

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

runner-manager/cfd/cmd/drive/get_job_config.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,9 @@ type CIVar struct {
6868
Value string
6969
}
7070

71+
// match images w/ docker domain, or no domain (i.e. docker by default)
72+
var domainRegex = regexp.MustCompile(`^((registry-\d+|index)?\.?docker\.io\/|[^.]*(:|$))`)
73+
7174
type VcapAppData struct {
7275
CFApi string `json:"cf_api"`
7376
OrgID string `json:"org_id"`
@@ -197,14 +200,11 @@ func (cfg *JobConfig) processImage(img Image, m *cloudgov.AppManifest) {
197200
if img.Name != "" {
198201
m.Docker.Image = img.Name
199202

200-
// match images w/ docker domain, or no domain (i.e. docker by default)
201-
re := regexp.MustCompile(`^((registry-\d+|index)?\.?docker\.io\/|[^.]*(:|$))`)
202-
203203
// TODO: #95
204204
if strings.Contains(img.Name, "registry.gitlab.com") {
205205
m.Docker.Username = cfg.CIRegistryUser
206206
m.Docker.Password = cfg.CIRegistryPass
207-
} else if re.FindString(img.Name) != "" {
207+
} else if domainRegex.FindString(img.Name) != "" {
208208
m.Docker.Username = cfg.DockerHubUser
209209
m.Docker.Password = cfg.DockerHubToken
210210
}

0 commit comments

Comments
 (0)