From 6c37fec17bf3166037499341f49c8e6753eecdd5 Mon Sep 17 00:00:00 2001 From: Thales Maciel Date: Sun, 26 Apr 2026 20:28:40 -0300 Subject: [PATCH] images: remove the docker field MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The 'docker' bit on model.Image was unused at runtime — every code path that branched on it had been removed earlier, leaving only the field, the SQL column, the --docker flag, and the #feature:docker sentinel that BuildMetadataPackages emitted into a hash file. None of those have callers anymore. Strip the field from the model, the API params, the SQLite column, the CLI flag, and BuildMetadataPackages's signature. Add migration 2 (drop_images_docker) so existing installs lose the column on next daemon start. ALTER TABLE ... DROP COLUMN is fine: SQLite has supported it since 3.35 (2021). Co-Authored-By: Claude Opus 4.7 (1M context) --- internal/api/types.go | 1 - internal/cli/cli_test.go | 2 +- internal/cli/commands_image.go | 1 - internal/daemon/imagemgr/paths.go | 11 +++-------- internal/daemon/images.go | 2 -- internal/model/types.go | 1 - internal/store/migrations.go | 11 +++++++++++ internal/store/store.go | 16 ++++++---------- internal/store/store_test.go | 6 ++---- 9 files changed, 23 insertions(+), 28 deletions(-) diff --git a/internal/api/types.go b/internal/api/types.go index d471995..776a7f3 100644 --- a/internal/api/types.go +++ b/internal/api/types.go @@ -158,7 +158,6 @@ type ImageRegisterParams struct { InitrdPath string `json:"initrd_path,omitempty"` ModulesDir string `json:"modules_dir,omitempty"` KernelRef string `json:"kernel_ref,omitempty"` - Docker bool `json:"docker,omitempty"` } type ImagePullParams struct { diff --git a/internal/cli/cli_test.go b/internal/cli/cli_test.go index db2ca4a..4b7acec 100644 --- a/internal/cli/cli_test.go +++ b/internal/cli/cli_test.go @@ -309,7 +309,7 @@ func TestImageRegisterFlagsExist(t *testing.T) { if err != nil { t.Fatalf("find register: %v", err) } - for _, flagName := range []string{"name", "rootfs", "work-seed", "kernel", "initrd", "modules", "docker"} { + for _, flagName := range []string{"name", "rootfs", "work-seed", "kernel", "initrd", "modules"} { if register.Flags().Lookup(flagName) == nil { t.Fatalf("missing flag %q", flagName) } diff --git a/internal/cli/commands_image.go b/internal/cli/commands_image.go index 235fbac..af1940e 100644 --- a/internal/cli/commands_image.go +++ b/internal/cli/commands_image.go @@ -80,7 +80,6 @@ func (d *deps) newImageRegisterCommand() *cobra.Command { cmd.Flags().StringVar(¶ms.InitrdPath, "initrd", "", "initrd path") cmd.Flags().StringVar(¶ms.ModulesDir, "modules", "", "modules dir") cmd.Flags().StringVar(¶ms.KernelRef, "kernel-ref", "", "name of a cataloged kernel (see 'banger kernel list')") - cmd.Flags().BoolVar(¶ms.Docker, "docker", false, "mark image as docker-prepared") _ = cmd.RegisterFlagCompletionFunc("kernel-ref", d.completeKernelNames) return cmd } diff --git a/internal/daemon/imagemgr/paths.go b/internal/daemon/imagemgr/paths.go index 5916381..22f4b03 100644 --- a/internal/daemon/imagemgr/paths.go +++ b/internal/daemon/imagemgr/paths.go @@ -129,14 +129,9 @@ func StageOptionalArtifactPath(artifactDir, stagedPath, name string) string { } // BuildMetadataPackages returns the canonical package set recorded for a -// managed image build. The #feature:docker sentinel is appended when -// docker is requested. -func BuildMetadataPackages(docker bool) []string { - packages := DebianBasePackages() - if docker { - packages = append(packages, "#feature:docker") - } - return packages +// managed image build. +func BuildMetadataPackages() []string { + return DebianBasePackages() } // WritePackagesMetadata writes the hash of packages next to rootfsPath so diff --git a/internal/daemon/images.go b/internal/daemon/images.go index 6b5a806..b9e1332 100644 --- a/internal/daemon/images.go +++ b/internal/daemon/images.go @@ -64,7 +64,6 @@ func (s *ImageService) RegisterImage(ctx context.Context, params api.ImageRegist image.KernelPath = kernelPath image.InitrdPath = initrdPath image.ModulesDir = modulesDir - image.Docker = params.Docker image.UpdatedAt = now case errors.Is(lookupErr, sql.ErrNoRows): id, idErr := model.NewID() @@ -80,7 +79,6 @@ func (s *ImageService) RegisterImage(ctx context.Context, params api.ImageRegist KernelPath: kernelPath, InitrdPath: initrdPath, ModulesDir: modulesDir, - Docker: params.Docker, CreatedAt: now, UpdatedAt: now, } diff --git a/internal/model/types.go b/internal/model/types.go index fcc8744..c37b71a 100644 --- a/internal/model/types.go +++ b/internal/model/types.go @@ -76,7 +76,6 @@ type Image struct { ModulesDir string `json:"modules_dir,omitempty"` BuildSize string `json:"build_size,omitempty"` SeededSSHPublicKeyFingerprint string `json:"seeded_ssh_public_key_fingerprint,omitempty"` - Docker bool `json:"docker"` CreatedAt time.Time `json:"created_at"` UpdatedAt time.Time `json:"updated_at"` } diff --git a/internal/store/migrations.go b/internal/store/migrations.go index 059ec7e..ea54187 100644 --- a/internal/store/migrations.go +++ b/internal/store/migrations.go @@ -24,6 +24,7 @@ type migration struct { // entries — installed DBs key off the id column. var migrations = []migration{ {id: 1, name: "baseline", up: migrateBaseline}, + {id: 2, name: "drop_images_docker", up: migrateDropImagesDocker}, } // runMigrations ensures schema_migrations exists, then applies every @@ -141,3 +142,13 @@ func migrateBaseline(tx *sql.Tx) error { } return nil } + +// migrateDropImagesDocker removes the legacy images.docker column. +// SQLite supports ALTER TABLE ... DROP COLUMN since 3.35 (2021), and +// banger ships against modern SQLite, so a single statement is enough. +// Existing values are simply discarded — the field never affected +// runtime behaviour. +func migrateDropImagesDocker(tx *sql.Tx) error { + _, err := tx.Exec(`ALTER TABLE images DROP COLUMN docker;`) + return err +} diff --git a/internal/store/store.go b/internal/store/store.go index ad995dc..9cd00e0 100644 --- a/internal/store/store.go +++ b/internal/store/store.go @@ -123,8 +123,8 @@ func (s *Store) UpsertImage(ctx context.Context, image model.Image) error { const query = ` INSERT INTO images ( id, name, managed, artifact_dir, rootfs_path, work_seed_path, kernel_path, initrd_path, - modules_dir, build_size, seeded_ssh_public_key_fingerprint, docker, created_at, updated_at - ) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) + modules_dir, build_size, seeded_ssh_public_key_fingerprint, created_at, updated_at + ) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) ON CONFLICT(id) DO UPDATE SET name=excluded.name, managed=excluded.managed, @@ -136,7 +136,6 @@ func (s *Store) UpsertImage(ctx context.Context, image model.Image) error { modules_dir=excluded.modules_dir, build_size=excluded.build_size, seeded_ssh_public_key_fingerprint=excluded.seeded_ssh_public_key_fingerprint, - docker=excluded.docker, updated_at=excluded.updated_at` _, err := s.db.ExecContext(ctx, query, image.ID, @@ -150,7 +149,6 @@ func (s *Store) UpsertImage(ctx context.Context, image model.Image) error { image.ModulesDir, image.BuildSize, image.SeededSSHPublicKeyFingerprint, - boolToInt(image.Docker), image.CreatedAt.Format(time.RFC3339), image.UpdatedAt.Format(time.RFC3339), ) @@ -158,15 +156,15 @@ func (s *Store) UpsertImage(ctx context.Context, image model.Image) error { } func (s *Store) GetImageByName(ctx context.Context, name string) (model.Image, error) { - return s.getImage(ctx, "SELECT id, name, managed, artifact_dir, rootfs_path, work_seed_path, kernel_path, initrd_path, modules_dir, build_size, seeded_ssh_public_key_fingerprint, docker, created_at, updated_at FROM images WHERE name = ?", name) + return s.getImage(ctx, "SELECT id, name, managed, artifact_dir, rootfs_path, work_seed_path, kernel_path, initrd_path, modules_dir, build_size, seeded_ssh_public_key_fingerprint, created_at, updated_at FROM images WHERE name = ?", name) } func (s *Store) GetImageByID(ctx context.Context, id string) (model.Image, error) { - return s.getImage(ctx, "SELECT id, name, managed, artifact_dir, rootfs_path, work_seed_path, kernel_path, initrd_path, modules_dir, build_size, seeded_ssh_public_key_fingerprint, docker, created_at, updated_at FROM images WHERE id = ?", id) + return s.getImage(ctx, "SELECT id, name, managed, artifact_dir, rootfs_path, work_seed_path, kernel_path, initrd_path, modules_dir, build_size, seeded_ssh_public_key_fingerprint, created_at, updated_at FROM images WHERE id = ?", id) } func (s *Store) ListImages(ctx context.Context) ([]model.Image, error) { - rows, err := s.db.QueryContext(ctx, "SELECT id, name, managed, artifact_dir, rootfs_path, work_seed_path, kernel_path, initrd_path, modules_dir, build_size, seeded_ssh_public_key_fingerprint, docker, created_at, updated_at FROM images ORDER BY created_at ASC") + rows, err := s.db.QueryContext(ctx, "SELECT id, name, managed, artifact_dir, rootfs_path, work_seed_path, kernel_path, initrd_path, modules_dir, build_size, seeded_ssh_public_key_fingerprint, created_at, updated_at FROM images ORDER BY created_at ASC") if err != nil { return nil, err } @@ -356,7 +354,7 @@ type scanner interface { func scanImageRow(row scanner) (model.Image, error) { var image model.Image - var managed, docker int + var managed int var workSeedPath sql.NullString var seededSSHPublicKeyFingerprint sql.NullString var createdAt, updatedAt string @@ -372,7 +370,6 @@ func scanImageRow(row scanner) (model.Image, error) { &image.ModulesDir, &image.BuildSize, &seededSSHPublicKeyFingerprint, - &docker, &createdAt, &updatedAt, ) @@ -380,7 +377,6 @@ func scanImageRow(row scanner) (model.Image, error) { return image, err } image.Managed = managed == 1 - image.Docker = docker == 1 image.WorkSeedPath = workSeedPath.String image.SeededSSHPublicKeyFingerprint = seededSSHPublicKeyFingerprint.String image.CreatedAt, err = time.Parse(time.RFC3339, createdAt) diff --git a/internal/store/store_test.go b/internal/store/store_test.go index 8d91784..29589e5 100644 --- a/internal/store/store_test.go +++ b/internal/store/store_test.go @@ -179,8 +179,8 @@ func TestGetImageRejectsMalformedTimestamp(t *testing.T) { _, err := store.db.ExecContext(ctx, ` INSERT INTO images ( id, name, managed, artifact_dir, rootfs_path, kernel_path, initrd_path, - modules_dir, build_size, docker, created_at, updated_at - ) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`, + modules_dir, build_size, created_at, updated_at + ) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`, "image-bad-time", "image-bad-time", 0, @@ -190,7 +190,6 @@ func TestGetImageRejectsMalformedTimestamp(t *testing.T) { "", "", "", - 0, "not-a-time", "not-a-time", ) @@ -398,7 +397,6 @@ func sampleImage(name string) model.Image { ModulesDir: "/modules/" + name, BuildSize: "8G", SeededSSHPublicKeyFingerprint: "seeded-fingerprint", - Docker: true, CreatedAt: now, UpdatedAt: now, }