package resources

import (
	"time"

	"github.com/pingcap/dbaas/central/db/entity"
	"github.com/pingcap/dbaas/pkg/tidb/component"
)

// ClusterResources combines a Cluster and Resources
type ClusterResources struct {
	Provider   entity.Cloud
	TenantID   uint64
	ProjectID  uint64
	ClusterID  uint64
	RegionName string
	//TODO(Louis): zones field should be deleted when gardener is removed
	Zones        []string
	MySqlAddress string
	KeyID        string
	KmsArn       string
	Resources    []component.Resources
	NodesCIDR    string
	ClusterName  string
	CreatedAt    time.Time
	Replicas     uint32
	Free         bool
}

func (cr *ClusterResources) TiFlashEnabled() bool {
	for _, c := range cr.Resources {
		if c.ComponentName == component.TiFlash {
			return true
		}
	}
	return false
}
