func CreateLayer(ctx context.Context, client client.Client, k8client kubernetes.Interface, log logr.Logger,
	recorder record.EventRecorder, scheme *runtime.Scheme, addonsLayer *kraanv1alpha1.AddonsLayer) Layer {
	l := &KraanLayer{
		Name:        addonsLayer.Name,
		requeue:     false,
		delayed:     false,
		updated:     false,
		ctx:         ctx,
		log:         log,
		client:      client,
		k8client:    k8client,
		recorder:    recorder,
		addonsLayer: addonsLayer,
	}
	if l.addonsLayer.Spec.Interval != nil {
		l.delay = l.addonsLayer.Spec.Interval.Duration
	} else {
		l.delay = time.Minute
	}
	if l.addonsLayer.Spec.Timeout != nil {
		l.timeout = l.addonsLayer.Spec.Timeout.Duration
	} else {
		l.timeout = time.Minute
	}
	var err error
	if l.ref, err = reference.GetReference(scheme, addonsLayer); err != nil {
		log.Error(err, "failed to get reference")
	}
	return l
}
CreateLayer creates a layer object.
package layers
import (
	"context"
	"fmt"
	"os"
	"strings"
	"time"
	sourcev1 "github.com/fluxcd/source-controller/api/v1beta1"
	"github.com/go-logr/logr"
	"github.com/pkg/errors"
	"golang.org/x/mod/semver"
	corev1 "k8s.io/api/core/v1"
	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
	"k8s.io/apimachinery/pkg/runtime"
	"k8s.io/apimachinery/pkg/types"
	"k8s.io/client-go/kubernetes"
	"k8s.io/client-go/tools/record"
	"k8s.io/client-go/tools/reference"
	"sigs.k8s.io/controller-runtime/pkg/client"
	kraanv1alpha1 "github.com/fidelity/kraan/api/v1alpha1"
	"github.com/fidelity/kraan/pkg/common"
	"github.com/fidelity/kraan/pkg/logging"
	"github.com/fidelity/kraan/pkg/repos"
)
var (
	MaxConditions = 10
	RootPath      = "/data"
)
func init() {
	path, set := os.LookupEnv("DATA_PATH")
	if set {
		RootPath = path
	}
}
type Layer interface {
	SetStatusK8sVersion()
	SetStatusApplying()
	SetStatusPruning()
	SetStatusPending()
	SetStatusDeployed()
	StatusUpdate(status, message string)
	IsHold() bool
	SetHold()
	DependenciesDeployed() bool
	GetSourceKey() string
	GetStatus() string
	GetName() string
	GetLogger() logr.Logger
	GetContext() context.Context
	GetSourcePath() string
	GetTimeout() time.Duration
	IsUpdated() bool
	NeedsRequeue() bool
	IsDelayed() bool
	GetDelay() time.Duration
	SetRequeue()
	SetDelayedRequeue()
	SetUpdated()
	SetDeleted()
	GetRequiredK8sVersion() string
	CheckK8sVersion() bool
	GetFullStatus() *kraanv1alpha1.AddonsLayerStatus
	GetSpec() *kraanv1alpha1.AddonsLayerSpec
	GetAddonsLayer() *kraanv1alpha1.AddonsLayer
	RevisionReady(conditions []metav1.Condition, revision string) (bool, string)
}
type KraanLayer struct {
	Name        string `json:"layer-name"`
	updated     bool
	requeue     bool
	delayed     bool
	delay       time.Duration
	timeout     time.Duration
	ctx         context.Context
	client      client.Client
	k8client    kubernetes.Interface
	log         logr.Logger
	recorder    record.EventRecorder
	ref         *corev1.ObjectReference
	Layer       `json:"-"`
	addonsLayer *kraanv1alpha1.AddonsLayer
}