oci/caps: improve error message for unsupported capabilities
A capability can either be invalid, or not supported by the kernel on which we're running. This patch changes the error message produced to reflect if the capability is invalid/unknown, or a known capability, but not supported by the kernel version. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
parent
72b1fb59fe
commit
fc3f98848a
1 changed files with 5 additions and 2 deletions
|
@ -19,10 +19,11 @@ func init() {
|
|||
allCaps = make([]string, min(int(last+1), len(rawCaps)))
|
||||
capabilityList = make(Capabilities, min(int(last+1), len(rawCaps)))
|
||||
for i, c := range rawCaps {
|
||||
capName := "CAP_" + strings.ToUpper(c.String())
|
||||
if c > last {
|
||||
capabilityList[capName] = nil
|
||||
continue
|
||||
}
|
||||
capName := "CAP_" + strings.ToUpper(c.String())
|
||||
allCaps[i] = capName
|
||||
capabilityList[capName] = &CapabilityMapping{
|
||||
Key: capName,
|
||||
|
@ -89,8 +90,10 @@ func NormalizeLegacyCapabilities(caps []string) ([]string, error) {
|
|||
if !strings.HasPrefix(c, "CAP_") {
|
||||
c = "CAP_" + c
|
||||
}
|
||||
if _, ok := capabilityList[c]; !ok {
|
||||
if v, ok := capabilityList[c]; !ok {
|
||||
return nil, errdefs.InvalidParameter(fmt.Errorf("unknown capability: %q", c))
|
||||
} else if v == nil {
|
||||
return nil, errdefs.InvalidParameter(fmt.Errorf("capability not supported by your kernel: %q", c))
|
||||
}
|
||||
normalized = append(normalized, c)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue