package data

import (
	"gorm.io/gorm"
	dataintegration "kra/internal/data/integration"
	"kra/internal/integration/runtimeconfig"
)

func readIntegrationRuntime(db *gorm.DB) ([]runtimeconfig.Config, error) {
	return dataintegration.ReadRuntime(db)
}

func (d *Data) loadIntegrationRuntime(db *gorm.DB) error {
	configs, err := readIntegrationRuntime(db)
	if err != nil {
		return err
	}
	if d.integrations != nil {
		d.integrations.Replace(configs)
	}
	return nil
}
