Skip to content

Commit 0801978

Browse files
committed
feat: only stemcell match when provided in template
1 parent d064b7a commit 0801978

2 files changed

Lines changed: 29 additions & 4 deletions

File tree

internal/component/artifactory_release_source.go

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,15 @@ func (ars *ArtifactoryReleaseSource) findReleaseVersion(spec, searchSpec cargo.B
178178
return cargo.BOSHReleaseTarballLock{}, err
179179
}
180180

181+
names := re.SubexpNames()
182+
hasStemcellGroup := false
183+
for _, name := range names {
184+
if name == reStemcellVersionGroup {
185+
hasStemcellGroup = true
186+
break
187+
}
188+
}
189+
181190
foundRelease := cargo.BOSHReleaseTarballLock{}
182191
for _, artifactoryFile := range artifactoryFiles {
183192
if artifactoryFile.Folder {
@@ -187,7 +196,6 @@ func (ars *ArtifactoryReleaseSource) findReleaseVersion(spec, searchSpec cargo.B
187196
if matches == nil {
188197
continue
189198
}
190-
names := re.SubexpNames()
191199
matchedGroups := map[string]string{}
192200
for i, n := range names {
193201
if i == 0 || n == "" {
@@ -197,9 +205,7 @@ func (ars *ArtifactoryReleaseSource) findReleaseVersion(spec, searchSpec cargo.B
197205
}
198206

199207
version := matchedGroups[reReleaseVersionGroup]
200-
stemcellVersion := matchedGroups[reStemcellVersionGroup]
201-
// we aren't updating stemcell version
202-
if stemcellVersion != spec.StemcellVersion {
208+
if hasStemcellGroup && matchedGroups[reStemcellVersionGroup] != spec.StemcellVersion {
203209
continue
204210
}
205211

internal/component/artifactory_release_source_test.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -344,6 +344,25 @@ var _ = Describe("interacting with BOSH releases on Artifactory", func() {
344344
Expect(resultErr).NotTo(HaveOccurred())
345345
Expect(local.LocalPath).To(BeAnExistingFile())
346346
})
347+
348+
It("still finds the release when the spec has stemcell info from the lock file", func() {
349+
resultLock, resultErr := source.FindReleaseVersion(cargo.BOSHReleaseTarballSpecification{
350+
Name: "mango",
351+
Version: "*",
352+
StemcellOS: "smoothie",
353+
StemcellVersion: "9.9",
354+
}, false)
355+
356+
Expect(resultErr).NotTo(HaveOccurred())
357+
Expect(resultLock).To(Equal(cargo.BOSHReleaseTarballLock{
358+
Name: "mango",
359+
Version: "2.3.4",
360+
SHA1: "some-sha",
361+
RemotePath: "bosh-releases/mango-2.3.4.tgz",
362+
RemoteSource: "some-mango-tree",
363+
}))
364+
})
365+
347366
When("the server URL ends in /artifactory", func() {
348367
JustBeforeEach(func() {
349368
logger := log.New(GinkgoWriter, "", 0)

0 commit comments

Comments
 (0)