Skip to content

Commit 36e15c7

Browse files
committed
use meta duration type for fields in ir file
Signed-off-by: sachin maurya <[email protected]>
1 parent 80d9bda commit 36e15c7

File tree

4 files changed

+17
-13
lines changed

4 files changed

+17
-13
lines changed

internal/gatewayapi/securitypolicy.go

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -980,10 +980,11 @@ func (t *Translator) buildRemoteJWKS(
980980
envoyProxy *egv1a1.EnvoyProxy,
981981
) (*ir.RemoteJWKS, error) {
982982
var (
983-
protocol ir.AppProtocol
984-
rd *ir.RouteDestination
985-
traffic *ir.TrafficFeatures
986-
err error
983+
protocol ir.AppProtocol
984+
rd *ir.RouteDestination
985+
traffic *ir.TrafficFeatures
986+
err error
987+
cacheDuration *metav1.Duration
987988
)
988989

989990
u, err := url.Parse(remoteJWKS.URI)
@@ -1010,11 +1011,19 @@ func (t *Translator) buildRemoteJWKS(
10101011
}
10111012
}
10121013

1014+
if remoteJWKS.CacheDuration != nil {
1015+
d, err := time.ParseDuration(string(*remoteJWKS.CacheDuration))
1016+
if err != nil {
1017+
return nil, err
1018+
}
1019+
cacheDuration = ir.MetaV1DurationPtr(d)
1020+
}
1021+
10131022
return &ir.RemoteJWKS{
10141023
Destination: rd,
10151024
Traffic: traffic,
10161025
URI: remoteJWKS.URI,
1017-
CacheDuration: remoteJWKS.CacheDuration,
1026+
CacheDuration: cacheDuration,
10181027
}, nil
10191028
}
10201029

internal/ir/xds.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1079,7 +1079,7 @@ type RemoteJWKS struct {
10791079
URI string `json:"uri"`
10801080

10811081
// Duration after which the cached JWKS should be expired. If not specified, default cache duration is 5 minutes.
1082-
CacheDuration *gwapiv1.Duration `json:"cacheDuration,omitempty"`
1082+
CacheDuration *metav1.Duration `json:"cacheDuration,omitempty"`
10831083
}
10841084

10851085
// OIDC defines the schema for authenticating HTTP requests using

internal/ir/zz_generated.deepcopy.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

internal/xds/translator/jwt.go

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ package translator
88
import (
99
"errors"
1010
"fmt"
11-
"time"
1211

1312
corev3 "github.com/envoyproxy/go-control-plane/envoy/config/core/v3"
1413
routev3 "github.com/envoyproxy/go-control-plane/envoy/config/route/v3"
@@ -164,11 +163,7 @@ func buildJWTAuthn(irListener *ir.HTTPListener) (*jwtauthnv3.JwtAuthentication,
164163
},
165164
}
166165
if jwks.CacheDuration != nil {
167-
cDur, err := time.ParseDuration(string(*jwks.CacheDuration))
168-
if err != nil {
169-
return nil, err
170-
}
171-
remote.RemoteJwks.CacheDuration = durationpb.New(cDur)
166+
remote.RemoteJwks.CacheDuration = durationpb.New(jwks.CacheDuration.Duration)
172167
}
173168
// Set the retry policy if it exists.
174169
if jwks.Traffic != nil && jwks.Traffic.Retry != nil {

0 commit comments

Comments
 (0)