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

Commit 97ddc0b

Browse files
committed
compile domain regex only once
1 parent 9b765dc commit 97ddc0b

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
@@ -61,6 +61,9 @@ type CIVar struct {
6161
Value string
6262
}
6363

64+
// match images w/ docker domain, or no domain (i.e. docker by default)
65+
var domainRegex = regexp.MustCompile(`^((registry-\d+|index)?\.?docker\.io\/|[^.]*(:|$))`)
66+
6467
type VcapAppData struct {
6568
CFApi string `json:"cf_api"`
6669
OrgID string `json:"org_id"`
@@ -159,14 +162,11 @@ func (cfg *JobConfig) processImage(img Image, m *cloudgov.AppManifest) {
159162
if img.Name != "" {
160163
m.Docker.Image = img.Name
161164

162-
// match images w/ docker domain, or no domain (i.e. docker by default)
163-
re := regexp.MustCompile(`^((registry-\d+|index)?\.?docker\.io\/|[^.]*(:|$))`)
164-
165165
// TODO: #95
166166
if strings.Contains(img.Name, "registry.gitlab.com") {
167167
m.Docker.Username = cfg.CIRegistryUser
168168
m.Docker.Password = cfg.CIRegistryPass
169-
} else if re.FindString(img.Name) != "" {
169+
} else if domainRegex.FindString(img.Name) != "" {
170170
m.Docker.Username = cfg.DockerHubUser
171171
m.Docker.Password = cfg.DockerHubToken
172172
}

0 commit comments

Comments
 (0)