Documentation ¶
Overview ¶
**************************************************************
* * Copyright (C) 2023, University of Nebraska-Lincoln * * Licensed under the Apache License, Version 2.0 (the "License"); you * may not use this file except in compliance with the License. You may * obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * **************************************************************
Index ¶
- Variables
- func AcquireToken(destination *url.URL, namespace namespaces.Namespace, ...) (string, error)
- func AddError(err error) bool
- func ByteCountSI(b int64) string
- func CanDisableProxy() bool
- func CheckOSDF(destination string, methods []string) (remoteSize uint64, err error)
- func ClearErrors()
- func CreateNsFromDirectorResp(dirResp *http.Response) (namespace namespaces.Namespace, err error)
- func CreateSharingUrl(objectUrl *url.URL, isWrite bool) (string, error)
- func DoShadowIngest(sourceFile string, originPrefix string, shadowOriginPrefix string) (int64, string, error)
- func DoStashCPSingle(sourceFile string, destination string, methods []string, recursive bool) (bytesTransferred int64, err error)
- func DownloadHTTP(transfer TransferDetails, dest string, token string) (int64, error)
- func ErrorsRetryable() bool
- func Find(slice []string, val string) (int, bool)
- func GetBehavior(behaviorName string) (packerBehavior, error)
- func GetBestCache(cacheListName string) ([]string, error)
- func GetCacheHostnames(testFile string) (urls []string, err error)
- func GetCachesFromDirectorResponse(resp *http.Response, needsToken bool) (caches []namespaces.DirectorCache, err error)
- func GetErrors() string
- func HasPort(host string) bool
- func HeaderParser(values string) (retMap map[string]string)
- func IsProxyEnabled() bool
- func IsRetryable(err error) bool
- func QueryDirector(source string, directorUrl string) (resp *http.Response, err error)
- func RegisterClient(namespace namespaces.Namespace) (*config.PrefixEntry, error)
- func StatHttp(dest *url.URL, namespace namespaces.Namespace) (uint64, error)
- func TokenIsAcceptable(jwtSerialized string, osdfPath string, namespace namespaces.Namespace, ...) bool
- func TokenIsExpired(jwtSerialized string) bool
- func UploadDirectory(src string, dest *url.URL, token string, namespace namespaces.Namespace) (int64, error)
- func UploadFile(src string, origDest *url.URL, token string, namespace namespaces.Namespace) (int64, error)
- type CacheInterface
- type ConnectionSetupError
- type ConstantSizer
- type FileDownloadError
- type HttpErrResp
- type OptionsStruct
- type ProgressReader
- type Sizer
- type SlowTransferError
- type StoppedTransferError
- type TimestampedError
- type TransferDetails
- func GenerateTransferDetailsUsingCache(cache CacheInterface, opts TransferDetailsOptions) []TransferDetails
- func NewTransferDetails(cache namespaces.Cache, opts TransferDetailsOptions) []TransferDetails
- func NewTransferDetailsUsingDirector(cache namespaces.DirectorCache, opts TransferDetailsOptions) []TransferDetails
- type TransferDetailsOptions
- type TransferResults
Constants ¶
This section is empty.
Variables ¶
var CacheOverride bool
CacheOverride
var CachesJsonLocation string
var CachesToTry int = 3
Number of caches to attempt to use in any invocation
var NearestCache string
Nearest cache
var NearestCacheList []string
List of caches, in order from closest to furthest
var UploadClient = &http.Client{Transport: config.GetTransport()}
Functions ¶
func AcquireToken ¶
func AcquireToken(destination *url.URL, namespace namespaces.Namespace, opts config.TokenGenerationOpts) (string, error)
Given a URL and a piece of the namespace, attempt to acquire a valid token for that URL.
func ByteCountSI ¶
func CanDisableProxy ¶
func CanDisableProxy() bool
Determine whether we are allowed to skip the proxy as a fallback
func ClearErrors ¶
func ClearErrors()
func CreateNsFromDirectorResp ¶
func CreateNsFromDirectorResp(dirResp *http.Response) (namespace namespaces.Namespace, err error)
Given the Director response, create the ordered list of caches and store it as namespace.SortedDirectorCaches
func DoShadowIngest ¶
func DoStashCPSingle ¶
func DoStashCPSingle(sourceFile string, destination string, methods []string, recursive bool) (bytesTransferred int64, err error)
Start the transfer, whether read or write back
func DownloadHTTP ¶
func DownloadHTTP(transfer TransferDetails, dest string, token string) (int64, error)
DownloadHTTP - Perform the actual download of the file
func ErrorsRetryable ¶
func ErrorsRetryable() bool
ErrorsRetryable returns if the errors in the stack are retryable later
func Find ¶
Find takes a slice and looks for an element in it. If found it will return it's key, otherwise it will return -1 and a bool of false. From https://golangcode.com/check-if-element-exists-in-slice/
func GetBehavior ¶
func GetBestCache ¶
func GetCacheHostnames ¶
FIXME: GetCacheHostnames is not director-aware!
func GetCachesFromDirectorResponse ¶
func GetCachesFromDirectorResponse(resp *http.Response, needsToken bool) (caches []namespaces.DirectorCache, err error)
func HeaderParser ¶
Simple parser to that takes a "values" string from a header and turns it into a map of key/value pairs
func IsProxyEnabled ¶
func IsProxyEnabled() bool
Determines whether or not we can interact with the site HTTP proxy
func IsRetryable ¶
IsRetryable will return true if the error is retryable
func QueryDirector ¶
func RegisterClient ¶
func RegisterClient(namespace namespaces.Namespace) (*config.PrefixEntry, error)
func TokenIsAcceptable ¶
func TokenIsAcceptable(jwtSerialized string, osdfPath string, namespace namespaces.Namespace, opts config.TokenGenerationOpts) bool
func TokenIsExpired ¶
func UploadDirectory ¶
func UploadDirectory(src string, dest *url.URL, token string, namespace namespaces.Namespace) (int64, error)
Recursively uploads a directory with all files and nested dirs, keeping file structure on server side
func UploadFile ¶
func UploadFile(src string, origDest *url.URL, token string, namespace namespaces.Namespace) (int64, error)
UploadFile Uploads a file using HTTP
Types ¶
type CacheInterface ¶
type CacheInterface interface{}
func GetCachesFromNamespace ¶
func GetCachesFromNamespace(namespace namespaces.Namespace, useDirector bool) (caches []CacheInterface, err error)
type ConnectionSetupError ¶
ConnectionSetupError is an error that is returned when a connection to the remote server fails
func (*ConnectionSetupError) Error ¶
func (e *ConnectionSetupError) Error() string
func (*ConnectionSetupError) Is ¶
func (e *ConnectionSetupError) Is(target error) bool
func (*ConnectionSetupError) Unwrap ¶
func (e *ConnectionSetupError) Unwrap() error
type ConstantSizer ¶
type ConstantSizer struct {
// contains filtered or unexported fields
}
func (*ConstantSizer) BytesComplete ¶
func (cs *ConstantSizer) BytesComplete() int64
func (*ConstantSizer) Size ¶
func (cs *ConstantSizer) Size() int64
type FileDownloadError ¶
func (*FileDownloadError) Error ¶
func (e *FileDownloadError) Error() string
func (*FileDownloadError) Unwrap ¶
func (e *FileDownloadError) Unwrap() error
type HttpErrResp ¶
func (*HttpErrResp) Error ¶
func (e *HttpErrResp) Error() string
type OptionsStruct ¶
type OptionsStruct struct { ProgressBars bool Recursive bool Plugin bool Token string Version string }
var ObjectClientOptions OptionsStruct
type ProgressReader ¶
type ProgressReader struct {
// contains filtered or unexported fields
}
ProgressReader wraps the io.Reader to get progress Adapted from https://stackoverflow.com/questions/26050380/go-tracking-post-request-progress
func (*ProgressReader) BytesComplete ¶
func (pr *ProgressReader) BytesComplete() int64
func (*ProgressReader) Close ¶
func (pr *ProgressReader) Close() error
Close implments the close function of io.Closer
func (*ProgressReader) Read ¶
func (pr *ProgressReader) Read(p []byte) (n int, err error)
Read implements the common read function for io.Reader
func (*ProgressReader) Size ¶
func (pr *ProgressReader) Size() int64
type SlowTransferError ¶
type SlowTransferError struct { BytesTransferred int64 BytesPerSecond int64 BytesTotal int64 Duration time.Duration }
SlowTransferError is an error that is returned when a transfer takes longer than the configured timeout
func (*SlowTransferError) Error ¶
func (e *SlowTransferError) Error() string
func (*SlowTransferError) Is ¶
func (e *SlowTransferError) Is(target error) bool
type StoppedTransferError ¶
type StoppedTransferError struct {
Err string
}
func (*StoppedTransferError) Error ¶
func (e *StoppedTransferError) Error() string
type TimestampedError ¶
type TimestampedError struct {
// contains filtered or unexported fields
}
type TransferDetails ¶
type TransferDetails struct { // Url is the url.URL of the cache and port Url url.URL // Proxy specifies if a proxy should be used Proxy bool // Specifies the pack option in the transfer URL PackOption string }
func GenerateTransferDetailsUsingCache ¶
func GenerateTransferDetailsUsingCache(cache CacheInterface, opts TransferDetailsOptions) []TransferDetails
func NewTransferDetails ¶
func NewTransferDetails(cache namespaces.Cache, opts TransferDetailsOptions) []TransferDetails
NewTransferDetails creates the TransferDetails struct with the given cache
func NewTransferDetailsUsingDirector ¶
func NewTransferDetailsUsingDirector(cache namespaces.DirectorCache, opts TransferDetailsOptions) []TransferDetails
NewTransferDetails creates the TransferDetails struct with the given cache