git

package
v0.0.0-...-8bbc6b9 Latest Latest
Warning

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

Go to latest
Published: Jun 1, 2016 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsFileNewOrModified

func IsFileNewOrModified(repoPath, file string) (bool, error)

IsFileNewOrModified checks if the given file is either new or modified in the given git repository.

func Pull

func Pull(repoPath, remote, branch string) error

Pull pulls changes from given remote branch.

func SetUserEmail

func SetUserEmail(repoPath, userEmail string) error

SetUserEmail sets the user's email for the given repository

func SetUserName

func SetUserName(repoPath, userName string) error

SetUserName sets the user's name for the given repository

Types

type GitResource

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

GitResource represents an OpenShift resource in a Git repository

func NewGitResource

func NewGitResource(repository *Repository, resource *openshift.Resource, format string) *GitResource

NewGitResource instantiates a new GitResource in the given repository, for the given resource, in the given format

func (*GitResource) Close

func (gr *GitResource) Close() error

Close closes the underlying file Needs to be called after writing implements the io.Closer interface

func (*GitResource) Commit

func (gr *GitResource) Commit() error

Commit commits the resource to the git repository

func (*GitResource) Delete

func (gr *GitResource) Delete() error

Delete deletes the resource from the filesystem does not complains if the file does not exists

func (*GitResource) Open

func (gr *GitResource) Open() error

Open opens the resource so that it could then be used as an io.Writer It then needs to be closed at the end.

func (*GitResource) Write

func (gr *GitResource) Write(p []byte) (n int, err error)

Write writes some data to the resource implements the io.Writer interface

type Repository

type Repository struct {
	// The underlying git repository
	*git.Repository

	// Path is the path of the repository on the FileSystem
	Path string

	// Branch is the branch that we will use to commit our changes
	Branch string

	// RemoteURL is the URL of the remote repository (optional).
	// If specified, we will pull/push from/to this remote
	RemoteURL string

	// ContextDir is the (optional) path (relative to `Path`)
	// which will be used inside the repository.
	ContextDir string
}

Repository represents a Git repository

func NewRepository

func NewRepository(path, branch, remoteURL, contextDir, userName, userEmail string) (*Repository, error)

NewRepository instantiates a new Git repository at the given path. If there is nothing at the given path, a new repository will be initialized: - If a remoteURL is provided, we will clone from this configured remote - Otherwise, we will just create an new empty repository

func (*Repository) KeyGetFuncForKindAndFormat

func (r *Repository) KeyGetFuncForKindAndFormat(kind, format string) func(key string) (interface{}, bool, error)

KeyGetFuncForKindAndFormat returns a GetByKey function, implements the cache.KeyGetter interface It is a function that returns the object that we "know about" for the given key ("namespace/name" format) - and a boolean if it exists for the given kind and format.

func (*Repository) KeyListFuncForKind

func (r *Repository) KeyListFuncForKind(kind string) func() []string

KeyListFuncForKind returns a ListKeys function, that implements the cache.KeyLister interface It is a function that returns the list of keys ("namespace/name" format) that we "know about" (to get a 2-way sync) for the given kind of resources. It simply walks the FS to list all the resources matching the given kind.

func (*Repository) PathForResource

func (r *Repository) PathForResource(resource *openshift.Resource, format string) string

PathForResource returns the full absolute path of the given resource, for the given format

func (*Repository) PathWithContextDir

func (r *Repository) PathWithContextDir() string

PathWithContextDir returns the full path of the directory where we will write the exported resources

func (*Repository) Pull

func (r *Repository) Pull() error

Pull pulls from the configured remote (if a remote as been configured)

func (*Repository) Push

func (r *Repository) Push() error

Push pushes to the configured remote (if a remote as been configured)

func (*Repository) ResourceFromPath

func (r *Repository) ResourceFromPath(path string) *openshift.Resource

ResourceFromPath returns a (minimalist) representation of the resource stored at the given path. Returns nil if no resource could be found at that path. Note that the returned resource contains only a reference (with kind, namespace and name), not the resource (content) itself.

Jump to

Keyboard shortcuts

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