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(&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().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
|
return cmd
|
||||||
}
|
}
|
||||||
|
@ -593,10 +593,13 @@ func (dr *dockerRunnerImpl) build(ctx context.Context, tag, pkg, dockerContext,
|
|||||||
cf = configfile.New("custom")
|
cf = configfile.New("custom")
|
||||||
// merge imageBuildOpts.RegistryAuths into dockercfg
|
// merge imageBuildOpts.RegistryAuths into dockercfg
|
||||||
for registry, auth := range imageBuildOpts.RegistryAuths {
|
for registry, auth := range imageBuildOpts.RegistryAuths {
|
||||||
bareRegistry := strings.TrimPrefix(registry, "https://")
|
// special case for docker.io
|
||||||
bareRegistry = strings.TrimPrefix(bareRegistry, "http://")
|
registryWithoutScheme := strings.TrimPrefix(registry, "https://")
|
||||||
cf.AuthConfigs[bareRegistry] = dockerconfigtypes.AuthConfig{
|
registryWithoutScheme = strings.TrimPrefix(registryWithoutScheme, "http://")
|
||||||
ServerAddress: bareRegistry,
|
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,
|
Username: auth.Username,
|
||||||
Password: auth.Password,
|
Password: auth.Password,
|
||||||
RegistryToken: auth.RegistryToken,
|
RegistryToken: auth.RegistryToken,
|
||||||
|
Loading…
Reference in New Issue
Block a user