mirror of
https://github.com/edgelesssys/constellation.git
synced 2025-08-05 05:24:16 -04:00
AB#2287 support community image IDs (#9)
* support community image IDs Signed-off-by: Fabian Kammel <fk@edgeless.systems>
This commit is contained in:
parent
e0a457b6ff
commit
778952e07c
13 changed files with 175 additions and 41 deletions
|
@ -5,6 +5,7 @@ import (
|
|||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
|
||||
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/compute/armcompute/v2"
|
||||
)
|
||||
|
||||
|
@ -22,10 +23,14 @@ func (c *Client) GetScalingGroupImage(ctx context.Context, scalingGroupID string
|
|||
res.Properties.VirtualMachineProfile == nil ||
|
||||
res.Properties.VirtualMachineProfile.StorageProfile == nil ||
|
||||
res.Properties.VirtualMachineProfile.StorageProfile.ImageReference == nil ||
|
||||
res.Properties.VirtualMachineProfile.StorageProfile.ImageReference.ID == nil {
|
||||
res.Properties.VirtualMachineProfile.StorageProfile.ImageReference.ID == nil && res.Properties.VirtualMachineProfile.StorageProfile.ImageReference.CommunityGalleryImageID == nil {
|
||||
return "", fmt.Errorf("scalet set %q does not have valid image reference", scalingGroupID)
|
||||
}
|
||||
return *res.Properties.VirtualMachineProfile.StorageProfile.ImageReference.ID, nil
|
||||
if res.Properties.VirtualMachineProfile.StorageProfile.ImageReference.ID != nil {
|
||||
return *res.Properties.VirtualMachineProfile.StorageProfile.ImageReference.ID, nil
|
||||
} else {
|
||||
return *res.Properties.VirtualMachineProfile.StorageProfile.ImageReference.CommunityGalleryImageID, nil
|
||||
}
|
||||
}
|
||||
|
||||
// SetScalingGroupImage sets the image URI of the scaling group.
|
||||
|
@ -38,9 +43,7 @@ func (c *Client) SetScalingGroupImage(ctx context.Context, scalingGroupID, image
|
|||
Properties: &armcompute.VirtualMachineScaleSetUpdateProperties{
|
||||
VirtualMachineProfile: &armcompute.VirtualMachineScaleSetUpdateVMProfile{
|
||||
StorageProfile: &armcompute.VirtualMachineScaleSetUpdateStorageProfile{
|
||||
ImageReference: &armcompute.ImageReference{
|
||||
ID: &imageURI,
|
||||
},
|
||||
ImageReference: imageReferenceFromImage(imageURI),
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -82,3 +85,15 @@ func (c *Client) ListScalingGroups(ctx context.Context, uid string) (controlPlan
|
|||
}
|
||||
return controlPlaneGroupIDs, workerGroupIDs, nil
|
||||
}
|
||||
|
||||
func imageReferenceFromImage(img string) *armcompute.ImageReference {
|
||||
ref := &armcompute.ImageReference{}
|
||||
|
||||
if strings.HasPrefix(img, "/CommunityGalleries") {
|
||||
ref.CommunityGalleryImageID = to.Ptr(img)
|
||||
} else {
|
||||
ref.ID = to.Ptr(img)
|
||||
}
|
||||
|
||||
return ref
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue