mirror of
https://github.com/rancher/os.git
synced 2025-09-19 09:22:40 +00:00
simplistic start
Signed-off-by: Sven Dowideit <SvenDowideit@home.org.au>
This commit is contained in:
@@ -181,23 +181,24 @@ func getDatasources(cfg *rancherConfig.CloudConfig, network bool) []datasource.D
|
||||
for _, ds := range cfg.Rancher.CloudInit.Datasources {
|
||||
parts := strings.SplitN(ds, ":", 2)
|
||||
|
||||
root := ""
|
||||
if len(parts) > 1 {
|
||||
root = parts[1]
|
||||
}
|
||||
|
||||
switch parts[0] {
|
||||
case "ec2":
|
||||
if network {
|
||||
if len(parts) == 1 {
|
||||
dss = append(dss, ec2.NewDatasource(ec2.DefaultAddress))
|
||||
} else {
|
||||
dss = append(dss, ec2.NewDatasource(parts[1]))
|
||||
}
|
||||
dss = append(dss, ec2.NewDatasource(root))
|
||||
}
|
||||
case "file":
|
||||
if len(parts) == 2 {
|
||||
dss = append(dss, file.NewDatasource(parts[1]))
|
||||
if root != "" {
|
||||
dss = append(dss, file.NewDatasource(root))
|
||||
}
|
||||
case "url":
|
||||
if network {
|
||||
if len(parts) == 2 {
|
||||
dss = append(dss, url.NewDatasource(parts[1]))
|
||||
if root != "" {
|
||||
dss = append(dss, url.NewDatasource(root))
|
||||
}
|
||||
}
|
||||
case "cmdline":
|
||||
@@ -207,28 +208,24 @@ func getDatasources(cfg *rancherConfig.CloudConfig, network bool) []datasource.D
|
||||
}
|
||||
}
|
||||
case "configdrive":
|
||||
if len(parts) == 2 {
|
||||
dss = append(dss, configdrive.NewDatasource(parts[1]))
|
||||
if root != "" {
|
||||
dss = append(dss, configdrive.NewDatasource(root))
|
||||
}
|
||||
case "digitalocean":
|
||||
if network {
|
||||
if len(parts) == 1 {
|
||||
dss = append(dss, digitalocean.NewDatasource(digitalocean.DefaultAddress))
|
||||
} else {
|
||||
dss = append(dss, digitalocean.NewDatasource(parts[1]))
|
||||
}
|
||||
dss = append(dss, digitalocean.NewDatasource(root))
|
||||
} else {
|
||||
enableDoLinkLocal()
|
||||
}
|
||||
case "gce":
|
||||
if network {
|
||||
dss = append(dss, gce.NewDatasource("http://metadata.google.internal/"))
|
||||
dss = append(dss, gce.NewDatasource(root))
|
||||
}
|
||||
case "packet":
|
||||
if !network {
|
||||
enablePacketNetwork(&cfg.Rancher)
|
||||
}
|
||||
dss = append(dss, packet.NewDatasource("https://metadata.packet.net/"))
|
||||
dss = append(dss, packet.NewDatasource(root))
|
||||
}
|
||||
}
|
||||
|
||||
|
3
config/cloudinit/datasource/metadata/digitalocean/metadata.go
Normal file → Executable file
3
config/cloudinit/datasource/metadata/digitalocean/metadata.go
Normal file → Executable file
@@ -66,6 +66,9 @@ type MetadataService struct {
|
||||
}
|
||||
|
||||
func NewDatasource(root string) *MetadataService {
|
||||
if root == "" {
|
||||
root = DefaultAddress
|
||||
}
|
||||
return &MetadataService{Service: metadata.NewDatasource(root, apiVersion, userdataURL, metadataPath, nil)}
|
||||
}
|
||||
|
||||
|
3
config/cloudinit/datasource/metadata/ec2/metadata.go
Normal file → Executable file
3
config/cloudinit/datasource/metadata/ec2/metadata.go
Normal file → Executable file
@@ -39,6 +39,9 @@ type MetadataService struct {
|
||||
}
|
||||
|
||||
func NewDatasource(root string) *MetadataService {
|
||||
if root == "" {
|
||||
root = DefaultAddress
|
||||
}
|
||||
return &MetadataService{metadata.NewDatasource(root, apiVersion, userdataPath, metadataPath, nil)}
|
||||
}
|
||||
|
||||
|
@@ -26,9 +26,10 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
apiVersion = "computeMetadata/v1/"
|
||||
metadataPath = apiVersion
|
||||
userdataPath = apiVersion + "instance/attributes/user-data"
|
||||
DefaultAddress = "http://metadata.google.internal/"
|
||||
apiVersion = "computeMetadata/v1/"
|
||||
metadataPath = apiVersion
|
||||
userdataPath = apiVersion + "instance/attributes/user-data"
|
||||
)
|
||||
|
||||
type MetadataService struct {
|
||||
@@ -36,6 +37,9 @@ type MetadataService struct {
|
||||
}
|
||||
|
||||
func NewDatasource(root string) *MetadataService {
|
||||
if root == "" {
|
||||
root = DefaultAddress
|
||||
}
|
||||
return &MetadataService{metadata.NewDatasource(root, apiVersion, userdataPath, metadataPath, http.Header{"Metadata-Flavor": {"Google"}})}
|
||||
}
|
||||
|
||||
|
4
config/cloudinit/datasource/metadata/packet/metadata.go
Normal file → Executable file
4
config/cloudinit/datasource/metadata/packet/metadata.go
Normal file → Executable file
@@ -62,6 +62,10 @@ type MetadataService struct {
|
||||
}
|
||||
|
||||
func NewDatasource(root string) *MetadataService {
|
||||
if root == "" {
|
||||
root = DefaultAddress
|
||||
}
|
||||
|
||||
return &MetadataService{Service: metadata.NewDatasource(root, apiVersion, userdataURL, metadataPath, nil)}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user