diff --git a/pkg/controller/integrationplatform/kamelets.go b/pkg/controller/integrationplatform/kamelets.go index 9aeb271bf9..0ce98285eb 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 89d1320803..5b4cff9c3f 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 a6b15b6be9..be10cbae61 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 {