oci-image-tools: make Config.User mapping errors a warning

Rather than throwing an error if we can't map a user to a uid,
output a warning. We aren't actually running the code, but are
just extracting it .. so the user not existing isn't an issue.

With this, we avoid the not-so-useful traces like this:

  config.User: unsupported format
  github.com/opencontainers/image-tools/image.(*config).runtimeSpec
        oci-image-tools/0.2.0-dev+gitAUTOINC+4abe1a166f-r0/oci-image-tools-0.2.0-dev+gitAUTOINC+4abe1a16 6f/src/import/vendor/src/github.com/opencontainers/image-tools/image/config.go:109
  <...>
  src/import/cmd/oci-image-tool/main.go:57
  runtime.main /usr/lib64/go/src/runtime/proc.go:185
  runtime.goexit /usr/lib64/go/src/runtime/asm_amd64.s:2337

Signed-off-by: Bruce Ashfield <bruce.ashfield@windriver.com>
This commit is contained in:
Bruce Ashfield 2017-11-17 00:01:06 -05:00
parent 5b6773e6cf
commit 68ab20d0c4
2 changed files with 32 additions and 1 deletions

View File

@ -0,0 +1,30 @@
From fbd62eff9ff2f447c2eb4634398110609fbf9d59 Mon Sep 17 00:00:00 2001
From: Bruce Ashfield <bruce.ashfield@windriver.com>
Date: Thu, 16 Nov 2017 23:40:17 -0500
Subject: [PATCH] config: make Config.User mapping errors a warning
Rather than throwing an error if we can't map a user to a uid,
output a warning. We aren't actually running the code, but are
just extracting it .. so the user not existing isn't an issue.
Signed-off-by: Bruce Ashfield <bruce.ashfield@windriver.com>
---
image/config.go | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/import/image/config.go b/src/import/image/config.go
index d28b1bc4fe5f..37dfd1f14ef7 100644
--- a/src/import/image/config.go
+++ b/src/import/image/config.go
@@ -106,7 +106,7 @@ func (c *config) runtimeSpec(rootfs string) (*specs.Spec, error) {
s.Process.User.UID = uint32(uid)
s.Process.User.GID = uint32(gid)
} else if c.Config.User != "" {
- return nil, errors.New("config.User: unsupported format")
+ fmt.Println("Warning: could not map UID for user:", c.Config.User)
}
s.Linux = &specs.Linux{}
--
2.4.0.53.g8440f74

View File

@ -14,7 +14,8 @@ DEPENDS = "\
SRC_URI = "git://github.com/opencontainers/image-tools.git \
file://0001-image-manifest-Recursively-remove-pre-existing-entri.patch \
file://0002-image-manifest-Split-unpackLayerEntry-into-its-own-f.patch"
file://0002-image-manifest-Split-unpackLayerEntry-into-its-own-f.patch \
file://0001-config-make-Config.User-mapping-errors-a-warning.patch"
SRCREV = "4abe1a166f9be97e8e71b1bb4d7599cc29323011"
PV = "0.2.0-dev+git${SRCPV}"