add variable and method comments
This commit is contained in:
2
internal/metal/models/doc.go
Normal file
2
internal/metal/models/doc.go
Normal file
@@ -0,0 +1,2 @@
|
||||
// Package models defines generic models each provider must be able to return.
|
||||
package models
|
||||
@@ -1,5 +1,6 @@
|
||||
package models
|
||||
|
||||
// Membership contains metal membership details.
|
||||
type Membership[T any] struct {
|
||||
ID string `json:"id"`
|
||||
User *UserDetails `json:"user"`
|
||||
|
||||
@@ -2,6 +2,7 @@ package models
|
||||
|
||||
import "go.infratographer.com/x/gidx"
|
||||
|
||||
// ProjectDetails contains project and membership information.
|
||||
type ProjectDetails struct {
|
||||
ID string `json:"id"`
|
||||
Name string `json:"name"`
|
||||
@@ -9,6 +10,7 @@ type ProjectDetails struct {
|
||||
Organization *OrganizationDetails `json:"organization"`
|
||||
}
|
||||
|
||||
// PrefixedID returns the prefixed id for the project.
|
||||
func (d *ProjectDetails) PrefixedID() gidx.PrefixedID {
|
||||
if d.ID == "" {
|
||||
return gidx.NullPrefixedID
|
||||
|
||||
@@ -8,10 +8,14 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
MetalUserIssuer = "https://auth.equinix.com/"
|
||||
// MetalUserIssuer is the issuer that is used for metal api token users.
|
||||
MetalUserIssuer = "https://auth.equinix.com/"
|
||||
|
||||
// MetaluserIssuerIDPrefix is the issuer id prefix added by the issuer.
|
||||
MetalUserIssuerIDPrefix = "auth|"
|
||||
)
|
||||
|
||||
// UserDetails contains the user information.
|
||||
type UserDetails struct {
|
||||
id *gidx.PrefixedID
|
||||
ID string `json:"id"`
|
||||
@@ -21,6 +25,7 @@ type UserDetails struct {
|
||||
Roles []string `json:"roles"`
|
||||
}
|
||||
|
||||
// PrefixedID returns the identity prefixed id for the user.
|
||||
func (d *UserDetails) PrefixedID() gidx.PrefixedID {
|
||||
if d.id != nil {
|
||||
return *d.id
|
||||
@@ -44,6 +49,7 @@ func (d *UserDetails) PrefixedID() gidx.PrefixedID {
|
||||
return *d.id
|
||||
}
|
||||
|
||||
// GenerateSubjectID builds a identity prefixed id with the provided prefix for the issuer and subject.
|
||||
func GenerateSubjectID(prefix, iss, sub string) (gidx.PrefixedID, error) {
|
||||
// Concatenate the iss and sub values, then hash them
|
||||
issSub := iss + sub
|
||||
|
||||
Reference in New Issue
Block a user