-
Notifications
You must be signed in to change notification settings - Fork 7
/
capa.go
92 lines (78 loc) · 2.34 KB
/
capa.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
package provider
import (
"context"
"io"
"github.com/giantswarm/k8sclient/v5/pkg/k8sclient"
"github.com/giantswarm/microerror"
"github.com/giantswarm/kubectl-gs/cmd/template/cluster/provider/templates/aws"
"github.com/giantswarm/kubectl-gs/internal/key"
)
func WriteCAPATemplate(ctx context.Context, client k8sclient.Interface, out io.Writer, config ClusterCRsConfig) error {
var err error
var sshSSOPublicKey string
{
sshSSOPublicKey, err = key.SSHSSOPublicKey(ctx, client.CtrlClient())
if err != nil {
return microerror.Mask(err)
}
}
data := struct {
BastionSSHDConfig string
Description string
KubernetesVersion string
Name string
Namespace string
Organization string
PodsCIDR string
ReleaseVersion string
SSHDConfig string
SSOPublicKey string
}{
BastionSSHDConfig: key.BastionSSHDConfigEncoded(),
Description: config.Description,
KubernetesVersion: "v1.19.9",
Name: config.Name,
Namespace: key.OrganizationNamespaceFromName(config.Organization),
Organization: config.Organization,
PodsCIDR: config.PodsCIDR,
ReleaseVersion: config.ReleaseVersion,
SSHDConfig: key.NodeSSHDConfigEncoded(),
SSOPublicKey: sshSSOPublicKey,
}
var templates []templateConfig
for _, t := range aws.GetAWSTemplates() {
templates = append(templates, templateConfig(t))
}
err = runMutation(ctx, client, data, templates, out)
if err != nil {
return microerror.Mask(err)
}
return nil
}
func WriteCAPAEKSTemplate(ctx context.Context, client k8sclient.Interface, out io.Writer, config ClusterCRsConfig) error {
var err error
data := struct {
Description string
KubernetesVersion string
Name string
Namespace string
Organization string
ReleaseVersion string
}{
Description: config.Description,
KubernetesVersion: "v1.21",
Name: config.Name,
Namespace: key.OrganizationNamespaceFromName(config.Organization),
Organization: config.Organization,
ReleaseVersion: config.ReleaseVersion,
}
var templates []templateConfig
for _, t := range aws.GetEKSTemplates() {
templates = append(templates, templateConfig(t))
}
err = runMutation(ctx, client, data, templates, out)
if err != nil {
return microerror.Mask(err)
}
return nil
}