kubeadm: fix the nil pointer dereference in testcase

`genCSRConfig.kubeadmConfig` is possible to be nil if there any error
from the config loading, so access the field should only be done if
there is no error in the previous step.

Signed-off-by: Dave Chen <dave.chen@arm.com>
This commit is contained in:
Dave Chen 2023-01-05 16:15:44 +08:00
parent 575616cc72
commit 23f75bf40e

View File

@ -464,11 +464,11 @@ kubernetesVersion: %s`,
err := config.load() err := config.load()
if test.expectErr { if test.expectErr {
assert.Error(t, err) assert.Error(t, err)
} else {
assert.NoError(t, err)
} }
for _, assertFunc := range test.assertions { if !test.expectErr && assert.NoError(t, err) {
assertFunc(t, config) for _, assertFunc := range test.assertions {
assertFunc(t, config)
}
} }
}) })
} }