This commit adds support to upload the build image directly to the target cloud. Currently only ami/AWS is supported. If the cloud specific configuration is given at the commandline and the image type is a cloud image the cloud upload will happen automatically (just like with bib). Incomplete upload config is an error.
35 lines
816 B
Go
35 lines
816 B
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
"path/filepath"
|
|
|
|
"github.com/osbuild/bootc-image-builder/bib/pkg/progress"
|
|
"github.com/osbuild/images/pkg/imagefilter"
|
|
)
|
|
|
|
type buildOptions struct {
|
|
OutputDir string
|
|
StoreDir string
|
|
|
|
WriteManifest bool
|
|
}
|
|
|
|
func buildImage(pbar progress.ProgressBar, res *imagefilter.Result, osbuildManifest []byte, opts *buildOptions) error {
|
|
if opts == nil {
|
|
opts = &buildOptions{}
|
|
}
|
|
|
|
if opts.WriteManifest {
|
|
p := filepath.Join(opts.OutputDir, fmt.Sprintf("%s.osbuild-manifest.json", outputNameFor(res)))
|
|
if err := os.MkdirAll(filepath.Dir(p), 0755); err != nil {
|
|
return err
|
|
}
|
|
if err := os.WriteFile(p, osbuildManifest, 0644); err != nil {
|
|
return err
|
|
}
|
|
}
|
|
|
|
return progress.RunOSBuild(pbar, osbuildManifest, opts.StoreDir, opts.OutputDir, res.ImgType.Exports(), nil)
|
|
}
|