2022-09-05 07:06:08 +00:00
|
|
|
/*
|
|
|
|
Copyright (c) Edgeless Systems GmbH
|
|
|
|
|
|
|
|
SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
*/
|
|
|
|
|
2022-05-24 08:04:42 +00:00
|
|
|
package kubernetes
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
|
2022-09-21 11:47:57 +00:00
|
|
|
"github.com/edgelesssys/constellation/v2/internal/cloud/metadata"
|
2022-05-24 08:04:42 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// ProviderMetadata implementers read/write cloud provider metadata.
|
|
|
|
type ProviderMetadata interface {
|
2022-07-29 14:30:24 +00:00
|
|
|
// UID returns the unique identifier for the constellation.
|
|
|
|
UID(ctx context.Context) (string, error)
|
2022-05-24 08:04:42 +00:00
|
|
|
// Self retrieves the current instance.
|
2022-06-28 16:23:24 +00:00
|
|
|
Self(ctx context.Context) (metadata.InstanceMetadata, error)
|
2022-08-01 14:51:34 +00:00
|
|
|
// GetLoadBalancerEndpoint retrieves the load balancer endpoint.
|
|
|
|
GetLoadBalancerEndpoint(ctx context.Context) (string, error)
|
2022-05-24 08:04:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
type stubProviderMetadata struct {
|
2022-11-15 09:31:55 +00:00
|
|
|
getLoadBalancerEndpointErr error
|
|
|
|
getLoadBalancerEndpointResp string
|
2022-05-24 08:04:42 +00:00
|
|
|
|
2022-11-15 09:31:55 +00:00
|
|
|
selfErr error
|
|
|
|
selfResp metadata.InstanceMetadata
|
2022-05-24 08:04:42 +00:00
|
|
|
|
2022-11-15 09:31:55 +00:00
|
|
|
uidErr error
|
|
|
|
uidResp string
|
2022-05-24 08:04:42 +00:00
|
|
|
}
|
|
|
|
|
2022-08-01 14:51:34 +00:00
|
|
|
func (m *stubProviderMetadata) GetLoadBalancerEndpoint(ctx context.Context) (string, error) {
|
2022-11-15 09:31:55 +00:00
|
|
|
return m.getLoadBalancerEndpointResp, m.getLoadBalancerEndpointErr
|
2022-05-24 08:04:42 +00:00
|
|
|
}
|
|
|
|
|
2022-06-28 16:23:24 +00:00
|
|
|
func (m *stubProviderMetadata) Self(ctx context.Context) (metadata.InstanceMetadata, error) {
|
2022-11-15 09:31:55 +00:00
|
|
|
return m.selfResp, m.selfErr
|
2022-05-24 08:04:42 +00:00
|
|
|
}
|
|
|
|
|
2022-07-29 14:30:24 +00:00
|
|
|
func (m *stubProviderMetadata) UID(ctx context.Context) (string, error) {
|
2022-11-15 09:31:55 +00:00
|
|
|
return m.uidResp, m.uidErr
|
2022-07-29 14:30:24 +00:00
|
|
|
}
|