Skip to content

Commit

Permalink
fix gql fail
Browse files Browse the repository at this point in the history
  • Loading branch information
AmaliMatharaarachchi committed Mar 29, 2024
1 parent 34b9b4e commit 5bb7d51
Show file tree
Hide file tree
Showing 4 changed files with 1 addition and 9 deletions.
6 changes: 0 additions & 6 deletions adapter/internal/discovery/xds/semantic_versioning.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,6 @@ func updateOldRegex(org string, oldSemVersions []oldSemVersion) {
}
}
}
logger.LoggerAPI.Error(oldSelectedSemVersion)
if oldSelectedSemVersion == nil {
continue
}
Expand All @@ -157,27 +156,22 @@ func updateOldRegex(org string, oldSemVersions []oldSemVersion) {
updateMinor := oldSelectedSemVersion.OldMinorSemVersion != nil && api.adapterInternalAPI.GetVersion() ==
oldSelectedSemVersion.OldMinorSemVersion.Version

// apiSemVersion, _ := semantic_version.ValidateAndGetVersionComponents(api.adapterInternalAPI.GetVersion())
for _, route := range api.routes {
regex := route.GetMatch().GetSafeRegex().GetRegex()
regexRewritePattern := route.GetRoute().GetRegexRewrite().GetPattern().GetRegex()
if updateMajor {
logger.LoggerAPI.Error(166, regex)
regex = strings.Replace(regex, GetMajorMinorVersionRangeRegex(oldSelectedSemVersion.OldMajorSemVersion),
GetMinorVersionRangeRegex(oldSelectedSemVersion.OldMajorSemVersion), 1)
regexRewritePattern = strings.Replace(regexRewritePattern,
GetMajorMinorVersionRangeRegex(oldSelectedSemVersion.OldMajorSemVersion),
GetMinorVersionRangeRegex(oldSelectedSemVersion.OldMajorSemVersion), 1)
logger.LoggerAPI.Error(166, regex)
}
if updateMinor {
logger.LoggerAPI.Error(175, regex)
regex = strings.Replace(regex, GetMinorVersionRangeRegex(oldSelectedSemVersion.OldMinorSemVersion),
GetVersionMatchRegex(oldSelectedSemVersion.OldMinorSemVersion.Version), 1)
regexRewritePattern = strings.Replace(regexRewritePattern,
GetMinorVersionRangeRegex(oldSelectedSemVersion.OldMinorSemVersion),
GetVersionMatchRegex(oldSelectedSemVersion.OldMinorSemVersion.Version), 1)
logger.LoggerAPI.Error(180, regex)
}
pathSpecifier := &routev3.RouteMatch_SafeRegex{
SafeRegex: &matcherv3.RegexMatcher{
Expand Down
1 change: 0 additions & 1 deletion adapter/internal/discovery/xds/semantic_versioning_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,6 @@ func TestUpdateRoutingRulesOnAPIUpdate(t *testing.T) {
finalRegex: apiID1ResourcePath,
finalRewrite: apiID1ResourcePath,
},
// Expected final regex: ^/test-api/v1\.0/orders([/]{0,1}), Got: ^/test-api/v1(?:\.0)?/orders([/]{0,1})
{
name: "Create an API with major and minor version",
organizationID: "org1",
Expand Down
2 changes: 1 addition & 1 deletion adapter/internal/operator/synchronizer/gql_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ func generateGQLAdapterInternalAPI(apiState APIState, gqlRoute *GQLRouteState, e

// getVhostForAPI returns the vHosts related to an API.
func getVhostsForGQLAPI(gqlRoute *v1alpha2.GQLRoute) map[string]struct{} {
var vHosts map[string]struct{}
vHosts := make(map[string]struct{})
for _, hostName := range gqlRoute.Spec.Hostnames {
vHosts[string(hostName)] = struct{}{}
}
Expand Down
1 change: 0 additions & 1 deletion adapter/internal/operator/synchronizer/rest_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,6 @@ func generateAdapterInternalAPI(apiState APIState, httpRoute *HTTPRouteState, en
// getVhostForAPI returns the vHosts related to an API.
func getVhostsForAPI(httpRoute *gwapiv1b1.HTTPRoute) map[string]struct{} {
vHosts := make(map[string]struct{})
loggers.LoggerAPI.Error("httpRoute.Spec.Hostnames: ", httpRoute.Spec.Hostnames)
for _, hostName := range httpRoute.Spec.Hostnames {
vHosts[string(hostName)] = struct{}{}
}
Expand Down

0 comments on commit 5bb7d51

Please sign in to comment.