mirror of
https://github.com/edgelesssys/constellation.git
synced 2024-12-17 20:04:36 -05:00
update api
This commit is contained in:
parent
2808012c9c
commit
7fee00566d
@ -5,7 +5,7 @@ SPDX-License-Identifier: AGPL-3.0-only
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Package client provides a client for the versions API.
|
Package client provides a general client to be used in for the several APIs.
|
||||||
|
|
||||||
The client needs to be authenticated with AWS. It should be used in internal
|
The client needs to be authenticated with AWS. It should be used in internal
|
||||||
development and CI tools for administrative tasks. For just fetching information
|
development and CI tools for administrative tasks. For just fetching information
|
||||||
@ -56,37 +56,8 @@ type Client struct {
|
|||||||
Log *logger.Logger
|
Log *logger.Logger
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewReadOnlyClient creates a new read-only client.
|
|
||||||
// This client can be used to fetch objects but cannot write updates.
|
|
||||||
func NewReadOnlyClient(ctx context.Context, region, bucket, distributionID string,
|
|
||||||
log *logger.Logger,
|
|
||||||
) (*Client, CloseFunc, error) {
|
|
||||||
staticUploadClient, staticUploadClientClose, err := staticupload.New(ctx, staticupload.Config{
|
|
||||||
Region: region,
|
|
||||||
Bucket: bucket,
|
|
||||||
DistributionID: distributionID,
|
|
||||||
CacheInvalidationStrategy: staticupload.CacheInvalidateBatchOnFlush,
|
|
||||||
})
|
|
||||||
if err != nil {
|
|
||||||
return nil, nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
client := &Client{
|
|
||||||
s3Client: staticUploadClient,
|
|
||||||
s3ClientClose: staticUploadClientClose,
|
|
||||||
bucket: bucket,
|
|
||||||
DryRun: true,
|
|
||||||
Log: log,
|
|
||||||
}
|
|
||||||
clientClose := func(ctx context.Context) error {
|
|
||||||
return client.Close(ctx)
|
|
||||||
}
|
|
||||||
|
|
||||||
return client, clientClose, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// NewClient creates a new client for the versions API.
|
// NewClient creates a new client for the versions API.
|
||||||
func NewClient(ctx context.Context, region, bucket, distributionID string, dryRun bool,
|
func NewClient(ctx context.Context, region, bucket, distributionID string, readOnly bool,
|
||||||
log *logger.Logger,
|
log *logger.Logger,
|
||||||
) (*Client, CloseFunc, error) {
|
) (*Client, CloseFunc, error) {
|
||||||
staticUploadClient, staticUploadClientClose, err := staticupload.New(ctx, staticupload.Config{
|
staticUploadClient, staticUploadClientClose, err := staticupload.New(ctx, staticupload.Config{
|
||||||
@ -103,7 +74,7 @@ func NewClient(ctx context.Context, region, bucket, distributionID string, dryRu
|
|||||||
s3Client: staticUploadClient,
|
s3Client: staticUploadClient,
|
||||||
s3ClientClose: staticUploadClientClose,
|
s3ClientClose: staticUploadClientClose,
|
||||||
bucket: bucket,
|
bucket: bucket,
|
||||||
DryRun: dryRun,
|
DryRun: readOnly,
|
||||||
Log: log,
|
Log: log,
|
||||||
cacheInvalidationWaitTimeout: 10 * time.Minute,
|
cacheInvalidationWaitTimeout: 10 * time.Minute,
|
||||||
}
|
}
|
||||||
|
@ -26,10 +26,13 @@ type Client struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// NewClient creates a new client for the versions API.
|
// NewClient creates a new client for the versions API.
|
||||||
func NewClient(ctx context.Context, region, bucket, distributionID string, dryRun bool,
|
func NewClient(ctx context.Context, region, bucket, distributionID string, readOnly bool,
|
||||||
log *logger.Logger,
|
log *logger.Logger,
|
||||||
) (*Client, CloseFunc, error) {
|
) (*Client, CloseFunc, error) {
|
||||||
genericClient, genericClientClose, err := apiclient.NewClient(ctx, region, bucket, distributionID, dryRun, log)
|
genericClient, genericClientClose, err := apiclient.NewClient(ctx, region, bucket, distributionID, readOnly, log)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
versionsClient := &Client{
|
versionsClient := &Client{
|
||||||
genericClient,
|
genericClient,
|
||||||
genericClientClose,
|
genericClientClose,
|
||||||
@ -45,18 +48,7 @@ func NewClient(ctx context.Context, region, bucket, distributionID string, dryRu
|
|||||||
func NewReadOnlyClient(ctx context.Context, region, bucket, distributionID string,
|
func NewReadOnlyClient(ctx context.Context, region, bucket, distributionID string,
|
||||||
log *logger.Logger,
|
log *logger.Logger,
|
||||||
) (*Client, CloseFunc, error) {
|
) (*Client, CloseFunc, error) {
|
||||||
genericClient, genericClientClose, err := apiclient.NewReadOnlyClient(ctx, region, bucket, distributionID, log)
|
return NewClient(ctx, region, bucket, distributionID, true, log)
|
||||||
if err != nil {
|
|
||||||
return nil, nil, err
|
|
||||||
}
|
|
||||||
versionsClient := &Client{
|
|
||||||
genericClient,
|
|
||||||
genericClientClose,
|
|
||||||
}
|
|
||||||
versionsClientClose := func(ctx context.Context) error {
|
|
||||||
return versionsClient.Close(ctx)
|
|
||||||
}
|
|
||||||
return versionsClient, versionsClientClose, err
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Close closes the client.
|
// Close closes the client.
|
||||||
|
Loading…
Reference in New Issue
Block a user