The filename of the image as produced by osbuild for a given export is currently set in each target options type in the `Filename` struct member. However, the value is not really specific to any target type, but to the specific export used for the target. For this reason move the value form target type options to the `Target` struct inside a new struct `OsbuildArtifact` under the name`ExportFilename`. The backward compatibility with older implementations of the composer and workers is kept on the JSON (Un)mashaling level, where the JSON object is always a super-set of the old and new way of providing the export filename in the Target.
44 lines
1.6 KiB
Go
44 lines
1.6 KiB
Go
package target
|
|
|
|
const TargetNameAzureImage TargetName = "org.osbuild.azure.image"
|
|
|
|
type AzureImageTargetOptions struct {
|
|
TenantID string `json:"tenant_id"`
|
|
Location string `json:"location"`
|
|
SubscriptionID string `json:"subscription_id"`
|
|
ResourceGroup string `json:"resource_group"`
|
|
}
|
|
|
|
func (AzureImageTargetOptions) isTargetOptions() {}
|
|
|
|
// NewAzureImageTarget creates org.osbuild.azure.image target
|
|
//
|
|
// This target uploads and registers an Azure Image. The image can be then
|
|
// immediately used to spin up a virtual machine.
|
|
//
|
|
// The target uses Azure OAuth credentials. In most cases you want to create
|
|
// a service principal for this purpose, see:
|
|
// https://docs.microsoft.com/en-us/azure/active-directory/develop/app-objects-and-service-principals
|
|
// The credentials are not passed in the target options, instead they are
|
|
// defined in the worker. If the worker doesn't have Azure credentials
|
|
// and gets a job with this target, the job will fail.
|
|
//
|
|
// The Tenant ID for the authorization process is specified in the target
|
|
// options. This means that this target can be used for multi-tenant
|
|
// applications.
|
|
//
|
|
// If you need to just upload a PageBlob into Azure Storage, see the
|
|
// org.osbuild.azure target.
|
|
func NewAzureImageTarget(options *AzureImageTargetOptions) *Target {
|
|
return newTarget(TargetNameAzureImage, options)
|
|
}
|
|
|
|
type AzureImageTargetResultOptions struct {
|
|
ImageName string `json:"image_name"`
|
|
}
|
|
|
|
func (AzureImageTargetResultOptions) isTargetResultOptions() {}
|
|
|
|
func NewAzureImageTargetResult(options *AzureImageTargetResultOptions) *TargetResult {
|
|
return newTargetResult(TargetNameAzureImage, options)
|
|
}
|