Help us shape the future of Go! Take the 2026 Go Developer Survey

deploycommit

package
v0.54.0 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2026 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Overview

Package deploycommit reports which commit a frontend deploy's source came from, so Volcano can tie the deployment to its repository and LavaFlow can open fix pull requests against the code that actually runs.

It sends only the GitHub repository as owner/name, the commit ID, whether the uploaded files differ from that commit, and the uploaded directory's path in the repository: never a remote URL, a local path, a branch, or a diff. When any part is missing or would not pass the server's check, it reports nothing at all. The server refuses a malformed commit with a 400 before anything deploys, so sending a doubtful one would fail the customer's deploy over a field they never asked for.

Index

Constants

View Source
const OptOutEnv = "VOLCANO_DEPLOY_COMMIT"

OptOutEnv turns reporting off when set to "off".

Variables

This section is empty.

Functions

This section is empty.

Types

type File

type File struct {
	// Path is the file packaging read.
	Path string
	// Executable is the executable bit the archive keeps for the file, nil
	// when the archive keeps none.
	Executable *bool
	// contains filtered or unexported fields
}

File is one file an upload holds, recorded from the bytes packaging wrote, so a later change to the file on disk cannot change what is compared.

func Copy

func Copy(dst io.Writer, src io.ReadSeeker, size int64, path string, executable *bool) (File, error)

Copy writes src, which holds size bytes, to dst and records the bytes as the file at path, without holding them in memory. When they have CRLF line endings it reads src again from the start to record them with LF; if they changed meanwhile, only what was written is recorded.

func NewFile

func NewFile(path string, content []byte, executable *bool) File

NewFile records an uploaded file from the bytes packaging read.

type Source

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

Source is the commit checked out where a deploy reads its files. Detect reads it; Commit then reports it for the upload.

func Detect

func Detect(ctx context.Context, deps cliruntime.Deps, dir string) *Source

Detect reads the commit checked out in dir: origin's GitHub repository, HEAD, and the files HEAD holds. It returns nil when it cannot say for sure, and in local development, which never reports a commit.

The commit comes from dir itself, in CI as anywhere else. A workflow's GITHUB_SHA names the commit that triggered it, which is not what a checkout of another ref or repository holds. On a pull_request run HEAD is the merge commit GitHub made for the check, which is on no branch, so the server records it unverified: true, and nothing more is claimed.

func (*Source) Commit

func (s *Source) Commit(ctx context.Context, root string, files []File, leftOut func(string) bool) *api.DeployCommit

Commit reports the commit for an upload of the directory root, whose archive holds files at their paths under it. leftOut reports whether a slash-separated path under root is one the deploy client leaves out of every upload, such as node_modules; nil names none. The upload is clean only when each file is in the commit at its own path, with the content the commit gives it and, where the archive keeps one, the same executable bit, and it holds every file the commit has under root that leftOut does not name. Anything else marks it dirty: an untracked or ignored file, an edit git's own status would not show, or a committed file the upload lacks, such as a deleted or excluded file, one under a symlinked directory, or a symlink, which the archive never holds. It returns nil when s is nil, root is outside the repository, or git cannot be asked.

Content is compared without running git: a clean or smudge filter is a program the repository's configuration names. Line endings git converts, and Git LFS pointers where the filter attribute names Git LFS, are compared here instead; content another filter changes reads as changed.

Directories

Path Synopsis
Package deploycommittest makes git repositories for tests of deploys that report their source commit.
Package deploycommittest makes git repositories for tests of deploys that report their source commit.

Jump to

Keyboard shortcuts

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