daemon: drop unnecessary long-lived var
Favour smaller scoped `path` vars since we don't actually need one
scoped for the full function. This would have caught the previous
regression.
@@ -271,7 +271,6 @@ func (dn *Daemon) updateFiles(oldConfig, newConfig *mcfgv1.MachineConfig) error
// this function doesn't cause the agent to stop on failures and logs any errors
// it encounters.
func (dn *Daemon) deleteStaleData(oldConfig, newConfig *mcfgv1.MachineConfig) {
- var path string
glog.Info("Deleting stale data")
newFileSet := make(map[string]struct{})
for _, f := range newConfig.Spec.Config.Storage.Files {
@@ -290,21 +289,21 @@ func (dn *Daemon) deleteStaleData(oldConfig, newConfig *mcfgv1.MachineConfig) {
newDropinSet := make(map[string]struct{})
for _, u := range newConfig.Spec.Config.Systemd.Units {
for j := range u.Dropins {
- path = filepath.Join(pathSystemd, u.Name+".d", u.Dropins[j].Name)
+ path := filepath.Join(pathSystemd, u.Name+".d", u.Dropins[j].Name)
newDropinSet[path] = struct{}{}
}
- path = filepath.Join(pathSystemd, u.Name)
+ path := filepath.Join(pathSystemd, u.Name)
newUnitSet[path] = struct{}{}
}
for _, u := range oldConfig.Spec.Config.Systemd.Units {
for j := range u.Dropins {
- path = filepath.Join(pathSystemd, u.Name+".d", u.Dropins[j].Name)
+ path := filepath.Join(pathSystemd, u.Name+".d", u.Dropins[j].Name)
if _, ok := newDropinSet[path]; !ok {
dn.fileSystemClient.RemoveAll(path)
}
}
- path = filepath.Join(pathSystemd, u.Name)
+ path := filepath.Join(pathSystemd, u.Name)
if _, ok := newUnitSet[path]; !ok {
if err := dn.disableUnit(u); err != nil {
glog.Warningf("Unable to disable %s: %s", u.Name, err)
