image-builder: fix cross-arch uploading

This commit fixes the cross-arch uploading in the most simple
case by reading the `--arch` when `image-builder build --upload`
is used. Note that this is not a complete fix as it will not
take boot mode into account nor will it (by default) DTRT when
`image-builder upload` is used on a previously build images
for a different architecture.

Thanks to `FrostyX` for reporting the issue.
This commit is contained in:
Michael Vogt 2025-05-27 10:58:26 +02:00 committed by Achilleas Koutsou
parent f4f8b557a5
commit 2996bbc0d1
3 changed files with 52 additions and 31 deletions

View file

@ -84,6 +84,10 @@ func uploaderForCmdAWS(cmd *cobra.Command) (cloud.Uploader, error) {
if err != nil {
return nil, err
}
targetArch, err := cmd.Flags().GetString("arch")
if err != nil {
return nil, err
}
var missing []string
requiredArgs := []string{"aws-ami-name", "aws-bucket", "aws-region"}
@ -103,8 +107,11 @@ func uploaderForCmdAWS(cmd *cobra.Command) (cloud.Uploader, error) {
return nil, fmt.Errorf("%w: %q", ErrMissingUploadConfig, missing)
}
opts := &awscloud.UploaderOptions{
TargetArch: targetArch,
}
return awscloudNewUploader(region, bucketName, amiName, nil)
return awscloudNewUploader(region, bucketName, amiName, opts)
}
func cmdUpload(cmd *cobra.Command, args []string) error {