Documentation
¶
Overview ¶
Package constants defines global constants and utility functions for the divekit CLI.
Index ¶
- Constants
- func DisplayTargetName(targetName string) string
- func GetDistributionCachePath(workingDir, distributionName string) string
- func GetDistributionConfigPath(workingDir, distributionName string) string
- func GetDistributionIndividualizationPath(workingDir, distributionName string) string
- func GetDistributionIndividualsPath(workingDir, distributionName string) string
- func GetDistributionPath(workingDir, distributionName string) string
- func GetDistributionRemotesPath(workingDir, distributionName string) string
- func GetDistributionReposCachePath(workingDir, distributionName, timestamp string) string
- func GetDistributionVariationPath(workingDir, distributionName string) string
- func GetDistributionsPath(workingDir string) string
- func GetDivekitIndexPath(workingDir string) string
- func GetDivekitPath(workingDir string) string
- func GetEvaluationPipelinePath(workingDir string) string
- func GetLegacyEvaluationPipelinePath(workingDir string) string
- func GetLocalDataProviderPath(workingDir, distributionName, targetName string) string
- func GetLocalDataReportPath(workingDir, distributionName string, timestamp time.Time) string
- func GetLocalDataReportsPath(workingDir string) string
- func GetLocalDataRootPath(workingDir string) string
- func GetProjectScriptsPath(workingDir string) string
- func GetRootIndividualizationPath(workingDir string) string
- func GetRootVariationPath(workingDir string) string
- func GetTempIndividualizedPath(workingDir, uuid string) string
- func NormalizeTargetName(name string) string
- func TargetRepoAliases(targetName string) []string
Constants ¶
const ( // Default buffer size for reading/writing operations (64 KB) DefaultBufferSize = 64 * 1024 // Maximum scanner buffer size (1 MB) MaxScannerBuffer = 1024 * 1024 )
Buffer Sizes for I/O Operations
const ( // Root is the name of the CLI application Root = "divekit" // DivekitHomeEnvVar is the environment variable used to specify the divekit home directory DivekitHomeEnvVar = "DIVEKIT_HOME" // DivekitFolder is the name of the divekit configuration directory DivekitFolder = ".divekit" // DistributionsFolder is the directory containing all distributions DistributionsFolder = "distributions" // TempIndividualizedFolder is the temporary directory for individualized content TempIndividualizedFolder = ".tmp-individualized" // DivekitConfigDir is the divekit configuration directory name DivekitConfigDir = ".divekit" // ConfigFile is the name of the main configuration file ConfigFile = "config.json" // DivekitConfigName is the name of the divekit-specific configuration file DivekitConfigName = "divekit-config.json" // VariationConfigFile is the name of the variation configuration file VariationConfigFile = "variation.json" // IndividualizationConfigFile is the name of the individualization configuration file IndividualizationConfigFile = "individualization.json" // IndividualsFile is the name of the individuals configuration file IndividualsFile = "individuals.json" // RemotesConfigFile is the name of the remotes configuration file RemotesConfigFile = "remotes.json" // LicenseFile is the name of the license file LicenseFile = "LICENSE" // ReadmeFile is the name of the readme file ReadmeFile = "README.md" // MembersFile is the name of the members configuration file MembersFile = "members.json" // IndexDbFile is the name of the index database file IndexDbFile = "index.db" // GitLabCIFileName is the standard GitLab CI file in the repository root. GitLabCIFileName = ".gitlab-ci.yml" // DefaultBranch is the default git branch name for new projects DefaultBranch = "main" // DefaultAuthorName is the default author name for commits DefaultAuthorName = "Divekit" // DefaultAuthorEmail is the default author email for commits DefaultAuthorEmail = "divekit@git.nrw" // DefaultPermissions is the default permissions for project members DefaultPermissions = "reporter" // DefaultTargetName is the canonical name of the primary work target. DefaultTargetName = "work" // LegacyDefaultTargetName is the historic primary target alias kept for backward compatibility. LegacyDefaultTargetName = "main" // LegacyCodeTargetAlias is the older user-facing alias for the primary work target. LegacyCodeTargetAlias = "code" // EvaluationTargetName is the canonical name of the evaluation target. EvaluationTargetName = "eval" // LegacyEvaluationTargetAlias is the historic evaluation target name kept for backward compatibility. LegacyEvaluationTargetAlias = "sandbox" // LegacyTestTargetName is the historic evaluation target alias kept for backward compatibility. LegacyTestTargetName = "test" // EvaluationPipelineDisplayName is the preferred singular label for the evaluation feature. EvaluationPipelineDisplayName = "Evaluation Pipeline" // EvaluationPipelineDisplayPluralName is the preferred plural label for the evaluation feature. EvaluationPipelineDisplayPluralName = "Evaluation Pipelines" // LegacyEvaluationPipelineConfigKey is the legacy persisted config key kept for backward compatibility. LegacyEvaluationPipelineConfigKey = "securePipeline" // EvaluationPipelineConfigKey is the canonical persisted config key. EvaluationPipelineConfigKey = "evaluationPipeline" // GroupLayoutModeLegacy keeps the legacy evaluation pipeline fallback behavior. GroupLayoutModeLegacy = "legacy" // GroupLayoutModeDistributionSubgroups creates per-distribution work/eval subgroups. GroupLayoutModeDistributionSubgroups = "distribution-subgroups" // DistributionStudentSubgroupName is the canonical subgroup for primary work repositories. DistributionStudentSubgroupName = "work" // LegacyDistributionMainSubgroupName is the historic subgroup name for primary repositories. LegacyDistributionMainSubgroupName = "main" // LegacyDistributionStudentSubgroupName is the older subgroup name for primary repositories. LegacyDistributionStudentSubgroupName = "student" // DistributionEvalSubgroupName is the canonical subgroup for evaluation repositories. DistributionEvalSubgroupName = "eval" // EvalSubgroupName is the canonical subgroup name created for evaluation fallback. EvalSubgroupName = "eval" // EvaluationPipelineDirName is the canonical directory for evaluation pipeline assets. EvaluationPipelineDirName = "evaluation-pipeline" // LegacyEvaluationPipelineDirName is the legacy directory retained for backward compatibility. LegacyEvaluationPipelineDirName = "secure-pipeline" // MainCIFileName is the canonical CI override file for work repositories. MainCIFileName = ".gitlab-ci_workrepo.yml" // LegacyMainCIFileName is the legacy CI override file retained for backward compatibility. LegacyMainCIFileName = ".gitlab-ci_mainrepo.yml" // EvaluationCIFileName is the canonical CI file for eval repositories. EvaluationCIFileName = ".gitlab-ci_evalrepo.yml" // LegacyEvaluationCIFileName is the legacy CI file retained for backward compatibility. LegacyEvaluationCIFileName = ".gitlab-ci_sandboxrepo.yml" // EvaluationSetupScriptName is the legacy eval setup override file retained for backward compatibility. EvaluationSetupScriptName = "setup-eval.sh" // LegacyEvaluationSetupScriptName is the older eval setup override file retained for backward compatibility. LegacyEvaluationSetupScriptName = "setup-sandbox.sh" // EvaluationSetupTargetFileName is the canonical setup script path inside eval repositories. EvaluationSetupTargetFileName = "setup.sh" // EvaluationSetupOverrideFileName is the canonical authoring-time setup override in the origin root. EvaluationSetupOverrideFileName = "setup_evalrepo.sh" // EvaluationPluginsConfigFile is the canonical plugin state file stored under .divekit. EvaluationPluginsConfigFile = "eval-plugins.json" // EvaluationPluginManagedOriginDir is the canonical origin path for eval-only managed plugin child pipelines. EvaluationPluginManagedOriginDir = ".gitlab_evalrepo/eval-plugins" // EvaluationPluginManagedTargetDir is the canonical eval-repo path for managed plugin child pipelines. EvaluationPluginManagedTargetDir = ".gitlab/eval-plugins" // FilePreIdentifierDefault is the default prefix used for target-scoped file markers. FilePreIdentifierDefault = "_" // FilePostIdentifierDefault is the default suffix used for target-scoped file markers. FilePostIdentifierDefault = "repo" // NoRepoIdentifierDefault is the default target marker used to exclude files from all repos. NoRepoIdentifierDefault = "no" // MainTargetNameWrapper defines how the work target derives its name from the base pattern. // {{base}} will be replaced with the main/base name pattern from config (e.g., "ST2-{{uuid}}"). MainTargetNameWrapper = "{{base}}" // NonMainTargetNameWrapper defines how non-work targets derive their name from the base pattern. // {{base}} will be replaced with the work/base name pattern (e.g., "ST2-{{uuid}}"). // {{target}} will be replaced with the user-facing target token (e.g., "eval"). NonMainTargetNameWrapper = "{{base}}_{{target}}" // TimeFormat is the standard time format used throughout the application TimeFormat = "2006-01-02 15:04" // InitialCommitMsg is the default commit message for the initial commit InitialCommitMsg = "Initial commit" // PatchCommitMsgTemplate is the template for patch commit messages PatchCommitMsgTemplate = "Patch applied on %s" // DryRunDelayShort is the delay for quick operations like reads/gets DryRunDelayShort = 50 * time.Millisecond // For quick reads/gets // DryRunDelayMid is the delay for medium operations like creations and assignments DryRunDelayMid = 150 * time.Millisecond // For creations, assignments, simple writes // DryRunDelayLong is the delay for complex operations like large commits DryRunDelayLong = 500 * time.Millisecond // For potentially complex operations like large commits // DryRunFakeProjectIDStart defines the starting ID for fake projects in dry runs DryRunFakeProjectIDStart = 9000 // DryRunFakeUserIDStart defines the starting ID for fake users in dry runs DryRunFakeUserIDStart = 8000 // DryRunFakeGroupPrefix defines the prefix for fake group paths in dry runs DryRunFakeGroupPrefix = "divekit-dry-run" // LocalDataProviderDirName defines the directory name for local data provider files LocalDataProviderDirName = "local-data" // MaxUploadRetries is the maximum number of retries for upload operations MaxUploadRetries = 3 // Maximum number of retries for upload operations // MaxLockRetries is the maximum number of retries for lock acquisition MaxLockRetries = 5 // Maximum number of retries for lock acquisition // UploadRetryDelay is the time to wait between upload retries UploadRetryDelay = 500 * time.Millisecond // Time to wait between upload retries // LockAcquisitionDelay is the time to wait between lock acquisition attempts LockAcquisitionDelay = 100 * time.Millisecond // Time to wait between lock acquisition attempts // StandardRateLimitDelay defines a small default pause between API requests StandardRateLimitDelay = 100 * time.Millisecond // OverviewDefaultWorkers is the default number of concurrent API workers for overview OverviewDefaultWorkers = 10 // Default number of concurrent API workers for overview // RunDefaultWorkers is the default number of concurrent workers for `divekit run` RunDefaultWorkers = 4 // Default number of concurrent workers for `divekit run` )
const ( // DefaultDirPermission is the standard permission for created directories (rwxr-xr-x) DefaultDirPermission = 0o755 // DefaultFilePermission is the standard permission for created files (rw-r--r--) DefaultFilePermission = 0o644 // ConfigFilePermission is the secure permission for config files (rw-------), owner-only access ConfigFilePermission = 0o600 // HomePrivatePermission is the permission for private home directories (rwx------), owner-only access HomePrivatePermission = 0o700 // LogDirPermission is the permission for log directories (rwxr-x---), group-readable LogDirPermission = 0o750 )
File and Directory Permissions
const ( // GitLabPageSize is the page size for GitLab API pagination GitLabPageSize = 100 // DefaultHTTPPort is the default HTTP port for local services DefaultHTTPPort = 8080 // DefaultHTTPTimeout is the timeout for HTTP requests to avoid indefinite hangs. // Set to 5 minutes to accommodate large commits with many files (e.g., 150+ files per project) DefaultHTTPTimeout = 5 * time.Minute )
API and HTTP Configuration
const ( CacheFolder = ".cache" ReposFolder = "repos" )
Cache-related folders
const ( // Text input and textarea dimensions TextInputCharLimit = 150 TextareaWidth = 100 TextareaHeight = 8 // Progress bar and display ProgressBarWidth = 40 ProgressBarMaxWidth = 15 LineNumberWidth = 3 // Output formatting DividerWidth = 50 // Display limits MaxExamplesPerToken = 12 ContextLinesToShow = 3 UnresolvedMatchesToShow = 5 )
UI Component Dimensions
const ( // DefaultQueueSize is the default queue capacity for worker pools DefaultQueueSize = 100 // DistributionQueueSize is the queue size for distribution operations DistributionQueueSize = 200 // PatchQueueSize is the queue size for patch operations PatchQueueSize = 150 // FetchQueueSize is the queue size for fetch operations FetchQueueSize = 64 // IndexingQueueSize is the queue size for indexing operations IndexingQueueSize = 500 // AggressiveQueueSize is the maximum queue size for aggressive operations AggressiveQueueSize = 512 )
Worker Pool Configuration - Queue Sizes
const ( // DefaultTaskTimeout is the default timeout for individual tasks DefaultTaskTimeout = 5 * time.Minute // DistributionTaskTimeout is the task timeout for distribution operations DistributionTaskTimeout = 10 * time.Minute // PatchTaskTimeout is the task timeout for patch operations PatchTaskTimeout = 3 * time.Minute // FetchTaskTimeout is the task timeout for fetch operations FetchTaskTimeout = 20 * time.Minute // IndexingTaskTimeout is the task timeout for indexing operations IndexingTaskTimeout = 2 * time.Minute // AggressiveTaskTimeout is the task timeout for aggressive operations AggressiveTaskTimeout = 15 * time.Minute )
Worker Pool Configuration - Task Timeouts
const ( // DefaultMaxRetries is the default maximum number of retries DefaultMaxRetries = 3 // DefaultInitialBackoff is the default initial backoff duration DefaultInitialBackoff = 100 * time.Millisecond // DefaultMaxBackoff is the default maximum backoff duration DefaultMaxBackoff = 30 * time.Second // DefaultBackoffMultiplier is the default backoff multiplier DefaultBackoffMultiplier = 2.0 // DefaultJitterFraction is the default jitter fraction for backoff calculation DefaultJitterFraction = 0.1 )
Retry Configuration - Default Policy
const ( // PatchRetryMaxAttempts is the maximum number of retry attempts for patch operations PatchRetryMaxAttempts = 2 // PatchRetryInitialBackoff is the initial backoff for patch retries PatchRetryInitialBackoff = 50 * time.Millisecond // PatchRetryMaxBackoff is the maximum backoff for patch retries PatchRetryMaxBackoff = 10 * time.Second )
Retry Configuration - Patch Policy
const ( // WorkerCountMultiplier is the multiplier for CPU-core-based worker count calculation WorkerCountMultiplier = 2 // IndexingWorkerMultiplier is the multiplier for indexing worker count IndexingWorkerMultiplier = 4 // MinWorkerCount is the absolute minimum number of workers allowed MinWorkerCount = 2 // MaxWorkerCount is the absolute maximum number of workers allowed MaxWorkerCount = 64 // DistributionWorkerCount is the fixed worker count for distribution operations. // Limited to 2 to avoid overwhelming GitLab's Gitaly with concurrent large commits. DistributionWorkerCount = 2 )
Worker Count Configuration
const ( // AggressiveRetryMaxAttempts is the maximum retry attempts for aggressive operations AggressiveRetryMaxAttempts = 5 // ConservativeRateLimit is the conservative rate limit value ConservativeRateLimit = 5 // FetchRateLimit is the rate limit for fetch operations FetchRateLimit = 10 // DistributionRateLimit is the rate limit for distribution operations (tasks per second). // Reduced from 8 to 2 to avoid overwhelming GitLab's Gitaly with large commits (177+ files). // This prevents "Deadline Exceeded" errors on local and smaller GitLab instances. DistributionRateLimit = 2 )
Rate Limiting and Concurrency
const ( // LinkingWorkerCount is the number of parallel workers for repository linking. // Conservative to avoid overwhelming GitLab with concurrent API requests. LinkingWorkerCount = 4 // LinkingQueueSize is the queue size for linking operations LinkingQueueSize = 100 // LinkingTaskTimeout is the timeout for individual linking tasks LinkingTaskTimeout = 5 * time.Minute // LinkingRateLimit is the rate limit for linking operations (requests per second). // Very conservative (3 req/sec) because linking involves multiple API calls per task: // GetProject, CreateProjectAccessToken, SetProjectVariable, CreatePipelineTriggerToken, etc. LinkingRateLimit = 3 )
Linking Configuration - for repository linking operations (cross-repo variables, tokens)
const DefaultUserTokenFallback = "owner"
DefaultUserTokenFallback is used when no user names are provided for individualization.
const (
DocsURL = "https://gitlab.git.nrw/divekit/divekit-cli/-/tree/main/docs"
)
Documentation links shared across the CLI.
Variables ¶
This section is empty.
Functions ¶
func DisplayTargetName ¶
DisplayTargetName returns the preferred user-facing label token for a target.
func GetDistributionCachePath ¶
GetDistributionCachePath returns the cache path for a distribution
func GetDistributionConfigPath ¶
GetDistributionConfigPath constructs the path to a distribution's main configuration file (config.json). This file contains the distribution settings including targets, linking pairs, and other metadata. The path follows the pattern: workingDir/.divekit/distributions/distributionName/config.json
Example: GetDistributionConfigPath("/project", "my-dist") -> "/project/.divekit/distributions/my-dist/config.json"
func GetDistributionIndividualizationPath ¶
GetDistributionIndividualizationPath constructs the path to a distribution's unified individualization configuration file (individualization.json). This file can contain variables, solution deletion, warnings, fileManipulation, relations, variableExtensions, and variations.
func GetDistributionIndividualsPath ¶
GetDistributionIndividualsPath constructs the path to a distribution's individuals configuration file (individuals.json). This file contains the user group assignments and individualization settings for the distribution.
Example: GetDistributionIndividualsPath("/project", "my-dist") -> "/project/.divekit/distributions/my-dist/individuals.json"
func GetDistributionPath ¶
GetDistributionPath constructs the full path to a specific distribution directory. This is the base directory where all distribution-specific files are stored. The path follows the pattern: workingDir/.divekit/distributions/distributionName
Example: GetDistributionPath("/project", "my-dist") -> "/project/.divekit/distributions/my-dist"
func GetDistributionRemotesPath ¶
GetDistributionRemotesPath constructs the path to a distribution's remotes configuration file (remotes.json). This file stores the mapping between UUIDs and remote repository information generated during distribution. The path follows the pattern: workingDir/.divekit/distributions/distributionName/remotes.json
Example: GetDistributionRemotesPath("/project", "my-dist") -> "/project/.divekit/distributions/my-dist/remotes.json"
func GetDistributionReposCachePath ¶
GetDistributionReposCachePath returns the repos cache path for a distribution
func GetDistributionVariationPath ¶
GetDistributionVariationPath constructs the path to a distribution's variation configuration file (variation.json). This file defines the individualization rules, token patterns, and content variations for the distribution.
Example: GetDistributionVariationPath("/project", "my-dist") -> "/project/.divekit/distributions/my-dist/variation.json"
func GetDistributionsPath ¶
GetDistributionsPath constructs the path to the distributions root directory. This directory contains all distribution subdirectories within a divekit project. The path follows the pattern: workingDir/.divekit/distributions
Example: GetDistributionsPath("/project") -> "/project/.divekit/distributions"
func GetDivekitIndexPath ¶
GetDivekitIndexPath constructs the path to the repository-local index directory.
func GetDivekitPath ¶
GetDivekitPath constructs the path to the repository-local divekit directory.
func GetEvaluationPipelinePath ¶
GetEvaluationPipelinePath constructs the path to the canonical evaluation pipeline directory.
func GetLegacyEvaluationPipelinePath ¶
GetLegacyEvaluationPipelinePath constructs the path to the legacy evaluation pipeline directory.
func GetLocalDataProviderPath ¶
GetLocalDataProviderPath constructs the path to local data provider storage for a specific distribution and target. This is used when running in local filesystem mode (dry-run with "fs" mode) to store simulated project data. The path follows the pattern: workingDir/.divekit/local-data/distributionName/targetName
Example: GetLocalDataProviderPath("/project", "my-dist", "work") -> "/project/.divekit/local-data/my-dist/work"
func GetLocalDataReportPath ¶
GetLocalDataReportPath constructs the path to a timestamped locally archived report directory. The path follows the pattern: workingDir/.divekit/local-data/reports/distributionName/timestamp
Example: GetLocalDataReportPath("/project", "my-dist", time.Date(2026, 4, 23, 12, 34, 56, 0, time.UTC)) -> "/project/.divekit/local-data/reports/my-dist/20260423_123456"
func GetLocalDataReportsPath ¶
GetLocalDataReportsPath constructs the shared root path for locally archived reports.
func GetLocalDataRootPath ¶
GetLocalDataRootPath constructs the shared root path for local provider storage.
func GetProjectScriptsPath ¶
GetProjectScriptsPath constructs the path to the repository-local scripts directory.
func GetRootIndividualizationPath ¶
GetRootIndividualizationPath constructs the path to the root unified individualization configuration file (individualization.json).
func GetRootVariationPath ¶
GetRootVariationPath constructs the path to the root variation configuration file (variation.json). This file defines the default individualization rules that can be overridden by distribution-specific variations.
Example: GetRootVariationPath("/project") -> "/project/.divekit/variation.json"
func GetTempIndividualizedPath ¶
GetTempIndividualizedPath constructs the path to a temporary directory for individualized content. This directory is used during the individualization process to store processed files before upload. Each UUID gets its own subdirectory to avoid conflicts during concurrent processing. The path follows the pattern: workingDir/.divekit/.tmp-individualized/uuid
Example: GetTempIndividualizedPath("/project", "uuid123") -> "/project/.divekit/.tmp-individualized/uuid123"
func NormalizeTargetName ¶
NormalizeTargetName maps legacy and user-facing target aliases to their canonical internal names.
func TargetRepoAliases ¶
TargetRepoAliases returns all recognized path/file aliases for a target.
Types ¶
This section is empty.