feat: support explicit source bundles through the common installer
This commit is contained in:
@@ -29,6 +29,7 @@ type RuntimeCheck struct {
|
||||
Status string `json:"status"`
|
||||
}
|
||||
type Result struct {
|
||||
Distribution string `json:"distribution"`
|
||||
SchemaVersion int `json:"schema_version"`
|
||||
PlatformReady bool `json:"platform_ready"`
|
||||
WorkspaceReady bool `json:"workspace_ready"`
|
||||
@@ -42,6 +43,7 @@ type Result struct {
|
||||
Journal string `json:"journal,omitempty"`
|
||||
}
|
||||
type journal struct {
|
||||
Distribution string `json:"distribution,omitempty"`
|
||||
SchemaVersion int `json:"schema_version"`
|
||||
Installation string `json:"installation"`
|
||||
ReleaseRevision string `json:"release_revision"`
|
||||
@@ -76,6 +78,7 @@ func Run(ctx context.Context, request Request, runner compose.Runner, check Chec
|
||||
if err != nil || !reflect.DeepEqual(manifest, plan.Release) {
|
||||
return fail("release", "Restore the exact verified release bundle and generate a new plan if its identity changed.")
|
||||
}
|
||||
result.Distribution = manifest.Mode()
|
||||
if err := safeio.EnsurePrivateDirectory(filepath.Join(installation.ProjectDirectory, ".tht")); err != nil {
|
||||
return fail("lock", "The installation control directory must be private and canonical.")
|
||||
}
|
||||
@@ -106,13 +109,20 @@ func Run(ctx context.Context, request Request, runner compose.Runner, check Chec
|
||||
}
|
||||
defer clear(payload)
|
||||
result.Journal = filepath.Join(installation.ControlDirectory(), "installation-apply.json")
|
||||
state := journal{SchemaVersion: 1, Installation: installation.Path, ReleaseRevision: plan.Release.Revision, PlanSeal: plan.InputSeal}
|
||||
state := journal{SchemaVersion: 1, Installation: installation.Path, ReleaseRevision: plan.Release.Revision, PlanSeal: plan.InputSeal, Distribution: manifest.Mode()}
|
||||
if _, err := os.Lstat(result.Journal); err == nil {
|
||||
data, readErr := safeio.ReadCanonicalPrivateRegular(result.Journal, 16<<10)
|
||||
var previous journal
|
||||
if readErr != nil || json.Unmarshal(data, &previous) != nil || previous.SchemaVersion != 1 || previous.Installation != installation.Path || previous.ReleaseRevision != plan.Release.Revision {
|
||||
return fail("journal", "The existing installation journal is invalid or belongs to another release; this command is not a product upgrade.")
|
||||
}
|
||||
previousMode := previous.Distribution
|
||||
if previousMode == "" {
|
||||
previousMode = "prebuilt"
|
||||
}
|
||||
if previousMode != manifest.Mode() {
|
||||
return fail("journal", "Changing between source and prebuilt requires an explicit upgrade or a separate installation.")
|
||||
}
|
||||
} else if !os.IsNotExist(err) {
|
||||
return fail("journal", "Cannot safely read the installation journal.")
|
||||
}
|
||||
@@ -181,6 +191,9 @@ func Run(ctx context.Context, request Request, runner compose.Runner, check Chec
|
||||
return nil
|
||||
}},
|
||||
{"pull", func() error {
|
||||
if manifest.Mode() == "source" {
|
||||
return docker(30*time.Minute, "pull", "--policy", "always", "catalog-db", "qdrant", "embedding", "embedding-model-init")
|
||||
}
|
||||
return docker(30*time.Minute, "--profile", "catalog-maintenance", "--profile", "workspace-maintenance", "pull", "--policy", "always")
|
||||
}},
|
||||
{"runtime-identity", func() error {
|
||||
|
||||
Reference in New Issue
Block a user