Documentation
¶
Overview ¶
Package command provides the core command execution infrastructure for gitlab-shell. It defines the Command interface that all shell commands must implement, along with shared utilities for logging, tracing, and context management.
Index ¶
Constants ¶
const LogDataKey contextKey = "logData"
LogDataKey is the context key used to store log data in request contexts.
Variables ¶
This section is empty.
Functions ¶
func CheckForVersionFlag ¶ added in v14.24.0
CheckForVersionFlag checks if the -version flag was passed and prints version info if so. It exits the program after printing the version.
func FeatureFlagEvaluatorFromContext ¶ added in v14.50.0
func FeatureFlagEvaluatorFromContext(ctx context.Context) featureflag.Evaluator
FeatureFlagEvaluatorFromContext returns the feature flag evaluator stored in ctx by Setup, or nil if no evaluator was registered (e.g. FEATURE_FLAG_ENDPOINT is not set). Callers must treat a nil return as "all flags off".
func Setup ¶
Setup initializes tracing from the configuration file and generates a background context from which all other contexts in the process should derive from, as it has a service name and initial correlation ID set.
A labkit v2 feature flag client is created when the FEATURE_FLAG_ENDPOINT environment variable is set. The client is stored in the returned context and can be retrieved with FeatureFlagEvaluatorFromContext. If no endpoint is configured the client is omitted and flag checks default to false — startup is never blocked by a missing Flipt server.
Types ¶
type Command ¶
Command is the interface that all gitlab-shell commands must implement. Execute runs the command and returns the updated context and any error.
type LogData ¶ added in v14.27.0
type LogData struct {
Username string `json:"username"`
WrittenBytes int64 `json:"written_bytes"`
Meta LogMetadata `json:"meta"`
}
LogData contains user and request information for structured logging.
func NewLogData ¶ added in v14.27.0
NewLogData creates a new LogData instance with the given project, username, and IDs. It extracts the root namespace from the project path.
type LogMetadata ¶ added in v14.24.0
type LogMetadata struct {
Project string `json:"project,omitempty"`
RootNamespace string `json:"root_namespace,omitempty"`
ProjectID int `json:"project_id,omitempty"`
RootNamespaceID int `json:"root_namespace_id,omitempty"`
}
LogMetadata contains project and namespace information for structured logging.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package authorizedkeys handles fetching and printing authorized SSH keys.
|
Package authorizedkeys handles fetching and printing authorized SSH keys. |
|
Package authorizedprincipals handles printing authorized principals in GitLab Shell.
|
Package authorizedprincipals handles printing authorized principals in GitLab Shell. |
|
Package commandargs defines structures and methods for handling command-line arguments related to authorized key checks in the GitLab shell.
|
Package commandargs defines structures and methods for handling command-line arguments related to authorized key checks in the GitLab shell. |
|
Package discover implements the "discover" command for fetching user info and displaying a welcome message.
|
Package discover implements the "discover" command for fetching user info and displaying a welcome message. |
|
Package gitauditevent handles Git audit events for GitLab.
|
Package gitauditevent handles Git audit events for GitLab. |
|
Package githttp provides functionality to handle Git operations over HTTP(S) and SSH, including executing Git commands like git-upload-pack and converting responses to the expected format for SSH protocols.
|
Package githttp provides functionality to handle Git operations over HTTP(S) and SSH, including executing Git commands like git-upload-pack and converting responses to the expected format for SSH protocols. |
|
Package healthcheck provides functionality to perform health checks.
|
Package healthcheck provides functionality to perform health checks. |
|
Package lfsauthenticate provides functionality for authenticating Git LFS requests
|
Package lfsauthenticate provides functionality for authenticating Git LFS requests |
|
Package lfstransfer wraps https://github.com/charmbracelet/git-lfs-transfer logic
|
Package lfstransfer wraps https://github.com/charmbracelet/git-lfs-transfer logic |
|
Package personalaccesstoken handles operations related to personal access tokens, including parsing arguments, requesting tokens, and formatting responses.
|
Package personalaccesstoken handles operations related to personal access tokens, including parsing arguments, requesting tokens, and formatting responses. |
|
Package readwriter provides I/O abstractions for command input and output streams.
|
Package readwriter provides I/O abstractions for command input and output streams. |
|
Package receivepack provides functionality for handling Git receive-pack commands
|
Package receivepack provides functionality for handling Git receive-pack commands |
|
shared
|
|
|
accessverifier
Package accessverifier handles the verification of access permission.
|
Package accessverifier handles the verification of access permission. |
|
disallowedcommand
Package disallowedcommand provides an error for handling disallowed commands.
|
Package disallowedcommand provides an error for handling disallowed commands. |
|
Package twofactorrecover defines logic for 2FA codes recovery
|
Package twofactorrecover defines logic for 2FA codes recovery |
|
Package twofactorverify provides functionality for two-factor verification
|
Package twofactorverify provides functionality for two-factor verification |
|
Package uploadarchive provides functionality for uploading archives
|
Package uploadarchive provides functionality for uploading archives |
|
Package uploadpack provides functionality for handling upload-pack command
|
Package uploadpack provides functionality for handling upload-pack command |