github.com/containers/podman/v2@v2.2.2-0.20210501105131-c1e07d070c4c/libpod/image/docker_registry_options.go (about) 1 package image 2 3 import ( 4 "fmt" 5 6 "github.com/containers/buildah/pkg/parse" 7 "github.com/containers/image/v5/docker/reference" 8 "github.com/containers/image/v5/types" 9 podmanVersion "github.com/containers/podman/v2/version" 10 ) 11 12 // DockerRegistryOptions encapsulates settings that affect how we connect or 13 // authenticate to a remote registry. 14 type DockerRegistryOptions struct { 15 // DockerRegistryCreds is the user name and password to supply in case 16 // we need to pull an image from a registry, and it requires us to 17 // authenticate. 18 DockerRegistryCreds *types.DockerAuthConfig 19 // DockerCertPath is the location of a directory containing CA 20 // certificates which will be used to verify the registry's certificate 21 // (all files with names ending in ".crt"), and possibly client 22 // certificates and private keys (pairs of files with the same name, 23 // except for ".cert" and ".key" suffixes). 24 DockerCertPath string 25 // DockerInsecureSkipTLSVerify turns off verification of TLS 26 // certificates and allows connecting to registries without encryption 27 // - or forces it on even if registries.conf has the registry configured as insecure. 28 DockerInsecureSkipTLSVerify types.OptionalBool 29 // If not "", overrides the use of platform.GOOS when choosing an image or verifying OS match. 30 OSChoice string 31 // If not "", overrides the use of platform.GOARCH when choosing an image or verifying architecture match. 32 ArchitectureChoice string 33 // If not "", overrides_VARIANT_ instead of the running architecture variant for choosing images. 34 VariantChoice string 35 // RegistriesConfPath can be used to override the default path of registries.conf. 36 RegistriesConfPath string 37 } 38 39 // GetSystemContext constructs a new system context from a parent context. the values in the DockerRegistryOptions, and other parameters. 40 func (o DockerRegistryOptions) GetSystemContext(parent *types.SystemContext, additionalDockerArchiveTags []reference.NamedTagged) *types.SystemContext { 41 sc := &types.SystemContext{ 42 DockerAuthConfig: o.DockerRegistryCreds, 43 DockerCertPath: o.DockerCertPath, 44 DockerInsecureSkipTLSVerify: o.DockerInsecureSkipTLSVerify, 45 DockerArchiveAdditionalTags: additionalDockerArchiveTags, 46 OSChoice: o.OSChoice, 47 ArchitectureChoice: o.ArchitectureChoice, 48 VariantChoice: o.VariantChoice, 49 BigFilesTemporaryDir: parse.GetTempDir(), 50 } 51 if parent != nil { 52 sc.SignaturePolicyPath = parent.SignaturePolicyPath 53 sc.AuthFilePath = parent.AuthFilePath 54 sc.DirForceCompress = parent.DirForceCompress 55 sc.DockerRegistryUserAgent = parent.DockerRegistryUserAgent 56 sc.OSChoice = parent.OSChoice 57 sc.ArchitectureChoice = parent.ArchitectureChoice 58 sc.BlobInfoCacheDir = parent.BlobInfoCacheDir 59 } 60 return sc 61 } 62 63 // GetSystemContext Constructs a new containers/image/types.SystemContext{} struct from the given signaturePolicy path 64 func GetSystemContext(signaturePolicyPath, authFilePath string, forceCompress bool) *types.SystemContext { 65 sc := &types.SystemContext{} 66 if signaturePolicyPath != "" { 67 sc.SignaturePolicyPath = signaturePolicyPath 68 } 69 sc.AuthFilePath = authFilePath 70 sc.DirForceCompress = forceCompress 71 sc.DockerRegistryUserAgent = fmt.Sprintf("libpod/%s", podmanVersion.Version) 72 73 return sc 74 }