mirror of
https://github.com/linuxkit/linuxkit.git
synced 2025-07-17 16:31:08 +00:00
fix registry auth (#4146)
Signed-off-by: Avi Deitcher <avi@deitcher.net>
This commit is contained in:
parent
33ee27971d
commit
bc44cb899c
@ -101,6 +101,6 @@ func pkgCmd() *cobra.Command {
|
||||
cmd.PersistentFlags().BoolVar(&dirty, "force-dirty", false, "Force the pkg(s) to be considered dirty")
|
||||
cmd.PersistentFlags().BoolVar(&devMode, "dev", false, "Force org and hash to $USER and \"dev\" respectively")
|
||||
|
||||
cmd.PersistentFlags().StringSliceVar(®istryCreds, "registry-creds", nil, "Registry auths to use for building images, format is <registry>=<username>:<password> OR <registry>=<registry-token>. If no username is provided, it is treated as a registry token. <registry> must be a URL, e.g. 'https://index.docker.io/'. May be provided as many times as desired. Will override anything in your default.")
|
||||
cmd.PersistentFlags().StringSliceVar(®istryCreds, "registry-creds", nil, "Registry auths to use for building images, format is <registry>=<username>:<password> OR <registry>=<registry-token-base64>; do NOT forget to base64 encode it. If no username is provided, it is treated as a registry token. <registry> must be a URL, e.g. 'https://index.docker.io/'. May be provided as many times as desired. Will override anything in your default.")
|
||||
return cmd
|
||||
}
|
||||
|
@ -593,10 +593,13 @@ func (dr *dockerRunnerImpl) build(ctx context.Context, tag, pkg, dockerContext,
|
||||
cf = configfile.New("custom")
|
||||
// merge imageBuildOpts.RegistryAuths into dockercfg
|
||||
for registry, auth := range imageBuildOpts.RegistryAuths {
|
||||
bareRegistry := strings.TrimPrefix(registry, "https://")
|
||||
bareRegistry = strings.TrimPrefix(bareRegistry, "http://")
|
||||
cf.AuthConfigs[bareRegistry] = dockerconfigtypes.AuthConfig{
|
||||
ServerAddress: bareRegistry,
|
||||
// special case for docker.io
|
||||
registryWithoutScheme := strings.TrimPrefix(registry, "https://")
|
||||
registryWithoutScheme = strings.TrimPrefix(registryWithoutScheme, "http://")
|
||||
if registryWithoutScheme == "docker.io" || registryWithoutScheme == "index.docker.io" || registryWithoutScheme == "registry-1.docker.io" {
|
||||
registry = "https://index.docker.io/v1/"
|
||||
}
|
||||
cf.AuthConfigs[registry] = dockerconfigtypes.AuthConfig{
|
||||
Username: auth.Username,
|
||||
Password: auth.Password,
|
||||
RegistryToken: auth.RegistryToken,
|
||||
|
Loading…
Reference in New Issue
Block a user