diff --git a/plugin/pluginexec/buf.gen.yaml b/plugin/pluginexec/buf.gen.yaml index 0d916e0b..fd5766e9 100644 --- a/plugin/pluginexec/buf.gen.yaml +++ b/plugin/pluginexec/buf.gen.yaml @@ -4,7 +4,12 @@ managed: enabled: true override: - file_option: go_package_prefix + path: heph/plugin/exec value: github.com/hephbuild/heph/plugin/pluginexec/gen + - file_option: go_package_prefix + path: heph/plugin + value: github.com/hephbuild/heph/plugin/gen + plugins: - remote: buf.build/protocolbuffers/go out: gen diff --git a/plugin/pluginexec/plugin.go b/plugin/pluginexec/plugin.go index 0cd84692..bcf04b81 100644 --- a/plugin/pluginexec/plugin.go +++ b/plugin/pluginexec/plugin.go @@ -117,24 +117,18 @@ func (p *Plugin) Parse(ctx context.Context, req *connect.Request[pluginv1.ParseR for name, sdeps := range targetSpec.Deps.Merge(targetSpec.HashDeps, targetSpec.RuntimeDeps) { var execDeps execv1.Target_Deps for _, dep := range sdeps { - sref, err := tref.ParseWithOut(dep) + ref, err := tref.ParseWithOut(dep) if err != nil { return nil, err } - ref := &execv1.Target_Deps_TargetRef{ - Package: sref.GetPackage(), - Name: sref.GetName(), - Output: sref.Output, //nolint:protogetter - } - meta, err := anypb.New(ref) if err != nil { return nil, err } deps = append(deps, &pluginv1.TargetDef_Dep{ - Ref: sref, + Ref: ref, Meta: meta, }) @@ -145,25 +139,18 @@ func (p *Plugin) Parse(ctx context.Context, req *connect.Request[pluginv1.ParseR for _, tools := range targetSpec.Tools { for _, tool := range tools { - sref, err := tref.ParseWithOut(tool) + ref, err := tref.ParseWithOut(tool) if err != nil { return nil, err } - ref := &execv1.Target_Deps_TargetRef{ - Package: sref.GetPackage(), - Name: sref.GetName(), - Args: sref.GetArgs(), - Output: sref.Output, //nolint:protogetter - } - meta, err := anypb.New(ref) if err != nil { return nil, err } deps = append(deps, &pluginv1.TargetDef_Dep{ - Ref: sref, + Ref: ref, Meta: meta, }) target.Tools = append(target.Tools, ref) diff --git a/plugin/pluginexec/proto/heph/plugin/exec/v1/plugin.proto b/plugin/pluginexec/proto/heph/plugin/exec/v1/plugin.proto index a0ae531b..54ebec61 100644 --- a/plugin/pluginexec/proto/heph/plugin/exec/v1/plugin.proto +++ b/plugin/pluginexec/proto/heph/plugin/exec/v1/plugin.proto @@ -1,6 +1,8 @@ syntax = "proto3"; package heph.plugin.exec.v1; +import "heph/plugin/v1/plugin.proto"; + message Target { message Output { string group = 1; @@ -8,21 +10,15 @@ message Target { } message Deps { - message TargetRef { - string package = 1; - string name = 2; - map args = 4; - optional string output = 3; - } repeated string files = 1; - repeated TargetRef targets = 2; + repeated heph.plugin.v1.TargetRefWithOutput targets = 2; } repeated string run = 1; map deps = 2; map hash_deps = 3; map runtime_deps = 4; - repeated Deps.TargetRef tools = 10; + repeated heph.plugin.v1.TargetRefWithOutput tools = 10; repeated Output outputs = 5; map env = 6; map runtime_env = 7; diff --git a/plugin/pluginexec/run.go b/plugin/pluginexec/run.go index 117c3f56..a558f974 100644 --- a/plugin/pluginexec/run.go +++ b/plugin/pluginexec/run.go @@ -262,7 +262,7 @@ func (p *Plugin) inputEnv( inputs []*pluginv1.ArtifactWithOrigin, deps map[string]*execv1.Target_Deps, ) ([]string, error) { - getDep := func(t *execv1.Target_Deps_TargetRef) (string, bool) { + getDep := func(t *pluginv1.TargetRefWithOutput) (string, bool) { for name, dep := range deps { for _, target := range dep.GetTargets() { if target.GetName() == t.GetName() && target.GetPackage() == t.GetPackage() { @@ -280,7 +280,7 @@ func (p *Plugin) inputEnv( continue } - ref := &execv1.Target_Deps_TargetRef{} + ref := &pluginv1.TargetRefWithOutput{} err := input.GetMeta().UnmarshalTo(ref) if err != nil { return nil, err diff --git a/plugin/pluginexec/sandbox.go b/plugin/pluginexec/sandbox.go index 72dc9762..81850973 100644 --- a/plugin/pluginexec/sandbox.go +++ b/plugin/pluginexec/sandbox.go @@ -74,14 +74,14 @@ func SetupSandbox(ctx context.Context, t *execv1.Target, results []*pluginv1.Art return listArtifacts, nil } -func ArtifactsForDep(inputs []*pluginv1.ArtifactWithOrigin, ref *execv1.Target_Deps_TargetRef) iter.Seq[*pluginv1.ArtifactWithOrigin] { +func ArtifactsForDep(inputs []*pluginv1.ArtifactWithOrigin, ref *pluginv1.TargetRefWithOutput) iter.Seq[*pluginv1.ArtifactWithOrigin] { return func(yield func(origin *pluginv1.ArtifactWithOrigin) bool) { for _, input := range inputs { if input.GetArtifact().GetType() != pluginv1.Artifact_TYPE_OUTPUT { continue } - aref := &execv1.Target_Deps_TargetRef{} + aref := &pluginv1.TargetRefWithOutput{} err := input.GetMeta().UnmarshalTo(aref) if err != nil { continue