Documentation
¶
Index ¶
- Variables
- func GetProviderKey(fs *ProviderConfig) string
- func InitAwsClient(ctx context.Context, fs *ProviderConfig) (*s3.Client, error)
- func RegisterS3Provider(kind Kind, builder S3ProviderBuilder)
- type AwsS3
- func (p *AwsS3) GetPreSignedURL(ctx context.Context, bucket, path string, expires time.Duration) (string, error)
- func (p *AwsS3) GetSTS(ctx context.Context, roleSessionName string) (*STSResponse, error)
- func (p *AwsS3) ParseUrlKey(urlStr string) (key string, err error)
- func (p *AwsS3) ProviderConfig() *ProviderConfig
- func (p *AwsS3) S3Client() *s3.Client
- type BizKey
- type Client
- func (c *Client) AddInterceptor(interceptor InterceptFunc)
- func (c *Client) Do(ctx context.Context, req *http.Request) (res *http.Response, err error)
- func (c *Client) DownloadObjectByKey(bizKey string, url string, localFile string, optFns ...DownloadOptionFn) error
- func (c *Client) GetProviderByBizKey(bizKey string) (S3Provider, error)
- func (c *Client) RegistryProvider(cfg *ProviderConfig, bizKey string) error
- type Config
- type Data
- type DownloadOption
- type DownloadOptionFn
- type EndpointResolverV2
- type FileIdentity
- type FileIdentityAPI
- type FileSource
- type GetFileIdentitiesRequest
- type GraphqlRequest
- type ID
- type InterceptFunc
- type Kind
- type ProviderConfig
- type Result
- type S3Provider
- type S3ProviderBuilder
- type STSResponse
Constants ¶
This section is empty.
Variables ¶
var ( // S3Builders s3 provider builders. S3Builders = map[Kind]S3ProviderBuilder{} )
Functions ¶
func GetProviderKey ¶
func GetProviderKey(fs *ProviderConfig) string
GetProviderKey get provider key.
func InitAwsClient ¶
InitAwsClient init aws s3 client.
func RegisterS3Provider ¶
func RegisterS3Provider(kind Kind, builder S3ProviderBuilder)
RegisterS3Provider register s3 provider builder. A builder is a function that creates a new s3 provider.
Types ¶
type AwsS3 ¶
type AwsS3 struct {
// contains filtered or unexported fields
}
AwsS3 aws s3 service for file storage.
func (*AwsS3) GetPreSignedURL ¶
func (p *AwsS3) GetPreSignedURL(ctx context.Context, bucket, path string, expires time.Duration) (string, error)
GetPreSignedURL get pre-signed url
func (*AwsS3) ParseUrlKey ¶
ParseUrlKey parse url key.
func (*AwsS3) ProviderConfig ¶
func (p *AwsS3) ProviderConfig() *ProviderConfig
ProviderConfig return ProviderConfig. Provider need hold a ProviderConfig.
type Client ¶
type Client struct { FileIdentityAPI *FileIdentityAPI // contains filtered or unexported fields }
Client file system client.
func (*Client) AddInterceptor ¶
func (c *Client) AddInterceptor(interceptor InterceptFunc)
AddInterceptor adds an interceptor to the APIClient
func (*Client) DownloadObjectByKey ¶
func (c *Client) DownloadObjectByKey(bizKey string, url string, localFile string, optFns ...DownloadOptionFn) error
DownloadObjectByKey download object by biz key(tenantID or ...).If local file exists, it will be overwritten.
func (*Client) GetProviderByBizKey ¶
func (c *Client) GetProviderByBizKey(bizKey string) (S3Provider, error)
GetProviderByBizKey get provider by biz key
func (*Client) RegistryProvider ¶
func (c *Client) RegistryProvider(cfg *ProviderConfig, bizKey string) error
RegistryProvider registry a file system provider.If provider is not exist, create a new one and cache it. Note that the cache key is the combination of access key id, endpoint, bucket and kind, maybe change it later. parameter bizKey is used to set/replace a customer key for the provider, so that you can get the provider by the key.
type Config ¶
type Config struct { BasePath string `json:"basePath,omitempty" yaml:"basePath,omitempty"` Host string `json:"host,omitempty" yaml:"host,omitempty"` Headers map[string]string `yaml:"headers,omitempty" json:"headers,omitempty"` UserAgent string `json:"userAgent,omitempty" yaml:"userAgent,omitempty"` HTTPClient *http.Client Providers []ProviderConfig `json:"providers" yaml:"providers"` }
Config file system config. if you want to add source config in config file.
type Data ¶
type Data struct {
FileIdentitiesForApp []*FileIdentity `json:"fileIdentitiesForApp"`
}
type DownloadOption ¶
type DownloadOption struct { // if true, overwrite the local file if it exists OverwrittenFile bool }
type DownloadOptionFn ¶
type DownloadOptionFn func(options *DownloadOption)
func WithOverwrittenFile ¶
func WithOverwrittenFile(overwrittenFile bool) DownloadOptionFn
type EndpointResolverV2 ¶
type EndpointResolverV2 struct { EndpointImmutable bool // contains filtered or unexported fields }
EndpointResolverV2 customer endpoint resolver
func (*EndpointResolverV2) ResolveEndpoint ¶
func (r *EndpointResolverV2) ResolveEndpoint(ctx context.Context, params s3.EndpointParameters) ( smithyendpoints.Endpoint, error, )
ResolveEndpoint resolve endpoint
type FileIdentity ¶
type FileIdentity struct { ID ID `json:"id"` TenantID ID `json:"tenantID"` AccessKeyID string `json:"accessKeyID"` AccessKeySecret string `json:"accessKeySecret"` RoleArn string `json:"roleArn"` Policy string `json:"policy,omitempty"` DurationSeconds int `json:"durationSeconds,omitempty"` IsDefault bool `json:"isDefault"` Source *FileSource `json:"source"` }
type FileIdentityAPI ¶
type FileIdentityAPI api
func (*FileIdentityAPI) GetFileIdentities ¶
func (a *FileIdentityAPI) GetFileIdentities(ctx context.Context, req *GetFileIdentitiesRequest) (ret []*FileIdentity, resp *http.Response, err error)
GetFileIdentities (POST fileIdentitiesForApp)
type FileSource ¶
type FileSource struct { ID ID `json:"id,omitempty"` Kind Kind `json:"kind,omitempty"` Endpoint string `json:"endpoint,omitempty"` EndpointImmutable bool `json:"endpointImmutable,omitempty"` StsEndpoint string `json:"stsEndpoint,omitempty"` Region string `json:"region,omitempty"` Bucket string `json:"bucket,omitempty"` BucketURL string `json:"bucketUrl,omitempty"` }
type GraphqlRequest ¶
type GraphqlRequest struct { Query string `json:"query"` Variables interface{} `json:"variables"` }
type InterceptFunc ¶
InterceptFunc is a function that intercepts a request before it is sent.
type ProviderConfig ¶
type ProviderConfig struct { // file source kind Kind Kind `json:"kind" yaml:"kind"` // access key id AccessKeyID string `json:"accessKeyID,omitempty" yaml:"accessKeyID"` // access key secret AccessKeySecret string `json:"accessKeySecret,omitempty" yaml:"accessKeySecret,omitempty"` // access endpoint, used for public access Endpoint string `json:"endpoint,omitempty" yaml:"endpoint,omitempty"` // endpoint is immutable, if it's custom domain, set to true EndpointImmutable bool `json:"endpointImmutable,omitempty" yaml:"endpointImmutable,omitempty"` // sts endpoint, used for sts StsEndpoint string `json:"stsEndpoint,omitempty" yaml:"stsEndpoint,omitempty"` // region, physical location of data storage Region string `json:"region,omitempty" yaml:"region,omitempty"` // file storage bucket Bucket string `json:"bucket" yaml:"bucket"` // file storage bucket url, used for matching url BucketUrl string `json:"bucketUrl" yaml:"bucketUrl"` // role arn, used for STS RoleArn string `json:"roleArn,omitempty" yaml:"roleArn,omitempty"` // specify the policy for the returned STS token Policy string `json:"policy,omitempty" yaml:"policy,omitempty"` // duration of the STS token, default 3600s DurationSeconds int `json:"durationSeconds,omitempty" yaml:"durationSeconds,omitempty"` }
ProviderConfig define file system source config.
func ToProviderConfig ¶
func ToProviderConfig(fi *FileIdentity) *ProviderConfig
type S3Provider ¶
type S3Provider interface { // ProviderConfig return ProviderConfig. Provider need hold a ProviderConfig. ProviderConfig() *ProviderConfig // ParseUrlKey parse url key. ParseUrlKey(urlStr string) (key string, err error) // GetSTS get sts response. GetSTS(ctx context.Context, roleSessionName string) (*STSResponse, error) // GetPreSignedURL get pre-signed url to make request format match each S3Provider. GetPreSignedURL(ctx context.Context, bucket, path string, expires time.Duration) (string, error) // S3Client return s3 client. S3Client() *s3.Client }
S3Provider s3 provider interface.
func BuildAwsS3 ¶
func BuildAwsS3(ctx context.Context, fileSource *ProviderConfig) (S3Provider, error)
BuildAwsS3 create aws s3 provider. it matches S3ProviderBuilder
type S3ProviderBuilder ¶
type S3ProviderBuilder func(context.Context, *ProviderConfig) (S3Provider, error)
S3ProviderBuilder s3 provider builder.