Include the osbuild/images module version in the Manifest job result. The module has direct impact on image definitions and the content of produced manifest, therefore including this information in the Manifest job result is very helpful for various purposes (debugging, traceability). This will enable to embed this information in the Koji build metadata. Signed-off-by: Tomáš Hozza <thozza@redhat.com>
28 lines
596 B
Go
28 lines
596 B
Go
package common
|
|
|
|
import (
|
|
"fmt"
|
|
"runtime/debug"
|
|
)
|
|
|
|
const (
|
|
OSBuildImagesModulePath = "github.com/osbuild/images"
|
|
)
|
|
|
|
// GetDepModuleInfoByPath returns the debug.Module for the dependency
|
|
// with the given path. If the dependency is not found, an error is
|
|
// returned.
|
|
func GetDepModuleInfoByPath(path string) (*debug.Module, error) {
|
|
buildinfo, ok := debug.ReadBuildInfo()
|
|
if !ok {
|
|
return nil, fmt.Errorf("Failed to read build info")
|
|
}
|
|
|
|
for _, dep := range buildinfo.Deps {
|
|
if dep.Path == path {
|
|
return dep, nil
|
|
}
|
|
}
|
|
|
|
return nil, fmt.Errorf("Could not find dependency %s", path)
|
|
}
|