Skip to content

Commit

Permalink
APIGOV-23548 - fix issue in building proxy endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
jcollins-axway committed Sep 22, 2022
1 parent c661ee0 commit 8038942
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
7 changes: 4 additions & 3 deletions discovery/pkg/apigee/pollproxiesjob.go
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,7 @@ func (j *pollProxiesJob) getVirtualHostURLs(ctx context.Context) context.Context
logger := getLoggerFromContext(ctx)
revision := ctx.Value(revNameField).(*models.ApiProxyRevision)
envName := getStringFromContext(ctx, envNameField)
proxyName := getStringFromContext(ctx, proxyNameField)

// attempt to get the spec from the endpoints the revision is hosted on
allURLs := []string{}
Expand All @@ -251,7 +252,7 @@ func (j *pollProxiesJob) getVirtualHostURLs(ctx context.Context) context.Context
logger.WithError(err).Debug("could not get virtual host details")
continue
}
urls := urlsFromVirtualHost(virtualHost)
urls := urlsFromVirtualHost(virtualHost, proxyName)
allURLs = append(allURLs, urls...)
}

Expand Down Expand Up @@ -321,8 +322,8 @@ func (j *pollProxiesJob) publish(ctx context.Context) {
cacheKey := createProxyCacheKey(getStringFromContext(ctx, proxyNameField), envName)

// Check DiscoveryCache for API
j.pubLock.Lock() // only publish one at a time
defer j.pubLock.Unlock()
// j.pubLock.Lock() // only publish one at a time
// defer j.pubLock.Unlock()
value := agent.GetAttributeOnPublishedAPIByID(revision.Name, fmt.Sprintf("%s-hash", envName))

if !agent.IsAPIPublishedByID(revision.Name) {
Expand Down
7 changes: 6 additions & 1 deletion discovery/pkg/apigee/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"fmt"
"net/url"
"strconv"
"strings"

"github.com/Axway/agent-sdk/pkg/apic"
"github.com/Axway/agent-sdk/pkg/util/log"
Expand All @@ -19,7 +20,7 @@ func isFullURL(urlString string) bool {
return false
}

func urlsFromVirtualHost(virtualHost *models.VirtualHost) []string {
func urlsFromVirtualHost(virtualHost *models.VirtualHost, proxyName string) []string {
urls := []string{}

scheme := "http"
Expand All @@ -39,6 +40,10 @@ func urlsFromVirtualHost(virtualHost *models.VirtualHost) []string {
if port == "" {
thisURL = fmt.Sprintf("%s://%s", scheme, host)
}
if virtualHost.BaseUrl != "/" {
thisURL += virtualHost.BaseUrl
}
thisURL += "/" + strings.ToLower(proxyName)
urls = append(urls, thisURL)
}

Expand Down

0 comments on commit 8038942

Please sign in to comment.