Skip to content

Commit

Permalink
address lint issue
Browse files Browse the repository at this point in the history
Signed-off-by: Kensei Nakada <handbomusic@gmail.com>
  • Loading branch information
sanposhiho committed Jul 27, 2024
1 parent 22e2e2d commit 0eed511
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 10 deletions.
10 changes: 5 additions & 5 deletions internal/gatewayapi/route.go
Original file line number Diff line number Diff line change
Expand Up @@ -320,28 +320,28 @@ func (t *Translator) processHTTPRouteRule(httpRoute *HTTPRouteContext, ruleIdx i
return nil, fmt.Errorf("idle timeout is not supported in envoy gateway")

Check warning on line 320 in internal/gatewayapi/route.go

View check run for this annotation

Codecov / codecov/patch

internal/gatewayapi/route.go#L319-L320

Added lines #L319 - L320 were not covered by tests
}

if rule.SessionPersistence.Type == nil || // Cookie-based session persistence is default.
*rule.SessionPersistence.Type == gwapiv1.CookieBasedSessionPersistence {
switch {

Check warning on line 323 in internal/gatewayapi/route.go

View check run for this annotation

Codecov / codecov/patch

internal/gatewayapi/route.go#L323

Added line #L323 was not covered by tests
case rule.SessionPersistence.Type == nil || // Cookie-based session persistence is default.
*rule.SessionPersistence.Type == gwapiv1.CookieBasedSessionPersistence:
sessionPersistence = &ir.SessionPersistence{
Cookie: &ir.CookieBasedSessionPersistence{
Name: *rule.SessionPersistence.SessionName,
},

Check warning on line 329 in internal/gatewayapi/route.go

View check run for this annotation

Codecov / codecov/patch

internal/gatewayapi/route.go#L325-L329

Added lines #L325 - L329 were not covered by tests
}

if rule.SessionPersistence.AbsoluteTimeout != nil {
ttl, err := time.ParseDuration(string(*rule.SessionPersistence.AbsoluteTimeout))
if err != nil {
return nil, err

Check warning on line 334 in internal/gatewayapi/route.go

View check run for this annotation

Codecov / codecov/patch

internal/gatewayapi/route.go#L331-L334

Added lines #L331 - L334 were not covered by tests
}
sessionPersistence.Cookie.TTL = &metav1.Duration{Duration: ttl}

Check warning on line 336 in internal/gatewayapi/route.go

View check run for this annotation

Codecov / codecov/patch

internal/gatewayapi/route.go#L336

Added line #L336 was not covered by tests
}
} else if *rule.SessionPersistence.Type == gwapiv1.HeaderBasedSessionPersistence {
case *rule.SessionPersistence.Type == gwapiv1.HeaderBasedSessionPersistence:
sessionPersistence = &ir.SessionPersistence{
Header: &ir.HeaderBasedSessionPersistence{
Name: *rule.SessionPersistence.SessionName,
},

Check warning on line 342 in internal/gatewayapi/route.go

View check run for this annotation

Codecov / codecov/patch

internal/gatewayapi/route.go#L338-L342

Added lines #L338 - L342 were not covered by tests
}
} else {
default:

Check warning on line 344 in internal/gatewayapi/route.go

View check run for this annotation

Codecov / codecov/patch

internal/gatewayapi/route.go#L344

Added line #L344 was not covered by tests
// Unknown session persistence type is specified.
return nil, fmt.Errorf("unknown session persistence type %s", *rule.SessionPersistence.Type)

Check warning on line 346 in internal/gatewayapi/route.go

View check run for this annotation

Codecov / codecov/patch

internal/gatewayapi/route.go#L346

Added line #L346 was not covered by tests
}
Expand Down
5 changes: 1 addition & 4 deletions test/e2e/testdata/cookie-based-session-persistence.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,4 @@ spec:
sessionPersistence:
sessionName: Session-A
type: Cookie
# Actually, absoluteTimeout is not necessary for Header based session persistence.
# But, we have to add it, otherwise the gateway-api validation (mistakenly) rejects it.
# https://github.com/kubernetes-sigs/gateway-api/issues/3214
absoluteTimeout: 10s
absoluteTimeout: 10s
2 changes: 1 addition & 1 deletion test/e2e/testdata/header-based-session-persistence.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,4 @@ spec:
# Actually, absoluteTimeout is not necessary for Header based session persistence.
# But, we have to add it, otherwise the gateway-api validation (mistakenly) rejects it.
# https://github.com/kubernetes-sigs/gateway-api/issues/3214
absoluteTimeout: 100s
absoluteTimeout: 10s

0 comments on commit 0eed511

Please sign in to comment.