astrolabe

package
v0.5.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 13, 2022 License: Apache-2.0 Imports: 21 Imported by: 19

Documentation

Overview

* Copyright 2019 the Astrolabe contributors * SPDX-License-Identifier: Apache-2.0 * 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

Constants

View Source
const (
	PvcPEType        = "pvc"
	ParaVirtPvPEType = "paravirt-pv"
	IvdPEType        = "ivd"
)
View Source
const (
	S3TransportType = "s3"
	S3URLParam      = "url"
	S3HostParam     = "host"
	S3BucketParam   = "bucket"
	S3KeyParam      = "key"
	S3UseHTTPParam  = "http"
)
View Source
const (
	DataExt     = ""
	MDExt       = ".md"
	CombinedExt = ".zip"
	PEInfoExt   = ".peinfo"
)

Variables

This section is empty.

Functions

func GetNamespaceAndNameFromPEID added in v0.2.0

func GetNamespaceAndNameFromPEID(peid ProtectedEntityID) (namespace string, name string, err error)

func StringFromCopyCreateOption added in v0.5.0

func StringFromCopyCreateOption(options CopyCreateOptions) string

func UnzipFileToProtectedEntity added in v0.4.0

func UnzipFileToProtectedEntity(ctx context.Context, zipFileReader io.ReaderAt, zipFileSize int64, destPE ProtectedEntity) error

func ZipProtectedEntityToFile added in v0.4.0

func ZipProtectedEntityToFile(ctx context.Context, srcPE ProtectedEntity, zipFileWriter io.WriteCloser) (bytesWritten int64, err error)

func ZipProtectedEntityToWriter added in v0.4.0

func ZipProtectedEntityToWriter(ctx context.Context, pe ProtectedEntity, writer io.Writer) error

Types

type CopyCreateOptions

type CopyCreateOptions int
const (
	AllocateNewObject    CopyCreateOptions = 1
	UpdateExistingObject CopyCreateOptions = 2
	AllocateObjectWithID CopyCreateOptions = 3
)

func CopyCreateOptionFromString added in v0.5.0

func CopyCreateOptionFromString(optionStr string) CopyCreateOptions

type DataTransport

type DataTransport struct {
	// contains filtered or unexported fields
}

func NewDataTransport

func NewDataTransport(transportType string, params map[string]string) DataTransport

func NewDataTransportForS3

func NewDataTransportForS3(host string, bucket string, key string) DataTransport

func NewDataTransportForS3URL

func NewDataTransportForS3URL(url string) DataTransport

func NewS3CombinedTransportForPEID added in v0.2.0

func NewS3CombinedTransportForPEID(peid ProtectedEntityID, s3Config S3Config) (DataTransport, error)

func NewS3DataTransportForPEID added in v0.2.0

func NewS3DataTransportForPEID(peid ProtectedEntityID, s3Config S3Config) (DataTransport, error)

func NewS3MDTransportForPEID added in v0.2.0

func NewS3MDTransportForPEID(peid ProtectedEntityID, s3Config S3Config) (DataTransport, error)

func NewS3PEInfoTransportForPEID added in v0.2.0

func NewS3PEInfoTransportForPEID(peid ProtectedEntityID, s3Config S3Config) (DataTransport, error)

func NewS3TransportForPEID added in v0.2.0

func NewS3TransportForPEID(peid ProtectedEntityID, ext string, s3Config S3Config) (DataTransport, error)

func (DataTransport) GetParam

func (this DataTransport) GetParam(key string) (string, bool)

func (DataTransport) GetTransportType

func (this DataTransport) GetTransportType() string

func (DataTransport) MarshalJSON

func (this DataTransport) MarshalJSON() ([]byte, error)

func (*DataTransport) UnmarshalJSON

func (this *DataTransport) UnmarshalJSON(data []byte) error

type GenericTask

type GenericTask struct {
	// Fields are public so we don't need setters from users of this structure
	ID                        TaskID
	Completed                 bool
	TaskStatus                TaskStatus
	Details                   string
	StartedTime, FinishedTime time.Time
	Progress                  float64
	Result                    interface{}
}

func NewGenericTask

func NewGenericTask() GenericTask

func (GenericTask) Cancel

func (this GenericTask) Cancel() error

func (GenericTask) GetDetails

func (this GenericTask) GetDetails() string

func (GenericTask) GetFinishedTime

func (this GenericTask) GetFinishedTime() time.Time

func (GenericTask) GetModelTaskInfo

func (this GenericTask) GetModelTaskInfo() models.TaskInfo

func (GenericTask) GetProgress

func (this GenericTask) GetProgress() float64

func (GenericTask) GetResult

func (this GenericTask) GetResult() interface{}

func (GenericTask) GetStartedTime

func (this GenericTask) GetStartedTime() time.Time

func (GenericTask) GetStatus

func (this GenericTask) GetStatus() TaskStatus

func (GenericTask) GetTaskID

func (this GenericTask) GetTaskID() TaskID

func (GenericTask) GetTaskStatus

func (this GenericTask) GetTaskStatus() TaskStatus

type ProtectedEntity

type ProtectedEntity interface {
	GetInfo(ctx context.Context) (ProtectedEntityInfo, error)
	GetCombinedInfo(ctx context.Context) ([]ProtectedEntityInfo, error)
	/*
	 * Snapshot APIs
	 */
	Snapshot(ctx context.Context, params map[string]map[string]interface{}) (ProtectedEntitySnapshotID, error)
	ListSnapshots(ctx context.Context) ([]ProtectedEntitySnapshotID, error)
	DeleteSnapshot(ctx context.Context, snapshotToDelete ProtectedEntitySnapshotID, params map[string]map[string]interface{}) (bool, error)
	GetInfoForSnapshot(ctx context.Context, snapshotID ProtectedEntitySnapshotID) (*ProtectedEntityInfo, error)

	GetComponents(ctx context.Context) ([]ProtectedEntity, error)
	GetID() ProtectedEntityID

	// GetDataReader returns a reader for the data of the ProtectedEntity.  The ProtectedEntity will pick the
	// best data path to provide the Reader stream.  If the ProtectedEntity does not have any data, nil will be
	// returned
	GetDataReader(ctx context.Context) (io.ReadCloser, error)

	// GetMetadataReader returns a reader for the metadata of the ProtectedEntity.  The ProtectedEntity will pick the
	// best data path to provide the Reader stream.  If the ProtectedEntity does not have any metadata, nil will be
	// returned
	GetMetadataReader(ctx context.Context) (io.ReadCloser, error)

	// Overwrite replaces the data and metadata of the ProtectedEntity with the metadata from the sourcePE
	// The ID of the protected entity does not change
	// Any components will also be overwritten from the components of the sourcePE if the overwriteComponents flag is set
	Overwrite(ctx context.Context, sourcePE ProtectedEntity, params map[string]map[string]interface{},
		overwriteComponents bool) error
}

func GetPEFromZipStream added in v0.4.0

func GetPEFromZipStream(ctx context.Context, reader io.ReaderAt, size int64) (ProtectedEntity, error)

type ProtectedEntityID

type ProtectedEntityID struct {
	// contains filtered or unexported fields
}

func NewProtectedEntityID

func NewProtectedEntityID(peType string, id string) ProtectedEntityID

func NewProtectedEntityIDFromModel

func NewProtectedEntityIDFromModel(mpei *models.ProtectedEntityID) (ProtectedEntityID, error)

func NewProtectedEntityIDFromString

func NewProtectedEntityIDFromString(peiString string) (returnPEI ProtectedEntityID, returnError error)

func NewProtectedEntityIDWithNamespace added in v0.2.0

func NewProtectedEntityIDWithNamespace(peType string, name string, namespace string) ProtectedEntityID

func NewProtectedEntityIDWithNamespaceAndSnapshot added in v0.2.0

func NewProtectedEntityIDWithNamespaceAndSnapshot(peType string, name string, namespace string, snapshotID string) ProtectedEntityID

func NewProtectedEntityIDWithSnapshotID

func NewProtectedEntityIDWithSnapshotID(peType string, id string, snapshotID ProtectedEntitySnapshotID) ProtectedEntityID

func (ProtectedEntityID) GetBaseID added in v0.5.0

func (this ProtectedEntityID) GetBaseID() ProtectedEntityID

func (ProtectedEntityID) GetID

func (this ProtectedEntityID) GetID() string

func (ProtectedEntityID) GetModelProtectedEntityID

func (this ProtectedEntityID) GetModelProtectedEntityID() *models.ProtectedEntityID

func (ProtectedEntityID) GetPeType

func (this ProtectedEntityID) GetPeType() string

func (ProtectedEntityID) GetSnapshotID

func (this ProtectedEntityID) GetSnapshotID() ProtectedEntitySnapshotID

func (ProtectedEntityID) HasSnapshot

func (this ProtectedEntityID) HasSnapshot() bool

func (ProtectedEntityID) IDWithSnapshot added in v0.2.0

func (this ProtectedEntityID) IDWithSnapshot(snapshotID ProtectedEntitySnapshotID) ProtectedEntityID

func (ProtectedEntityID) MarshalJSON

func (this ProtectedEntityID) MarshalJSON() ([]byte, error)

func (ProtectedEntityID) String

func (this ProtectedEntityID) String() string

func (*ProtectedEntityID) UnmarshalJSON

func (this *ProtectedEntityID) UnmarshalJSON(b []byte) error

type ProtectedEntityInfo

type ProtectedEntityInfo interface {
	GetID() ProtectedEntityID
	GetName() string
	GetSize() int64 // Size in bytes
	GetDataTransports() []DataTransport
	GetMetadataTransports() []DataTransport
	GetCombinedTransports() []DataTransport
	GetComponentIDs() []ProtectedEntityID
	GetModelProtectedEntityInfo() models.ProtectedEntityInfo
}

func NewProtectedEntityInfo

func NewProtectedEntityInfo(id ProtectedEntityID, name string, size int64, dataTransports []DataTransport, metadataTransports []DataTransport,
	combinedTransports []DataTransport, componentIDs []ProtectedEntityID) ProtectedEntityInfo

func NewProtectedEntityInfoFromModel

func NewProtectedEntityInfoFromModel(mpei *models.ProtectedEntityInfo) (ProtectedEntityInfo, error)

type ProtectedEntityInfoImpl

type ProtectedEntityInfoImpl struct {
	// contains filtered or unexported fields
}

func (*ProtectedEntityInfoImpl) FillFromModel

func (this *ProtectedEntityInfoImpl) FillFromModel(jsonStruct *models.ProtectedEntityInfo) error

func (ProtectedEntityInfoImpl) GetCombinedTransports

func (this ProtectedEntityInfoImpl) GetCombinedTransports() []DataTransport

func (ProtectedEntityInfoImpl) GetComponentIDs

func (this ProtectedEntityInfoImpl) GetComponentIDs() []ProtectedEntityID

func (ProtectedEntityInfoImpl) GetDataTransports

func (this ProtectedEntityInfoImpl) GetDataTransports() []DataTransport

func (ProtectedEntityInfoImpl) GetID

func (ProtectedEntityInfoImpl) GetMetadataTransports

func (this ProtectedEntityInfoImpl) GetMetadataTransports() []DataTransport

func (ProtectedEntityInfoImpl) GetModelProtectedEntityInfo

func (this ProtectedEntityInfoImpl) GetModelProtectedEntityInfo() models.ProtectedEntityInfo

func (ProtectedEntityInfoImpl) GetName

func (this ProtectedEntityInfoImpl) GetName() string

func (ProtectedEntityInfoImpl) GetSize added in v0.4.0

func (this ProtectedEntityInfoImpl) GetSize() int64

func (ProtectedEntityInfoImpl) MarshalJSON

func (this ProtectedEntityInfoImpl) MarshalJSON() ([]byte, error)

func (*ProtectedEntityInfoImpl) UnmarshalJSON

func (this *ProtectedEntityInfoImpl) UnmarshalJSON(data []byte) error

type ProtectedEntityManager

type ProtectedEntityManager interface {
	GetProtectedEntity(ctx context.Context, id ProtectedEntityID) (ProtectedEntity, error)
	GetProtectedEntityTypeManager(peType string) ProtectedEntityTypeManager
	ListEntityTypeManagers() []ProtectedEntityTypeManager
}

type ProtectedEntitySnapshotID

type ProtectedEntitySnapshotID struct {
	// contains filtered or unexported fields
}

func NewProtectedEntitySnapshotID

func NewProtectedEntitySnapshotID(pesiString string) ProtectedEntitySnapshotID

func NewProtectedEntitySnapshotIDFromModel added in v0.2.0

func NewProtectedEntitySnapshotIDFromModel(mpei *models.ProtectedEntitySnapshotID) ProtectedEntitySnapshotID

func (ProtectedEntitySnapshotID) GetID

func (this ProtectedEntitySnapshotID) GetID() string

func (ProtectedEntitySnapshotID) GetModelProtectedEntitySnapshotID

func (this ProtectedEntitySnapshotID) GetModelProtectedEntitySnapshotID() models.ProtectedEntitySnapshotID

func (ProtectedEntitySnapshotID) String

func (this ProtectedEntitySnapshotID) String() string

type ProtectedEntityTypeManager

type ProtectedEntityTypeManager interface {
	GetTypeName() string
	GetProtectedEntity(ctx context.Context, id ProtectedEntityID) (ProtectedEntity, error)
	GetProtectedEntities(ctx context.Context) ([]ProtectedEntityID, error)
	Copy(ctx context.Context, pe ProtectedEntity, params map[string]map[string]interface{}, options CopyCreateOptions) (ProtectedEntity, error)
	CopyFromInfo(ctx context.Context, info ProtectedEntityInfo, params map[string]map[string]interface{}, options CopyCreateOptions) (ProtectedEntity, error)
}

type S3Config added in v0.2.0

type S3Config struct {
	Port      int    `json:"port,omitempty"`
	Host      net.IP `json:"host,omitempty"`
	AccessKey string `json:"accessKey,omitempty"`
	Secret    string `json:"secret,omitempty"`
	Prefix    string `json:"prefix,omitempty"`
	URLBase   string `json:"urlBase,omitempty"`
	Region    string `json:"region,omitempty"`
	UseHttp   bool   `json:"http,omitempty"`
}

type Task

type Task interface {
	GetID() TaskID
	GetDetails() string
	GetFinishedTime() time.Time
	GetStartedTime() time.Time
	GetProgress() float64
	GetResult() interface{}
	GetModelTaskInfo() models.TaskInfo
	Cancel() error
}

type TaskID

type TaskID struct {
	// contains filtered or unexported fields
}

func GenerateTaskID

func GenerateTaskID() TaskID

func (TaskID) GetModelTaskID

func (this TaskID) GetModelTaskID() *models.TaskID

type TaskStatus

type TaskStatus int
const (
	Running TaskStatus = iota
	Success
	Failed
	Cancelled
)

func (TaskStatus) String

func (this TaskStatus) String() string

type ZipProtectedEntity

type ZipProtectedEntity struct {
	// contains filtered or unexported fields
}

func (ZipProtectedEntity) DeleteSnapshot added in v0.4.0

func (recv ZipProtectedEntity) DeleteSnapshot(ctx context.Context, snapshotToDelete ProtectedEntitySnapshotID, params map[string]map[string]interface{}) (bool, error)

func (ZipProtectedEntity) GetCombinedInfo added in v0.4.0

func (recv ZipProtectedEntity) GetCombinedInfo(ctx context.Context) ([]ProtectedEntityInfo, error)

func (ZipProtectedEntity) GetComponents added in v0.4.0

func (recv ZipProtectedEntity) GetComponents(ctx context.Context) ([]ProtectedEntity, error)

func (ZipProtectedEntity) GetDataReader added in v0.4.0

func (recv ZipProtectedEntity) GetDataReader(ctx context.Context) (io.ReadCloser, error)

func (ZipProtectedEntity) GetID added in v0.4.0

func (ZipProtectedEntity) GetInfo added in v0.4.0

func (ZipProtectedEntity) GetInfoForSnapshot added in v0.4.0

func (recv ZipProtectedEntity) GetInfoForSnapshot(ctx context.Context, snapshotID ProtectedEntitySnapshotID) (*ProtectedEntityInfo, error)

func (ZipProtectedEntity) GetMetadataReader added in v0.4.0

func (recv ZipProtectedEntity) GetMetadataReader(ctx context.Context) (io.ReadCloser, error)

func (ZipProtectedEntity) ListSnapshots added in v0.4.0

func (recv ZipProtectedEntity) ListSnapshots(ctx context.Context) ([]ProtectedEntitySnapshotID, error)

func (ZipProtectedEntity) Overwrite added in v0.4.0

func (recv ZipProtectedEntity) Overwrite(ctx context.Context, sourcePE ProtectedEntity, params map[string]map[string]interface{}, overwriteComponents bool) error

func (ZipProtectedEntity) Snapshot added in v0.4.0

func (recv ZipProtectedEntity) Snapshot(ctx context.Context, params map[string]map[string]interface{}) (ProtectedEntitySnapshotID, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL