package config

// O11yRegionalServerTestConfig is the configuration for the o11y region server dev.
// If the enable is true, regionalserver will filter the tenants and projects, if the target tenant or project is in the list, the request will be forwarded to the dev server.
type O11yRegionalServerTestConfig struct {
	// Enable is the flag to enable the dev server.
	Enable bool `json:"enable"`
	// TestEndpoint is the endpoint of the dev o11y regionalserver.
	TestEndpoint string `json:"testEndpoint"`
	// Tenants is the list of tenants that will be forwarded to the dev server.
	Tenants []string `json:"tenants"`
	// Projects is the list of projects that will be forwarded to the dev server.
	Projects []string `json:"projects"`
}

// IsInList checks if the tenant and project are in the test list.
func (c O11yRegionalServerTestConfig) IsInList(tenant, project string) bool {
	if c.Enable && c.TestEndpoint != "" {
		for _, t := range c.Tenants {
			if t == tenant {
				return true
			}
		}
		for _, p := range c.Projects {
			if p == project {
				return true
			}
		}
	}
	return false
}
