github.com/apptainer/singularity@v3.1.1+incompatible/internal/app/singularity/capability_avail_linux.go (about) 1 // Copyright (c) 2019, Sylabs Inc. All rights reserved. 2 // This software is licensed under a 3-clause BSD license. Please consult the 3 // LICENSE.md file distributed with the sources of this project regarding your 4 // rights to use or distribute this software. 5 6 package singularity 7 8 import ( 9 "fmt" 10 "strings" 11 12 "github.com/sylabs/singularity/pkg/util/capabilities" 13 ) 14 15 // CapAvailConfig instructs CapabilityAvail on what capability to list/describe 16 type CapAvailConfig struct { 17 Caps string 18 Desc bool 19 } 20 21 // CapabilityAvail lists the capabilities based on the CapAvailConfig 22 func CapabilityAvail(c CapAvailConfig) error { 23 caps, ign := capabilities.Split(c.Caps) 24 if len(ign) > 0 { 25 return fmt.Errorf("unknown capabilities found in: %s", strings.Join(ign, ",")) 26 } 27 28 if len(caps) > 0 { 29 for _, cap := range caps { 30 fmt.Printf("%-22s %s\n\n", cap+":", capabilities.Map[cap].Description) 31 } 32 return nil 33 } 34 35 for k := range capabilities.Map { 36 fmt.Printf("%-22s %s\n\n", k+":", capabilities.Map[k].Description) 37 } 38 return nil 39 }