Skip to content

Commit

Permalink
Rename variable for consistency
Browse files Browse the repository at this point in the history
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
  • Loading branch information
thaJeztah committed Sep 3, 2019
1 parent 6e5a304 commit e128f17
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions daemon/container_operations_unix.go
Expand Up @@ -227,21 +227,21 @@ func (daemon *Daemon) setupSecretDir(c *container.Container) (setupErr error) {
}
}

for _, ref := range c.ConfigReferences {
for _, configRef := range c.ConfigReferences {
// TODO (ehazlett): use type switch when more are supported
if ref.File == nil {
if configRef.File == nil {
// Runtime configs are not mounted into the container, but they're
// a valid type of config so we should not error when we encounter
// one.
if ref.Runtime == nil {
if configRef.Runtime == nil {
logrus.Error("config target type is not a file or runtime target")
}
// However, in any case, this isn't a file config, so we have no
// further work to do
continue
}

fPath, err := c.ConfigFilePath(*ref)
fPath, err := c.ConfigFilePath(*configRef)
if err != nil {
return errors.Wrap(err, "error getting config file path for container")
}
Expand All @@ -250,30 +250,30 @@ func (daemon *Daemon) setupSecretDir(c *container.Container) (setupErr error) {
}

logrus.WithFields(logrus.Fields{
"name": ref.File.Name,
"name": configRef.File.Name,
"path": fPath,
}).Debug("injecting config")
config, err := c.DependencyStore.Configs().Get(ref.ConfigID)
config, err := c.DependencyStore.Configs().Get(configRef.ConfigID)
if err != nil {
return errors.Wrap(err, "unable to get config from config store")
}
if err := ioutil.WriteFile(fPath, config.Spec.Data, ref.File.Mode); err != nil {
if err := ioutil.WriteFile(fPath, config.Spec.Data, configRef.File.Mode); err != nil {
return errors.Wrap(err, "error injecting config")
}

uid, err := strconv.Atoi(ref.File.UID)
uid, err := strconv.Atoi(configRef.File.UID)
if err != nil {
return err
}
gid, err := strconv.Atoi(ref.File.GID)
gid, err := strconv.Atoi(configRef.File.GID)
if err != nil {
return err
}

if err := os.Chown(fPath, rootIDs.UID+uid, rootIDs.GID+gid); err != nil {
return errors.Wrap(err, "error setting ownership for config")
}
if err := os.Chmod(fPath, ref.File.Mode); err != nil {
if err := os.Chmod(fPath, configRef.File.Mode); err != nil {
return errors.Wrap(err, "error setting file mode for config")
}
}
Expand Down

0 comments on commit e128f17

Please sign in to comment.