@@ -5,10 +5,11 @@ import (
55
66 "github.com/stretchr/testify/assert"
77 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
8- "k8s.io/utils/pointer "
8+ "k8s.io/utils/ptr "
99
1010 "github.com/openshift/installer/pkg/ipnet"
1111 "github.com/openshift/installer/pkg/types"
12+ nutanixtypes "github.com/openshift/installer/pkg/types/nutanix"
1213 vspheretypes "github.com/openshift/installer/pkg/types/vsphere"
1314)
1415
@@ -36,13 +37,13 @@ func TestRedactedInstallConfig(t *testing.T) {
3637 },
3738 ControlPlane : & types.MachinePool {
3839 Name : "control-plane" ,
39- Replicas : pointer . Int64Ptr ( 3 ),
40+ Replicas : ptr . To ( int64 ( 3 ) ),
4041 Architecture : types .ArchitectureAMD64 ,
4142 },
4243 Compute : []types.MachinePool {
4344 {
4445 Name : "compute" ,
45- Replicas : pointer . Int64Ptr ( 3 ),
46+ Replicas : ptr . To ( int64 ( 3 ) ),
4647 Architecture : types .ArchitectureAMD64 ,
4748 },
4849 },
@@ -131,3 +132,114 @@ sshKey: test-ssh-key
131132 }
132133 assert .Equal (t , expectedConfig , ic , "install config was unexpectedly modified" )
133134}
135+
136+ // TestRedactedInstallConfigNutanix tests the redactedInstallConfig function for Nutanix platform.
137+ func TestRedactedInstallConfigNutanix (t * testing.T ) {
138+ createInstallConfigWithNutanix := func () * types.InstallConfig {
139+ return & types.InstallConfig {
140+ ObjectMeta : metav1.ObjectMeta {
141+ Name : "test-nutanix-cluster" ,
142+ },
143+ SSHKey : "test-ssh-key" ,
144+ BaseDomain : "test-domain" ,
145+ Networking : & types.Networking {
146+ MachineNetwork : []types.MachineNetworkEntry {
147+ {CIDR : * ipnet .MustParseCIDR ("1.2.3.4/5" )},
148+ },
149+ NetworkType : "test-network-type" ,
150+ ClusterNetwork : []types.ClusterNetworkEntry {
151+ {
152+ CIDR : * ipnet .MustParseCIDR ("1.2.3.4/5" ),
153+ HostPrefix : 6 ,
154+ },
155+ },
156+ ServiceNetwork : []ipnet.IPNet {* ipnet .MustParseCIDR ("1.2.3.4/5" )},
157+ },
158+ ControlPlane : & types.MachinePool {
159+ Name : "control-plane" ,
160+ Replicas : ptr .To (int64 (3 )),
161+ Architecture : types .ArchitectureAMD64 ,
162+ },
163+ Compute : []types.MachinePool {
164+ {
165+ Name : "compute" ,
166+ Replicas : ptr .To (int64 (3 )),
167+ Architecture : types .ArchitectureAMD64 ,
168+ },
169+ },
170+ Platform : types.Platform {
171+ Nutanix : & nutanixtypes.Platform {
172+ PrismCentral : nutanixtypes.PrismCentral {
173+ Endpoint : nutanixtypes.PrismEndpoint {
174+ Address : "test-prism-central.test.com" ,
175+ Port : 9440 ,
176+ },
177+ Username : "test-username" ,
178+ Password : "test-password" ,
179+ },
180+ PrismElements : []nutanixtypes.PrismElement {{
181+ UUID : "test-uuid" ,
182+ Endpoint : nutanixtypes.PrismEndpoint {
183+ Address : "test-prism-element.test.com" ,
184+ Port : 9440 ,
185+ },
186+ Name : "test-element" ,
187+ }},
188+ SubnetUUIDs : []string {"test-subnet-uuid" },
189+ },
190+ },
191+ PullSecret : "test-pull-secret" ,
192+ }
193+ }
194+
195+ expectedYaml := `baseDomain: test-domain
196+ compute:
197+ - architecture: amd64
198+ name: compute
199+ platform: {}
200+ replicas: 3
201+ controlPlane:
202+ architecture: amd64
203+ name: control-plane
204+ platform: {}
205+ replicas: 3
206+ metadata:
207+ creationTimestamp: null
208+ name: test-nutanix-cluster
209+ networking:
210+ clusterNetwork:
211+ - cidr: 1.2.3.4/5
212+ hostPrefix: 6
213+ machineNetwork:
214+ - cidr: 1.2.3.4/5
215+ networkType: test-network-type
216+ serviceNetwork:
217+ - 1.2.3.4/5
218+ platform:
219+ nutanix:
220+ prismCentral:
221+ endpoint:
222+ address: test-prism-central.test.com
223+ port: 9440
224+ password: ""
225+ username: ""
226+ prismElements:
227+ - endpoint:
228+ address: test-prism-element.test.com
229+ port: 9440
230+ name: test-element
231+ uuid: test-uuid
232+ subnetUUIDs:
233+ - test-subnet-uuid
234+ pullSecret: ""
235+ sshKey: test-ssh-key
236+ `
237+
238+ expectedConfig := createInstallConfigWithNutanix ()
239+ ic := createInstallConfigWithNutanix ()
240+ actualYaml , err := redactedInstallConfig (* ic )
241+ if assert .NoError (t , err , "unexpected error" ) {
242+ assert .Equal (t , expectedYaml , string (actualYaml ), "unexpected yaml" )
243+ }
244+ assert .Equal (t , expectedConfig , ic , "install config was unexpectedly modified" )
245+ }
0 commit comments