2022-09-05 09:06:08 +02:00
|
|
|
/*
|
|
|
|
Copyright (c) Edgeless Systems GmbH
|
|
|
|
|
|
|
|
SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
*/
|
|
|
|
|
2022-06-28 18:33:27 +02:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
|
2022-09-21 13:47:57 +02:00
|
|
|
"github.com/edgelesssys/constellation/v2/internal/cloud/metadata"
|
|
|
|
"github.com/edgelesssys/constellation/v2/internal/role"
|
2023-01-06 12:04:36 +01:00
|
|
|
"github.com/edgelesssys/constellation/v2/internal/versions/components"
|
2022-06-28 18:33:27 +02:00
|
|
|
kubeadm "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm/v1beta3"
|
|
|
|
)
|
|
|
|
|
|
|
|
// ClusterFake behaves like a real cluster, but does not actually initialize or join Kubernetes.
|
|
|
|
type clusterFake struct{}
|
|
|
|
|
|
|
|
// InitCluster fakes bootstrapping a new cluster with the current node being the master, returning the arguments required to join the cluster.
|
2022-08-12 15:59:45 +02:00
|
|
|
func (c *clusterFake) InitCluster(
|
2023-07-31 10:53:05 +02:00
|
|
|
context.Context, string, string,
|
2024-05-22 16:12:53 +02:00
|
|
|
bool, components.Components, []string, string,
|
2022-06-28 18:33:27 +02:00
|
|
|
) ([]byte, error) {
|
|
|
|
return []byte{}, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// JoinCluster will fake joining the current node to an existing cluster.
|
2024-05-22 16:12:53 +02:00
|
|
|
func (c *clusterFake) JoinCluster(context.Context, *kubeadm.BootstrapTokenDiscovery, role.Role, components.Components) error {
|
2022-06-28 18:33:27 +02:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// StartKubelet starts the kubelet service.
|
2023-11-03 20:45:32 +01:00
|
|
|
func (c *clusterFake) StartKubelet() error {
|
2022-06-28 18:33:27 +02:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
type providerMetadataFake struct{}
|
|
|
|
|
|
|
|
func (f *providerMetadataFake) List(ctx context.Context) ([]metadata.InstanceMetadata, error) {
|
|
|
|
self, err := f.Self(ctx)
|
|
|
|
return []metadata.InstanceMetadata{self}, err
|
|
|
|
}
|
|
|
|
|
2023-03-20 11:03:36 +01:00
|
|
|
func (f *providerMetadataFake) Self(_ context.Context) (metadata.InstanceMetadata, error) {
|
2022-06-28 18:33:27 +02:00
|
|
|
return metadata.InstanceMetadata{
|
|
|
|
Name: "instanceName",
|
|
|
|
ProviderID: "fake://instance-id",
|
|
|
|
Role: role.Unknown,
|
2022-08-04 11:08:20 +02:00
|
|
|
VPCIP: "192.0.2.1",
|
2022-06-28 18:33:27 +02:00
|
|
|
}, nil
|
|
|
|
}
|
|
|
|
|
2023-07-21 16:43:51 +02:00
|
|
|
func (f *providerMetadataFake) GetLoadBalancerEndpoint(_ context.Context) (string, string, error) {
|
|
|
|
return "", "", nil
|
2022-08-01 16:51:34 +02:00
|
|
|
}
|
2022-11-26 19:44:34 +01:00
|
|
|
|
2023-03-20 11:03:36 +01:00
|
|
|
func (f *providerMetadataFake) InitSecretHash(_ context.Context) ([]byte, error) {
|
2022-11-26 19:44:34 +01:00
|
|
|
return nil, nil
|
|
|
|
}
|