func IsComposition(o runtime.Object) error {
	switch o.(type) {
	case *v1beta1.Composition:
		return nil
	case *v1.Composition:
		return nil
	default:
		return errors.New(errNotComposition)
	}
}
IsComposition checks that an object is a Composition.
package xpkg
import (
	"github.com/Masterminds/semver"
	"github.com/pkg/errors"
	extv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
	extv1beta1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1"
	"k8s.io/apimachinery/pkg/runtime"
	"github.com/crossplane/crossplane-runtime/pkg/parser"
	v1 "github.com/crossplane/crossplane/apis/apiextensions/v1"
	v1beta1 "github.com/crossplane/crossplane/apis/apiextensions/v1beta1"
	pkgmetav1 "github.com/crossplane/crossplane/apis/pkg/meta/v1"
)
const (
	errNotExactlyOneMeta    = "not exactly one package meta type"
	errNotMeta              = "meta type is not a package"
	errNotMetaProvider      = "package meta type is not Provider"
	errNotMetaConfiguration = "package meta type is not Configuration"
	errNotCRD               = "object is not a CRD"
	errNotXRD               = "object is not an XRD"
	errNotComposition       = "object is not a Composition"
	errBadConstraints       = "package version constraints are poorly formatted"
)
func NewProviderLinter() parser.Linter {
	return parser.NewPackageLinter(parser.PackageLinterFns(OneMeta), parser.ObjectLinterFns(IsProvider, PackageValidSemver), parser.ObjectLinterFns(IsCRD))
}
func NewConfigurationLinter() parser.Linter {
	return parser.NewPackageLinter(parser.PackageLinterFns(OneMeta), parser.ObjectLinterFns(IsConfiguration, PackageValidSemver), parser.ObjectLinterFns(parser.Or(IsXRD, IsComposition)))
}
func OneMeta(pkg *parser.Package) error {
	if len(pkg.GetMeta()) != 1 {
		return errors.New(errNotExactlyOneMeta)
	}
	return nil
}
func IsProvider(o runtime.Object) error {
	po, _ := TryConvert(o, &pkgmetav1.Provider{})
	if _, ok := po.(*pkgmetav1.Provider); !ok {
		return errors.New(errNotMetaProvider)
	}
	return nil
}
func IsConfiguration(o runtime.Object) error {
	po, _ := TryConvert(o, &pkgmetav1.Configuration{})
	if _, ok := po.(*pkgmetav1.Configuration); !ok {
		return errors.New(errNotMetaConfiguration)
	}
	return nil
}
func PackageValidSemver(o runtime.Object) error {
	p, ok := TryConvertToPkg(o, &pkgmetav1.Provider{}, &pkgmetav1.Configuration{})
	if !ok {
		return errors.New(errNotMeta)
	}
	if p.GetCrossplaneConstraints() == nil {
		return nil
	}
	if _, err := semver.NewConstraint(p.GetCrossplaneConstraints().Version); err != nil {
		return errors.Wrap(err, errBadConstraints)
	}
	return nil
}
func IsCRD(o runtime.Object) error {
	switch o.(type) {
	case *extv1beta1.CustomResourceDefinition, *extv1.CustomResourceDefinition:
		return nil
	default:
		return errors.New(errNotCRD)
	}
}
func IsXRD(o runtime.Object) error {
	switch o.(type) {
	case *v1beta1.CompositeResourceDefinition:
		return nil
	case *v1.CompositeResourceDefinition:
		return nil
	default:
		return errors.New(errNotXRD)
	}
}