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 07e87c38caef957a5e4d43b4b755f7d8685ab902 Author: James Netherton <jamesnether...@gmail.com> AuthorDate: Tue Aug 13 09:27:47 2019 +0100 fix: Enable proxy server to be configured for Kaniko builds fixes #899 --- .../camel/v1alpha1/integrationplatform_types.go | 1 + pkg/builder/kaniko/publisher.go | 40 ++++++++++++++++++++++ pkg/cmd/install.go | 7 ++++ 3 files changed, 48 insertions(+) diff --git a/pkg/apis/camel/v1alpha1/integrationplatform_types.go b/pkg/apis/camel/v1alpha1/integrationplatform_types.go index 9a1e047..19dbcab 100644 --- a/pkg/apis/camel/v1alpha1/integrationplatform_types.go +++ b/pkg/apis/camel/v1alpha1/integrationplatform_types.go @@ -104,6 +104,7 @@ type IntegrationPlatformBuildSpec struct { Timeout metav1.Duration `json:"timeout,omitempty"` PersistentVolumeClaim string `json:"persistentVolumeClaim,omitempty"` Maven MavenSpec `json:"maven,omitempty"` + HTTPProxySecret string `json:"httpProxySecret,omitempty"` } // IntegrationPlatformRegistrySpec -- diff --git a/pkg/builder/kaniko/publisher.go b/pkg/builder/kaniko/publisher.go index 4e798ea..1951f5b 100644 --- a/pkg/builder/kaniko/publisher.go +++ b/pkg/builder/kaniko/publisher.go @@ -111,6 +111,46 @@ func publisher(ctx *builder.Context) error { args = baseArgs } + if ctx.Build.Platform.Build.HTTPProxySecret != "" { + optional := true + envs = append(envs, corev1.EnvVar{ + Name: "HTTP_PROXY", + ValueFrom: &corev1.EnvVarSource{ + SecretKeyRef: &corev1.SecretKeySelector{ + LocalObjectReference: corev1.LocalObjectReference{ + Name: ctx.Build.Platform.Build.HTTPProxySecret, + }, + Key: "HTTP_PROXY", + Optional: &optional, + }, + }, + }) + envs = append(envs, corev1.EnvVar{ + Name: "HTTPS_PROXY", + ValueFrom: &corev1.EnvVarSource{ + SecretKeyRef: &corev1.SecretKeySelector{ + LocalObjectReference: corev1.LocalObjectReference{ + Name: ctx.Build.Platform.Build.HTTPProxySecret, + }, + Key: "HTTPS_PROXY", + Optional: &optional, + }, + }, + }) + envs = append(envs, corev1.EnvVar{ + Name: "NO_PROXY", + ValueFrom: &corev1.EnvVarSource{ + SecretKeyRef: &corev1.SecretKeySelector{ + LocalObjectReference: corev1.LocalObjectReference{ + Name: ctx.Build.Platform.Build.HTTPProxySecret, + }, + Key: "NO_PROXY", + Optional: &optional, + }, + }, + }) + } + pod := corev1.Pod{ TypeMeta: metav1.TypeMeta{ APIVersion: corev1.SchemeGroupVersion.String(), diff --git a/pkg/cmd/install.go b/pkg/cmd/install.go index 166b862..25e94b3 100644 --- a/pkg/cmd/install.go +++ b/pkg/cmd/install.go @@ -74,6 +74,8 @@ func newCmdInstall(rootCmdOptions *RootCmdOptions) *cobra.Command { cmd.Flags().StringVar(&impl.buildStrategy, "build-strategy", "", "Set the build strategy") cmd.Flags().StringVar(&impl.buildTimeout, "build-timeout", "", "Set how long the build process can last") cmd.Flags().StringVar(&impl.traitProfile, "trait-profile", "", "The profile to use for traits") + cmd.Flags().StringVar(&impl.httpProxySecret, "http-proxy-secret", "", "Configure the source of the secret holding HTTP proxy server details "+ + "(HTTP_PROXY|HTTPS_PROXY|NO_PROXY)") // maven settings cmd.Flags().StringVar(&impl.localRepository, "local-repository", "", "Location of the local maven repository") @@ -114,6 +116,7 @@ type installCmdOptions struct { kits []string registry v1alpha1.IntegrationPlatformRegistrySpec traitProfile string + httpProxySecret string } // nolint: gocyclo @@ -228,6 +231,10 @@ func (o *installCmdOptions) install(_ *cobra.Command, _ []string) error { platform.Spec.Build.Maven.Settings = mavenSettings } + if o.httpProxySecret != "" { + platform.Spec.Build.HTTPProxySecret = o.httpProxySecret + } + platform.Spec.Resources.Kits = o.kits err = install.RuntimeObjectOrCollect(o.Context, c, namespace, collection, platform)