2022-09-05 03:06:08 -04:00
|
|
|
/*
|
|
|
|
Copyright (c) Edgeless Systems GmbH
|
|
|
|
|
|
|
|
SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
*/
|
|
|
|
|
2022-08-31 14:10:49 -04:00
|
|
|
package snp
|
2022-08-19 06:26:29 -04:00
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
2023-03-21 07:46:49 -04:00
|
|
|
"fmt"
|
2022-08-19 06:26:29 -04:00
|
|
|
|
2023-03-21 07:46:49 -04:00
|
|
|
"github.com/edgelesssys/constellation/v2/internal/cloud/azure"
|
2022-08-19 06:26:29 -04:00
|
|
|
)
|
|
|
|
|
2023-03-21 07:46:49 -04:00
|
|
|
const tagMAAURL = "constellation-maa-url"
|
|
|
|
|
2022-08-19 06:26:29 -04:00
|
|
|
type imdsClient struct {
|
2023-03-21 07:46:49 -04:00
|
|
|
imdsClient *azure.IMDSClient
|
2022-08-19 06:26:29 -04:00
|
|
|
}
|
|
|
|
|
2023-03-21 07:46:49 -04:00
|
|
|
func newIMDSClient() *imdsClient {
|
|
|
|
return &imdsClient{
|
|
|
|
imdsClient: azure.NewIMDSClient(),
|
2022-08-19 06:26:29 -04:00
|
|
|
}
|
2023-03-21 07:46:49 -04:00
|
|
|
}
|
2022-08-19 06:26:29 -04:00
|
|
|
|
2023-03-21 07:46:49 -04:00
|
|
|
func (c *imdsClient) getMAAURL(ctx context.Context) (string, error) {
|
|
|
|
tags, err := c.imdsClient.Tags(ctx)
|
|
|
|
if err != nil {
|
|
|
|
return "", fmt.Errorf("getting tags: %w", err)
|
2022-08-19 06:26:29 -04:00
|
|
|
}
|
|
|
|
|
2023-03-21 07:46:49 -04:00
|
|
|
return tags[tagMAAURL], nil
|
2022-08-19 06:26:29 -04:00
|
|
|
}
|