git

package
v0.7.4 Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2023 License: Apache-2.0 Imports: 14 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Organization string
	Type         string
	ServerURL    string
	SSLNoVerify  bool
	Token        string
}

Config represents the configuration of a git service

type File

type File struct {
	Content string
	Path    string
	SHA     string
}

File represents a single file and it's the user that is making the change

type Git

type Git interface {
	// GetContents retrieves file and/or directory contents from git
	GetContent(string, string) (*File, interface{}, error)

	// CreateFile creates a new repository file
	CreateFile(string, string, string, *User, []byte) (string, error)

	// UpdateFile updates a repository file
	UpdateFile(string, string, string, string, *User, []byte) (string, error)

	// DeleteFile deletes a repository file
	DeleteFile(string, string, string, string, *User) (string, error)

	// DeleteDirectory deletes a repository directory including all content
	DeleteDirectory(string, string, interface{}, *User) error

	// GetDiff returns the diff and committer details
	GetDiff(string, string, string) (string, error)

	// GetArchiveLink returns a download link for the repo/tag combo
	GetArchiveLink(string, string) (*url.URL, error)

	// TagRepo creates a new tag on a project
	TagRepo(string, string, *User) error

	// TagExists returns true if the tag exists
	TagExists(string, string) (bool, error)

	// UntagRepo removes a new tag from a project
	UntagRepo(string, string) error
}

Git is an interface that must be implemented by any git service that can be used with Chef-Guard

func NewGitClient

func NewGitClient(c *Config) (Git, error)

NewGitClient returns either a GitHub or GitLab client as Git interface

type GitHub

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

GitHub represents a GitHub client

func (*GitHub) CreateFile

func (g *GitHub) CreateFile(repo, path, msg string, usr *User, content []byte) (string, error)

CreateFile implements the Git interface

func (*GitHub) DeleteDirectory

func (g *GitHub) DeleteDirectory(repo, msg string, dir interface{}, usr *User) error

DeleteDirectory implements the Git interface

func (*GitHub) DeleteFile

func (g *GitHub) DeleteFile(repo, path, sha, msg string, usr *User) (string, error)

DeleteFile implements the Git interface

func (g *GitHub) GetArchiveLink(repo, tag string) (*url.URL, error)

GetArchiveLink implements the Git interface

func (*GitHub) GetContent

func (g *GitHub) GetContent(repo, path string) (*File, interface{}, error)

GetContent implements the Git interface

func (*GitHub) GetDiff

func (g *GitHub) GetDiff(repo, user, sha string) (string, error)

GetDiff implements the Git interface

func (*GitHub) TagExists

func (g *GitHub) TagExists(repo, tag string) (bool, error)

TagExists implements the Git interface

func (*GitHub) TagRepo

func (g *GitHub) TagRepo(repo, tag string, usr *User) error

TagRepo implements the Git interface

func (*GitHub) UntagRepo

func (g *GitHub) UntagRepo(repo, tag string) error

UntagRepo implements the Git interface

func (*GitHub) UpdateFile

func (g *GitHub) UpdateFile(repo, path, sha, msg string, usr *User, content []byte) (string, error)

UpdateFile implements the Git interface

type GitLab

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

GitLab represents a GitLab client

func (*GitLab) CreateFile

func (g *GitLab) CreateFile(project, path, msg string, usr *User, content []byte) (string, error)

CreateFile implements the Git interface

func (*GitLab) DeleteDirectory

func (g *GitLab) DeleteDirectory(project, msg string, dir interface{}, usr *User) error

DeleteDirectory implements the Git interface

func (*GitLab) DeleteFile

func (g *GitLab) DeleteFile(project, path, sha, msg string, usr *User) (string, error)

DeleteFile implements the Git interface

func (g *GitLab) GetArchiveLink(project, tag string) (*url.URL, error)

GetArchiveLink implements the Git interface

func (*GitLab) GetContent

func (g *GitLab) GetContent(project, path string) (*File, interface{}, error)

GetContent implements the Git interface

func (*GitLab) GetDiff

func (g *GitLab) GetDiff(project, user, sha string) (string, error)

GetDiff implements the Git interface

func (*GitLab) TagExists

func (g *GitLab) TagExists(project, tag string) (bool, error)

TagExists implements the Git interface

func (*GitLab) TagRepo

func (g *GitLab) TagRepo(project, tag string, usr *User) error

TagRepo implements the Git interface

func (*GitLab) UntagRepo

func (g *GitLab) UntagRepo(project, tag string) error

UntagRepo implements the Git interface

func (*GitLab) UpdateFile

func (g *GitLab) UpdateFile(project, path, sha, msg string, usr *User, content []byte) (string, error)

UpdateFile implements the Git interface

type User

type User struct {
	Name string
	Mail string
}

User represents the user that is making the change

Jump to

Keyboard shortcuts

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