73
73
}
74
74
)
75
75
76
+ // GetServiceAccountFunc is a function type that returns a service account token for the given namespace and name.
77
+ type GetServiceAccountFunc func (namespace , name string ) (* v1.ServiceAccount , error )
78
+
79
+ // getServiceAccountTokenFunc is a function type that returns a service account token for the given namespace and name.
80
+ type getServiceAccountTokenFunc func (namespace , name string , tr * authenticationv1.TokenRequest ) (* authenticationv1.TokenRequest , error )
81
+
76
82
func init () {
77
83
install .Install (scheme )
78
84
kubeletconfig .AddToScheme (scheme )
@@ -84,8 +90,8 @@ func init() {
84
90
// RegisterCredentialProviderPlugins is called from kubelet to register external credential provider
85
91
// plugins according to the CredentialProviderConfig config file.
86
92
func RegisterCredentialProviderPlugins (pluginConfigFile , pluginBinDir string ,
87
- getServiceAccountToken func ( namespace , name string , tr * authenticationv1. TokenRequest ) ( * authenticationv1. TokenRequest , error ) ,
88
- getServiceAccount func ( namespace , name string ) ( * v1. ServiceAccount , error ) ,
93
+ getServiceAccountToken getServiceAccountTokenFunc ,
94
+ getServiceAccount GetServiceAccountFunc ,
89
95
) error {
90
96
if _ , err := os .Stat (pluginBinDir ); err != nil {
91
97
if os .IsNotExist (err ) {
@@ -133,8 +139,8 @@ func RegisterCredentialProviderPlugins(pluginConfigFile, pluginBinDir string,
133
139
134
140
// newPluginProvider returns a new pluginProvider based on the credential provider config.
135
141
func newPluginProvider (pluginBinDir string , provider kubeletconfig.CredentialProvider ,
136
- getServiceAccountToken func ( namespace , name string , tr * authenticationv1. TokenRequest ) ( * authenticationv1. TokenRequest , error ) ,
137
- getServiceAccount func ( namespace , name string ) ( * v1. ServiceAccount , error ) ,
142
+ getServiceAccountToken getServiceAccountTokenFunc ,
143
+ getServiceAccount GetServiceAccountFunc ,
138
144
) (* pluginProvider , error ) {
139
145
mediaType := "application/json"
140
146
info , ok := runtime .SerializerInfoForMediaType (codecs .SupportedMediaTypes (), mediaType )
@@ -200,16 +206,16 @@ type pluginProvider struct {
200
206
type serviceAccountProvider struct {
201
207
audience string
202
208
requireServiceAccount bool
203
- getServiceAccountFunc func ( namespace , name string ) ( * v1. ServiceAccount , error )
204
- getServiceAccountTokenFunc func ( podNamespace , serviceAccountName string , tr * authenticationv1. TokenRequest ) ( * authenticationv1. TokenRequest , error )
209
+ getServiceAccountFunc GetServiceAccountFunc
210
+ getServiceAccountTokenFunc getServiceAccountTokenFunc
205
211
requiredServiceAccountAnnotationKeys []string
206
212
optionalServiceAccountAnnotationKeys []string
207
213
}
208
214
209
215
func newServiceAccountProvider (
210
216
provider kubeletconfig.CredentialProvider ,
211
- getServiceAccount func ( namespace , name string ) ( * v1. ServiceAccount , error ) ,
212
- getServiceAccountToken func ( namespace , name string , tr * authenticationv1. TokenRequest ) ( * authenticationv1. TokenRequest , error ) ,
217
+ getServiceAccount GetServiceAccountFunc ,
218
+ getServiceAccountToken getServiceAccountTokenFunc ,
213
219
) * serviceAccountProvider {
214
220
featureGateEnabled := utilfeature .DefaultFeatureGate .Enabled (features .KubeletServiceAccountTokenForCredentialProviders )
215
221
serviceAccountTokenAudienceSet := provider .TokenAttributes != nil && len (provider .TokenAttributes .ServiceAccountTokenAudience ) > 0
0 commit comments