Documentation
¶
Overview ¶
Package deploysource implements the bridge side of add-coolify-hosting's artifact bridge (tasks 4.1-4.3): pack the mission's working source tree and upload it to the platform's deploys/ R2 namespace via the same two-phase protocol previews use (declare -> presigned PUTs -> complete).
Unlike the preview package there is no auto path at all — the only trigger is a `pending` hosted_deployments row the user created with an explicit deploy click, discovered through the bridge's poll. Task completion and merges never reach this package, so zero source leaves the machine unless the user asked for it (task 4.3's hard requirement).
Index ¶
Constants ¶
const ( MaxFileBytes = 26_214_400 // 25MB per file MaxTotalBytes = 314_572_800 // 300MB per source tree )
Same ceilings as the platform's defaults (hosted-deployments.ts). Checked at pack time to fail fast before any bytes move; the platform re-checks at declare, so a config drift between the two sides surfaces as a declare rejection rather than a truncated upload.
Variables ¶
var ExcludedDirs = map[string]bool{ ".git": true, "node_modules": true, "dist": true, "build": true, "out": true, ".next": true, ".cache": true, ".turbo": true, "coverage": true, ".open-agents-bridge-worktrees": true, }
ExcludedDirs are directory names never packed, at any depth. Mirrors the platform's SOURCE_EXCLUDED_DIRS (apps/api/src/services/hosted-deployments.ts): .git because the platform materializes its own single-commit repo from the tree, .open-agents-bridge-worktrees because mission task worktrees under it are merge intermediates (their leftover state after a failed merge must not ride along — the platform rejects any path hitting the name), the rest because they are build outputs or dependency caches the build on the hosting node regenerates anyway.
var SensitivePatterns = []*regexp.Regexp{ regexp.MustCompile(`^\.env(\..+)?$`), regexp.MustCompile(`\.(pem|key|p12|pfx)$`), regexp.MustCompile(`^id_rsa`), regexp.MustCompile(`^id_ed25519`), regexp.MustCompile(`^id_ecdsa`), regexp.MustCompile(`^service-account.+\.json$`), regexp.MustCompile(`^credentials.*\.json$`), }
SensitivePatterns match file basenames stripped from the pack (not uploaded — the hosting node gets a clean tree and injects its own env). Mirrors the platform's SOURCE_SENSITIVE_PATTERNS; the platform additionally REJECTS a manifest containing any of these (SOURCE_SENSITIVE_FILE), so the strip here is for the honest path and the rejection there is the backstop against a buggy or modified packer.
Functions ¶
func RunSourceUpload ¶
RunSourceUpload packs repoRoot and runs the two-phase upload for one pending deployment. Best-effort like every preview path: failures are logged and returned, never propagated into mission control flow — and the platform keeps offering the row on the next poll, so a transient failure self-heals (declare's skip-list means the retry only uploads what is missing).
Types ¶
type Logf ¶
type Logf func(format string, args ...interface{})
Logf matches bridge.go's b.logInfo/b.logDebug shape.
type PackResult ¶
type PackResult struct {
Files []preview.ManifestFile
Stripped []string // sensitive basenames removed, for the log line
}
PackResult carries the manifest plus what was left out, so the caller can log the strip decisions — a deploy whose app genuinely needs a stripped file fails at the hosting node, and this is the only place the omission is visible before that.
func PackSourceTree ¶
func PackSourceTree(root string) (*PackResult, error)
PackSourceTree walks root and manifests every packable file. Paths are POSIX-relative to root, sorted deterministically, hashed with sha256 — the same manifest contract as previews. Oversize files/trees are errors, not truncations: a partial tree deploys a broken app.
type Uploader ¶
type Uploader interface {
DeclareHostedSource(missionID, deploymentID string, files []api.PreviewFile) (*api.DeclareSourceResponse, error)
CompleteHostedSource(missionID, deploymentID string) error
UploadPreviewFile(url string, data []byte) error
}
Uploader is the subset of *api.Client this package needs. Kept as a local interface (not preview.Uploader, which demands the preview calls) so tests stub exactly the deploy boundary.