2022-09-05 03:06:08 -04:00
|
|
|
/*
|
|
|
|
Copyright (c) Edgeless Systems GmbH
|
|
|
|
|
|
|
|
SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
*/
|
|
|
|
|
2022-08-23 07:19:37 -04:00
|
|
|
package azure
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
|
|
|
|
"github.com/google/uuid"
|
|
|
|
)
|
|
|
|
|
|
|
|
const (
|
2022-11-09 09:57:54 -05:00
|
|
|
// DefaultResourceGroupName to find Constellation images in.
|
2022-08-23 07:19:37 -04:00
|
|
|
DefaultResourceGroupName = "CONSTELLATION-IMAGES"
|
2022-11-09 09:57:54 -05:00
|
|
|
// DefaultGalleryName to find Constellation images in.
|
|
|
|
DefaultGalleryName = "Constellation_CVM"
|
|
|
|
// DefaultImageDefinition to find Constellation images in.
|
|
|
|
DefaultImageDefinition = "constellation"
|
2022-08-23 07:19:37 -04:00
|
|
|
)
|
|
|
|
|
2022-11-09 09:57:54 -05:00
|
|
|
// Options for Azure Client to download image references.
|
2022-08-23 07:19:37 -04:00
|
|
|
type Options struct {
|
|
|
|
SubscriptionID string
|
|
|
|
ResourceGroupName string
|
|
|
|
GalleryName string
|
|
|
|
ImageDefinition string
|
|
|
|
}
|
|
|
|
|
2022-11-09 09:57:54 -05:00
|
|
|
// DefaultOptions creates an Options object with good defaults.
|
2022-08-23 07:19:37 -04:00
|
|
|
func DefaultOptions() Options {
|
|
|
|
return Options{
|
|
|
|
SubscriptionID: "",
|
|
|
|
ResourceGroupName: DefaultResourceGroupName,
|
|
|
|
GalleryName: DefaultGalleryName,
|
|
|
|
ImageDefinition: DefaultImageDefinition,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-11-09 09:57:54 -05:00
|
|
|
// SetSubscription sets subscription from string. It expects a UUID conform value.
|
2022-08-23 07:19:37 -04:00
|
|
|
func (o *Options) SetSubscription(sub string) error {
|
|
|
|
if _, err := uuid.Parse(sub); err != nil {
|
|
|
|
return fmt.Errorf("unable to set subscription: %w", err)
|
|
|
|
}
|
|
|
|
o.SubscriptionID = sub
|
|
|
|
return nil
|
|
|
|
}
|