mirror of
https://github.com/edgelesssys/constellation.git
synced 2025-09-18 20:14:48 -04:00
Refactor Azure IMDS client and metadata
This commit is contained in:
parent
f15605cb45
commit
69abe17c96
10 changed files with 312 additions and 250 deletions
|
@ -4,7 +4,6 @@ import (
|
|||
"errors"
|
||||
"fmt"
|
||||
"regexp"
|
||||
"strings"
|
||||
)
|
||||
|
||||
var azureVMSSProviderIDRegexp = regexp.MustCompile(`^azure:///subscriptions/([^/]+)/resourceGroups/([^/]+)/providers/Microsoft.Compute/virtualMachineScaleSets/([^/]+)/virtualMachines/([^/]+)$`)
|
||||
|
@ -18,19 +17,6 @@ func BasicsFromProviderID(providerID string) (subscriptionID, resourceGroup stri
|
|||
return "", "", fmt.Errorf("providerID %v is malformatted", providerID)
|
||||
}
|
||||
|
||||
// UIDFromProviderID extracts our own generated unique ID, which is the
|
||||
// suffix at the resource group, e.g., resource-group-J18dB
|
||||
// J18dB is the UID.
|
||||
func UIDFromProviderID(providerID string) (string, error) {
|
||||
_, resourceGroup, _, _, err := ScaleSetInformationFromProviderID(providerID)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
parts := strings.Split(resourceGroup, "-")
|
||||
return parts[len(parts)-1], nil
|
||||
}
|
||||
|
||||
// ScaleSetInformationFromProviderID splits a provider's id belonging to an azure scaleset into core components.
|
||||
// A providerID for scale set VMs is build after the following schema:
|
||||
// - 'azure:///subscriptions/<subscription-id>/resourceGroups/<resource-group>/providers/Microsoft.Compute/virtualMachineScaleSets/<scale-set-name>/virtualMachines/<instance-id>'
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue