6 Commits

Author SHA1 Message Date
Jeff McCune
4482930e82 cue: improve error messages to show user field paths
Use v.Validate(cue.Concrete(true)) before decoding to get user-friendly
field paths like "holos.metadata.name" instead of internal type names
like "#Metadata.name". This makes error messages clearer and matches
the output style of cue export.

With this patch the error is as I want it to be:

    ❯ holos show platform
    error at internal/platform/platform.go:153: holos.metadata.name: incomplete value string
    holos.metadata.name: incomplete value string:
        /Users/jeff/Holos/holos/tmp/examples/cue.mod/gen/github.com/holos-run/holos/api/core/v1alpha6/types_go_gen.cue:419:8
2025-05-22 15:01:36 -07:00
Jeff McCune
6c4561bd84 platform: refactor component selectors
Previously we were having to define selectors on every command that
processes platform components.  This patch fixes the problems by moving
component selectors to the platform.Config struct.

Result:
Commands that process platform components need to explicity add the
platform.Config.FlagSet to the command, but otherwise the configuration
is consolidated and reused as we want.  The holos show platform command
always uses the default configuration so we don't bother adding the
flags for this case.
2025-04-02 12:13:03 -07:00
Jeff McCune
36ade0b5b6 cli: refactor holos render platform command
This patch refactors the holos render platform command to use the new
platform package instead of the previous builder package.  Similar to
the holos show buildplans command, the PerComponentFunc is used, the
main difference is it simply constructs an argument vector to execute
holos render component injecting the proper flags and tags for cue to
produce the build plan.
2025-04-02 11:32:49 -07:00
Jeff McCune
ddb6dc8dee maint: cleanup undused platform_test.go 2025-04-02 11:32:49 -07:00
Jeff McCune
95d53062da cli: refactor how build plans are loaded
Previously the show buildplans, render platform, and render component
commands used duplicate code paths to obtain build plans and render
components.  This patch consolidates the behaviors into the component
and platform packages.  The platform Build method is used to call a
different PerComponentFunc depending on the use case of showing build
plans or rendering each component in the platform.

The behavior of loading a build plan from cue is consolidated into the
Component.BuildPlan method.

Result:

1. Platform.Build is reused for both show buildplans and render platform
2. Component.BuildPlan is reused for both show buildplans and render
   component.
2025-04-01 20:59:39 -07:00
Jeff McCune
779f04b85a builder: refactor to component and platform packages
There are only two version specific cue builders, a Platform and a
component BuildPlan. The platform is anemic while the component holds
most of the behavior of the Holos rendering pipeline.  Without this
patch the two types of builders were mixed together in the same package.

This patch refactors the version specific builders into the platform and
component packages respectively.  The version specific BuildPlan builder
is where most of the behavior lies and what we expect to evolve most
over time.  With the typemeta.yaml approach, we can easily switch code
paths, isolated to the process boundary since holos render platform
invokes sub processes for each holos render component command.

This patch helps focus on good test coverage by establishing a clear
area to add version specific test cases, both for the platform layer and
the individual component layer.
2025-04-01 08:51:36 -07:00