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 5227b8046d7ca4cb8a4a62fd9b0209b382f515f0 Author: Antonin Stefanutti <[email protected]> AuthorDate: Mon Feb 24 14:33:21 2020 +0100 feat(openshift): Default to auto-configuring OpenShift internal container images registry --- pkg/platform/defaults.go | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/pkg/platform/defaults.go b/pkg/platform/defaults.go index 30cf3c1..caffed1 100644 --- a/pkg/platform/defaults.go +++ b/pkg/platform/defaults.go @@ -20,11 +20,13 @@ package platform import ( "context" "fmt" + "strings" "time" corev1 "k8s.io/api/core/v1" k8serrors "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/types" v1 "github.com/apache/camel-k/pkg/apis/camel/v1" "github.com/apache/camel-k/pkg/client" @@ -82,6 +84,29 @@ func ConfigureDefaults(ctx context.Context, c client.Client, p *v1.IntegrationPl return err } + // Default to using OpenShift internal container images registry when using a strategy other than S2I + if p.Status.Cluster == v1.IntegrationPlatformClusterOpenShift && + p.Status.Build.PublishStrategy != v1.IntegrationPlatformBuildPublishStrategyS2I && + p.Status.Build.Registry.Address == "" { + p.Status.Build.Registry.Address = "image-registry.openshift-image-registry.svc:5000" + + // Default to using the registry secret that's configured for the builder service account + if p.Status.Build.Registry.Secret == "" { + sa := corev1.ServiceAccount{} + err := c.Get(ctx, types.NamespacedName{Namespace: p.Namespace, Name: "camel-k-builder"}, &sa) + if err != nil { + return err + } + // We may want to read the secret keys instead of relying on the secret name scheme + for _, secret := range sa.Secrets { + if strings.Contains(secret.Name, "camel-k-builder-dockercfg") { + p.Status.Build.Registry.Secret = secret.Name + break + } + } + } + } + if verbose && p.Status.Build.PublishStrategy != v1.IntegrationPlatformBuildPublishStrategyS2I && p.Status.Build.Registry.Address == "" { log.Log.Info("No registry specified for publishing images") }
