Skip to content

Commit

Permalink
Merge pull request #111 from concourse/fix-swift-initial-version
Browse files Browse the repository at this point in the history
[swift] make initial version optional
  • Loading branch information
taylorsilva authored May 19, 2020
2 parents b820c58 + 31e1d5b commit c9c668a
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
11 changes: 8 additions & 3 deletions driver/swift.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,14 @@ func NewSwiftDriver(source *models.Source) (Driver, error) {
return nil, fmt.Errorf("Unable to get container by name '%s', inner error: %s", source.OpenStack.Container, err.Error())
}

initialVersion, err := semver.Parse(source.InitialVersion)
if err != nil {
return nil, fmt.Errorf("Initial version was not a valid sem ver: %s", err.Error())
var initialVersion semver.Version
if source.InitialVersion != "" {
initialVersion, err = semver.Parse(source.InitialVersion)
if err != nil {
return nil, fmt.Errorf("Initial version was not a valid sem ver: %s", err.Error())
}
} else {
initialVersion = semver.Version{Major: 0, Minor: 0, Patch: 0}
}

driver := &SwiftDriver{
Expand Down
10 changes: 10 additions & 0 deletions driver/swift_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,16 @@ var _ = Describe("Swift", func() {
Expect(semVers).To(HaveLen(1))
Expect(semVers[0].String()).To(Equal("2.0.10"))
})

It("the initial version is optional", func() {
driver, err := newTestSwiftDriver("", "testitem4.txt")
defer deleteObject("testitem4.txt")
Expect(err).To(BeNil())

semVers, err := driver.Check(nil)
Expect(err).To(BeNil())
Expect(semVers).To(HaveLen(0))
})
})

func newTestSwiftDriver(initialVersion string, itemName string) (Driver, error) {
Expand Down

0 comments on commit c9c668a

Please sign in to comment.