mirror of
https://github.com/edgelesssys/constellation.git
synced 2025-08-03 04:26:20 -04:00
AB#2523 Refactor GCP metadata/cloud API (#387)
* Refactor GCP metadata/cloud API * Remove cloud controller manager from metadata package * Remove PublicIP * Move shared cloud packages * Remove dead code Signed-off-by: Daniel Weiße <dw@edgeless.systems>
This commit is contained in:
parent
e9fecec0bc
commit
c9873f2bfb
54 changed files with 1587 additions and 3791 deletions
|
@ -11,11 +11,7 @@ import (
|
|||
"fmt"
|
||||
"net"
|
||||
|
||||
awscloud "github.com/edgelesssys/constellation/v2/internal/cloud/aws"
|
||||
azurecloud "github.com/edgelesssys/constellation/v2/internal/cloud/azure"
|
||||
gcpcloud "github.com/edgelesssys/constellation/v2/internal/cloud/gcp"
|
||||
"github.com/edgelesssys/constellation/v2/internal/cloud/metadata"
|
||||
qemucloud "github.com/edgelesssys/constellation/v2/internal/cloud/qemu"
|
||||
"github.com/edgelesssys/constellation/v2/internal/deploy/ssh"
|
||||
"github.com/edgelesssys/constellation/v2/internal/role"
|
||||
)
|
||||
|
@ -34,46 +30,9 @@ type Fetcher struct {
|
|||
metaAPI providerMetadata
|
||||
}
|
||||
|
||||
// NewGCP creates a new GCP fetcher.
|
||||
func NewGCP(ctx context.Context) (*Fetcher, error) {
|
||||
gcpClient, err := gcpcloud.NewClient(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
metaAPI := gcpcloud.New(gcpClient)
|
||||
|
||||
func New(cloud providerMetadata) *Fetcher {
|
||||
return &Fetcher{
|
||||
metaAPI: metaAPI,
|
||||
}, nil
|
||||
}
|
||||
|
||||
// NewAzure creates a new Azure fetcher.
|
||||
func NewAWS(ctx context.Context) (*Fetcher, error) {
|
||||
metaAPI, err := awscloud.New(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &Fetcher{
|
||||
metaAPI: metaAPI,
|
||||
}, nil
|
||||
}
|
||||
|
||||
// NewAzure creates a new Azure fetcher.
|
||||
func NewAzure(ctx context.Context) (*Fetcher, error) {
|
||||
metaAPI, err := azurecloud.NewMetadata(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &Fetcher{
|
||||
metaAPI: metaAPI,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func NewQEMU() *Fetcher {
|
||||
return &Fetcher{
|
||||
metaAPI: &qemucloud.Metadata{},
|
||||
metaAPI: cloud,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -226,7 +226,6 @@ type stubMetadata struct {
|
|||
getInstanceErr error
|
||||
getLBEndpointRes string
|
||||
getLBEndpointErr error
|
||||
supportedRes bool
|
||||
}
|
||||
|
||||
func (m *stubMetadata) List(ctx context.Context) ([]metadata.InstanceMetadata, error) {
|
||||
|
@ -244,7 +243,3 @@ func (m *stubMetadata) GetInstance(ctx context.Context, providerID string) (meta
|
|||
func (m *stubMetadata) GetLoadBalancerEndpoint(ctx context.Context) (string, error) {
|
||||
return m.getLBEndpointRes, m.getLBEndpointErr
|
||||
}
|
||||
|
||||
func (m *stubMetadata) Supported() bool {
|
||||
return m.supportedRes
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue