@@ -2,6 +2,7 @@ package workloadapi
22
33import (
44 "github.com/spiffe/go-spiffe/v2/logger"
5+ "github.com/spiffe/go-spiffe/v2/svid/jwtsvid"
56 "github.com/spiffe/go-spiffe/v2/svid/x509svid"
67 "google.golang.org/grpc"
78)
@@ -68,12 +69,12 @@ type X509SourceOption interface {
6869 configureX509Source (* x509SourceConfig )
6970}
7071
71- // WithDefaultX509SVIDPicker provides a function that is used to determine the
72- // default X509 -SVID when more than one is provided by the Workload API. By
73- // default, the first X509 -SVID in the list returned by the Workload API is
72+ // WithDefaultJWTSVIDPicker provides a function that is used to determine the
73+ // default JWT -SVID when more than one is provided by the Workload API. By
74+ // default, the first JWT -SVID in the list returned by the Workload API is
7475// used.
75- func WithDefaultX509SVIDPicker (picker func ([]* x509svid .SVID ) * x509svid .SVID ) X509SourceOption {
76- return withDefaultX509SVIDPicker {picker : picker }
76+ func WithDefaultJWTSVIDPicker (picker func ([]* jwtsvid .SVID ) * jwtsvid .SVID ) JWTSourceOption {
77+ return withDefaultJWTSVIDPicker {picker : picker }
7778}
7879
7980// JWTSourceOption is an option for the JWTSource. A SourceOption is also a
@@ -82,6 +83,14 @@ type JWTSourceOption interface {
8283 configureJWTSource (* jwtSourceConfig )
8384}
8485
86+ // WithDefaultX509SVIDPicker provides a function that is used to determine the
87+ // default X509-SVID when more than one is provided by the Workload API. By
88+ // default, the first X509-SVID in the list returned by the Workload API is
89+ // used.
90+ func WithDefaultX509SVIDPicker (picker func ([]* x509svid.SVID ) * x509svid.SVID ) X509SourceOption {
91+ return withDefaultX509SVIDPicker {picker : picker }
92+ }
93+
8594// BundleSourceOption is an option for the BundleSource. A SourceOption is also
8695// a BundleSourceOption.
8796type BundleSourceOption interface {
@@ -109,6 +118,7 @@ type x509SourceConfig struct {
109118
110119type jwtSourceConfig struct {
111120 watcher watcherConfig
121+ picker func ([]* jwtsvid.SVID ) * jwtsvid.SVID
112122}
113123
114124type bundleSourceConfig struct {
@@ -154,3 +164,11 @@ type withDefaultX509SVIDPicker struct {
154164func (o withDefaultX509SVIDPicker ) configureX509Source (config * x509SourceConfig ) {
155165 config .picker = o .picker
156166}
167+
168+ type withDefaultJWTSVIDPicker struct {
169+ picker func ([]* jwtsvid.SVID ) * jwtsvid.SVID
170+ }
171+
172+ func (o withDefaultJWTSVIDPicker ) configureJWTSource (config * jwtSourceConfig ) {
173+ config .picker = o .picker
174+ }
0 commit comments