Documentation ¶
Index ¶
- func IsFileNewOrModified(repoPath, file string) (bool, error)
- func Pull(repoPath, remote, branch string) error
- func SetUserEmail(repoPath, userEmail string) error
- func SetUserName(repoPath, userName string) error
- type GitResource
- type Repository
- func (r *Repository) KeyGetFuncForKindAndFormat(kind, format string) func(key string) (interface{}, bool, error)
- func (r *Repository) KeyListFuncForKind(kind string) func() []string
- func (r *Repository) PathForResource(resource *openshift.Resource, format string) string
- func (r *Repository) PathWithContextDir() string
- func (r *Repository) Pull() error
- func (r *Repository) Push() error
- func (r *Repository) ResourceFromPath(path string) *openshift.Resource
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsFileNewOrModified ¶
IsFileNewOrModified checks if the given file is either new or modified in the given git repository.
func SetUserEmail ¶
SetUserEmail sets the user's email for the given repository
func SetUserName ¶
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.
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.