chartstreams

package
v0.0.0-...-58c0690 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2021 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ContainsStringSlice

func ContainsStringSlice(slice []string, str string) bool

ContainsStringSlice given a string slice and a string, returns boolean when is contained.

func SetLogLevel

func SetLogLevel(level string)

Types

type ChartProvider

type ChartProvider interface {
	Initialize() error
	GetChart(name, version string) (*Package, error)
	GetIndexFile() *helmrepo.IndexFile
	UpdateBranch(branch string) error
}

type CommitInfo

type CommitInfo struct {
	Time     *time.Time // commit time
	ID       string     // commit-id (sha)
	Revision string     // repository branch name
	Digest   string     // data digest
}

CommitInfo holds together time and commit hash.

type CommitIterFn

type CommitIterFn func(string, *git.Commit, bool) error

CommitIterFn function to be executed against each commit.

type Config

type Config struct {
	RepoURL             string // git repository URL
	RelativeDir         string // relative directory in repository
	CloneDepth          int    // number of commits to load from history
	ListenAddr          string // address to listen on (address:port)
	ForceClone          bool   // destroy the destination directory before cloning
	GitHubWebhookSecret string // GitHub's webhook secret to decode the events
}

Config application central configuration instance.

type FakeChartProvider

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

func NewFakeChartProvider

func NewFakeChartProvider(cfg *Config) *FakeChartProvider

func (*FakeChartProvider) GetChart

func (f *FakeChartProvider) GetChart(name, version string) (*Package, error)

func (*FakeChartProvider) GetIndexFile

func (f *FakeChartProvider) GetIndexFile() *helmrepo.IndexFile

func (*FakeChartProvider) Initialize

func (f *FakeChartProvider) Initialize() error

func (*FakeChartProvider) UpdateBranch

func (f *FakeChartProvider) UpdateBranch(branch string) error

type GitChartProvider

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

GitChartProvider provides Helm charts from a specified Git repository.

func NewGitChartProvider

func NewGitChartProvider(cfg *Config, workingDir string) *GitChartProvider

NewGitChartProvider returns an chart provider that can build and index charts from a Git repository.

func (*GitChartProvider) BuildIndexFile

func (g *GitChartProvider) BuildIndexFile() error

func (*GitChartProvider) BuildPackage

func (g *GitChartProvider) BuildPackage(
	path string,
	info *CommitInfo,
	commit *git.Commit,
) (*Package, error)

func (*GitChartProvider) GetChart

func (g *GitChartProvider) GetChart(name string, version string) (*Package, error)

GetChart returns a chart Package for the given chart name and version.

func (*GitChartProvider) GetIndexFile

func (g *GitChartProvider) GetIndexFile() *helmrepo.IndexFile

GetIndexFile returns the helm repository index-file instance.

func (*GitChartProvider) Initialize

func (g *GitChartProvider) Initialize() error

Initialize clones a Git repository and harvests, for each commit, Helm charts and their versions.

func (*GitChartProvider) UpdateBranch

func (g *GitChartProvider) UpdateBranch(name string) error

UpdateBranch fetches the latest changes from the remote.

type GitRepo

type GitRepo struct {
	WorkingDir string
	// contains filtered or unexported fields
}

GitRepo represents the actual Git repository, all actions taken on Git backend are here.

func NewGitRepo

func NewGitRepo(cfg *Config, workdingDir string) (*GitRepo, error)

NewGitRepo instantiate git repository by cloning, and extract repository information.

func (*GitRepo) CommitIter

func (g *GitRepo) CommitIter(fn CommitIterFn) error

CommitIter executed informed function on each branch commit.

func (*GitRepo) FetchBranch

func (g *GitRepo) FetchBranch(branchName string) error

func (*GitRepo) GetFilesFromCommit

func (g *GitRepo) GetFilesFromCommit(
	commit *git.Commit,
	path string,
) ([]*loader.BufferedFile, error)

GetFilesFromCommit returns a list of files inside the path for a given commit; this list of files is meant to be consumed by Helm's `loader.LoadFiles` function.

func (*GitRepo) LookupBranch

func (g *GitRepo) LookupBranch(branch string) (*git.Branch, error)

LookupBranch search for a remote branch, and if not found, a local branch instead.

func (*GitRepo) LookupBranchCommit

func (g *GitRepo) LookupBranchCommit(branch string) (*git.Commit, error)

LookupBranchCommit look up branch, and look up head commit, with this information it can checkout the branch tree and finally, set repository information about new head.

func (*GitRepo) LookupCommit

func (g *GitRepo) LookupCommit(id string) (*git.Commit, error)

LookupCommit search for informed commit id.

func (*GitRepo) ModifiedFiles

func (g *GitRepo) ModifiedFiles(c *git.Commit) ([]string, error)

ModifiedFiles for a given commit and tree, check what are the files that have changed, return them as string slice.

type Index

type Index struct {
	IndexFile *helmrepo.IndexFile // repository index-file
}

Index represent a chart index of some sort.

type IndexBuilder

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

IndexBuilder navigate the repository commits in order to discover charts, and store the relationship between chart version and commit-id.

func NewIndexBuilder

func NewIndexBuilder(cfg *Config, g *GitRepo) *IndexBuilder

NewIndexBuilder instantiate a Helm repository index-file builder.

func (*IndexBuilder) Build

func (i *IndexBuilder) Build() (*helmrepo.IndexFile, error)

Build create instance of index-file by inspecting commits.

func (*IndexBuilder) GetChartCommitInfo

func (i *IndexBuilder) GetChartCommitInfo(name, version string) *CommitInfo

GetChartCommitInfo return the commit information based on chart name and version, or nil in case of not found.

type Package

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

Package wraps the Helm Chart archive, which consists of chart files in a given directory packaged as a tarball, skipping ignored files in the process.

func LoadFiles

func LoadFiles(files []*loader.BufferedFile, t *time.Time) (*Package, error)

LoadFiles creates a Package using the given in-memory files.

func NewPackage

func NewPackage(dir string, t *time.Time) (*Package, error)

NewPackage instantiate a package by inspecting directory and loading the chart.

func (*Package) Build

func (p *Package) Build() error

Build inspect chart files skipping ignored files, creating a tarball payload out of chart instance.

func (*Package) Bytes

func (p *Package) Bytes() []byte

Bytes return buffer bytes.

func (*Package) SHA256

func (p *Package) SHA256() (string, error)

SHA256 returns the sha256 digest of package contents.

type Server

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

Server represents the chartstreams server offering its API. The server puts together the routes, and bootstrap steps in order to respond as a valid Helm repository.

func NewServer

func NewServer(cfg *Config, chartProvider ChartProvider) *Server

NewServer instantiate server.

func (*Server) DirectLinkHandler

func (s *Server) DirectLinkHandler(c *gin.Context)

DirectLinkHandler endpoint handler to directly load a chart tarball payload.

func (*Server) GitHubPullTriggerHandler

func (s *Server) GitHubPullTriggerHandler(c *gin.Context)

func (*Server) IndexHandler

func (s *Server) IndexHandler(c *gin.Context)

IndexHandler endpoint handler to marshal and return index yaml payload.

func (*Server) RootHandler

func (s *Server) RootHandler(c *gin.Context)

RootHandler returns a simple string.

func (*Server) SetupRoutes

func (s *Server) SetupRoutes() *gin.Engine

SetupRoutes register routes

func (*Server) Start

func (s *Server) Start() error

Start executes the boostrap steps in order to start listening on configured address.

Jump to

Keyboard shortcuts

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