func (s *InstanceOperation) Insert(io *internal.InstanceOperation) error {
	defer unlock(s.lockW())
	if io == nil {
		return errors.New("entity may not be nil")
	}
	if io.InstanceID.IsZero() || io.OperationID.IsZero() {
		return errors.New("both instance and operation id must be set")
	}
	if _, found := s.storage[io.InstanceID]; !found {
		s.storage[io.InstanceID] = make(map[internal.OperationID]*internal.InstanceOperation)
	}
	if _, found := s.storage[io.InstanceID][io.OperationID]; found {
		return alreadyExistsError{}
	}
	for oID := range s.storage[io.InstanceID] {
		if s.storage[io.InstanceID][oID].State == internal.OperationStateInProgress {
			return activeOperationInProgressError{}
		}
	}
	io.CreatedAt = s.nowProvider.Now()
	s.storage[io.InstanceID][io.OperationID] = io
	return nil
}
Insert inserts object into storage.
package memory
import (
	"time"
	"github.com/pkg/errors"
	yTime "github.com/kyma-project/helm-broker/internal/platform/time"
	"github.com/kyma-project/helm-broker/internal"
)
func NewInstanceOperation() *InstanceOperation {
	return &InstanceOperation{
		storage: make(map[internal.InstanceID]map[internal.OperationID]*internal.InstanceOperation),
	}
}
type InstanceOperation struct {
	threadSafeStorage
	storage     map[internal.InstanceID]map[internal.OperationID]*internal.InstanceOperation
	nowProvider yTime.NowProvider
}
func (s *InstanceOperation) WithTimeProvider(nowProvider func() time.Time) *InstanceOperation {
	s.nowProvider = nowProvider
	return s
}