Compare commits
12 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
a0fcbb16d6 | ||
|
f63fa39a2d | ||
|
0ae90f3b22 | ||
|
dee67b964a | ||
|
05062188f1 | ||
|
5405fc9d0d | ||
|
c7f327bb89 | ||
|
71e2b2bddb | ||
|
8fac253214 | ||
|
e19fd09664 | ||
|
4a25948b53 | ||
|
f5cc75299a |
@@ -3,11 +3,10 @@ sudo: false
|
||||
matrix:
|
||||
include:
|
||||
- go: 1.4
|
||||
env: TOOLS_CMD=golang.org/x/tools/cmd
|
||||
|
||||
install:
|
||||
- go get ${TOOLS_CMD}/cover
|
||||
- go get ${TOOLS_CMD}/vet
|
||||
install:
|
||||
- go get golang.org/x/tools/cmd/cover
|
||||
- go get golang.org/x/tools/cmd/vet
|
||||
- go: 1.5
|
||||
|
||||
script:
|
||||
- ./test
|
||||
|
@@ -17,11 +17,11 @@ For example, the following cloud-config document...
|
||||
#cloud-config
|
||||
coreos:
|
||||
oem:
|
||||
id: rackspace
|
||||
name: Rackspace Cloud Servers
|
||||
version-id: 168.0.0
|
||||
home-url: https://www.rackspace.com/cloud/servers/
|
||||
bug-report-url: https://github.com/coreos/coreos-overlay
|
||||
id: "rackspace"
|
||||
name: "Rackspace Cloud Servers"
|
||||
version-id: "168.0.0"
|
||||
home-url: "https://www.rackspace.com/cloud/servers/"
|
||||
bug-report-url: "https://github.com/coreos/coreos-overlay"
|
||||
```
|
||||
|
||||
...would be rendered to the following `/etc/oem-release`:
|
||||
|
@@ -59,12 +59,12 @@ If the platform environment supports the templating feature of coreos-cloudinit
|
||||
|
||||
coreos:
|
||||
etcd:
|
||||
name: node001
|
||||
name: "node001"
|
||||
# generate a new token for each unique cluster from https://discovery.etcd.io/new
|
||||
discovery: https://discovery.etcd.io/<token>
|
||||
discovery: "https://discovery.etcd.io/<token>"
|
||||
# multi-region and multi-cloud deployments need to use $public_ipv4
|
||||
addr: $public_ipv4:4001
|
||||
peer-addr: $private_ipv4:7001
|
||||
addr: "$public_ipv4:4001"
|
||||
peer-addr: "$private_ipv4:7001"
|
||||
```
|
||||
|
||||
...will generate a systemd unit drop-in for etcd.service with the following contents:
|
||||
@@ -96,14 +96,14 @@ For example, the following cloud-config document...
|
||||
coreos:
|
||||
etcd2:
|
||||
# generate a new token for each unique cluster from https://discovery.etcd.io/new?size=3
|
||||
discovery: https://discovery.etcd.io/<token>
|
||||
discovery: "https://discovery.etcd.io/<token>"
|
||||
# multi-region and multi-cloud deployments need to use $public_ipv4
|
||||
advertise-client-urls: http://$public_ipv4:2379
|
||||
initial-advertise-peer-urls: http://$private_ipv4:2380
|
||||
advertise-client-urls: "http://$public_ipv4:2379"
|
||||
initial-advertise-peer-urls: "http://$private_ipv4:2380"
|
||||
# listen on both the official ports and the legacy ports
|
||||
# legacy ports can be omitted if your application doesn't depend on them
|
||||
listen-client-urls: http://0.0.0.0:2379,http://0.0.0.0:4001
|
||||
listen-peer-urls: http://$private_ipv4:2380,http://$private_ipv4:7001
|
||||
listen-client-urls: "http://0.0.0.0:2379,http://0.0.0.0:4001"
|
||||
listen-peer-urls: "http://$private_ipv4:2380,http://$private_ipv4:7001"
|
||||
```
|
||||
|
||||
...will generate a systemd unit drop-in for etcd2.service with the following contents:
|
||||
@@ -132,8 +132,8 @@ The `coreos.fleet.*` parameters work very similarly to `coreos.etcd2.*`, and all
|
||||
|
||||
coreos:
|
||||
fleet:
|
||||
public-ip: $public_ipv4
|
||||
metadata: region=us-west
|
||||
public-ip: "$public_ipv4"
|
||||
metadata: "region=us-west"
|
||||
```
|
||||
|
||||
...will generate a systemd unit drop-in like this:
|
||||
@@ -144,6 +144,20 @@ Environment="FLEET_PUBLIC_IP=203.0.113.29"
|
||||
Environment="FLEET_METADATA=region=us-west"
|
||||
```
|
||||
|
||||
List of fleet configuration parameters:
|
||||
|
||||
- **agent_ttl**: An Agent will be considered dead if it exceeds this amount of time to communicate with the Registry
|
||||
- **engine_reconcile_interval**: Interval in seconds at which the engine should reconcile the cluster schedule in etcd
|
||||
- **etcd_cafile**: Path to CA file used for TLS communication with etcd
|
||||
- **etcd_certfile**: Provide TLS configuration when SSL certificate authentication is enabled in etcd endpoints
|
||||
- **etcd_keyfile**: Path to private key file used for TLS communication with etcd
|
||||
- **etcd_key_prefix**: etcd prefix path to be used for fleet keys
|
||||
- **etcd_request_timeout**: Amount of time in seconds to allow a single etcd request before considering it failed
|
||||
- **etcd_servers**: Comma separated list of etcd endpoints
|
||||
- **metadata**: Comma separated key/value pairs that are published with the local to the fleet registry
|
||||
- **public_ip**: IP accessible by other nodes for inter-host communication
|
||||
- **verbosity**: Enable debug logging by setting this to an integer value greater than zero
|
||||
|
||||
For more information on fleet configuration, see the [fleet documentation][fleet-config].
|
||||
|
||||
[fleet-config]: https://github.com/coreos/fleet/blob/master/Documentation/deployment-and-configuration.md#configuration
|
||||
@@ -159,7 +173,7 @@ flanneld. For example, the following cloud-config...
|
||||
|
||||
coreos:
|
||||
flannel:
|
||||
etcd_prefix: /coreos.com/network2
|
||||
etcd_prefix: "/coreos.com/network2"
|
||||
```
|
||||
|
||||
...will generate a systemd unit drop-in like so:
|
||||
@@ -181,6 +195,8 @@ List of flannel configuration parameters:
|
||||
- **interface**: Interface (name or IP) that should be used for inter-host communication
|
||||
- **public_ip**: IP accessible by other nodes for inter-host communication
|
||||
|
||||
For more information on flannel configuration, see the [flannel documentation][flannel-readme].
|
||||
|
||||
[flannel-readme]: https://github.com/coreos/flannel/blob/master/README.md
|
||||
|
||||
#### locksmith
|
||||
@@ -193,7 +209,7 @@ for locksmith. For example, the following cloud-config...
|
||||
|
||||
coreos:
|
||||
locksmith:
|
||||
endpoint: http://example.com:2379
|
||||
endpoint: "http://example.com:2379"
|
||||
```
|
||||
|
||||
...will generate a systemd unit drop-in like so:
|
||||
@@ -203,6 +219,13 @@ coreos:
|
||||
Environment="LOCKSMITHD_ENDPOINT=http://example.com:2379"
|
||||
```
|
||||
|
||||
List of locksmith configuration parameters:
|
||||
|
||||
- **endpoint**: Comma separated list of etcd endpoints
|
||||
- **etcd_cafile**: Path to CA file used for TLS communication with etcd
|
||||
- **etcd_certfile**: Path to certificate file used for TLS communication with etcd
|
||||
- **etcd_keyfile**: Path to private key file used for TLS communication with etcd
|
||||
|
||||
For the complete list of locksmith configuration parameters, see the [locksmith documentation][locksmith-readme].
|
||||
|
||||
[locksmith-readme]: https://github.com/coreos/locksmith/blob/master/README.md
|
||||
@@ -233,7 +256,7 @@ The `reboot-strategy` parameter also affects the behaviour of [locksmith](https:
|
||||
#cloud-config
|
||||
coreos:
|
||||
update:
|
||||
reboot-strategy: etcd-lock
|
||||
reboot-strategy: "etcd-lock"
|
||||
```
|
||||
|
||||
#### units
|
||||
@@ -264,8 +287,8 @@ Write a unit to disk, automatically starting it.
|
||||
|
||||
coreos:
|
||||
units:
|
||||
- name: docker-redis.service
|
||||
command: start
|
||||
- name: "docker-redis.service"
|
||||
command: "start"
|
||||
content: |
|
||||
[Unit]
|
||||
Description=Redis container
|
||||
@@ -285,9 +308,9 @@ Add the DOCKER_OPTS environment variable to docker.service.
|
||||
|
||||
coreos:
|
||||
units:
|
||||
- name: docker.service
|
||||
- name: "docker.service"
|
||||
drop-ins:
|
||||
- name: 50-insecure-registry.conf
|
||||
- name: "50-insecure-registry.conf"
|
||||
content: |
|
||||
[Service]
|
||||
Environment=DOCKER_OPTS='--insecure-registry="10.0.1.0/24"'
|
||||
@@ -300,10 +323,10 @@ Start the built-in `etcd2` and `fleet` services:
|
||||
|
||||
coreos:
|
||||
units:
|
||||
- name: etcd2.service
|
||||
command: start
|
||||
- name: fleet.service
|
||||
command: start
|
||||
- name: "etcd2.service"
|
||||
command: "start"
|
||||
- name: "fleet.service"
|
||||
command: "start"
|
||||
```
|
||||
|
||||
### ssh_authorized_keys
|
||||
@@ -317,7 +340,7 @@ Override this by using the `--ssh-key-name` flag when calling `coreos-cloudinit`
|
||||
#cloud-config
|
||||
|
||||
ssh_authorized_keys:
|
||||
- ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC0g+ZTxC7weoIJLUafOgrm+h...
|
||||
- "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC0g+ZTxC7weoIJLUafOgrm+h..."
|
||||
```
|
||||
|
||||
### hostname
|
||||
@@ -328,7 +351,7 @@ This is the local part of a fully-qualified domain name (i.e. `foo` in `foo.exam
|
||||
```yaml
|
||||
#cloud-config
|
||||
|
||||
hostname: coreos1
|
||||
hostname: "coreos1"
|
||||
```
|
||||
|
||||
### users
|
||||
@@ -364,13 +387,13 @@ The following fields are not yet implemented:
|
||||
#cloud-config
|
||||
|
||||
users:
|
||||
- name: elroy
|
||||
passwd: $6$5s2u6/jR$un0AvWnqilcgaNB3Mkxd5yYv6mTlWfOoCYHZmfi3LDKVltj.E8XNKEcwWm...
|
||||
- name: "elroy"
|
||||
passwd: "$6$5s2u6/jR$un0AvWnqilcgaNB3Mkxd5yYv6mTlWfOoCYHZmfi3LDKVltj.E8XNKEcwWm..."
|
||||
groups:
|
||||
- sudo
|
||||
- docker
|
||||
- "sudo"
|
||||
- "docker"
|
||||
ssh-authorized-keys:
|
||||
- ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC0g+ZTxC7weoIJLUafOgrm+h...
|
||||
- "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC0g+ZTxC7weoIJLUafOgrm+h..."
|
||||
```
|
||||
|
||||
#### Generating a password hash
|
||||
@@ -411,32 +434,32 @@ Each item in the list may have the following keys:
|
||||
```yaml
|
||||
#cloud-config
|
||||
write_files:
|
||||
- path: /etc/resolv.conf
|
||||
permissions: 0644
|
||||
owner: root
|
||||
- path: "/etc/resolv.conf"
|
||||
permissions: "0644"
|
||||
owner: "root"
|
||||
content: |
|
||||
nameserver 8.8.8.8
|
||||
- path: /etc/motd
|
||||
permissions: 0644
|
||||
owner: root
|
||||
- path: "/etc/motd"
|
||||
permissions: "0644"
|
||||
owner: "root"
|
||||
content: |
|
||||
Good news, everyone!
|
||||
- path: /tmp/like_this
|
||||
permissions: 0644
|
||||
owner: root
|
||||
encoding: gzip
|
||||
- path: "/tmp/like_this"
|
||||
permissions: "0644"
|
||||
owner: "root"
|
||||
encoding: "gzip"
|
||||
content: !!binary |
|
||||
H4sIAKgdh1QAAwtITM5WyK1USMqvUCjPLMlQSMssS1VIya9KzVPIySwszS9SyCpNLwYARQFQ5CcAAAA=
|
||||
- path: /tmp/or_like_this
|
||||
permissions: 0644
|
||||
owner: root
|
||||
encoding: gzip+base64
|
||||
- path: "/tmp/or_like_this"
|
||||
permissions: "0644"
|
||||
owner: "root"
|
||||
encoding: "gzip+base64"
|
||||
content: |
|
||||
H4sIAKgdh1QAAwtITM5WyK1USMqvUCjPLMlQSMssS1VIya9KzVPIySwszS9SyCpNLwYARQFQ5CcAAAA=
|
||||
- path: /tmp/todolist
|
||||
permissions: 0644
|
||||
owner: root
|
||||
encoding: base64
|
||||
- path: "/tmp/todolist"
|
||||
permissions: "0644"
|
||||
owner: "root"
|
||||
encoding: "base64"
|
||||
content: |
|
||||
UGFjayBteSBib3ggd2l0aCBmaXZlIGRvemVuIGxpcXVvciBqdWdz
|
||||
```
|
||||
@@ -451,5 +474,5 @@ infrastructure in place to resolve its own hostname, for example, when using Vag
|
||||
```yaml
|
||||
#cloud-config
|
||||
|
||||
manage_etc_hosts: localhost
|
||||
manage_etc_hosts: "localhost"
|
||||
```
|
||||
|
@@ -1,18 +1,16 @@
|
||||
/*
|
||||
Copyright 2014 CoreOS, Inc.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
// Copyright 2015 CoreOS, Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package config
|
||||
|
||||
|
@@ -15,8 +15,11 @@
|
||||
package config
|
||||
|
||||
type Locksmith struct {
|
||||
Endpoint string `yaml:"endpoint" env:"LOCKSMITHD_ENDPOINT"`
|
||||
EtcdCAFile string `yaml:"etcd_cafile" env:"LOCKSMITHD_ETCD_CAFILE"`
|
||||
EtcdCertFile string `yaml:"etcd_certfile" env:"LOCKSMITHD_ETCD_CERTFILE"`
|
||||
EtcdKeyFile string `yaml:"etcd_keyfile" env:"LOCKSMITHD_ETCD_KEYFILE"`
|
||||
Endpoint string `yaml:"endpoint" env:"LOCKSMITHD_ENDPOINT"`
|
||||
EtcdCAFile string `yaml:"etcd_cafile" env:"LOCKSMITHD_ETCD_CAFILE"`
|
||||
EtcdCertFile string `yaml:"etcd_certfile" env:"LOCKSMITHD_ETCD_CERTFILE"`
|
||||
EtcdKeyFile string `yaml:"etcd_keyfile" env:"LOCKSMITHD_ETCD_KEYFILE"`
|
||||
Group string `yaml:"group" env:"LOCKSMITHD_GROUP"`
|
||||
RebootWindowStart string `yaml:"window_start" env:"REBOOT_WINDOW_START" valid:"^((?i:sun|mon|tue|wed|thu|fri|sat|sun) )?0*([0-9]|1[0-9]|2[0-3]):0*([0-9]|[1-5][0-9])$"`
|
||||
RebootWindowLength string `yaml:"window_length" env:"REBOOT_WINDOW_LENGTH" valid:"^[-+]?([0-9]*(\\.[0-9]*)?[a-z]+)+$"`
|
||||
}
|
||||
|
76
config/locksmith_test.go
Normal file
76
config/locksmith_test.go
Normal file
@@ -0,0 +1,76 @@
|
||||
// Copyright 2015 CoreOS, Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package config
|
||||
|
||||
import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestRebootWindowStart(t *testing.T) {
|
||||
tests := []struct {
|
||||
value string
|
||||
|
||||
isValid bool
|
||||
}{
|
||||
{value: "Sun 0:0", isValid: true},
|
||||
{value: "Sun 00:00", isValid: true},
|
||||
{value: "sUn 23:59", isValid: true},
|
||||
{value: "mon 0:0", isValid: true},
|
||||
{value: "tue 0:0", isValid: true},
|
||||
{value: "tues 0:0", isValid: false},
|
||||
{value: "wed 0:0", isValid: true},
|
||||
{value: "thu 0:0", isValid: true},
|
||||
{value: "thur 0:0", isValid: false},
|
||||
{value: "fri 0:0", isValid: true},
|
||||
{value: "sat 0:0", isValid: true},
|
||||
{value: "sat00:00", isValid: false},
|
||||
{value: "00:00", isValid: true},
|
||||
{value: "10:10", isValid: true},
|
||||
{value: "20:20", isValid: true},
|
||||
{value: "20:30", isValid: true},
|
||||
{value: "20:40", isValid: true},
|
||||
{value: "20:50", isValid: true},
|
||||
{value: "20:60", isValid: false},
|
||||
{value: "24:00", isValid: false},
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
isValid := (nil == AssertStructValid(Locksmith{RebootWindowStart: tt.value}))
|
||||
if tt.isValid != isValid {
|
||||
t.Errorf("bad assert (%s): want %t, got %t", tt.value, tt.isValid, isValid)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestRebootWindowLength(t *testing.T) {
|
||||
tests := []struct {
|
||||
value string
|
||||
|
||||
isValid bool
|
||||
}{
|
||||
{value: "1h", isValid: true},
|
||||
{value: "1d", isValid: true},
|
||||
{value: "0d", isValid: true},
|
||||
{value: "0.5h", isValid: true},
|
||||
{value: "0.5.0h", isValid: false},
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
isValid := (nil == AssertStructValid(Locksmith{RebootWindowLength: tt.value}))
|
||||
if tt.isValid != isValid {
|
||||
t.Errorf("bad assert (%s): want %t, got %t", tt.value, tt.isValid, isValid)
|
||||
}
|
||||
}
|
||||
}
|
@@ -118,7 +118,6 @@ var (
|
||||
},
|
||||
"packet": oemConfig{
|
||||
"from-packet-metadata": "https://metadata.packet.net/",
|
||||
"convert-netconf": "packet",
|
||||
},
|
||||
"vmware": oemConfig{
|
||||
"from-vmware-backdoor": "true",
|
||||
|
@@ -52,6 +52,14 @@ func TestParseNameservers(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func mkInvalidMAC() error {
|
||||
if isGo15 {
|
||||
return &net.AddrError{Err: "invalid MAC address", Addr: "bad"}
|
||||
} else {
|
||||
return errors.New("invalid MAC address: bad")
|
||||
}
|
||||
}
|
||||
|
||||
func TestParseInterface(t *testing.T) {
|
||||
for _, tt := range []struct {
|
||||
cfg digitalocean.Interface
|
||||
@@ -64,7 +72,7 @@ func TestParseInterface(t *testing.T) {
|
||||
cfg: digitalocean.Interface{
|
||||
MAC: "bad",
|
||||
},
|
||||
err: errors.New("invalid MAC address: bad"),
|
||||
err: mkInvalidMAC(),
|
||||
},
|
||||
{
|
||||
cfg: digitalocean.Interface{
|
||||
@@ -337,13 +345,13 @@ func TestParseInterfaces(t *testing.T) {
|
||||
cfg: digitalocean.Interfaces{
|
||||
Public: []digitalocean.Interface{{MAC: "bad"}},
|
||||
},
|
||||
err: errors.New("invalid MAC address: bad"),
|
||||
err: mkInvalidMAC(),
|
||||
},
|
||||
{
|
||||
cfg: digitalocean.Interfaces{
|
||||
Private: []digitalocean.Interface{{MAC: "bad"}},
|
||||
},
|
||||
err: errors.New("invalid MAC address: bad"),
|
||||
err: mkInvalidMAC(),
|
||||
},
|
||||
} {
|
||||
ifaces, err := parseInterfaces(tt.cfg, tt.nss)
|
||||
|
5
network/is_go15_false_test.go
Normal file
5
network/is_go15_false_test.go
Normal file
@@ -0,0 +1,5 @@
|
||||
// +build !go1.5
|
||||
|
||||
package network
|
||||
|
||||
const isGo15 = false
|
5
network/is_go15_true_test.go
Normal file
5
network/is_go15_true_test.go
Normal file
@@ -0,0 +1,5 @@
|
||||
// +build go1.5
|
||||
|
||||
package network
|
||||
|
||||
const isGo15 = true
|
Reference in New Issue
Block a user