mirror of
				https://github.com/optim-enterprises-bv/kubernetes.git
				synced 2025-11-04 04:08:16 +00:00 
			
		
		
		
	Define type alias for getServiceAccount function
Signed-off-by: Anish Ramasekar <anish.ramasekar@gmail.com>
This commit is contained in:
		@@ -73,6 +73,12 @@ var (
 | 
				
			|||||||
	}
 | 
						}
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// GetServiceAccountFunc is a function type that returns a service account token for the given namespace and name.
 | 
				
			||||||
 | 
					type GetServiceAccountFunc func(namespace, name string) (*v1.ServiceAccount, error)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// getServiceAccountTokenFunc is a function type that returns a service account token for the given namespace and name.
 | 
				
			||||||
 | 
					type getServiceAccountTokenFunc func(namespace, name string, tr *authenticationv1.TokenRequest) (*authenticationv1.TokenRequest, error)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func init() {
 | 
					func init() {
 | 
				
			||||||
	install.Install(scheme)
 | 
						install.Install(scheme)
 | 
				
			||||||
	kubeletconfig.AddToScheme(scheme)
 | 
						kubeletconfig.AddToScheme(scheme)
 | 
				
			||||||
@@ -84,8 +90,8 @@ func init() {
 | 
				
			|||||||
// RegisterCredentialProviderPlugins is called from kubelet to register external credential provider
 | 
					// RegisterCredentialProviderPlugins is called from kubelet to register external credential provider
 | 
				
			||||||
// plugins according to the CredentialProviderConfig config file.
 | 
					// plugins according to the CredentialProviderConfig config file.
 | 
				
			||||||
func RegisterCredentialProviderPlugins(pluginConfigFile, pluginBinDir string,
 | 
					func RegisterCredentialProviderPlugins(pluginConfigFile, pluginBinDir string,
 | 
				
			||||||
	getServiceAccountToken func(namespace, name string, tr *authenticationv1.TokenRequest) (*authenticationv1.TokenRequest, error),
 | 
						getServiceAccountToken getServiceAccountTokenFunc,
 | 
				
			||||||
	getServiceAccount func(namespace, name string) (*v1.ServiceAccount, error),
 | 
						getServiceAccount GetServiceAccountFunc,
 | 
				
			||||||
) error {
 | 
					) error {
 | 
				
			||||||
	if _, err := os.Stat(pluginBinDir); err != nil {
 | 
						if _, err := os.Stat(pluginBinDir); err != nil {
 | 
				
			||||||
		if os.IsNotExist(err) {
 | 
							if os.IsNotExist(err) {
 | 
				
			||||||
@@ -133,8 +139,8 @@ func RegisterCredentialProviderPlugins(pluginConfigFile, pluginBinDir string,
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
// newPluginProvider returns a new pluginProvider based on the credential provider config.
 | 
					// newPluginProvider returns a new pluginProvider based on the credential provider config.
 | 
				
			||||||
func newPluginProvider(pluginBinDir string, provider kubeletconfig.CredentialProvider,
 | 
					func newPluginProvider(pluginBinDir string, provider kubeletconfig.CredentialProvider,
 | 
				
			||||||
	getServiceAccountToken func(namespace, name string, tr *authenticationv1.TokenRequest) (*authenticationv1.TokenRequest, error),
 | 
						getServiceAccountToken getServiceAccountTokenFunc,
 | 
				
			||||||
	getServiceAccount func(namespace, name string) (*v1.ServiceAccount, error),
 | 
						getServiceAccount GetServiceAccountFunc,
 | 
				
			||||||
) (*pluginProvider, error) {
 | 
					) (*pluginProvider, error) {
 | 
				
			||||||
	mediaType := "application/json"
 | 
						mediaType := "application/json"
 | 
				
			||||||
	info, ok := runtime.SerializerInfoForMediaType(codecs.SupportedMediaTypes(), mediaType)
 | 
						info, ok := runtime.SerializerInfoForMediaType(codecs.SupportedMediaTypes(), mediaType)
 | 
				
			||||||
@@ -200,16 +206,16 @@ type pluginProvider struct {
 | 
				
			|||||||
type serviceAccountProvider struct {
 | 
					type serviceAccountProvider struct {
 | 
				
			||||||
	audience                             string
 | 
						audience                             string
 | 
				
			||||||
	requireServiceAccount                bool
 | 
						requireServiceAccount                bool
 | 
				
			||||||
	getServiceAccountFunc                func(namespace, name string) (*v1.ServiceAccount, error)
 | 
						getServiceAccountFunc                GetServiceAccountFunc
 | 
				
			||||||
	getServiceAccountTokenFunc           func(podNamespace, serviceAccountName string, tr *authenticationv1.TokenRequest) (*authenticationv1.TokenRequest, error)
 | 
						getServiceAccountTokenFunc           getServiceAccountTokenFunc
 | 
				
			||||||
	requiredServiceAccountAnnotationKeys []string
 | 
						requiredServiceAccountAnnotationKeys []string
 | 
				
			||||||
	optionalServiceAccountAnnotationKeys []string
 | 
						optionalServiceAccountAnnotationKeys []string
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func newServiceAccountProvider(
 | 
					func newServiceAccountProvider(
 | 
				
			||||||
	provider kubeletconfig.CredentialProvider,
 | 
						provider kubeletconfig.CredentialProvider,
 | 
				
			||||||
	getServiceAccount func(namespace, name string) (*v1.ServiceAccount, error),
 | 
						getServiceAccount GetServiceAccountFunc,
 | 
				
			||||||
	getServiceAccountToken func(namespace, name string, tr *authenticationv1.TokenRequest) (*authenticationv1.TokenRequest, error),
 | 
						getServiceAccountToken getServiceAccountTokenFunc,
 | 
				
			||||||
) *serviceAccountProvider {
 | 
					) *serviceAccountProvider {
 | 
				
			||||||
	featureGateEnabled := utilfeature.DefaultFeatureGate.Enabled(features.KubeletServiceAccountTokenForCredentialProviders)
 | 
						featureGateEnabled := utilfeature.DefaultFeatureGate.Enabled(features.KubeletServiceAccountTokenForCredentialProviders)
 | 
				
			||||||
	serviceAccountTokenAudienceSet := provider.TokenAttributes != nil && len(provider.TokenAttributes.ServiceAccountTokenAudience) > 0
 | 
						serviceAccountTokenAudienceSet := provider.TokenAttributes != nil && len(provider.TokenAttributes.ServiceAccountTokenAudience) > 0
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -224,7 +224,7 @@ func NewKubeGenericRuntimeManager(
 | 
				
			|||||||
	podPullingTimeRecorder images.ImagePodPullingTimeRecorder,
 | 
						podPullingTimeRecorder images.ImagePodPullingTimeRecorder,
 | 
				
			||||||
	tracerProvider trace.TracerProvider,
 | 
						tracerProvider trace.TracerProvider,
 | 
				
			||||||
	tokenManager *token.Manager,
 | 
						tokenManager *token.Manager,
 | 
				
			||||||
	getServiceAccount func(string, string) (*v1.ServiceAccount, error),
 | 
						getServiceAccount plugin.GetServiceAccountFunc,
 | 
				
			||||||
) (KubeGenericRuntime, error) {
 | 
					) (KubeGenericRuntime, error) {
 | 
				
			||||||
	ctx := context.Background()
 | 
						ctx := context.Background()
 | 
				
			||||||
	runtimeService = newInstrumentedRuntimeService(runtimeService)
 | 
						runtimeService = newInstrumentedRuntimeService(runtimeService)
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user