Documentation ¶
Index ¶
- Constants
- Variables
- type AuthProvider
- type CompileRequest
- type FeatureCompilationResult
- type FeatureCompilationResults
- type Repo
- func (r *Repo) Add(ctx context.Context, ns, featureName string, fType feature.FeatureType) error
- func (r *Repo) BasicAuth() transport.AuthMethod
- func (r *Repo) BranchName() (string, error)
- func (r *Repo) BuildDynamicTypeRegistry(ctx context.Context, protoDirPath string) (*protoregistry.Types, error)
- func (r *Repo) CheckoutRemoteBranch(branchName string) error
- func (r *Repo) Cleanup(ctx context.Context, branchName *string) error
- func (r *Repo) CleanupBranch(ctx context.Context, branchName *string) error
- func (r *Repo) Commit(ctx context.Context, message string) (string, error)
- func (r *Repo) Compile(ctx context.Context, req *CompileRequest) ([]*FeatureCompilationResult, error)
- func (r *Repo) CompileFeature(ctx context.Context, registry *protoregistry.Types, ...) (*feature.CompiledFeature, error)
- func (r *Repo) CreateOrRestore(branchName string) error
- func (r *Repo) CredentialsExist() error
- func (r *Repo) Eval(ctx context.Context, ns, featureName string, iCtx map[string]interface{}) (*anypb.Any, error)
- func (r *Repo) Fetch(branchName string) error
- func (r *Repo) FindFeatureFiles(ctx context.Context, namespaceFilter, featureFilter string, verify bool) ([]*feature.FeatureFile, int, error)
- func (r *Repo) Format(ctx context.Context) error
- func (r *Repo) FormatFeature(ctx context.Context, ff feature.FeatureFile) error
- func (r *Repo) GenBranchName() (string, error)
- func (r *Repo) GetContents(ctx context.Context) (map[metadata.NamespaceConfigRepoMetadata][]feature.FeatureFile, error)
- func (r *Repo) GetDirContents(_ context.Context, path string) ([]fs.ProviderFile, error)
- func (r *Repo) GetFeatureContents(ctx context.Context, namespace, featureName string) (*feature.FeatureContents, error)
- func (r *Repo) GetFeatureFile(ctx context.Context, namespace, featureName string) (*feature.FeatureFile, error)
- func (r *Repo) GetFeatureFiles(ctx context.Context, namespace string) ([]feature.FeatureFile, error)
- func (r *Repo) GetFeatureHash(ctx context.Context, namespace, featureName string) (*plumbing.Hash, error)
- func (r *Repo) GetFileContents(_ context.Context, path string) ([]byte, error)
- func (r *Repo) GetPRInfo(ctx context.Context, branchName string, ghCli *gh.GithubClient) (*github.PullRequest, []*github.PullRequestReview, []*github.CheckRun, error)
- func (r *Repo) GetURL() (*url.URL, error)
- func (r *Repo) HasReference(refName plumbing.ReferenceName) (bool, error)
- func (r *Repo) HasRemote(branchName string) (bool, error)
- func (r *Repo) HumanReadableHash() (string, error)
- func (r *Repo) IsNotExist(err error) bool
- func (r *Repo) Logf(format string, a ...any)
- func (r *Repo) MainBranchHash() (string, error)
- func (r *Repo) Merge(ctx context.Context, prNum *int, ghCli *gh.GithubClient) error
- func (r *Repo) MkdirAll(path string, perm os.FileMode) error
- func (r *Repo) Parse(ctx context.Context, ns, featureName string) error
- func (r *Repo) ParseMetadata(ctx context.Context) (*metadata.RootConfigRepoMetadata, ...)
- func (r *Repo) PersistFeature(ctx context.Context, registry *protoregistry.Types, namespace string, ...) error
- func (r *Repo) Pull() error
- func (r *Repo) ReBuildDynamicTypeRegistry(ctx context.Context, protoDirPath string) (*protoregistry.Types, error)
- func (r *Repo) Read(path string) ([]byte, error)
- func (r *Repo) RemoveFeature(ctx context.Context, ns, featureName string) error
- func (r *Repo) RemoveIfExists(path string) (bool, error)
- func (r *Repo) RemoveNamespace(ctx context.Context, ns string) error
- func (r *Repo) Reset() error
- func (r *Repo) RestoreWorkingDirectory(hash string) error
- func (r *Repo) Review(ctx context.Context, title string, ghCli *gh.GithubClient) (string, error)
- func (r *Repo) WorkingDirectoryHash() (*plumbing.Hash, error)
- func (r *Repo) WriteFile(name string, data []byte, perm os.FileMode) error
Constants ¶
const ( MainBranchName = "main" RemoteName = "origin" )
Variables ¶
var ( ErrMissingCredentials = fmt.Errorf("missing credentials") ErrNotFound = fmt.Errorf("not found") )
Functions ¶
This section is empty.
Types ¶
type AuthProvider ¶
AuthProvider provides access to basic auth credentials. Depending on the context (local vs ephemeral), credentials may be provided in different ways, thus the interface.
type CompileRequest ¶
type CompileRequest struct { // Registry of protobuf types. This field is optional, if it does not exist, it will be instantiated. Registry *protoregistry.Types // Optional fields to filter features by, so as to not compile the entire world. NamespaceFilter, FeatureFilter string // Whether or not to persist the successfully compiled features Persist bool // If true, any generated compilation changes will overwrite previous features // even if there are type mismatches IgnoreBackwardsCompatibility bool }
type FeatureCompilationResult ¶
type FeatureCompilationResult struct { NamespaceName string FeatureName string CompiledFeature *feature.CompiledFeature CompilationError error }
func (*FeatureCompilationResult) Err ¶
func (fcr *FeatureCompilationResult) Err() error
func (*FeatureCompilationResult) SummaryString ¶
func (fcr *FeatureCompilationResult) SummaryString() string
type FeatureCompilationResults ¶
type FeatureCompilationResults []*FeatureCompilationResult
func (FeatureCompilationResults) Err ¶
func (fcrs FeatureCompilationResults) Err() error
type Repo ¶
type Repo struct { Repo *git.Repository Wt *git.Worktree Fs billy.Filesystem Auth AuthProvider fs.Provider fs.ConfigWriter // contains filtered or unexported fields }
Abstraction around git and github operations associated with the lekko configuration repo. This class can be used either by the cli, or by any other system that intends to manage operations around the lekko config repo.
func NewEphemeral ¶
func NewEphemeral(url string, auth AuthProvider, branchName string) (*Repo, error)
Creates a new instance of Repo designed to work with ephemeral repos.
func NewLocalClone ¶
func NewLocalClone(path, url string, auth AuthProvider) (*Repo, error)
Creates a local clone of a remote github config repository based on the given url at the provided path.
func (*Repo) BasicAuth ¶
func (r *Repo) BasicAuth() transport.AuthMethod
func (*Repo) BranchName ¶
func (*Repo) BuildDynamicTypeRegistry ¶
func (*Repo) CheckoutRemoteBranch ¶
Checks out the remote branch
func (*Repo) Cleanup ¶
Cleans up all resources and references associated with the given branch on local and remote, if they exist. If branchName is nil, uses the current (non-master) branch. Will switch the current branch back to main, and pull from remote to ensure we are on the latest commit.
func (*Repo) CleanupBranch ¶
func (*Repo) Commit ¶
Commit will take an optional commit message and push the changes in the local working directory to the remote branch.
func (*Repo) Compile ¶
func (r *Repo) Compile(ctx context.Context, req *CompileRequest) ([]*FeatureCompilationResult, error)
func (*Repo) CompileFeature ¶
func (r *Repo) CompileFeature(ctx context.Context, registry *protoregistry.Types, namespace, featureName string) (*feature.CompiledFeature, error)
func (*Repo) CreateOrRestore ¶
If branchName already exists on remote, pull it down and switch to it. If branchName already exists on local, switch to it. If branchName doesn't exist, create it off of the main branch. This method is idempotent.
func (*Repo) CredentialsExist ¶
func (*Repo) FindFeatureFiles ¶
func (*Repo) FormatFeature ¶
func (*Repo) GenBranchName ¶
func (*Repo) GetContents ¶
func (r *Repo) GetContents(ctx context.Context) (map[metadata.NamespaceConfigRepoMetadata][]feature.FeatureFile, error)
func (*Repo) GetDirContents ¶
func (*Repo) GetFeatureContents ¶
func (*Repo) GetFeatureFile ¶
func (*Repo) GetFeatureFiles ¶
func (*Repo) GetFeatureHash ¶
func (r *Repo) GetFeatureHash(ctx context.Context, namespace, featureName string) (*plumbing.Hash, error)
Returns the hash of the proto bin file as indexed by the git tree. If there are uncommitted changes those won't be accounted for in the hash. The method is a reference, so I don't forget how to do this in the future (shubhit)
func (*Repo) GetFileContents ¶
func (*Repo) GetPRInfo ¶
func (r *Repo) GetPRInfo(ctx context.Context, branchName string, ghCli *gh.GithubClient) (*github.PullRequest, []*github.PullRequestReview, []*github.CheckRun, error)
func (*Repo) HasReference ¶
func (r *Repo) HasReference(refName plumbing.ReferenceName) (bool, error)
func (*Repo) HumanReadableHash ¶
func (*Repo) IsNotExist ¶
func (*Repo) MainBranchHash ¶
func (*Repo) ParseMetadata ¶
func (r *Repo) ParseMetadata(ctx context.Context) (*metadata.RootConfigRepoMetadata, map[string]*metadata.NamespaceConfigRepoMetadata, error)
func (*Repo) PersistFeature ¶
func (*Repo) ReBuildDynamicTypeRegistry ¶
func (r *Repo) ReBuildDynamicTypeRegistry(ctx context.Context, protoDirPath string) (*protoregistry.Types, error)
Actually regenerates the buf image, and writes it to the file system. Note: we don't have a way yet to run this from an ephemeral repo, because we need to first ensure that buf cmd line can be executed in the ephemeral env.
func (*Repo) RemoveFeature ¶
func (*Repo) RestoreWorkingDirectory ¶
Restores the entire repository to the git hash specified. The given hash must be a fully formed hash (e.g. 11586ea8bd20290ddc8fceaaab782b4d3dbe15c9). We do this by checking out the given hash in a detached head state, copying all the files (except the .git directory) to local memory, and writing out all the contents to our current working directory.
func (*Repo) Review ¶
Review will open a pull request. It takes different actions depending on whether or not we are currently on main, and whether or not the working directory is clean.