package adminroles

import "github.com/fiskerinc/cloud-services/pkg/utils/envtool"

// RoleID for groups
type RoleID string
type RoleMap map[string][]RoleID

var (
	RoleCreate              RoleID = RoleID(envtool.GetEnv("ROLE_CREATE", "REPLACE_ME"))
	RoleReadOnly            RoleID = RoleID(envtool.GetEnv("ROLE_READ_ONLY", "REPLACE_ME"))
	RoleDelete              RoleID = RoleID(envtool.GetEnv("ROLE_DELETE", "REPLACE_ME"))
	RoleGenerateCertificate RoleID = RoleID(envtool.GetEnv("ROLE_GENERATE_CERTIFICATE", "REPLACE_ME"))
	RoleManufacture         RoleID = RoleID(envtool.GetEnv("ROLE_MANUFACTURE", "REPLACE_ME"))
	RoleCarDiagnostic       RoleID = RoleID(envtool.GetEnv("ROLE_CAR_DIAGNOSTIC", "REPLACE_ME"))
	RoleSupplier            RoleID = RoleID(envtool.GetEnv("ROLE_SUPPLIER", "REPLACE_ME"))
	RoleSupplierApprover    RoleID = RoleID(envtool.GetEnv("ROLE_SUPPLIER_APPROVER", "REPLACE_ME"))
	RoleAfterSalesAccess    RoleID = RoleID(envtool.GetEnv("ROLE_AFTER_SALES_ACCESS", "REPLACE_ME"))
	RoleAfterSalesAccessFSP RoleID = RoleID(envtool.GetEnv("ROLE_AFTER_SALES_ACCESS_FSP", "REPLACE_ME"))
	RoleSAPIntegration      RoleID = RoleID(envtool.GetEnv("ROLE_SAP_INTEGRATION", "REPLACE_ME"))
	RoleMagna               RoleID = RoleID(envtool.GetEnv("MAGNA_GROUP_ID", "REPLACE_ME"))
	RoleManifestMigration   RoleID = RoleID(envtool.GetEnv("ROLE_MANIFEST_MIGRATION", "REPLACE_ME"))
	RoleUpdateDeploy        RoleID = RoleID(envtool.GetEnv("ROLE_UPDATE_DEPLOY", "REPLACE_ME"))
)

func (r RoleMap) CopyAndMerge(m RoleMap) RoleMap {
	nMap := make(RoleMap)
	for k, v := range r {
		nMap[k] = v
	}

	for k, v := range m {
		nMap[k] = v
	}

	return nMap
}
