mirror of
https://github.com/k3s-io/kubernetes.git
synced 2026-07-18 04:54:54 +00:00
fix lint error
This commit is contained in:
@@ -154,11 +154,9 @@ func CreateStaticPodFiles(manifestDir, patchesDir string, cfg *kubeadmapi.Cluste
|
||||
if features.Enabled(cfg.FeatureGates, features.RootlessControlPlane) {
|
||||
if isDryRun {
|
||||
fmt.Printf("[control-plane] Would update static pod manifest for %q to run run as non-root\n", componentName)
|
||||
} else {
|
||||
if usersAndGroups != nil {
|
||||
if err := staticpodutil.RunComponentAsNonRoot(componentName, &spec, usersAndGroups, cfg); err != nil {
|
||||
return errors.Wrapf(err, "failed to run component %q as non-root", componentName)
|
||||
}
|
||||
} else if usersAndGroups != nil {
|
||||
if err := staticpodutil.RunComponentAsNonRoot(componentName, &spec, usersAndGroups, cfg); err != nil {
|
||||
return errors.Wrapf(err, "failed to run component %q as non-root", componentName)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@ See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
// Package staticpod contains utilities for managing the static pod.
|
||||
package staticpod
|
||||
|
||||
import (
|
||||
|
||||
@@ -17,6 +17,7 @@ See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
// Package staticpod contains utilities for managing the static pod.
|
||||
package staticpod
|
||||
|
||||
import (
|
||||
|
||||
@@ -17,6 +17,7 @@ See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
// Package users contains utilities for managing the users.
|
||||
package users
|
||||
|
||||
import (
|
||||
@@ -238,12 +239,17 @@ func addUsersAndGroupsImpl(pathLoginDef, pathUsers, pathGroups string) (*UsersAn
|
||||
}
|
||||
|
||||
// Prepare the maps of users and groups.
|
||||
usersConcat := append(users, usersToCreate...)
|
||||
var usersConcat []*entry
|
||||
usersConcat = append(usersConcat, users...)
|
||||
usersConcat = append(usersConcat, usersToCreate...)
|
||||
mapUsers, err := entriesToEntryMap(usersConcat, usersToCreateSpec)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
groupsConcat := append(groups, groupsToCreate...)
|
||||
|
||||
var groupsConcat []*entry
|
||||
groupsConcat = append(groupsConcat, groups...)
|
||||
groupsConcat = append(groupsConcat, groupsToCreate...)
|
||||
mapGroups, err := entriesToEntryMap(groupsConcat, groupsToCreateSpec)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -593,15 +599,15 @@ func openFileWithLock(path string) (f *os.File, close func(), err error) {
|
||||
}
|
||||
}
|
||||
if err != nil {
|
||||
f.Close()
|
||||
_ = f.Close()
|
||||
return nil, nil, err
|
||||
}
|
||||
close = func() {
|
||||
// This function should be called once operations with the file are finished.
|
||||
// It unlocks the file and closes it.
|
||||
unlock := syscall.Flock_t{Type: syscall.F_UNLCK}
|
||||
syscall.FcntlFlock(f.Fd(), syscall.F_SETLK, &unlock)
|
||||
f.Close()
|
||||
_ = syscall.FcntlFlock(f.Fd(), syscall.F_SETLK, &unlock)
|
||||
_ = f.Close()
|
||||
}
|
||||
return f, close, nil
|
||||
}
|
||||
|
||||
@@ -579,7 +579,7 @@ func writeTempFile(t *testing.T, contents string) (string, func()) {
|
||||
t.Fatalf("could not write file: %v", err)
|
||||
}
|
||||
close := func() {
|
||||
os.Remove(file.Name())
|
||||
_ = os.Remove(file.Name())
|
||||
}
|
||||
return file.Name(), close
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@ See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
// Package users contains utilities for managing the users.
|
||||
package users
|
||||
|
||||
// EntryMap is empty on non-Linux.
|
||||
|
||||
Reference in New Issue
Block a user