github.com/pingcap/tiflow@v0.0.0-20240520035814-5bf52d54e205/engine/pkg/tenant/tenant.go (about) 1 // Copyright 2022 PingCAP, Inc. 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // See the License for the specific language governing permissions and 12 // limitations under the License. 13 14 package tenant 15 16 type ( 17 // Tenant is the tenant id type 18 Tenant = string 19 // ProjectID is the project id type of tenant 20 ProjectID = string 21 ) 22 23 // tenant const variables 24 var ( 25 FrameProjectInfo = ProjectInfo{ 26 tenantID: "dfe_tenant_root", 27 projectID: "dfe_proj_root", 28 } 29 TestProjectInfo = ProjectInfo{ 30 tenantID: "dfe_tenant_test", 31 projectID: "dfe_proj_test", 32 } 33 DefaultUserProjectInfo = ProjectInfo{ 34 tenantID: "dfe_tenant_default", 35 projectID: "dfe_proj_default", 36 } 37 ) 38 39 // NewProjectInfo return an immutable ProjectInfo 40 func NewProjectInfo(tenant string, project string) ProjectInfo { 41 return ProjectInfo{ 42 tenantID: tenant, 43 projectID: project, 44 } 45 } 46 47 // ProjectInfo is the tenant/project information which is consistent with cloud service provider 48 type ProjectInfo struct { 49 tenantID Tenant 50 projectID ProjectID 51 } 52 53 // UniqueID get the unique id for project 54 // Theoretically, ProjectID is global uniqueness and can used as the identifier 55 // We offer this method here to hide the implementation of getting a unique ID 56 func (p ProjectInfo) UniqueID() string { 57 return p.projectID 58 } 59 60 // TenantID return tenant id 61 func (p ProjectInfo) TenantID() string { 62 return p.tenantID 63 } 64 65 // ProjectID return project id 66 func (p ProjectInfo) ProjectID() string { 67 return p.projectID 68 }