Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions candy/plugin-fleet/bed_persist_writer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ func bedTestMarshalNode(_ string, node *deploykit.DeployNode) (*yaml.Node, error
// merge/preserve contract). There is no lighter-weight node-form-aware reader at the deploykit
// layer (sdk/loaderkit's real decoder needs a live executor/registry a standalone plugin test
// has none of) — this is a THIN, TEST-SCOPED decoder for exactly the shapes this suite's
// fixtures use (pod/local/group discriminators; image/port/disposable/requires_exclusive/
// preemptible scalar fields; Children vs Members disambiguated by whether the parent's own
// discriminator is "group"), not a general node-form parser.
// fixtures use (pod/local/group discriminators; image/engine/resolved_image/port/disposable/
// requires_exclusive/preemptible scalar fields; Children vs Members disambiguated by whether
// the parent's own discriminator is "group"), not a general node-form parser.
func bedTestLoadDeployConfig() (*deploykit.DeployConfig, error) {
path, err := spec.DefaultDeployConfigPath()
if err != nil {
Expand Down Expand Up @@ -116,6 +116,12 @@ func bedTestDecodeNode(entryMap map[string]any) *spec.DeployNode {
if lifecycle, ok := discBody["lifecycle"].(string); ok {
node.Lifecycle = lifecycle
}
if engine, ok := discBody["engine"].(string); ok {
node.Engine = spec.EngineName(engine)
}
if resolved, ok := discBody["resolved_image"].(string); ok {
node.ResolvedImage = resolved
}
if b, ok := discBody["disposable"].(bool); ok {
node.Disposable = &b
}
Expand Down
39 changes: 39 additions & 0 deletions candy/plugin-fleet/deploy_state_writer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,45 @@ existing-deploy:
}
}

// TestSaveDeployState_PersistsEngine is the consumer-side witness for
// opencharly/charly#1109: the PrepareVenue state patch plugin-fleet decodes must carry a pod
// deploy's authored `engine:` selector through this module's own pinned spec/sdk and land it
// on the per-host entry. It fails if EITHER pin is older than the field (the typed decode
// drops it) or if sdk stops applying it. `charly config`/`charly start` resolve their run
// mode from that entry, so a dropped selector emits a podman quadlet for an
// `engine: containerd` deploy.
func TestSaveDeployState_PersistsEngine(t *testing.T) {
dir := t.TempDir()
t.Setenv("XDG_CONFIG_HOME", dir)
if err := os.MkdirAll(filepath.Join(dir, "charly"), 0700); err != nil {
t.Fatalf("mkdir: %v", err)
}
path := filepath.Join(dir, "charly", "charly.yml")
if err := os.WriteFile(path, []byte("existing-deploy:\n pod:\n image: existing-image\n"), 0600); err != nil {
t.Fatalf("write initial: %v", err)
}

deploykit.SaveDeployState("probe", "", deploykit.SaveDeployStateInput{
ResolvedImage: "probe-overlay:abc",
Engine: spec.EngineName("containerd"),
}, bedTestMarshalNode, bedTestLoadDeployConfig, context.Background())

dc, err := bedTestLoadDeployConfig()
if err != nil {
t.Fatalf("reload after save: %v", err)
}
entry, ok := dc.Deploy["probe"]
if !ok {
t.Fatal("probe entry not added")
}
if entry.Engine != spec.EngineName("containerd") {
t.Fatalf("Engine = %q, want containerd — the state decode or the sdk apply dropped the authored selector", entry.Engine)
}
if entry.ResolvedImage != "probe-overlay:abc" {
t.Fatalf("ResolvedImage = %q, want the overlay ref preserved alongside the engine", entry.ResolvedImage)
}
}

// TestSaveDeployState_DoesNotClobberExistingImageTarget pins the "only set when entry
// doesn't already declare" semantics: if a pre-existing entry already has box:/target:, a
// SaveDeployState call with different Image/Target values MUST leave the existing values
Expand Down
4 changes: 2 additions & 2 deletions candy/plugin-fleet/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/opencharly/plugin-fleet/candy/plugin-fleet
go 1.26.8

require (
github.com/opencharly/sdk v0.2026296.1058
github.com/opencharly/sdk v0.2026309.1926
gopkg.in/yaml.v3 v3.0.1
)

Expand Down Expand Up @@ -34,7 +34,7 @@ require (
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/mitchellh/go-wordwrap v1.0.1 // indirect
github.com/oklog/run v1.1.0 // indirect
github.com/opencharly/spec v0.2026296.1036
github.com/opencharly/spec v0.2026309.1917
github.com/pelletier/go-toml/v2 v2.4.3 // indirect
github.com/protocolbuffers/txtpbfmt v0.0.0-20260217160748-a481f6a22f94 // indirect
go.yaml.in/yaml/v3 v3.0.5 // indirect
Expand Down
4 changes: 4 additions & 0 deletions candy/plugin-fleet/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,12 @@ github.com/opencharly/plugin-init/candy/plugin-init v0.2026240.1727 h1:O+O561QPo
github.com/opencharly/plugin-init/candy/plugin-init v0.2026240.1727/go.mod h1:TFRtupIf/As+ETNbtEr0v+kEYUmNiDqBFKDduymv3x4=
github.com/opencharly/sdk v0.2026296.1058 h1:vXoozMXS9ZDj2KlpTQWDi2iXPWpDF2xKhraKFFOk20Y=
github.com/opencharly/sdk v0.2026296.1058/go.mod h1:JATa64xjMSgqEdOhRRm4iiptgfaetvmHOwybt9kKZko=
github.com/opencharly/sdk v0.2026309.1926 h1:DLhLwsT5E17bEYh6iGVRs+BYz6r1bUQ04zq5UgnlExw=
github.com/opencharly/sdk v0.2026309.1926/go.mod h1:r8zMVnKjFjkOaIlRTmlRA/jCtDhRn1doLR0PedHhDgs=
github.com/opencharly/spec v0.2026296.1036 h1:F3Up2zG5hLw2SFVOR772cMQ1JegU/+HjoK8dOPGR/AU=
github.com/opencharly/spec v0.2026296.1036/go.mod h1:VrjzjP2glMbDwP4JNm50OV0MraHFZnFKTl+bVlouoso=
github.com/opencharly/spec v0.2026309.1917 h1:DHjf0t7TloPeG44PNSxqlZBvxWv1ssEZ+4UnQZi94E0=
github.com/opencharly/spec v0.2026309.1917/go.mod h1:VrjzjP2glMbDwP4JNm50OV0MraHFZnFKTl+bVlouoso=
github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U=
github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM=
github.com/opencontainers/image-spec v1.1.1 h1:y0fUlFfIZhPF1W537XOLg0/fcx6zcHCJwooC2xJA040=
Expand Down