You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by as...@apache.org on 2020/02/26 18:34:45 UTC
[camel-k] 02/15: fix(buildah): Support old Docker registry
authentication format
This is an automated email from the ASF dual-hosted git repository.
astefanutti pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel-k.git
commit b93e1ce42526651a401ad13f809c0ccaa9d2f28b
Author: Antonin Stefanutti <an...@stefanutti.fr>
AuthorDate: Mon Feb 24 14:26:52 2020 +0100
fix(buildah): Support old Docker registry authentication format
---
pkg/trait/builder.go | 26 ++++++++++++++++++++++++--
1 file changed, 24 insertions(+), 2 deletions(-)
diff --git a/pkg/trait/builder.go b/pkg/trait/builder.go
index 32fa921..1a49ee6 100644
--- a/pkg/trait/builder.go
+++ b/pkg/trait/builder.go
@@ -236,6 +236,11 @@ func (t *builderTrait) buildahTask(e *Environment) (*v1.ImageTask, error) {
push = append(push[:2], append([]string{"--log-level=debug"}, push[2:]...)...)
}
+ args := []string{
+ strings.Join(bud, " "),
+ strings.Join(push, " "),
+ }
+
env := make([]corev1.EnvVar, 0)
volumes := make([]corev1.Volume, 0)
volumeMounts := make([]corev1.VolumeMount, 0)
@@ -245,6 +250,17 @@ func (t *builderTrait) buildahTask(e *Environment) (*v1.ImageTask, error) {
if err != nil {
return nil, err
}
+ if secret == plainDockerBuildahRegistrySecret {
+ // Handle old format and make it compatible with Buildah
+ auth := []string{
+ "(echo '{ \"auths\": ' ; cat /buildah/.docker/config.json ; echo \"}\") > /tmp/.dockercfg",
+ }
+ args = append([]string{strings.Join(auth, " ")}, args...)
+ env = append(env, corev1.EnvVar{
+ Name: "REGISTRY_AUTH_FILE",
+ Value: "/tmp/.dockercfg",
+ })
+ }
mountRegistrySecret(e.Platform.Status.Build.Registry.Secret, secret, &volumes, &volumeMounts, &env)
} else if e.Platform.Status.Build.Registry.Insecure {
bud = append(bud[:2], append([]string{"--tls-verify=false"}, bud[2:]...)...)
@@ -262,7 +278,7 @@ func (t *builderTrait) buildahTask(e *Environment) (*v1.ImageTask, error) {
},
Image: fmt.Sprintf("quay.io/buildah/stable:v%s", defaults.BuildahVersion),
Command: []string{"/bin/sh", "-c"},
- Args: []string{strings.Join(bud, " ") + " && " + strings.Join(push, " ")},
+ Args: []string{strings.Join(args, " && ")},
Env: env,
WorkingDir: path.Join(builderDir, e.IntegrationKit.Name, "context"),
},
@@ -326,7 +342,12 @@ type registrySecret struct {
var (
plainDockerBuildahRegistrySecret = registrySecret{
- fileName: "config.json",
+ fileName: corev1.DockerConfigKey,
+ mountPath: "/buildah/.docker",
+ destination: "config.json",
+ }
+ standardDockerBuildahRegistrySecret = registrySecret{
+ fileName: corev1.DockerConfigJsonKey,
mountPath: "/buildah/.docker",
destination: "config.json",
refEnv: "REGISTRY_AUTH_FILE",
@@ -334,6 +355,7 @@ var (
buildahRegistrySecrets = []registrySecret{
plainDockerBuildahRegistrySecret,
+ standardDockerBuildahRegistrySecret,
}
)