package services

import (
	"sync"

	"github.com/fiskerinc/cloud-services/pkg/logger"

	vconfig "github.com/fiskerinc/cloud-services/pkg/vehicleconfig"
)

var (
	configOnce     sync.Once
	configInstance vconfig.ConfigServiceInterface
)

func GetVehicleConfig() vconfig.ConfigServiceInterface {
	configOnce.Do(func() {
		if configInstance != nil {
			return
		}
		logger.Info().Msg("init vehicle config instance")
		configInstance = vconfig.NewConfigService()
	})
	return configInstance
}

func SetVehicleConfig(c vconfig.ConfigServiceInterface) {
	configInstance = c
}
