sync

package
v0.1.14 Latest Latest
Warning

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

Go to latest
Published: Feb 1, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Cmd = &cobra.Command{
	Use:   "sync",
	Short: "Sync images between IBM COS buckets",
	Long: `Sync images between IBM COS buckets
pvsadm image sync --help for information

# Set the API key or feed the --api-key commandline argument
export IBMCLOUD_API_KEY=<IBM_CLOUD_API_KEY>

Examples:

# using spec yaml file
pvsadm image sync --spec-file spec.yaml

Sample spec.yaml file:
---
- source:
    bucket: bucket-fqsdgh
    cos: cos-test-buphij
    object: ".txt"
    storageClass: smart
    region: jp-tok
  target:
  - bucket: bucket-ielfqq
    storageClass: smart
    region: jp-tok
  - bucket: bucket-kkoyrg
    storageClass: smart
    region: jp-tok
- source:
    bucket: bucket-embocx
    cos: cos-test-icrbul
    object: ""
    storageClass: smart
    region: us-east
  target:
  - bucket: bucket-xgskog
    storageClass: standard
    region: jp-tok
  - bucket: bucket-nomoer
    storageClass: cold
    region: jp-tok

`,
	RunE: func(cmd *cobra.Command, args []string) error {

		var apikey string = pkg.Options.APIKey
		opt := pkg.ImageCMDOptions
		start := time.Now()

		bxCli, err := client.NewClientWithEnv(apikey, pkg.Options.Environment, pkg.Options.Debug)
		if err != nil {
			return err
		}

		spec, err := getSpec(opt.SpecYAML)
		if err != nil {
			return err
		}

		instanceList, err := createInstanceList(spec, bxCli)
		if err != nil {
			return err
		}

		err = syncObjects(spec, instanceList)
		if err != nil {
			return err
		}

		duration := time.Since(start)
		klog.Infof("Total elapsed time: %v", duration)
		return nil
	},
}

Functions

This section is empty.

Types

type InstanceItem

type InstanceItem struct {
	Source SyncClient
	Target []SyncClient
}

instance item for source and target instances

type SyncClient

type SyncClient interface {
	// S3Client methods
	CopyObjectToBucket(srcBucketName string, destBucketName string, objectName string) error
	CheckBucketLocationConstraint(bucketName string, bucketLocationConstraint string) (bool, error)
	SelectObjects(bucketName string, regex string) ([]string, error)
}

sync client interface

func NewS3Client

func NewS3Client(c *client.Client, instanceName string, region string) (SyncClient, error)

Directories

Path Synopsis
Code generated by MockGen.
Code generated by MockGen.

Jump to

Keyboard shortcuts

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