Skip to content

Commit 2b733d1

Browse files
authored
fix: correct function signature and remove unused app proxy code (#779)
## What * Updated the getAppProxyClient function to accept a pointer for the runtime parameter. * Removed unused app proxy version retrieval logic from the newVersionCommand function to clean up the code and improve maintainability. ## Why using the pointer ensures the appproxy Client connects to the runtime supplied in the `--runtime` flag ## Notes the original issue originated from #757
1 parent 3830f1f commit 2b733d1

File tree

3 files changed

+4
-32
lines changed

3 files changed

+4
-32
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
VERSION=v0.2.1
1+
VERSION=v0.2.2
22

33
OUT_DIR=dist
44
YEAR?=$(shell date +"%Y")

cmd/commands/integrations.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ func newIntegrationCommand() *cobra.Command {
6767
Use: "integration",
6868
Aliases: []string{"integrations", "intg"},
6969
Short: "Manage integrations with git providers, container registries and more",
70-
PersistentPreRunE: getAppProxyClient(runtime, &apClient),
70+
PersistentPreRunE: getAppProxyClient(&runtime, &apClient),
7171
Args: cobra.NoArgs, // Workaround for subcommand usage errors. See: https://github.com/spf13/cobra/issues/706
7272
Run: func(cmd *cobra.Command, args []string) {
7373
cmd.HelpFunc()(cmd, args)
@@ -405,15 +405,15 @@ func runGitIntegrationDeregisterCommand(ctx context.Context, apClient ap.AppProx
405405
return nil
406406
}
407407

408-
func getAppProxyClient(runtime string, apClient *ap.AppProxyAPI) func(*cobra.Command, []string) error {
408+
func getAppProxyClient(runtime *string, apClient *ap.AppProxyAPI) func(*cobra.Command, []string) error {
409409
return func(cmd *cobra.Command, args []string) error {
410410
ctx := cmd.Context()
411411

412412
if err := cfConfig.RequireAuthentication(cmd, args); err != nil {
413413
return err
414414
}
415415

416-
runtimeName, err := ensureRuntimeName(ctx, []string{runtime}, nil)
416+
runtimeName, err := ensureRuntimeName(ctx, []string{*runtime}, nil)
417417
if err != nil {
418418
return fmt.Errorf("failed to get runtime name: %w", err)
419419
}

cmd/commands/version.go

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,8 @@ package commands
1717
import (
1818
"fmt"
1919

20-
"github.com/codefresh-io/cli-v2/internal/log"
2120
"github.com/codefresh-io/cli-v2/internal/store"
2221

23-
ap "github.com/codefresh-io/go-sdk/pkg/appproxy"
2422
"github.com/spf13/cobra"
2523
)
2624

@@ -44,32 +42,6 @@ func newVersionCommand() *cobra.Command {
4442
fmt.Printf(" GoVersion: %s\n", s.Version.GoVersion)
4543
fmt.Printf(" GoCompiler: %s\n", s.Version.GoCompiler)
4644
fmt.Printf(" Platform: %s\n", s.Version.Platform)
47-
48-
// try to get app proxy version info
49-
if err := cfConfig.Load(cmd, args); err != nil {
50-
return err
51-
}
52-
53-
runtime := ""
54-
var apClient ap.AppProxyAPI
55-
56-
if err := getAppProxyClient(runtime, &apClient)(cmd, args); err != nil {
57-
// can't create client, print error only if in debug level
58-
log.G(cmd.Context()).Debug(fmt.Errorf("failed to build app proxy client: %w", err))
59-
return nil
60-
}
61-
62-
apInfo, err := apClient.VersionInfo().VersionInfo(cmd.Context())
63-
if err != nil {
64-
// can't get version, print error only if in debug level
65-
log.G(cmd.Context()).Debug(fmt.Errorf("failed to get app proxy version info: %w", err))
66-
return nil
67-
}
68-
69-
fmt.Printf("\nAppProxy:\n")
70-
fmt.Printf(" Version: %s\n", apInfo.Version)
71-
fmt.Printf(" PlatformHost: %s\n", apInfo.PlatformHost)
72-
fmt.Printf(" PlatformVersion: %s\n", apInfo.PlatformVersion)
7345
} else {
7446
fmt.Printf("%+s\n", s.Version.Version)
7547
}

0 commit comments

Comments
 (0)