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

Commit 622d361

Browse files
Gab Satchimvalliath
authored andcommitted
Adds 1803 as an OS version.
- Uses same hwVersion as 2016 [#159599345] (https://www.pivotaltracker.com/story/show/159599345) Signed-off-by: Malini Valliath <mvalliath@pivotal.io>
1 parent 738ccd6 commit 622d361

File tree

4 files changed

+69
-11
lines changed

4 files changed

+69
-11
lines changed

integration/apply_patch_command_test.go

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,10 +110,36 @@ var _ = Describe("Apply Patch", func() {
110110
manifestStruct.OSVersion = ""
111111
})
112112

113-
It("displays an error", func(){
113+
It("displays an error", func() {
114114
session := helpers.Stembuild("apply-patch", manifestFilename)
115115
Eventually(session).Should(Exit(1))
116-
Eventually(session.Err).Should(Say("OS version must be either 2012R2 or 2016"))
116+
Eventually(session.Err).Should(Say("OS version must be either 2012R2, 2016 or 1803"))
117+
})
118+
})
119+
120+
Context("when OS version is 1803", func() {
121+
BeforeEach(func() {
122+
manifestStruct.OSVersion = "1803"
123+
osVersion = "1803"
124+
manifestStruct.Version = "1803.0"
125+
stemcellFilename = fmt.Sprintf("bosh-stemcell-%s-vsphere-esxi-windows%s-go_agent.tgz", manifestStruct.Version, osVersion)
126+
})
127+
128+
AfterEach(func() {
129+
Expect(os.Remove(stemcellFilename)).To(Succeed())
130+
})
131+
132+
It("creates a valid stemcell", func() {
133+
session := helpers.Stembuild("apply-patch", manifestFilename)
134+
Eventually(session, 5).Should(Exit(0))
135+
136+
stemcellDir, err := helpers.ExtractGzipArchive(stemcellFilename)
137+
Expect(err).NotTo(HaveOccurred())
138+
manifestFilepath := filepath.Join(stemcellDir, "stemcell.MF")
139+
manifest, err := helpers.ReadFile(manifestFilepath)
140+
Expect(err).NotTo(HaveOccurred())
141+
expectedName := fmt.Sprintf("name: bosh-vsphere-esxi-windows%s-go_agent", osVersion)
142+
Expect(manifest).To(ContainSubstring(expectedName))
117143
})
118144
})
119145

integration/convert_vmdk_command_test.go

Lines changed: 37 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,18 +22,50 @@ var _ = Describe("Convert VMDK", func() {
2222
Context("stembuild when executed", func() {
2323
var osVersion string
2424
var version string
25-
BeforeEach(func() {
25+
26+
AfterEach(func() {
27+
Expect(os.Remove(stemcellFilename)).To(Succeed())
28+
})
29+
30+
It("creates a valid 2012R2 stemcell", func() {
2631
osVersion = "2012R2"
2732
version = "1200.0"
2833
stemcellFilename = fmt.Sprintf("bosh-stemcell-%s-vsphere-esxi-windows%s-go_agent.tgz", version, osVersion)
2934
inputVmdk = filepath.Join("..", "testdata", "expected.vmdk")
30-
})
3135

32-
AfterEach(func() {
33-
Expect(os.Remove(stemcellFilename)).To(Succeed())
36+
session := helpers.Stembuild("-vmdk", inputVmdk, "-v", version, "-os", osVersion)
37+
Eventually(session, 5).Should(Exit(0))
38+
Eventually(session).Should(Say(`created stemcell: .*\.tgz`))
39+
Expect(stemcellFilename).To(BeAnExistingFile())
40+
41+
stemcellDir, err := helpers.ExtractGzipArchive(stemcellFilename)
42+
Expect(err).NotTo(HaveOccurred())
43+
44+
manifestFilepath := filepath.Join(stemcellDir, "stemcell.MF")
45+
manifest, err := helpers.ReadFile(manifestFilepath)
46+
Expect(err).NotTo(HaveOccurred())
47+
48+
expectedOs := fmt.Sprintf("operating_system: windows%s", osVersion)
49+
Expect(manifest).To(ContainSubstring(expectedOs))
50+
51+
expectedName := fmt.Sprintf("name: bosh-vsphere-esxi-windows%s-go_agent", osVersion)
52+
Expect(manifest).To(ContainSubstring(expectedName))
53+
54+
imageFilepath := filepath.Join(stemcellDir, "image")
55+
imageDir, err := helpers.ExtractGzipArchive(imageFilepath)
56+
Expect(err).NotTo(HaveOccurred())
57+
58+
actualVmdkFilepath := filepath.Join(imageDir, "image-disk1.vmdk")
59+
_, err = ioutil.ReadFile(actualVmdkFilepath)
60+
Expect(err).NotTo(HaveOccurred())
3461
})
3562

36-
It("creates a valid stemcell", func() {
63+
It("creates a valid 1803 stemcell", func() {
64+
osVersion = "1803"
65+
version = "1803.0"
66+
stemcellFilename = fmt.Sprintf("bosh-stemcell-%s-vsphere-esxi-windows%s-go_agent.tgz", version, osVersion)
67+
inputVmdk = filepath.Join("..", "testdata", "expected.vmdk")
68+
3769
session := helpers.Stembuild("-vmdk", inputVmdk, "-v", version, "-os", osVersion)
3870
Eventually(session, 5).Should(Exit(0))
3971
Eventually(session).Should(Say(`created stemcell: .*\.tgz`))

main.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ func Init() {
8787
flag.StringVar(&applyPatch.PatchFile, "d", "", "Patch file (shorthand)")
8888

8989
flag.StringVar(&applyPatch.OSVersion, "os", "",
90-
"OS version must be either 2012R2 or 2016")
90+
"OS version must be either 2012R2, 2016 or 1803")
9191

9292
flag.StringVar(&applyPatch.Version, "version", "",
9393
"Stemcell version in the form of [DIGITS].[DIGITS] (e.x. 123.01)")
@@ -236,10 +236,10 @@ func ValidateFlags() []error {
236236

237237
Debugf("validating OS version: %s", applyPatch.OSVersion)
238238
switch applyPatch.OSVersion {
239-
case "2012R2", "2016":
239+
case "2012R2", "2016", "1803":
240240
// Ok
241241
default:
242-
add(fmt.Errorf("OS version must be either 2012R2 or 2016 have: %s", applyPatch.OSVersion))
242+
add(fmt.Errorf("OS version must be either 2012R2, 2016 or 1803 have: %s", applyPatch.OSVersion))
243243
}
244244

245245
name := filepath.Join(applyPatch.OutputDir, stemcell.StemcellFilename(applyPatch.Version, applyPatch.OSVersion))

stemcell/stemcell.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,7 @@ func (c *Config) CreateImage(vmdk string) error {
351351
switch c.BuildOptions.OSVersion {
352352
case "2012R2":
353353
hwVersion = 9
354-
case "2016":
354+
case "2016", "1803":
355355
hwVersion = 10
356356
}
357357

0 commit comments

Comments
 (0)