{"modulePath":"github.com/suxess-it/kubrix-cli","version":"v0.1.6","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package gitopsdiff\n\nPackage gitopsdiff renders the charts a change touches on two revisions of a platform repository and reports what changed: the rendered manifests per chart and test case, the subcharts' default values, and the effective values with the file and line that set them. It replaces kubriX's create-pr-comment-file.sh and gitops-diff-comments.py.\n\n## Constants\n\n```go\nconst (\n\t// MaxCommentLength keeps some headroom below GitHub's 65536 characters per comment.\n\tMaxCommentLength = 60000\n\t// MaxChartComments is how many charts get a comment of their own; with more, only the summary is posted.\n\tMaxChartComments = 10\n)\n```\n\n```go\nconst ChartsDir = \"platform-apps/charts\"\n```\nChartsDir holds the application charts of a platform repository.\n\n## Functions\n\n```go\nfunc BaseCandidates(ctx context.Context, repo string) ([]string, error)\n```\nBaseCandidates lists the revisions a change is usually compared against, the most likely first: the remote's default branch, then local branches and the other remote branches.\n\n```go\nfunc CaptureHelmWarnings(w io.Writer) func()\n```\nCaptureHelmWarnings routes the warnings helm prints through the standard logger (for example \"cannot overwrite table with non table\") to w, each distinct warning once and without a timestamp: a diff renders the same chart many times. It returns a function that restores the standard logger.\n\n```go\nfunc FailureLabel(s FailureStatus) string\n```\nFailureLabel describes a failure's status for people.\n\n```go\nfunc FailureSubject(f Failure) string\n```\nFailureSubject names what failed: a chart with a test case, or a whole test case.\n\n```go\nfunc Marker(name string) string\n```\nMarker starts every comment body, so a later run finds and updates or deletes its own comments.\n\n```go\nfunc MarkerName(body string) (string, bool)\n```\nMarkerName returns the comment name of a body that starts with a marker.\n\n```go\nfunc SyncComments(ctx context.Context, c CommentClient, pr PullRequest, comments []Comment, dryRun bool, log io.Writer) error\n```\nSyncComments makes the pull request's diff comments match comments: a comment whose body changed is updated, an unchanged one is left alone, one that is no longer wanted is deleted, and new ones are created in order (the summary first). With dryRun it only prints what it would do.\n\n```go\nfunc WriteText(w io.Writer, r *Report)\n```\nWriteText prints the report for a terminal: what changed per chart and test case, the changed values with the file that sets them, and the diffs.\n\n## Types\n\n```go\ntype Choices struct {\n\tTargetTypes []string\n\tCharts      []string\n\tChanged     []string\n}\n```\nChoices is what a diff of a change can render: the target types and charts of either revision, and the charts the change touches (all of them when it touches the target chart, a bootstrap Application or no chart).\n\n```go\nfunc ListChoices(ctx context.Context, repo, base, head string) (Choices, error)\n```\nListChoices finds the choices of comparing head (empty: the working tree) against base, reading git trees and the working tree without checking anything out.\n\n```go\ntype Comment struct {\n\tName string\n\tBody string\n}\n```\nComment is one PR comment: Name identifies it across runs through its marker, Body is its Markdown.\n\n```go\nfunc Comments(r *Report, runURL string) []Comment\n```\nComments renders the report as PR comments: the summary first, then one comment per changed chart unless more than MaxChartComments charts changed. runURL links the full diffs.\n\n```go\ntype CommentClient interface {\n\tIssueComments(ctx context.Context, owner, repo string, number int) ([]git.IssueComment, error)\n\tCreateIssueComment(ctx context.Context, owner, repo string, number int, body string) error\n\tEditIssueComment(ctx context.Context, owner, repo string, id int64, body string) error\n\tDeleteIssueComment(ctx context.Context, owner, repo string, id int64) error\n}\n```\nCommentClient is the part of a git host's API that syncing PR comments needs.\n\n```go\ntype DependencyBuilder func(ctx context.Context, dir string) error\n```\nDependencyBuilder fetches the dependencies of the chart in dir into its charts/ directory.\n\n```go\nfunc HelmDependencies(home string) DependencyBuilder\n```\nHelmDependencies builds dependencies like \\`helm dependency build\\`, falling back to \\`helm dependency update\\` when the chart has no Chart.lock or it is out of date. Repositories are used by URL; helm's own repository config and cache are not touched, so state lives in home.\n\n```go\ntype Failure struct {\n\tChart    string        `json:\"chart,omitempty\"`\n\tTestCase string        `json:\"testCase\"`\n\tStatus   FailureStatus `json:\"status\"`\n\t// Error is the head revision's error, or the base revision's for a failure the change fixes.\n\tError string `json:\"error\"`\n}\n```\nFailure is a chart that could not be rendered with a test case on one or both revisions, or, with an empty Chart, a test case whose applications could not be resolved. Its rendered files are not compared.\n\n```go\ntype FailureStatus string\n```\nFailureStatus says which revision a failure is on.\n\n```go\nconst (\n\t// Broken fails on the change only: the change breaks rendering.\n\tBroken FailureStatus = \"broken\"\n\t// StillBroken fails on both revisions: the change neither caused nor fixed it.\n\tStillBroken FailureStatus = \"still-broken\"\n\t// Fixed fails on the base revision only: the change fixes it.\n\tFixed FailureStatus = \"fixed\"\n)\n```\n\n```go\ntype FileDiff struct {\n\tChart     string `json:\"chart\"`\n\tTestCase  string `json:\"testCase\"`\n\tPath      string `json:\"path\"`\n\tStatus    Status `json:\"status\"`\n\tAdditions int    `json:\"additions\"`\n\tDeletions int    `json:\"deletions\"`\n\t// Text is the unified diff, starting with a \"diff -U 4 -rN\" header line like diff -r prints.\n\tText string `json:\"diff\"`\n}\n```\nFileDiff is the change of one rendered file of a chart in one test case.\n\n```go\ntype Options struct {\n\t// Repo is the platform repository; its git history provides Base and Head.\n\tRepo string\n\tBase string\n\t// Head is the revision to compare; empty compares the working tree.\n\tHead string\n\t// TestCases default to every target type of either revision.\n\tTestCases []TestCase\n\t// Charts to compare; empty compares the charts the change touches, or all charts with AllCharts.\n\tCharts    []string\n\tAllCharts bool\n\t// CustomerConfig renders templates; empty uses each revision's bootstrap/customer-config.yaml.\n\tCustomerConfig string\n\t// Dependencies fetches chart dependencies; nil uses HelmDependencies.\n\tDependencies DependencyBuilder\n\t// Parallel renders this many charts at once; 0 uses the number of CPUs.\n\tParallel int\n\t// Progress, if set, is called after each rendering; calls are serialised.\n\tProgress func(Progress)\n}\n```\nOptions of a diff.\n\n```go\ntype Progress struct {\n\tDone, Total int\n\tLast        string\n}\n```\nProgress reports how many of the renderings a diff needs are done; Done is the last one finished.\n\n```go\ntype PullRequest struct {\n\tOwner, Repo string\n\tNumber      int\n\t// Author is the login whose marked comments are this diff's; comments of anyone else are never touched.\n\tAuthor string\n}\n```\nPullRequest names the pull request to comment on and who the diff's own comments are written by.\n\n```go\ntype Report struct {\n\tFiles             []FileDiff    `json:\"files\"`\n\tDefaultValuesDiff string        `json:\"defaultValuesDiff\"`\n\tValueChanges      []ValueChange `json:\"valueChanges\"`\n\tFailures          []Failure     `json:\"failures\"`\n}\n```\nReport is everything that changed, sorted by chart, test case and path.\n\n```go\nfunc Run(ctx context.Context, opts Options) (*Report, error)\n```\nRun checks out both revisions, renders the selected charts with every test case and reports what changed.\n\n```go\nfunc (r *Report) Broken() []Failure\n```\nBroken are the failures the change introduces.\n\n```go\nfunc (r *Report) Charts() []string\n```\nCharts are the charts with rendered changes, sorted.\n\n```go\nfunc (r *Report) Empty() bool\n```\nEmpty reports whether nothing changed.\n\n```go\ntype Status string\n```\nStatus of a file or value between the two revisions.\n\n```go\nconst (\n\tAdded    Status = \"added\"\n\tRemoved  Status = \"removed\"\n\tModified Status = \"modified\"\n)\n```\n\n```go\ntype TestCase struct {\n\tName string\n\t// TargetType resolves each chart's values through the target chart, as Argo CD would.\n\tTargetType string\n\t// Files are values files looked up in each chart's directory; missing ones are skipped.\n\tFiles []string\n\t// Sets are helm --set expressions applied after Files.\n\tSets []engine.SetSource\n}\n```\nTestCase is one set of values every changed chart is rendered with: the files and parameters a target type's Application passes to the chart, or chart-local values files and --set expressions given by hand.\n\n```go\ntype ValueChange struct {\n\tChart    string `json:\"chart\"`\n\tTestCase string `json:\"testCase\"`\n\tPath     string `json:\"path\"`\n\tKind     Status `json:\"kind\"`\n\tBefore   any    `json:\"before,omitempty\"`\n\tAfter    any    `json:\"after,omitempty\"`\n\t// Source is where the head revision sets the value, or where the base revision set a removed one.\n\tSource engine.SourceLocation `json:\"source\"`\n}\n```\nValueChange is an effective value of an application that differs between the revisions.\n\n","path":"github.com/suxess-it/kubrix-cli/internal/gitopsdiff","name":"gitopsdiff","synopsis":"Package gitopsdiff renders the charts a change touches on two revisions of a platform repository and reports what changed: the rendered manifests per chart and test case, the subcharts' default values, and the effective values with the file and line that set them.","isRedistributable":true}
