gitservices

package
v0.19.1 Latest Latest
Warning

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

Go to latest
Published: Dec 8, 2025 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Attributes

type Attributes struct {
	// ServerRoot is the root filesystem path of the git server. URL paths
	// refer to repositories relative to this root
	ServerRoot string
	// PrivateRepoPath is the filesystem path, relative to `serverRoot`, where
	// the private git repository is hosted
	PrivateRepoPath string
	// privateRepoPath is the URI path in the name of the public go module;
	// this public go module has a private dependency on the repo at
	// `privateRepoPath`
	DependingRepoPath string
	// HTTP Server path is the filesystem path of the already-built HTTP
	// server, installed into its final location.
	HTTPServerPath string

	// PrivateGomoduleHost is the hostname of the git server
	PrivateGomoduleHost string
	// GitRemoteAddr is the IPv4 address to which the hostname resolves
	GitRemoteAddr string

	// HTTPPort is the port on which the http git server runs
	HTTPPort string
	// SSHPort is the port on which the ssh git server runs
	SSHPort string

	// HTTPServerBuildDir is the location at which the HTTP server program's
	// code will be loaded for building
	HTTPServerBuildDir string
	// HTTPServerBuildPath is the *local filesystem* location at which the HTTP server program's
	// code can be found
	HTTPServeCodeLocalPath string
	// OutDir is the location to which dalec will output files
	OutDir string

	// ModFileGoVersion is the go version for the go modules
	ModFileGoVersion string
	// contains filtered or unexported fields
}

Attributes are the basic pieces of information needed to host two git servers, one via SSH and one via HTTP

func (*Attributes) HTTPServerBase

func (g *Attributes) HTTPServerBase() string

func (*Attributes) HTTPServerDir

func (g *Attributes) HTTPServerDir() string

func (*Attributes) PrivateGoModuleGitTag

func (a *Attributes) PrivateGoModuleGitTag() string

func (*Attributes) PrivateRepoAbsPath

func (g *Attributes) PrivateRepoAbsPath() string

`PrivateRepoAbsPath` returns the resolved absolute filepath of the private git repo in the `gitHost` container.

func (*Attributes) RepoAbsDir

func (a *Attributes) RepoAbsDir() string

func (*Attributes) WithNewPrivateGoModuleGitTag

func (a *Attributes) WithNewPrivateGoModuleGitTag() *Attributes

type CustomMount

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

type File

type File struct {
	Location string
	Template string
}

Wrapper types to make templating and injecting files into llb states

func (*File) Inject

func (f *File) Inject(t *testing.T, obj *Attributes) []byte

type Script

type Script struct {
	Basename string
	Template string
}

Wrapper types to make templating and injecting files into llb states. Scripts will typically be copied into `customScriptDir`

func (*Script) Inject

func (s *Script) Inject(t *testing.T, obj *Attributes) []byte

Completes a template and adds a shebang to a script.

type TestState

type TestState struct {
	T    *testing.T
	Ctx  context.Context
	Attr Attributes
	// contains filtered or unexported fields
}

`TestState` is a bundle of stuff that the tests need access to in order to do their work.

func NewTestState

func NewTestState(ctx context.Context, t *testing.T, client gwclient.Client, attr *Attributes) TestState

func (*TestState) Client

func (ts *TestState) Client() gwclient.Client

func (*TestState) CustomFile

func (ts *TestState) CustomFile(f File) llb.StateOption

func (*TestState) GenerateSpec

func (ts *TestState) GenerateSpec(gomodContents string, auth dalec.GomodGitAuth) *dalec.Spec

Dalec spec boilerplate

func (*TestState) InitializeGitRepo

func (ts *TestState) InitializeGitRepo(worker llb.State) llb.StateOption

InitializeGitRepo returns a stateOption that uses `worker` to create an initialized git repository from the base state.

func (*TestState) StartHTTPGitServer

func (ts *TestState) StartHTTPGitServer(gitHost llb.State) <-chan error

`StartHTTPGitServer` starts a git HTTP server to serve the private go module as a git repo.

func (*TestState) StartSSHServer

func (ts *TestState) StartSSHServer(gitHost llb.State) <-chan error

startSSHServer starts an sshd instance in a container hosting the git repo. It runs asynchronously and checks the connection after starting the server.

func (*TestState) UpdatedGitconfig

func (ts *TestState) UpdatedGitconfig() llb.StateOption

`UpdatedGitconfig` updatesd the gitconfig on the gomod worker. This is convoluted, but necessary. The `go` tool uses `git` under the hood to download go modules in response to an invocation of `go mod download`. Making such an invocation will cause go to open the `go.mod` file in the current directory and build a dependency graph of modules to download.

A go module cannot have a URI that includes a port number. Go uses the standard HTTP/HTTPS/SSH ports of 80, 443, and 22 respenctively, to attempt to fetch a module. Root privileges would be required to bind to those port numbers, so we run our HTTP and SSH servers on nonstandard ports.

Modifying the gitconfig as below will tell git to substitute http://host.com:port/ when it receives a request for a repository at http://host.com/ . That way, when go sees a module with URI path `host.com/module/name`, it will call `git` to look up the repository there. Git will first consult the gitconfig to see if there are any subsittutions, and will then make a request instead to http://host.com:<portnumber>/module/name .

Jump to

Keyboard shortcuts

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