fix lint errors

Signed-off-by: carlory <baofa.fan@daocloud.io>
This commit is contained in:
carlory 2025-01-18 22:10:05 +08:00
parent 8b4eae24ab
commit aecf3238bf
2 changed files with 14 additions and 14 deletions

View File

@ -250,12 +250,12 @@ func (s *fsGroupChangePolicyTestSuite) DefineTests(driver storageframework.TestD
// Change the ownership of files in the initial pod.
if test.changedRootDirFileOwnership != 0 {
ginkgo.By(fmt.Sprintf("Changing the root directory file ownership to %s", strconv.Itoa(test.changedRootDirFileOwnership)))
storageutils.ChangeFilePathGidInPod(ctx, f, rootDirFilePath, strconv.Itoa(test.changedRootDirFileOwnership), pod)
storageutils.ChangeFilePathGIDInPod(ctx, f, rootDirFilePath, strconv.Itoa(test.changedRootDirFileOwnership), pod)
}
if test.changedSubDirFileOwnership != 0 {
ginkgo.By(fmt.Sprintf("Changing the sub-directory file ownership to %s", strconv.Itoa(test.changedSubDirFileOwnership)))
storageutils.ChangeFilePathGidInPod(ctx, f, subDirFilePath, strconv.Itoa(test.changedSubDirFileOwnership), pod)
storageutils.ChangeFilePathGIDInPod(ctx, f, subDirFilePath, strconv.Itoa(test.changedSubDirFileOwnership), pod)
}
ginkgo.By(fmt.Sprintf("Deleting Pod %s/%s", pod.Namespace, pod.Name))
@ -283,7 +283,7 @@ func createPodAndVerifyContentGid(ctx context.Context, f *framework.Framework, p
var err error
_, _, err = e2epod.ExecShellInPodWithFullOutput(ctx, f, pod.Name, cmd)
framework.ExpectNoError(err)
storageutils.VerifyFilePathGidInPod(ctx, f, rootDirFilePath, podFsGroup, pod)
storageutils.VerifyFilePathGIDInPod(ctx, f, rootDirFilePath, podFsGroup, pod)
cmd = fmt.Sprintf("mkdir %s", subdir)
_, _, err = e2epod.ExecShellInPodWithFullOutput(ctx, f, pod.Name, cmd)
@ -291,14 +291,14 @@ func createPodAndVerifyContentGid(ctx context.Context, f *framework.Framework, p
cmd = fmt.Sprintf("touch %s", subDirFilePath)
_, _, err = e2epod.ExecShellInPodWithFullOutput(ctx, f, pod.Name, cmd)
framework.ExpectNoError(err)
storageutils.VerifyFilePathGidInPod(ctx, f, subDirFilePath, podFsGroup, pod)
storageutils.VerifyFilePathGIDInPod(ctx, f, subDirFilePath, podFsGroup, pod)
return pod
}
// Verify existing contents of the volume
ginkgo.By(fmt.Sprintf("Verifying the ownership of root directory file is %s", expectedRootDirFileOwnership))
storageutils.VerifyFilePathGidInPod(ctx, f, rootDirFilePath, expectedRootDirFileOwnership, pod)
storageutils.VerifyFilePathGIDInPod(ctx, f, rootDirFilePath, expectedRootDirFileOwnership, pod)
ginkgo.By(fmt.Sprintf("Verifying the ownership of sub directory file is %s", expectedSubDirFileOwnership))
storageutils.VerifyFilePathGidInPod(ctx, f, subDirFilePath, expectedSubDirFileOwnership, pod)
storageutils.VerifyFilePathGIDInPod(ctx, f, subDirFilePath, expectedSubDirFileOwnership, pod)
return pod
}

View File

@ -722,23 +722,23 @@ func WaitForGVRFinalizer(ctx context.Context, c dynamic.Interface, gvr schema.Gr
return err
}
// VerifyFilePathGidInPod verfies expected GID of the target filepath
func VerifyFilePathGidInPod(ctx context.Context, f *framework.Framework, filePath, expectedGid string, pod *v1.Pod) {
// VerifyFilePathGIDInPod verfies expected GID of the target filepath
func VerifyFilePathGIDInPod(ctx context.Context, f *framework.Framework, filePath, expectedGID string, pod *v1.Pod) {
cmd := fmt.Sprintf("ls -l %s", filePath)
stdout, stderr, err := e2epod.ExecShellInPodWithFullOutput(ctx, f, pod.Name, cmd)
framework.ExpectNoError(err)
framework.Logf("pod %s/%s exec for cmd %s, stdout: %s, stderr: %s", pod.Namespace, pod.Name, cmd, stdout, stderr)
ll := strings.Fields(stdout)
framework.Logf("stdout split: %v, expected gid: %v", ll, expectedGid)
gomega.Expect(ll[3]).To(gomega.Equal(expectedGid))
framework.Logf("stdout split: %v, expected gid: %v", ll, expectedGID)
gomega.Expect(ll[3]).To(gomega.Equal(expectedGID))
}
// ChangeFilePathGidInPod changes the GID of the target filepath.
func ChangeFilePathGidInPod(ctx context.Context, f *framework.Framework, filePath, targetGid string, pod *v1.Pod) {
cmd := fmt.Sprintf("chgrp %s %s", targetGid, filePath)
// ChangeFilePathGIDInPod changes the GID of the target filepath.
func ChangeFilePathGIDInPod(ctx context.Context, f *framework.Framework, filePath, targetGID string, pod *v1.Pod) {
cmd := fmt.Sprintf("chgrp %s %s", targetGID, filePath)
_, _, err := e2epod.ExecShellInPodWithFullOutput(ctx, f, pod.Name, cmd)
framework.ExpectNoError(err)
VerifyFilePathGidInPod(ctx, f, filePath, targetGid, pod)
VerifyFilePathGIDInPod(ctx, f, filePath, targetGID, pod)
}
// DeleteStorageClass deletes the passed in StorageClass and catches errors other than "Not Found"