@@ -2,7 +2,6 @@ package create
22
33import (
44 "context"
5- "fmt"
65 "testing"
76 "time"
87
@@ -17,59 +16,59 @@ import (
1716 "github.com/google/go-cmp/cmp"
1817 "github.com/google/go-cmp/cmp/cmpopts"
1918 "github.com/google/uuid"
20- "github.com/stackitcloud/stackit-sdk-go/services/ske"
19+ ske "github.com/stackitcloud/stackit-sdk-go/services/ske/v2api "
2120)
2221
2322var projectIdFlag = globalflags .ProjectIdFlag
2423
2524type testCtxKey struct {}
2625
2726var testCtx = context .WithValue (context .Background (), testCtxKey {}, "foo" )
28- var testClient = & ske.APIClient {}
27+ var testClient = & ske.APIClient {DefaultAPI : & ske. DefaultAPIService {} }
2928var testProjectId = uuid .NewString ()
3029var testClusterName = "cluster"
3130
3231const testRegion = "eu01"
3332
3433var testPayload = & ske.CreateOrUpdateClusterPayload {
35- Kubernetes : & ske.Kubernetes {
36- Version : utils . Ptr ( "1.25.15" ) ,
34+ Kubernetes : ske.Kubernetes {
35+ Version : "1.25.15" ,
3736 },
38- Nodepools : & []ske.Nodepool {
37+ Nodepools : []ske.Nodepool {
3938 {
40- Name : utils . Ptr ( "np-name" ) ,
41- Machine : & ske.Machine {
42- Image : & ske.Image {
43- Name : utils . Ptr ( "flatcar" ) ,
44- Version : utils . Ptr ( "3760.2.1" ) ,
39+ Name : "np-name" ,
40+ Machine : ske.Machine {
41+ Image : ske.Image {
42+ Name : "flatcar" ,
43+ Version : "3760.2.1" ,
4544 },
46- Type : utils . Ptr ( "b1.2" ) ,
45+ Type : "b1.2" ,
4746 },
48- Minimum : utils . Ptr ( int64 ( 1 ) ),
49- Maximum : utils . Ptr ( int64 ( 2 ) ),
50- MaxSurge : utils .Ptr (int64 (1 )),
51- Volume : & ske.Volume {
47+ Minimum : int32 ( 1 ),
48+ Maximum : int32 ( 2 ),
49+ MaxSurge : utils .Ptr (int32 (1 )),
50+ Volume : ske.Volume {
5251 Type : utils .Ptr ("storage_premium_perf0" ),
53- Size : utils . Ptr ( int64 ( 40 ) ),
52+ Size : int32 ( 40 ),
5453 },
55- AvailabilityZones : & []string {"eu01-3" },
56- Cri : & ske.CRI {Name : ske . CRINAME_DOCKER . Ptr ()},
54+ AvailabilityZones : []string {"eu01-3" },
55+ Cri : & ske.CRI {Name : utils . Ptr ("containerd" )},
5756 },
5857 },
5958 Extensions : & ske.Extension {
6059 Acl : & ske.ACL {
61- Enabled : utils . Ptr ( true ) ,
62- AllowedCidrs : & []string {"0.0.0.0/0" },
60+ Enabled : true ,
61+ AllowedCidrs : []string {"0.0.0.0/0" },
6362 },
6463 },
6564 Maintenance : & ske.Maintenance {
66- AutoUpdate : & ske.MaintenanceAutoUpdate {
65+ AutoUpdate : ske.MaintenanceAutoUpdate {
6766 KubernetesVersion : utils .Ptr (true ),
6867 MachineImageVersion : utils .Ptr (true ),
6968 },
70- TimeWindow : & ske.TimeWindow {
71- End : utils . Ptr ( time .Date (0 , 1 , 1 , 5 , 0 , 0 , 0 , time .FixedZone ("test-zone" , 2 * 60 * 60 ) )),
72- Start : utils . Ptr ( time .Date (0 , 1 , 1 , 3 , 0 , 0 , 0 , time .FixedZone ("test-zone" , 2 * 60 * 60 ) )),
69+ TimeWindow : ske.TimeWindow {
70+ End : time .Date (0 , 1 , 1 , 5 , 0 , 0 , 0 , time .FixedZone ("test-zone" , 2 * 60 * 60 )),
71+ Start : time .Date (0 , 1 , 1 , 3 , 0 , 0 , 0 , time .FixedZone ("test-zone" , 2 * 60 * 60 )),
7372 },
7473 },
7574}
@@ -88,8 +87,7 @@ func fixtureFlagValues(mods ...func(flagValues map[string]string)) map[string]st
8887 flagValues := map [string ]string {
8988 globalflags .ProjectIdFlag : testProjectId ,
9089 globalflags .RegionFlag : testRegion ,
91- payloadFlag : fmt .Sprintf (`{
92- "name": "cli-jp",
90+ payloadFlag : `{
9391 "kubernetes": {
9492 "version": "1.25.15"
9593 },
@@ -107,7 +105,7 @@ func fixtureFlagValues(mods ...func(flagValues map[string]string)) map[string]st
107105 "maximum": 2,
108106 "maxSurge": 1,
109107 "volume": { "type": "storage_premium_perf0", "size": 40 },
110- "cri": { "name": "%s " },
108+ "cri": { "name": "containerd " },
111109 "availabilityZones": ["eu01-3"]
112110 }
113111 ],
@@ -122,7 +120,7 @@ func fixtureFlagValues(mods ...func(flagValues map[string]string)) map[string]st
122120 "start": "0000-01-01T03:00:00+02:00"
123121 }
124122 }
125- }` , ske . CRINAME_DOCKER ),
123+ }` ,
126124 }
127125 for _ , mod := range mods {
128126 mod (flagValues )
@@ -147,7 +145,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel {
147145}
148146
149147func fixtureRequest (mods ... func (request * ske.ApiCreateOrUpdateClusterRequest )) ske.ApiCreateOrUpdateClusterRequest {
150- request := testClient .CreateOrUpdateCluster (testCtx , testProjectId , testRegion , fixtureInputModel ().ClusterName )
148+ request := testClient .DefaultAPI . CreateOrUpdateCluster (testCtx , testProjectId , testRegion , fixtureInputModel ().ClusterName )
151149 request = request .CreateOrUpdateClusterPayload (* testPayload )
152150 for _ , mod := range mods {
153151 mod (& request )
@@ -262,6 +260,7 @@ func TestBuildRequest(t *testing.T) {
262260 diff := cmp .Diff (request , tt .expectedRequest ,
263261 cmp .AllowUnexported (tt .expectedRequest ),
264262 cmpopts .EquateComparable (testCtx ),
263+ cmpopts .EquateComparable (testClient .DefaultAPI ),
265264 )
266265 if diff != "" {
267266 t .Fatalf ("Data does not match: %s" , diff )
0 commit comments