func (fn TrackerFn) Track(ctx context.Context, mg Managed) error {
	return fn(ctx, mg)
}
Track the supplied managed resource.
package resource
import (
	"context"
	"os"
	"github.com/spf13/afero"
	corev1 "k8s.io/api/core/v1"
	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
	"k8s.io/apimachinery/pkg/runtime"
	"k8s.io/apimachinery/pkg/types"
	"sigs.k8s.io/controller-runtime/pkg/client"
	xpv1 "github.com/crossplane/crossplane-runtime/apis/common/v1"
	"github.com/crossplane/crossplane-runtime/pkg/errors"
	"github.com/crossplane/crossplane-runtime/pkg/meta"
)
const (
	errExtractEnv            = "cannot extract from environment variable when none specified"
	errExtractFs             = "cannot extract from filesystem when no path specified"
	errExtractSecretKey      = "cannot extract from secret key when none specified"
	errGetCredentialsSecret  = "cannot get credentials secret"
	errNoHandlerForSourceFmt = "no extraction handler registered for source: %s"
	errMissingPCRef          = "managed resource does not reference a ProviderConfig"
	errApplyPCU              = "cannot apply ProviderConfigUsage"
)
type errMissingRef struct{ error }
func (m errMissingRef) MissingReference() bool { return true }
func IsMissingReference(err error) bool {
	_, ok := err.(interface {
		MissingReference() bool
	})
	return ok
}
type EnvLookupFn func(string) string
func ExtractEnv(ctx context.Context, e EnvLookupFn, s xpv1.CommonCredentialSelectors) ([]byte, error) {
	if s.Env == nil {
		return nil, errors.New(errExtractEnv)
	}
	return []byte(e(s.Env.Name)), nil
}
func ExtractFs(ctx context.Context, fs afero.Fs, s xpv1.CommonCredentialSelectors) ([]byte, error) {
	if s.Fs == nil {
		return nil, errors.New(errExtractFs)
	}
	return afero.ReadFile(fs, s.Fs.Path)
}
func ExtractSecret(ctx context.Context, client client.Client, s xpv1.CommonCredentialSelectors) ([]byte, error) {
	if s.SecretRef == nil {
		return nil, errors.New(errExtractSecretKey)
	}
	secret := &corev1.Secret{}
	if err := client.Get(ctx, types.NamespacedName{Namespace: s.SecretRef.Namespace, Name: s.SecretRef.Name}, secret); err != nil {
		return nil, errors.Wrap(err, errGetCredentialsSecret)
	}
	return secret.Data[s.SecretRef.Key], nil
}
func CommonCredentialExtractor(ctx context.Context, source xpv1.CredentialsSource, client client.Client, selector xpv1.CommonCredentialSelectors) ([]byte, error) {
	switch source {  
	case xpv1.CredentialsSourceEnvironment:
		return ExtractEnv(ctx, os.Getenv, selector)
	case xpv1.CredentialsSourceFilesystem:
		return ExtractFs(ctx, afero.NewOsFs(), selector)
	case xpv1.CredentialsSourceSecret:
		return ExtractSecret(ctx, client, selector)
	case xpv1.CredentialsSourceNone:
		return nil, nil
	}
	return nil, errors.Errorf(errNoHandlerForSourceFmt, source)
}
type Tracker interface {
	Track(ctx context.Context, mg Managed) error
}
type TrackerFn func(ctx context.Context, mg Managed) error