2017-08-02 17:27:17 +00:00
|
|
|
/*
|
|
|
|
Copyright 2017 Heptio Inc.
|
|
|
|
|
|
|
|
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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
package cloudprovider
|
|
|
|
|
2017-08-14 14:14:30 +00:00
|
|
|
import (
|
|
|
|
"io"
|
|
|
|
"time"
|
2017-11-29 17:23:21 +00:00
|
|
|
|
|
|
|
"k8s.io/apimachinery/pkg/runtime"
|
2017-08-14 14:14:30 +00:00
|
|
|
)
|
2017-08-02 17:27:17 +00:00
|
|
|
|
2017-11-02 18:36:11 +00:00
|
|
|
// ObjectStore exposes basic object-storage operations required
|
2017-08-02 17:27:17 +00:00
|
|
|
// by Ark.
|
2017-11-02 18:36:11 +00:00
|
|
|
type ObjectStore interface {
|
2017-11-13 23:31:36 +00:00
|
|
|
// Init prepares the ObjectStore for usage using the provided map of
|
|
|
|
// configuration key-value pairs. It returns an error if the ObjectStore
|
|
|
|
// cannot be initialized from the provided config.
|
|
|
|
Init(config map[string]string) error
|
|
|
|
|
2017-08-02 17:27:17 +00:00
|
|
|
// PutObject creates a new object using the data in body within the specified
|
|
|
|
// object storage bucket with the given key.
|
2017-10-27 23:27:20 +00:00
|
|
|
PutObject(bucket string, key string, body io.Reader) error
|
2017-08-02 17:27:17 +00:00
|
|
|
|
|
|
|
// GetObject retrieves the object with the given key from the specified
|
|
|
|
// bucket in object storage.
|
|
|
|
GetObject(bucket string, key string) (io.ReadCloser, error)
|
|
|
|
|
|
|
|
// ListCommonPrefixes gets a list of all object key prefixes that come
|
|
|
|
// before the provided delimiter (this is often used to simulate a directory
|
|
|
|
// hierarchy in object storage).
|
|
|
|
ListCommonPrefixes(bucket string, delimiter string) ([]string, error)
|
|
|
|
|
2017-09-06 20:56:05 +00:00
|
|
|
// ListObjects gets a list of all objects in bucket that have the same prefix.
|
|
|
|
ListObjects(bucket, prefix string) ([]string, error)
|
|
|
|
|
2017-08-02 17:27:17 +00:00
|
|
|
// DeleteObject removes object with the specified key from the given
|
|
|
|
// bucket.
|
|
|
|
DeleteObject(bucket string, key string) error
|
2017-08-14 14:14:30 +00:00
|
|
|
|
|
|
|
// CreateSignedURL creates a pre-signed URL for the given bucket and key that expires after ttl.
|
|
|
|
CreateSignedURL(bucket, key string, ttl time.Duration) (string, error)
|
2017-08-02 17:27:17 +00:00
|
|
|
}
|
|
|
|
|
2017-11-02 18:36:11 +00:00
|
|
|
// BlockStore exposes basic block-storage operations required
|
2017-08-02 17:27:17 +00:00
|
|
|
// by Ark.
|
2017-11-02 18:36:11 +00:00
|
|
|
type BlockStore interface {
|
2017-11-13 23:31:36 +00:00
|
|
|
// Init prepares the BlockStore for usage using the provided map of
|
|
|
|
// configuration key-value pairs. It returns an error if the BlockStore
|
|
|
|
// cannot be initialized from the provided config.
|
|
|
|
Init(config map[string]string) error
|
|
|
|
|
2017-08-02 17:27:17 +00:00
|
|
|
// CreateVolumeFromSnapshot creates a new block volume, initialized from the provided snapshot,
|
|
|
|
// and with the specified type and IOPS (if using provisioned IOPS).
|
2017-09-25 01:45:36 +00:00
|
|
|
CreateVolumeFromSnapshot(snapshotID, volumeType, volumeAZ string, iops *int64) (volumeID string, err error)
|
2017-08-02 17:27:17 +00:00
|
|
|
|
2017-11-29 17:23:21 +00:00
|
|
|
// GetVolumeID returns the cloud provider specific identifier for the PersistentVolume.
|
|
|
|
GetVolumeID(pv runtime.Unstructured) (string, error)
|
|
|
|
|
|
|
|
// SetVolumeID sets the cloud provider specific identifier for the PersistentVolume.
|
|
|
|
SetVolumeID(pv runtime.Unstructured, volumeID string) (runtime.Unstructured, error)
|
|
|
|
|
2017-08-02 17:27:17 +00:00
|
|
|
// GetVolumeInfo returns the type and IOPS (if using provisioned IOPS) for a specified block
|
|
|
|
// volume.
|
2017-09-25 01:45:36 +00:00
|
|
|
GetVolumeInfo(volumeID, volumeAZ string) (string, *int64, error)
|
2017-08-02 17:27:17 +00:00
|
|
|
|
|
|
|
// IsVolumeReady returns whether the specified volume is ready to be used.
|
2017-09-25 01:45:36 +00:00
|
|
|
IsVolumeReady(volumeID, volumeAZ string) (ready bool, err error)
|
2017-08-02 17:27:17 +00:00
|
|
|
|
|
|
|
// CreateSnapshot creates a snapshot of the specified block volume, and applies the provided
|
|
|
|
// set of tags to the snapshot.
|
2017-09-25 01:45:36 +00:00
|
|
|
CreateSnapshot(volumeID, volumeAZ string, tags map[string]string) (snapshotID string, err error)
|
2017-08-02 17:27:17 +00:00
|
|
|
|
|
|
|
// DeleteSnapshot deletes the specified volume snapshot.
|
|
|
|
DeleteSnapshot(snapshotID string) error
|
|
|
|
}
|