Skip to content

Commit

Permalink
fix PR comments
Browse files Browse the repository at this point in the history
  • Loading branch information
andrii-codefresh committed Dec 17, 2024
1 parent c06ce89 commit fc0addc
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
3 changes: 0 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,3 @@ replace (
k8s.io/sample-cli-plugin => k8s.io/sample-cli-plugin v0.29.6
k8s.io/sample-controller => k8s.io/sample-controller v0.29.6
)

// TODO:CR-26144: Remove alias
replace github.com/codefresh-io/octopus-argo => /Users/andrii/go/src/github.com/codefresh-io/octopus-argo
14 changes: 8 additions & 6 deletions pkg/sources_server_client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,16 @@ import (
"fmt"
"io"
"net/http"
netUrl "net/url"

log "github.com/sirupsen/logrus"

"github.com/argoproj/argo-cd/v2/pkg/apis/application/v1alpha1"
)

type VersionPayload struct {
app *v1alpha1.Application
revision *string
App v1alpha1.Application `json:"app"`
Revision string `json:"revision"`
}

type DependenciesMap struct {
Expand All @@ -37,7 +38,7 @@ type sourceServerClient struct {
}

type SourceServerClientInteface interface {
GetAppVersion(app *v1alpha1.Application, revisions *string) *AppVersionResult
GetAppVersion(app *v1alpha1.Application, revision *string) *AppVersionResult
}

func (c *sourceServerClient) sendRequest(method, url string, payload interface{}) ([]byte, error) {
Expand All @@ -50,7 +51,8 @@ func (c *sourceServerClient) sendRequest(method, url string, payload interface{}
}
}

req, err := http.NewRequest(method, fmt.Sprintf("%s%s", c.clientConfig.BaseURL, url), bytes.NewBuffer(requestBody))
fullURL, err := netUrl.JoinPath(c.clientConfig.BaseURL, url)
req, err := http.NewRequest(method, fullURL, bytes.NewBuffer(requestBody))
if err != nil {
return nil, fmt.Errorf("error creating request: %w", err)
}
Expand All @@ -77,8 +79,8 @@ func (c *sourceServerClient) sendRequest(method, url string, payload interface{}
return body, nil
}

func (c *sourceServerClient) GetAppVersion(app *v1alpha1.Application, revisions *string) *AppVersionResult {
appVersionResult, err := c.sendRequest("POST", "/getAppVersion", VersionPayload{app: app, revision: revision})
func (c *sourceServerClient) GetAppVersion(app *v1alpha1.Application, revision *string) *AppVersionResult {
appVersionResult, err := c.sendRequest("POST", "/getAppVersion", VersionPayload{App: *app, Revision: *revision})
if err != nil {
log.Errorf("error getting app version: %v", err)
return nil
Expand Down

0 comments on commit fc0addc

Please sign in to comment.