Carry module identity through candidate results
This commit is contained in:
22
build.go
22
build.go
@@ -22,11 +22,14 @@ type BuildSpec struct {
|
||||
|
||||
// BuildRequest contains the source and output settings for Build.
|
||||
type BuildRequest struct {
|
||||
RepositoryDir string // source repository whose current HEAD is recorded.
|
||||
Version string // stable vMAJOR.MINOR.PATCH value injected at link time.
|
||||
Spec BuildSpec // application package, artifact name, and targets.
|
||||
OutputDir string // output location; empty selects <repository>/dist.
|
||||
Output io.Writer // optional build progress destination.
|
||||
RepositoryDir string // source repository whose current HEAD is recorded.
|
||||
// ModuleDir selects a repository-relative module directory; empty selects
|
||||
// the repository root.
|
||||
ModuleDir string
|
||||
Version string // stable vMAJOR.MINOR.PATCH value injected at link time.
|
||||
Spec BuildSpec // application package, artifact name, and targets.
|
||||
OutputDir string // output location; empty selects <repository>/dist.
|
||||
Output io.Writer // optional build progress destination.
|
||||
}
|
||||
|
||||
// BuildArtifact identifies one generated binary and its SHA-256 digest.
|
||||
@@ -40,6 +43,9 @@ type BuildArtifact struct {
|
||||
// BuildResult describes the source and artifacts reached by Build.
|
||||
type BuildResult struct {
|
||||
RepositoryDir string // absolute source repository path.
|
||||
ModuleDir string // absolute selected module directory.
|
||||
ModulePath string // selected module's declared Go path.
|
||||
Tag string // complete tag derived for this version.
|
||||
CandidateCommit string // Git HEAD observed when the build started.
|
||||
// SourceVerified reports clean source and the same HEAD observed before and
|
||||
// after a completed build. It is required for binary delivery, not an attestation.
|
||||
@@ -62,6 +68,7 @@ type BuildResult struct {
|
||||
func Build(ctx context.Context, request BuildRequest) (BuildResult, error) {
|
||||
result, err := internalbuild.Build(ctx, internalbuild.Request{
|
||||
RepositoryDir: request.RepositoryDir,
|
||||
ModuleDir: request.ModuleDir,
|
||||
Version: request.Version,
|
||||
Spec: *internalBuildSpec(&request.Spec),
|
||||
OutputDir: request.OutputDir,
|
||||
@@ -69,6 +76,9 @@ func Build(ctx context.Context, request BuildRequest) (BuildResult, error) {
|
||||
})
|
||||
public := BuildResult{
|
||||
RepositoryDir: result.RepositoryDir,
|
||||
ModuleDir: result.ModuleDir,
|
||||
ModulePath: result.ModulePath,
|
||||
Tag: result.Tag,
|
||||
CandidateCommit: result.CandidateCommit,
|
||||
SourceVerified: result.SourceVerified,
|
||||
Version: result.Version,
|
||||
@@ -105,7 +115,7 @@ func internalBuildSpec(spec *BuildSpec) *internalbuild.Spec {
|
||||
}
|
||||
|
||||
func internalBuildResult(result BuildResult) *internalbuild.Result {
|
||||
converted := &internalbuild.Result{RepositoryDir: result.RepositoryDir, CandidateCommit: result.CandidateCommit, SourceVerified: result.SourceVerified, Version: result.Version, MainPackage: result.MainPackage, BinaryName: result.BinaryName, OutputDir: result.OutputDir, Compiler: result.Compiler}
|
||||
converted := &internalbuild.Result{RepositoryDir: result.RepositoryDir, ModuleDir: result.ModuleDir, ModulePath: result.ModulePath, Tag: result.Tag, CandidateCommit: result.CandidateCommit, SourceVerified: result.SourceVerified, Version: result.Version, MainPackage: result.MainPackage, BinaryName: result.BinaryName, OutputDir: result.OutputDir, Compiler: result.Compiler}
|
||||
for _, target := range result.Targets {
|
||||
converted.Targets = append(converted.Targets, internalbuild.Target{OS: target.OS, Arch: target.Arch})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user