Documentation
¶
Overview ¶
Package server_structs shares structs and their methods used across multiple server packages (origin/cache/registry/director).
It should only import lower level packages (config/param/etc). It should NEVER import any server packages (origin/cache/registry/director) or server_utils package.
For functions used across multiple server packages, put them in server_utils package instead
Index ¶
- Variables
- func GetCacheNS(host string) string
- func GetOriginNs(host string) string
- func IsCacheNS(ns string) bool
- func IsOriginNS(ns string) bool
- func IsValidRegStatus(s string) bool
- func IsValidStrategy(strategy string) bool
- func ServerAdsToServerNameURL(ads []ServerAd) (output string)
- type AdTokCfg
- type AdminMetadata
- type Advertisement
- type ApiKey
- type ApiKeyCached
- type Capabilities
- type CheckNamespaceCompleteReq
- type CheckNamespaceCompleteRes
- type CheckNamespaceExistsReq
- type CheckNamespaceExistsRes
- type CheckNamespaceStatusReq
- type CheckNamespaceStatusRes
- type DirectorResponse
- type DirectorTestResult
- type GetPrefixByPathRes
- type Namespace
- type NamespaceAdV1
- type NamespaceAdV2
- type NamespaceCompletenessResult
- type NamespaceHolder
- type OAuthCallbackRequest
- type OAuthLoginRequest
- type OpenIdDiscoveryResponse
- type OriginAdvertiseV1
- type OriginAdvertiseV2
- type OriginStorageType
- type RegistrationStatus
- type ServerAd
- type ServerPrefix
- type ServerType
- func (sType *ServerType) Clear()
- func (sType ServerType) IsEnabled(testServer ServerType) bool
- func (sType *ServerType) Set(server ServerType) ServerType
- func (sType *ServerType) SetList(newServers []ServerType)
- func (sType *ServerType) SetString(name string) bool
- func (sType ServerType) String() string
- type SimpleApiResp
- type SimpleRespStatus
- type SortType
- type StrategyType
- type TokenGen
- type TokenIssuer
- type TokenResponse
- type TopoCredentialGeneration
- type TopoCurrentDowntimes
- type TopoDowntimeInfo
- type TopoNamespace
- type TopoResourceGroup
- type TopoScitokens
- type TopoServer
- type TopoServerDowntime
- type TopoService
- type TopoServices
- type TopologyNamespacesJSON
- type XPelAuth
- type XPelHeader
- type XPelNs
- type XPelTokGen
- type XRootDServer
Constants ¶
This section is empty.
Variables ¶
var (
ErrUnknownOriginStorageType = errors.New("unknown origin storage type")
)
Functions ¶
func GetCacheNS ¶
Get the namespace for a cache server, i.e. /caches/<hostname> It returns an empty string is the host is empty
func GetOriginNs ¶
Get the namespace for an origin server, i.e. /origins/<hostname> It returns an empty string is the host is empty
func IsOriginNS ¶
Check if a namespace is for an origin, i.e. /origins/<hostname>
func IsValidRegStatus ¶
func IsValidStrategy ¶
Types ¶
type AdminMetadata ¶
type AdminMetadata struct { UserID string `json:"user_id" post:"exclude"` // "sub" claim of user JWT who requested registration Description string `json:"description"` SiteName string `json:"site_name"` Institution string `json:"institution" validate:"required"` // the unique identifier of the institution SecurityContactUserID string `json:"security_contact_user_id" description:"User Identifier of the user responsible for the security of the service"` // "sub" claim of user who is responsible for taking security concern Status RegistrationStatus `json:"status" post:"exclude"` ApproverID string `json:"approver_id" post:"exclude"` // "sub" claim of user JWT who approved registration ApprovedAt time.Time `json:"approved_at" post:"exclude"` CreatedAt time.Time `json:"created_at" post:"exclude"` UpdatedAt time.Time `json:"updated_at" post:"exclude"` }
The AdminMetadata is used in Namespace as a marshaled JSON string to be stored in registry DB.
The UserID and SecurityContactUserID are meant to correspond to the "sub" claim of the user token that the OAuth client issues if the user is logged in using OAuth, or it should be "admin" from local password-based authentication.
To prevent users from writing to certain fields (readonly), you may use "post" tag with value "exclude". This will exclude the field from user's create/update requests and the field will also be excluded from field discovery endpoint (OPTION method).
We use validator package to validate struct fields from user requests. If a field is required, add `validate:"required"` to that field. This tag will also be used by fields discovery endpoint to tell the UI if a field is required. For other validator tags, visit: https://pkg.go.dev/github.com/go-playground/validator/v10
func (AdminMetadata) Equal ¶
func (a AdminMetadata) Equal(b AdminMetadata) bool
type Advertisement ¶
type Advertisement struct { sync.RWMutex ServerAd NamespaceAds []NamespaceAdV2 }
The struct holding a server's advertisement (including ServerAd and NamespaceAd)
func (*Advertisement) GetIOLoad ¶
func (ad *Advertisement) GetIOLoad() float64
func (*Advertisement) SetIOLoad ¶
func (ad *Advertisement) SetIOLoad(load float64)
type ApiKey ¶
type ApiKey struct { ID string `gorm:"primaryKey;column:id;type:text;not null;unique"` Name string `gorm:"column:name;type:text"` HashedValue string `gorm:"column:hashed_value;type:text;not null"` Scopes string `gorm:"column:scopes;type:text"` ExpiresAt time.Time CreatedAt time.Time CreatedBy string `gorm:"column:created_by;type:text"` }
type ApiKeyCached ¶
type Capabilities ¶
type Capabilities struct { PublicReads bool `json:"PublicRead"` Reads bool `json:"Read"` Writes bool `json:"Write"` Listings bool `json:"Listing"` DirectReads bool `json:"FallBackRead"` }
Note that the json are kept in uppercase for backward compatibility
type CheckNamespaceCompleteReq ¶
type CheckNamespaceCompleteReq struct {
Prefixes []string `json:"prefixes"`
}
type CheckNamespaceCompleteRes ¶
type CheckNamespaceCompleteRes struct {
Results map[string]NamespaceCompletenessResult `json:"results"`
}
type CheckNamespaceExistsReq ¶
type CheckNamespaceExistsRes ¶
type CheckNamespaceStatusReq ¶
type CheckNamespaceStatusReq struct {
Prefix string `json:"prefix"`
}
type CheckNamespaceStatusRes ¶
type CheckNamespaceStatusRes struct {
Approved bool `json:"approved"`
}
type DirectorResponse ¶
type DirectorTestResult ¶
type GetPrefixByPathRes ¶
type GetPrefixByPathRes struct {
Prefix string `json:"prefix"`
}
type Namespace ¶
type Namespace struct { ID int `json:"id" post:"exclude" gorm:"primaryKey"` Prefix string `json:"prefix" validate:"required"` Pubkey string `json:"pubkey" validate:"required" description:"Pubkey is your Pelican server public key in JWKS form"` Identity string `json:"identity" post:"exclude"` AdminMetadata AdminMetadata `json:"admin_metadata" gorm:"serializer:json"` CustomFields map[string]interface{} `json:"custom_fields" gorm:"serializer:json"` }
type NamespaceAdV1 ¶
type NamespaceAdV1 struct { RequireToken bool `json:"requireToken"` Path string `json:"path"` Issuer url.URL `json:"url"` MaxScopeDepth uint `json:"maxScopeDepth"` Strategy StrategyType `json:"strategy"` BasePath string `json:"basePath"` VaultServer string `json:"vaultServer"` DirlistHost string `json:"dirlisthost"` }
func ConvertNamespaceAdsV2ToV1 ¶
func ConvertNamespaceAdsV2ToV1(nsV2 []NamespaceAdV2) []NamespaceAdV1
type NamespaceAdV2 ¶
type NamespaceAdV2 struct { Caps Capabilities // Namespace capabilities should be considered independently of the origin’s capabilities. Path string `json:"path"` Generation []TokenGen `json:"token-generation"` Issuer []TokenIssuer `json:"token-issuer"` FromTopology bool `json:"from-topology"` }
func ConvertNamespaceAdsV1ToV2 ¶
func ConvertNamespaceAdsV1ToV2(nsAdsV1 []NamespaceAdV1, oAd *OriginAdvertiseV1) []NamespaceAdV2
type NamespaceHolder ¶
type NamespaceHolder struct {
// contains filtered or unexported fields
}
func (*NamespaceHolder) GetNamespaceAds ¶
func (ns *NamespaceHolder) GetNamespaceAds() []NamespaceAdV2
func (*NamespaceHolder) SetNamespaceAds ¶
func (ns *NamespaceHolder) SetNamespaceAds(ads []NamespaceAdV2)
type OAuthCallbackRequest ¶
type OAuthLoginRequest ¶
type OAuthLoginRequest struct {
NextUrl string `form:"nextUrl,omitempty"`
}
type OpenIdDiscoveryResponse ¶
type OpenIdDiscoveryResponse struct { Issuer string `json:"issuer"` JwksUri string `json:"jwks_uri"` TokenEndpoint string `json:"token_endpoint,omitempty"` UserInfoEndpoint string `json:"userinfo_endpoint,omitempty"` RevocationEndpoint string `json:"revocation_endpoint,omitempty"` GrantTypesSupported []string `json:"grant_types_supported,omitempty"` ScopesSupported []string `json:"scopes_supported,omitempty"` TokenAuthMethods []string `json:"token_endpoint_auth_methods_supported,omitempty"` RegistrationEndpoint string `json:"registration_endpoint,omitempty"` DeviceEndpoint string `json:"device_authorization_endpoint,omitempty"` }
type OriginAdvertiseV1 ¶
type OriginAdvertiseV1 struct { Name string `json:"name"` URL string `json:"url" binding:"required"` // This is the url for origin's XRootD service and file transfer WebURL string `json:"web_url,omitempty"` // This is the url for origin's web engine and APIs Namespaces []NamespaceAdV1 `json:"namespaces"` Writes bool `json:"enablewrite"` DirectReads bool `json:"enable-fallback-read"` // True if the origin will allow direct client reads when no caches are available }
type OriginAdvertiseV2 ¶
type OriginAdvertiseV2 struct { // The displayed name of the server. // The value is from the Sitename of the server registration in the registry if set, or Xrootd.Sitename if not Name string `json:"name"` // The namespace prefix to register/look up the server in the registry. // The value is /caches/{Xrootd.Sitename} for cache servers and /origins/{Xrootd.Sitename} for the origin servers RegistryPrefix string `json:"registry-prefix"` BrokerURL string `json:"broker-url,omitempty"` DataURL string `json:"data-url" binding:"required"` WebURL string `json:"web-url,omitempty"` Caps Capabilities `json:"capabilities"` Namespaces []NamespaceAdV2 `json:"namespaces"` Issuer []TokenIssuer `json:"token-issuer"` StorageType OriginStorageType `json:"storageType"` DisableDirectorTest bool `json:"directorTest"` // Use negative attribute (disable instead of enable) to be BC with legacy servers where they don't have this field Version string `json:"version"` }
func ConvertOriginAdV1ToV2 ¶
func ConvertOriginAdV1ToV2(oAd1 OriginAdvertiseV1) OriginAdvertiseV2
Converts a V1 origin advertisement to a V2 origin advertisement
type OriginStorageType ¶
type OriginStorageType string
const ( OriginStoragePosix OriginStorageType = "posix" OriginStorageS3 OriginStorageType = "s3" OriginStorageHTTPS OriginStorageType = "https" OriginStorageGlobus OriginStorageType = "globus" OriginStorageXRoot OriginStorageType = "xroot" // Not meant to be extensible, but facilitates legacy OSDF --> Pelican transition )
func ParseOriginStorageType ¶
func ParseOriginStorageType(storageType string) (ost OriginStorageType, err error)
Convert a string to an OriginStorageType
type RegistrationStatus ¶
type RegistrationStatus string
const ( RegPending RegistrationStatus = "Pending" RegApproved RegistrationStatus = "Approved" RegDenied RegistrationStatus = "Denied" RegUnknown RegistrationStatus = "Unknown" )
func (RegistrationStatus) LowerString ¶
func (rs RegistrationStatus) LowerString() string
func (RegistrationStatus) String ¶
func (rs RegistrationStatus) String() string
type ServerAd ¶
type ServerAd struct { Name string `json:"name"` StorageType OriginStorageType `json:"storageType"` // Always POSIX for caches DisableDirectorTest bool `json:"directorTest"` AuthURL url.URL `json:"auth_url"` BrokerURL url.URL `json:"broker_url"` // The URL of the broker service to use for this host. URL url.URL `json:"url"` // This is server's XRootD URL for file transfer WebURL url.URL `json:"web_url"` // This is server's Web interface and API Type string `json:"type"` Latitude float64 `json:"latitude"` Longitude float64 `json:"longitude"` Caps Capabilities `json:"capabilities"` FromTopology bool `json:"from_topology"` IOLoad float64 `json:"io_load"` Version string `json:"version"` }
func (*ServerAd) MarshalJSON ¶
type ServerPrefix ¶
type ServerPrefix string // The base namespace prefix for origin/cache server
const ( CachePrefix ServerPrefix = "/caches/" OriginPrefix ServerPrefix = "/origins/" )
func (ServerPrefix) String ¶
func (s ServerPrefix) String() string
type ServerType ¶
type ServerType int // ServerType is a bit mask indicating which Pelican server(s) are running in the current process
const ( CacheType ServerType = 1 << iota OriginType DirectorType RegistryType BrokerType LocalCacheType )
func (ServerType) IsEnabled ¶
func (sType ServerType) IsEnabled(testServer ServerType) bool
IsEnabled checks if a testServer is in the ServerType instance
func (*ServerType) Set ¶
func (sType *ServerType) Set(server ServerType) ServerType
Enable a single server type in the bitmask
func (*ServerType) SetList ¶
func (sType *ServerType) SetList(newServers []ServerType)
Set sets a list of newServers to ServerType instance
func (*ServerType) SetString ¶
func (sType *ServerType) SetString(name string) bool
func (ServerType) String ¶
func (sType ServerType) String() string
Get the string representation of a ServerType instance. This is intended for getting the string form of a single ServerType constant, such as CacheType OriginType, etc. To get a string slice of enabled servers, use EnabledServerString()
type SimpleApiResp ¶
type SimpleApiResp struct { Status SimpleRespStatus `json:"status"` Msg string `json:"msg,omitempty"` }
A short response object, meant for the result from most of the Pelican APIs. Will generate a JSON of the form: {"status": "error", "msg": "Some Error Message"} or {"status": "success"}
type SimpleRespStatus ¶
type SimpleRespStatus string
The standardized status message for the API response
const ( // Indicates the API succeeded. RespOK SimpleRespStatus = "success" // Indicates the API call failed; the SimpleApiResp Msg should be non-empty in this case RespFailed SimpleRespStatus = "error" // For long-polling APIs, indicates the requested timeout was hit without any response generated. // Should not be considered an error or success but rather indication the long-poll should be retried. RespPollTimeout SimpleRespStatus = "timeout" )
type StrategyType ¶
type StrategyType string
const ( OAuthStrategy StrategyType = "OAuth2" VaultStrategy StrategyType = "Vault" )
type TokenGen ¶
type TokenGen struct { Strategy StrategyType `json:"strategy"` VaultServer string `json:"vault-server"` MaxScopeDepth uint `json:"max-scope-depth"` CredentialIssuer url.URL `json:"issuer"` }
type TokenIssuer ¶
type TokenResponse ¶
type TopoCurrentDowntimes ¶
type TopoCurrentDowntimes struct {
Downtimes []TopoServerDowntime `xml:"Downtime"`
}
type TopoDowntimeInfo ¶
type TopoDowntimeInfo struct { XMLName xml.Name `xml:"Downtimes"` CurrentDowntimes TopoCurrentDowntimes `xml:"CurrentDowntimes"` }
type TopoNamespace ¶
type TopoNamespace struct { Caches []TopoServer `json:"caches"` Origins []TopoServer `json:"origins"` CredentialGeneration TopoCredentialGeneration `json:"credential_generation"` DirlistHost string `json:"dirlisthost"` Path string `json:"path"` ReadHTTPS bool `json:"readhttps"` Scitokens []TopoScitokens `json:"scitokens"` UseTokenOnRead bool `json:"usetokenonread"` WritebackHost string `json:"writebackhost"` }
type TopoResourceGroup ¶
type TopoScitokens ¶
type TopoServer ¶
type TopoServerDowntime ¶
type TopoServerDowntime struct { ID int `xml:"ID"` ResourceGroup TopoResourceGroup `xml:"ResourceGroup"` ResourceName string `xml:"ResourceName"` ResourceFQDN string `xml:"ResourceFQDN"` StartTime string `xml:"StartTime"` EndTime string `xml:"EndTime"` CreatedTime string `xml:"CreatedTime"` UpdateTime string `xml:"UpdateTime"` Services TopoServices `xml:"Services"` Description string `xml:"Description"` }
type TopoService ¶
type TopoServices ¶
type TopoServices struct {
Service []TopoService `xml:"Service"`
}
type TopologyNamespacesJSON ¶
type TopologyNamespacesJSON struct { Caches []TopoServer `json:"caches"` Namespaces []TopoNamespace `json:"namespaces"` }
type XPelHeader ¶
type XPelNs ¶
type XPelTokGen ¶
type XPelTokGen struct { Issuers []*url.URL MaxScopeDepth uint Strategy StrategyType BasePaths []string VaultServer *url.URL }
func (XPelTokGen) GetName ¶
func (x XPelTokGen) GetName() string
func (*XPelTokGen) ParseRawResponse ¶
func (x *XPelTokGen) ParseRawResponse(resp *http.Response) error
type XRootDServer ¶
type XRootDServer interface { GetServerType() ServerType SetNamespaceAds([]NamespaceAdV2) GetNamespaceAds() []NamespaceAdV2 CreateAdvertisement(name string, serverUrl string, serverWebUrl string) (*OriginAdvertiseV2, error) GetNamespaceAdsFromDirector() error GetAdTokCfg(context.Context) (AdTokCfg, error) GetFedTokLocation() string // Return the PIDs corresponding to the running process(es) for the XRootD // server instance (could be multiple if there's both cmsd and xrootd) GetPids() []int // Set the PIDs associated with the running process(es) for the XRootD instance SetPids([]int) }