-
Notifications
You must be signed in to change notification settings - Fork 1.4k
/
al2.go
43 lines (34 loc) · 1.02 KB
/
al2.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
package nodebootstrap
import (
"github.com/kris-nova/logger"
"github.com/pkg/errors"
api "github.com/weaveworks/eksctl/pkg/apis/eksctl.io/v1alpha5"
"github.com/weaveworks/eksctl/pkg/nodebootstrap/assets"
)
const (
al2BootScript = "bootstrap.al2.sh"
)
type AmazonLinux2 struct {
clusterConfig *api.ClusterConfig
ng *api.NodeGroup
clusterDNS string
}
func NewAL2Bootstrapper(clusterConfig *api.ClusterConfig, ng *api.NodeGroup, clusterDNS string) *AmazonLinux2 {
return &AmazonLinux2{
clusterConfig: clusterConfig,
ng: ng,
clusterDNS: clusterDNS,
}
}
func (b *AmazonLinux2) UserData() (string, error) {
var scripts []script
if api.IsEnabled(b.ng.EFAEnabled) {
scripts = append(scripts, script{name: "efa.al2.sh", contents: assets.EfaAl2Sh})
}
body, err := linuxConfig(b.clusterConfig, al2BootScript, assets.BootstrapAl2Sh, b.clusterDNS, b.ng, scripts...)
if err != nil {
return "", errors.Wrap(err, "encoding user data")
}
logger.Debug("user-data = %s", body)
return body, nil
}