diff --git a/build_capabilities_test.go b/build_capabilities_test.go new file mode 100644 index 0000000..db8da51 --- /dev/null +++ b/build_capabilities_test.go @@ -0,0 +1,21 @@ +package main + +import ( + "context" + "testing" + + builderv0 "github.com/codefly-dev/core/generated/go/codefly/services/builder/v0" +) + +// The CLI verifies every agent before dispatching a build to a selected Buildx +// builder (an environment that mirrors a registry builds on one of its own); +// an agent that cannot answer fails the whole render. +func TestBuildCapabilitiesHonourASelectedBuilder(t *testing.T) { + capabilities, err := NewBuilder().BuildCapabilities(context.Background(), &builderv0.BuildCapabilitiesRequest{}) + if err != nil { + t.Fatal(err) + } + if !capabilities.GetBuildxSelection() { + t.Fatal("a selected Buildx builder must be honoured") + } +} diff --git a/builder.go b/builder.go index c1a23df..f9f6c34 100644 --- a/builder.go +++ b/builder.go @@ -53,6 +53,17 @@ type deploymentTemplateParameters struct { External bool } +// BuildCapabilities answers the CLI's check before a build that names a Buildx +// builder: this agent executes no docker build of its own — its Build hands +// the CLI a recipe or no image at all — so a selected builder is always +// honoured, by the CLI, which runs every recipe on the builder it selected. +// Without this answer core refuses the whole render of any environment that +// mirrors a registry, because such an environment builds on a dedicated +// builder and core verifies every agent before dispatching to it. +func (s *Builder) BuildCapabilities(context.Context, *builderv0.BuildCapabilitiesRequest) (*builderv0.BuildCapabilitiesResponse, error) { + return &builderv0.BuildCapabilitiesResponse{BuildxSelection: true}, nil +} + func NewBuilder() *Builder { return &Builder{ Service: NewService(),