mirror of
https://github.com/apricote/hcloud-upload-image.git
synced 2025-08-07 06:16:58 +02:00
feat: upload xz compressed images (#16)
Required for Talos images: https://www.talos.dev/v1.7/talos-guides/install/cloud-platforms/hetzner/#rescue-mode
This commit is contained in:
parent
fcea3e3c6e
commit
1c943e4480
@ -86,10 +86,10 @@ func init() {
|
|||||||
uploadCmd.MarkFlagsMutuallyExclusive(uploadFlagImageURL, uploadFlagImagePath)
|
uploadCmd.MarkFlagsMutuallyExclusive(uploadFlagImageURL, uploadFlagImagePath)
|
||||||
uploadCmd.MarkFlagsOneRequired(uploadFlagImageURL, uploadFlagImagePath)
|
uploadCmd.MarkFlagsOneRequired(uploadFlagImageURL, uploadFlagImagePath)
|
||||||
|
|
||||||
uploadCmd.Flags().String(uploadFlagCompression, "", "Type of compression that was used on the disk image [choices: bz2]")
|
uploadCmd.Flags().String(uploadFlagCompression, "", "Type of compression that was used on the disk image [choices: bz2, xz]")
|
||||||
_ = uploadCmd.RegisterFlagCompletionFunc(
|
_ = uploadCmd.RegisterFlagCompletionFunc(
|
||||||
uploadFlagCompression,
|
uploadFlagCompression,
|
||||||
cobra.FixedCompletions([]string{string(hcloudimages.CompressionBZ2)}, cobra.ShellCompDirectiveNoFileComp),
|
cobra.FixedCompletions([]string{string(hcloudimages.CompressionBZ2), string(hcloudimages.CompressionXZ)}, cobra.ShellCompDirectiveNoFileComp),
|
||||||
)
|
)
|
||||||
|
|
||||||
uploadCmd.Flags().String(uploadFlagArchitecture, "", "CPU architecture of the disk image [choices: x86, arm]")
|
uploadCmd.Flags().String(uploadFlagArchitecture, "", "CPU architecture of the disk image [choices: x86, arm]")
|
||||||
|
@ -86,9 +86,10 @@ type Compression string
|
|||||||
const (
|
const (
|
||||||
CompressionNone Compression = ""
|
CompressionNone Compression = ""
|
||||||
CompressionBZ2 Compression = "bz2"
|
CompressionBZ2 Compression = "bz2"
|
||||||
|
CompressionXZ Compression = "xz"
|
||||||
|
|
||||||
// Possible future additions:
|
// Possible future additions:
|
||||||
// zip,xz,zstd
|
// zip,zstd
|
||||||
)
|
)
|
||||||
|
|
||||||
// NewClient instantiates a new client. It requires a working [*hcloud.Client] to interact with the Hetzner Cloud API.
|
// NewClient instantiates a new client. It requires a working [*hcloud.Client] to interact with the Hetzner Cloud API.
|
||||||
@ -290,6 +291,8 @@ func (s *Client) Upload(ctx context.Context, options UploadOptions) (*hcloud.Ima
|
|||||||
switch options.ImageCompression {
|
switch options.ImageCompression {
|
||||||
case CompressionBZ2:
|
case CompressionBZ2:
|
||||||
cmd += "bzip2 -cd | "
|
cmd += "bzip2 -cd | "
|
||||||
|
case CompressionXZ:
|
||||||
|
cmd += "xz -cd | "
|
||||||
default:
|
default:
|
||||||
return nil, fmt.Errorf("unknown compression: %q", options.ImageCompression)
|
return nil, fmt.Errorf("unknown compression: %q", options.ImageCompression)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user