astefanutti commented on a change in pull request #3153:
URL: https://github.com/apache/camel-k/pull/3153#discussion_r838185670
##########
File path: e2e/support/test_support.go
##########
@@ -1719,9 +1719,9 @@ func UserCleanup() {
command.Stderr = os.Stderr
command.Stdout = os.Stdout
if err := command.Run(); err != nil {
- fmt.Printf("An error occurred during user cleanup
command execution: %v\n", err)
+ fmt.Fprintf(command.Stderr, "An error occurred during
user cleanup command execution: %v\n", err)
Review comment:
Could be replaced with `Fprintln`.
##########
File path: pkg/cmd/run_help.go
##########
@@ -43,20 +44,20 @@ func hashFrom(contents ...[]byte) string {
return fmt.Sprintf("%x", hash.Sum(nil))
}
-func parseConfigAndGenCm(ctx context.Context, c client.Client, config
*resource.Config, integration *v1.Integration, enableCompression bool)
(*corev1.ConfigMap, error) {
+func parseConfigAndGenCm(ctx context.Context, cmd *cobra.Command, c
client.Client, config *resource.Config, integration *v1.Integration,
enableCompression bool) (*corev1.ConfigMap, error) {
switch config.StorageType() {
case resource.StorageTypeConfigmap:
cm := kubernetes.LookupConfigmap(ctx, c, integration.Namespace,
config.Name())
if cm == nil {
- fmt.Printf("Warn: %s Configmap not found in %s
namespace, make sure to provide it before the Integration can run\n",
+ fmt.Fprintf(cmd.ErrOrStderr(), "Warn: %s Configmap not
found in %s namespace, make sure to provide it before the Integration can
run\n",
config.Name(), integration.Namespace)
} else if config.ContentType() != resource.ContentTypeData &&
cm.BinaryData != nil {
return nil, fmt.Errorf("you cannot provide a binary
config, use a text file instead")
}
case resource.StorageTypeSecret:
secret := kubernetes.LookupSecret(ctx, c,
integration.Namespace, config.Name())
if secret == nil {
- fmt.Printf("Warn: %s Secret not found in %s namespace,
make sure to provide it before the Integration can run\n",
+ fmt.Fprintf(cmd.ErrOrStderr(), "Warn: %s Secret not
found in %s namespace, make sure to provide it before the Integration can
run\n",
Review comment:
Could be replaced with `Fprintln`.
##########
File path: pkg/cmd/uninstall.go
##########
@@ -209,71 +209,71 @@ func (o *uninstallCmdOptions)
uninstallClusterWideResources(ctx context.Context,
if !o.SkipClusterRoleBindings || o.UninstallAll {
if err := o.uninstallClusterRoleBindings(ctx, c); err != nil {
if k8serrors.IsForbidden(err) {
- return createActionNotAuthorizedError()
+ return createActionNotAuthorizedError(cmd)
}
return err
}
- fmt.Printf("Camel K Cluster Role Bindings removed from
cluster\n")
+ fmt.Fprintf(cmd.OutOrStdout(), "Camel K Cluster Role Bindings
removed from cluster\n")
}
if !o.SkipClusterRoles || o.UninstallAll {
if err := o.uninstallClusterRoles(ctx, c); err != nil {
if k8serrors.IsForbidden(err) {
- return createActionNotAuthorizedError()
+ return createActionNotAuthorizedError(cmd)
}
return err
}
- fmt.Printf("Camel K Cluster Roles removed from cluster\n")
+ fmt.Fprintf(cmd.OutOrStdout(), "Camel K Cluster Roles removed
from cluster\n")
}
return nil
}
-func (o *uninstallCmdOptions) uninstallNamespaceRoles(ctx context.Context, c
client.Client) error {
+func (o *uninstallCmdOptions) uninstallNamespaceRoles(cmd *cobra.Command, ctx
context.Context, c client.Client) error {
if !o.SkipRoleBindings {
if err := o.uninstallRoleBindings(ctx, c); err != nil {
return err
}
- fmt.Printf("Camel K Role Bindings removed from namespace %s\n",
o.Namespace)
+ fmt.Fprintf(cmd.OutOrStdout(), "Camel K Role Bindings removed
from namespace %s\n", o.Namespace)
}
if !o.SkipRoles {
if err := o.uninstallRoles(ctx, c); err != nil {
return err
}
- fmt.Printf("Camel K Roles removed from namespace %s\n",
o.Namespace)
+ fmt.Fprintf(cmd.OutOrStdout(), "Camel K Roles removed from
namespace %s\n", o.Namespace)
}
if !o.SkipServiceAccounts {
if err := o.uninstallServiceAccounts(ctx, c); err != nil {
return err
}
- fmt.Printf("Camel K Service Accounts removed from namespace
%s\n", o.Namespace)
+ fmt.Fprintf(cmd.OutOrStdout(), "Camel K Service Accounts
removed from namespace %s\n", o.Namespace)
}
return nil
}
-func (o *uninstallCmdOptions) uninstallNamespaceResources(ctx context.Context,
c client.Client) error {
+func (o *uninstallCmdOptions) uninstallNamespaceResources(cmd *cobra.Command,
ctx context.Context, c client.Client) error {
if !o.SkipConfigMaps {
if err := o.uninstallConfigMaps(ctx, c); err != nil {
return err
}
- fmt.Printf("Camel K Config Maps removed from namespace %s\n",
o.Namespace)
+ fmt.Fprintf(cmd.OutOrStdout(), "Camel K Config Maps removed
from namespace %s\n", o.Namespace)
}
if !o.SkipRegistrySecret {
if err := o.uninstallRegistrySecret(ctx, c); err != nil {
return err
}
- fmt.Printf("Camel K Registry Secret removed from namespace
%s\n", o.Namespace)
+ fmt.Fprintf(cmd.OutOrStdout(), "Camel K Registry Secret removed
from namespace %s\n", o.Namespace)
}
if !o.SkipKamelets {
if err := o.uninstallKamelets(ctx, c); err != nil {
return err
}
- fmt.Printf("Camel K platform Kamelets removed from namespace
%s\n", o.Namespace)
+ fmt.Fprintf(cmd.OutOrStdout(), "Camel K platform Kamelets
removed from namespace %s\n", o.Namespace)
Review comment:
Could be replaced with `Fprintln`.
##########
File path: pkg/cmd/uninstall.go
##########
@@ -209,71 +209,71 @@ func (o *uninstallCmdOptions)
uninstallClusterWideResources(ctx context.Context,
if !o.SkipClusterRoleBindings || o.UninstallAll {
if err := o.uninstallClusterRoleBindings(ctx, c); err != nil {
if k8serrors.IsForbidden(err) {
- return createActionNotAuthorizedError()
+ return createActionNotAuthorizedError(cmd)
}
return err
}
- fmt.Printf("Camel K Cluster Role Bindings removed from
cluster\n")
+ fmt.Fprintf(cmd.OutOrStdout(), "Camel K Cluster Role Bindings
removed from cluster\n")
}
if !o.SkipClusterRoles || o.UninstallAll {
if err := o.uninstallClusterRoles(ctx, c); err != nil {
if k8serrors.IsForbidden(err) {
- return createActionNotAuthorizedError()
+ return createActionNotAuthorizedError(cmd)
}
return err
}
- fmt.Printf("Camel K Cluster Roles removed from cluster\n")
+ fmt.Fprintf(cmd.OutOrStdout(), "Camel K Cluster Roles removed
from cluster\n")
}
return nil
}
-func (o *uninstallCmdOptions) uninstallNamespaceRoles(ctx context.Context, c
client.Client) error {
+func (o *uninstallCmdOptions) uninstallNamespaceRoles(cmd *cobra.Command, ctx
context.Context, c client.Client) error {
if !o.SkipRoleBindings {
if err := o.uninstallRoleBindings(ctx, c); err != nil {
return err
}
- fmt.Printf("Camel K Role Bindings removed from namespace %s\n",
o.Namespace)
+ fmt.Fprintf(cmd.OutOrStdout(), "Camel K Role Bindings removed
from namespace %s\n", o.Namespace)
}
if !o.SkipRoles {
if err := o.uninstallRoles(ctx, c); err != nil {
return err
}
- fmt.Printf("Camel K Roles removed from namespace %s\n",
o.Namespace)
+ fmt.Fprintf(cmd.OutOrStdout(), "Camel K Roles removed from
namespace %s\n", o.Namespace)
}
if !o.SkipServiceAccounts {
if err := o.uninstallServiceAccounts(ctx, c); err != nil {
return err
}
- fmt.Printf("Camel K Service Accounts removed from namespace
%s\n", o.Namespace)
+ fmt.Fprintf(cmd.OutOrStdout(), "Camel K Service Accounts
removed from namespace %s\n", o.Namespace)
}
return nil
}
-func (o *uninstallCmdOptions) uninstallNamespaceResources(ctx context.Context,
c client.Client) error {
+func (o *uninstallCmdOptions) uninstallNamespaceResources(cmd *cobra.Command,
ctx context.Context, c client.Client) error {
if !o.SkipConfigMaps {
if err := o.uninstallConfigMaps(ctx, c); err != nil {
return err
}
- fmt.Printf("Camel K Config Maps removed from namespace %s\n",
o.Namespace)
+ fmt.Fprintf(cmd.OutOrStdout(), "Camel K Config Maps removed
from namespace %s\n", o.Namespace)
}
if !o.SkipRegistrySecret {
if err := o.uninstallRegistrySecret(ctx, c); err != nil {
return err
}
- fmt.Printf("Camel K Registry Secret removed from namespace
%s\n", o.Namespace)
+ fmt.Fprintf(cmd.OutOrStdout(), "Camel K Registry Secret removed
from namespace %s\n", o.Namespace)
Review comment:
Could be replaced with `Fprintln`.
##########
File path: pkg/cmd/uninstall.go
##########
@@ -186,21 +186,21 @@ func (o *uninstallCmdOptions) uninstallOperator(ctx
context.Context, c client.Cl
return nil
}
-func (o *uninstallCmdOptions) uninstallClusterWideResources(ctx
context.Context, c client.Client, namespace string) error {
+func (o *uninstallCmdOptions) uninstallClusterWideResources(cmd
*cobra.Command, ctx context.Context, c client.Client, namespace string) error {
if !o.SkipCrd || o.UninstallAll {
if err := o.uninstallCrd(ctx, c); err != nil {
if k8serrors.IsForbidden(err) {
- return createActionNotAuthorizedError()
+ return createActionNotAuthorizedError(cmd)
}
return err
}
- fmt.Printf("Camel K Custom Resource Definitions removed from
cluster\n")
+ fmt.Fprintf(cmd.OutOrStdout(), "Camel K Custom Resource
Definitions removed from cluster\n")
Review comment:
Could be replaced with `Fprintln`.
##########
File path: e2e/support/test_support.go
##########
@@ -1719,9 +1719,9 @@ func UserCleanup() {
command.Stderr = os.Stderr
command.Stdout = os.Stdout
if err := command.Run(); err != nil {
- fmt.Printf("An error occurred during user cleanup
command execution: %v\n", err)
+ fmt.Fprintf(command.Stderr, "An error occurred during
user cleanup command execution: %v\n", err)
} else {
- fmt.Printf("User cleanup command completed
successfully\n")
+ fmt.Fprintf(command.Stdout, "User cleanup command
completed successfully\n")
Review comment:
Could be replaced with `Fprintln`.
##########
File path: pkg/cmd/uninstall.go
##########
@@ -209,71 +209,71 @@ func (o *uninstallCmdOptions)
uninstallClusterWideResources(ctx context.Context,
if !o.SkipClusterRoleBindings || o.UninstallAll {
if err := o.uninstallClusterRoleBindings(ctx, c); err != nil {
if k8serrors.IsForbidden(err) {
- return createActionNotAuthorizedError()
+ return createActionNotAuthorizedError(cmd)
}
return err
}
- fmt.Printf("Camel K Cluster Role Bindings removed from
cluster\n")
+ fmt.Fprintf(cmd.OutOrStdout(), "Camel K Cluster Role Bindings
removed from cluster\n")
}
if !o.SkipClusterRoles || o.UninstallAll {
if err := o.uninstallClusterRoles(ctx, c); err != nil {
if k8serrors.IsForbidden(err) {
- return createActionNotAuthorizedError()
+ return createActionNotAuthorizedError(cmd)
}
return err
}
- fmt.Printf("Camel K Cluster Roles removed from cluster\n")
+ fmt.Fprintf(cmd.OutOrStdout(), "Camel K Cluster Roles removed
from cluster\n")
}
return nil
}
-func (o *uninstallCmdOptions) uninstallNamespaceRoles(ctx context.Context, c
client.Client) error {
+func (o *uninstallCmdOptions) uninstallNamespaceRoles(cmd *cobra.Command, ctx
context.Context, c client.Client) error {
if !o.SkipRoleBindings {
if err := o.uninstallRoleBindings(ctx, c); err != nil {
return err
}
- fmt.Printf("Camel K Role Bindings removed from namespace %s\n",
o.Namespace)
+ fmt.Fprintf(cmd.OutOrStdout(), "Camel K Role Bindings removed
from namespace %s\n", o.Namespace)
}
if !o.SkipRoles {
if err := o.uninstallRoles(ctx, c); err != nil {
return err
}
- fmt.Printf("Camel K Roles removed from namespace %s\n",
o.Namespace)
+ fmt.Fprintf(cmd.OutOrStdout(), "Camel K Roles removed from
namespace %s\n", o.Namespace)
}
if !o.SkipServiceAccounts {
if err := o.uninstallServiceAccounts(ctx, c); err != nil {
return err
}
- fmt.Printf("Camel K Service Accounts removed from namespace
%s\n", o.Namespace)
+ fmt.Fprintf(cmd.OutOrStdout(), "Camel K Service Accounts
removed from namespace %s\n", o.Namespace)
}
return nil
}
-func (o *uninstallCmdOptions) uninstallNamespaceResources(ctx context.Context,
c client.Client) error {
+func (o *uninstallCmdOptions) uninstallNamespaceResources(cmd *cobra.Command,
ctx context.Context, c client.Client) error {
if !o.SkipConfigMaps {
if err := o.uninstallConfigMaps(ctx, c); err != nil {
return err
}
- fmt.Printf("Camel K Config Maps removed from namespace %s\n",
o.Namespace)
+ fmt.Fprintf(cmd.OutOrStdout(), "Camel K Config Maps removed
from namespace %s\n", o.Namespace)
Review comment:
Could be replaced with `Fprintln`.
##########
File path: pkg/cmd/bind.go
##########
@@ -219,9 +219,9 @@ func (o *bindCmdOptions) run(cmd *cobra.Command, args
[]string) error {
}
if !existed {
- fmt.Printf("kamelet binding \"%s\" created\n", name)
+ fmt.Fprintf(cmd.OutOrStdout(), "kamelet binding \"%s\"
created\n", name)
Review comment:
Could be replaced with `Fprintln`.
##########
File path: pkg/cmd/bind.go
##########
@@ -219,9 +219,9 @@ func (o *bindCmdOptions) run(cmd *cobra.Command, args
[]string) error {
}
if !existed {
- fmt.Printf("kamelet binding \"%s\" created\n", name)
+ fmt.Fprintf(cmd.OutOrStdout(), "kamelet binding \"%s\"
created\n", name)
} else {
- fmt.Printf("kamelet binding \"%s\" updated\n", name)
+ fmt.Fprintf(cmd.OutOrStdout(), "kamelet binding \"%s\"
updated\n", name)
Review comment:
Could be replaced with `Fprintln`.
##########
File path: pkg/cmd/run.go
##########
@@ -615,10 +615,10 @@ func (o *runCmdOptions) createOrUpdateIntegration(cmd
*cobra.Command, c client.C
if existing == nil {
err = c.Create(o.Context, integration)
- fmt.Printf("Integration \"%s\" created\n", name)
+ fmt.Fprintf(cmd.OutOrStdout(), "Integration \"%s\" created\n",
name)
} else {
err = c.Patch(o.Context, integration,
ctrl.MergeFromWithOptions(existing, ctrl.MergeFromWithOptimisticLock{}))
- fmt.Printf("Integration \"%s\" updated\n", name)
+ fmt.Fprintf(cmd.OutOrStdout(), "Integration \"%s\" updated\n",
name)
Review comment:
Could be replaced with `Fprintln`.
##########
File path: pkg/cmd/uninstall.go
##########
@@ -209,71 +209,71 @@ func (o *uninstallCmdOptions)
uninstallClusterWideResources(ctx context.Context,
if !o.SkipClusterRoleBindings || o.UninstallAll {
if err := o.uninstallClusterRoleBindings(ctx, c); err != nil {
if k8serrors.IsForbidden(err) {
- return createActionNotAuthorizedError()
+ return createActionNotAuthorizedError(cmd)
}
return err
}
- fmt.Printf("Camel K Cluster Role Bindings removed from
cluster\n")
+ fmt.Fprintf(cmd.OutOrStdout(), "Camel K Cluster Role Bindings
removed from cluster\n")
}
if !o.SkipClusterRoles || o.UninstallAll {
if err := o.uninstallClusterRoles(ctx, c); err != nil {
if k8serrors.IsForbidden(err) {
- return createActionNotAuthorizedError()
+ return createActionNotAuthorizedError(cmd)
}
return err
}
- fmt.Printf("Camel K Cluster Roles removed from cluster\n")
+ fmt.Fprintf(cmd.OutOrStdout(), "Camel K Cluster Roles removed
from cluster\n")
}
return nil
}
-func (o *uninstallCmdOptions) uninstallNamespaceRoles(ctx context.Context, c
client.Client) error {
+func (o *uninstallCmdOptions) uninstallNamespaceRoles(cmd *cobra.Command, ctx
context.Context, c client.Client) error {
if !o.SkipRoleBindings {
if err := o.uninstallRoleBindings(ctx, c); err != nil {
return err
}
- fmt.Printf("Camel K Role Bindings removed from namespace %s\n",
o.Namespace)
+ fmt.Fprintf(cmd.OutOrStdout(), "Camel K Role Bindings removed
from namespace %s\n", o.Namespace)
}
if !o.SkipRoles {
if err := o.uninstallRoles(ctx, c); err != nil {
return err
}
- fmt.Printf("Camel K Roles removed from namespace %s\n",
o.Namespace)
+ fmt.Fprintf(cmd.OutOrStdout(), "Camel K Roles removed from
namespace %s\n", o.Namespace)
Review comment:
Could be replaced with `Fprintln`.
##########
File path: pkg/cmd/run_help.go
##########
@@ -43,20 +44,20 @@ func hashFrom(contents ...[]byte) string {
return fmt.Sprintf("%x", hash.Sum(nil))
}
-func parseConfigAndGenCm(ctx context.Context, c client.Client, config
*resource.Config, integration *v1.Integration, enableCompression bool)
(*corev1.ConfigMap, error) {
+func parseConfigAndGenCm(ctx context.Context, cmd *cobra.Command, c
client.Client, config *resource.Config, integration *v1.Integration,
enableCompression bool) (*corev1.ConfigMap, error) {
switch config.StorageType() {
case resource.StorageTypeConfigmap:
cm := kubernetes.LookupConfigmap(ctx, c, integration.Namespace,
config.Name())
if cm == nil {
- fmt.Printf("Warn: %s Configmap not found in %s
namespace, make sure to provide it before the Integration can run\n",
+ fmt.Fprintf(cmd.ErrOrStderr(), "Warn: %s Configmap not
found in %s namespace, make sure to provide it before the Integration can
run\n",
Review comment:
Could be replaced with `Fprintln`.
##########
File path: pkg/cmd/uninstall.go
##########
@@ -209,71 +209,71 @@ func (o *uninstallCmdOptions)
uninstallClusterWideResources(ctx context.Context,
if !o.SkipClusterRoleBindings || o.UninstallAll {
if err := o.uninstallClusterRoleBindings(ctx, c); err != nil {
if k8serrors.IsForbidden(err) {
- return createActionNotAuthorizedError()
+ return createActionNotAuthorizedError(cmd)
}
return err
}
- fmt.Printf("Camel K Cluster Role Bindings removed from
cluster\n")
+ fmt.Fprintf(cmd.OutOrStdout(), "Camel K Cluster Role Bindings
removed from cluster\n")
}
if !o.SkipClusterRoles || o.UninstallAll {
if err := o.uninstallClusterRoles(ctx, c); err != nil {
if k8serrors.IsForbidden(err) {
- return createActionNotAuthorizedError()
+ return createActionNotAuthorizedError(cmd)
}
return err
}
- fmt.Printf("Camel K Cluster Roles removed from cluster\n")
+ fmt.Fprintf(cmd.OutOrStdout(), "Camel K Cluster Roles removed
from cluster\n")
}
return nil
}
-func (o *uninstallCmdOptions) uninstallNamespaceRoles(ctx context.Context, c
client.Client) error {
+func (o *uninstallCmdOptions) uninstallNamespaceRoles(cmd *cobra.Command, ctx
context.Context, c client.Client) error {
if !o.SkipRoleBindings {
if err := o.uninstallRoleBindings(ctx, c); err != nil {
return err
}
- fmt.Printf("Camel K Role Bindings removed from namespace %s\n",
o.Namespace)
+ fmt.Fprintf(cmd.OutOrStdout(), "Camel K Role Bindings removed
from namespace %s\n", o.Namespace)
Review comment:
Could be replaced with `Fprintln`.
##########
File path: pkg/cmd/util_containerization.go
##########
@@ -192,7 +196,7 @@ func createAndBuildIntegrationImage(ctx context.Context,
containerRegistry strin
cmd.Stdout = stdout
// Output executed command.
- fmt.Printf("Executing: %s\n", strings.Join(cmd.Args, " "))
+ fmt.Fprintf(cmd.Stdout, "Executing: %s\n", strings.Join(cmd.Args, " "))
Review comment:
Could be replaced with `Fprintln`.
##########
File path: pkg/cmd/run.go
##########
@@ -615,10 +615,10 @@ func (o *runCmdOptions) createOrUpdateIntegration(cmd
*cobra.Command, c client.C
if existing == nil {
err = c.Create(o.Context, integration)
- fmt.Printf("Integration \"%s\" created\n", name)
+ fmt.Fprintf(cmd.OutOrStdout(), "Integration \"%s\" created\n",
name)
Review comment:
Could be replaced with `Fprintln`.
##########
File path: pkg/cmd/util_containerization.go
##########
@@ -94,8 +94,12 @@ func createAndBuildBaseImage(ctx context.Context) error {
args := docker.BuildBaseImageArgs()
cmd := exec.CommandContext(ctx, "docker", args...)
+ // Set stdout and stderr.
+ cmd.Stdout = stdout
+ cmd.Stderr = stderr
+
// Output executed command.
- fmt.Printf("Executing: %s\n", strings.Join(cmd.Args, " "))
+ fmt.Fprintf(cmd.Stdout, "Executing: %s\n", strings.Join(cmd.Args, " "))
Review comment:
Could be replaced with `Fprintln`.
##########
File path: pkg/cmd/uninstall.go
##########
@@ -209,71 +209,71 @@ func (o *uninstallCmdOptions)
uninstallClusterWideResources(ctx context.Context,
if !o.SkipClusterRoleBindings || o.UninstallAll {
if err := o.uninstallClusterRoleBindings(ctx, c); err != nil {
if k8serrors.IsForbidden(err) {
- return createActionNotAuthorizedError()
+ return createActionNotAuthorizedError(cmd)
}
return err
}
- fmt.Printf("Camel K Cluster Role Bindings removed from
cluster\n")
+ fmt.Fprintf(cmd.OutOrStdout(), "Camel K Cluster Role Bindings
removed from cluster\n")
}
if !o.SkipClusterRoles || o.UninstallAll {
if err := o.uninstallClusterRoles(ctx, c); err != nil {
if k8serrors.IsForbidden(err) {
- return createActionNotAuthorizedError()
+ return createActionNotAuthorizedError(cmd)
}
return err
}
- fmt.Printf("Camel K Cluster Roles removed from cluster\n")
+ fmt.Fprintf(cmd.OutOrStdout(), "Camel K Cluster Roles removed
from cluster\n")
}
return nil
}
-func (o *uninstallCmdOptions) uninstallNamespaceRoles(ctx context.Context, c
client.Client) error {
+func (o *uninstallCmdOptions) uninstallNamespaceRoles(cmd *cobra.Command, ctx
context.Context, c client.Client) error {
if !o.SkipRoleBindings {
if err := o.uninstallRoleBindings(ctx, c); err != nil {
return err
}
- fmt.Printf("Camel K Role Bindings removed from namespace %s\n",
o.Namespace)
+ fmt.Fprintf(cmd.OutOrStdout(), "Camel K Role Bindings removed
from namespace %s\n", o.Namespace)
}
if !o.SkipRoles {
if err := o.uninstallRoles(ctx, c); err != nil {
return err
}
- fmt.Printf("Camel K Roles removed from namespace %s\n",
o.Namespace)
+ fmt.Fprintf(cmd.OutOrStdout(), "Camel K Roles removed from
namespace %s\n", o.Namespace)
}
if !o.SkipServiceAccounts {
if err := o.uninstallServiceAccounts(ctx, c); err != nil {
return err
}
- fmt.Printf("Camel K Service Accounts removed from namespace
%s\n", o.Namespace)
+ fmt.Fprintf(cmd.OutOrStdout(), "Camel K Service Accounts
removed from namespace %s\n", o.Namespace)
Review comment:
Could be replaced with `Fprintln`.
##########
File path: pkg/cmd/version.go
##########
@@ -171,15 +171,15 @@ func operatorVersion(ctx context.Context, c
client.Client, namespace string) (st
return infos[infoVersion], nil
}
-func compatibleVersions(aVersion, bVersion string) bool {
+func compatibleVersions(aVersion, bVersion string, cmd *cobra.Command) bool {
a, err := semver.NewVersion(aVersion)
if err != nil {
- fmt.Printf("Could not parse %s (error: %s)\n", a, err)
+ fmt.Fprintf(cmd.ErrOrStderr(), "Could not parse %s (error:
%s)\n", a, err)
Review comment:
Could be replaced with `Fprintln`.
##########
File path: pkg/cmd/util_containerization.go
##########
@@ -225,7 +229,7 @@ func runIntegrationImage(ctx context.Context, image string,
stdout, stderr io.Wr
cmd.Stdout = stdout
// Output executed command.
- fmt.Printf("Executing: %s\n", strings.Join(cmd.Args, " "))
+ fmt.Fprintf(cmd.Stdout, "Executing: %s\n", strings.Join(cmd.Args, " "))
Review comment:
Could be replaced with `Fprintln`.
##########
File path: pkg/cmd/util_dependencies.go
##########
@@ -230,37 +231,37 @@ func createCamelCatalog(ctx context.Context)
(*camel.RuntimeCatalog, error) {
return catalog, nil
}
-func outputDependencies(dependencies []string, format string) error {
+func outputDependencies(dependencies []string, format string, cmd
*cobra.Command) error {
if format != "" {
- err := printDependencies(format, dependencies)
+ err := printDependencies(format, dependencies, cmd)
if err != nil {
return err
}
} else {
// Print output in text form
- fmt.Println("dependencies:")
+ fmt.Fprintln(cmd.OutOrStdout(), "dependencies:")
for _, dep := range dependencies {
- fmt.Printf("%v\n", dep)
+ fmt.Fprintf(cmd.OutOrStdout(), "%v\n", dep)
Review comment:
Could be replaced with `Fprintln`.
##########
File path: pkg/cmd/version.go
##########
@@ -171,15 +171,15 @@ func operatorVersion(ctx context.Context, c
client.Client, namespace string) (st
return infos[infoVersion], nil
}
-func compatibleVersions(aVersion, bVersion string) bool {
+func compatibleVersions(aVersion, bVersion string, cmd *cobra.Command) bool {
a, err := semver.NewVersion(aVersion)
if err != nil {
- fmt.Printf("Could not parse %s (error: %s)\n", a, err)
+ fmt.Fprintf(cmd.ErrOrStderr(), "Could not parse %s (error:
%s)\n", a, err)
return false
}
b, err := semver.NewVersion(bVersion)
if err != nil {
- fmt.Printf("Could not parse %s (error: %s)\n", b, err)
+ fmt.Fprintf(cmd.ErrOrStderr(), "Could not parse %s (error:
%s)\n", b, err)
Review comment:
Could be replaced with `Fprintln`.
##########
File path: pkg/cmd/util_commands.go
##########
@@ -108,7 +108,7 @@ func RunLocalIntegrationRunCommand(ctx context.Context,
properties []string, dep
}
// Output command we are about to run.
- fmt.Printf("Executing: %s\n", strings.Join(cmd.Args, " "))
+ fmt.Fprintf(cmd.Stdout, "Executing: %s\n", strings.Join(cmd.Args, " "))
Review comment:
Could be replaced with `Fprintln`.
##########
File path: e2e/support/test_support.go
##########
@@ -1719,9 +1719,9 @@ func UserCleanup() {
command.Stderr = os.Stderr
command.Stdout = os.Stdout
if err := command.Run(); err != nil {
- fmt.Printf("An error occurred during user cleanup
command execution: %v\n", err)
+ fmt.Fprintf(command.Stderr, "An error occurred during
user cleanup command execution: %v\n", err)
Review comment:
In that case, I think it's more appropriate to use the test logger with
`t.Logf`.
##########
File path: e2e/support/test_support.go
##########
@@ -1719,9 +1719,9 @@ func UserCleanup() {
command.Stderr = os.Stderr
command.Stdout = os.Stdout
if err := command.Run(); err != nil {
- fmt.Printf("An error occurred during user cleanup
command execution: %v\n", err)
+ fmt.Fprintf(command.Stderr, "An error occurred during
user cleanup command execution: %v\n", err)
} else {
- fmt.Printf("User cleanup command completed
successfully\n")
+ fmt.Fprintf(command.Stdout, "User cleanup command
completed successfully\n")
Review comment:
In that case, I think it's more appropriate to use the test logger with
`t.Logf`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]