2022-09-05 03:06:08 -04:00
|
|
|
/*
|
|
|
|
Copyright (c) Edgeless Systems GmbH
|
|
|
|
|
|
|
|
SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
*/
|
|
|
|
|
2022-05-24 04:04:42 -04:00
|
|
|
package kubernetes
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
|
2022-09-21 07:47:57 -04:00
|
|
|
"github.com/edgelesssys/constellation/v2/internal/cloud/metadata"
|
2022-05-24 04:04:42 -04:00
|
|
|
)
|
|
|
|
|
|
|
|
// ProviderMetadata implementers read/write cloud provider metadata.
|
|
|
|
type ProviderMetadata interface {
|
2022-07-29 10:30:24 -04:00
|
|
|
// UID returns the unique identifier for the constellation.
|
|
|
|
UID(ctx context.Context) (string, error)
|
2022-05-24 04:04:42 -04:00
|
|
|
// List retrieves all instances belonging to the current Constellation.
|
2022-06-28 12:23:24 -04:00
|
|
|
List(ctx context.Context) ([]metadata.InstanceMetadata, error)
|
2022-05-24 04:04:42 -04:00
|
|
|
// Self retrieves the current instance.
|
2022-06-28 12:23:24 -04:00
|
|
|
Self(ctx context.Context) (metadata.InstanceMetadata, error)
|
2022-08-01 10:51:34 -04:00
|
|
|
// GetLoadBalancerEndpoint retrieves the load balancer endpoint.
|
|
|
|
GetLoadBalancerEndpoint(ctx context.Context) (string, error)
|
2022-05-24 04:04:42 -04:00
|
|
|
// GetInstance retrieves an instance using its providerID.
|
2022-06-28 12:23:24 -04:00
|
|
|
GetInstance(ctx context.Context, providerID string) (metadata.InstanceMetadata, error)
|
2022-05-24 04:04:42 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
type stubProviderMetadata struct {
|
2022-08-01 10:51:34 -04:00
|
|
|
GetLoadBalancerEndpointErr error
|
|
|
|
GetLoadBalancerEndpointResp string
|
2022-05-24 04:04:42 -04:00
|
|
|
|
|
|
|
ListErr error
|
2022-06-28 12:23:24 -04:00
|
|
|
ListResp []metadata.InstanceMetadata
|
2022-05-24 04:04:42 -04:00
|
|
|
|
|
|
|
SelfErr error
|
2022-06-28 12:23:24 -04:00
|
|
|
SelfResp metadata.InstanceMetadata
|
2022-05-24 04:04:42 -04:00
|
|
|
|
|
|
|
GetInstanceErr error
|
2022-06-28 12:23:24 -04:00
|
|
|
GetInstanceResp metadata.InstanceMetadata
|
2022-05-24 04:04:42 -04:00
|
|
|
|
2022-07-29 10:30:24 -04:00
|
|
|
UIDErr error
|
|
|
|
UIDResp string
|
2022-05-24 04:04:42 -04:00
|
|
|
}
|
|
|
|
|
2022-08-01 10:51:34 -04:00
|
|
|
func (m *stubProviderMetadata) GetLoadBalancerEndpoint(ctx context.Context) (string, error) {
|
|
|
|
return m.GetLoadBalancerEndpointResp, m.GetLoadBalancerEndpointErr
|
2022-05-24 04:04:42 -04:00
|
|
|
}
|
|
|
|
|
2022-06-28 12:23:24 -04:00
|
|
|
func (m *stubProviderMetadata) List(ctx context.Context) ([]metadata.InstanceMetadata, error) {
|
2022-05-24 04:04:42 -04:00
|
|
|
return m.ListResp, m.ListErr
|
|
|
|
}
|
|
|
|
|
2022-06-28 12:23:24 -04:00
|
|
|
func (m *stubProviderMetadata) Self(ctx context.Context) (metadata.InstanceMetadata, error) {
|
2022-05-24 04:04:42 -04:00
|
|
|
return m.SelfResp, m.SelfErr
|
|
|
|
}
|
|
|
|
|
2022-06-28 12:23:24 -04:00
|
|
|
func (m *stubProviderMetadata) GetInstance(ctx context.Context, providerID string) (metadata.InstanceMetadata, error) {
|
2022-05-24 04:04:42 -04:00
|
|
|
return m.GetInstanceResp, m.GetInstanceErr
|
|
|
|
}
|
|
|
|
|
2022-07-29 10:30:24 -04:00
|
|
|
func (m *stubProviderMetadata) UID(ctx context.Context) (string, error) {
|
|
|
|
return m.UIDResp, m.UIDErr
|
|
|
|
}
|