This is an automated email from the ASF dual-hosted git repository.
pcongiusti pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-k.git
The following commit(s) were added to refs/heads/main by this push:
new e891a66be fix: keystore generation output
e891a66be is described below
commit e891a66bed11cf37d88125b5e0a865379c3ae1f1
Author: Pasquale Congiusti <[email protected]>
AuthorDate: Thu Jan 30 18:16:22 2025 +0100
fix: keystore generation output
---
pkg/controller/integrationplatform/kamelets.go | 4 ++--
pkg/util/jvm/keystore.go | 8 ++++----
pkg/util/jvm/keystore_test.go | 3 +++
3 files changed, 9 insertions(+), 6 deletions(-)
diff --git a/pkg/controller/integrationplatform/kamelets.go
b/pkg/controller/integrationplatform/kamelets.go
index 9aeb271bf..0ce98285e 100644
--- a/pkg/controller/integrationplatform/kamelets.go
+++ b/pkg/controller/integrationplatform/kamelets.go
@@ -50,8 +50,8 @@ const (
kamelVersionAnnotation = "camel.apache.org/version"
)
-// installKameletCatalog installs the version Apache Kamelet Catalog into the
specified namespace. It returns the number of Kamelets installed and errored
-// if successful.
+// installKameletCatalog installs the version Apache Kamelet Catalog into the
specified namespace.
+// It returns the number of Kamelets installed and errored if successful.
func installKameletCatalog(ctx context.Context, c client.Client, platform
*v1.IntegrationPlatform, version string) (int, int, error) {
// Prepare proper privileges for Kamelets installed globally
if err := prepareKameletsPermissions(ctx, c, platform.Namespace); err
!= nil {
diff --git a/pkg/util/jvm/keystore.go b/pkg/util/jvm/keystore.go
index 89d132080..5b4cff9c3 100644
--- a/pkg/util/jvm/keystore.go
+++ b/pkg/util/jvm/keystore.go
@@ -37,8 +37,8 @@ const (
var (
logger = log.WithName("keytool")
- loggerInfo = func(s string) string { logger.Info(s); return "" }
- loggerError = func(s string) string { logger.Error(nil, s); return "" }
+ loggerInfo = func(s string) string { logger.Info(s); return s }
+ loggerError = func(s string) string { logger.Error(nil, s); return s }
)
func GenerateKeystore(ctx context.Context, keystoreDir, keystoreName,
keystorePass string, data [][]byte) error {
@@ -49,7 +49,7 @@ func GenerateKeystore(ctx context.Context, keystoreDir,
keystoreName, keystorePa
cmd.Stdin = bytes.NewReader(data)
// keytool logs info messages to stderr, as stdout is used to
output results,
// otherwise it logs error messages to stdout.
- err := util.RunAndLog(ctx, cmd, loggerError, loggerInfo)
+ err := util.RunAndLog(ctx, cmd, loggerInfo, loggerError)
if err != nil {
return err
}
@@ -66,7 +66,7 @@ func GenerateKeystore(ctx context.Context, keystoreDir,
keystoreName, keystorePa
cmd.Dir = keystoreDir
// keytool logs info messages to stderr, as stdout is used to
output results,
// otherwise it logs error messages to stdout.
- err := util.RunAndLog(ctx, cmd, loggerError, loggerInfo)
+ err := util.RunAndLog(ctx, cmd, loggerInfo, loggerError)
if err != nil {
return err
}
diff --git a/pkg/util/jvm/keystore_test.go b/pkg/util/jvm/keystore_test.go
index a6b15b6be..be10cbae6 100644
--- a/pkg/util/jvm/keystore_test.go
+++ b/pkg/util/jvm/keystore_test.go
@@ -23,6 +23,7 @@ import (
"testing"
"github.com/apache/camel-k/v2/pkg/util"
+ "github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
@@ -38,10 +39,12 @@ func TestGenerateKeystore(t *testing.T) {
data = [][]byte{{0}, {1}}
err = GenerateKeystore(ctx, "", "/tmp/keystore", NewKeystorePassword(),
data)
require.Error(t, err)
+ assert.Equal(t, "keytool error: java.io.IOException: keystore password
was incorrect: exit status 1", err.Error())
// Incorrect password format
err = GenerateKeystore(ctx, "", "/tmp/keystore", "", data)
require.Error(t, err)
+ assert.Equal(t, "Illegal option: /tmp/keystore: exit status 1",
err.Error())
testFileExists, _ := util.FileExists("/tmp/keystore")
if testFileExists {