зеркало из https://github.com/microsoft/docker.git
Golint: remove redundant ifs
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Родитель
63a0e88e8a
Коммит
b4a6313969
|
@ -485,10 +485,7 @@ func (s *fsCacheStore) delete(id string) error {
|
|||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := s.fs.Remove(src.BackendID); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
return s.fs.Remove(src.BackendID)
|
||||
}
|
||||
|
||||
type sourceMeta struct {
|
||||
|
|
|
@ -14,9 +14,8 @@ import (
|
|||
)
|
||||
|
||||
const (
|
||||
memdbContainersTable = "containers"
|
||||
memdbNamesTable = "names"
|
||||
|
||||
memdbContainersTable = "containers"
|
||||
memdbNamesTable = "names"
|
||||
memdbIDIndex = "id"
|
||||
memdbContainerIDIndex = "containerid"
|
||||
)
|
||||
|
@ -191,11 +190,7 @@ func (db *memDB) ReserveName(name, containerID string) error {
|
|||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
if err := txn.Insert(memdbNamesTable, nameAssociation{name: name, containerID: containerID}); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
return txn.Insert(memdbNamesTable, nameAssociation{name: name, containerID: containerID})
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
@ -262,11 +262,7 @@ func (c *containerAdapter) create(ctx context.Context) error {
|
|||
return err
|
||||
}
|
||||
|
||||
if err := c.backend.UpdateContainerServiceConfig(cr.ID, c.container.serviceConfig()); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
return c.backend.UpdateContainerServiceConfig(cr.ID, c.container.serviceConfig())
|
||||
}
|
||||
|
||||
// checkMounts ensures that the provided mounts won't have any host-specific
|
||||
|
|
|
@ -511,11 +511,7 @@ func Validate(config *Config) error {
|
|||
}
|
||||
|
||||
// validate platform-specific settings
|
||||
if err := config.ValidatePlatformConfig(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
return config.ValidatePlatformConfig()
|
||||
}
|
||||
|
||||
// ModifiedDiscoverySettings returns whether the discovery configuration has been modified or not.
|
||||
|
|
|
@ -1046,11 +1046,7 @@ func (daemon *Daemon) Shutdown() error {
|
|||
daemon.netController.Stop()
|
||||
}
|
||||
|
||||
if err := daemon.cleanupMounts(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
return daemon.cleanupMounts()
|
||||
}
|
||||
|
||||
// Mount sets container.BaseFS
|
||||
|
|
|
@ -1501,10 +1501,7 @@ func (daemon *Daemon) initCgroupsPath(path string) error {
|
|||
if err := maybeCreateCPURealTimeFile(sysinfo.CPURealtimePeriod, daemon.configStore.CPURealtimePeriod, "cpu.rt_period_us", path); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := maybeCreateCPURealTimeFile(sysinfo.CPURealtimeRuntime, daemon.configStore.CPURealtimeRuntime, "cpu.rt_runtime_us", path); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
return maybeCreateCPURealTimeFile(sysinfo.CPURealtimeRuntime, daemon.configStore.CPURealtimeRuntime, "cpu.rt_runtime_us", path)
|
||||
}
|
||||
|
||||
func maybeCreateCPURealTimeFile(sysinfoPresent bool, configValue int64, file string, path string) error {
|
||||
|
|
|
@ -579,10 +579,7 @@ func (a *Driver) unmount(mountPath string) error {
|
|||
if mounted, err := a.mounted(mountPath); err != nil || !mounted {
|
||||
return err
|
||||
}
|
||||
if err := Unmount(mountPath); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
return Unmount(mountPath)
|
||||
}
|
||||
|
||||
func (a *Driver) mounted(mountpoint string) (bool, error) {
|
||||
|
|
|
@ -14,8 +14,5 @@ func Unmount(target string) error {
|
|||
if err := exec.Command("auplink", target, "flush").Run(); err != nil {
|
||||
logrus.Warnf("Couldn't run auplink before unmount %s: %s", target, err)
|
||||
}
|
||||
if err := unix.Unmount(target, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
return unix.Unmount(target, 0)
|
||||
}
|
||||
|
|
|
@ -598,16 +598,10 @@ func (d *Driver) setStorageSize(dir string, driver *Driver) error {
|
|||
if d.options.minSpace > 0 && driver.options.size < d.options.minSpace {
|
||||
return fmt.Errorf("btrfs: storage size cannot be less than %s", units.HumanSize(float64(d.options.minSpace)))
|
||||
}
|
||||
|
||||
if err := d.subvolEnableQuota(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := subvolLimitQgroup(dir, driver.options.size); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
return subvolLimitQgroup(dir, driver.options.size)
|
||||
}
|
||||
|
||||
// Remove the filesystem with given id.
|
||||
|
@ -634,10 +628,7 @@ func (d *Driver) Remove(id string) error {
|
|||
if err := system.EnsureRemoveAll(dir); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := d.subvolRescanQuota(); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
return d.subvolRescanQuota()
|
||||
}
|
||||
|
||||
// Get the requested filesystem id.
|
||||
|
|
|
@ -273,8 +273,5 @@ func doCopyXattrs(srcPath, dstPath string) error {
|
|||
// this function is used to copy those. It is set by overlay if a directory
|
||||
// is removed and then re-created and should not inherit anything from the
|
||||
// same dir in the lower dir.
|
||||
if err := copyXattr(srcPath, dstPath, "trusted.overlay.opaque"); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
return copyXattr(srcPath, dstPath, "trusted.overlay.opaque")
|
||||
}
|
||||
|
|
|
@ -129,15 +129,10 @@ func verifyBlockDevice(dev string, force bool) error {
|
|||
if err := checkDevInVG(dev); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if force {
|
||||
return nil
|
||||
}
|
||||
|
||||
if err := checkDevHasFS(dev); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
return checkDevHasFS(dev)
|
||||
}
|
||||
|
||||
func readLVMConfig(root string) (directLVMConfig, error) {
|
||||
|
|
|
@ -355,10 +355,7 @@ func (devices *DeviceSet) saveMetadata(info *devInfo) error {
|
|||
if err != nil {
|
||||
return fmt.Errorf("devmapper: Error encoding metadata to json: %s", err)
|
||||
}
|
||||
if err := devices.writeMetaFile(jsonData, devices.metadataFile(info)); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
return devices.writeMetaFile(jsonData, devices.metadataFile(info))
|
||||
}
|
||||
|
||||
func (devices *DeviceSet) markDeviceIDUsed(deviceID int) {
|
||||
|
@ -889,11 +886,7 @@ func (devices *DeviceSet) takeSnapshot(hash string, baseInfo *devInfo, size uint
|
|||
defer devicemapper.ResumeDevice(baseInfo.Name())
|
||||
}
|
||||
|
||||
if err = devices.createRegisterSnapDevice(hash, baseInfo, size); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
return devices.createRegisterSnapDevice(hash, baseInfo, size)
|
||||
}
|
||||
|
||||
func (devices *DeviceSet) createRegisterSnapDevice(hash string, baseInfo *devInfo, size uint64) error {
|
||||
|
@ -1233,12 +1226,7 @@ func (devices *DeviceSet) setupBaseImage() error {
|
|||
if err := devices.setupVerifyBaseImageUUIDFS(oldInfo); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := devices.checkGrowBaseDeviceFS(oldInfo); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
return devices.checkGrowBaseDeviceFS(oldInfo)
|
||||
}
|
||||
|
||||
logrus.Debug("devmapper: Removing uninitialized base image")
|
||||
|
@ -1259,11 +1247,7 @@ func (devices *DeviceSet) setupBaseImage() error {
|
|||
}
|
||||
|
||||
// Create new base image device
|
||||
if err := devices.createBaseImage(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
return devices.createBaseImage()
|
||||
}
|
||||
|
||||
func setCloseOnExec(name string) {
|
||||
|
@ -2082,11 +2066,7 @@ func (devices *DeviceSet) deleteDevice(info *devInfo, syncDelete bool) error {
|
|||
return err
|
||||
}
|
||||
|
||||
if err := devices.deleteTransaction(info, syncDelete); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
return devices.deleteTransaction(info, syncDelete)
|
||||
}
|
||||
|
||||
// DeleteDevice will return success if device has been marked for deferred
|
||||
|
|
|
@ -146,12 +146,7 @@ func (d *Driver) Create(id, parent string, opts *graphdriver.CreateOpts) error {
|
|||
if opts != nil {
|
||||
storageOpt = opts.StorageOpt
|
||||
}
|
||||
|
||||
if err := d.DeviceSet.AddDevice(id, parent, storageOpt); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
return d.DeviceSet.AddDevice(id, parent, storageOpt)
|
||||
}
|
||||
|
||||
// Remove removes a device with a given id, unmounts the filesystem.
|
||||
|
|
|
@ -263,11 +263,7 @@ func addLayerFiles(drv graphdriver.Driver, layer, parent string, i int) error {
|
|||
if err := driver.WriteFile(root, root.Join(layerDir, "layer-id"), []byte(layer), 0755); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := driver.WriteFile(root, root.Join(layerDir, "parent-id"), []byte(parent), 0755); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
return driver.WriteFile(root, root.Join(layerDir, "parent-id"), []byte(parent), 0755)
|
||||
}
|
||||
|
||||
func addManyLayers(drv graphdriver.Driver, baseLayer string, count int) (string, error) {
|
||||
|
|
|
@ -309,10 +309,7 @@ func (d *Driver) Create(id, parent string, opts *graphdriver.CreateOpts) (retErr
|
|||
if err := idtools.MkdirAndChown(path.Join(dir, "work"), 0700, root); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := ioutil.WriteFile(path.Join(dir, "lower-id"), []byte(parent), 0666); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
return ioutil.WriteFile(path.Join(dir, "lower-id"), []byte(parent), 0666)
|
||||
}
|
||||
|
||||
// Otherwise, copy the upper and the lower-id from the parent
|
||||
|
|
|
@ -14,12 +14,7 @@ func (daemon *Daemon) ContainerPause(name string) error {
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := daemon.containerPause(container); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
return daemon.containerPause(container)
|
||||
}
|
||||
|
||||
// containerPause pauses the container execution without stopping the process.
|
||||
|
|
|
@ -90,11 +90,7 @@ func (daemon *Daemon) ContainerStart(name string, hostConfig *containertypes.Hos
|
|||
return validationError{err}
|
||||
}
|
||||
}
|
||||
|
||||
if err := daemon.containerStart(container, checkpoint, checkpointDir, true); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
return daemon.containerStart(container, checkpoint, checkpointDir, true)
|
||||
}
|
||||
|
||||
// containerStart prepares the container to run by setting up everything the
|
||||
|
|
|
@ -14,12 +14,7 @@ func (daemon *Daemon) ContainerUnpause(name string) error {
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := daemon.containerUnpause(container); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
return daemon.containerUnpause(container)
|
||||
}
|
||||
|
||||
// containerUnpause resumes the container execution after the container is paused.
|
||||
|
|
|
@ -133,10 +133,7 @@ func (s *fs) Delete(dgst digest.Digest) error {
|
|||
if err := os.RemoveAll(s.metadataDir(dgst)); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := os.Remove(s.contentFile(dgst)); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
return os.Remove(s.contentFile(dgst))
|
||||
}
|
||||
|
||||
// SetMetadata sets metadata for a given ID. It fails if there's no base file.
|
||||
|
|
|
@ -348,11 +348,7 @@ func (d *Daemon) Kill() error {
|
|||
return err
|
||||
}
|
||||
|
||||
if err := os.Remove(fmt.Sprintf("%s/docker.pid", d.Folder)); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
return os.Remove(fmt.Sprintf("%s/docker.pid", d.Folder))
|
||||
}
|
||||
|
||||
// Pid returns the pid of the daemon
|
||||
|
@ -459,11 +455,7 @@ out2:
|
|||
|
||||
d.cmd.Wait()
|
||||
|
||||
if err := os.Remove(fmt.Sprintf("%s/docker.pid", d.Folder)); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
return os.Remove(fmt.Sprintf("%s/docker.pid", d.Folder))
|
||||
}
|
||||
|
||||
// Restart will restart the daemon by first stopping it and the starting it.
|
||||
|
|
|
@ -328,9 +328,8 @@ func createNetwork(c *check.C, config types.NetworkCreateRequest, expectedStatus
|
|||
c.Assert(err, checker.IsNil)
|
||||
|
||||
return nr.ID
|
||||
} else {
|
||||
return ""
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func connectNetwork(c *check.C, nid, cid string) {
|
||||
|
|
|
@ -153,10 +153,7 @@ func (tf *testFile) ApplyFile(root containerfs.ContainerFS) error {
|
|||
return err
|
||||
}
|
||||
}
|
||||
if err := driver.WriteFile(root, fullPath, tf.content, tf.permission); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
return driver.WriteFile(root, fullPath, tf.content, tf.permission)
|
||||
}
|
||||
|
||||
func initWithFiles(files ...FileApplier) layerInit {
|
||||
|
|
|
@ -68,11 +68,7 @@ func (ls *layerStore) CreateRWLayerByGraphID(name string, graphID string, parent
|
|||
m.initID = initID
|
||||
}
|
||||
|
||||
if err = ls.saveMount(m); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
return ls.saveMount(m)
|
||||
}
|
||||
|
||||
func (ls *layerStore) ChecksumForGraphID(id, parent, oldTarDataPath, newTarDataPath string) (diffID DiffID, size int64, err error) {
|
||||
|
|
|
@ -143,11 +143,7 @@ func storeLayer(tx MetadataTransaction, layer *roLayer) error {
|
|||
return err
|
||||
}
|
||||
}
|
||||
if err := tx.SetOS(layer.os); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
return tx.SetOS(layer.os)
|
||||
}
|
||||
|
||||
func newVerifiedReadCloser(rc io.ReadCloser, dgst digest.Digest) (io.ReadCloser, error) {
|
||||
|
|
|
@ -89,11 +89,7 @@ func Migrate(root, driverName string, ls layer.Store, is image.Store, rs refstor
|
|||
return err
|
||||
}
|
||||
|
||||
if err := migrateRefs(root, driverName, rs, mappings); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
return migrateRefs(root, driverName, rs, mappings)
|
||||
}
|
||||
|
||||
// CalculateLayerChecksums walks an old graph directory and calculates checksums
|
||||
|
|
|
@ -323,10 +323,7 @@ func addContainer(dest, jsonConfig string) error {
|
|||
if err := os.MkdirAll(contDir, 0700); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := ioutil.WriteFile(filepath.Join(contDir, "config.json"), []byte(jsonConfig), 0600); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
return ioutil.WriteFile(filepath.Join(contDir, "config.json"), []byte(jsonConfig), 0600)
|
||||
}
|
||||
|
||||
type mockTagAdder struct {
|
||||
|
|
|
@ -27,9 +27,5 @@ func Chtimes(name string, atime time.Time, mtime time.Time) error {
|
|||
}
|
||||
|
||||
// Take platform specific action for setting create time.
|
||||
if err := setCTime(name, mtime); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
return setCTime(name, mtime)
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче