@@ -17,15 +17,11 @@ import (
1717 "github.com/stackitcloud/stackit-sdk-go/services/iaas"
1818)
1919
20- var projectIdFlag = globalflags .ProjectIdFlag
21-
22- type testCtxKey struct {}
23-
24- var (
25- testCtx = context .WithValue (context .Background (), testCtxKey {}, "foo" )
26- testClient = & iaas.APIClient {}
27- testProjectId = uuid .NewString ()
20+ const (
21+ projectIdFlag = globalflags .ProjectIdFlag
22+ regionFlag = globalflags .RegionFlag
2823
24+ testRegion = "eu01"
2925 testLocalImagePath = "/does/not/exist"
3026 testDiskFormat = "raw"
3127 testDiskSize int64 = 16 * 1024 * 1024 * 1024
4945 testLabels = "foo=FOO,bar=BAR,baz=BAZ"
5046)
5147
48+ type testCtxKey struct {}
49+
50+ var (
51+ testCtx = context .WithValue (context .Background (), testCtxKey {}, "foo" )
52+ testClient = & iaas.APIClient {}
53+ testProjectId = uuid .NewString ()
54+ )
55+
5256func fixtureFlagValues (mods ... func (flagValues map [string ]string )) map [string ]string {
5357 flagValues := map [string ]string {
5458 projectIdFlag : testProjectId ,
59+ regionFlag : testRegion ,
5560
5661 nameFlag : testName ,
5762 diskFormatFlag : testDiskFormat ,
@@ -93,30 +98,34 @@ func parseLabels(labelstring string) map[string]string {
9398
9499func fixtureInputModel (mods ... func (model * inputModel )) * inputModel {
95100 model := & inputModel {
96- GlobalFlagModel : & globalflags.GlobalFlagModel {ProjectId : testProjectId , Verbosity : globalflags .VerbosityDefault },
97- Name : testName ,
98- DiskFormat : testDiskFormat ,
99- LocalFilePath : testLocalImagePath ,
100- Labels : utils .Ptr (parseLabels (testLabels )),
101+ GlobalFlagModel : & globalflags.GlobalFlagModel {
102+ ProjectId : testProjectId ,
103+ Verbosity : globalflags .VerbosityDefault ,
104+ Region : testRegion ,
105+ },
106+ Name : testName ,
107+ DiskFormat : testDiskFormat ,
108+ LocalFilePath : testLocalImagePath ,
109+ Labels : utils .Ptr (parseLabels (testLabels )),
101110 Config : & imageConfig {
102- Architecture : & testArchitecture ,
103- BootMenu : & testBootmenu ,
104- CdromBus : & testCdRomBus ,
105- DiskBus : & testDiskBus ,
106- NicModel : & testNicModel ,
107- OperatingSystem : & testOperatingSystem ,
108- OperatingSystemDistro : & testOperatingSystemDistro ,
109- OperatingSystemVersion : & testOperatingSystemVersion ,
110- RescueBus : & testRescueBus ,
111- RescueDevice : & testRescueDevice ,
112- SecureBoot : & testSecureBoot ,
111+ Architecture : utils . Ptr ( testArchitecture ) ,
112+ BootMenu : utils . Ptr ( testBootmenu ) ,
113+ CdromBus : utils . Ptr ( testCdRomBus ) ,
114+ DiskBus : utils . Ptr ( testDiskBus ) ,
115+ NicModel : utils . Ptr ( testNicModel ) ,
116+ OperatingSystem : utils . Ptr ( testOperatingSystem ) ,
117+ OperatingSystemDistro : utils . Ptr ( testOperatingSystemDistro ) ,
118+ OperatingSystemVersion : utils . Ptr ( testOperatingSystemVersion ) ,
119+ RescueBus : utils . Ptr ( testRescueBus ) ,
120+ RescueDevice : utils . Ptr ( testRescueDevice ) ,
121+ SecureBoot : utils . Ptr ( testSecureBoot ) ,
113122 Uefi : testUefi ,
114- VideoModel : & testVideoModel ,
115- VirtioScsi : & testVirtioScsi ,
123+ VideoModel : utils . Ptr ( testVideoModel ) ,
124+ VirtioScsi : utils . Ptr ( testVirtioScsi ) ,
116125 },
117- MinDiskSize : & testDiskSize ,
118- MinRam : & testRamSize ,
119- Protected : & testProtected ,
126+ MinDiskSize : utils . Ptr ( testDiskSize ) ,
127+ MinRam : utils . Ptr ( testRamSize ) ,
128+ Protected : utils . Ptr ( testProtected ) ,
120129 }
121130 for _ , mod := range mods {
122131 mod (model )
@@ -127,31 +136,31 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel {
127136func fixtureCreatePayload (mods ... func (payload * iaas.CreateImagePayload )) (payload iaas.CreateImagePayload ) {
128137 payload = iaas.CreateImagePayload {
129138 Config : & iaas.ImageConfig {
130- Architecture : & testArchitecture ,
131- BootMenu : & testBootmenu ,
132- CdromBus : iaas .NewNullableString (& testCdRomBus ),
133- DiskBus : iaas .NewNullableString (& testDiskBus ),
134- NicModel : iaas .NewNullableString (& testNicModel ),
135- OperatingSystem : & testOperatingSystem ,
136- OperatingSystemDistro : iaas .NewNullableString (& testOperatingSystemDistro ),
137- OperatingSystemVersion : iaas .NewNullableString (& testOperatingSystemVersion ),
138- RescueBus : iaas .NewNullableString (& testRescueBus ),
139- RescueDevice : iaas .NewNullableString (& testRescueDevice ),
140- SecureBoot : & testSecureBoot ,
141- Uefi : & testUefi ,
142- VideoModel : iaas .NewNullableString (& testVideoModel ),
143- VirtioScsi : & testVirtioScsi ,
139+ Architecture : utils . Ptr ( testArchitecture ) ,
140+ BootMenu : utils . Ptr ( testBootmenu ) ,
141+ CdromBus : iaas .NewNullableString (utils . Ptr ( testCdRomBus ) ),
142+ DiskBus : iaas .NewNullableString (utils . Ptr ( testDiskBus ) ),
143+ NicModel : iaas .NewNullableString (utils . Ptr ( testNicModel ) ),
144+ OperatingSystem : utils . Ptr ( testOperatingSystem ) ,
145+ OperatingSystemDistro : iaas .NewNullableString (utils . Ptr ( testOperatingSystemDistro ) ),
146+ OperatingSystemVersion : iaas .NewNullableString (utils . Ptr ( testOperatingSystemVersion ) ),
147+ RescueBus : iaas .NewNullableString (utils . Ptr ( testRescueBus ) ),
148+ RescueDevice : iaas .NewNullableString (utils . Ptr ( testRescueDevice ) ),
149+ SecureBoot : utils . Ptr ( testSecureBoot ) ,
150+ Uefi : utils . Ptr ( testUefi ) ,
151+ VideoModel : iaas .NewNullableString (utils . Ptr ( testVideoModel ) ),
152+ VirtioScsi : utils . Ptr ( testVirtioScsi ) ,
144153 },
145- DiskFormat : & testDiskFormat ,
154+ DiskFormat : utils . Ptr ( testDiskFormat ) ,
146155 Labels : & map [string ]interface {}{
147156 "foo" : "FOO" ,
148157 "bar" : "BAR" ,
149158 "baz" : "BAZ" ,
150159 },
151- MinDiskSize : & testDiskSize ,
152- MinRam : & testRamSize ,
153- Name : & testName ,
154- Protected : & testProtected ,
160+ MinDiskSize : utils . Ptr ( testDiskSize ) ,
161+ MinRam : utils . Ptr ( testRamSize ) ,
162+ Name : utils . Ptr ( testName ) ,
163+ Protected : utils . Ptr ( testProtected ) ,
155164 }
156165 for _ , mod := range mods {
157166 mod (& payload )
@@ -160,7 +169,7 @@ func fixtureCreatePayload(mods ...func(payload *iaas.CreateImagePayload)) (paylo
160169}
161170
162171func fixtureRequest (mods ... func (request * iaas.ApiCreateImageRequest )) iaas.ApiCreateImageRequest {
163- request := testClient .CreateImage (testCtx , testProjectId )
172+ request := testClient .CreateImage (testCtx , testProjectId , testRegion )
164173
165174 request = request .CreateImagePayload (fixtureCreatePayload ())
166175
0 commit comments