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 2021/03/30 17:20:46 UTC
[camel-k] 04/20: feat(build): Support custom CA certificate in
OpenAPI builds
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 4e2a7b2c95aad4fffb2992aed00208b9d02ad5d6
Author: Antonin Stefanutti <an...@stefanutti.fr>
AuthorDate: Thu Mar 25 11:23:43 2021 +0100
feat(build): Support custom CA certificate in OpenAPI builds
---
pkg/trait/openapi.go | 25 +++++++++++++++----------
1 file changed, 15 insertions(+), 10 deletions(-)
diff --git a/pkg/trait/openapi.go b/pkg/trait/openapi.go
index 197eb92..b0880b7 100644
--- a/pkg/trait/openapi.go
+++ b/pkg/trait/openapi.go
@@ -39,13 +39,11 @@ import (
"github.com/apache/camel-k/pkg/util/defaults"
"github.com/apache/camel-k/pkg/util/digest"
"github.com/apache/camel-k/pkg/util/gzip"
+ "github.com/apache/camel-k/pkg/util/jvm"
"github.com/apache/camel-k/pkg/util/kubernetes"
"github.com/apache/camel-k/pkg/util/maven"
)
-// OpenAPITraitName ---
-const OpenAPITraitName = "openapi"
-
// The OpenAPI DSL trait is internally used to allow creating integrations from a OpenAPI specs.
//
// +camel-k:trait=openapi
@@ -55,7 +53,7 @@ type openAPITrait struct {
func newOpenAPITrait() Trait {
return &openAPITrait{
- BaseTrait: NewBaseTrait(OpenAPITraitName, 300),
+ BaseTrait: NewBaseTrait("openapi", 300),
}
}
@@ -117,9 +115,7 @@ func (t *openAPITrait) Apply(e *Environment) error {
generatedSources := make([]v1.SourceSpec, 0, len(e.Integration.Status.GeneratedSources))
if e.Integration.Status.GeneratedSources != nil {
- //
// Filter out the previously generated source
- //
for _, x := range e.Integration.Status.GeneratedSources {
if x.Name != generatedSourceName {
generatedSources = append(generatedSources, x)
@@ -127,9 +123,7 @@ func (t *openAPITrait) Apply(e *Environment) error {
}
}
- //
// Add an additional source that references the config map
- //
generatedSources = append(generatedSources, v1.SourceSpec{
DataSpec: v1.DataSpec{
Name: generatedSourceName,
@@ -221,6 +215,19 @@ func (t *openAPITrait) createNewOpenAPIConfigMap(e *Environment, resource v1.Res
mc.SettingsContent = []byte(settings)
}
+ if e.Platform.Status.Build.Maven.CaCert != nil {
+ certData, err := kubernetes.GetSecretRefData(e.C, e.Client, e.Platform.Namespace, e.Platform.Status.Build.Maven.CaCert)
+ if err != nil {
+ return err
+ }
+ trustStoreName := "trust.jks"
+ err = jvm.GenerateJavaKeystore(e.C, tmpDir, trustStoreName, certData)
+ if err != nil {
+ return err
+ }
+ mc.ExtraMavenOpts = append(mc.ExtraMavenOpts, "-Djavax.net.ssl.trustStore="+trustStoreName)
+ }
+
err = maven.Run(mc)
if err != nil {
return err
@@ -246,10 +253,8 @@ func (t *openAPITrait) createNewOpenAPIConfigMap(e *Environment, resource v1.Res
return err
}
- //
// Store the generated rest xml in a separate config map in order
// not to pollute the integration with generated data
- //
cm := corev1.ConfigMap{
TypeMeta: metav1.TypeMeta{
Kind: "ConfigMap",