Skip to content

Commit

Permalink
Merge branch 'master' into meat-sig-switch
Browse files Browse the repository at this point in the history
  • Loading branch information
meatballhat authored Oct 16, 2017
2 parents 3ba889b + 9464c6c commit bd3ce9f
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/).
### Removed

### Fixed
- backend/docker: switch to container hostname with dashes instead of dots

### Security

Expand Down
4 changes: 2 additions & 2 deletions backend/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -707,7 +707,7 @@ func findDockerImageByTag(searchTags []string, images []dockertypes.ImageSummary
}

func containerNameFromContext(ctx gocontext.Context) string {
randName := fmt.Sprintf("travis-job.unk.unk.%s", uuid.NewRandom())
randName := fmt.Sprintf("travis-job-unk-unk-%s", uuid.NewRandom())
jobID, ok := context.JobIDFromContext(ctx)
if !ok {
return randName
Expand All @@ -733,5 +733,5 @@ func containerNameFromContext(ctx gocontext.Context) string {
nameParts = append(nameParts, cleanedPart)
}

return strings.Join(append(nameParts, fmt.Sprintf("%v", jobID)), ".")
return strings.Join(append(nameParts, fmt.Sprintf("%v", jobID)), "-")
}
10 changes: 5 additions & 5 deletions backend/docker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -589,20 +589,20 @@ func TestDocker_containerNameFromContext(t *testing.T) {
for _, tc := range []struct{ r, n string }{
{
r: "friendly/fribble",
n: fmt.Sprintf("travis-job.friendly.fribble.%v", jobID),
n: fmt.Sprintf("travis-job-friendly-fribble-%v", jobID),
},
{
r: "very-SiLlY.nAmE.wat/por-cu-pine",
n: fmt.Sprintf("travis-job.very-SiLlY-nAm.por-cu-pine.%v", jobID),
n: fmt.Sprintf("travis-job-very-SiLlY-nAm-por-cu-pine-%v", jobID),
},
} {
ctx := context.FromRepository(context.FromJobID(gocontext.TODO(), jobID), tc.r)
assert.Equal(t, tc.n, containerNameFromContext(ctx))
}

randName := containerNameFromContext(gocontext.TODO())
randParts := strings.Split(randName, ".")
assert.Len(t, randParts, 4)
assert.Equal(t, "unk", randParts[1])
randParts := strings.Split(randName, "-")
assert.Len(t, randParts, 9)
assert.Equal(t, "unk", randParts[2])
assert.Equal(t, "unk", randParts[3])
}

0 comments on commit bd3ce9f

Please sign in to comment.