Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix internal map on api updates and refactor api delete #2052

Merged
merged 5 commits into from
Apr 1, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix gql fail
  • Loading branch information
AmaliMatharaarachchi committed Mar 29, 2024
commit 5bb7d51252a7860be18827b68092cc50292d29a5
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
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
Loading