walker

package
v0.7.19 Latest Latest
Warning

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

Go to latest
Published: Apr 7, 2024 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidSizeFileCode = "meshkit-11241"
	ErrCloningRepoCode     = "meshkit-11242"
)

Functions

func ErrCloningRepo

func ErrCloningRepo(err error) error

func ErrInvalidSizeFile

func ErrInvalidSizeFile(err error) error

Types

type DirInterceptor

type DirInterceptor func(Directory) error

type Directory

type Directory struct {
	Name string `json:"name,omitempty"`
	Path string `json:"path,omitempty"`
}

type File

type File struct {
	Name    string `json:"name,omitempty"`
	Content string `json:"content,omitempty"`
	Path    string `json:"path,omitempty"`
}

func WalkLocalDirectory

func WalkLocalDirectory(path string) ([]*File, error)

type FileInterceptor

type FileInterceptor func(File) error

type Git

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

Git represents the Git Walker

func NewGit

func NewGit() *Git

NewGit returns a pointer to an instance of Git

func (*Git) BaseURL

func (g *Git) BaseURL(baseurl string) *Git

BaseURL sets git repository base URL and returns a pointer to the same Git instance

func (*Git) Branch

func (g *Git) Branch(branch string) *Git

Branch sets git repository branch which will be cloned and returns a pointer to the same Git instance

func (*Git) MaxFileSize

func (g *Git) MaxFileSize(size int64) *Git

BaseURL sets git repository base URL and returns a pointer to the same Git instance

func (*Git) Owner

func (g *Git) Owner(owner string) *Git

Owner sets git repository owner and returns a pointer to the same Git instance

func (*Git) ReferenceName

func (g *Git) ReferenceName(refName string) *Git

func (*Git) RegisterDirInterceptor

func (g *Git) RegisterDirInterceptor(i DirInterceptor) *Git

func (*Git) RegisterFileInterceptor

func (g *Git) RegisterFileInterceptor(i FileInterceptor) *Git

func (*Git) Repo

func (g *Git) Repo(repo string) *Git

Repo sets github repository and returns a pointer to the same Git instance

func (*Git) Root

func (g *Git) Root(root string) *Git

Root sets git repository root node from where Git walker needs to start traversing and returns a pointer to the same Git instance

If the root parameter ends with a "/**" then github walker will run in "traversal" mode, ie. it will look into each sub directory of the root node If path will be prefixed with "/" if not already.

func (*Git) ShowLogs

func (g *Git) ShowLogs() *Git

ShowLogs enable the logs and returns a pointer to the same Git instance

func (*Git) Walk

func (g *Git) Walk() error

Walk will initiate traversal process

type Github

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

Github represents the Github Walker

func NewGithub

func NewGithub() *Github

NewGithub returns a pointer to an instance of Github

func (*Github) Branch

func (g *Github) Branch(branch string) *Github

Branch sets github repository branch which will be traversed and returns a pointer to the same Github instance

func (*Github) Owner

func (g *Github) Owner(owner string) *Github

Owner sets github repository owner and returns a pointer to the same Github instance

func (*Github) RegisterDirInterceptor

func (g *Github) RegisterDirInterceptor(i GithubDirInterceptor) *Github

RegisterFileInterceptor takes in a directory interceptor which will be invoked on each "directory" node and it returns pointer to the same github instance

Github Walker walks the nodes concurrently so if the interceptor is reading or writing to any variable from a higher namespace then those operations should be done in thread safe manner in order to avoid data races

func (*Github) RegisterFileInterceptor

func (g *Github) RegisterFileInterceptor(i GithubFileInterceptor) *Github

RegisterFileInterceptor takes in a file interceptor which will be invoked on each "file" node and it returns pointer to the same github instance

Github Walker walks the nodes concurrently so if the interceptor is reading or writing to any variable from a higher namespace then those operations should be done in thread safe manner in order to avoid data races

func (*Github) Repo

func (g *Github) Repo(repo string) *Github

Repo sets github repository and returns a pointer to the same Github instance

func (*Github) Root

func (g *Github) Root(root string) *Github

Root sets github repository root node from where Github walker needs to start traversing and returns a pointer to the same Github instance

If the root parameter ends with a "/**" then github walker will run in "traversal" mode, ie. it will look into each sub directory of the root node

If the root node ends with an extension, then that file will be returned and github walker will not traverse deeper

func (*Github) Walk

func (g *Github) Walk() error

Walk will initiate traversal process

type GithubContentAPI

type GithubContentAPI struct {
	Name        string `json:"name,omitempty"`
	Path        string `json:"path,omitempty"`
	SHA         string `json:"sha,omitempty"`
	Size        int64  `json:"size,omitempty"`
	URL         string `json:"url,omitempty"`
	HTMLURL     string `json:"html_url,omitempty"`
	GitURL      string `json:"git_url,omitempty"`
	DownloadURL string `json:"download_url,omitempty"`
	Type        string `json:"type,omitempty"`
	// Content will be empty when the path is of a directory
	Content string `json:"content,omitempty"`
	// Encoding will be empty when the path is of a directory
	Encoding string `json:"encoding,omitempty"`
}

GithubContentAPI represents Github API v3 response to /repos/{owner}/{repo}/contents/{path}?ref={branch}

type GithubDirInterceptor

type GithubDirInterceptor func(GithubDirectoryContentAPI) error

GithubDirInterceptor represents function signature which will be used on "dir" nodes when the github walker traverses the paths

type GithubDirectoryContentAPI

type GithubDirectoryContentAPI []GithubContentAPI

GithubDirectoryContentAPI represents Github API v3 response to /repos/{owner}/{repo}/contents/{path}?ref={branch} when "path" is of a directory

type GithubFileInterceptor

type GithubFileInterceptor func(GithubContentAPI) error

GithubFileInterceptor represents function signature which will be used on "file" nodes when the github walker traverses the paths

Jump to

Keyboard shortcuts

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