short-name aliasing

Add support for short-name aliasing.

Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
This commit is contained in:
Valentin Rothberg
2020-10-07 16:58:53 +02:00
parent 0b1a60ec27
commit 8e4a42aa42
128 changed files with 12694 additions and 503 deletions

View File

@ -59,7 +59,6 @@ type BudResults struct {
Creds string
DisableCompression bool
DisableContentTrust bool
DecryptionKeys []string
File []string
Format string
Iidfile string
@ -90,38 +89,39 @@ type BudResults struct {
// FromAndBugResults represents the results for common flags
// in bud and from
type FromAndBudResults struct {
AddHost []string
BlobCache string
CapAdd []string
CapDrop []string
CgroupParent string
CPUPeriod uint64
CPUQuota int64
CPUSetCPUs string
CPUSetMems string
CPUShares uint64
Devices []string
DNSSearch []string
DNSServers []string
DNSOptions []string
HTTPProxy bool
Isolation string
Memory string
MemorySwap string
OverrideArch string
OverrideOS string
SecurityOpt []string
ShmSize string
Ulimit []string
Volumes []string
AddHost []string
BlobCache string
CapAdd []string
CapDrop []string
CgroupParent string
CPUPeriod uint64
CPUQuota int64
CPUSetCPUs string
CPUSetMems string
CPUShares uint64
DecryptionKeys []string
Devices []string
DNSSearch []string
DNSServers []string
DNSOptions []string
HTTPProxy bool
Isolation string
Memory string
MemorySwap string
OverrideArch string
OverrideOS string
SecurityOpt []string
ShmSize string
Ulimit []string
Volumes []string
}
// GetUserNSFlags returns the common flags for usernamespace
func GetUserNSFlags(flags *UserNSResults) pflag.FlagSet {
usernsFlags := pflag.FlagSet{}
usernsFlags.StringVar(&flags.UserNS, "userns", "", "'container', `path` of user namespace to join, or 'host'")
usernsFlags.StringSliceVar(&flags.UserNSUIDMap, "userns-uid-map", []string{}, "`containerID:hostID:length` UID mapping to use in user namespace")
usernsFlags.StringSliceVar(&flags.UserNSGIDMap, "userns-gid-map", []string{}, "`containerID:hostID:length` GID mapping to use in user namespace")
usernsFlags.StringSliceVar(&flags.UserNSUIDMap, "userns-uid-map", []string{}, "`containerUID:hostUID:length` UID mapping to use in user namespace")
usernsFlags.StringSliceVar(&flags.UserNSGIDMap, "userns-gid-map", []string{}, "`containerGID:hostGID:length` GID mapping to use in user namespace")
usernsFlags.StringVar(&flags.UserNSUIDMapUser, "userns-uid-map-user", "", "`name` of entries from /etc/subuid to use to set user namespace UID mapping")
usernsFlags.StringVar(&flags.UserNSGIDMapGroup, "userns-gid-map-group", "", "`name` of entries from /etc/subgid to use to set user namespace GID mapping")
return usernsFlags
@ -208,6 +208,9 @@ func GetBudFlags(flags *BudResults) pflag.FlagSet {
fs.StringSliceVar(&flags.RuntimeFlags, "runtime-flag", []string{}, "add global flags for the container runtime")
fs.StringVar(&flags.SignBy, "sign-by", "", "sign the image using a GPG key with the specified `FINGERPRINT`")
fs.StringVar(&flags.SignaturePolicy, "signature-policy", "", "`pathname` of signature policy file (not usually used)")
if err := fs.MarkHidden("signature-policy"); err != nil {
panic(fmt.Sprintf("error marking the signature-policy flag as hidden: %v", err))
}
fs.BoolVar(&flags.Squash, "squash", false, "squash newly built layers into a single new layer")
fs.StringArrayVarP(&flags.Tag, "tag", "t", []string{}, "tagged `name` to apply to the built image")
fs.StringVar(&flags.Target, "target", "", "set the target build stage to build")
@ -265,6 +268,7 @@ func GetFromAndBudFlags(flags *FromAndBudResults, usernsResults *UserNSResults,
fs.Uint64VarP(&flags.CPUShares, "cpu-shares", "c", 0, "CPU shares (relative weight)")
fs.StringVar(&flags.CPUSetCPUs, "cpuset-cpus", "", "CPUs in which to allow execution (0-3, 0,1)")
fs.StringVar(&flags.CPUSetMems, "cpuset-mems", "", "memory nodes (MEMs) in which to allow execution (0-3, 0,1). Only effective on NUMA systems.")
fs.StringSliceVar(&flags.DecryptionKeys, "decryption-key", nil, "key needed to decrypt the image")
fs.StringArrayVar(&flags.Devices, "device", defaultContainerConfig.Containers.Devices, "Additional devices to be used within containers (default [])")
fs.StringSliceVar(&flags.DNSSearch, "dns-search", defaultContainerConfig.Containers.DNSSearches, "Set custom DNS search domains")
fs.StringSliceVar(&flags.DNSServers, "dns", defaultContainerConfig.Containers.DNSServers, "Set custom DNS servers or disable it completely by setting it to 'none', which prevents the automatic creation of `/etc/resolv.conf`.")
@ -308,6 +312,7 @@ func GetFromAndBudFlagsCompletions() commonComp.FlagCompletions {
flagCompletion["cpu-shares"] = commonComp.AutocompleteNone
flagCompletion["cpuset-cpus"] = commonComp.AutocompleteNone
flagCompletion["cpuset-mems"] = commonComp.AutocompleteNone
flagCompletion["decryption-key"] = commonComp.AutocompleteNone
flagCompletion["device"] = commonComp.AutocompleteDefault
flagCompletion["dns-search"] = commonComp.AutocompleteNone
flagCompletion["dns"] = commonComp.AutocompleteNone