Skip to content

Add internal/model package for shared data types #17

Description

@castrojo

Description

Extract a pure data-types package (internal/model) to serve as the contract between all packages. This prevents wizard from becoming a god package and eliminates import cycle risk.

Rationale

Without this, ignition imports wizard for the config struct, install imports wizard, and tui imports wizard. Having a leaf package with zero dependencies that everyone imports cleanly breaks this coupling.

Implementation

// internal/model/model.go
package model

// InstallConfig is the accumulated wizard state passed to ignition generation.
type InstallConfig struct {
    Hostname    string
    Disk        DiskSelection
    Network     NetworkConfig
    Users       []UserConfig
    Sysexts     []Sysext
    ConfigMode  ConfigMode
    ExternalURL string // only when ConfigMode == ExternalURL
}

type ConfigMode int
const (
    ConfigModeGuided ConfigMode = iota
    ConfigModeExternal
)

type DiskSelection struct {
    ByIDPath   string // /dev/disk/by-id/...
    Model      string
    Serial     string
    SizeBytes  uint64
    Transport  string // sata, nvme, usb
    Removable  bool
}

type NetworkMode int
const (
    NetworkModeDHCP NetworkMode = iota
    NetworkModeStatic
)

type NetworkConfig struct {
    Mode      NetworkMode
    Interface string
    Address   string // CIDR notation
    Gateway   string
    DNS       []string
    Hostname  string
}

type UserConfig struct {
    Username     string
    SSHKeys      []string
    PasswordHash string // optional, bcrypt/SHA-512
}

type Sysext struct {
    Name    string
    URL     string
    Version string
    Channel string
}

Dependency Graph

model ← (leaf, zero imports — everyone can depend on it)
runner ← probe, install
validate ← tui, ignition
probe ← wizard/tui
bakery ← wizard/tui
ignition ← install, wizard
install ← wizard
wizard ← tui, cmd/knuckle

Acceptance Criteria

  • internal/model/model.go exists with all types above
  • Zero imports (only stdlib if needed for enums)
  • All other packages reference model.InstallConfig instead of defining their own structs
  • go build ./... passes

Metadata

Metadata

Assignees

No one assigned

    Labels

    1-triageNew work awaiting human triage.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions