mirror of
https://github.com/edgelesssys/constellation.git
synced 2024-12-25 23:49:37 -05:00
0d12e37c96
* Include EXC0014 and fix issues. * Include EXC0012 and fix issues. Signed-off-by: Fabian Kammel <fk@edgeless.systems> Co-authored-by: Otto Bittner <cobittner@posteo.net>
50 lines
1.2 KiB
Go
50 lines
1.2 KiB
Go
/*
|
|
Copyright (c) Edgeless Systems GmbH
|
|
|
|
SPDX-License-Identifier: AGPL-3.0-only
|
|
*/
|
|
|
|
package azure
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/google/uuid"
|
|
)
|
|
|
|
const (
|
|
// DefaultResourceGroupName to find Constellation images in.
|
|
DefaultResourceGroupName = "CONSTELLATION-IMAGES"
|
|
// DefaultGalleryName to find Constellation images in.
|
|
DefaultGalleryName = "Constellation_CVM"
|
|
// DefaultImageDefinition to find Constellation images in.
|
|
DefaultImageDefinition = "constellation"
|
|
)
|
|
|
|
// Options for Azure Client to download image references.
|
|
type Options struct {
|
|
SubscriptionID string
|
|
ResourceGroupName string
|
|
GalleryName string
|
|
ImageDefinition string
|
|
}
|
|
|
|
// DefaultOptions creates an Options object with good defaults.
|
|
func DefaultOptions() Options {
|
|
return Options{
|
|
SubscriptionID: "",
|
|
ResourceGroupName: DefaultResourceGroupName,
|
|
GalleryName: DefaultGalleryName,
|
|
ImageDefinition: DefaultImageDefinition,
|
|
}
|
|
}
|
|
|
|
// SetSubscription sets subscription from string. It expects a UUID conform value.
|
|
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
|
|
}
|