-
Notifications
You must be signed in to change notification settings - Fork 286
/
fetch.go
52 lines (45 loc) · 1.57 KB
/
fetch.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package snow
import (
"context"
apierrors "k8s.io/apimachinery/pkg/api/errors"
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
controlplanev1 "sigs.k8s.io/cluster-api/controlplane/kubeadm/api/v1beta1"
"github.com/aws/eks-anywhere/pkg/clients/kubernetes"
"github.com/aws/eks-anywhere/pkg/cluster"
"github.com/aws/eks-anywhere/pkg/clusterapi"
"github.com/aws/eks-anywhere/pkg/constants"
snowv1 "github.com/aws/eks-anywhere/pkg/providers/snow/api/v1beta1"
)
func oldControlPlaneMachineTemplate(ctx context.Context, kubeClient kubernetes.Client, oldSpec *cluster.Spec) (*snowv1.AWSSnowMachineTemplate, error) {
cp := &controlplanev1.KubeadmControlPlane{}
err := kubeClient.Get(ctx, clusterapi.KubeadmControlPlaneName(oldSpec), constants.EksaSystemNamespace, cp)
if apierrors.IsNotFound(err) {
return nil, nil
}
if err != nil {
return nil, err
}
mt := &snowv1.AWSSnowMachineTemplate{}
err = kubeClient.Get(ctx, cp.Spec.MachineTemplate.InfrastructureRef.Name, constants.EksaSystemNamespace, mt)
if apierrors.IsNotFound(err) {
return nil, nil
}
if err != nil {
return nil, err
}
return mt, nil
}
func oldWorkerMachineTemplate(ctx context.Context, kubeclient kubernetes.Client, clusterSpec *cluster.Spec, md *clusterv1.MachineDeployment) (*snowv1.AWSSnowMachineTemplate, error) {
if md == nil {
return nil, nil
}
mt := &snowv1.AWSSnowMachineTemplate{}
err := kubeclient.Get(ctx, md.Spec.Template.Spec.InfrastructureRef.Name, constants.EksaSystemNamespace, mt)
if apierrors.IsNotFound(err) {
return nil, nil
}
if err != nil {
return nil, err
}
return mt, nil
}