gitops

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Feb 2, 2024 License: AGPL-3.0 Imports: 20 Imported by: 0

Documentation

Overview

Package gitops handles interpreting changes to a git repository as RSoP differentials.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DownloadAuth

func DownloadAuth(ctx context.Context, vc *vault.Client, authDirectory string) error

func DownloadPolicies

func DownloadPolicies(ctx context.Context, vc *vault.Client, policyDirectory string) error

func GetAuthPrincipalDifferential

func GetAuthPrincipalDifferential(repositoryPath, relativePrincipalPath, relativePolicyDirectory, historicalGitRef string) (*internal.RSoPDifferential, error)

GetAuthPrincipalDifferential compares policies for an auth principal in the working copy to a historical git ref.

func GetPolicyChangeDifferentials

func GetPolicyChangeDifferentials(
	changedFiles []ChangedFile,
	repositoryPath, policyName,
	relativePolicyDirectory, relativePrincipalDirectory,
	historicalGitRef string,
) (map[string]*internal.RSoPDifferential, error)

GetPolicyChangeDifferentials returns an RSoP differential for every auth principal that involves this policy.

func MustEmitMarkdownDiffs

func MustEmitMarkdownDiffs(ctx context.Context, gitDirectory, compareRef string)

Prints RSoPDifferential tables for all changes made to auth principals and policies between `compareRef` and the current working copy.

Uses log.Fatal() instead of returning an error because it's directly called by a command.

Types

type ChangedFile

type ChangedFile struct {
	Path      string
	Mutation  Mutation
	Principal bool `json:",omitempty"`
	Policy    bool `json:",omitempty"`
}

func GetChangedFiles

func GetChangedFiles(ctx context.Context, repo string, referenceName string) ([]ChangedFile, string, error)

Computes a change between HEAD and some reference, like a branch. Leave blank to use the default branch, which is usually named main or master.

Returns the branch used.

type Git

type Git struct {
	Dir string
}

A little wrapper for subprocess commands to git.

If you're curious about why, github.com/go-git/go-git can get a little dicey and bugs are more easily triaged this way.

func (Git) CombinedOutput

func (g Git) CombinedOutput(args ...string) (string, error)

type Mutation

type Mutation int
const (
	Add Mutation = iota
	Delete
	Change
)

func (Mutation) MarshalText

func (m Mutation) MarshalText() ([]byte, error)

MarshalText implements encoding.TextMarshaler.

func (Mutation) String

func (i Mutation) String() string

Jump to

Keyboard shortcuts

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