Merge branch 'upstream'
This commit is contained in:
commit
f33a90587f
@ -81,7 +81,7 @@ For more information about the available configuration parameters, see the [etcd
|
||||
|
||||
_Note: The `$private_ipv4` and `$public_ipv4` substitution variables referenced in other documents are only supported on Amazon EC2, Google Compute Engine, OpenStack, Rackspace, DigitalOcean, and Vagrant._
|
||||
|
||||
[etcd-config]: https://github.com/coreos/etcd/blob/9fa3bea5a22265151f0d5063ce38a79c5b5d0271/Documentation/configuration.md
|
||||
[etcd-config]: https://github.com/coreos/etcd/blob/release-0.4/Documentation/configuration.md
|
||||
|
||||
#### etcd2
|
||||
|
||||
@ -117,11 +117,11 @@ Environment="ETCD_LISTEN_CLIENT_URLS=http://0.0.0.0:2379,http://0.0.0.0:4001"
|
||||
Environment="ETCD_LISTEN_PEER_URLS=http://192.0.2.13:2380,http://192.0.2.13:7001"
|
||||
```
|
||||
|
||||
For more information about the available configuration parameters, see the [etcd documentation][etcd-config].
|
||||
For more information about the available configuration parameters, see the [etcd2 documentation][etcd2-config].
|
||||
|
||||
_Note: The `$private_ipv4` and `$public_ipv4` substitution variables referenced in other documents are only supported on Amazon EC2, Google Compute Engine, OpenStack, Rackspace, DigitalOcean, and Vagrant._
|
||||
|
||||
[etcd-config]: https://github.com/coreos/etcd/blob/86e616c6e974828fc9119c1eb0f6439577a9ce0b/Documentation/configuration.md
|
||||
[etcd2-config]: https://github.com/coreos/etcd/blob/master/Documentation/configuration.md
|
||||
|
||||
#### fleet
|
||||
|
||||
|
@ -3,7 +3,7 @@
|
||||
## Cloud-Config VMWare Guestinfo Variables
|
||||
|
||||
coreos-cloudinit accepts configuration from the VMware RPC API's *guestinfo*
|
||||
facility. This datasource can be enabled with the `-from-vmware-guestinfo`
|
||||
facility. This datasource can be enabled with the `--from-vmware-guestinfo`
|
||||
flag to coreos-cloudinit.
|
||||
|
||||
The following guestinfo variables are recognized and processed by cloudinit
|
||||
|
@ -15,8 +15,11 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"compress/gzip"
|
||||
"flag"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"os"
|
||||
"runtime"
|
||||
@ -185,7 +188,7 @@ func main() {
|
||||
|
||||
dss := getDatasources()
|
||||
if len(dss) == 0 {
|
||||
fmt.Println("Provide at least one of -from-file, -from-configdrive, -from-ec2-metadata, -from-cloudsigma-metadata, -from-packet-metadata, -from-digitalocean-metadata, -from-vmware-guestinfo, -from-waagent, -from-url or -from-proc-cmdline")
|
||||
fmt.Println("Provide at least one of --from-file, --from-configdrive, --from-ec2-metadata, --from-cloudsigma-metadata, --from-packet-metadata, --from-digitalocean-metadata, --from-vmware-guestinfo, --from-waagent, --from-url or --from-proc-cmdline")
|
||||
os.Exit(2)
|
||||
}
|
||||
|
||||
@ -201,6 +204,11 @@ func main() {
|
||||
log.Printf("Failed fetching user-data from datasource: %v. Continuing...\n", err)
|
||||
failure = true
|
||||
}
|
||||
userdataBytes, err = decompressIfGzip(userdataBytes)
|
||||
if err != nil {
|
||||
log.Printf("Failed decompressing user-data from datasource: %v. Continuing...\n", err)
|
||||
failure = true
|
||||
}
|
||||
|
||||
if report, err := validate.Validate(userdataBytes); err == nil {
|
||||
ret := 0
|
||||
@ -415,3 +423,17 @@ func runScript(script config.Script, env *initialize.Environment) error {
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
const gzipMagicBytes = "\x1f\x8b"
|
||||
|
||||
func decompressIfGzip(userdataBytes []byte) ([]byte, error) {
|
||||
if !bytes.HasPrefix(userdataBytes, []byte(gzipMagicBytes)) {
|
||||
return userdataBytes, nil
|
||||
}
|
||||
gzr, err := gzip.NewReader(bytes.NewReader(userdataBytes))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer gzr.Close()
|
||||
return ioutil.ReadAll(gzr)
|
||||
}
|
||||
|
@ -15,6 +15,9 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/base64"
|
||||
"errors"
|
||||
"reflect"
|
||||
"testing"
|
||||
|
||||
@ -87,3 +90,58 @@ func TestMergeConfigs(t *testing.T) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func mustDecode(in string) []byte {
|
||||
out, err := base64.StdEncoding.DecodeString(in)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
func TestDecompressIfGzip(t *testing.T) {
|
||||
tests := []struct {
|
||||
in []byte
|
||||
|
||||
out []byte
|
||||
err error
|
||||
}{
|
||||
{
|
||||
in: nil,
|
||||
|
||||
out: nil,
|
||||
err: nil,
|
||||
},
|
||||
{
|
||||
in: []byte{},
|
||||
|
||||
out: []byte{},
|
||||
err: nil,
|
||||
},
|
||||
{
|
||||
in: mustDecode("H4sIAJWV/VUAA1NOzskvTdFNzs9Ly0wHABt6mQENAAAA"),
|
||||
|
||||
out: []byte("#cloud-config"),
|
||||
err: nil,
|
||||
},
|
||||
{
|
||||
in: []byte("#cloud-config"),
|
||||
|
||||
out: []byte("#cloud-config"),
|
||||
err: nil,
|
||||
},
|
||||
{
|
||||
in: mustDecode("H4sCORRUPT=="),
|
||||
|
||||
out: nil,
|
||||
err: errors.New("any error"),
|
||||
},
|
||||
}
|
||||
for i, tt := range tests {
|
||||
out, err := decompressIfGzip(tt.in)
|
||||
if !bytes.Equal(out, tt.out) || (tt.err != nil && err == nil) {
|
||||
t.Errorf("bad gzip (%d): want (%s, %#v), got (%s, %#v)", i, string(tt.out), tt.err, string(out), err)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user