-
Notifications
You must be signed in to change notification settings - Fork 43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
commonids: add commonid for TenantId
#216
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍
@manicminer given the default Tenant ID can be represented as |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed, for convenience it might be worth declaring a default tenant for easy re-use. Otherwise LGTM 👍
var DefaultTenantId = TenantId{
TenantId: "/",
}
// TenantId is a struct representing the Resource ID for a Tenant | ||
type TenantId struct { | ||
TenantId string | ||
} | ||
|
||
// DefaultTenantId returns a default TenantId | ||
var DefaultTenantId = NewTenantID("/") | ||
|
||
// NewTenantID returns a new TenantId struct | ||
func NewTenantID(tenantId string) TenantId { | ||
return TenantId{ | ||
TenantId: tenantId, | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thinking more about the default Tenant ID perhaps we want to handle this differently?
If we make the TenantId
field a pointer, we could support parsing both the Default Tenant ID and another Tenant ID? It'd be different to the other Resource ID parsers but this is a unique case where the Default is handled differently, which I don't believe we've got anywhere else - so perhaps it's worth handling that explicitly here?
// TenantId is a struct representing the Resource ID for a Tenant | |
type TenantId struct { | |
TenantId string | |
} | |
// DefaultTenantId returns a default TenantId | |
var DefaultTenantId = NewTenantID("/") | |
// NewTenantID returns a new TenantId struct | |
func NewTenantID(tenantId string) TenantId { | |
return TenantId{ | |
TenantId: tenantId, | |
} | |
} | |
// TenantId is a struct representing the Resource ID for a Tenant | |
type TenantId struct { | |
TenantId *string | |
} | |
// NewDefaultTenantId returns a TenantId for the default Tenant | |
func NewDefaultTenantID() TenantId { | |
return TenantId{} | |
} | |
// NewTenantID returns a new TenantId struct | |
func NewTenantID(tenantId string) TenantId { | |
return TenantId{ | |
TenantId: &tenantId, | |
} | |
} |
WDYT @catriona-m @manicminer?
No description provided.