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:53 UTC
[camel-k] 11/20: feat(build): Pipe CA Secret data into keytool
stdin directly
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 0867183a0a68ed9151beb585496f5573f74353f2
Author: Antonin Stefanutti <an...@stefanutti.fr>
AuthorDate: Fri Mar 26 18:34:03 2021 +0100
feat(build): Pipe CA Secret data into keytool stdin directly
---
pkg/util/jvm/keystore.go | 15 ++++-----------
1 file changed, 4 insertions(+), 11 deletions(-)
diff --git a/pkg/util/jvm/keystore.go b/pkg/util/jvm/keystore.go
index 0a3fe1a..eb055b2 100644
--- a/pkg/util/jvm/keystore.go
+++ b/pkg/util/jvm/keystore.go
@@ -18,6 +18,7 @@ limitations under the License.
package jvm
import (
+ "bytes"
"context"
"fmt"
"math/rand"
@@ -26,25 +27,17 @@ import (
"path"
"strings"
"time"
-
- "github.com/apache/camel-k/pkg/util"
)
func GenerateKeystore(ctx context.Context, keystoreDir, keystoreName, keystorePass string, data []byte) error {
- tmpFile := "ca-cert.tmp"
- err := util.WriteFileWithContent(keystoreDir, tmpFile, data)
- if err != nil {
- return err
- }
- defer os.Remove(path.Join(keystoreDir, tmpFile))
-
- args := strings.Fields(fmt.Sprintf("-importcert -noprompt -alias maven -storepass %s -file %s -keystore %s", keystorePass, tmpFile, keystoreName))
+ args := strings.Fields(fmt.Sprintf("-importcert -noprompt -alias maven -storepass %s -keystore %s", keystorePass, keystoreName))
cmd := exec.CommandContext(ctx, "keytool", args...)
cmd.Dir = keystoreDir
+ cmd.Stdin = bytes.NewReader(data)
cmd.Stderr = os.Stderr
cmd.Stdout = os.Stdout
- err = cmd.Run()
+ err := cmd.Run()
if err != nil {
return err
}