container: add support for uploading to registries
Add a new generic container registry client via a new `container` package. Use this to create a command line utility as well as a new upload target for container registries. The code uses the github.com/containers/* project and packages to interact with container registires that is also used by skopeo, podman et al. One if the dependencies is `proglottis/gpgme` that is using cgo to bind libgpgme, so we have to add the corresponding devel package to the BuildRequires as well as installing it on CI. Checks will follow later via an integration test.
This commit is contained in:
parent
d136a075bc
commit
986f076276
955 changed files with 164203 additions and 2549 deletions
|
|
@ -12,6 +12,7 @@ import (
|
|||
"path"
|
||||
"strings"
|
||||
|
||||
"github.com/osbuild/osbuild-composer/internal/container"
|
||||
"github.com/osbuild/osbuild-composer/internal/upload/oci"
|
||||
|
||||
"github.com/google/uuid"
|
||||
|
|
@ -813,6 +814,38 @@ func (impl *OSBuildJobImpl) Run(job worker.Job) error {
|
|||
)
|
||||
osbuildJobResult.Success = true
|
||||
osbuildJobResult.UploadStatus = "success"
|
||||
|
||||
case *target.ContainerTargetOptions:
|
||||
destination := args.Targets[0].ImageName
|
||||
|
||||
logWithId.Printf("[container] ⬆ Uploading the image to %s", destination)
|
||||
|
||||
ctx := context.Background()
|
||||
client, err := container.NewClient(destination)
|
||||
if err != nil {
|
||||
osbuildJobResult.JobError = clienterrors.WorkerClientError(clienterrors.ErrorInvalidConfig, err.Error())
|
||||
return nil
|
||||
}
|
||||
|
||||
client.Auth.Username = options.Username
|
||||
client.Auth.Password = options.Password
|
||||
|
||||
if options.TlsVerify != nil {
|
||||
client.TlsVerify = *options.TlsVerify
|
||||
}
|
||||
|
||||
sourcePath := path.Join(outputDirectory, exportPath, options.Filename)
|
||||
|
||||
// TODO: get the container type from the metadata of the osbuild job
|
||||
sourceRef := fmt.Sprintf("oci-archive:%s", sourcePath)
|
||||
|
||||
digest, err := client.UploadImage(ctx, sourceRef, "")
|
||||
if err != nil {
|
||||
osbuildJobResult.JobError = clienterrors.WorkerClientError(clienterrors.ErrorUploadingImage, err.Error())
|
||||
return nil
|
||||
}
|
||||
logWithId.Printf("[container] 🎉 Image uploaded (%s)!", digest.String())
|
||||
|
||||
default:
|
||||
osbuildJobResult.JobError = clienterrors.WorkerClientError(clienterrors.ErrorInvalidTarget, fmt.Sprintf("invalid target type: %s", args.Targets[0].Name))
|
||||
return nil
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue