@@ -168,7 +168,7 @@ func EnsureSSHKeyPresentInTheCluster(ctx context.Context, ocConfig oc.Config, ss
168168 }
169169 stdout , stderr , err := ocConfig .RunOcCommand ("get" , "machineconfigs" , "99-master-ssh" , "-o" , `jsonpath='{.spec.config.passwd.users[0].sshAuthorizedKeys[0]}'` )
170170 if err != nil {
171- return fmt .Errorf ("Failed to get machine configs %v : %s " , err , stderr )
171+ return fmt .Errorf ("failed to get machine configs: %s : %w " , stderr , err )
172172 }
173173 if stdout == string (sshPublicKey ) {
174174 return nil
@@ -179,7 +179,7 @@ func EnsureSSHKeyPresentInTheCluster(ctx context.Context, ocConfig oc.Config, ss
179179 "--type" , "merge" }
180180 _ , stderr , err = ocConfig .RunOcCommand (cmdArgs ... )
181181 if err != nil {
182- return fmt .Errorf ("Failed to update ssh key %v : %s " , err , stderr )
182+ return fmt .Errorf ("failed to update ssh key: %s : %w " , stderr , err )
183183 }
184184 return nil
185185}
@@ -191,7 +191,7 @@ func EnsurePullSecretPresentInTheCluster(ctx context.Context, ocConfig oc.Config
191191
192192 stdout , stderr , err := ocConfig .RunOcCommandPrivate ("get" , "secret" , "pull-secret" , "-n" , "openshift-config" , "-o" , `jsonpath="{['data']['\.dockerconfigjson']}"` )
193193 if err != nil {
194- return fmt .Errorf ("Failed to get pull secret %v : %s " , err , stderr )
194+ return fmt .Errorf ("failed to get pull secret: %s : %w " , stderr , err )
195195 }
196196 decoded , err := base64 .StdEncoding .DecodeString (stdout )
197197 if err != nil {
@@ -213,7 +213,7 @@ func EnsurePullSecretPresentInTheCluster(ctx context.Context, ocConfig oc.Config
213213
214214 _ , stderr , err = ocConfig .RunOcCommandPrivate (cmdArgs ... )
215215 if err != nil {
216- return fmt .Errorf ("Failed to add Pull secret %v : %s " , err , stderr )
216+ return fmt .Errorf ("failed to add pull secret: %s : %w " , stderr , err )
217217 }
218218 return nil
219219}
@@ -225,7 +225,7 @@ func EnsureGeneratedClientCAPresentInTheCluster(ctx context.Context, ocConfig oc
225225 }
226226 clusterClientCA , stderr , err := ocConfig .RunOcCommand ("get" , "configmaps" , "admin-kubeconfig-client-ca" , "-n" , "openshift-config" , "-o" , `jsonpath="{.data.ca-bundle\.crt}"` )
227227 if err != nil {
228- return fmt .Errorf ("Failed to get config map %v : %s " , err , stderr )
228+ return fmt .Errorf ("failed to get config map: %s : %w " , stderr , err )
229229 }
230230
231231 ok , err := crctls .VerifyCertificateAgainstRootCA (clusterClientCA , adminCert )
@@ -242,10 +242,10 @@ func EnsureGeneratedClientCAPresentInTheCluster(ctx context.Context, ocConfig oc
242242 "-n" , "openshift-config" , "--patch" , jsonPath }
243243 _ , stderr , err = ocConfig .RunOcCommand (cmdArgs ... )
244244 if err != nil {
245- return fmt .Errorf ("Failed to patch admin-kubeconfig-client-ca config map with new CA` %v : %s " , err , stderr )
245+ return fmt .Errorf ("failed to patch admin-kubeconfig-client-ca config map with new CA: %s : %w " , stderr , err )
246246 }
247247 if err := sshRunner .CopyFile (constants .KubeconfigFilePath , ocConfig .KubeconfigPath , 0644 ); err != nil {
248- return fmt .Errorf ("Failed to copy generated kubeconfig file to VM: %v " , err )
248+ return fmt .Errorf ("failed to copy generated kubeconfig file to VM: %w " , err )
249249 }
250250
251251 return nil
@@ -259,7 +259,7 @@ func RemovePullSecretFromCluster(ctx context.Context, ocConfig oc.Config, sshRun
259259
260260 _ , stderr , err := ocConfig .RunOcCommand (cmdArgs ... )
261261 if err != nil {
262- return fmt .Errorf ("Failed to remove Pull secret %w : %s " , err , stderr )
262+ return fmt .Errorf ("failed to remove pull secret: %s : %w " , stderr , err )
263263 }
264264 return waitForPullSecretRemovedFromInstanceDisk (ctx , sshRunner )
265265}
@@ -269,7 +269,7 @@ func waitForPullSecretRemovedFromInstanceDisk(ctx context.Context, sshRunner *ss
269269 pullSecretPresentFunc := func () error {
270270 stdout , stderr , err := sshRunner .RunPrivate (fmt .Sprintf ("sudo cat %s" , vmPullSecretPath ))
271271 if err != nil {
272- return & errors.RetriableError {Err : fmt .Errorf ("failed to read %s file: %v : %s " , vmPullSecretPath , err , stderr )}
272+ return & errors.RetriableError {Err : fmt .Errorf ("failed to read %s file: %s : %w " , vmPullSecretPath , stderr , err )}
273273 }
274274 if err := validation .ImagePullSecret (stdout ); err == nil {
275275 return & errors.RetriableError {Err : fmt .Errorf ("pull secret is still present on the instance disk" )}
@@ -286,7 +286,7 @@ func RemoveOldRenderedMachineConfig(ocConfig oc.Config) error {
286286 // For 4.8 we don't disable mco and it does contain the machineconfigs.
287287 stdout , stderr , err := ocConfig .RunOcCommand ("get mc --sort-by=.metadata.creationTimestamp --no-headers -oname" )
288288 if err != nil {
289- return fmt .Errorf ("failed to get machineconfig resource %w : %s " , err , stderr )
289+ return fmt .Errorf ("failed to get machineconfig resource: %s : %w " , stderr , err )
290290 }
291291 sortedMachineConfigsWithTime := strings .Split (stdout , "\n " )
292292 if len (sortedMachineConfigsWithTime ) == 0 {
@@ -318,7 +318,7 @@ func RemoveOldRenderedMachineConfig(ocConfig oc.Config) error {
318318 if deleteRenderedMachineConfig != "" {
319319 _ , stderr , err = ocConfig .RunOcCommand (fmt .Sprintf ("delete %s" , deleteRenderedMachineConfig ))
320320 if err != nil {
321- return fmt .Errorf ("Failed to remove machineconfigpools %w : %s " , err , stderr )
321+ return fmt .Errorf ("failed to remove machineconfigpools: %s : %w " , stderr , err )
322322 }
323323 }
324324 return nil
@@ -331,7 +331,7 @@ func EnsureClusterIDIsNotEmpty(ctx context.Context, ocConfig oc.Config) error {
331331
332332 stdout , stderr , err := ocConfig .RunOcCommand ("get" , "clusterversion" , "version" , "-o" , `jsonpath="{['spec']['clusterID']}"` )
333333 if err != nil {
334- return fmt .Errorf ("Failed to get clusterversion %v : %s " , err , stderr )
334+ return fmt .Errorf ("failed to get clusterversion: %s : %w " , stderr , err )
335335 }
336336 if strings .TrimSpace (stdout ) != "" {
337337 return nil
@@ -344,7 +344,7 @@ func EnsureClusterIDIsNotEmpty(ctx context.Context, ocConfig oc.Config) error {
344344
345345 _ , stderr , err = ocConfig .RunOcCommand (cmdArgs ... )
346346 if err != nil {
347- return fmt .Errorf ("Failed to update cluster ID %v : %s " , err , stderr )
347+ return fmt .Errorf ("failed to update cluster ID: %s : %w " , stderr , err )
348348 }
349349
350350 return nil
@@ -389,13 +389,13 @@ func AddProxyConfigToCluster(ctx context.Context, sshRunner *ssh.Runner, ocConfi
389389
390390 patchEncode , err := json .Marshal (patch )
391391 if err != nil {
392- return fmt .Errorf ("Failed to encode to json: %v " , err )
392+ return fmt .Errorf ("failed to encode to json: %w " , err )
393393 }
394394 logging .Debugf ("Patch string %s" , string (patchEncode ))
395395
396396 cmdArgs := []string {"patch" , "proxy" , "cluster" , "-p" , fmt .Sprintf ("'%s'" , string (patchEncode )), "--type" , "merge" }
397397 if _ , stderr , err := ocConfig .RunOcCommandPrivate (cmdArgs ... ); err != nil {
398- return fmt .Errorf ("Failed to add proxy details %v : %s " , err , stderr )
398+ return fmt .Errorf ("failed to add proxy details: %s : %w " , stderr , err )
399399 }
400400 return nil
401401}
@@ -423,7 +423,7 @@ func addProxyCACertToCluster(sshRunner *ssh.Runner, ocConfig oc.Config, proxy *h
423423 }
424424 cmdArgs := []string {"apply" , "-f" , proxyConfigMapFileName }
425425 if _ , stderr , err := ocConfig .RunOcCommandPrivate (cmdArgs ... ); err != nil {
426- return fmt .Errorf ("Failed to add proxy cert details %v : %s " , err , stderr )
426+ return fmt .Errorf ("failed to add proxy cert details: %s : %w " , stderr , err )
427427 }
428428 return nil
429429}
@@ -452,7 +452,7 @@ func WaitForPullSecretPresentOnInstanceDisk(ctx context.Context, sshRunner *ssh.
452452 }
453453 stdout , stderr , err := sshRunner .RunPrivate (fmt .Sprintf ("sudo cat %s" , vmPullSecretPath ))
454454 if err != nil {
455- return fmt .Errorf ("failed to read %s file: %v : %s " , vmPullSecretPath , err , stderr )
455+ return fmt .Errorf ("failed to read %s file: %s : %w " , vmPullSecretPath , stderr , err )
456456 }
457457 if err := validation .ImagePullSecret (stdout ); err != nil {
458458 return & errors.RetriableError {Err : fmt .Errorf ("pull secret not updated to disk" )}
0 commit comments