Skip to content
This repository has been archived by the owner on Oct 10, 2023. It is now read-only.

Commit

Permalink
Consider additional metadata as part of k8s's build version
Browse files Browse the repository at this point in the history
  • Loading branch information
anujc25 committed May 3, 2022
1 parent b1007f2 commit 4a38d87
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 2 deletions.
7 changes: 5 additions & 2 deletions pkg/v1/tkg/utils/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,11 @@ func CompareVMwareVersionStrings(v1, v2 string) (int, error) {
return compareResult, nil
}

v1VmwareBuildVersion, err1 := strconv.Atoi(v1s[1])
v2VmwareBuildVersion, err2 := strconv.Atoi(v2s[1])
buildVersionV1 := strings.Split(v1s[1], "-")
buildVersionV2 := strings.Split(v2s[1], "-")

v1VmwareBuildVersion, err1 := strconv.Atoi(buildVersionV1[0])
v2VmwareBuildVersion, err2 := strconv.Atoi(buildVersionV2[0])
if err1 != nil || err2 != nil {
return 0, errors.New("invalid version string")
}
Expand Down
55 changes: 55 additions & 0 deletions pkg/v1/tkg/utils/common_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,61 @@ var _ = Describe("CompareVMwareVersionStrings", func() {
Expect(err).To(MatchError("invalid version string"))
})
})

Context("When buildVersion includes more information about fips etc", func() {
BeforeEach(func() {
fromVersion = "v1.17.3+vmware.1-fips.1"
toVersion = "v1.17.4+vmware.1-fips.1"
})
It("expect compareResult < 0", func() {
Expect(err).NotTo(HaveOccurred())
Expect(compareResult < 0).To(Equal(true))
})
})

Context("When buildVersion includes more information about fips etc and buildVersion is different", func() {
BeforeEach(func() {
fromVersion = "v1.17.3+vmware.1-fips.1"
toVersion = "v1.17.3+vmware.2-fips.1"
})
It("expect compareResult < 0", func() {
Expect(err).NotTo(HaveOccurred())
Expect(compareResult < 0).To(Equal(true))
})
})

Context("When buildVersion includes more information about fips etc and buildVersion is different", func() {
BeforeEach(func() {
fromVersion = "v1.17.3+vmware.2-fips.1"
toVersion = "v1.17.3+vmware.1-fips.1"
})
It("expect compareResult > 0", func() {
Expect(err).NotTo(HaveOccurred())
Expect(compareResult > 0).To(Equal(true))
})
})

Context("When buildVersion includes more information about fips etc and buildVersion are same", func() {
BeforeEach(func() {
fromVersion = "v1.17.3+vmware.1-fips.1"
toVersion = "v1.17.3+vmware.1-fips.1"
})
It("expect compareResult = 0", func() {
Expect(err).NotTo(HaveOccurred())
Expect(compareResult == 0).To(Equal(true))
})
})

Context("When buildVersion includes more information about fips and fips build version are different", func() {
BeforeEach(func() {
fromVersion = "v1.17.3+vmware.1-fips.1"
toVersion = "v1.17.3+vmware.1-fips.2"
})
It("expect compareResult = 0", func() {
Expect(err).NotTo(HaveOccurred())
Expect(compareResult == 0).To(Equal(true))
})
})
})

var _ = Describe("GenerateRandomID", func() {
Expand Down

0 comments on commit 4a38d87

Please # to comment.