inlets / inlets/inletsctl

[Suggestion] Move defaults into provision package

Open
#17 3 comments 0 reactions 0 assignees View on GitHub
Dominant language
Go
Stars
488
Forks
62
PR merge metrics
No merged PRs in 30d

Description

@alexellis how would you feel about moving the provisioner defaults into the provision package and removing the additional section? The only config currently in there is for projectID, port and zone. If we make port a constant and add it to provision as well then we only have to add projectID and zone to BasicHost which can be populated if set. This would also require some minor changes to a couple of the provisioners.

Something like this in provision.go
```
func NewBasicHost(provider, name, region, projectID, zone, userData string) (*BasicHost, error) {
if _, ok := defaults[provider]; !ok {
return nil, fmt.Errorf("no provisioner for provider: %q", provider)
}
host := &BasicHost{
Name: name,
OS: defaults[provider].os,
Plan: defaults[provider].plan,
UserData: userData,
ProjectID: projectID,
Zone: zone,
}
if region == "" && len(defaults[provider].region) != 0 {
host.Region = defaults[provider].region
} else {
host.Region = region
}
return host, nil
}

type provisionerDefaults struct {
os string
plan string
region string
}

const ControlPort = 8080

var defaults = map[string]provisionerDefaults{
"digitalocean": {
os: "ubuntu-16-04-x64",
plan: "512mb",
},
"packet": {
os: "ubuntu_16_04",
plan: "t1.small.x86",
region: "ams1",
},
"scaleway": {
os: "ubuntu-bionic",
plan: "DEV1-S",
region: "fr-par-1",
},
"civo": {
os: "811a8dfb-8202-49ad-b1ef-1e6320b20497",
plan: "g2.small",
},
"gce": {
os: "projects/debian-cloud/global/images/debian-9-stretch-v20191121",
plan: "f1-micro",
},
"ec2": {
os: "ubuntu/images/hvm-ssd/ubuntu-xenial-16.04-amd64-server-20191114",
plan: "t3.nano",
region: "eu-west-1",
},
}
```

I am happy to do the work for this if you think it is a good idea. No worries if not.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.