s3git

package module
v0.0.0-...-41cac4f Latest Latest
Warning

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

Go to latest
Published: May 26, 2016 License: Apache-2.0 Imports: 19 Imported by: 0

README

s3git-go

This is the go SDK package for s3git.

For brevity reasons, error handling and other boilerplate code like package naming etc. is not shown in the examples. Actual client code should always check for errors, see s3git as an example.

DISCLAIMER: This software is still under development (although the storage format/model using BLAKE2 hashing is stable) -- use at your own peril for now

Note that the API is not stable yet, you can expect minor changes

BLAKE2 Tree Hashing

If you would like to understand how s3git uses the BLAKE2 Tree hashing mode please see here.

Development environment

See here for setting up the development environment.

Create a repository

import "github.com/s3git/s3git-go"

// Create repo
repo, _ := s3git.InitRepository(".")

// Add some data
repo.Add(strings.NewReader("hello s3git"))

// Commit changes
repo.Commit("Initial commit")

// List commits
commits, _ := repo.ListCommits("")

for commit := range commits {
    fmt.Println(commit)
}

See here for the full example (and others). And run like this:

$ cd $GOPATH/src/github.com/s3git/s3git-go/examples
$ go run create.go

Clone a repository

import "github.com/s3git/s3git-go"

options := []s3git.CloneOptions{}
options = append(options, s3git.CloneOptionSetAccessKey("AKIAJYNT4FCBFWDQPERQ"))
options = append(options, s3git.CloneOptionSetSecretKey("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"))

// Clone a repo
repo, _ := s3git.Clone("s3://s3git-spoon-knife", ".", options...)

// List contents
list, _ := repo.List("")

for l := range list {
    fmt.Println(l)
}

Make changes and push

import "github.com/s3git/s3git-go"

repo, _ := s3git.OpenRepository(".")

repo.Add(strings.NewReader(fmt.Sprint(time.Now())))

repo.Commit("New commit")

hydrate := false 	// For explanation, see https://github.com/s3git/s3git/blob/master/BLAKE2.md#hydrated
repo.Push(hydrate)

See change_and_push.go.

Pull down changes

import "github.com/s3git/s3git-go"

repo, _ := s3git.OpenRepository(".")

repo.Pull()

repo.Log()

Extract data

import "github.com/s3git/s3git-go"

repo, _ := s3git.OpenRepository(".")

r, _ := repo.Get("012345678")

io.Copy(os.Stdout, r)

Clone a repository with progress

import "github.com/s3git/s3git-go"

repo, _ := s3git.Clone("s3://s3git-100m", ".")

Contributions

Contributions are welcome! Please see CONTRIBUTING.md.

License

s3git-go is released under the Apache License v2.0. You can find the complete text in the file LICENSE.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CloneOptionSetAccessKey

func CloneOptionSetAccessKey(accessKey string) func(optns *cloneOptions)

func CloneOptionSetDownloadProgress

func CloneOptionSetDownloadProgress(progressDownloading func(maxTicks int64)) func(optns *cloneOptions)

func CloneOptionSetEndpoint

func CloneOptionSetEndpoint(endpoint string) func(optns *cloneOptions)

func CloneOptionSetLeafSize

func CloneOptionSetLeafSize(leafSize uint32) func(optns *cloneOptions)

func CloneOptionSetMaxRepoSize

func CloneOptionSetMaxRepoSize(maxRepoSize uint64) func(optns *cloneOptions)

func CloneOptionSetProcessingProgress

func CloneOptionSetProcessingProgress(progressProcessing func(maxTicks int64)) func(optns *cloneOptions)

func CloneOptionSetSecretKey

func CloneOptionSetSecretKey(secretKey string) func(optns *cloneOptions)

func InitOptionSetLeafSize

func InitOptionSetLeafSize(leafSize uint32) func(optns *initOptions)

func InitOptionSetMaxRepoSize

func InitOptionSetMaxRepoSize(maxRepoSize uint64) func(optns *initOptions)

func ListCommitOptionSetOnlySnapshots

func ListCommitOptionSetOnlySnapshots(onlySnapshots bool) func(optns *listCommitOptions)

func PushBlobDeduped

func PushBlobDeduped(hash string, size *uint64, client backend.Backend) (newlyUploaded bool, err error)

Push a blob to the back end store in deduplicated format

func RemoteOptionSetEndpoint

func RemoteOptionSetEndpoint(endpoint string) func(optns *remoteOptions)

func SnapshotListOptionSetJsonOutput

func SnapshotListOptionSetJsonOutput(jsonOutput bool) func(optns *snapshotListOptions)

func SnapshotListOptionSetPresignedUrls

func SnapshotListOptionSetPresignedUrls(presignedUrls bool) func(optns *snapshotListOptions)

func SnapshotListOptionSetShowHash

func SnapshotListOptionSetShowHash(showHash bool) func(optns *snapshotListOptions)

Types

type CloneOptions

type CloneOptions func(*cloneOptions)

type Commit

type Commit struct {
	Hash       string
	Message    string
	TimeStamp  string
	Parent     string
	IsSnapshot bool
}

type InitOptions

type InitOptions func(*initOptions)

type ListCommitOptions

type ListCommitOptions func(*listCommitOptions)

type Remote

type Remote struct {
	Name     string
	Resource string
}

type RemoteOptions

type RemoteOptions func(*remoteOptions)

type Repository

type Repository struct {
	Remotes []Remote
}

func Clone

func Clone(url, path string, options ...CloneOptions) (*Repository, error)

Clone a remote repository

func InitRepository

func InitRepository(path string, options ...InitOptions) (*Repository, error)

Initialize a new repository

func OpenRepository

func OpenRepository(path string) (*Repository, error)

Open an existing repository

func (Repository) Add

func (repo Repository) Add(r io.Reader) (string, bool, error)

Add a stream to the repository

func (Repository) Commit

func (repo Repository) Commit(message string) (hash string, empty bool, err error)

Perform a commit for the repository

func (Repository) CommitToBranch

func (repo Repository) CommitToBranch(message, branch string) (hash string, empty bool, err error)

Perform a commit for the named branch of the repository

func (Repository) Get

func (repo Repository) Get(hash string) (io.Reader, error)

Get a stream from the repository

func (Repository) List

func (repo Repository) List(prefix string) (<-chan string, error)

List the contents of a repository

func (Repository) ListCommits

func (repo Repository) ListCommits(branch string, options ...ListCommitOptions) (<-chan Commit, error)

List the commits for a repository

func (Repository) MakeUnique

func (repo Repository) MakeUnique(prefix string) (string, error)

Get the full size unique hash for a given prefix. Return error in case none or multiple candidates are found

func (Repository) Pull

func (repo Repository) Pull(progress func(maxTicks int64)) error

Pull updates for the repository

func (Repository) Push

func (repo Repository) Push(hydrated bool, progress func(maxTicks int64)) error

Perform a push to the back end for the repository

func (Repository) RemoteAdd

func (repo Repository) RemoteAdd(name, resource, accessKey, secretKey string, options ...RemoteOptions) error

func (Repository) RemotesShow

func (repo Repository) RemotesShow() ([]Remote, error)

func (Repository) SnapshotCheckout

func (repo Repository) SnapshotCheckout(path, commit string, dedupe bool) error

Checkout a snapshot for the repository

func (Repository) SnapshotCreate

func (repo Repository) SnapshotCreate(path, message string) (hash string, empty bool, err error)

Create a snapshot for the repository

func (Repository) SnapshotList

func (repo Repository) SnapshotList(commit string, options ...SnapshotListOptions) error

List a snapshot for the repository

func (Repository) SnapshotStatus

func (repo Repository) SnapshotStatus(path, commit string) error

Show status for a snapshot of the repository

func (Repository) Statistics

func (repo Repository) Statistics() (*Statistics, error)

Get statistics for the repository

func (Repository) Status

func (repo Repository) Status() (<-chan string, error)

Get the list of changes for a repository

type SnapshotListOptions

type SnapshotListOptions func(*snapshotListOptions)

type Statistics

type Statistics struct {
	Objects   uint64
	TotalSize uint64
	StageSize uint64
	CacheSize uint64
}

Directories

Path Synopsis
internal
backend/acd
Backend connection to Amazon Cloud Drive
Backend connection to Amazon Cloud Drive
cas
kv

Jump to

Keyboard shortcuts

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