├── .gitignore ├── LICENSE ├── README.md ├── kube-apiproxy.service.sample ├── src └── github.com │ └── vaijab │ └── kube-apiproxy │ ├── fleet.go │ ├── main.go │ ├── proxy.go │ └── version.go └── vendor ├── manifest └── src └── github.com └── coreos └── fleet ├── CONTRIBUTING.md ├── DCO ├── Documentation ├── api-v1.md ├── architecture.md ├── deployment-and-configuration.md ├── examples │ ├── api.py │ ├── example-deployment.md │ ├── img │ │ └── subgun.png │ └── service-discovery.md ├── rkt_guide.md ├── states.md ├── unit-files-and-scheduling.md └── using-the-client.md ├── Godeps ├── Godeps.json ├── Readme └── _workspace │ └── src │ ├── code.google.com │ └── p │ │ └── go-uuid │ │ └── uuid │ │ ├── LICENSE │ │ ├── dce.go │ │ ├── doc.go │ │ ├── hash.go │ │ ├── json.go │ │ ├── json_test.go │ │ ├── node.go │ │ ├── seq_test.go │ │ ├── time.go │ │ ├── util.go │ │ ├── uuid.go │ │ ├── uuid_test.go │ │ ├── version1.go │ │ └── version4.go │ ├── github.com │ ├── coreos │ │ ├── go-semver │ │ │ └── semver │ │ │ │ ├── semver.go │ │ │ │ ├── semver_test.go │ │ │ │ └── sort.go │ │ └── go-systemd │ │ │ ├── activation │ │ │ ├── files.go │ │ │ ├── files_test.go │ │ │ ├── listeners.go │ │ │ ├── listeners_test.go │ │ │ ├── packetconns.go │ │ │ └── packetconns_test.go │ │ │ ├── dbus │ │ │ ├── dbus.go │ │ │ ├── dbus_test.go │ │ │ ├── methods.go │ │ │ ├── methods_test.go │ │ │ ├── properties.go │ │ │ ├── set.go │ │ │ ├── set_test.go │ │ │ ├── subscription.go │ │ │ ├── subscription_set.go │ │ │ ├── subscription_set_test.go │ │ │ └── subscription_test.go │ │ │ └── unit │ │ │ ├── deserialize.go │ │ │ ├── deserialize_test.go │ │ │ ├── option.go │ │ │ ├── option_test.go │ │ │ ├── serialize.go │ │ │ └── serialize_test.go │ ├── docker │ │ └── libcontainer │ │ │ └── netlink │ │ │ ├── MAINTAINERS │ │ │ ├── netlink.go │ │ │ ├── netlink_linux.go │ │ │ └── netlink_unsupported.go │ ├── godbus │ │ └── dbus │ │ │ ├── LICENSE │ │ │ ├── README.markdown │ │ │ ├── auth.go │ │ │ ├── auth_external.go │ │ │ ├── auth_sha1.go │ │ │ ├── call.go │ │ │ ├── conn.go │ │ │ ├── conn_darwin.go │ │ │ ├── conn_other.go │ │ │ ├── conn_test.go │ │ │ ├── dbus.go │ │ │ ├── decoder.go │ │ │ ├── doc.go │ │ │ ├── encoder.go │ │ │ ├── examples_test.go │ │ │ ├── export.go │ │ │ ├── homedir.go │ │ │ ├── homedir_dynamic.go │ │ │ ├── homedir_static.go │ │ │ ├── introspect │ │ │ ├── call.go │ │ │ ├── introspect.go │ │ │ └── introspectable.go │ │ │ ├── message.go │ │ │ ├── prop │ │ │ └── prop.go │ │ │ ├── proto_test.go │ │ │ ├── sig.go │ │ │ ├── sig_test.go │ │ │ ├── transport_darwin.go │ │ │ ├── transport_generic.go │ │ │ ├── transport_unix.go │ │ │ ├── transport_unix_test.go │ │ │ ├── transport_unixcred_dragonfly.go │ │ │ ├── transport_unixcred_linux.go │ │ │ ├── variant.go │ │ │ ├── variant_lexer.go │ │ │ ├── variant_parser.go │ │ │ └── variant_test.go │ ├── jonboulle │ │ └── clockwork │ │ │ ├── LICENSE │ │ │ ├── README.md │ │ │ ├── clockwork.go │ │ │ ├── clockwork_test.go │ │ │ └── example_test.go │ └── rakyll │ │ ├── globalconf │ │ ├── README.md │ │ ├── globalconf.go │ │ ├── globalconf_test.go │ │ └── testdata │ │ │ ├── custom.ini │ │ │ ├── global.ini │ │ │ └── globalandcustom.ini │ │ └── goini │ │ ├── Makefile │ │ ├── empty.ini │ │ ├── example.ini │ │ ├── ini.go │ │ └── ini_test.go │ ├── golang.org │ └── x │ │ └── crypto │ │ └── ssh │ │ ├── agent │ │ ├── client.go │ │ ├── client_test.go │ │ ├── forward.go │ │ ├── keyring.go │ │ ├── server.go │ │ ├── server_test.go │ │ └── testdata_test.go │ │ ├── benchmark_test.go │ │ ├── buffer.go │ │ ├── buffer_test.go │ │ ├── certs.go │ │ ├── certs_test.go │ │ ├── channel.go │ │ ├── cipher.go │ │ ├── cipher_test.go │ │ ├── client.go │ │ ├── client_auth.go │ │ ├── client_auth_test.go │ │ ├── client_test.go │ │ ├── common.go │ │ ├── connection.go │ │ ├── doc.go │ │ ├── example_test.go │ │ ├── handshake.go │ │ ├── handshake_test.go │ │ ├── kex.go │ │ ├── kex_test.go │ │ ├── keys.go │ │ ├── keys_test.go │ │ ├── mac.go │ │ ├── mempipe_test.go │ │ ├── messages.go │ │ ├── messages_test.go │ │ ├── mux.go │ │ ├── mux_test.go │ │ ├── server.go │ │ ├── session.go │ │ ├── session_test.go │ │ ├── tcpip.go │ │ ├── tcpip_test.go │ │ ├── terminal │ │ ├── terminal.go │ │ ├── terminal_test.go │ │ ├── util.go │ │ ├── util_bsd.go │ │ ├── util_linux.go │ │ └── util_windows.go │ │ ├── test │ │ ├── agent_unix_test.go │ │ ├── cert_test.go │ │ ├── doc.go │ │ ├── forward_unix_test.go │ │ ├── session_test.go │ │ ├── tcpip_test.go │ │ ├── test_unix_test.go │ │ └── testdata_test.go │ │ ├── testdata │ │ ├── doc.go │ │ └── keys.go │ │ ├── testdata_test.go │ │ ├── transport.go │ │ └── transport_test.go │ └── google.golang.org │ └── api │ ├── google-api-go-generator │ ├── gen.go │ ├── gen_test.go │ └── testdata │ │ ├── arrayofarray-1.json │ │ ├── arrayofarray-1.want │ │ ├── arrayofmapofobjects.json │ │ ├── arrayofmapofobjects.want │ │ ├── arrayofmapofstrings.json │ │ ├── arrayofmapofstrings.want │ │ ├── blogger-3.json │ │ ├── blogger-3.want │ │ ├── getwithoutbody.json │ │ ├── getwithoutbody.want │ │ ├── mapofany.json │ │ ├── mapofany.want │ │ ├── mapofarrayofobjects.json │ │ ├── mapofarrayofobjects.want │ │ ├── mapofobjects.json │ │ ├── mapofobjects.want │ │ ├── mapofstrings-1.json │ │ ├── mapofstrings-1.want │ │ ├── quotednum.json │ │ ├── quotednum.want │ │ ├── resource-named-service.json │ │ ├── resource-named-service.want │ │ ├── variants.json │ │ └── variants.want │ └── googleapi │ ├── googleapi.go │ ├── googleapi_test.go │ ├── internal │ └── uritemplates │ │ ├── LICENSE │ │ ├── uritemplates.go │ │ └── utils.go │ ├── transport │ └── apikey.go │ ├── types.go │ └── types_test.go ├── LICENSE ├── MAINTAINERS ├── NOTICE ├── README.md ├── agent ├── agent.go ├── agent_test.go ├── cache.go ├── reconcile.go ├── reconcile_test.go ├── state.go ├── state_test.go ├── task.go ├── task_test.go ├── unit_state.go └── unit_state_test.go ├── api ├── deserialization_test.go ├── discovery.go ├── discovery_test.go ├── machines.go ├── machines_test.go ├── mux.go ├── mux_test.go ├── pagination.go ├── pagination_test.go ├── path.go ├── path_test.go ├── serialization.go ├── serialization_test.go ├── server.go ├── state.go ├── state_test.go ├── units.go └── units_test.go ├── build ├── build-aci ├── build-docker ├── client ├── api.go ├── http.go └── registry.go ├── config ├── config.go └── config_test.go ├── cover ├── engine ├── engine.go ├── engine_test.go ├── reconciler.go ├── reconciler_test.go ├── scheduler.go ├── scheduler_test.go ├── state.go └── state_test.go ├── etcd ├── action.go ├── action_test.go ├── client.go ├── client_test.go ├── error.go ├── error_test.go ├── lease.go ├── lease_test.go ├── result.go └── result_test.go ├── examples ├── hello.service ├── ping.service └── pong.service ├── fixtures ├── authorized_keys ├── bad_known_hosts ├── insecure_private_key └── known_hosts ├── fleet.conf.sample ├── fleetctl ├── cat.go ├── destroy.go ├── fdforward.go ├── fleetctl.go ├── fleetctl_test.go ├── help.go ├── journal.go ├── list_machines.go ├── list_machines_test.go ├── list_unit_files.go ├── list_unit_files_test.go ├── list_units.go ├── list_units_test.go ├── load.go ├── ssh.go ├── ssh_test.go ├── start.go ├── start_test.go ├── status.go ├── stop.go ├── submit.go ├── unload.go ├── verify.go └── version.go ├── fleetd └── fleet.go ├── functional ├── README.md ├── clean.sh ├── client_test.go ├── cluster_test.go ├── fixtures │ ├── id_rsa │ ├── id_rsa.pub │ └── units │ │ ├── conflict.0.service │ │ ├── conflict.1.service │ │ ├── conflict.2.service │ │ ├── conflict.3.service │ │ ├── conflict.4.service │ │ ├── conflicts-with-hello.service │ │ ├── global.service │ │ ├── goodbye.service │ │ ├── hello.service │ │ ├── pin@.service │ │ ├── ping.0.service │ │ ├── ping.1.service │ │ ├── ping.2.service │ │ ├── pong.0.service │ │ ├── pong.1.service │ │ └── pong.2.service ├── fleetctl_test.go ├── node_test.go ├── platform │ ├── cluster.go │ └── nspawn.go ├── scheduling_test.go ├── systemd_test.go ├── unit_action_test.go └── util │ ├── config.go │ └── util.go ├── heart ├── heart.go └── monitor.go ├── job ├── job.go └── job_test.go ├── log └── log.go ├── machine ├── coreos.go ├── coreos_test.go ├── fake.go ├── fake_test.go ├── machine.go ├── machine_test.go ├── state.go └── state_test.go ├── registry ├── event.go ├── event_test.go ├── fake.go ├── fake_test.go ├── interface.go ├── job.go ├── job_state.go ├── machine.go ├── registry.go ├── unit.go ├── unit_state.go ├── unit_state_test.go └── version.go ├── resource ├── resource.go └── resource_test.go ├── schema ├── mapper.go ├── v1-gen.go ├── v1-json.go └── v1.json ├── scripts ├── build-release ├── bump-release ├── fleetctl-inject-ssh.sh ├── schema-generator └── schema_generator_import.go ├── server └── server.go ├── ssh ├── LICENSE ├── known_hosts.go ├── known_hosts_test.go ├── match.go ├── match_test.go ├── proxy.go └── ssh.go ├── systemd ├── manager.go └── manager_test.go ├── test ├── test-docker ├── unit ├── fake.go ├── fake_test.go ├── generator.go ├── generator_test.go ├── manager.go ├── unit.go └── unit_test.go └── version └── version.go /.gitignore: -------------------------------------------------------------------------------- 1 | bin/ 2 | pkg/ 3 | 4 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # kube-apiproxy 2 | 3 | If you ever had to set up a Kubernetes cluster you know that it is a fairly 4 | simple task, apart from one thing - if API server goes away, you have to bring 5 | it back and tell other components where it is. Some people use an ELB with a 6 | persistent DNS entry which they update if kubernetes API service is moved 7 | somewhere else, others use config management tools to update configuration and 8 | restart Kubernetes components, etc. 9 | 10 | A lot of people deploy Kubernetes on CoreOS using fleet which is a really great 11 | way. 12 | 13 | This proxy service talks to fleet daemon to find which node runs Kubernetes API 14 | and proxies traffic through to the API server. When that node goes down, fleet 15 | will then start the API service on another node which is automatically 16 | discovered by `kube-apiproxy`. 17 | 18 | This means that Kubernetes API is always accessible on `localhost:8081` by default. 19 | 20 | ## Building 21 | 22 | You will need `gb` tool - http://getgb.io/. 23 | 24 | ``` 25 | git clone https://github.com/vaijab/kube-apiproxy.git 26 | cd kube-apiproxy 27 | gb build all 28 | ``` 29 | 30 | ## Configuration 31 | 32 | Configuration is done via command line arguments. 33 | 34 | ```bash 35 | $ kube-apiproxy --help 36 | Usage of bin/kube-apiproxy: 37 | -api-port="8080": kubernetes api port 38 | -fleet-endpoint="unix:///run/fleet.sock": fleet endpoint 39 | -proxy-listen="localhost:8081": proxy listen ip:port 40 | -unit-name="kube-apiserver.service": fleet unit name for kubernetes api server 41 | ``` 42 | 43 | ## Contribution 44 | 45 | Please feel free to send PRs and issues my way. I am very new to Go 46 | programming, I am sure that the code can be improved a lot by keeping the core 47 | principle the same. 48 | 49 | -------------------------------------------------------------------------------- /kube-apiproxy.service.sample: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=Kubernetes API Server Proxy 3 | Documentation=https://github.com/vaijab/kube-apiproxy 4 | 5 | [Service] 6 | ExecStart=/opt/bin/kube-apiproxy \ 7 | --api-port=8080 \ 8 | --unit-name=kube-apiserver.service 9 | Restart=always 10 | RestartSec=10 11 | 12 | [X-Fleet] 13 | Global=true 14 | MachineMetadata=role=kubernetes 15 | -------------------------------------------------------------------------------- /src/github.com/vaijab/kube-apiproxy/fleet.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "github.com/coreos/fleet/client" 6 | "net" 7 | "net/http" 8 | "net/url" 9 | ) 10 | 11 | func getUnitMachineIP(c client.API, u string) (string, error) { 12 | id, err := getUnitMachineID(c, u) 13 | if err != nil { 14 | return "", err 15 | } 16 | unitMachineIP, err := getMachineIP(c, id) 17 | if err != nil { 18 | return "", err 19 | } 20 | return unitMachineIP, nil 21 | } 22 | 23 | func getUnitMachineID(c client.API, u string) (string, error) { 24 | unit, err := c.Unit(u) 25 | if err != nil { 26 | return "", err 27 | } 28 | if unit == nil || unit.CurrentState != "launched" { 29 | return "", fmt.Errorf("cannot get unit's machine id.") 30 | } 31 | return unit.MachineID, nil 32 | } 33 | 34 | // getMachineIP function takes a machine ID and returns its IP address 35 | func getMachineIP(c client.API, id string) (string, error) { 36 | machines, err := c.Machines() 37 | if err != nil { 38 | return "", err 39 | } 40 | for _, m := range machines { 41 | if m.ID == id { 42 | return m.PublicIP, nil 43 | } 44 | } 45 | return "", fmt.Errorf("%s", "machine id not found.") 46 | } 47 | 48 | func getClient(endpoint string) (client.API, error) { 49 | ep, err := url.Parse(endpoint) 50 | if err != nil { 51 | return nil, err 52 | } 53 | dialFunc := net.Dial 54 | if ep.Scheme == "unix" { 55 | ep.Scheme = "http" 56 | ep.Host = "domain-sock" 57 | sockPath := ep.Path 58 | ep.Path = "" 59 | dialFunc = func(network, addr string) (net.Conn, error) { 60 | // return net.Dial("unix", ep.Path) 61 | return net.Dial("unix", sockPath) 62 | } 63 | 64 | } 65 | c := &http.Client{ 66 | Transport: &http.Transport{ 67 | Dial: dialFunc, 68 | DisableKeepAlives: true, 69 | }, 70 | } 71 | return client.NewHTTPClient(c, *ep) 72 | } 73 | -------------------------------------------------------------------------------- /src/github.com/vaijab/kube-apiproxy/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "flag" 5 | "fmt" 6 | "log" 7 | "net" 8 | "os" 9 | "time" 10 | ) 11 | 12 | var ( 13 | fleetEndpoint string 14 | unitName string 15 | proxyListen string 16 | apiPort string 17 | printVersion bool 18 | ) 19 | 20 | func init() { 21 | flag.StringVar(&fleetEndpoint, "fleet-endpoint", "unix:///run/fleet.sock", "fleet endpoint") 22 | flag.StringVar(&unitName, "unit-name", "kube-apiserver.service", "fleet unit name for kubernetes api server") 23 | flag.StringVar(&proxyListen, "proxy-listen", "localhost:8081", "proxy listen ip:port") 24 | flag.StringVar(&apiPort, "api-port", "8080", "kubernetes api port") 25 | flag.BoolVar(&printVersion, "version", false, "print version and exit") 26 | } 27 | 28 | func main() { 29 | flag.Parse() 30 | if printVersion { 31 | fmt.Printf("kube-apiproxy %s\n", Version) 32 | os.Exit(0) 33 | } 34 | 35 | ipChan := make(chan string) 36 | fleetClient, err := getClient(fleetEndpoint) 37 | if err != nil { 38 | log.Fatalln(err) 39 | } 40 | go func() { 41 | for { 42 | ip, err := getUnitMachineIP(fleetClient, unitName) 43 | if err != nil { 44 | log.Println(err) 45 | } else { 46 | ipChan <- ip 47 | } 48 | time.Sleep(time.Second * 3) 49 | } 50 | }() 51 | 52 | l, err := net.ResolveTCPAddr("tcp", proxyListen) 53 | listen, err := net.ListenTCP("tcp", l) 54 | if err != nil { 55 | log.Fatalln(err) 56 | } 57 | if listen == nil { 58 | fmt.Errorf("cannot bind to local socket.") 59 | } 60 | 61 | unitIP := "" 62 | go func() { 63 | prevIP := "" 64 | for { 65 | select { 66 | case ip := <-ipChan: 67 | if prevIP == ip { 68 | continue 69 | } else { 70 | prevIP = ip 71 | unitIP = ip 72 | } 73 | } 74 | } 75 | }() 76 | // TODO(vaijab) Would be great to handle OS signals 77 | for { 78 | // TODO(vaijab) it would probably better to use some locking here? 79 | if unitIP == "" { 80 | time.Sleep(time.Second * 1) 81 | continue 82 | } 83 | conn, err := listen.AcceptTCP() 84 | if err != nil { 85 | log.Fatalln(err) 86 | } 87 | go proxy(conn, unitIP+":"+apiPort) 88 | } 89 | } 90 | -------------------------------------------------------------------------------- /src/github.com/vaijab/kube-apiproxy/proxy.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "io" 5 | "log" 6 | "net" 7 | "sync" 8 | ) 9 | 10 | func proxy(lconn *net.TCPConn, remoteAddr string) { 11 | var wg sync.WaitGroup 12 | wg.Add(2) 13 | r, err := net.ResolveTCPAddr("tcp", remoteAddr) 14 | rconn, err := net.DialTCP("tcp", nil, r) 15 | if err != nil { 16 | log.Println(err) 17 | return 18 | } 19 | if rconn == nil { 20 | log.Println("failed to connect to remote socket.") 21 | } 22 | go copyBytes(lconn, rconn, &wg) 23 | go copyBytes(rconn, lconn, &wg) 24 | wg.Wait() 25 | lconn.Close() 26 | rconn.Close() 27 | } 28 | 29 | func copyBytes(dest, src *net.TCPConn, wg *sync.WaitGroup) { 30 | defer wg.Done() 31 | _, err := io.Copy(dest, src) 32 | if err != nil { 33 | log.Printf("I/O error: %v\n", err) 34 | } 35 | dest.CloseWrite() 36 | src.CloseRead() 37 | } 38 | -------------------------------------------------------------------------------- /src/github.com/vaijab/kube-apiproxy/version.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | const Version = "0.0.1" 4 | -------------------------------------------------------------------------------- /vendor/manifest: -------------------------------------------------------------------------------- 1 | { 2 | "version": 0, 3 | "dependencies": [ 4 | { 5 | "importpath": "github.com/coreos/fleet", 6 | "repository": "https://github.com/coreos/fleet", 7 | "revision": "f1d86c7bd0ec00162682024336d898d5838cc9a4", 8 | "branch": "master", 9 | "path": "" 10 | } 11 | ] 12 | } -------------------------------------------------------------------------------- /vendor/src/github.com/coreos/fleet/DCO: -------------------------------------------------------------------------------- 1 | Developer Certificate of Origin 2 | Version 1.1 3 | 4 | Copyright (C) 2004, 2006 The Linux Foundation and its contributors. 5 | 660 York Street, Suite 102, 6 | San Francisco, CA 94110 USA 7 | 8 | Everyone is permitted to copy and distribute verbatim copies of this 9 | license document, but changing it is not allowed. 10 | 11 | 12 | Developer's Certificate of Origin 1.1 13 | 14 | By making a contribution to this project, I certify that: 15 | 16 | (a) The contribution was created in whole or in part by me and I 17 | have the right to submit it under the open source license 18 | indicated in the file; or 19 | 20 | (b) The contribution is based upon previous work that, to the best 21 | of my knowledge, is covered under an appropriate open source 22 | license and I have the right under that license to submit that 23 | work with modifications, whether created in whole or in part 24 | by me, under the same open source license (unless I am 25 | permitted to submit under a different license), as indicated 26 | in the file; or 27 | 28 | (c) The contribution was provided directly to me by some other 29 | person who certified (a), (b) or (c) and I have not modified 30 | it. 31 | 32 | (d) I understand and agree that this project and the contribution 33 | are public and that a record of the contribution (including all 34 | personal information I submit with it, including my sign-off) is 35 | maintained indefinitely and may be redistributed consistent with 36 | this project or the open source license(s) involved. 37 | -------------------------------------------------------------------------------- /vendor/src/github.com/coreos/fleet/Documentation/examples/img/subgun.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vaijab/kube-apiproxy/bd59de7d5926512b4678c5a9ccd9c523986f9deb/vendor/src/github.com/coreos/fleet/Documentation/examples/img/subgun.png -------------------------------------------------------------------------------- /vendor/src/github.com/coreos/fleet/Documentation/examples/service-discovery.md: -------------------------------------------------------------------------------- 1 | # Service Discovery 2 | 3 | Since applications and networking environments vary widely between customer deployments, fleet does not provide a generalized, integrated solution for service discovery. However, there are a number of patterns available which can easily be implemented on top of fleet to provide automated and reliable service discovery. One such pattern, the _sidekick model_, is described below. 4 | 5 | ## Sidekick model 6 | 7 | The sidekick model works in a very similar fashion to [Synapse](https://github.com/airbnb/synapse), which runs a separate discovery agent next to the main container that is being run. This can be easily accomplished in fleet with the `MachineOf` option. 8 | 9 | Instead of guessing when an application is healthy and ready to serve traffic, you can write agent to be as simple or complex as you see fit. For example, your agent might want to check the applications `/v1/health` endpoint after deployment before declaring the instance healthy and announcing it. For another application, you might want to announce each instance by public IP address instead of a private IP. 10 | 11 | ## Sample Discovery Unit 12 | 13 | Here's an extremely simple bash agent that blindly announces our Nginx container after it is started: 14 | 15 | ``` 16 | [Unit] 17 | Description=Announce nginx1.service 18 | # Binds this unit and nginx1 together. When nginx1 is stopped, this unit will be stopped too. 19 | BindsTo=nginx1.service 20 | 21 | [Service] 22 | ExecStart=/bin/sh -c "while true; do etcdctl set /services/website/nginx1 '{ \"host\": \"%H\", \"port\": 8080, \"version\": \"52c7248a14\" }' --ttl 60;sleep 45;done" 23 | ExecStop=/usr/bin/etcdctl delete /services/website/nginx1 24 | 25 | [X-Fleet] 26 | # This unit will always be colocated with nginx1.service 27 | MachineOf=nginx1.service 28 | ``` 29 | -------------------------------------------------------------------------------- /vendor/src/github.com/coreos/fleet/Documentation/rkt_guide.md: -------------------------------------------------------------------------------- 1 | # Running fleetd under rkt 2 | 3 | The following guide will show you how to run fleetd under rkt. 4 | 5 | ## Building fleet ACI 6 | 7 | Just run the [build-aci](/build-aci) script. 8 | 9 | ## Running fleet ACI 10 | 11 | You'll need a `/run/fleet/units` directory in the host since this is where fleet stores systemd units and it will be mounted as a volume inside the container. 12 | 13 | Then you can run fleet under rkt: 14 | 15 | ``` 16 | # rkt -insecure-skip-verify run -inherit-env -volume machine-id,kind=host,source=/etc/machine-id -volume dbus-socket,kind=host,source=/run/dbus/system_bus_socket -volume fleet-units,kind=host,source=/run/fleet/units -volume etc-fleet,kind=host,source=/etc/fleet fleetd-0.9.0.aci 17 | ``` 18 | 19 | You can configure it modifying the file `/etc/fleet/fleet.conf` in your host and with enviroment variables as described in [deployment-and-configuration.md](deployment-and-configuration.md). 20 | 21 | ## Example systemd unit file 22 | 23 | ``` 24 | [Unit] 25 | Description=fleet daemon (rkt flavor) 26 | 27 | Wants=etcd.service 28 | After=etcd.service 29 | 30 | Wants=fleet.socket 31 | After=fleet.socket 32 | 33 | [Service] 34 | ExecStartPre=/usr/bin/mkdir -p /run/fleet/units 35 | ExecStart=/etc/usr/bin/rkt -insecure-skip-verify run -inherit-env -volume machine-id,kind=host,source=/etc/machine-id -volume dbus-socket,kind=host,source=/run/dbus/system_bus_socket -volume fleet-units,kind=host,source=/run/fleet/units -volume etc-fleet,kind=host,source=/etc/fleet /usr/images/fleetd-0.9.0.aci 36 | Restart=always 37 | RestartSec=10s 38 | ``` 39 | -------------------------------------------------------------------------------- /vendor/src/github.com/coreos/fleet/Godeps/Godeps.json: -------------------------------------------------------------------------------- 1 | { 2 | "ImportPath": "github.com/coreos/fleet", 3 | "GoVersion": "go1.3.3", 4 | "Packages": [ 5 | "./..." 6 | ], 7 | "Deps": [ 8 | { 9 | "ImportPath": "code.google.com/p/go-uuid/uuid", 10 | "Comment": "null-15", 11 | "Rev": "35bc42037350f0078e3c974c6ea690f1926603ab" 12 | }, 13 | { 14 | "ImportPath": "github.com/coreos/go-semver/semver", 15 | "Rev": "a9a0c39c7e4a2929f73d4b757d1860fbb8e66d06" 16 | }, 17 | { 18 | "ImportPath": "github.com/coreos/go-systemd/activation", 19 | "Comment": "v2-35-gcf3cdf7", 20 | "Rev": "cf3cdf77462baaad163ad2d5d1984b9c1b493701" 21 | }, 22 | { 23 | "ImportPath": "github.com/coreos/go-systemd/dbus", 24 | "Comment": "v2-35-gcf3cdf7", 25 | "Rev": "cf3cdf77462baaad163ad2d5d1984b9c1b493701" 26 | }, 27 | { 28 | "ImportPath": "github.com/coreos/go-systemd/unit", 29 | "Comment": "v2-35-gcf3cdf7", 30 | "Rev": "cf3cdf77462baaad163ad2d5d1984b9c1b493701" 31 | }, 32 | { 33 | "ImportPath": "github.com/docker/libcontainer/netlink", 34 | "Comment": "v1.1.0-44-g8c0303d", 35 | "Rev": "8c0303d92862eccc4bb9a07d7dac9065e4a32014" 36 | }, 37 | { 38 | "ImportPath": "github.com/godbus/dbus", 39 | "Comment": "0-11-gcfab99a", 40 | "Rev": "cfab99a9500db4ba03067996059d2fc425090bf3" 41 | }, 42 | { 43 | "ImportPath": "github.com/jonboulle/clockwork", 44 | "Rev": "b473f398c464f1988327f67c9e6aa7fba62f80d2" 45 | }, 46 | { 47 | "ImportPath": "github.com/rakyll/globalconf", 48 | "Rev": "fd9ff89130a682478a0c94e893ff4affe570b002" 49 | }, 50 | { 51 | "ImportPath": "github.com/rakyll/goini", 52 | "Rev": "907cca0f578a5316fb864ec6992dc3d9730ec58c" 53 | }, 54 | { 55 | "ImportPath": "golang.org/x/crypto/ssh", 56 | "Comment": "null-234", 57 | "Rev": "60a80aaa50ff0e8506f61b1fa35078a24941be50" 58 | }, 59 | { 60 | "ImportPath": "google.golang.org/api/google-api-go-generator", 61 | "Rev": "d3edb0282bde692467788c50070a9211afe75cf3" 62 | }, 63 | { 64 | "ImportPath": "google.golang.org/api/googleapi", 65 | "Rev": "d3edb0282bde692467788c50070a9211afe75cf3" 66 | } 67 | ] 68 | } 69 | -------------------------------------------------------------------------------- /vendor/src/github.com/coreos/fleet/Godeps/Readme: -------------------------------------------------------------------------------- 1 | This directory tree is generated automatically by godep. 2 | 3 | Please do not edit. 4 | 5 | See https://github.com/tools/godep for more information. 6 | -------------------------------------------------------------------------------- /vendor/src/github.com/coreos/fleet/Godeps/_workspace/src/code.google.com/p/go-uuid/uuid/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2009,2014 Google Inc. All rights reserved. 2 | 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions are 5 | met: 6 | 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above 10 | copyright notice, this list of conditions and the following disclaimer 11 | in the documentation and/or other materials provided with the 12 | distribution. 13 | * Neither the name of Google Inc. nor the names of its 14 | contributors may be used to endorse or promote products derived from 15 | this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | -------------------------------------------------------------------------------- /vendor/src/github.com/coreos/fleet/Godeps/_workspace/src/code.google.com/p/go-uuid/uuid/dce.go: -------------------------------------------------------------------------------- 1 | // Copyright 2011 Google Inc. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package uuid 6 | 7 | import ( 8 | "encoding/binary" 9 | "fmt" 10 | "os" 11 | ) 12 | 13 | // A Domain represents a Version 2 domain 14 | type Domain byte 15 | 16 | // Domain constants for DCE Security (Version 2) UUIDs. 17 | const ( 18 | Person = Domain(0) 19 | Group = Domain(1) 20 | Org = Domain(2) 21 | ) 22 | 23 | // NewDCESecurity returns a DCE Security (Version 2) UUID. 24 | // 25 | // The domain should be one of Person, Group or Org. 26 | // On a POSIX system the id should be the users UID for the Person 27 | // domain and the users GID for the Group. The meaning of id for 28 | // the domain Org or on non-POSIX systems is site defined. 29 | // 30 | // For a given domain/id pair the same token may be returned for up to 31 | // 7 minutes and 10 seconds. 32 | func NewDCESecurity(domain Domain, id uint32) UUID { 33 | uuid := NewUUID() 34 | if uuid != nil { 35 | uuid[6] = (uuid[6] & 0x0f) | 0x20 // Version 2 36 | uuid[9] = byte(domain) 37 | binary.BigEndian.PutUint32(uuid[0:], id) 38 | } 39 | return uuid 40 | } 41 | 42 | // NewDCEPerson returns a DCE Security (Version 2) UUID in the person 43 | // domain with the id returned by os.Getuid. 44 | // 45 | // NewDCEPerson(Person, uint32(os.Getuid())) 46 | func NewDCEPerson() UUID { 47 | return NewDCESecurity(Person, uint32(os.Getuid())) 48 | } 49 | 50 | // NewDCEGroup returns a DCE Security (Version 2) UUID in the group 51 | // domain with the id returned by os.Getgid. 52 | // 53 | // NewDCEGroup(Group, uint32(os.Getgid())) 54 | func NewDCEGroup() UUID { 55 | return NewDCESecurity(Group, uint32(os.Getgid())) 56 | } 57 | 58 | // Domain returns the domain for a Version 2 UUID or false. 59 | func (uuid UUID) Domain() (Domain, bool) { 60 | if v, _ := uuid.Version(); v != 2 { 61 | return 0, false 62 | } 63 | return Domain(uuid[9]), true 64 | } 65 | 66 | // Id returns the id for a Version 2 UUID or false. 67 | func (uuid UUID) Id() (uint32, bool) { 68 | if v, _ := uuid.Version(); v != 2 { 69 | return 0, false 70 | } 71 | return binary.BigEndian.Uint32(uuid[0:4]), true 72 | } 73 | 74 | func (d Domain) String() string { 75 | switch d { 76 | case Person: 77 | return "Person" 78 | case Group: 79 | return "Group" 80 | case Org: 81 | return "Org" 82 | } 83 | return fmt.Sprintf("Domain%d", int(d)) 84 | } 85 | -------------------------------------------------------------------------------- /vendor/src/github.com/coreos/fleet/Godeps/_workspace/src/code.google.com/p/go-uuid/uuid/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2011 Google Inc. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // The uuid package generates and inspects UUIDs. 6 | // 7 | // UUIDs are based on RFC 4122 and DCE 1.1: Authentication and Security Services. 8 | package uuid 9 | -------------------------------------------------------------------------------- /vendor/src/github.com/coreos/fleet/Godeps/_workspace/src/code.google.com/p/go-uuid/uuid/hash.go: -------------------------------------------------------------------------------- 1 | // Copyright 2011 Google Inc. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package uuid 6 | 7 | import ( 8 | "crypto/md5" 9 | "crypto/sha1" 10 | "hash" 11 | ) 12 | 13 | // Well known Name Space IDs and UUIDs 14 | var ( 15 | NameSpace_DNS = Parse("6ba7b810-9dad-11d1-80b4-00c04fd430c8") 16 | NameSpace_URL = Parse("6ba7b811-9dad-11d1-80b4-00c04fd430c8") 17 | NameSpace_OID = Parse("6ba7b812-9dad-11d1-80b4-00c04fd430c8") 18 | NameSpace_X500 = Parse("6ba7b814-9dad-11d1-80b4-00c04fd430c8") 19 | NIL = Parse("00000000-0000-0000-0000-000000000000") 20 | ) 21 | 22 | // NewHash returns a new UUID dervied from the hash of space concatenated with 23 | // data generated by h. The hash should be at least 16 byte in length. The 24 | // first 16 bytes of the hash are used to form the UUID. The version of the 25 | // UUID will be the lower 4 bits of version. NewHash is used to implement 26 | // NewMD5 and NewSHA1. 27 | func NewHash(h hash.Hash, space UUID, data []byte, version int) UUID { 28 | h.Reset() 29 | h.Write(space) 30 | h.Write([]byte(data)) 31 | s := h.Sum(nil) 32 | uuid := make([]byte, 16) 33 | copy(uuid, s) 34 | uuid[6] = (uuid[6] & 0x0f) | uint8((version&0xf)<<4) 35 | uuid[8] = (uuid[8] & 0x3f) | 0x80 // RFC 4122 variant 36 | return uuid 37 | } 38 | 39 | // NewMD5 returns a new MD5 (Version 3) UUID based on the 40 | // supplied name space and data. 41 | // 42 | // NewHash(md5.New(), space, data, 3) 43 | func NewMD5(space UUID, data []byte) UUID { 44 | return NewHash(md5.New(), space, data, 3) 45 | } 46 | 47 | // NewSHA1 returns a new SHA1 (Version 5) UUID based on the 48 | // supplied name space and data. 49 | // 50 | // NewHash(sha1.New(), space, data, 5) 51 | func NewSHA1(space UUID, data []byte) UUID { 52 | return NewHash(sha1.New(), space, data, 5) 53 | } 54 | -------------------------------------------------------------------------------- /vendor/src/github.com/coreos/fleet/Godeps/_workspace/src/code.google.com/p/go-uuid/uuid/json.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 Google Inc. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package uuid 6 | 7 | import "errors" 8 | 9 | func (u UUID) MarshalJSON() ([]byte, error) { 10 | if len(u) == 0 { 11 | return []byte(`""`), nil 12 | } 13 | return []byte(`"` + u.String() + `"`), nil 14 | } 15 | 16 | func (u *UUID) UnmarshalJSON(data []byte) error { 17 | if len(data) == 0 || string(data) == `""` { 18 | return nil 19 | } 20 | if len(data) < 2 || data[0] != '"' || data[len(data)-1] != '"' { 21 | return errors.New("invalid UUID format") 22 | } 23 | data = data[1 : len(data)-1] 24 | uu := Parse(string(data)) 25 | if uu == nil { 26 | return errors.New("invalid UUID format") 27 | } 28 | *u = uu 29 | return nil 30 | } 31 | -------------------------------------------------------------------------------- /vendor/src/github.com/coreos/fleet/Godeps/_workspace/src/code.google.com/p/go-uuid/uuid/json_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 Google Inc. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package uuid 6 | 7 | import ( 8 | "encoding/json" 9 | "reflect" 10 | "testing" 11 | ) 12 | 13 | var testUUID = Parse("f47ac10b-58cc-0372-8567-0e02b2c3d479") 14 | 15 | func TestJSON(t *testing.T) { 16 | type S struct { 17 | ID1 UUID 18 | ID2 UUID 19 | } 20 | s1 := S{ID1: testUUID} 21 | data, err := json.Marshal(&s1) 22 | if err != nil { 23 | t.Fatal(err) 24 | } 25 | var s2 S 26 | if err := json.Unmarshal(data, &s2); err != nil { 27 | t.Fatal(err) 28 | } 29 | if !reflect.DeepEqual(&s1, &s2) { 30 | t.Errorf("got %#v, want %#v", s2, s1) 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /vendor/src/github.com/coreos/fleet/Godeps/_workspace/src/code.google.com/p/go-uuid/uuid/seq_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 Google Inc. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package uuid 6 | 7 | import ( 8 | "flag" 9 | "runtime" 10 | "testing" 11 | "time" 12 | ) 13 | 14 | // This test is only run when --regressions is passed on the go test line. 15 | var regressions = flag.Bool("regressions", false, "run uuid regression tests") 16 | 17 | // TestClockSeqRace tests for a particular race condition of returning two 18 | // identical Version1 UUIDs. The duration of 1 minute was chosen as the race 19 | // condition, before being fixed, nearly always occured in under 30 seconds. 20 | func TestClockSeqRace(t *testing.T) { 21 | if !*regressions { 22 | t.Skip("skipping regression tests") 23 | } 24 | duration := time.Minute 25 | 26 | done := make(chan struct{}) 27 | defer close(done) 28 | 29 | ch := make(chan UUID, 10000) 30 | ncpu := runtime.NumCPU() 31 | switch ncpu { 32 | case 0, 1: 33 | // We can't run the test effectively. 34 | t.Skip("skipping race test, only one CPU detected") 35 | return 36 | default: 37 | runtime.GOMAXPROCS(ncpu) 38 | } 39 | for i := 0; i < ncpu; i++ { 40 | go func() { 41 | for { 42 | select { 43 | case <-done: 44 | return 45 | case ch <- NewUUID(): 46 | } 47 | } 48 | }() 49 | } 50 | 51 | uuids := make(map[string]bool) 52 | cnt := 0 53 | start := time.Now() 54 | for u := range ch { 55 | s := u.String() 56 | if uuids[s] { 57 | t.Errorf("duplicate uuid after %d in %v: %s", cnt, time.Since(start), s) 58 | return 59 | } 60 | uuids[s] = true 61 | if time.Since(start) > duration { 62 | return 63 | } 64 | cnt++ 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /vendor/src/github.com/coreos/fleet/Godeps/_workspace/src/code.google.com/p/go-uuid/uuid/util.go: -------------------------------------------------------------------------------- 1 | // Copyright 2011 Google Inc. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package uuid 6 | 7 | import ( 8 | "io" 9 | ) 10 | 11 | // randomBits completely fills slice b with random data. 12 | func randomBits(b []byte) { 13 | if _, err := io.ReadFull(rander, b); err != nil { 14 | panic(err.Error()) // rand should never fail 15 | } 16 | } 17 | 18 | // xvalues returns the value of a byte as a hexadecimal digit or 255. 19 | var xvalues = []byte{ 20 | 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 21 | 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 22 | 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 23 | 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 255, 255, 255, 255, 255, 255, 24 | 255, 10, 11, 12, 13, 14, 15, 255, 255, 255, 255, 255, 255, 255, 255, 255, 25 | 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 26 | 255, 10, 11, 12, 13, 14, 15, 255, 255, 255, 255, 255, 255, 255, 255, 255, 27 | 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 28 | 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 29 | 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 30 | 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 31 | 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 32 | 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 33 | 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 34 | 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 35 | 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 36 | } 37 | 38 | // xtob converts the the first two hex bytes of x into a byte. 39 | func xtob(x string) (byte, bool) { 40 | b1 := xvalues[x[0]] 41 | b2 := xvalues[x[1]] 42 | return (b1 << 4) | b2, b1 != 255 && b2 != 255 43 | } 44 | -------------------------------------------------------------------------------- /vendor/src/github.com/coreos/fleet/Godeps/_workspace/src/code.google.com/p/go-uuid/uuid/version1.go: -------------------------------------------------------------------------------- 1 | // Copyright 2011 Google Inc. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package uuid 6 | 7 | import ( 8 | "encoding/binary" 9 | ) 10 | 11 | // NewUUID returns a Version 1 UUID based on the current NodeID and clock 12 | // sequence, and the current time. If the NodeID has not been set by SetNodeID 13 | // or SetNodeInterface then it will be set automatically. If the NodeID cannot 14 | // be set NewUUID returns nil. If clock sequence has not been set by 15 | // SetClockSequence then it will be set automatically. If GetTime fails to 16 | // return the current NewUUID returns nil. 17 | func NewUUID() UUID { 18 | if nodeID == nil { 19 | SetNodeInterface("") 20 | } 21 | 22 | now, seq, err := GetTime() 23 | if err != nil { 24 | return nil 25 | } 26 | 27 | uuid := make([]byte, 16) 28 | 29 | time_low := uint32(now & 0xffffffff) 30 | time_mid := uint16((now >> 32) & 0xffff) 31 | time_hi := uint16((now >> 48) & 0x0fff) 32 | time_hi |= 0x1000 // Version 1 33 | 34 | binary.BigEndian.PutUint32(uuid[0:], time_low) 35 | binary.BigEndian.PutUint16(uuid[4:], time_mid) 36 | binary.BigEndian.PutUint16(uuid[6:], time_hi) 37 | binary.BigEndian.PutUint16(uuid[8:], seq) 38 | copy(uuid[10:], nodeID) 39 | 40 | return uuid 41 | } 42 | -------------------------------------------------------------------------------- /vendor/src/github.com/coreos/fleet/Godeps/_workspace/src/code.google.com/p/go-uuid/uuid/version4.go: -------------------------------------------------------------------------------- 1 | // Copyright 2011 Google Inc. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package uuid 6 | 7 | // Random returns a Random (Version 4) UUID or panics. 8 | // 9 | // The strength of the UUIDs is based on the strength of the crypto/rand 10 | // package. 11 | // 12 | // A note about uniqueness derived from from the UUID Wikipedia entry: 13 | // 14 | // Randomly generated UUIDs have 122 random bits. One's annual risk of being 15 | // hit by a meteorite is estimated to be one chance in 17 billion, that 16 | // means the probability is about 0.00000000006 (6 × 10−11), 17 | // equivalent to the odds of creating a few tens of trillions of UUIDs in a 18 | // year and having one duplicate. 19 | func NewRandom() UUID { 20 | uuid := make([]byte, 16) 21 | randomBits([]byte(uuid)) 22 | uuid[6] = (uuid[6] & 0x0f) | 0x40 // Version 4 23 | uuid[8] = (uuid[8] & 0x3f) | 0x80 // Variant is 10 24 | return uuid 25 | } 26 | -------------------------------------------------------------------------------- /vendor/src/github.com/coreos/fleet/Godeps/_workspace/src/github.com/coreos/go-semver/semver/sort.go: -------------------------------------------------------------------------------- 1 | package semver 2 | 3 | import ( 4 | "sort" 5 | ) 6 | 7 | type Versions []*Version 8 | 9 | func (s Versions) Len() int { 10 | return len(s) 11 | } 12 | 13 | func (s Versions) Swap(i, j int) { 14 | s[i], s[j] = s[j], s[i] 15 | } 16 | 17 | func (s Versions) Less(i, j int) bool { 18 | return s[i].LessThan(*s[j]) 19 | } 20 | 21 | // Sort sorts the given slice of Version 22 | func Sort(versions []*Version) { 23 | sort.Sort(Versions(versions)) 24 | } 25 | -------------------------------------------------------------------------------- /vendor/src/github.com/coreos/fleet/Godeps/_workspace/src/github.com/coreos/go-systemd/activation/files.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2013 CoreOS Inc. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Package activation implements primitives for systemd socket activation. 18 | package activation 19 | 20 | import ( 21 | "os" 22 | "strconv" 23 | "syscall" 24 | ) 25 | 26 | // based on: https://gist.github.com/alberts/4640792 27 | const ( 28 | listenFdsStart = 3 29 | ) 30 | 31 | func Files(unsetEnv bool) []*os.File { 32 | if unsetEnv { 33 | // there is no way to unset env in golang os package for now 34 | // https://code.google.com/p/go/issues/detail?id=6423 35 | defer os.Setenv("LISTEN_PID", "") 36 | defer os.Setenv("LISTEN_FDS", "") 37 | } 38 | 39 | pid, err := strconv.Atoi(os.Getenv("LISTEN_PID")) 40 | if err != nil || pid != os.Getpid() { 41 | return nil 42 | } 43 | 44 | nfds, err := strconv.Atoi(os.Getenv("LISTEN_FDS")) 45 | if err != nil || nfds == 0 { 46 | return nil 47 | } 48 | 49 | var files []*os.File 50 | for fd := listenFdsStart; fd < listenFdsStart+nfds; fd++ { 51 | syscall.CloseOnExec(fd) 52 | files = append(files, os.NewFile(uintptr(fd), "LISTEN_FD_"+strconv.Itoa(fd))) 53 | } 54 | 55 | return files 56 | } 57 | -------------------------------------------------------------------------------- /vendor/src/github.com/coreos/fleet/Godeps/_workspace/src/github.com/coreos/go-systemd/activation/listeners.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2014 CoreOS Inc. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package activation 18 | 19 | import ( 20 | "net" 21 | ) 22 | 23 | // Listeners returns a slice containing a net.Listener for each matching socket type 24 | // passed to this process. 25 | // 26 | // The order of the file descriptors is preserved in the returned slice. 27 | // Nil values are used to fill any gaps. For example if systemd were to return file descriptors 28 | // corresponding with "udp, tcp, tcp", then the slice would contain {nil, net.Listener, net.Listener} 29 | func Listeners(unsetEnv bool) ([]net.Listener, error) { 30 | files := Files(unsetEnv) 31 | listeners := make([]net.Listener, 0) 32 | 33 | for i := 0; i < len(files); i++ { 34 | if pc, err := net.FileListener(files[i]); err == nil { 35 | listeners = append(listeners, pc) 36 | continue 37 | } else { 38 | listeners = append(listeners, nil) 39 | } 40 | } 41 | return listeners, nil 42 | } 43 | -------------------------------------------------------------------------------- /vendor/src/github.com/coreos/fleet/Godeps/_workspace/src/github.com/coreos/go-systemd/activation/listeners_test.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2014 CoreOS Inc. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package activation 18 | 19 | import ( 20 | "io" 21 | "net" 22 | "os" 23 | "os/exec" 24 | "testing" 25 | ) 26 | 27 | // correctStringWritten fails the text if the correct string wasn't written 28 | // to the other side of the pipe. 29 | func correctStringWrittenNet(t *testing.T, r net.Conn, expected string) bool { 30 | bytes := make([]byte, len(expected)) 31 | io.ReadAtLeast(r, bytes, len(expected)) 32 | 33 | if string(bytes) != expected { 34 | t.Fatalf("Unexpected string %s", string(bytes)) 35 | } 36 | 37 | return true 38 | } 39 | 40 | // TestActivation forks out a copy of activation.go example and reads back two 41 | // strings from the pipes that are passed in. 42 | func TestListeners(t *testing.T) { 43 | cmd := exec.Command("go", "run", "../examples/activation/listen.go") 44 | 45 | l1, err := net.Listen("tcp", ":9999") 46 | if err != nil { 47 | t.Fatalf(err.Error()) 48 | } 49 | l2, err := net.Listen("tcp", ":1234") 50 | if err != nil { 51 | t.Fatalf(err.Error()) 52 | } 53 | 54 | t1 := l1.(*net.TCPListener) 55 | t2 := l2.(*net.TCPListener) 56 | 57 | f1, _ := t1.File() 58 | f2, _ := t2.File() 59 | 60 | cmd.ExtraFiles = []*os.File{ 61 | f1, 62 | f2, 63 | } 64 | 65 | r1, err := net.Dial("tcp", "127.0.0.1:9999") 66 | if err != nil { 67 | t.Fatalf(err.Error()) 68 | } 69 | r1.Write([]byte("Hi")) 70 | 71 | r2, err := net.Dial("tcp", "127.0.0.1:1234") 72 | if err != nil { 73 | t.Fatalf(err.Error()) 74 | } 75 | r2.Write([]byte("Hi")) 76 | 77 | cmd.Env = os.Environ() 78 | cmd.Env = append(cmd.Env, "LISTEN_FDS=2", "FIX_LISTEN_PID=1") 79 | 80 | out, err := cmd.Output() 81 | if err != nil { 82 | println(string(out)) 83 | t.Fatalf(err.Error()) 84 | } 85 | 86 | correctStringWrittenNet(t, r1, "Hello world") 87 | correctStringWrittenNet(t, r2, "Goodbye world") 88 | } 89 | -------------------------------------------------------------------------------- /vendor/src/github.com/coreos/fleet/Godeps/_workspace/src/github.com/coreos/go-systemd/activation/packetconns.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2014 CoreOS Inc. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package activation 18 | 19 | import ( 20 | "net" 21 | ) 22 | 23 | // PacketConns returns a slice containing a net.PacketConn for each matching socket type 24 | // passed to this process. 25 | // 26 | // The order of the file descriptors is preserved in the returned slice. 27 | // Nil values are used to fill any gaps. For example if systemd were to return file descriptors 28 | // corresponding with "udp, tcp, udp", then the slice would contain {net.PacketConn, nil, net.PacketConn} 29 | func PacketConns(unsetEnv bool) ([]net.PacketConn, error) { 30 | files := Files(unsetEnv) 31 | conns := make([]net.PacketConn, 0) 32 | for i := 0; i < len(files); i++ { 33 | if pc, err := net.FilePacketConn(files[i]); err == nil { 34 | conns = append(conns, pc) 35 | continue 36 | } else { 37 | conns = append(conns, nil) 38 | } 39 | } 40 | return conns, nil 41 | } 42 | -------------------------------------------------------------------------------- /vendor/src/github.com/coreos/fleet/Godeps/_workspace/src/github.com/coreos/go-systemd/activation/packetconns_test.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2014 CoreOS Inc. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package activation 18 | 19 | import ( 20 | "net" 21 | "os" 22 | "os/exec" 23 | "testing" 24 | ) 25 | 26 | // TestActivation forks out a copy of activation.go example and reads back two 27 | // strings from the pipes that are passed in. 28 | func TestPacketConns(t *testing.T) { 29 | cmd := exec.Command("go", "run", "../examples/activation/udpconn.go") 30 | 31 | u1, err := net.ListenUDP("udp", &net.UDPAddr{Port: 9999}) 32 | if err != nil { 33 | t.Fatalf(err.Error()) 34 | } 35 | u2, err := net.ListenUDP("udp", &net.UDPAddr{Port: 1234}) 36 | if err != nil { 37 | t.Fatalf(err.Error()) 38 | } 39 | 40 | f1, _ := u1.File() 41 | f2, _ := u2.File() 42 | 43 | cmd.ExtraFiles = []*os.File{ 44 | f1, 45 | f2, 46 | } 47 | 48 | r1, err := net.Dial("udp", "127.0.0.1:9999") 49 | if err != nil { 50 | t.Fatalf(err.Error()) 51 | } 52 | r1.Write([]byte("Hi")) 53 | 54 | r2, err := net.Dial("udp", "127.0.0.1:1234") 55 | if err != nil { 56 | t.Fatalf(err.Error()) 57 | } 58 | r2.Write([]byte("Hi")) 59 | 60 | cmd.Env = os.Environ() 61 | cmd.Env = append(cmd.Env, "LISTEN_FDS=2", "FIX_LISTEN_PID=1") 62 | 63 | out, err := cmd.CombinedOutput() 64 | if err != nil { 65 | t.Fatalf("Cmd output '%s', err: '%s'\n", out, err) 66 | } 67 | 68 | correctStringWrittenNet(t, r1, "Hello world") 69 | correctStringWrittenNet(t, r2, "Goodbye world") 70 | } 71 | -------------------------------------------------------------------------------- /vendor/src/github.com/coreos/fleet/Godeps/_workspace/src/github.com/coreos/go-systemd/dbus/dbus_test.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2013 CoreOS Inc. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package dbus 18 | 19 | import ( 20 | "testing" 21 | ) 22 | 23 | func TestNeedsEscape(t *testing.T) { 24 | // Anything not 0-9a-zA-Z should always be escaped 25 | for want, vals := range map[bool][]byte{ 26 | false: []byte{'a', 'b', 'z', 'A', 'Q', '1', '4', '9'}, 27 | true: []byte{'#', '%', '$', '!', '.', '_', '-', '%', '\\'}, 28 | } { 29 | for i := 1; i < 10; i++ { 30 | for _, b := range vals { 31 | got := needsEscape(i, b) 32 | if got != want { 33 | t.Errorf("needsEscape(%d, %c) returned %t, want %t", i, b, got, want) 34 | } 35 | } 36 | } 37 | } 38 | 39 | // 0-9 in position 0 should be escaped 40 | for want, vals := range map[bool][]byte{ 41 | false: []byte{'A', 'a', 'e', 'x', 'Q', 'Z'}, 42 | true: []byte{'0', '4', '5', '9'}, 43 | } { 44 | for _, b := range vals { 45 | got := needsEscape(0, b) 46 | if got != want { 47 | t.Errorf("needsEscape(0, %c) returned %t, want %t", b, got, want) 48 | } 49 | } 50 | } 51 | 52 | } 53 | 54 | func TestPathBusEscape(t *testing.T) { 55 | for in, want := range map[string]string{ 56 | "": "_", 57 | "foo.service": "foo_2eservice", 58 | "foobar": "foobar", 59 | "woof@woof.service": "woof_40woof_2eservice", 60 | "0123456": "_30123456", 61 | "account_db.service": "account_5fdb_2eservice", 62 | "got-dashes": "got_2ddashes", 63 | } { 64 | got := PathBusEscape(in) 65 | if got != want { 66 | t.Errorf("bad result for PathBusEscape(%s): got %q, want %q", in, got, want) 67 | } 68 | } 69 | 70 | } 71 | 72 | // TestNew ensures that New() works without errors. 73 | func TestNew(t *testing.T) { 74 | _, err := New() 75 | 76 | if err != nil { 77 | t.Fatal(err) 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /vendor/src/github.com/coreos/fleet/Godeps/_workspace/src/github.com/coreos/go-systemd/dbus/set.go: -------------------------------------------------------------------------------- 1 | package dbus 2 | 3 | type set struct { 4 | data map[string]bool 5 | } 6 | 7 | func (s *set) Add(value string) { 8 | s.data[value] = true 9 | } 10 | 11 | func (s *set) Remove(value string) { 12 | delete(s.data, value) 13 | } 14 | 15 | func (s *set) Contains(value string) (exists bool) { 16 | _, exists = s.data[value] 17 | return 18 | } 19 | 20 | func (s *set) Length() (int) { 21 | return len(s.data) 22 | } 23 | 24 | func (s *set) Values() (values []string) { 25 | for val, _ := range s.data { 26 | values = append(values, val) 27 | } 28 | return 29 | } 30 | 31 | func newSet() (*set) { 32 | return &set{make(map[string] bool)} 33 | } 34 | -------------------------------------------------------------------------------- /vendor/src/github.com/coreos/fleet/Godeps/_workspace/src/github.com/coreos/go-systemd/dbus/set_test.go: -------------------------------------------------------------------------------- 1 | package dbus 2 | 3 | import ( 4 | "testing" 5 | ) 6 | 7 | // TestBasicSetActions asserts that Add & Remove behavior is correct 8 | func TestBasicSetActions(t *testing.T) { 9 | s := newSet() 10 | 11 | if s.Contains("foo") { 12 | t.Fatal("set should not contain 'foo'") 13 | } 14 | 15 | s.Add("foo") 16 | 17 | if !s.Contains("foo") { 18 | t.Fatal("set should contain 'foo'") 19 | } 20 | 21 | v := s.Values() 22 | if len(v) != 1 { 23 | t.Fatal("set.Values did not report correct number of values") 24 | } 25 | if v[0] != "foo" { 26 | t.Fatal("set.Values did not report value") 27 | } 28 | 29 | s.Remove("foo") 30 | 31 | if s.Contains("foo") { 32 | t.Fatal("set should not contain 'foo'") 33 | } 34 | 35 | v = s.Values() 36 | if len(v) != 0 { 37 | t.Fatal("set.Values did not report correct number of values") 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /vendor/src/github.com/coreos/fleet/Godeps/_workspace/src/github.com/coreos/go-systemd/dbus/subscription_set.go: -------------------------------------------------------------------------------- 1 | package dbus 2 | 3 | import ( 4 | "time" 5 | ) 6 | 7 | // SubscriptionSet returns a subscription set which is like conn.Subscribe but 8 | // can filter to only return events for a set of units. 9 | type SubscriptionSet struct { 10 | *set 11 | conn *Conn 12 | } 13 | 14 | func (s *SubscriptionSet) filter(unit string) bool { 15 | return !s.Contains(unit) 16 | } 17 | 18 | // Subscribe starts listening for dbus events for all of the units in the set. 19 | // Returns channels identical to conn.SubscribeUnits. 20 | func (s *SubscriptionSet) Subscribe() (<-chan map[string]*UnitStatus, <-chan error) { 21 | // TODO: Make fully evented by using systemd 209 with properties changed values 22 | return s.conn.SubscribeUnitsCustom(time.Second, 0, 23 | mismatchUnitStatus, 24 | func(unit string) bool { return s.filter(unit) }, 25 | ) 26 | } 27 | 28 | // NewSubscriptionSet returns a new subscription set. 29 | func (conn *Conn) NewSubscriptionSet() *SubscriptionSet { 30 | return &SubscriptionSet{newSet(), conn} 31 | } 32 | 33 | // mismatchUnitStatus returns true if the provided UnitStatus objects 34 | // are not equivalent. false is returned if the objects are equivalent. 35 | // Only the Name, Description and state-related fields are used in 36 | // the comparison. 37 | func mismatchUnitStatus(u1, u2 *UnitStatus) bool { 38 | return u1.Name != u2.Name || 39 | u1.Description != u2.Description || 40 | u1.LoadState != u2.LoadState || 41 | u1.ActiveState != u2.ActiveState || 42 | u1.SubState != u2.SubState 43 | } 44 | -------------------------------------------------------------------------------- /vendor/src/github.com/coreos/fleet/Godeps/_workspace/src/github.com/coreos/go-systemd/dbus/subscription_set_test.go: -------------------------------------------------------------------------------- 1 | package dbus 2 | 3 | import ( 4 | "testing" 5 | "time" 6 | ) 7 | 8 | // TestSubscribeUnit exercises the basics of subscription of a particular unit. 9 | func TestSubscriptionSetUnit(t *testing.T) { 10 | target := "subscribe-events-set.service" 11 | 12 | conn, err := New() 13 | 14 | if err != nil { 15 | t.Fatal(err) 16 | } 17 | 18 | err = conn.Subscribe() 19 | if err != nil { 20 | t.Fatal(err) 21 | } 22 | 23 | subSet := conn.NewSubscriptionSet() 24 | evChan, errChan := subSet.Subscribe() 25 | 26 | subSet.Add(target) 27 | setupUnit(target, conn, t) 28 | linkUnit(target, conn, t) 29 | 30 | reschan := make(chan string) 31 | _, err = conn.StartUnit(target, "replace", reschan) 32 | if err != nil { 33 | t.Fatal(err) 34 | } 35 | 36 | job := <-reschan 37 | if job != "done" { 38 | t.Fatal("Couldn't start", target) 39 | } 40 | 41 | timeout := make(chan bool, 1) 42 | go func() { 43 | time.Sleep(3 * time.Second) 44 | close(timeout) 45 | }() 46 | 47 | for { 48 | select { 49 | case changes := <-evChan: 50 | tCh, ok := changes[target] 51 | 52 | if !ok { 53 | t.Fatal("Unexpected event:", changes) 54 | } 55 | 56 | if tCh.ActiveState == "active" && tCh.Name == target { 57 | goto success 58 | } 59 | case err = <-errChan: 60 | t.Fatal(err) 61 | case <-timeout: 62 | t.Fatal("Reached timeout") 63 | } 64 | } 65 | 66 | success: 67 | return 68 | } 69 | -------------------------------------------------------------------------------- /vendor/src/github.com/coreos/fleet/Godeps/_workspace/src/github.com/coreos/go-systemd/dbus/subscription_test.go: -------------------------------------------------------------------------------- 1 | package dbus 2 | 3 | import ( 4 | "testing" 5 | "time" 6 | ) 7 | 8 | // TestSubscribe exercises the basics of subscription 9 | func TestSubscribe(t *testing.T) { 10 | conn, err := New() 11 | 12 | if err != nil { 13 | t.Fatal(err) 14 | } 15 | 16 | err = conn.Subscribe() 17 | if err != nil { 18 | t.Fatal(err) 19 | } 20 | 21 | err = conn.Unsubscribe() 22 | if err != nil { 23 | t.Fatal(err) 24 | } 25 | } 26 | 27 | // TestSubscribeUnit exercises the basics of subscription of a particular unit. 28 | func TestSubscribeUnit(t *testing.T) { 29 | target := "subscribe-events.service" 30 | 31 | conn, err := New() 32 | 33 | if err != nil { 34 | t.Fatal(err) 35 | } 36 | 37 | err = conn.Subscribe() 38 | if err != nil { 39 | t.Fatal(err) 40 | } 41 | 42 | err = conn.Unsubscribe() 43 | if err != nil { 44 | t.Fatal(err) 45 | } 46 | 47 | evChan, errChan := conn.SubscribeUnits(time.Second) 48 | 49 | setupUnit(target, conn, t) 50 | linkUnit(target, conn, t) 51 | 52 | reschan := make(chan string) 53 | _, err = conn.StartUnit(target, "replace", reschan) 54 | if err != nil { 55 | t.Fatal(err) 56 | } 57 | 58 | job := <-reschan 59 | if job != "done" { 60 | t.Fatal("Couldn't start", target) 61 | } 62 | 63 | timeout := make(chan bool, 1) 64 | go func() { 65 | time.Sleep(3 * time.Second) 66 | close(timeout) 67 | }() 68 | 69 | for { 70 | select { 71 | case changes := <-evChan: 72 | tCh, ok := changes[target] 73 | 74 | // Just continue until we see our event. 75 | if !ok { 76 | continue 77 | } 78 | 79 | if tCh.ActiveState == "active" && tCh.Name == target { 80 | goto success 81 | } 82 | case err = <-errChan: 83 | t.Fatal(err) 84 | case <-timeout: 85 | t.Fatal("Reached timeout") 86 | } 87 | } 88 | 89 | success: 90 | return 91 | } 92 | -------------------------------------------------------------------------------- /vendor/src/github.com/coreos/fleet/Godeps/_workspace/src/github.com/coreos/go-systemd/unit/option.go: -------------------------------------------------------------------------------- 1 | package unit 2 | 3 | import ( 4 | "fmt" 5 | ) 6 | 7 | type UnitOption struct { 8 | Section string 9 | Name string 10 | Value string 11 | } 12 | 13 | func (uo *UnitOption) String() string { 14 | return fmt.Sprintf("{Section: %q, Name: %q, Value: %q}", uo.Section, uo.Name, uo.Value) 15 | } 16 | 17 | func (uo *UnitOption) Match(other *UnitOption) bool { 18 | return uo.Section == other.Section && 19 | uo.Name == other.Name && 20 | uo.Value == other.Value 21 | } 22 | 23 | func AllMatch(u1 []*UnitOption, u2 []*UnitOption) bool { 24 | length := len(u1) 25 | if length != len(u2) { 26 | return false 27 | } 28 | 29 | for i := 0; i < length; i++ { 30 | if !u1[i].Match(u2[i]) { 31 | return false 32 | } 33 | } 34 | 35 | return true 36 | } 37 | -------------------------------------------------------------------------------- /vendor/src/github.com/coreos/fleet/Godeps/_workspace/src/github.com/coreos/go-systemd/unit/serialize.go: -------------------------------------------------------------------------------- 1 | package unit 2 | 3 | import ( 4 | "bytes" 5 | "io" 6 | ) 7 | 8 | // Serialize encodes all of the given UnitOption objects into a unit file 9 | func Serialize(opts []*UnitOption) io.Reader { 10 | var buf bytes.Buffer 11 | 12 | if len(opts) == 0 { 13 | return &buf 14 | } 15 | 16 | curSection := opts[0].Section 17 | 18 | writeSectionHeader(&buf, curSection) 19 | writeNewline(&buf) 20 | 21 | for _, opt := range opts { 22 | if opt.Section != curSection { 23 | curSection = opt.Section 24 | 25 | writeNewline(&buf) 26 | writeSectionHeader(&buf, curSection) 27 | writeNewline(&buf) 28 | } 29 | 30 | writeOption(&buf, opt) 31 | writeNewline(&buf) 32 | } 33 | 34 | return &buf 35 | } 36 | 37 | func writeNewline(buf *bytes.Buffer) { 38 | buf.WriteRune('\n') 39 | } 40 | 41 | func writeSectionHeader(buf *bytes.Buffer, section string) { 42 | buf.WriteRune('[') 43 | buf.WriteString(section) 44 | buf.WriteRune(']') 45 | } 46 | 47 | func writeOption(buf *bytes.Buffer, opt *UnitOption) { 48 | buf.WriteString(opt.Name) 49 | buf.WriteRune('=') 50 | buf.WriteString(opt.Value) 51 | } 52 | -------------------------------------------------------------------------------- /vendor/src/github.com/coreos/fleet/Godeps/_workspace/src/github.com/docker/libcontainer/netlink/MAINTAINERS: -------------------------------------------------------------------------------- 1 | Michael Crosby (@crosbymichael) 2 | Guillaume J. Charmes (@creack) 3 | -------------------------------------------------------------------------------- /vendor/src/github.com/coreos/fleet/Godeps/_workspace/src/github.com/docker/libcontainer/netlink/netlink.go: -------------------------------------------------------------------------------- 1 | // Packet netlink provide access to low level Netlink sockets and messages. 2 | // 3 | // Actual implementations are in: 4 | // netlink_linux.go 5 | // netlink_darwin.go 6 | package netlink 7 | 8 | import ( 9 | "errors" 10 | "net" 11 | ) 12 | 13 | var ( 14 | ErrWrongSockType = errors.New("Wrong socket type") 15 | ErrShortResponse = errors.New("Got short response from netlink") 16 | ) 17 | 18 | // A Route is a subnet associated with the interface to reach it. 19 | type Route struct { 20 | *net.IPNet 21 | Iface *net.Interface 22 | Default bool 23 | } 24 | -------------------------------------------------------------------------------- /vendor/src/github.com/coreos/fleet/Godeps/_workspace/src/github.com/docker/libcontainer/netlink/netlink_unsupported.go: -------------------------------------------------------------------------------- 1 | // +build !linux !amd64 2 | 3 | package netlink 4 | 5 | import ( 6 | "errors" 7 | "net" 8 | ) 9 | 10 | var ( 11 | ErrNotImplemented = errors.New("not implemented") 12 | ) 13 | 14 | func NetworkGetRoutes() ([]Route, error) { 15 | return nil, ErrNotImplemented 16 | } 17 | 18 | func NetworkLinkAdd(name string, linkType string) error { 19 | return ErrNotImplemented 20 | } 21 | 22 | func NetworkLinkUp(iface *net.Interface) error { 23 | return ErrNotImplemented 24 | } 25 | 26 | func NetworkLinkAddIp(iface *net.Interface, ip net.IP, ipNet *net.IPNet) error { 27 | return ErrNotImplemented 28 | } 29 | 30 | func AddRoute(destination, source, gateway, device string) error { 31 | return ErrNotImplemented 32 | } 33 | 34 | func AddDefaultGw(ip, device string) error { 35 | return ErrNotImplemented 36 | } 37 | 38 | func NetworkSetMTU(iface *net.Interface, mtu int) error { 39 | return ErrNotImplemented 40 | } 41 | 42 | func NetworkCreateVethPair(name1, name2 string) error { 43 | return ErrNotImplemented 44 | } 45 | 46 | func NetworkChangeName(iface *net.Interface, newName string) error { 47 | return ErrNotImplemented 48 | } 49 | 50 | func NetworkSetNsFd(iface *net.Interface, fd int) error { 51 | return ErrNotImplemented 52 | } 53 | 54 | func NetworkSetNsPid(iface *net.Interface, nspid int) error { 55 | return ErrNotImplemented 56 | } 57 | 58 | func NetworkSetMaster(iface, master *net.Interface) error { 59 | return ErrNotImplemented 60 | } 61 | 62 | func NetworkLinkDown(iface *net.Interface) error { 63 | return ErrNotImplemented 64 | } 65 | 66 | func CreateBridge(name string, setMacAddr bool) error { 67 | return ErrNotImplemented 68 | } 69 | 70 | func AddToBridge(iface, master *net.Interface) error { 71 | return ErrNotImplemented 72 | } 73 | -------------------------------------------------------------------------------- /vendor/src/github.com/coreos/fleet/Godeps/_workspace/src/github.com/godbus/dbus/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2013, Georg Reinke () 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions 6 | are met: 7 | 8 | 1. Redistributions of source code must retain the above copyright notice, 9 | this list of conditions and the following disclaimer. 10 | 11 | 2. Redistributions in binary form must reproduce the above copyright 12 | notice, this list of conditions and the following disclaimer in the 13 | documentation and/or other materials provided with the distribution. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 16 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 17 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 18 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 19 | HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 20 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 21 | TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 22 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 23 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 24 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | -------------------------------------------------------------------------------- /vendor/src/github.com/coreos/fleet/Godeps/_workspace/src/github.com/godbus/dbus/README.markdown: -------------------------------------------------------------------------------- 1 | dbus 2 | ---- 3 | 4 | dbus is a simple library that implements native Go client bindings for the 5 | D-Bus message bus system. 6 | 7 | ### Features 8 | 9 | * Complete native implementation of the D-Bus message protocol 10 | * Go-like API (channels for signals / asynchronous method calls, Goroutine-safe connections) 11 | * Subpackages that help with the introspection / property interfaces 12 | 13 | ### Installation 14 | 15 | This packages requires Go 1.1. If you installed it and set up your GOPATH, just run: 16 | 17 | ``` 18 | go get github.com/godbus/dbus 19 | ``` 20 | 21 | If you want to use the subpackages, you can install them the same way. 22 | 23 | ### Usage 24 | 25 | The complete package documentation and some simple examples are available at 26 | [godoc.org](http://godoc.org/github.com/godbus/dbus). Also, the 27 | [_examples](https://github.com/godbus/dbus/tree/master/_examples) directory 28 | gives a short overview over the basic usage. 29 | 30 | Please note that the API is considered unstable for now and may change without 31 | further notice. 32 | 33 | ### License 34 | 35 | go.dbus is available under the Simplified BSD License; see LICENSE for the full 36 | text. 37 | 38 | Nearly all of the credit for this library goes to github.com/guelfey/go.dbus. 39 | -------------------------------------------------------------------------------- /vendor/src/github.com/coreos/fleet/Godeps/_workspace/src/github.com/godbus/dbus/auth_external.go: -------------------------------------------------------------------------------- 1 | package dbus 2 | 3 | import ( 4 | "encoding/hex" 5 | ) 6 | 7 | // AuthExternal returns an Auth that authenticates as the given user with the 8 | // EXTERNAL mechanism. 9 | func AuthExternal(user string) Auth { 10 | return authExternal{user} 11 | } 12 | 13 | // AuthExternal implements the EXTERNAL authentication mechanism. 14 | type authExternal struct { 15 | user string 16 | } 17 | 18 | func (a authExternal) FirstData() ([]byte, []byte, AuthStatus) { 19 | b := make([]byte, 2*len(a.user)) 20 | hex.Encode(b, []byte(a.user)) 21 | return []byte("EXTERNAL"), b, AuthOk 22 | } 23 | 24 | func (a authExternal) HandleData(b []byte) ([]byte, AuthStatus) { 25 | return nil, AuthError 26 | } 27 | -------------------------------------------------------------------------------- /vendor/src/github.com/coreos/fleet/Godeps/_workspace/src/github.com/godbus/dbus/conn_darwin.go: -------------------------------------------------------------------------------- 1 | package dbus 2 | 3 | import ( 4 | "errors" 5 | "os/exec" 6 | ) 7 | 8 | func sessionBusPlatform() (*Conn, error) { 9 | cmd := exec.Command("launchctl", "getenv", "DBUS_LAUNCHD_SESSION_BUS_SOCKET") 10 | b, err := cmd.CombinedOutput() 11 | 12 | if err != nil { 13 | return nil, err 14 | } 15 | 16 | if len(b) == 0 { 17 | return nil, errors.New("dbus: couldn't determine address of session bus") 18 | } 19 | 20 | return Dial("unix:path=" + string(b[:len(b)-1])) 21 | } 22 | -------------------------------------------------------------------------------- /vendor/src/github.com/coreos/fleet/Godeps/_workspace/src/github.com/godbus/dbus/conn_other.go: -------------------------------------------------------------------------------- 1 | // +build !darwin 2 | 3 | package dbus 4 | 5 | import ( 6 | "bytes" 7 | "errors" 8 | "os/exec" 9 | ) 10 | 11 | func sessionBusPlatform() (*Conn, error) { 12 | cmd := exec.Command("dbus-launch") 13 | b, err := cmd.CombinedOutput() 14 | 15 | if err != nil { 16 | return nil, err 17 | } 18 | 19 | i := bytes.IndexByte(b, '=') 20 | j := bytes.IndexByte(b, '\n') 21 | 22 | if i == -1 || j == -1 { 23 | return nil, errors.New("dbus: couldn't determine address of session bus") 24 | } 25 | 26 | return Dial(string(b[i+1 : j])) 27 | } 28 | -------------------------------------------------------------------------------- /vendor/src/github.com/coreos/fleet/Godeps/_workspace/src/github.com/godbus/dbus/examples_test.go: -------------------------------------------------------------------------------- 1 | package dbus 2 | 3 | import "fmt" 4 | 5 | func ExampleConn_Emit() { 6 | conn, err := SessionBus() 7 | if err != nil { 8 | panic(err) 9 | } 10 | 11 | conn.Emit("/foo/bar", "foo.bar.Baz", uint32(0xDAEDBEEF)) 12 | } 13 | 14 | func ExampleObject_Call() { 15 | var list []string 16 | 17 | conn, err := SessionBus() 18 | if err != nil { 19 | panic(err) 20 | } 21 | 22 | err = conn.BusObject().Call("org.freedesktop.DBus.ListNames", 0).Store(&list) 23 | if err != nil { 24 | panic(err) 25 | } 26 | for _, v := range list { 27 | fmt.Println(v) 28 | } 29 | } 30 | 31 | func ExampleObject_Go() { 32 | conn, err := SessionBus() 33 | if err != nil { 34 | panic(err) 35 | } 36 | 37 | ch := make(chan *Call, 10) 38 | conn.BusObject().Go("org.freedesktop.DBus.ListActivatableNames", 0, ch) 39 | select { 40 | case call := <-ch: 41 | if call.Err != nil { 42 | panic(err) 43 | } 44 | list := call.Body[0].([]string) 45 | for _, v := range list { 46 | fmt.Println(v) 47 | } 48 | // put some other cases here 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /vendor/src/github.com/coreos/fleet/Godeps/_workspace/src/github.com/godbus/dbus/homedir.go: -------------------------------------------------------------------------------- 1 | package dbus 2 | 3 | import ( 4 | "os" 5 | "sync" 6 | ) 7 | 8 | var ( 9 | homeDir string 10 | homeDirLock sync.Mutex 11 | ) 12 | 13 | func getHomeDir() string { 14 | homeDirLock.Lock() 15 | defer homeDirLock.Unlock() 16 | 17 | if homeDir != "" { 18 | return homeDir 19 | } 20 | 21 | homeDir = os.Getenv("HOME") 22 | if homeDir != "" { 23 | return homeDir 24 | } 25 | 26 | homeDir = lookupHomeDir() 27 | return homeDir 28 | } 29 | -------------------------------------------------------------------------------- /vendor/src/github.com/coreos/fleet/Godeps/_workspace/src/github.com/godbus/dbus/homedir_dynamic.go: -------------------------------------------------------------------------------- 1 | // +build !static_build 2 | 3 | package dbus 4 | 5 | import ( 6 | "os/user" 7 | ) 8 | 9 | func lookupHomeDir() string { 10 | u, err := user.Current() 11 | if err != nil { 12 | return "/" 13 | } 14 | return u.HomeDir 15 | } 16 | -------------------------------------------------------------------------------- /vendor/src/github.com/coreos/fleet/Godeps/_workspace/src/github.com/godbus/dbus/homedir_static.go: -------------------------------------------------------------------------------- 1 | // +build static_build 2 | 3 | package dbus 4 | 5 | import ( 6 | "bufio" 7 | "os" 8 | "strconv" 9 | "strings" 10 | ) 11 | 12 | func lookupHomeDir() string { 13 | myUid := os.Getuid() 14 | 15 | f, err := os.Open("/etc/passwd") 16 | if err != nil { 17 | return "/" 18 | } 19 | defer f.Close() 20 | 21 | s := bufio.NewScanner(f) 22 | 23 | for s.Scan() { 24 | if err := s.Err(); err != nil { 25 | break 26 | } 27 | 28 | line := strings.TrimSpace(s.Text()) 29 | if line == "" { 30 | continue 31 | } 32 | 33 | parts := strings.Split(line, ":") 34 | 35 | if len(parts) >= 6 { 36 | uid, err := strconv.Atoi(parts[2]) 37 | if err == nil && uid == myUid { 38 | return parts[5] 39 | } 40 | } 41 | } 42 | 43 | // Default to / if we can't get a better value 44 | return "/" 45 | } 46 | -------------------------------------------------------------------------------- /vendor/src/github.com/coreos/fleet/Godeps/_workspace/src/github.com/godbus/dbus/introspect/call.go: -------------------------------------------------------------------------------- 1 | package introspect 2 | 3 | import ( 4 | "encoding/xml" 5 | "github.com/coreos/fleet/Godeps/_workspace/src/github.com/godbus/dbus" 6 | "strings" 7 | ) 8 | 9 | // Call calls org.freedesktop.Introspectable.Introspect on a remote object 10 | // and returns the introspection data. 11 | func Call(o *dbus.Object) (*Node, error) { 12 | var xmldata string 13 | var node Node 14 | 15 | err := o.Call("org.freedesktop.DBus.Introspectable.Introspect", 0).Store(&xmldata) 16 | if err != nil { 17 | return nil, err 18 | } 19 | err = xml.NewDecoder(strings.NewReader(xmldata)).Decode(&node) 20 | if err != nil { 21 | return nil, err 22 | } 23 | if node.Name == "" { 24 | node.Name = string(o.Path()) 25 | } 26 | return &node, nil 27 | } 28 | -------------------------------------------------------------------------------- /vendor/src/github.com/coreos/fleet/Godeps/_workspace/src/github.com/godbus/dbus/sig_test.go: -------------------------------------------------------------------------------- 1 | package dbus 2 | 3 | import ( 4 | "testing" 5 | ) 6 | 7 | var sigTests = []struct { 8 | vs []interface{} 9 | sig Signature 10 | }{ 11 | { 12 | []interface{}{new(int32)}, 13 | Signature{"i"}, 14 | }, 15 | { 16 | []interface{}{new(string)}, 17 | Signature{"s"}, 18 | }, 19 | { 20 | []interface{}{new(Signature)}, 21 | Signature{"g"}, 22 | }, 23 | { 24 | []interface{}{new([]int16)}, 25 | Signature{"an"}, 26 | }, 27 | { 28 | []interface{}{new(int16), new(uint32)}, 29 | Signature{"nu"}, 30 | }, 31 | { 32 | []interface{}{new(map[byte]Variant)}, 33 | Signature{"a{yv}"}, 34 | }, 35 | { 36 | []interface{}{new(Variant), new([]map[int32]string)}, 37 | Signature{"vaa{is}"}, 38 | }, 39 | } 40 | 41 | func TestSig(t *testing.T) { 42 | for i, v := range sigTests { 43 | sig := SignatureOf(v.vs...) 44 | if sig != v.sig { 45 | t.Errorf("test %d: got %q, expected %q", i+1, sig.str, v.sig.str) 46 | } 47 | } 48 | } 49 | 50 | var getSigTest = []interface{}{ 51 | []struct { 52 | b byte 53 | i int32 54 | t uint64 55 | s string 56 | }{}, 57 | map[string]Variant{}, 58 | } 59 | 60 | func BenchmarkGetSignatureSimple(b *testing.B) { 61 | for i := 0; i < b.N; i++ { 62 | SignatureOf("", int32(0)) 63 | } 64 | } 65 | 66 | func BenchmarkGetSignatureLong(b *testing.B) { 67 | for i := 0; i < b.N; i++ { 68 | SignatureOf(getSigTest...) 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /vendor/src/github.com/coreos/fleet/Godeps/_workspace/src/github.com/godbus/dbus/transport_darwin.go: -------------------------------------------------------------------------------- 1 | package dbus 2 | 3 | func (t *unixTransport) SendNullByte() error { 4 | _, err := t.Write([]byte{0}) 5 | return err 6 | } 7 | -------------------------------------------------------------------------------- /vendor/src/github.com/coreos/fleet/Godeps/_workspace/src/github.com/godbus/dbus/transport_generic.go: -------------------------------------------------------------------------------- 1 | package dbus 2 | 3 | import ( 4 | "encoding/binary" 5 | "errors" 6 | "io" 7 | ) 8 | 9 | type genericTransport struct { 10 | io.ReadWriteCloser 11 | } 12 | 13 | func (t genericTransport) SendNullByte() error { 14 | _, err := t.Write([]byte{0}) 15 | return err 16 | } 17 | 18 | func (t genericTransport) SupportsUnixFDs() bool { 19 | return false 20 | } 21 | 22 | func (t genericTransport) EnableUnixFDs() {} 23 | 24 | func (t genericTransport) ReadMessage() (*Message, error) { 25 | return DecodeMessage(t) 26 | } 27 | 28 | func (t genericTransport) SendMessage(msg *Message) error { 29 | for _, v := range msg.Body { 30 | if _, ok := v.(UnixFD); ok { 31 | return errors.New("dbus: unix fd passing not enabled") 32 | } 33 | } 34 | return msg.EncodeTo(t, binary.LittleEndian) 35 | } 36 | -------------------------------------------------------------------------------- /vendor/src/github.com/coreos/fleet/Godeps/_workspace/src/github.com/godbus/dbus/transport_unix_test.go: -------------------------------------------------------------------------------- 1 | package dbus 2 | 3 | import ( 4 | "os" 5 | "testing" 6 | ) 7 | 8 | const testString = `This is a test! 9 | This text should be read from the file that is created by this test.` 10 | 11 | type unixFDTest struct{} 12 | 13 | func (t unixFDTest) Test(fd UnixFD) (string, *Error) { 14 | var b [4096]byte 15 | file := os.NewFile(uintptr(fd), "testfile") 16 | defer file.Close() 17 | n, err := file.Read(b[:]) 18 | if err != nil { 19 | return "", &Error{"com.github.guelfey.test.Error", nil} 20 | } 21 | return string(b[:n]), nil 22 | } 23 | 24 | func TestUnixFDs(t *testing.T) { 25 | conn, err := SessionBus() 26 | if err != nil { 27 | t.Fatal(err) 28 | } 29 | r, w, err := os.Pipe() 30 | if err != nil { 31 | t.Fatal(err) 32 | } 33 | defer w.Close() 34 | if _, err := w.Write([]byte(testString)); err != nil { 35 | t.Fatal(err) 36 | } 37 | name := conn.Names()[0] 38 | test := unixFDTest{} 39 | conn.Export(test, "/com/github/guelfey/test", "com.github.guelfey.test") 40 | var s string 41 | obj := conn.Object(name, "/com/github/guelfey/test") 42 | err = obj.Call("com.github.guelfey.test.Test", 0, UnixFD(r.Fd())).Store(&s) 43 | if err != nil { 44 | t.Fatal(err) 45 | } 46 | if s != testString { 47 | t.Fatal("got", s, "wanted", testString) 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /vendor/src/github.com/coreos/fleet/Godeps/_workspace/src/github.com/godbus/dbus/transport_unixcred_linux.go: -------------------------------------------------------------------------------- 1 | // The UnixCredentials system call is currently only implemented on Linux 2 | // http://golang.org/src/pkg/syscall/sockcmsg_linux.go 3 | // https://golang.org/s/go1.4-syscall 4 | // http://code.google.com/p/go/source/browse/unix/sockcmsg_linux.go?repo=sys 5 | 6 | package dbus 7 | 8 | import ( 9 | "io" 10 | "os" 11 | "syscall" 12 | ) 13 | 14 | func (t *unixTransport) SendNullByte() error { 15 | ucred := &syscall.Ucred{Pid: int32(os.Getpid()), Uid: uint32(os.Getuid()), Gid: uint32(os.Getgid())} 16 | b := syscall.UnixCredentials(ucred) 17 | _, oobn, err := t.UnixConn.WriteMsgUnix([]byte{0}, b, nil) 18 | if err != nil { 19 | return err 20 | } 21 | if oobn != len(b) { 22 | return io.ErrShortWrite 23 | } 24 | return nil 25 | } 26 | -------------------------------------------------------------------------------- /vendor/src/github.com/coreos/fleet/Godeps/_workspace/src/github.com/jonboulle/clockwork/README.md: -------------------------------------------------------------------------------- 1 | clockwork 2 | ========= 3 | 4 | [![Build Status](https://travis-ci.org/jonboulle/clockwork.png?branch=master)](https://travis-ci.org/jonboulle/clockwork) 5 | [![godoc](https://godoc.org/github.com/jonboulle/clockwork?status.svg)](http://godoc.org/github.com/jonboulle/clockwork) 6 | 7 | a simple fake clock for golang 8 | 9 | # Usage 10 | 11 | Replace uses of the `time` package with the `clockwork.Clock` interface instead. 12 | 13 | For example, instead of using `time.Sleep` directly: 14 | 15 | ``` 16 | func my_func() { 17 | time.Sleep(3 * time.Second) 18 | do_something() 19 | } 20 | ``` 21 | 22 | inject a clock and use its `Sleep` method instead: 23 | 24 | ``` 25 | func my_func(clock clockwork.Clock) { 26 | clock.Sleep(3 * time.Second) 27 | do_something() 28 | } 29 | ``` 30 | 31 | Now you can easily test `my_func` with a `FakeClock`: 32 | 33 | ``` 34 | func TestMyFunc(t *testing.T) { 35 | c := clockwork.NewFakeClock() 36 | 37 | // Start our sleepy function 38 | my_func(c) 39 | 40 | // Ensure we wait until my_func is sleeping 41 | c.BlockUntil(1) 42 | 43 | assert_state() 44 | 45 | // Advance the FakeClock forward in time 46 | c.Advance(3) 47 | 48 | assert_state() 49 | } 50 | ``` 51 | 52 | and in production builds, simply inject the real clock instead: 53 | ``` 54 | my_func(clockwork.NewRealClock()) 55 | ``` 56 | 57 | See [example_test.go](example_test.go) for a full example. 58 | 59 | # Credits 60 | 61 | clockwork is inspired by @wickman's [threaded fake clock](https://gist.github.com/wickman/3840816), and the [Golang playground](http://blog.golang.org/playground#Faking time) 62 | -------------------------------------------------------------------------------- /vendor/src/github.com/coreos/fleet/Godeps/_workspace/src/github.com/jonboulle/clockwork/example_test.go: -------------------------------------------------------------------------------- 1 | package clockwork 2 | 3 | import ( 4 | "sync" 5 | "testing" 6 | "time" 7 | ) 8 | 9 | // my_func is an example of a time-dependent function, using an 10 | // injected clock 11 | func my_func(clock Clock, i *int) { 12 | clock.Sleep(3 * time.Second) 13 | *i += 1 14 | } 15 | 16 | // assert_state is an example of a state assertion in a test 17 | func assert_state(t *testing.T, i, j int) { 18 | if i != j { 19 | t.Fatalf("i %d, j %d", i, j) 20 | } 21 | } 22 | 23 | // TestMyFunc tests my_func's behaviour with a FakeClock 24 | func TestMyFunc(t *testing.T) { 25 | var i int 26 | c := NewFakeClock() 27 | 28 | var wg sync.WaitGroup 29 | wg.Add(1) 30 | go func() { 31 | my_func(c, &i) 32 | wg.Done() 33 | }() 34 | 35 | // Wait until my_func is actually sleeping on the clock 36 | c.BlockUntil(1) 37 | 38 | // Assert the initial state 39 | assert_state(t, i, 0) 40 | 41 | // Now advance the clock forward in time 42 | c.Advance(1 * time.Hour) 43 | 44 | // Wait until the function completes 45 | wg.Wait() 46 | 47 | // Assert the final state 48 | assert_state(t, i, 1) 49 | } 50 | -------------------------------------------------------------------------------- /vendor/src/github.com/coreos/fleet/Godeps/_workspace/src/github.com/rakyll/globalconf/testdata/custom.ini: -------------------------------------------------------------------------------- 1 | [custom] 2 | d = Hello d 3 | -------------------------------------------------------------------------------- /vendor/src/github.com/coreos/fleet/Godeps/_workspace/src/github.com/rakyll/globalconf/testdata/global.ini: -------------------------------------------------------------------------------- 1 | a = true 2 | b = 5.6 3 | c = Hello world 4 | -------------------------------------------------------------------------------- /vendor/src/github.com/coreos/fleet/Godeps/_workspace/src/github.com/rakyll/globalconf/testdata/globalandcustom.ini: -------------------------------------------------------------------------------- 1 | a = true 2 | b = 5.6 3 | c = Hello world 4 | 5 | [custom] 6 | d = Hello d 7 | -------------------------------------------------------------------------------- /vendor/src/github.com/coreos/fleet/Godeps/_workspace/src/github.com/rakyll/goini/Makefile: -------------------------------------------------------------------------------- 1 | test: 2 | go test 3 | 4 | format: 5 | gofmt -w *.go 6 | 7 | .PHONY: format test 8 | -------------------------------------------------------------------------------- /vendor/src/github.com/coreos/fleet/Godeps/_workspace/src/github.com/rakyll/goini/empty.ini: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vaijab/kube-apiproxy/bd59de7d5926512b4678c5a9ccd9c523986f9deb/vendor/src/github.com/coreos/fleet/Godeps/_workspace/src/github.com/rakyll/goini/empty.ini -------------------------------------------------------------------------------- /vendor/src/github.com/coreos/fleet/Godeps/_workspace/src/github.com/rakyll/goini/example.ini: -------------------------------------------------------------------------------- 1 | # 2 | # This is an example of ini file 3 | # 4 | 5 | [Pizza] 6 | 7 | Ham = yes; 8 | Mushrooms = TRUE; 9 | Capres = 0; 10 | Cheese = Non; 11 | 12 | 13 | [Wine] 14 | 15 | Grape = Cabernet Sauvignon; 16 | Year = 1989; 17 | Country = Spain; 18 | Alcohol = 12.5; 19 | -------------------------------------------------------------------------------- /vendor/src/github.com/coreos/fleet/Godeps/_workspace/src/golang.org/x/crypto/ssh/agent/server_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2012 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package agent 6 | 7 | import ( 8 | "testing" 9 | 10 | "github.com/coreos/fleet/Godeps/_workspace/src/golang.org/x/crypto/ssh" 11 | ) 12 | 13 | func TestServer(t *testing.T) { 14 | c1, c2, err := netPipe() 15 | if err != nil { 16 | t.Fatalf("netPipe: %v", err) 17 | } 18 | defer c1.Close() 19 | defer c2.Close() 20 | client := NewClient(c1) 21 | 22 | go ServeAgent(NewKeyring(), c2) 23 | 24 | testAgentInterface(t, client, testPrivateKeys["rsa"], nil) 25 | } 26 | 27 | func TestLockServer(t *testing.T) { 28 | testLockAgent(NewKeyring(), t) 29 | } 30 | 31 | func TestSetupForwardAgent(t *testing.T) { 32 | a, b, err := netPipe() 33 | if err != nil { 34 | t.Fatalf("netPipe: %v", err) 35 | } 36 | 37 | defer a.Close() 38 | defer b.Close() 39 | 40 | _, socket, cleanup := startAgent(t) 41 | defer cleanup() 42 | 43 | serverConf := ssh.ServerConfig{ 44 | NoClientAuth: true, 45 | } 46 | serverConf.AddHostKey(testSigners["rsa"]) 47 | incoming := make(chan *ssh.ServerConn, 1) 48 | go func() { 49 | conn, _, _, err := ssh.NewServerConn(a, &serverConf) 50 | if err != nil { 51 | t.Fatalf("Server: %v", err) 52 | } 53 | incoming <- conn 54 | }() 55 | 56 | conf := ssh.ClientConfig{} 57 | conn, chans, reqs, err := ssh.NewClientConn(b, "", &conf) 58 | if err != nil { 59 | t.Fatalf("NewClientConn: %v", err) 60 | } 61 | client := ssh.NewClient(conn, chans, reqs) 62 | 63 | if err := ForwardToRemote(client, socket); err != nil { 64 | t.Fatalf("SetupForwardAgent: %v", err) 65 | } 66 | 67 | server := <-incoming 68 | ch, reqs, err := server.OpenChannel(channelType, nil) 69 | if err != nil { 70 | t.Fatalf("OpenChannel(%q): %v", channelType, err) 71 | } 72 | go ssh.DiscardRequests(reqs) 73 | 74 | agentClient := NewClient(ch) 75 | testAgentInterface(t, agentClient, testPrivateKeys["rsa"], nil) 76 | conn.Close() 77 | } 78 | -------------------------------------------------------------------------------- /vendor/src/github.com/coreos/fleet/Godeps/_workspace/src/golang.org/x/crypto/ssh/cipher_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2011 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package ssh 6 | 7 | import ( 8 | "bytes" 9 | "crypto" 10 | "crypto/rand" 11 | "testing" 12 | ) 13 | 14 | func TestDefaultCiphersExist(t *testing.T) { 15 | for _, cipherAlgo := range supportedCiphers { 16 | if _, ok := cipherModes[cipherAlgo]; !ok { 17 | t.Errorf("default cipher %q is unknown", cipherAlgo) 18 | } 19 | } 20 | } 21 | 22 | func TestPacketCiphers(t *testing.T) { 23 | for cipher := range cipherModes { 24 | kr := &kexResult{Hash: crypto.SHA1} 25 | algs := directionAlgorithms{ 26 | Cipher: cipher, 27 | MAC: "hmac-sha1", 28 | Compression: "none", 29 | } 30 | client, err := newPacketCipher(clientKeys, algs, kr) 31 | if err != nil { 32 | t.Errorf("newPacketCipher(client, %q): %v", cipher, err) 33 | continue 34 | } 35 | server, err := newPacketCipher(clientKeys, algs, kr) 36 | if err != nil { 37 | t.Errorf("newPacketCipher(client, %q): %v", cipher, err) 38 | continue 39 | } 40 | 41 | want := "bla bla" 42 | input := []byte(want) 43 | buf := &bytes.Buffer{} 44 | if err := client.writePacket(0, buf, rand.Reader, input); err != nil { 45 | t.Errorf("writePacket(%q): %v", cipher, err) 46 | continue 47 | } 48 | 49 | packet, err := server.readPacket(0, buf) 50 | if err != nil { 51 | t.Errorf("readPacket(%q): %v", cipher, err) 52 | continue 53 | } 54 | 55 | if string(packet) != want { 56 | t.Errorf("roundtrip(%q): got %q, want %q", cipher, packet, want) 57 | } 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /vendor/src/github.com/coreos/fleet/Godeps/_workspace/src/golang.org/x/crypto/ssh/client_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package ssh 6 | 7 | import ( 8 | "net" 9 | "testing" 10 | ) 11 | 12 | func testClientVersion(t *testing.T, config *ClientConfig, expected string) { 13 | clientConn, serverConn := net.Pipe() 14 | defer clientConn.Close() 15 | receivedVersion := make(chan string, 1) 16 | go func() { 17 | version, err := readVersion(serverConn) 18 | if err != nil { 19 | receivedVersion <- "" 20 | } else { 21 | receivedVersion <- string(version) 22 | } 23 | serverConn.Close() 24 | }() 25 | NewClientConn(clientConn, "", config) 26 | actual := <-receivedVersion 27 | if actual != expected { 28 | t.Fatalf("got %s; want %s", actual, expected) 29 | } 30 | } 31 | 32 | func TestCustomClientVersion(t *testing.T) { 33 | version := "Test-Client-Version-0.0" 34 | testClientVersion(t, &ClientConfig{ClientVersion: version}, version) 35 | } 36 | 37 | func TestDefaultClientVersion(t *testing.T) { 38 | testClientVersion(t, &ClientConfig{}, packageVersion) 39 | } 40 | -------------------------------------------------------------------------------- /vendor/src/github.com/coreos/fleet/Godeps/_workspace/src/golang.org/x/crypto/ssh/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2011 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | /* 6 | Package ssh implements an SSH client and server. 7 | 8 | SSH is a transport security protocol, an authentication protocol and a 9 | family of application protocols. The most typical application level 10 | protocol is a remote shell and this is specifically implemented. However, 11 | the multiplexed nature of SSH is exposed to users that wish to support 12 | others. 13 | 14 | References: 15 | [PROTOCOL.certkeys]: http://www.openbsd.org/cgi-bin/cvsweb/src/usr.bin/ssh/PROTOCOL.certkeys 16 | [SSH-PARAMETERS]: http://www.iana.org/assignments/ssh-parameters/ssh-parameters.xml#ssh-parameters-1 17 | */ 18 | package ssh 19 | -------------------------------------------------------------------------------- /vendor/src/github.com/coreos/fleet/Godeps/_workspace/src/golang.org/x/crypto/ssh/kex_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package ssh 6 | 7 | // Key exchange tests. 8 | 9 | import ( 10 | "crypto/rand" 11 | "reflect" 12 | "testing" 13 | ) 14 | 15 | func TestKexes(t *testing.T) { 16 | type kexResultErr struct { 17 | result *kexResult 18 | err error 19 | } 20 | 21 | for name, kex := range kexAlgoMap { 22 | a, b := memPipe() 23 | 24 | s := make(chan kexResultErr, 1) 25 | c := make(chan kexResultErr, 1) 26 | var magics handshakeMagics 27 | go func() { 28 | r, e := kex.Client(a, rand.Reader, &magics) 29 | c <- kexResultErr{r, e} 30 | }() 31 | go func() { 32 | r, e := kex.Server(b, rand.Reader, &magics, testSigners["ecdsa"]) 33 | s <- kexResultErr{r, e} 34 | }() 35 | 36 | clientRes := <-c 37 | serverRes := <-s 38 | if clientRes.err != nil { 39 | t.Errorf("client: %v", clientRes.err) 40 | } 41 | if serverRes.err != nil { 42 | t.Errorf("server: %v", serverRes.err) 43 | } 44 | if !reflect.DeepEqual(clientRes.result, serverRes.result) { 45 | t.Errorf("kex %q: mismatch %#v, %#v", name, clientRes.result, serverRes.result) 46 | } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /vendor/src/github.com/coreos/fleet/Godeps/_workspace/src/golang.org/x/crypto/ssh/mac.go: -------------------------------------------------------------------------------- 1 | // Copyright 2012 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package ssh 6 | 7 | // Message authentication support 8 | 9 | import ( 10 | "crypto/hmac" 11 | "crypto/sha1" 12 | "hash" 13 | ) 14 | 15 | type macMode struct { 16 | keySize int 17 | new func(key []byte) hash.Hash 18 | } 19 | 20 | // truncatingMAC wraps around a hash.Hash and truncates the output digest to 21 | // a given size. 22 | type truncatingMAC struct { 23 | length int 24 | hmac hash.Hash 25 | } 26 | 27 | func (t truncatingMAC) Write(data []byte) (int, error) { 28 | return t.hmac.Write(data) 29 | } 30 | 31 | func (t truncatingMAC) Sum(in []byte) []byte { 32 | out := t.hmac.Sum(in) 33 | return out[:len(in)+t.length] 34 | } 35 | 36 | func (t truncatingMAC) Reset() { 37 | t.hmac.Reset() 38 | } 39 | 40 | func (t truncatingMAC) Size() int { 41 | return t.length 42 | } 43 | 44 | func (t truncatingMAC) BlockSize() int { return t.hmac.BlockSize() } 45 | 46 | var macModes = map[string]*macMode{ 47 | "hmac-sha1": {20, func(key []byte) hash.Hash { 48 | return hmac.New(sha1.New, key) 49 | }}, 50 | "hmac-sha1-96": {20, func(key []byte) hash.Hash { 51 | return truncatingMAC{12, hmac.New(sha1.New, key)} 52 | }}, 53 | } 54 | -------------------------------------------------------------------------------- /vendor/src/github.com/coreos/fleet/Godeps/_workspace/src/golang.org/x/crypto/ssh/tcpip_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package ssh 6 | 7 | import ( 8 | "testing" 9 | ) 10 | 11 | func TestAutoPortListenBroken(t *testing.T) { 12 | broken := "SSH-2.0-OpenSSH_5.9hh11" 13 | works := "SSH-2.0-OpenSSH_6.1" 14 | if !isBrokenOpenSSHVersion(broken) { 15 | t.Errorf("version %q not marked as broken", broken) 16 | } 17 | if isBrokenOpenSSHVersion(works) { 18 | t.Errorf("version %q marked as broken", works) 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /vendor/src/github.com/coreos/fleet/Godeps/_workspace/src/golang.org/x/crypto/ssh/terminal/util_bsd.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build darwin dragonfly freebsd netbsd openbsd 6 | 7 | package terminal 8 | 9 | import "syscall" 10 | 11 | const ioctlReadTermios = syscall.TIOCGETA 12 | const ioctlWriteTermios = syscall.TIOCSETA 13 | -------------------------------------------------------------------------------- /vendor/src/github.com/coreos/fleet/Godeps/_workspace/src/golang.org/x/crypto/ssh/terminal/util_linux.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package terminal 6 | 7 | // These constants are declared here, rather than importing 8 | // them from the syscall package as some syscall packages, even 9 | // on linux, for example gccgo, do not declare them. 10 | const ioctlReadTermios = 0x5401 // syscall.TCGETS 11 | const ioctlWriteTermios = 0x5402 // syscall.TCSETS 12 | -------------------------------------------------------------------------------- /vendor/src/github.com/coreos/fleet/Godeps/_workspace/src/golang.org/x/crypto/ssh/test/agent_unix_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build darwin dragonfly freebsd linux netbsd openbsd 6 | 7 | package test 8 | 9 | import ( 10 | "bytes" 11 | "testing" 12 | 13 | "github.com/coreos/fleet/Godeps/_workspace/src/golang.org/x/crypto/ssh" 14 | "github.com/coreos/fleet/Godeps/_workspace/src/golang.org/x/crypto/ssh/agent" 15 | ) 16 | 17 | func TestAgentForward(t *testing.T) { 18 | server := newServer(t) 19 | defer server.Shutdown() 20 | conn := server.Dial(clientConfig()) 21 | defer conn.Close() 22 | 23 | keyring := agent.NewKeyring() 24 | keyring.Add(testPrivateKeys["dsa"], nil, "") 25 | pub := testPublicKeys["dsa"] 26 | 27 | sess, err := conn.NewSession() 28 | if err != nil { 29 | t.Fatalf("NewSession: %v", err) 30 | } 31 | if err := agent.RequestAgentForwarding(sess); err != nil { 32 | t.Fatalf("RequestAgentForwarding: %v", err) 33 | } 34 | 35 | if err := agent.ForwardToAgent(conn, keyring); err != nil { 36 | t.Fatalf("SetupForwardKeyring: %v", err) 37 | } 38 | out, err := sess.CombinedOutput("ssh-add -L") 39 | if err != nil { 40 | t.Fatalf("running ssh-add: %v, out %s", err, out) 41 | } 42 | key, _, _, _, err := ssh.ParseAuthorizedKey(out) 43 | if err != nil { 44 | t.Fatalf("ParseAuthorizedKey(%q): %v", out, err) 45 | } 46 | 47 | if !bytes.Equal(key.Marshal(), pub.Marshal()) { 48 | t.Fatalf("got key %s, want %s", ssh.MarshalAuthorizedKey(key), ssh.MarshalAuthorizedKey(pub)) 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /vendor/src/github.com/coreos/fleet/Godeps/_workspace/src/golang.org/x/crypto/ssh/test/cert_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build darwin dragonfly freebsd linux netbsd openbsd 6 | 7 | package test 8 | 9 | import ( 10 | "crypto/rand" 11 | "testing" 12 | 13 | "github.com/coreos/fleet/Godeps/_workspace/src/golang.org/x/crypto/ssh" 14 | ) 15 | 16 | func TestCertLogin(t *testing.T) { 17 | s := newServer(t) 18 | defer s.Shutdown() 19 | 20 | // Use a key different from the default. 21 | clientKey := testSigners["dsa"] 22 | caAuthKey := testSigners["ecdsa"] 23 | cert := &ssh.Certificate{ 24 | Key: clientKey.PublicKey(), 25 | ValidPrincipals: []string{username()}, 26 | CertType: ssh.UserCert, 27 | ValidBefore: ssh.CertTimeInfinity, 28 | } 29 | if err := cert.SignCert(rand.Reader, caAuthKey); err != nil { 30 | t.Fatalf("SetSignature: %v", err) 31 | } 32 | 33 | certSigner, err := ssh.NewCertSigner(cert, clientKey) 34 | if err != nil { 35 | t.Fatalf("NewCertSigner: %v", err) 36 | } 37 | 38 | conf := &ssh.ClientConfig{ 39 | User: username(), 40 | } 41 | conf.Auth = append(conf.Auth, ssh.PublicKeys(certSigner)) 42 | client, err := s.TryDial(conf) 43 | if err != nil { 44 | t.Fatalf("TryDial: %v", err) 45 | } 46 | client.Close() 47 | } 48 | -------------------------------------------------------------------------------- /vendor/src/github.com/coreos/fleet/Godeps/_workspace/src/golang.org/x/crypto/ssh/test/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2012 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // This package contains integration tests for the 6 | // code.google.com/p/go.crypto/ssh package. 7 | package test 8 | -------------------------------------------------------------------------------- /vendor/src/github.com/coreos/fleet/Godeps/_workspace/src/golang.org/x/crypto/ssh/test/tcpip_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2012 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !windows 6 | 7 | package test 8 | 9 | // direct-tcpip functional tests 10 | 11 | import ( 12 | "io" 13 | "net" 14 | "testing" 15 | ) 16 | 17 | func TestDial(t *testing.T) { 18 | server := newServer(t) 19 | defer server.Shutdown() 20 | sshConn := server.Dial(clientConfig()) 21 | defer sshConn.Close() 22 | 23 | l, err := net.Listen("tcp", "127.0.0.1:0") 24 | if err != nil { 25 | t.Fatalf("Listen: %v", err) 26 | } 27 | defer l.Close() 28 | 29 | go func() { 30 | for { 31 | c, err := l.Accept() 32 | if err != nil { 33 | break 34 | } 35 | 36 | io.WriteString(c, c.RemoteAddr().String()) 37 | c.Close() 38 | } 39 | }() 40 | 41 | conn, err := sshConn.Dial("tcp", l.Addr().String()) 42 | if err != nil { 43 | t.Fatalf("Dial: %v", err) 44 | } 45 | defer conn.Close() 46 | } 47 | -------------------------------------------------------------------------------- /vendor/src/github.com/coreos/fleet/Godeps/_workspace/src/golang.org/x/crypto/ssh/testdata/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // This package contains test data shared between the various subpackages of 6 | // the code.google.com/p/go.crypto/ssh package. Under no circumstance should 7 | // this data be used for production code. 8 | package testdata 9 | -------------------------------------------------------------------------------- /vendor/src/github.com/coreos/fleet/Godeps/_workspace/src/golang.org/x/crypto/ssh/testdata/keys.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package testdata 6 | 7 | var PEMBytes = map[string][]byte{ 8 | "dsa": []byte(`-----BEGIN DSA PRIVATE KEY----- 9 | MIIBuwIBAAKBgQD6PDSEyXiI9jfNs97WuM46MSDCYlOqWw80ajN16AohtBncs1YB 10 | lHk//dQOvCYOsYaE+gNix2jtoRjwXhDsc25/IqQbU1ahb7mB8/rsaILRGIbA5WH3 11 | EgFtJmXFovDz3if6F6TzvhFpHgJRmLYVR8cqsezL3hEZOvvs2iH7MorkxwIVAJHD 12 | nD82+lxh2fb4PMsIiaXudAsBAoGAQRf7Q/iaPRn43ZquUhd6WwvirqUj+tkIu6eV 13 | 2nZWYmXLlqFQKEy4Tejl7Wkyzr2OSYvbXLzo7TNxLKoWor6ips0phYPPMyXld14r 14 | juhT24CrhOzuLMhDduMDi032wDIZG4Y+K7ElU8Oufn8Sj5Wge8r6ANmmVgmFfynr 15 | FhdYCngCgYEA3ucGJ93/Mx4q4eKRDxcWD3QzWyqpbRVRRV1Vmih9Ha/qC994nJFz 16 | DQIdjxDIT2Rk2AGzMqFEB68Zc3O+Wcsmz5eWWzEwFxaTwOGWTyDqsDRLm3fD+QYj 17 | nOwuxb0Kce+gWI8voWcqC9cyRm09jGzu2Ab3Bhtpg8JJ8L7gS3MRZK4CFEx4UAfY 18 | Fmsr0W6fHB9nhS4/UXM8 19 | -----END DSA PRIVATE KEY----- 20 | `), 21 | "ecdsa": []byte(`-----BEGIN EC PRIVATE KEY----- 22 | MHcCAQEEINGWx0zo6fhJ/0EAfrPzVFyFC9s18lBt3cRoEDhS3ARooAoGCCqGSM49 23 | AwEHoUQDQgAEi9Hdw6KvZcWxfg2IDhA7UkpDtzzt6ZqJXSsFdLd+Kx4S3Sx4cVO+ 24 | 6/ZOXRnPmNAlLUqjShUsUBBngG0u2fqEqA== 25 | -----END EC PRIVATE KEY----- 26 | `), 27 | "rsa": []byte(`-----BEGIN RSA PRIVATE KEY----- 28 | MIIBOwIBAAJBALdGZxkXDAjsYk10ihwU6Id2KeILz1TAJuoq4tOgDWxEEGeTrcld 29 | r/ZwVaFzjWzxaf6zQIJbfaSEAhqD5yo72+sCAwEAAQJBAK8PEVU23Wj8mV0QjwcJ 30 | tZ4GcTUYQL7cF4+ezTCE9a1NrGnCP2RuQkHEKxuTVrxXt+6OF15/1/fuXnxKjmJC 31 | nxkCIQDaXvPPBi0c7vAxGwNY9726x01/dNbHCE0CBtcotobxpwIhANbbQbh3JHVW 32 | 2haQh4fAG5mhesZKAGcxTyv4mQ7uMSQdAiAj+4dzMpJWdSzQ+qGHlHMIBvVHLkqB 33 | y2VdEyF7DPCZewIhAI7GOI/6LDIFOvtPo6Bj2nNmyQ1HU6k/LRtNIXi4c9NJAiAr 34 | rrxx26itVhJmcvoUhOjwuzSlP2bE5VHAvkGB352YBg== 35 | -----END RSA PRIVATE KEY----- 36 | `), 37 | "user": []byte(`-----BEGIN EC PRIVATE KEY----- 38 | MHcCAQEEILYCAeq8f7V4vSSypRw7pxy8yz3V5W4qg8kSC3zJhqpQoAoGCCqGSM49 39 | AwEHoUQDQgAEYcO2xNKiRUYOLEHM7VYAp57HNyKbOdYtHD83Z4hzNPVC4tM5mdGD 40 | PLL8IEwvYu2wq+lpXfGQnNMbzYf9gspG0w== 41 | -----END EC PRIVATE KEY----- 42 | `), 43 | } 44 | -------------------------------------------------------------------------------- /vendor/src/github.com/coreos/fleet/Godeps/_workspace/src/google.golang.org/api/google-api-go-generator/gen_test.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "bytes" 5 | "flag" 6 | "io/ioutil" 7 | "path/filepath" 8 | "testing" 9 | ) 10 | 11 | var updateGolden = flag.Bool("update_golden", false, "If true, causes TestAPIs to update golden files") 12 | 13 | func TestAPIs(t *testing.T) { 14 | names := []string{ 15 | "arrayofarray-1", 16 | "arrayofmapofobjects", 17 | "arrayofmapofstrings", 18 | "blogger-3", 19 | "getwithoutbody", 20 | "mapofany", 21 | "mapofarrayofobjects", 22 | "mapofobjects", 23 | "mapofstrings-1", 24 | "quotednum", 25 | "resource-named-service", // blogger/v3/blogger-api.json + s/BlogUserInfo/Service/ 26 | "variants", 27 | } 28 | for _, name := range names { 29 | api, err := apiFromFile(filepath.Join("testdata", name+".json")) 30 | if err != nil { 31 | t.Errorf("Error loading API testdata/%s.json: %v", name, err) 32 | continue 33 | } 34 | clean, err := api.GenerateCode() 35 | if err != nil { 36 | t.Errorf("Error generating code for %s: %v", name, err) 37 | continue 38 | } 39 | goldenFile := filepath.Join("testdata", name+".want") 40 | if *updateGolden { 41 | if err := ioutil.WriteFile(goldenFile, clean, 0644); err != nil { 42 | t.Fatal(err) 43 | } 44 | } 45 | want, err := ioutil.ReadFile(goldenFile) 46 | if err != nil { 47 | t.Error(err) 48 | continue 49 | } 50 | if !bytes.Equal(want, clean) { 51 | tf, _ := ioutil.TempFile("", "api-"+name+"-got-json.") 52 | tf.Write(clean) 53 | tf.Close() 54 | t.Errorf("Output for API %s differs: diff -u %s %s", name, goldenFile, tf.Name()) 55 | } 56 | } 57 | } 58 | 59 | func TestScope(t *testing.T) { 60 | tests := [][]string{ 61 | { 62 | "https://www.googleapis.com/auth/somescope", 63 | "SomescopeScope", 64 | }, 65 | { 66 | "https://mail.google.com/somescope", 67 | "MailGoogleComSomescopeScope", 68 | }, 69 | { 70 | "https://mail.google.com/", 71 | "MailGoogleComScope", 72 | }, 73 | } 74 | for _, test := range tests { 75 | if got := scopeIdentifierFromURL(test[0]); got != test[1] { 76 | t.Errorf("scopeIdentifierFromURL(%q) got %q, want %q", test[0], got, test[1]) 77 | } 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /vendor/src/github.com/coreos/fleet/Godeps/_workspace/src/google.golang.org/api/google-api-go-generator/testdata/arrayofarray-1.json: -------------------------------------------------------------------------------- 1 | { 2 | "kind": "discovery#restDescription", 3 | "etag": "\"kEk3sFj6Ef5_yR1-H3bAO6qw9mI/3m5rB86FE5KuW1K3jAl88AxCreg\"", 4 | "discoveryVersion": "v1", 5 | "id": "arrayofarray:v1", 6 | "name": "arrayofarray", 7 | "version": "v1", 8 | "title": "Example API", 9 | "description": "The Example API demonstrates an array of arrays.", 10 | "ownerDomain": "google.com", 11 | "ownerName": "Google", 12 | "protocol": "rest", 13 | "schemas": { 14 | "GeoJsonMultiPolygon": { 15 | "id": "GeoJsonMultiPolygon", 16 | "type": "object", 17 | "description": "Multi Polygon", 18 | "properties": { 19 | "coordinates": { 20 | "type": "array", 21 | "description": "Coordinate arrays.", 22 | "items": { 23 | "type": "array", 24 | "items": { 25 | "type": "array", 26 | "items": { 27 | "type": "array", 28 | "items": { 29 | "type": "number", 30 | "format": "double" 31 | } 32 | } 33 | } 34 | } 35 | }, 36 | "type": { 37 | "type": "string", 38 | "description": "Identifies this object as a multi-polygon.", 39 | "enum": [ 40 | "MultiPolygon" 41 | ], 42 | "enumDescriptions": [ 43 | "" 44 | ] 45 | } 46 | } 47 | } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /vendor/src/github.com/coreos/fleet/Godeps/_workspace/src/google.golang.org/api/google-api-go-generator/testdata/arrayofarray-1.want: -------------------------------------------------------------------------------- 1 | // Package arrayofarray provides access to the Example API. 2 | // 3 | // Usage example: 4 | // 5 | // import "google.golang.org/api/arrayofarray/v1" 6 | // ... 7 | // arrayofarrayService, err := arrayofarray.New(oauthHttpClient) 8 | package arrayofarray 9 | 10 | import ( 11 | "bytes" 12 | "google.golang.org/api/googleapi" 13 | "encoding/json" 14 | "errors" 15 | "fmt" 16 | "io" 17 | "net/http" 18 | "net/url" 19 | "strconv" 20 | "strings" 21 | ) 22 | 23 | // Always reference these packages, just in case the auto-generated code 24 | // below doesn't. 25 | var _ = bytes.NewBuffer 26 | var _ = strconv.Itoa 27 | var _ = fmt.Sprintf 28 | var _ = json.NewDecoder 29 | var _ = io.Copy 30 | var _ = url.Parse 31 | var _ = googleapi.Version 32 | var _ = errors.New 33 | var _ = strings.Replace 34 | 35 | const apiId = "arrayofarray:v1" 36 | const apiName = "arrayofarray" 37 | const apiVersion = "v1" 38 | const basePath = "https://www.googleapis.com/discovery/v1/apis" 39 | 40 | func New(client *http.Client) (*Service, error) { 41 | if client == nil { 42 | return nil, errors.New("client is nil") 43 | } 44 | s := &Service{client: client, BasePath: basePath} 45 | return s, nil 46 | } 47 | 48 | type Service struct { 49 | client *http.Client 50 | BasePath string // API endpoint base URL 51 | } 52 | 53 | type GeoJsonMultiPolygon struct { 54 | // Coordinates: Coordinate arrays. 55 | Coordinates [][][][]float64 `json:"coordinates,omitempty"` 56 | 57 | // Type: Identifies this object as a multi-polygon. 58 | Type string `json:"type,omitempty"` 59 | } 60 | -------------------------------------------------------------------------------- /vendor/src/github.com/coreos/fleet/Godeps/_workspace/src/google.golang.org/api/google-api-go-generator/testdata/arrayofmapofobjects.json: -------------------------------------------------------------------------------- 1 | { 2 | "kind": "discovery#restDescription", 3 | "etag": "\"kEk3sFj6Ef5_yR1-H3bAO6qw9mI/3m5rB86FE5KuW1K3jAl88AxCreg\"", 4 | "discoveryVersion": "v1", 5 | "id": "arrayofmapofstrings:v1", 6 | "name": "arrayofmapofstrings", 7 | "version": "v1", 8 | "title": "Example API", 9 | "description": "The Example API demonstrates an array of arrays.", 10 | "ownerDomain": "google.com", 11 | "ownerName": "Google", 12 | "protocol": "rest", 13 | "schemas": { 14 | "Analyze": { 15 | "id": "Analyze", 16 | "type": "object", 17 | "properties": { 18 | "errors": { 19 | "type": "array", 20 | "description": "List of errors with the data.", 21 | "items": { 22 | "type": "object", 23 | "additionalProperties": { 24 | "$ref": "Property", 25 | "description": "Error level followed by a detailed error message." 26 | } 27 | } 28 | } 29 | } 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /vendor/src/github.com/coreos/fleet/Godeps/_workspace/src/google.golang.org/api/google-api-go-generator/testdata/arrayofmapofobjects.want: -------------------------------------------------------------------------------- 1 | // Package arrayofmapofstrings provides access to the Example API. 2 | // 3 | // Usage example: 4 | // 5 | // import "google.golang.org/api/arrayofmapofstrings/v1" 6 | // ... 7 | // arrayofmapofstringsService, err := arrayofmapofstrings.New(oauthHttpClient) 8 | package arrayofmapofstrings 9 | 10 | import ( 11 | "bytes" 12 | "google.golang.org/api/googleapi" 13 | "encoding/json" 14 | "errors" 15 | "fmt" 16 | "io" 17 | "net/http" 18 | "net/url" 19 | "strconv" 20 | "strings" 21 | ) 22 | 23 | // Always reference these packages, just in case the auto-generated code 24 | // below doesn't. 25 | var _ = bytes.NewBuffer 26 | var _ = strconv.Itoa 27 | var _ = fmt.Sprintf 28 | var _ = json.NewDecoder 29 | var _ = io.Copy 30 | var _ = url.Parse 31 | var _ = googleapi.Version 32 | var _ = errors.New 33 | var _ = strings.Replace 34 | 35 | const apiId = "arrayofmapofstrings:v1" 36 | const apiName = "arrayofmapofstrings" 37 | const apiVersion = "v1" 38 | const basePath = "https://www.googleapis.com/discovery/v1/apis" 39 | 40 | func New(client *http.Client) (*Service, error) { 41 | if client == nil { 42 | return nil, errors.New("client is nil") 43 | } 44 | s := &Service{client: client, BasePath: basePath} 45 | return s, nil 46 | } 47 | 48 | type Service struct { 49 | client *http.Client 50 | BasePath string // API endpoint base URL 51 | } 52 | 53 | type Analyze struct { 54 | // Errors: List of errors with the data. 55 | Errors []map[string]Property `json:"errors,omitempty"` 56 | } 57 | -------------------------------------------------------------------------------- /vendor/src/github.com/coreos/fleet/Godeps/_workspace/src/google.golang.org/api/google-api-go-generator/testdata/arrayofmapofstrings.json: -------------------------------------------------------------------------------- 1 | { 2 | "kind": "discovery#restDescription", 3 | "etag": "\"kEk3sFj6Ef5_yR1-H3bAO6qw9mI/3m5rB86FE5KuW1K3jAl88AxCreg\"", 4 | "discoveryVersion": "v1", 5 | "id": "arrayofmapofstrings:v1", 6 | "name": "arrayofmapofstrings", 7 | "version": "v1", 8 | "title": "Example API", 9 | "description": "The Example API demonstrates an array of arrays.", 10 | "ownerDomain": "google.com", 11 | "ownerName": "Google", 12 | "protocol": "rest", 13 | "schemas": { 14 | "Analyze": { 15 | "id": "Analyze", 16 | "type": "object", 17 | "properties": { 18 | "errors": { 19 | "type": "array", 20 | "description": "List of errors with the data.", 21 | "items": { 22 | "type": "object", 23 | "additionalProperties": { 24 | "type": "string", 25 | "description": "Error level followed by a detailed error message." 26 | } 27 | } 28 | } 29 | } 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /vendor/src/github.com/coreos/fleet/Godeps/_workspace/src/google.golang.org/api/google-api-go-generator/testdata/arrayofmapofstrings.want: -------------------------------------------------------------------------------- 1 | // Package arrayofmapofstrings provides access to the Example API. 2 | // 3 | // Usage example: 4 | // 5 | // import "google.golang.org/api/arrayofmapofstrings/v1" 6 | // ... 7 | // arrayofmapofstringsService, err := arrayofmapofstrings.New(oauthHttpClient) 8 | package arrayofmapofstrings 9 | 10 | import ( 11 | "bytes" 12 | "google.golang.org/api/googleapi" 13 | "encoding/json" 14 | "errors" 15 | "fmt" 16 | "io" 17 | "net/http" 18 | "net/url" 19 | "strconv" 20 | "strings" 21 | ) 22 | 23 | // Always reference these packages, just in case the auto-generated code 24 | // below doesn't. 25 | var _ = bytes.NewBuffer 26 | var _ = strconv.Itoa 27 | var _ = fmt.Sprintf 28 | var _ = json.NewDecoder 29 | var _ = io.Copy 30 | var _ = url.Parse 31 | var _ = googleapi.Version 32 | var _ = errors.New 33 | var _ = strings.Replace 34 | 35 | const apiId = "arrayofmapofstrings:v1" 36 | const apiName = "arrayofmapofstrings" 37 | const apiVersion = "v1" 38 | const basePath = "https://www.googleapis.com/discovery/v1/apis" 39 | 40 | func New(client *http.Client) (*Service, error) { 41 | if client == nil { 42 | return nil, errors.New("client is nil") 43 | } 44 | s := &Service{client: client, BasePath: basePath} 45 | return s, nil 46 | } 47 | 48 | type Service struct { 49 | client *http.Client 50 | BasePath string // API endpoint base URL 51 | } 52 | 53 | type Analyze struct { 54 | // Errors: List of errors with the data. 55 | Errors []map[string]string `json:"errors,omitempty"` 56 | } 57 | -------------------------------------------------------------------------------- /vendor/src/github.com/coreos/fleet/Godeps/_workspace/src/google.golang.org/api/google-api-go-generator/testdata/mapofany.json: -------------------------------------------------------------------------------- 1 | { 2 | "kind": "discovery#restDescription", 3 | "etag": "\"kEk3sFj6Ef5_yR1-H3bAO6qw9mI/3m5rB86FE5KuW1K3jAl88AxCreg\"", 4 | "discoveryVersion": "v1", 5 | "id": "mapofany:v1", 6 | "name": "mapofany", 7 | "version": "v1", 8 | "title": "Example API", 9 | "description": "The Example API demonstrates an associative array.", 10 | "ownerDomain": "google.com", 11 | "ownerName": "Google", 12 | "protocol": "rest", 13 | "schemas": { 14 | "TableDataInsertAllRequest": { 15 | "id": "TableDataInsertAllRequest", 16 | "type": "object", 17 | "properties": { 18 | "kind": { 19 | "type": "string", 20 | "description": "The resource type of the response.", 21 | "default": "bigquery#tableDataInsertAllRequest" 22 | }, 23 | "rows": { 24 | "type": "array", 25 | "description": "The rows to insert.", 26 | "items": { 27 | "type": "object", 28 | "properties": { 29 | "json": { 30 | "$ref": "JsonObject", 31 | "description": "[Required] A JSON object that contains a row of data. The object's properties and values must match the destination table's schema." 32 | } 33 | } 34 | } 35 | } 36 | } 37 | }, 38 | "JsonObject": { 39 | "id": "JsonObject", 40 | "type": "object", 41 | "description": "Represents a single JSON object.", 42 | "additionalProperties": { 43 | "$ref": "JsonValue" 44 | } 45 | }, 46 | "JsonValue": { 47 | "id": "JsonValue", 48 | "type": "any" 49 | } 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /vendor/src/github.com/coreos/fleet/Godeps/_workspace/src/google.golang.org/api/google-api-go-generator/testdata/mapofany.want: -------------------------------------------------------------------------------- 1 | // Package mapofany provides access to the Example API. 2 | // 3 | // Usage example: 4 | // 5 | // import "google.golang.org/api/mapofany/v1" 6 | // ... 7 | // mapofanyService, err := mapofany.New(oauthHttpClient) 8 | package mapofany 9 | 10 | import ( 11 | "bytes" 12 | "google.golang.org/api/googleapi" 13 | "encoding/json" 14 | "errors" 15 | "fmt" 16 | "io" 17 | "net/http" 18 | "net/url" 19 | "strconv" 20 | "strings" 21 | ) 22 | 23 | // Always reference these packages, just in case the auto-generated code 24 | // below doesn't. 25 | var _ = bytes.NewBuffer 26 | var _ = strconv.Itoa 27 | var _ = fmt.Sprintf 28 | var _ = json.NewDecoder 29 | var _ = io.Copy 30 | var _ = url.Parse 31 | var _ = googleapi.Version 32 | var _ = errors.New 33 | var _ = strings.Replace 34 | 35 | const apiId = "mapofany:v1" 36 | const apiName = "mapofany" 37 | const apiVersion = "v1" 38 | const basePath = "https://www.googleapis.com/discovery/v1/apis" 39 | 40 | func New(client *http.Client) (*Service, error) { 41 | if client == nil { 42 | return nil, errors.New("client is nil") 43 | } 44 | s := &Service{client: client, BasePath: basePath} 45 | return s, nil 46 | } 47 | 48 | type Service struct { 49 | client *http.Client 50 | BasePath string // API endpoint base URL 51 | } 52 | 53 | type JsonValue interface{} 54 | 55 | type TableDataInsertAllRequest struct { 56 | // Kind: The resource type of the response. 57 | Kind string `json:"kind,omitempty"` 58 | 59 | // Rows: The rows to insert. 60 | Rows []*TableDataInsertAllRequestRows `json:"rows,omitempty"` 61 | } 62 | 63 | type TableDataInsertAllRequestRows struct { 64 | // Json: [Required] A JSON object that contains a row of data. The 65 | // object's properties and values must match the destination table's 66 | // schema. 67 | Json map[string]JsonValue `json:"json,omitempty"` 68 | } 69 | -------------------------------------------------------------------------------- /vendor/src/github.com/coreos/fleet/Godeps/_workspace/src/google.golang.org/api/google-api-go-generator/testdata/mapofarrayofobjects.json: -------------------------------------------------------------------------------- 1 | { 2 | "kind": "discovery#restDescription", 3 | "etag": "\"kEk3sFj6Ef5_yR1-H3bAO6qw9mI/3m5rB86FE5KuW1K3jAl88AxCreg\"", 4 | "discoveryVersion": "v1", 5 | "id": "additionalprops:v1", 6 | "name": "additionalprops", 7 | "version": "v1", 8 | "title": "Example API", 9 | "description": "The Example API demonstrates an associative array.", 10 | "ownerDomain": "google.com", 11 | "ownerName": "Google", 12 | "protocol": "rest", 13 | "schemas": { 14 | "TimeseriesDescriptor": { 15 | "id": "TimeseriesDescriptor", 16 | "type": "object", 17 | "description": "The descriptions of a time series.", 18 | "properties": { 19 | "labels": { 20 | "type": "object", 21 | "description": "The set of key-value pairs that describe this time series, including target-specific labels and metric-specific labels.", 22 | "additionalProperties": { 23 | "type": "string", 24 | "description": "The label's name." 25 | } 26 | }, 27 | "metric": { 28 | "type": "string", 29 | "description": "The name of the metric." 30 | }, 31 | "project": { 32 | "type": "string", 33 | "description": "The project ID to which this time series belongs." 34 | }, 35 | "tags": { 36 | "type": "object", 37 | "description": "A map of additional information.", 38 | "additionalProperties": { 39 | "type": "array", 40 | "description": "A string which maps to an array of values.", 41 | "items": { 42 | "$ref": "Property" 43 | } 44 | } 45 | } 46 | } 47 | }, 48 | "GetMapResponse": { 49 | "id": "GetMapResponse", 50 | "type": "object", 51 | "description": "Response of getting a map.", 52 | "additionalProperties": { 53 | "type": "string" 54 | } 55 | } 56 | }, 57 | "resources": { 58 | "atlas": { 59 | "methods": { 60 | "getMap": { 61 | "id": "mapofstrings.getMap", 62 | "path": "map", 63 | "httpMethod": "GET", 64 | "description": "Get a map.", 65 | "response": { 66 | "$ref": "GetMapResponse" 67 | } 68 | } 69 | } 70 | } 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /vendor/src/github.com/coreos/fleet/Godeps/_workspace/src/google.golang.org/api/google-api-go-generator/testdata/mapofobjects.json: -------------------------------------------------------------------------------- 1 | { 2 | "kind": "discovery#restDescription", 3 | "etag": "\"kEk3sFj6Ef5_yR1-H3bAO6qw9mI/3m5rB86FE5KuW1K3jAl88AxCreg\"", 4 | "discoveryVersion": "v1", 5 | "id": "additionalpropsobjs:v1", 6 | "name": "additionalpropsobjs", 7 | "version": "v1", 8 | "title": "Example API", 9 | "description": "The Example API demonstrates an associative array.", 10 | "ownerDomain": "google.com", 11 | "ownerName": "Google", 12 | "protocol": "rest", 13 | "schemas": { 14 | "Entity": { 15 | "id": "Entity", 16 | "type": "object", 17 | "externalTypeName": "apphosting.client.datastoreservice.proto.Entity", 18 | "properties": { 19 | "properties": { 20 | "type": "object", 21 | "description": "The entity's properties.", 22 | "additionalProperties": { 23 | "$ref": "Property", 24 | "description": "The name of the property. Properties with names matching regex \"__.*__\" are reserved. A reserved property name is forbidden in certain documented contexts. The name cannot be \"\"." 25 | } 26 | } 27 | } 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /vendor/src/github.com/coreos/fleet/Godeps/_workspace/src/google.golang.org/api/google-api-go-generator/testdata/mapofobjects.want: -------------------------------------------------------------------------------- 1 | // Package additionalpropsobjs provides access to the Example API. 2 | // 3 | // Usage example: 4 | // 5 | // import "google.golang.org/api/additionalpropsobjs/v1" 6 | // ... 7 | // additionalpropsobjsService, err := additionalpropsobjs.New(oauthHttpClient) 8 | package additionalpropsobjs 9 | 10 | import ( 11 | "bytes" 12 | "google.golang.org/api/googleapi" 13 | "encoding/json" 14 | "errors" 15 | "fmt" 16 | "io" 17 | "net/http" 18 | "net/url" 19 | "strconv" 20 | "strings" 21 | ) 22 | 23 | // Always reference these packages, just in case the auto-generated code 24 | // below doesn't. 25 | var _ = bytes.NewBuffer 26 | var _ = strconv.Itoa 27 | var _ = fmt.Sprintf 28 | var _ = json.NewDecoder 29 | var _ = io.Copy 30 | var _ = url.Parse 31 | var _ = googleapi.Version 32 | var _ = errors.New 33 | var _ = strings.Replace 34 | 35 | const apiId = "additionalpropsobjs:v1" 36 | const apiName = "additionalpropsobjs" 37 | const apiVersion = "v1" 38 | const basePath = "https://www.googleapis.com/discovery/v1/apis" 39 | 40 | func New(client *http.Client) (*Service, error) { 41 | if client == nil { 42 | return nil, errors.New("client is nil") 43 | } 44 | s := &Service{client: client, BasePath: basePath} 45 | return s, nil 46 | } 47 | 48 | type Service struct { 49 | client *http.Client 50 | BasePath string // API endpoint base URL 51 | } 52 | 53 | type Entity struct { 54 | // Properties: The entity's properties. 55 | Properties map[string]Property `json:"properties,omitempty"` 56 | } 57 | -------------------------------------------------------------------------------- /vendor/src/github.com/coreos/fleet/Godeps/_workspace/src/google.golang.org/api/google-api-go-generator/testdata/mapofstrings-1.json: -------------------------------------------------------------------------------- 1 | { 2 | "kind": "discovery#restDescription", 3 | "etag": "\"kEk3sFj6Ef5_yR1-H3bAO6qw9mI/3m5rB86FE5KuW1K3jAl88AxCreg\"", 4 | "discoveryVersion": "v1", 5 | "id": "additionalprops:v1", 6 | "name": "additionalprops", 7 | "version": "v1", 8 | "title": "Example API", 9 | "description": "The Example API demonstrates an associative array.", 10 | "ownerDomain": "google.com", 11 | "ownerName": "Google", 12 | "protocol": "rest", 13 | "schemas": { 14 | "TimeseriesDescriptor": { 15 | "id": "TimeseriesDescriptor", 16 | "type": "object", 17 | "description": "The descriptions of a time series.", 18 | "properties": { 19 | "labels": { 20 | "type": "object", 21 | "description": "The set of key-value pairs that describe this time series, including target-specific labels and metric-specific labels.", 22 | "additionalProperties": { 23 | "type": "string", 24 | "description": "The label's name." 25 | } 26 | }, 27 | "metric": { 28 | "type": "string", 29 | "description": "The name of the metric." 30 | }, 31 | "project": { 32 | "type": "string", 33 | "description": "The project ID to which this time series belongs." 34 | }, 35 | "tags": { 36 | "type": "object", 37 | "description": "A map of additional information.", 38 | "additionalProperties": { 39 | "type": "array", 40 | "description": "A string which maps to an array of values.", 41 | "items": { 42 | "type": "string" 43 | } 44 | } 45 | } 46 | } 47 | }, 48 | "GetMapResponse": { 49 | "id": "GetMapResponse", 50 | "type": "object", 51 | "description": "Response of getting a map.", 52 | "additionalProperties": { 53 | "type": "string" 54 | } 55 | } 56 | }, 57 | "resources": { 58 | "atlas": { 59 | "methods": { 60 | "getMap": { 61 | "id": "mapofstrings.getMap", 62 | "path": "map", 63 | "httpMethod": "GET", 64 | "description": "Get a map.", 65 | "response": { 66 | "$ref": "GetMapResponse" 67 | } 68 | } 69 | } 70 | } 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /vendor/src/github.com/coreos/fleet/Godeps/_workspace/src/google.golang.org/api/google-api-go-generator/testdata/quotednum.want: -------------------------------------------------------------------------------- 1 | // Package adexchangebuyer provides access to the Ad Exchange Buyer API. 2 | // 3 | // See https://developers.google.com/ad-exchange/buyer-rest 4 | // 5 | // Usage example: 6 | // 7 | // import "google.golang.org/api/adexchangebuyer/v1.1" 8 | // ... 9 | // adexchangebuyerService, err := adexchangebuyer.New(oauthHttpClient) 10 | package adexchangebuyer 11 | 12 | import ( 13 | "bytes" 14 | "google.golang.org/api/googleapi" 15 | "encoding/json" 16 | "errors" 17 | "fmt" 18 | "io" 19 | "net/http" 20 | "net/url" 21 | "strconv" 22 | "strings" 23 | ) 24 | 25 | // Always reference these packages, just in case the auto-generated code 26 | // below doesn't. 27 | var _ = bytes.NewBuffer 28 | var _ = strconv.Itoa 29 | var _ = fmt.Sprintf 30 | var _ = json.NewDecoder 31 | var _ = io.Copy 32 | var _ = url.Parse 33 | var _ = googleapi.Version 34 | var _ = errors.New 35 | var _ = strings.Replace 36 | 37 | const apiId = "adexchangebuyer:v1.1" 38 | const apiName = "adexchangebuyer" 39 | const apiVersion = "v1.1" 40 | const basePath = "https://www.googleapis.com/adexchangebuyer/v1.1/" 41 | 42 | // OAuth2 scopes used by this API. 43 | const ( 44 | // Manage your Ad Exchange buyer account configuration 45 | AdexchangeBuyerScope = "https://www.googleapis.com/auth/adexchange.buyer" 46 | ) 47 | 48 | func New(client *http.Client) (*Service, error) { 49 | if client == nil { 50 | return nil, errors.New("client is nil") 51 | } 52 | s := &Service{client: client, BasePath: basePath} 53 | return s, nil 54 | } 55 | 56 | type Service struct { 57 | client *http.Client 58 | BasePath string // API endpoint base URL 59 | } 60 | 61 | type Creative struct { 62 | // AdvertiserId: Detected advertiser id, if any. Read-only. This field 63 | // should not be set in requests. 64 | AdvertiserId googleapi.Int64s `json:"advertiserId,omitempty"` 65 | } 66 | -------------------------------------------------------------------------------- /vendor/src/github.com/coreos/fleet/Godeps/_workspace/src/google.golang.org/api/googleapi/internal/uritemplates/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2013 Joshua Tacoma 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of 4 | this software and associated documentation files (the "Software"), to deal in 5 | the Software without restriction, including without limitation the rights to 6 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 7 | the Software, and to permit persons to whom the Software is furnished to do so, 8 | subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in all 11 | copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 16 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | -------------------------------------------------------------------------------- /vendor/src/github.com/coreos/fleet/Godeps/_workspace/src/google.golang.org/api/googleapi/internal/uritemplates/utils.go: -------------------------------------------------------------------------------- 1 | package uritemplates 2 | 3 | func Expand(path string, expansions map[string]string) (string, error) { 4 | template, err := Parse(path) 5 | if err != nil { 6 | return "", err 7 | } 8 | values := make(map[string]interface{}) 9 | for k, v := range expansions { 10 | values[k] = v 11 | } 12 | return template.Expand(values) 13 | } 14 | -------------------------------------------------------------------------------- /vendor/src/github.com/coreos/fleet/Godeps/_workspace/src/google.golang.org/api/googleapi/transport/apikey.go: -------------------------------------------------------------------------------- 1 | // Copyright 2012 Google Inc. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Package transport contains HTTP transports used to make 6 | // authenticated API requests. 7 | package transport 8 | 9 | import ( 10 | "errors" 11 | "net/http" 12 | ) 13 | 14 | // APIKey is an HTTP Transport which wraps an underlying transport and 15 | // appends an API Key "key" parameter to the URL of outgoing requests. 16 | type APIKey struct { 17 | // Key is the API Key to set on requests. 18 | Key string 19 | 20 | // Transport is the underlying HTTP transport. 21 | // If nil, http.DefaultTransport is used. 22 | Transport http.RoundTripper 23 | } 24 | 25 | func (t *APIKey) RoundTrip(req *http.Request) (*http.Response, error) { 26 | rt := t.Transport 27 | if rt == nil { 28 | rt = http.DefaultTransport 29 | if rt == nil { 30 | return nil, errors.New("googleapi/transport: no Transport specified or available") 31 | } 32 | } 33 | newReq := *req 34 | args := newReq.URL.Query() 35 | args.Set("key", t.Key) 36 | newReq.URL.RawQuery = args.Encode() 37 | return rt.RoundTrip(&newReq) 38 | } 39 | -------------------------------------------------------------------------------- /vendor/src/github.com/coreos/fleet/Godeps/_workspace/src/google.golang.org/api/googleapi/types_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013 Google Inc. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package googleapi 6 | 7 | import ( 8 | "encoding/json" 9 | "reflect" 10 | "testing" 11 | ) 12 | 13 | func TestTypes(t *testing.T) { 14 | type T struct { 15 | I32 Int32s 16 | I64 Int64s 17 | U32 Uint32s 18 | U64 Uint64s 19 | F64 Float64s 20 | } 21 | v := &T{ 22 | I32: Int32s{-1, 2, 3}, 23 | I64: Int64s{-1, 2, 1 << 33}, 24 | U32: Uint32s{1, 2}, 25 | U64: Uint64s{1, 2, 1 << 33}, 26 | F64: Float64s{1.5, 3.33}, 27 | } 28 | got, err := json.Marshal(v) 29 | if err != nil { 30 | t.Fatal(err) 31 | } 32 | want := `{"I32":["-1","2","3"],"I64":["-1","2","8589934592"],"U32":["1","2"],"U64":["1","2","8589934592"],"F64":["1.5","3.33"]}` 33 | if string(got) != want { 34 | t.Fatalf("Marshal mismatch.\n got: %s\nwant: %s\n", got, want) 35 | } 36 | 37 | v2 := new(T) 38 | if err := json.Unmarshal(got, v2); err != nil { 39 | t.Fatalf("Unmarshal: %v", err) 40 | } 41 | if !reflect.DeepEqual(v, v2) { 42 | t.Fatalf("Unmarshal didn't produce same results.\n got: %#v\nwant: %#v\n", v, v2) 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /vendor/src/github.com/coreos/fleet/MAINTAINERS: -------------------------------------------------------------------------------- 1 | Brian Waldon (@bcwaldon) 2 | Jonathan Boulle (@jonboulle) 3 | -------------------------------------------------------------------------------- /vendor/src/github.com/coreos/fleet/NOTICE: -------------------------------------------------------------------------------- 1 | CoreOS Project 2 | Copyright 2014 CoreOS, Inc 3 | 4 | This product includes software developed at CoreOS, Inc. 5 | (http://www.coreos.com/). 6 | -------------------------------------------------------------------------------- /vendor/src/github.com/coreos/fleet/agent/cache.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 CoreOS, Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package agent 16 | 17 | import ( 18 | "encoding/json" 19 | 20 | "github.com/coreos/fleet/job" 21 | ) 22 | 23 | type agentCache map[string]job.JobState 24 | 25 | func (ac *agentCache) MarshalJSON() ([]byte, error) { 26 | type ds struct { 27 | TargetStates map[string]job.JobState 28 | } 29 | data := ds{ 30 | TargetStates: map[string]job.JobState(*ac), 31 | } 32 | return json.Marshal(data) 33 | } 34 | 35 | func (ac *agentCache) setTargetState(jobName string, state job.JobState) { 36 | (*ac)[jobName] = state 37 | } 38 | 39 | func (ac *agentCache) dropTargetState(jobName string) { 40 | delete(*ac, jobName) 41 | } 42 | 43 | func (ac *agentCache) launchedJobs() []string { 44 | jobs := make([]string, 0) 45 | for j, ts := range *ac { 46 | if ts == job.JobStateLaunched { 47 | jobs = append(jobs, j) 48 | } 49 | } 50 | return jobs 51 | } 52 | 53 | func (ac *agentCache) loadedJobs() []string { 54 | jobs := make([]string, 0) 55 | for j, ts := range *ac { 56 | if ts == job.JobStateLoaded { 57 | jobs = append(jobs, j) 58 | } 59 | } 60 | return jobs 61 | } 62 | -------------------------------------------------------------------------------- /vendor/src/github.com/coreos/fleet/api/deserialization_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 CoreOS, Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package api 16 | 17 | import ( 18 | "encoding/json" 19 | "fmt" 20 | "net/http/httptest" 21 | "reflect" 22 | ) 23 | 24 | func assertErrorResponse(rr *httptest.ResponseRecorder, code int) error { 25 | if rr.Code != code { 26 | return fmt.Errorf("expected HTTP code %d, got %d", code, rr.Code) 27 | } 28 | 29 | ctypes := rr.HeaderMap["Content-Type"] 30 | expect := []string{"application/json"} 31 | if !reflect.DeepEqual(expect, ctypes) { 32 | return fmt.Errorf("Expected Content-Type %v, got %v", expect, ctypes) 33 | } 34 | 35 | var eresp errorResponse 36 | dec := json.NewDecoder(rr.Body) 37 | err := dec.Decode(&eresp) 38 | if err != nil { 39 | return fmt.Errorf("unable to decode error entity in body: %v", err) 40 | } 41 | 42 | if eresp.Error.Code != code { 43 | return fmt.Errorf("expected error entity code %d, got %d", code, eresp.Error.Code) 44 | } 45 | 46 | return nil 47 | } 48 | -------------------------------------------------------------------------------- /vendor/src/github.com/coreos/fleet/api/discovery.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 CoreOS, Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package api 16 | 17 | import ( 18 | "fmt" 19 | "net/http" 20 | "path" 21 | 22 | "github.com/coreos/fleet/log" 23 | "github.com/coreos/fleet/schema" 24 | ) 25 | 26 | func wireUpDiscoveryResource(mux *http.ServeMux, prefix string) { 27 | base := path.Join(prefix, "discovery") 28 | dr := discoveryResource{} 29 | mux.Handle(base, &dr) 30 | } 31 | 32 | type discoveryResource struct{} 33 | 34 | func (dr *discoveryResource) ServeHTTP(rw http.ResponseWriter, req *http.Request) { 35 | if req.Method != "GET" { 36 | sendError(rw, http.StatusBadRequest, fmt.Errorf("only HTTP GET supported against this resource")) 37 | return 38 | } 39 | rw.Header().Set("Content-Type", "application/json") 40 | rw.WriteHeader(200) 41 | if _, err := rw.Write([]byte(schema.DiscoveryJSON)); err != nil { 42 | log.Errorf("Failed sending HTTP response body: %v", err) 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /vendor/src/github.com/coreos/fleet/api/discovery_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 CoreOS, Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package api 16 | 17 | import ( 18 | "net/http" 19 | "net/http/httptest" 20 | "testing" 21 | 22 | "github.com/coreos/fleet/schema" 23 | ) 24 | 25 | func TestDiscoveryJson(t *testing.T) { 26 | url := "http://example.com/discovery" 27 | for _, verb := range []string{"POST", "PUT", "DELETE"} { 28 | res := &discoveryResource{} 29 | rw := httptest.NewRecorder() 30 | req, err := http.NewRequest(verb, url, nil) 31 | if err != nil { 32 | t.Fatalf("Failed creating http.Request: %v", err) 33 | } 34 | res.ServeHTTP(rw, req) 35 | if rw.Code != http.StatusBadRequest { 36 | t.Errorf("Expected 400 for %s, got %d", verb, rw.Code) 37 | } 38 | } 39 | res := &discoveryResource{} 40 | rw := httptest.NewRecorder() 41 | req, err := http.NewRequest("GET", url, nil) 42 | if err != nil { 43 | t.Fatalf("Failed creating http.Request: %v", err) 44 | } 45 | res.ServeHTTP(rw, req) 46 | if rw.Code != http.StatusOK { 47 | t.Errorf("Expected 200, got %d", rw.Code) 48 | } 49 | ct := rw.HeaderMap["Content-Type"] 50 | if len(ct) != 1 { 51 | t.Errorf("Response has wrong number of Content-Type values: %v", ct) 52 | } else if ct[0] != "application/json" { 53 | t.Errorf("Expected application/json, got %s", ct) 54 | } 55 | if rw.Body == nil { 56 | t.Error("Received nil response body") 57 | } else { 58 | if rw.Body.String() != schema.DiscoveryJSON { 59 | t.Error("Received unexpected body!") 60 | } 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /vendor/src/github.com/coreos/fleet/api/mux.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 CoreOS, Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package api 16 | 17 | import ( 18 | "net/http" 19 | 20 | "github.com/coreos/fleet/client" 21 | "github.com/coreos/fleet/log" 22 | "github.com/coreos/fleet/registry" 23 | "github.com/coreos/fleet/version" 24 | ) 25 | 26 | func NewServeMux(reg registry.Registry) http.Handler { 27 | sm := http.NewServeMux() 28 | cAPI := &client.RegistryClient{Registry: reg} 29 | 30 | for _, prefix := range []string{"/v1-alpha", "/fleet/v1"} { 31 | wireUpDiscoveryResource(sm, prefix) 32 | wireUpMachinesResource(sm, prefix, cAPI) 33 | wireUpStateResource(sm, prefix, cAPI) 34 | wireUpUnitsResource(sm, prefix, cAPI) 35 | sm.HandleFunc(prefix, methodNotAllowedHandler) 36 | } 37 | 38 | sm.HandleFunc("/", baseHandler) 39 | 40 | hdlr := http.Handler(sm) 41 | hdlr = &loggingMiddleware{hdlr} 42 | hdlr = &serverInfoMiddleware{hdlr} 43 | 44 | return hdlr 45 | } 46 | 47 | type loggingMiddleware struct { 48 | next http.Handler 49 | } 50 | 51 | func (lm *loggingMiddleware) ServeHTTP(rw http.ResponseWriter, req *http.Request) { 52 | log.Debugf("HTTP %s %v", req.Method, req.URL) 53 | lm.next.ServeHTTP(rw, req) 54 | } 55 | 56 | type serverInfoMiddleware struct { 57 | next http.Handler 58 | } 59 | 60 | func (si *serverInfoMiddleware) ServeHTTP(rw http.ResponseWriter, req *http.Request) { 61 | rw.Header().Set("Server", "fleetd/"+version.Version) 62 | si.next.ServeHTTP(rw, req) 63 | } 64 | 65 | func methodNotAllowedHandler(rw http.ResponseWriter, req *http.Request) { 66 | sendError(rw, http.StatusMethodNotAllowed, nil) 67 | } 68 | 69 | func baseHandler(rw http.ResponseWriter, req *http.Request) { 70 | var code int 71 | if req.URL.Path == "/" { 72 | code = http.StatusMethodNotAllowed 73 | } else { 74 | code = http.StatusNotFound 75 | } 76 | 77 | sendError(rw, code, nil) 78 | } 79 | -------------------------------------------------------------------------------- /vendor/src/github.com/coreos/fleet/api/mux_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 CoreOS, Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package api 16 | 17 | import ( 18 | "fmt" 19 | "net/http" 20 | "net/http/httptest" 21 | "testing" 22 | 23 | "github.com/coreos/fleet/registry" 24 | "github.com/coreos/fleet/version" 25 | ) 26 | 27 | func TestDefaultHandlers(t *testing.T) { 28 | tests := []struct { 29 | method string 30 | path string 31 | code int 32 | }{ 33 | {"GET", "/", http.StatusMethodNotAllowed}, 34 | {"GET", "/v1-alpha", http.StatusMethodNotAllowed}, 35 | {"GET", "/fleet/v1", http.StatusMethodNotAllowed}, 36 | {"GET", "/bogus", http.StatusNotFound}, 37 | } 38 | 39 | for i, tt := range tests { 40 | fr := registry.NewFakeRegistry() 41 | hdlr := NewServeMux(fr) 42 | rr := httptest.NewRecorder() 43 | 44 | req, err := http.NewRequest(tt.method, tt.path, nil) 45 | if err != nil { 46 | t.Errorf("case %d: failed setting up http.Request for test: %v", i, err) 47 | continue 48 | } 49 | 50 | hdlr.ServeHTTP(rr, req) 51 | 52 | err = assertErrorResponse(rr, tt.code) 53 | if err != nil { 54 | t.Errorf("case %d: %v", i, err) 55 | } 56 | 57 | wantServer := fmt.Sprintf("fleetd/%s", version.Version) 58 | gotServer := rr.HeaderMap["Server"][0] 59 | if wantServer != gotServer { 60 | t.Errorf("case %d: received incorrect Server header: want=%s, got=%s", i, wantServer, gotServer) 61 | } 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /vendor/src/github.com/coreos/fleet/api/path.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 CoreOS, Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package api 16 | 17 | import ( 18 | "path" 19 | "strings" 20 | 21 | "github.com/coreos/fleet/log" 22 | ) 23 | 24 | func isCollectionPath(base, p string) bool { 25 | return p == base 26 | } 27 | 28 | func isItemPath(base, p string) (item string, matched bool) { 29 | if strings.HasSuffix(p, "/") { 30 | return 31 | } 32 | 33 | var err error 34 | matched, err = path.Match(path.Join(base, "*"), p) 35 | // err will only be non-nil in the event that our pattern is bad, not due 36 | // to user-provided data 37 | if err != nil { 38 | log.Errorf("Failed to determine if %q is an item path: %v", p, err) 39 | matched = false 40 | } else if matched { 41 | item = path.Base(p) 42 | } 43 | 44 | return 45 | } 46 | -------------------------------------------------------------------------------- /vendor/src/github.com/coreos/fleet/api/server.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 CoreOS, Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package api 16 | 17 | import ( 18 | "errors" 19 | "net" 20 | "net/http" 21 | 22 | "github.com/coreos/fleet/log" 23 | ) 24 | 25 | var unavailable = &unavailableHdlr{} 26 | 27 | func NewServer(listeners []net.Listener, hdlr http.Handler) *Server { 28 | return &Server{ 29 | listeners: listeners, 30 | api: hdlr, 31 | cur: unavailable, 32 | } 33 | } 34 | 35 | type Server struct { 36 | listeners []net.Listener 37 | api http.Handler 38 | cur http.Handler 39 | } 40 | 41 | func (s *Server) ServeHTTP(rw http.ResponseWriter, req *http.Request) { 42 | s.cur.ServeHTTP(rw, req) 43 | } 44 | 45 | func (s *Server) Serve() { 46 | for i, _ := range s.listeners { 47 | l := s.listeners[i] 48 | go func() { 49 | err := http.Serve(l, s) 50 | if err != nil { 51 | log.Errorf("Failed serving HTTP on listener: %v", l.Addr()) 52 | } 53 | }() 54 | } 55 | } 56 | 57 | // Available switches the Server's HTTP handler from a generic 503 Unavailable 58 | // response to the actual API. Once the provided channel is closed, the API is 59 | // torn back down and 503 responses are served. 60 | func (s *Server) Available(stop chan bool) { 61 | s.cur = s.api 62 | <-stop 63 | s.cur = unavailable 64 | } 65 | 66 | type unavailableHdlr struct{} 67 | 68 | func (uh *unavailableHdlr) ServeHTTP(rw http.ResponseWriter, req *http.Request) { 69 | sendError(rw, http.StatusServiceUnavailable, errors.New("fleet server unable to communicate with etcd")) 70 | } 71 | -------------------------------------------------------------------------------- /vendor/src/github.com/coreos/fleet/build: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | ORG_PATH="github.com/coreos" 4 | REPO_PATH="${ORG_PATH}/fleet" 5 | 6 | if [ ! -h gopath/src/${REPO_PATH} ]; then 7 | mkdir -p gopath/src/${ORG_PATH} 8 | ln -s ../../../.. gopath/src/${REPO_PATH} || exit 255 9 | fi 10 | 11 | export GOBIN=${PWD}/bin 12 | export GOPATH=${PWD}/gopath 13 | 14 | eval $(go env) 15 | 16 | if [ ${GOOS} = "linux" ]; then 17 | echo "Building fleetd..." 18 | CGO_ENABLED=0 go build -o bin/fleetd -a -installsuffix netgo -ldflags '-s' ${REPO_PATH}/fleetd 19 | else 20 | echo "Not on Linux - skipping fleetd build" 21 | fi 22 | 23 | echo "Building fleetctl..." 24 | CGO_ENABLED=0 go build -o bin/fleetctl -a -installsuffix netgo -ldflags '-s' ${REPO_PATH}/fleetctl 25 | -------------------------------------------------------------------------------- /vendor/src/github.com/coreos/fleet/build-aci: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | 4 | if [ $# -ne 1 ]; then 5 | echo "Usage: $0 tag" >/dev/stderr 6 | exit 1 7 | fi 8 | 9 | tag=$1 10 | 11 | tgt=$(mktemp -d) 12 | 13 | # Build fleet inside 14 | docker run -v $PWD:/opt/fleet google/golang:1.3.1 /bin/bash -c "cd /opt/fleet && ./build" 15 | 16 | # Generate manifest into target tmp dir 17 | cat <${tgt}/manifest 18 | { 19 | "acVersion" : "0.5.1", 20 | "acKind" : "ImageManifest", 21 | "name" : "coreos.com/fleetd", 22 | "labels" : [ 23 | { 24 | "value" : "${tag}", 25 | "name" : "version" 26 | }, 27 | { 28 | "name" : "os", 29 | "value" : "linux" 30 | } 31 | ], 32 | "app" : { 33 | "exec" : [ 34 | "/bin/fleetd" 35 | ], 36 | "user" : "0", 37 | "group" : "0", 38 | "mountPoints" : [ 39 | { 40 | "name" : "machine-id", 41 | "readOnly" : true, 42 | "path" : "/etc/machine-id" 43 | }, 44 | { 45 | "path" : "/run/dbus/system_bus_socket", 46 | "readOnly" : false, 47 | "name" : "dbus-socket" 48 | }, 49 | { 50 | "path" : "/run/fleet/units", 51 | "readOnly" : false, 52 | "name" : "fleet-units" 53 | }, 54 | { 55 | "path" : "/etc/fleet", 56 | "readOnly" : true, 57 | "name" : "etc-fleet" 58 | } 59 | ] 60 | } 61 | } 62 | DF 63 | 64 | # Create dirs and links 65 | mkdir -p $tgt/rootfs/bin 66 | mkdir -p $tgt/rootfs/etc/fleet 67 | mkdir -p $tgt/rootfs/run/dbus 68 | mkdir -p $tgt/rootfs/var 69 | ln -s /run $tgt/rootfs/var/run 70 | 71 | # Generate minimal hosts file 72 | cat <${tgt}/rootfs/etc/hosts 73 | 127.0.0.1 localhost 74 | ::1 localhost ip6-localhost ip6-loopback 75 | DF 76 | 77 | # Copy fleetd binary 78 | cp bin/fleetd $tgt/rootfs/bin 79 | 80 | # Create resolv.conf file 81 | touch $tgt/rootfs/etc/resolv.conf 82 | 83 | # Build ACI 84 | actool build -overwrite $tgt fleetd-${tag}.aci 85 | 86 | # Validate ACI 87 | actool validate fleetd-${tag}.aci 88 | 89 | # Cleanup 90 | rm -rf $tgt 91 | -------------------------------------------------------------------------------- /vendor/src/github.com/coreos/fleet/build-docker: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | docker run -v $PWD:/opt/fleet google/golang:1.3.1 /bin/bash -c "cd /opt/fleet && ./build" 4 | -------------------------------------------------------------------------------- /vendor/src/github.com/coreos/fleet/client/api.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 CoreOS, Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package client 16 | 17 | import ( 18 | "github.com/coreos/fleet/machine" 19 | "github.com/coreos/fleet/schema" 20 | ) 21 | 22 | type API interface { 23 | Machines() ([]machine.MachineState, error) 24 | 25 | Unit(string) (*schema.Unit, error) 26 | Units() ([]*schema.Unit, error) 27 | UnitStates() ([]*schema.UnitState, error) 28 | 29 | SetUnitTargetState(name, target string) error 30 | CreateUnit(*schema.Unit) error 31 | DestroyUnit(string) error 32 | } 33 | -------------------------------------------------------------------------------- /vendor/src/github.com/coreos/fleet/config/config.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 CoreOS, Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package config 16 | 17 | import ( 18 | "strings" 19 | ) 20 | 21 | type Config struct { 22 | EtcdServers []string 23 | EtcdKeyPrefix string 24 | EtcdKeyFile string 25 | EtcdCertFile string 26 | EtcdCAFile string 27 | EtcdRequestTimeout float64 28 | EngineReconcileInterval float64 29 | PublicIP string 30 | Verbosity int 31 | RawMetadata string 32 | AgentTTL string 33 | VerifyUnits bool 34 | AuthorizedKeysFile string 35 | } 36 | 37 | func (c *Config) Metadata() map[string]string { 38 | meta := make(map[string]string, 0) 39 | 40 | for _, pair := range strings.Split(c.RawMetadata, ",") { 41 | parts := strings.SplitN(pair, "=", 2) 42 | if len(parts) != 2 { 43 | continue 44 | } 45 | 46 | key := strings.TrimSpace(parts[0]) 47 | val := strings.TrimSpace(parts[1]) 48 | 49 | meta[key] = val 50 | } 51 | 52 | return meta 53 | } 54 | -------------------------------------------------------------------------------- /vendor/src/github.com/coreos/fleet/config/config_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 CoreOS, Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package config 16 | 17 | import ( 18 | "testing" 19 | ) 20 | 21 | func TestConfigMetadata(t *testing.T) { 22 | raw := "foo=bar, ping=pong" 23 | cfg := Config{RawMetadata: raw} 24 | metadata := cfg.Metadata() 25 | 26 | if len(metadata) != 2 { 27 | t.Errorf("Parsed %d keys, expected 1", len(metadata)) 28 | } 29 | 30 | if metadata["foo"] != "bar" { 31 | t.Errorf("Incorrect value '%s' of key 'foo', expected 'bar'", metadata["foo"]) 32 | } 33 | 34 | if metadata["ping"] != "pong" { 35 | t.Errorf("Incorrect value '%s' of key 'ping', expected 'pong'", metadata["ping"]) 36 | } 37 | } 38 | 39 | func TestConfigMetadataNotSet(t *testing.T) { 40 | cfg := Config{} 41 | metadata := cfg.Metadata() 42 | 43 | if len(metadata) != 0 { 44 | t.Errorf("Parsed %d keys, expected 0", len(metadata)) 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /vendor/src/github.com/coreos/fleet/cover: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | # 3 | # Generate coverage HTML for a package 4 | # e.g. PKG=./unit ./cover 5 | # 6 | 7 | if [ -z "$PKG" ]; then 8 | echo "cover only works with a single package, sorry" 9 | exit 255 10 | fi 11 | 12 | COVEROUT="coverage" 13 | 14 | if ! [ -d "$COVEROUT" ]; then 15 | mkdir "$COVEROUT" 16 | fi 17 | 18 | # strip out slashes and dots 19 | COVERPKG=${PKG//\//} 20 | COVERPKG=${COVERPKG//./} 21 | 22 | # generate arg for "go test" 23 | export COVER="-coverprofile ${COVEROUT}/${COVERPKG}.out" 24 | 25 | source ./test 26 | 27 | go tool cover -html=${COVEROUT}/${COVERPKG}.out 28 | -------------------------------------------------------------------------------- /vendor/src/github.com/coreos/fleet/etcd/error.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 CoreOS, Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package etcd 16 | 17 | import ( 18 | "encoding/json" 19 | "fmt" 20 | "net/http" 21 | ) 22 | 23 | const ( 24 | ErrorKeyNotFound = 100 25 | ErrorNodeExist = 105 26 | ErrorEventIndexCleared = 401 27 | ) 28 | 29 | type Error struct { 30 | ErrorCode int `json:"errorCode"` 31 | Message string `json:"message"` 32 | Cause string `json:"cause"` 33 | Index uint64 `json:"index"` 34 | } 35 | 36 | func (e Error) Error() string { 37 | return fmt.Sprintf("%v: %v (%v) [%v]", e.ErrorCode, e.Message, e.Cause, e.Index) 38 | } 39 | 40 | func unmarshalFailedResponse(resp *http.Response, body []byte) (*Result, error) { 41 | var etcdErr Error 42 | err := json.Unmarshal(body, &etcdErr) 43 | if err != nil { 44 | return nil, err 45 | } 46 | 47 | return nil, etcdErr 48 | } 49 | 50 | func IsKeyNotFound(err error) bool { 51 | e, ok := err.(Error) 52 | return ok && e.ErrorCode == ErrorKeyNotFound 53 | } 54 | 55 | func IsNodeExist(err error) bool { 56 | e, ok := err.(Error) 57 | return ok && e.ErrorCode == ErrorNodeExist 58 | } 59 | -------------------------------------------------------------------------------- /vendor/src/github.com/coreos/fleet/etcd/error_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 CoreOS, Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package etcd 16 | 17 | import ( 18 | "reflect" 19 | "testing" 20 | ) 21 | 22 | func TestUnmarshalFailedResponse(t *testing.T) { 23 | body := "{\"errorCode\":401,\"message\":\"foo\",\"cause\":\"bar\",\"index\":12}" 24 | expect := Error{ErrorCode: 401, Message: "foo", Cause: "bar", Index: 12} 25 | 26 | res, err := unmarshalFailedResponse(nil, []byte(body)) 27 | if res != nil { 28 | t.Errorf("*Result should always be nil") 29 | } 30 | 31 | etcdErr, ok := err.(Error) 32 | if !ok { 33 | t.Fatalf("error should be of type Error") 34 | } 35 | 36 | if !reflect.DeepEqual(etcdErr, err) { 37 | t.Fatalf("returned err %v does not match expected %v", etcdErr, expect) 38 | } 39 | } 40 | 41 | func TestUnmarshalFailedResponseGarbage(t *testing.T) { 42 | res, err := unmarshalFailedResponse(nil, []byte("garbage")) 43 | if res != nil { 44 | t.Errorf("*Result should always be nil") 45 | } 46 | 47 | if _, ok := err.(Error); ok { 48 | t.Fatalf("error should not be of type Error") 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /vendor/src/github.com/coreos/fleet/etcd/result.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 CoreOS, Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package etcd 16 | 17 | import ( 18 | "encoding/json" 19 | "fmt" 20 | "net/http" 21 | "time" 22 | ) 23 | 24 | type Result struct { 25 | Action string `json:"action"` 26 | Node *Node `json:"node"` 27 | PrevNode *Node `json:"prevNode"` 28 | Raw []byte `json:"-"` 29 | } 30 | 31 | func (r *Result) String() string { 32 | return fmt.Sprintf("{Action: %s, Node: %v, PrevNode: %v}", r.Action, r.Node, r.PrevNode) 33 | } 34 | 35 | type Nodes []Node 36 | type Node struct { 37 | Key string `json:"key"` 38 | Value string `json:"value"` 39 | TTL int `json:"ttl"` 40 | Nodes Nodes `json:"nodes"` 41 | ModifiedIndex uint64 `json:"modifiedIndex"` 42 | CreatedIndex uint64 `json:"createdIndex"` 43 | } 44 | 45 | func (n Node) TTLDuration() time.Duration { 46 | dur := time.Duration(n.TTL) * time.Second 47 | if dur < 0 { 48 | dur = 0 49 | } 50 | return dur 51 | } 52 | 53 | func (n *Node) String() string { 54 | return fmt.Sprintf("{Key: %s, CreatedIndex: %d, ModifiedIndex: %d}", n.Key, n.CreatedIndex, n.ModifiedIndex) 55 | } 56 | 57 | func unmarshalSuccessfulResponse(resp *http.Response, body []byte) (*Result, error) { 58 | var res Result 59 | err := json.Unmarshal(body, &res) 60 | if err != nil { 61 | return nil, err 62 | } 63 | 64 | res.Raw = body 65 | return &res, nil 66 | } 67 | -------------------------------------------------------------------------------- /vendor/src/github.com/coreos/fleet/examples/hello.service: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=Hello World 3 | 4 | [Service] 5 | ExecStart=/bin/bash -c "while true; do echo \"Hello, world\"; sleep 1; done" 6 | -------------------------------------------------------------------------------- /vendor/src/github.com/coreos/fleet/examples/ping.service: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=PING 3 | 4 | [Service] 5 | ExecStart=/bin/bash -c "while true; do echo \"ping\"; sleep 1; done" 6 | -------------------------------------------------------------------------------- /vendor/src/github.com/coreos/fleet/examples/pong.service: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=PONG 3 | 4 | [Service] 5 | ExecStart=/bin/bash -c "while true; do echo \"pong\"; sleep 1; done" 6 | 7 | [X-Fleet] 8 | MachineOf=ping.service 9 | -------------------------------------------------------------------------------- /vendor/src/github.com/coreos/fleet/fixtures/authorized_keys: -------------------------------------------------------------------------------- 1 | ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDMmq9hew++XUyYKDRIuq4K3VaVJUaE76LscrJ4Ov+UPJ0nTm0/VH2z0eOX9fQijmZ3c0/uMN03bdTfZG2w4TLYwxkgtIgch6nYG540oeKGHfcx3D/LYQ1isTwlLFelSAnDjaIsiLmxv0XHc4lojhLEtjf1OyHMf06snQscizYTmin29/7qSehf9WBEAPxdMuBGWYMi4yHnDn0cT4b7iowzZ+LQFjhZDthz2WTdSqofHbjPQSLGm65IotCJh8WRROKYPVLqnlZtQV7ntkzxsDSVpv5gsGMfZpuF1LGkQ89p/dCvpShoiklORMDA0Stm0wSemoKkwWvaYTbiyj1ZreXl yicheng.qin@coreos.com 2 | ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA6NF8iallvQVp22WDkTkyrtvp9eWW6A8YVr+kz4TjGYe7gHzIw+niNltGEFHzD8+v1I2YJ6oXevct1YeS0o9HZyN1Q9qgCgzUFtdOKLv6IedplqoPkcmF0aYet2PkEDo3MlTBckFXPITAMzF8dJSIFo9D8HfdOV0IAdx4O7PtixWKn5y2hMNG0zQPyUecp4pzC6kivAIhyfHilFR61RGL+GPXQ2MWZWFYbAGjyiYJnAmCP3NOTd0jMZEnDkbUvxhMmBYSdETk1rRgm+R4LOzFUGaHqHDLKLX+FIPKcF96hrucXzcWyLbIbEgE98OHlnVYCzRdK8jlqm8tehUc9c9WhQ== vagrant insecure public key 3 | -------------------------------------------------------------------------------- /vendor/src/github.com/coreos/fleet/fixtures/bad_known_hosts: -------------------------------------------------------------------------------- 1 | 192.0.2.1ssh-rsaAAAAB3NzaC1yc2EAAAADAQABAAABAQDLksjqug/hlE29QF0YEVNydoqsHX9VeeELn1UqdZAuOYp+DBlQSBbIsb6d8quPQP8WionLFNyd7Z6bxymP7mZBE2Iu0P4G3vIhwbfMINwvAWanxnxAANSlNyeV0oDG1vjsGUGmBPlSunjoDXPvEyo4kkxBFs7dVsaLqqP/3JcxuI+RGsA8cD+JzSir4YlEOlCX96LTm83Pu9fMh8GBoGQBTiReOPm+ecakKXkrV9t7K2U1QJaFJOVGlcvhieXV3UadjfSaeKqJe3cZG8YsZZauSDrHEUwls3jtb94hRizqwokGE/gUyKRCPszefn+hV6wITcHcfGYXCmncRwljoB/D 2 | 192.0.2.2 ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAzJjWHWVDum5WukrlWTYPtPN/Ny8BTXzhHFf89vejOQukQNMPcoohjSOBkrFZXQMLQ0s/RqpTKly1omdo8TgfUE5f7rgegwPhzleuxw/Q/XJJJiiCi7KHSQv9Vs+fNlMr14VsF8JStpKei5jD/moM1Pk/q5asYtY9I4+0rJRq1KbFPR4gTGlCqZApvJWfEHlgQxwlug6zFKaVy3vG04ggvS4GREd6XQeVjAE5cPY31Yrtdgll/BETHAxvy1+ucWxiFy6BNrqPni6XSOkSZc44EEIj4TCRAQdv5nZyd2VKPQHENYLDaC9KkxllZdqNuJuXx9stRv8auwOFRnF+JSk+7Q= 3 | -------------------------------------------------------------------------------- /vendor/src/github.com/coreos/fleet/fixtures/insecure_private_key: -------------------------------------------------------------------------------- 1 | -----BEGIN RSA PRIVATE KEY----- 2 | MIIEogIBAAKCAQEA6NF8iallvQVp22WDkTkyrtvp9eWW6A8YVr+kz4TjGYe7gHzI 3 | w+niNltGEFHzD8+v1I2YJ6oXevct1YeS0o9HZyN1Q9qgCgzUFtdOKLv6IedplqoP 4 | kcmF0aYet2PkEDo3MlTBckFXPITAMzF8dJSIFo9D8HfdOV0IAdx4O7PtixWKn5y2 5 | hMNG0zQPyUecp4pzC6kivAIhyfHilFR61RGL+GPXQ2MWZWFYbAGjyiYJnAmCP3NO 6 | Td0jMZEnDkbUvxhMmBYSdETk1rRgm+R4LOzFUGaHqHDLKLX+FIPKcF96hrucXzcW 7 | yLbIbEgE98OHlnVYCzRdK8jlqm8tehUc9c9WhQIBIwKCAQEA4iqWPJXtzZA68mKd 8 | ELs4jJsdyky+ewdZeNds5tjcnHU5zUYE25K+ffJED9qUWICcLZDc81TGWjHyAqD1 9 | Bw7XpgUwFgeUJwUlzQurAv+/ySnxiwuaGJfhFM1CaQHzfXphgVml+fZUvnJUTvzf 10 | TK2Lg6EdbUE9TarUlBf/xPfuEhMSlIE5keb/Zz3/LUlRg8yDqz5w+QWVJ4utnKnK 11 | iqwZN0mwpwU7YSyJhlT4YV1F3n4YjLswM5wJs2oqm0jssQu/BT0tyEXNDYBLEF4A 12 | sClaWuSJ2kjq7KhrrYXzagqhnSei9ODYFShJu8UWVec3Ihb5ZXlzO6vdNQ1J9Xsf 13 | 4m+2ywKBgQD6qFxx/Rv9CNN96l/4rb14HKirC2o/orApiHmHDsURs5rUKDx0f9iP 14 | cXN7S1uePXuJRK/5hsubaOCx3Owd2u9gD6Oq0CsMkE4CUSiJcYrMANtx54cGH7Rk 15 | EjFZxK8xAv1ldELEyxrFqkbE4BKd8QOt414qjvTGyAK+OLD3M2QdCQKBgQDtx8pN 16 | CAxR7yhHbIWT1AH66+XWN8bXq7l3RO/ukeaci98JfkbkxURZhtxV/HHuvUhnPLdX 17 | 3TwygPBYZFNo4pzVEhzWoTtnEtrFueKxyc3+LjZpuo+mBlQ6ORtfgkr9gBVphXZG 18 | YEzkCD3lVdl8L4cw9BVpKrJCs1c5taGjDgdInQKBgHm/fVvv96bJxc9x1tffXAcj 19 | 3OVdUN0UgXNCSaf/3A/phbeBQe9xS+3mpc4r6qvx+iy69mNBeNZ0xOitIjpjBo2+ 20 | dBEjSBwLk5q5tJqHmy/jKMJL4n9ROlx93XS+njxgibTvU6Fp9w+NOFD/HvxB3Tcz 21 | 6+jJF85D5BNAG3DBMKBjAoGBAOAxZvgsKN+JuENXsST7F89Tck2iTcQIT8g5rwWC 22 | P9Vt74yboe2kDT531w8+egz7nAmRBKNM751U/95P9t88EDacDI/Z2OwnuFQHCPDF 23 | llYOUI+SpLJ6/vURRbHSnnn8a/XG+nzedGH5JGqEJNQsz+xT2axM0/W/CRknmGaJ 24 | kda/AoGANWrLCz708y7VYgAtW2Uf1DPOIYMdvo6fxIB5i9ZfISgcJ/bbCUkFrhoH 25 | +vq/5CIWxCPp0f85R4qxxQ5ihxJ0YDQT9Jpx4TMss4PSavPaBH3RXow5Ohe+bYoQ 26 | NE5OgEXk2wVfZczCZpigBKbKZHNYcelXtTt/nP3rsCuGcM4h53s= 27 | -----END RSA PRIVATE KEY----- 28 | -------------------------------------------------------------------------------- /vendor/src/github.com/coreos/fleet/fleet.conf.sample: -------------------------------------------------------------------------------- 1 | # This config file is INI-formatted 2 | 3 | # Lower the logging threshold. Acceptable values are 0, 1, and 2. A higher 4 | # value corresponds to a lower logging threshold. 5 | # verbosity=0 6 | 7 | # Provide a custom set of etcd endpoints. The default value is determined 8 | # by the underlying go-etcd library. 9 | # etcd_servers=["http://127.0.0.1:4001", "http://127.0.0.1:2379"] 10 | 11 | # Amount of time in seconds to allow a single etcd request before considering it failed. 12 | # etcd_request_timeout=1.0 13 | 14 | # Provide TLS configuration when SSL certificate authentication is enabled in etcd endpoints 15 | # etcd_cafile=/path/to/CAfile 16 | # etcd_keyfile=/path/to/keyfile 17 | # etcd_certfile=/path/to/certfile 18 | 19 | # IP address that should be published with any socket information. By default, 20 | # no IP address is published. 21 | # public_ip="" 22 | 23 | # Comma-delimited key/value pairs that are published to the fleet registry. 24 | # This data can be referenced in unit files to affect scheduling decisions. 25 | # An example could look like: metadata="region=us-west,az=us-west-1" 26 | # metadata="" 27 | 28 | # An Agent will be considered dead if it exceeds this amount of time to 29 | # communicate with the Registry. The agent will attempt a heartbeat at half 30 | # of this value. 31 | # agent_ttl="30s" 32 | 33 | # Interval at which the engine should reconcile the cluster schedule in etcd. 34 | # engine_reconcile_interval=2 35 | -------------------------------------------------------------------------------- /vendor/src/github.com/coreos/fleet/fleetctl/cat.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 CoreOS, Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package main 16 | 17 | import ( 18 | "fmt" 19 | 20 | "github.com/coreos/fleet/schema" 21 | ) 22 | 23 | var ( 24 | cmdCatUnit = &Command{ 25 | Name: "cat", 26 | Summary: "Output the contents of a submitted unit", 27 | Usage: "UNIT", 28 | Description: `Outputs the unit file that is currently loaded in the cluster. Useful to verify 29 | the correct version of a unit is running.`, 30 | Run: runCatUnit, 31 | } 32 | ) 33 | 34 | func runCatUnit(args []string) (exit int) { 35 | if len(args) != 1 { 36 | stderr("One unit file must be provided") 37 | return 1 38 | } 39 | 40 | name := unitNameMangle(args[0]) 41 | u, err := cAPI.Unit(name) 42 | if err != nil { 43 | stderr("Error retrieving Unit %s: %v", name, err) 44 | return 1 45 | } 46 | if u == nil { 47 | stderr("Unit %s not found", name) 48 | return 1 49 | } 50 | 51 | uf := schema.MapSchemaUnitOptionsToUnitFile(u.Options) 52 | 53 | // Must not add a newline here. The contents of the unit file 54 | // must not be modified. 55 | fmt.Print(uf.String()) 56 | 57 | return 58 | } 59 | -------------------------------------------------------------------------------- /vendor/src/github.com/coreos/fleet/fleetctl/destroy.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 CoreOS, Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package main 16 | 17 | var cmdDestroyUnit = &Command{ 18 | Name: "destroy", 19 | Summary: "Destroy one or more units in the cluster", 20 | Usage: "UNIT...", 21 | Description: `Completely remove one or more running or submitted units from the cluster. 22 | 23 | Instructs systemd on the host machine to stop the unit, deferring to systemd 24 | completely for any custom stop directives (i.e. ExecStop option in the unit 25 | file). 26 | 27 | Destroyed units are impossible to start unless re-submitted.`, 28 | Run: runDestroyUnits, 29 | } 30 | 31 | func runDestroyUnits(args []string) (exit int) { 32 | for _, v := range args { 33 | name := unitNameMangle(v) 34 | err := cAPI.DestroyUnit(name) 35 | if err != nil { 36 | continue 37 | } 38 | 39 | stdout("Destroyed %s", name) 40 | } 41 | return 42 | } 43 | -------------------------------------------------------------------------------- /vendor/src/github.com/coreos/fleet/fleetctl/fdforward.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 CoreOS, Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package main 16 | 17 | import ( 18 | "io" 19 | "net" 20 | "os" 21 | ) 22 | 23 | var ( 24 | cmdFDForward = &Command{ 25 | Name: "fd-forward", 26 | Summary: "Proxy stdin and stdout to a unix domain socket", 27 | Usage: "SOCKET", 28 | Description: `fleetctl utilizes fd-forward when --tunnel is used and --endpoint is a unix socket. This command is not intended to be called by users directly.`, 29 | Run: runFDForward, 30 | } 31 | ) 32 | 33 | func runFDForward(args []string) (exit int) { 34 | if len(args) != 1 { 35 | stderr("Provide a single argument") 36 | return 1 37 | } 38 | 39 | to := args[0] 40 | 41 | raddr, err := net.ResolveUnixAddr("unix", to) 42 | if err != nil { 43 | stderr("Unable to use %q as unix address: %v", to, err) 44 | return 1 45 | } 46 | 47 | sock, err := net.DialUnix("unix", nil, raddr) 48 | if err != nil { 49 | stderr("Failed dialing remote address: %v", err) 50 | return 51 | } 52 | defer sock.Close() 53 | 54 | errchan := make(chan error) 55 | go cp(os.Stdout, sock, errchan) 56 | go cp(sock, os.Stdin, errchan) 57 | 58 | select { 59 | case err := <-errchan: 60 | if err != nil { 61 | stderr("Encountered error during copy: %v", err) 62 | return 1 63 | } 64 | } 65 | 66 | return 67 | } 68 | 69 | func cp(to io.Writer, from io.Reader, errchan chan error) { 70 | _, err := io.Copy(to, from) 71 | errchan <- err 72 | } 73 | -------------------------------------------------------------------------------- /vendor/src/github.com/coreos/fleet/fleetctl/list_machines_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 CoreOS, Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package main 16 | 17 | import ( 18 | "testing" 19 | 20 | "github.com/coreos/fleet/machine" 21 | "github.com/coreos/fleet/registry" 22 | ) 23 | 24 | func newTestRegistryForListMachines() registry.Registry { 25 | m := []machine.MachineState{ 26 | machine.MachineState{ID: "mnopqr"}, 27 | machine.MachineState{ID: "abcdef"}, 28 | machine.MachineState{ID: "ghijkl"}, 29 | } 30 | 31 | reg := registry.NewFakeRegistry() 32 | reg.SetMachines(m) 33 | 34 | return reg 35 | } 36 | 37 | func TestListMachinesFieldsToStrings(t *testing.T) { 38 | id := "4d389537d9d14bdabe8be54a9c29f68d" 39 | ip := "192.0.2.1" 40 | metadata := map[string]string{ 41 | "foo": "bar", 42 | "ping": "pong", 43 | } 44 | ver := "v9.9.9" 45 | 46 | ms := &machine.MachineState{ 47 | ID: id, 48 | PublicIP: ip, 49 | Metadata: metadata, 50 | Version: ver, 51 | } 52 | 53 | val := listMachinesFields["machine"](ms, false) 54 | assertEqual(t, "machine", "4d389537...", val) 55 | 56 | val = listMachinesFields["machine"](ms, true) 57 | assertEqual(t, "machine", "4d389537d9d14bdabe8be54a9c29f68d", val) 58 | 59 | val = listMachinesFields["ip"](ms, false) 60 | assertEqual(t, "ip", "192.0.2.1", val) 61 | 62 | val = listMachinesFields["metadata"](ms, false) 63 | assertEqual(t, "metadata", "foo=bar,ping=pong", val) 64 | } 65 | 66 | func TestListMachinesFieldsEmpty(t *testing.T) { 67 | id := "4d389537d9d14bdabe8be54a9c29f68d" 68 | ip := "" 69 | metadata := map[string]string{} 70 | ver := "v9.9.9" 71 | 72 | ms := &machine.MachineState{ 73 | ID: id, 74 | PublicIP: ip, 75 | Metadata: metadata, 76 | Version: ver, 77 | } 78 | 79 | for _, tt := range []string{"ip", "metadata"} { 80 | f := listMachinesFields[tt](ms, false) 81 | assertEqual(t, tt, "-", f) 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /vendor/src/github.com/coreos/fleet/fleetctl/submit.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 CoreOS, Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package main 16 | 17 | var cmdSubmitUnit = &Command{ 18 | Name: "submit", 19 | Summary: "Upload one or more units to the cluster without starting them", 20 | Usage: "UNIT...", 21 | Description: `Upload one or more units to the cluster without starting them. Useful 22 | for validating units before they are started. 23 | 24 | This operation is idempotent; if a named unit already exists in the cluster, it will not be resubmitted. 25 | 26 | Submit a single unit: 27 | fleetctl submit foo.service 28 | 29 | Submit a directory of units with glob matching: 30 | fleetctl submit myservice/*`, 31 | Run: runSubmitUnits, 32 | } 33 | 34 | func init() { 35 | cmdSubmitUnit.Flags.BoolVar(&sharedFlags.Sign, "sign", false, "DEPRECATED - this option cannot be used") 36 | } 37 | 38 | func runSubmitUnits(args []string) (exit int) { 39 | if err := lazyCreateUnits(args); err != nil { 40 | stderr("Error creating units: %v", err) 41 | exit = 1 42 | } 43 | return 44 | } 45 | -------------------------------------------------------------------------------- /vendor/src/github.com/coreos/fleet/fleetctl/unload.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 CoreOS, Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package main 16 | 17 | import ( 18 | "os" 19 | 20 | "github.com/coreos/fleet/job" 21 | "github.com/coreos/fleet/log" 22 | ) 23 | 24 | var ( 25 | cmdUnloadUnit = &Command{ 26 | Name: "unload", 27 | Summary: "Unschedule one or more units in the cluster.", 28 | Usage: "UNIT...", 29 | Run: runUnloadUnit, 30 | } 31 | ) 32 | 33 | func init() { 34 | cmdUnloadUnit.Flags.IntVar(&sharedFlags.BlockAttempts, "block-attempts", 0, "Wait until the units are inactive, performing up to N attempts before giving up. A value of 0 indicates no limit.") 35 | cmdUnloadUnit.Flags.BoolVar(&sharedFlags.NoBlock, "no-block", false, "Do not wait until the units have become inactive before exiting.") 36 | } 37 | 38 | func runUnloadUnit(args []string) (exit int) { 39 | units, err := findUnits(args) 40 | if err != nil { 41 | stderr("%v", err) 42 | return 1 43 | } 44 | 45 | wait := make([]string, 0) 46 | for _, s := range units { 47 | if !suToGlobal(s) { 48 | if job.JobState(s.CurrentState) == job.JobStateInactive { 49 | log.Debugf("Target state of Unit(%s) already %s, skipping.", s.Name, job.JobStateInactive) 50 | continue 51 | } 52 | } 53 | 54 | log.Debugf("Setting target state of Unit(%s) to %s", s.Name, job.JobStateInactive) 55 | cAPI.SetUnitTargetState(s.Name, string(job.JobStateInactive)) 56 | if suToGlobal(s) { 57 | stdout("Triggered global unit %s unload", s.Name) 58 | } else { 59 | wait = append(wait, s.Name) 60 | } 61 | } 62 | 63 | if !sharedFlags.NoBlock { 64 | errchan := waitForUnitStates(wait, job.JobStateInactive, sharedFlags.BlockAttempts, os.Stdout) 65 | for err := range errchan { 66 | stderr("Error waiting for units: %v", err) 67 | exit = 1 68 | } 69 | } else { 70 | for _, name := range wait { 71 | stdout("Triggered unit %s unload", name) 72 | } 73 | } 74 | 75 | return 76 | } 77 | -------------------------------------------------------------------------------- /vendor/src/github.com/coreos/fleet/fleetctl/verify.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 CoreOS, Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package main 16 | 17 | var cmdVerifyUnit = &Command{ 18 | Name: "verify", 19 | Summary: "DEPRECATED - No longer works", 20 | Usage: "UNIT", 21 | Run: runVerifyUnit, 22 | } 23 | 24 | func runVerifyUnit(args []string) (exit int) { 25 | stderr("WARNING: The signed/verified units feature is DEPRECATED and cannot be used.") 26 | return 2 27 | } 28 | -------------------------------------------------------------------------------- /vendor/src/github.com/coreos/fleet/fleetctl/version.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 CoreOS, Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package main 16 | 17 | import ( 18 | "github.com/coreos/fleet/version" 19 | ) 20 | 21 | var cmdVersion = &Command{ 22 | Name: "version", 23 | Description: "Print the version and exit", 24 | Summary: "Print the version and exit", 25 | Run: runVersion, 26 | } 27 | 28 | func runVersion(args []string) (exit int) { 29 | stdout("fleetctl version %s", version.Version) 30 | return 31 | } 32 | -------------------------------------------------------------------------------- /vendor/src/github.com/coreos/fleet/functional/README.md: -------------------------------------------------------------------------------- 1 | ## fleet functional tests 2 | 3 | This functional test suite deploys a fleet cluster using nspawn containers, and asserts fleet is functioning properly. 4 | 5 | It shares an instance of etcd deployed on the host machine with each of the nspawn containers. 6 | 7 | It's recommended to run this in a virtual machine environment on CoreOS (e.g. using coreos-vagrant). The only dependency for the tests not provided on the CoreOS image is `go`. 8 | 9 | The caller must do three things before running the tests: 10 | 11 | 1. Ensure an ssh-agent is running and the functional-testing identity is loaded. The `SSH_AUTH_SOCK` environment variable must be set. 12 | 13 | ``` 14 | $ ssh-agent 15 | $ ssh-add fleet/functional/fixtures/id_rsa 16 | $ echo $SSH_AUTH_SOCK 17 | /tmp/ssh-kwmtTOsL7978/agent.7978 18 | ``` 19 | 2. Ensure the `FLEETD_BIN` and `FLEETCTL_BIN` environment variables point to the respective fleetd and fleetctl binaries that should be used to drive the actual tests. 20 | 21 | ``` 22 | $ export FLEETD_BIN=/path/to/fleetd 23 | $ export FLEETCTL_BIN=/path/to/fleetctl 24 | ``` 25 | 26 | 3. Make sure etcd is running on the host system. 27 | 28 | ``` 29 | $ systemctl start etcd 30 | ``` 31 | 32 | Then the tests can be run with: 33 | 34 | ``` 35 | # go test github.com/coreos/fleet/functional 36 | ``` 37 | 38 | Since the tests utilize `systemd-nspawn`, this needs to be invoked as sudo/root. 39 | 40 | An example test session using coreos-vagrant follows. This assumes that go is available in `/home/core/go` and the fleet repository in `/home/core/fleet` on the target machine (the easiest way to achieve this is to use shared folders). 41 | ``` 42 | vagrant ssh core-01 -- -A 43 | export GOROOT="$(pwd)/go" 44 | export PATH="${GOROOT}/bin:$PATH" 45 | cd fleet 46 | ssh-add functional/fixtures/id_rsa 47 | export GOPATH="$(pwd)/gopath" 48 | export FLEETD_BIN="$(pwd)/bin/fleetd" 49 | export FLEETCTL_BIN="$(pwd)/bin/fleetctl" 50 | sudo -E env PATH=$PATH go test github.com/coreos/fleet/functional -v 51 | ``` 52 | 53 | If the tests are aborted partway through, it's currently possible for them to leave residual state as a result of the systemd-nspawn operations. This can be cleaned up using the `clean.sh` script. 54 | -------------------------------------------------------------------------------- /vendor/src/github.com/coreos/fleet/functional/clean.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # WARNING: This script is destructive and should only be run within the test environment 4 | # 5 | 6 | machinectl --no-legend | cut -d ' ' -f1 | sudo xargs -r machinectl terminate 7 | sudo pkill -9 systemd-nspawn 8 | sudo rm -fr /run/systemd/system/*smoke* /tmp/smoke 9 | sudo systemctl daemon-reload 10 | ip link show fleet0 &>/dev/null && sudo ip link del fleet0 11 | etcdctl rm --recursive /fleet_functional 12 | -------------------------------------------------------------------------------- /vendor/src/github.com/coreos/fleet/functional/fixtures/id_rsa.pub: -------------------------------------------------------------------------------- 1 | ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQCrgZOtFX3mHmqp6cu44YSUa5BmNo2agooYnqHlcR5oIDPVXHwH5wwHXlJtEwTO95+sbmXCPxGDzwA5InVfDfbkDWKyhHPg/E/J5VXnFD9Obzi+yqesyFUxWnWmFvee2P8R6Yu0LfqunwWyIZ2w0PqTY/vY022qgo/pK4MBCMnbtIO85F1TO7mmFpxq4jToJTwP3KB3Dpvy3wPLBuWbR8VdJCwMHUYne0zRp/ufKRGfprXOtumjRRcODcLQ+oZTD7Dk9d5pVY2NDegHrhhfW0PIuHKvE5LX+O5PeMRzu3oQF7X0+qz7+GAN6N9UIJ4UNX6xkBW8I41kw5BmYA4CDn8AQnJkVKs/nMPNurtx3+vlpr7zr2j+ZGh4ZOkrdhdlYJPZfA1ZyuX6aCkXakG+IzflhSswxOEawlFUOx2GZ/yrgNFep01WBysJceqBGaKwqSBT2Sini/WmJDnxuj7A5L8JTUflDezwGLgKWGGip6zH75hIY/K1Gk8YRDHJDnv2tY78Eu6bYUIgHkzZJIHhkcqttups2e1fo5Tgiv5oi242bGH/h3l+FJi/DOCNMTLsogw0GGRRbXvtrSvmD+oelpPGF06VjdCSQ6PmNPG0J5oHLJ92SqYes277I+lF49ulNt/kalTvCxNi74crhPj25iTob8cEYAolarqj9BBGNhJw/Q== fleet functional testing key 2 | -------------------------------------------------------------------------------- /vendor/src/github.com/coreos/fleet/functional/fixtures/units/conflict.0.service: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=Test Unit 3 | 4 | [Service] 5 | ExecStart=/bin/bash -c "while true; do echo Hello, World!; sleep 1; done" 6 | 7 | [X-Fleet] 8 | Conflicts=conflict.*.service 9 | -------------------------------------------------------------------------------- /vendor/src/github.com/coreos/fleet/functional/fixtures/units/conflict.1.service: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=Test Unit 3 | 4 | [Service] 5 | ExecStart=/bin/bash -c "while true; do echo Hello, World!; sleep 1; done" 6 | 7 | [X-Fleet] 8 | Conflicts=conflict.*.service 9 | -------------------------------------------------------------------------------- /vendor/src/github.com/coreos/fleet/functional/fixtures/units/conflict.2.service: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=Test Unit 3 | 4 | [Service] 5 | ExecStart=/bin/bash -c "while true; do echo Hello, World!; sleep 1; done" 6 | 7 | [X-Fleet] 8 | Conflicts=conflict.*.service 9 | -------------------------------------------------------------------------------- /vendor/src/github.com/coreos/fleet/functional/fixtures/units/conflict.3.service: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=Test Unit 3 | 4 | [Service] 5 | ExecStart=/bin/bash -c "while true; do echo Hello, World!; sleep 1; done" 6 | 7 | [X-Fleet] 8 | Conflicts=conflict.*.service 9 | -------------------------------------------------------------------------------- /vendor/src/github.com/coreos/fleet/functional/fixtures/units/conflict.4.service: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=Test Unit 3 | 4 | [Service] 5 | ExecStart=/bin/bash -c "while true; do echo Hello, World!; sleep 1; done" 6 | 7 | [X-Fleet] 8 | Conflicts=conflict.*.service 9 | -------------------------------------------------------------------------------- /vendor/src/github.com/coreos/fleet/functional/fixtures/units/conflicts-with-hello.service: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=Test Unit 3 | 4 | [Service] 5 | ExecStart=/bin/bash -c "while true; do echo Hello, World!; sleep 1; done" 6 | 7 | [X-Fleet] 8 | Conflicts=hello.service 9 | -------------------------------------------------------------------------------- /vendor/src/github.com/coreos/fleet/functional/fixtures/units/global.service: -------------------------------------------------------------------------------- 1 | [Service] 2 | ExecStart=/bin/bash -c "while true; do echo Hello, Global World!; sleep 1; done" 3 | 4 | [X-Fleet] 5 | Global=true 6 | -------------------------------------------------------------------------------- /vendor/src/github.com/coreos/fleet/functional/fixtures/units/goodbye.service: -------------------------------------------------------------------------------- 1 | [Service] 2 | ExecStart=/bin/bash -c "while true; do echo Goodbye, World!; sleep 1; done" 3 | -------------------------------------------------------------------------------- /vendor/src/github.com/coreos/fleet/functional/fixtures/units/hello.service: -------------------------------------------------------------------------------- 1 | [Service] 2 | ExecStart=/bin/bash -c "while true; do echo Hello, World!; sleep 1; done" 3 | -------------------------------------------------------------------------------- /vendor/src/github.com/coreos/fleet/functional/fixtures/units/pin@.service: -------------------------------------------------------------------------------- 1 | [Service] 2 | ExecStart=/bin/bash -c "while true; do echo Hello, World!; sleep 1; done" 3 | 4 | [X-Fleet] 5 | MachineID=%i 6 | -------------------------------------------------------------------------------- /vendor/src/github.com/coreos/fleet/functional/fixtures/units/ping.0.service: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=PING 3 | 4 | [Service] 5 | ExecStart=/bin/bash -c "while true; do echo ping; sleep 1; done" 6 | -------------------------------------------------------------------------------- /vendor/src/github.com/coreos/fleet/functional/fixtures/units/ping.1.service: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=PING 3 | 4 | [Service] 5 | ExecStart=/bin/bash -c "while true; do echo ping; sleep 1; done" 6 | -------------------------------------------------------------------------------- /vendor/src/github.com/coreos/fleet/functional/fixtures/units/ping.2.service: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=PING 3 | 4 | [Service] 5 | ExecStart=/bin/bash -c "while true; do echo ping; sleep 1; done" 6 | -------------------------------------------------------------------------------- /vendor/src/github.com/coreos/fleet/functional/fixtures/units/pong.0.service: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=PONG 3 | 4 | [Service] 5 | ExecStart=/bin/bash -c "while true; do echo pong; sleep 1; done" 6 | 7 | [X-Fleet] 8 | MachineOf=ping.0.service 9 | -------------------------------------------------------------------------------- /vendor/src/github.com/coreos/fleet/functional/fixtures/units/pong.1.service: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=PONG 3 | 4 | [Service] 5 | ExecStart=/bin/bash -c "while true; do echo pong; sleep 1; done" 6 | 7 | [X-Fleet] 8 | MachineOf=ping.1.service 9 | -------------------------------------------------------------------------------- /vendor/src/github.com/coreos/fleet/functional/fixtures/units/pong.2.service: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=PONG 3 | 4 | [Service] 5 | ExecStart=/bin/bash -c "while true; do echo pong; sleep 1; done" 6 | 7 | [X-Fleet] 8 | MachineOf=ping.2.service 9 | -------------------------------------------------------------------------------- /vendor/src/github.com/coreos/fleet/functional/platform/cluster.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 CoreOS, Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package platform 16 | 17 | import ( 18 | "github.com/coreos/fleet/functional/util" 19 | ) 20 | 21 | type Member interface { 22 | ID() string 23 | IP() string 24 | Endpoint() string 25 | } 26 | 27 | type Cluster interface { 28 | CreateMember() (Member, error) 29 | DestroyMember(Member) error 30 | ReplaceMember(Member) (Member, error) 31 | Members() []Member 32 | MemberCommand(Member, ...string) (string, error) 33 | Destroy() error 34 | 35 | // client operations 36 | Fleetctl(m Member, args ...string) (string, string, error) 37 | FleetctlWithInput(m Member, input string, args ...string) (string, string, error) 38 | WaitForNActiveUnits(Member, int) (map[string][]util.UnitState, error) 39 | WaitForNMachines(Member, int) ([]string, error) 40 | } 41 | 42 | func CreateNClusterMembers(cl Cluster, count int) ([]Member, error) { 43 | ms := make([]Member, 0) 44 | for i := 0; i < count; i++ { 45 | m, err := cl.CreateMember() 46 | if err != nil { 47 | return nil, err 48 | } 49 | ms = append(ms, m) 50 | } 51 | return ms, nil 52 | } 53 | -------------------------------------------------------------------------------- /vendor/src/github.com/coreos/fleet/heart/heart.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 CoreOS, Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package heart 16 | 17 | import ( 18 | "time" 19 | 20 | "github.com/coreos/fleet/machine" 21 | "github.com/coreos/fleet/registry" 22 | ) 23 | 24 | type Heart interface { 25 | Beat(time.Duration) (uint64, error) 26 | Clear() error 27 | } 28 | 29 | func New(reg registry.Registry, mach machine.Machine) Heart { 30 | return &machineHeart{reg, mach} 31 | } 32 | 33 | type machineHeart struct { 34 | reg registry.Registry 35 | mach machine.Machine 36 | } 37 | 38 | func (h *machineHeart) Beat(ttl time.Duration) (uint64, error) { 39 | return h.reg.SetMachineState(h.mach.State(), ttl) 40 | } 41 | 42 | func (h *machineHeart) Clear() error { 43 | return h.reg.RemoveMachineState(h.mach.State().ID) 44 | } 45 | -------------------------------------------------------------------------------- /vendor/src/github.com/coreos/fleet/heart/monitor.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 CoreOS, Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package heart 16 | 17 | import ( 18 | "errors" 19 | "time" 20 | 21 | "github.com/coreos/fleet/log" 22 | ) 23 | 24 | func NewMonitor(ttl time.Duration) *Monitor { 25 | return &Monitor{ttl, ttl / 2} 26 | } 27 | 28 | type Monitor struct { 29 | TTL time.Duration 30 | ival time.Duration 31 | } 32 | 33 | // Monitor ensures a Heart is still beating until a channel is closed, returning 34 | // an error if the heartbeats fail. 35 | func (m *Monitor) Monitor(hrt Heart, stop chan bool) error { 36 | ticker := time.Tick(m.ival) 37 | for { 38 | select { 39 | case <-stop: 40 | log.Debug("Monitor exiting due to stop signal") 41 | return nil 42 | case <-ticker: 43 | if _, err := m.check(hrt); err != nil { 44 | return err 45 | } 46 | } 47 | } 48 | } 49 | 50 | // check attempts to beat a Heart several times within a timeout, returning the 51 | // log index at which the beat succeeded or an error 52 | func (m *Monitor) check(hrt Heart) (idx uint64, err error) { 53 | // time out after a third of the machine presence TTL, attempting 54 | // the heartbeat up to four times 55 | timeout := m.TTL / 3 56 | interval := timeout / 4 57 | 58 | tchan := time.After(timeout) 59 | next := time.After(0) 60 | for idx == 0 { 61 | select { 62 | case <-tchan: 63 | err = errors.New("Monitor timed out before successful heartbeat") 64 | return 65 | case <-next: 66 | idx, err = hrt.Beat(m.TTL) 67 | if err != nil { 68 | log.Debugf("Monitor heartbeat function returned err, retrying in %v: %v", interval, err) 69 | } 70 | 71 | next = time.After(interval) 72 | } 73 | } 74 | 75 | return 76 | } 77 | -------------------------------------------------------------------------------- /vendor/src/github.com/coreos/fleet/machine/fake.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 CoreOS, Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package machine 16 | 17 | type FakeMachine struct { 18 | MachineState MachineState 19 | } 20 | 21 | func (fm *FakeMachine) State() MachineState { 22 | return fm.MachineState 23 | } 24 | -------------------------------------------------------------------------------- /vendor/src/github.com/coreos/fleet/machine/fake_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 CoreOS, Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package machine 16 | 17 | import ( 18 | "reflect" 19 | "testing" 20 | ) 21 | 22 | func TestFakeMachine(t *testing.T) { 23 | ms := MachineState{ID: "XXX"} 24 | fm := FakeMachine{ms} 25 | 26 | ret := fm.State() 27 | if !reflect.DeepEqual(ms, ret) { 28 | t.Fatalf("FakeMachine.State() returned %v, expected %v", ret, ms) 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /vendor/src/github.com/coreos/fleet/machine/machine.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 CoreOS, Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package machine 16 | 17 | import ( 18 | "github.com/coreos/fleet/log" 19 | "github.com/coreos/fleet/pkg" 20 | ) 21 | 22 | type Machine interface { 23 | State() MachineState 24 | } 25 | 26 | // HasMetadata determine if the Metadata of a given MachineState 27 | // matches the indicated values. 28 | func HasMetadata(state *MachineState, metadata map[string]pkg.Set) bool { 29 | for key, values := range metadata { 30 | local, ok := state.Metadata[key] 31 | if !ok { 32 | log.Debugf("No local values found for Metadata(%s)", key) 33 | return false 34 | } 35 | 36 | log.Debugf("Asserting local Metadata(%s) meets requirements", key) 37 | 38 | if values.Contains(local) { 39 | log.Debugf("Local Metadata(%s) meets requirement", key) 40 | } else { 41 | log.Debugf("Local Metadata(%s) does not match requirement", key) 42 | return false 43 | } 44 | } 45 | 46 | return true 47 | } 48 | -------------------------------------------------------------------------------- /vendor/src/github.com/coreos/fleet/machine/machine_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 CoreOS, Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package machine 16 | 17 | import ( 18 | "testing" 19 | 20 | "github.com/coreos/fleet/pkg" 21 | ) 22 | 23 | func TestHasMetadata(t *testing.T) { 24 | testCases := []struct { 25 | metadata map[string]string 26 | match map[string]pkg.Set 27 | want bool 28 | }{ 29 | { 30 | map[string]string{ 31 | "region": "us-east-1", 32 | }, 33 | map[string]pkg.Set{ 34 | "region": pkg.NewUnsafeSet("us-east-1"), 35 | }, 36 | true, 37 | }, 38 | { 39 | map[string]string{ 40 | "groups": "ping", 41 | }, 42 | map[string]pkg.Set{ 43 | "groups": pkg.NewUnsafeSet("ping", "pong"), 44 | }, 45 | true, 46 | }, 47 | { 48 | map[string]string{ 49 | "groups": "ping", 50 | }, 51 | map[string]pkg.Set{ 52 | "groups": pkg.NewUnsafeSet("pong"), 53 | }, 54 | false, 55 | }, 56 | { 57 | map[string]string{ 58 | "region": "us-east-1", 59 | "groups": "ping", 60 | }, 61 | map[string]pkg.Set{ 62 | "region": pkg.NewUnsafeSet("us-east-1"), 63 | "groups": pkg.NewUnsafeSet("pong"), 64 | }, 65 | false, 66 | }, 67 | { 68 | map[string]string{}, 69 | map[string]pkg.Set{ 70 | "groups": pkg.NewUnsafeSet("pong"), 71 | }, 72 | false, 73 | }, 74 | } 75 | 76 | for i, tt := range testCases { 77 | ms := &MachineState{Metadata: tt.metadata} 78 | got := HasMetadata(ms, tt.match) 79 | if got != tt.want { 80 | t.Errorf("case %d: HasMetadata returned %t, expected %t", i, got, tt.want) 81 | } 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /vendor/src/github.com/coreos/fleet/machine/state.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 CoreOS, Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package machine 16 | 17 | const ( 18 | shortIDLen = 8 19 | ) 20 | 21 | // MachineState represents a point-in-time snapshot of the 22 | // state of the local host. 23 | type MachineState struct { 24 | ID string 25 | PublicIP string 26 | Metadata map[string]string 27 | Version string 28 | } 29 | 30 | func (ms MachineState) ShortID() string { 31 | if len(ms.ID) <= shortIDLen { 32 | return ms.ID 33 | } 34 | return ms.ID[0:shortIDLen] 35 | } 36 | 37 | func (ms MachineState) MatchID(ID string) bool { 38 | return ms.ID == ID || ms.ShortID() == ID 39 | } 40 | 41 | // stackState is used to merge two MachineStates. Values configured on the top 42 | // MachineState always take precedence over those on the bottom. 43 | func stackState(top, bottom MachineState) MachineState { 44 | state := MachineState(bottom) 45 | 46 | if top.PublicIP != "" { 47 | state.PublicIP = top.PublicIP 48 | } 49 | 50 | if top.ID != "" { 51 | state.ID = top.ID 52 | } 53 | 54 | //FIXME: This will *always* overwrite the bottom's metadata, 55 | // but the only use-case we have today does not ever have 56 | // metadata on the bottom. 57 | if len(top.Metadata) > 0 { 58 | state.Metadata = top.Metadata 59 | } 60 | 61 | if top.Version != "" { 62 | state.Version = top.Version 63 | } 64 | 65 | return state 66 | } 67 | -------------------------------------------------------------------------------- /vendor/src/github.com/coreos/fleet/registry/event_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 CoreOS, Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package registry 16 | 17 | import ( 18 | "reflect" 19 | "testing" 20 | 21 | "github.com/coreos/fleet/etcd" 22 | "github.com/coreos/fleet/pkg" 23 | ) 24 | 25 | func TestFilterEtcdEvents(t *testing.T) { 26 | tests := []struct { 27 | in string 28 | ev pkg.Event 29 | ok bool 30 | }{ 31 | { 32 | in: "", 33 | ok: false, 34 | }, 35 | { 36 | in: "/", 37 | ok: false, 38 | }, 39 | { 40 | in: "/fleet", 41 | ok: false, 42 | }, 43 | { 44 | in: "/fleet/job", 45 | ok: false, 46 | }, 47 | { 48 | in: "/fleet/job/foo/object", 49 | ok: false, 50 | }, 51 | { 52 | in: "/fleet/machine/asdf", 53 | ok: false, 54 | }, 55 | { 56 | in: "/fleet/state/asdf", 57 | ok: false, 58 | }, 59 | { 60 | in: "/fleet/job/foobarbaz/target-state", 61 | ev: JobTargetStateChangeEvent, 62 | ok: true, 63 | }, 64 | { 65 | in: "/fleet/job/asdf/target", 66 | ev: JobTargetChangeEvent, 67 | ok: true, 68 | }, 69 | } 70 | 71 | for i, tt := range tests { 72 | for _, action := range []string{"set", "update", "create", "delete"} { 73 | prefix := "/fleet" 74 | 75 | res := &etcd.Result{ 76 | Node: &etcd.Node{ 77 | Key: tt.in, 78 | }, 79 | Action: action, 80 | } 81 | ev, ok := parse(res, prefix) 82 | if ok != tt.ok { 83 | t.Errorf("case %d: expected ok=%t, got %t", i, tt.ok, ok) 84 | continue 85 | } 86 | 87 | if !reflect.DeepEqual(tt.ev, ev) { 88 | t.Errorf("case %d: received incorrect event\nexpected %#v\ngot %#v", i, tt.ev, ev) 89 | t.Logf("action: %v", action) 90 | } 91 | } 92 | } 93 | } 94 | -------------------------------------------------------------------------------- /vendor/src/github.com/coreos/fleet/registry/job_state.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 CoreOS, Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package registry 16 | 17 | import ( 18 | "path" 19 | "time" 20 | 21 | "github.com/coreos/fleet/etcd" 22 | "github.com/coreos/fleet/job" 23 | "github.com/coreos/fleet/unit" 24 | ) 25 | 26 | // determineJobState decides what the State field of a Job object should 27 | // be, based on three parameters: 28 | // - heartbeat should be the machine ID that is known to have recently 29 | // heartbeaten (see UnitHeartbeat) the Unit. 30 | // - tgt should be the machine ID to which the Job is currently scheduled 31 | // - us should be the most recent UnitState 32 | func determineJobState(heartbeat, tgt string, us *unit.UnitState) (state job.JobState) { 33 | state = job.JobStateInactive 34 | 35 | if tgt == "" || us == nil { 36 | return 37 | } 38 | 39 | state = job.JobStateLoaded 40 | 41 | if heartbeat != tgt { 42 | return 43 | } 44 | 45 | state = job.JobStateLaunched 46 | return 47 | } 48 | 49 | func (r *EtcdRegistry) UnitHeartbeat(name, machID string, ttl time.Duration) error { 50 | req := etcd.Set{ 51 | Key: r.jobHeartbeatPath(name), 52 | Value: machID, 53 | TTL: ttl, 54 | } 55 | _, err := r.etcd.Do(&req) 56 | return err 57 | } 58 | 59 | func (r *EtcdRegistry) ClearUnitHeartbeat(name string) { 60 | req := etcd.Delete{ 61 | Key: r.jobHeartbeatPath(name), 62 | } 63 | r.etcd.Do(&req) 64 | } 65 | 66 | func (r *EtcdRegistry) jobHeartbeatPath(jobName string) string { 67 | return path.Join(r.keyPrefix, jobPrefix, jobName, "job-state") 68 | } 69 | -------------------------------------------------------------------------------- /vendor/src/github.com/coreos/fleet/registry/registry.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 CoreOS, Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package registry 16 | 17 | import ( 18 | "encoding/json" 19 | "fmt" 20 | 21 | "github.com/coreos/fleet/etcd" 22 | ) 23 | 24 | const DefaultKeyPrefix = "/_coreos.com/fleet/" 25 | 26 | // EtcdRegistry fulfils the Registry interface and uses etcd as a backend 27 | type EtcdRegistry struct { 28 | etcd etcd.Client 29 | keyPrefix string 30 | } 31 | 32 | func NewEtcdRegistry(client etcd.Client, keyPrefix string) *EtcdRegistry { 33 | return &EtcdRegistry{ 34 | etcd: client, 35 | keyPrefix: keyPrefix, 36 | } 37 | } 38 | 39 | func marshal(obj interface{}) (string, error) { 40 | encoded, err := json.Marshal(obj) 41 | if err == nil { 42 | return string(encoded), nil 43 | } 44 | return "", fmt.Errorf("unable to JSON-serialize object: %s", err) 45 | } 46 | 47 | func unmarshal(val string, obj interface{}) error { 48 | err := json.Unmarshal([]byte(val), &obj) 49 | if err == nil { 50 | return nil 51 | } 52 | return fmt.Errorf("unable to JSON-deserialize object: %s", err) 53 | } 54 | -------------------------------------------------------------------------------- /vendor/src/github.com/coreos/fleet/registry/unit.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 CoreOS, Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package registry 16 | 17 | import ( 18 | "path" 19 | 20 | "github.com/coreos/fleet/etcd" 21 | "github.com/coreos/fleet/log" 22 | "github.com/coreos/fleet/unit" 23 | ) 24 | 25 | const ( 26 | unitPrefix = "/unit/" 27 | ) 28 | 29 | func (r *EtcdRegistry) storeOrGetUnitFile(u unit.UnitFile) (err error) { 30 | um := unitModel{ 31 | Raw: u.String(), 32 | } 33 | 34 | json, err := marshal(um) 35 | if err != nil { 36 | return err 37 | } 38 | 39 | req := etcd.Create{ 40 | Key: r.hashedUnitPath(u.Hash()), 41 | Value: json, 42 | } 43 | _, err = r.etcd.Do(&req) 44 | // unit is already stored 45 | if err != nil && etcd.IsNodeExist(err) { 46 | // TODO(jonboulle): verify more here? 47 | err = nil 48 | } 49 | return 50 | } 51 | 52 | // getUnitByHash retrieves from the Registry the Unit associated with the given Hash 53 | func (r *EtcdRegistry) getUnitByHash(hash unit.Hash) *unit.UnitFile { 54 | req := etcd.Get{ 55 | Key: r.hashedUnitPath(hash), 56 | Recursive: true, 57 | } 58 | resp, err := r.etcd.Do(&req) 59 | if err != nil { 60 | if etcd.IsKeyNotFound(err) { 61 | err = nil 62 | } 63 | return nil 64 | } 65 | var um unitModel 66 | if err := unmarshal(resp.Node.Value, &um); err != nil { 67 | log.Errorf("error unmarshaling Unit(%s): %v", hash, err) 68 | return nil 69 | } 70 | 71 | u, err := unit.NewUnitFile(um.Raw) 72 | if err != nil { 73 | log.Errorf("error parsing Unit(%s): %v", hash, err) 74 | return nil 75 | } 76 | 77 | return u 78 | } 79 | 80 | func (r *EtcdRegistry) hashedUnitPath(hash unit.Hash) string { 81 | return path.Join(r.keyPrefix, unitPrefix, hash.String()) 82 | } 83 | 84 | type unitModel struct { 85 | Raw string 86 | } 87 | -------------------------------------------------------------------------------- /vendor/src/github.com/coreos/fleet/resource/resource.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 CoreOS, Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package resource 16 | 17 | // ResourceTuple groups together CPU, memory and disk space. This could be 18 | // total, available or consumed. It could also be used by job resource requirements. 19 | type ResourceTuple struct { 20 | // in hundreds, ie 100=1core, 50=0.5core, 200=2cores, etc 21 | Cores int 22 | // in MB 23 | Memory int 24 | // in MB 25 | Disk int 26 | } 27 | 28 | // Empty returns true if all components of the ResourceTuple are zero. 29 | func (rt ResourceTuple) Empty() bool { 30 | return rt.Cores == 0 && rt.Memory == 0 && rt.Disk == 0 31 | } 32 | 33 | const ( 34 | // TODO(jonboulle): make these configurable 35 | HostCores = 100 36 | HostMemory = 256 37 | HostDisk = 0 38 | ) 39 | 40 | // HostResources represents a set of resources that fleet considers reserved 41 | // for the host, i.e. outside of any units it is running 42 | var HostResources = ResourceTuple{ 43 | HostCores, 44 | HostMemory, 45 | HostDisk, 46 | } 47 | 48 | // Sum aggregates a number of ResourceTuples into a single entity 49 | func Sum(resources ...ResourceTuple) (res ResourceTuple) { 50 | for _, r := range resources { 51 | res.Cores += r.Cores 52 | res.Memory += r.Memory 53 | res.Disk += r.Disk 54 | } 55 | return 56 | } 57 | 58 | // Sub returns a ResourceTuple representing the difference between two 59 | // ResourceTuples 60 | func Sub(r1, r2 ResourceTuple) (res ResourceTuple) { 61 | res.Cores = r1.Cores - r2.Cores 62 | res.Memory = r1.Memory - r2.Memory 63 | res.Disk = r1.Disk - r2.Disk 64 | return 65 | } 66 | -------------------------------------------------------------------------------- /vendor/src/github.com/coreos/fleet/resource/resource_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 CoreOS, Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package resource 16 | 17 | import "reflect" 18 | import "testing" 19 | 20 | func TestSum(t *testing.T) { 21 | for i, tt := range []struct { 22 | in []ResourceTuple 23 | want ResourceTuple 24 | }{ 25 | { 26 | []ResourceTuple{ResourceTuple{10, 24, 1024}}, 27 | ResourceTuple{10, 24, 1024}, 28 | }, 29 | { 30 | []ResourceTuple{ResourceTuple{10, 24, 1024}, ResourceTuple{10, 24, 1024}}, 31 | ResourceTuple{20, 48, 2048}, 32 | }, 33 | { 34 | []ResourceTuple{}, 35 | ResourceTuple{0, 0, 0}, 36 | }, 37 | } { 38 | got := Sum(tt.in...) 39 | if !reflect.DeepEqual(got, tt.want) { 40 | t.Errorf("case %d: got %v, want %v", i, got, tt.want) 41 | } 42 | } 43 | } 44 | 45 | func TestSub(t *testing.T) { 46 | for i, tt := range []struct { 47 | r1 ResourceTuple 48 | r2 ResourceTuple 49 | want ResourceTuple 50 | }{ 51 | { 52 | ResourceTuple{10, 24, 1024}, 53 | ResourceTuple{10, 24, 1024}, 54 | ResourceTuple{0, 0, 0}, 55 | }, 56 | { 57 | ResourceTuple{20, 48, 2048}, 58 | ResourceTuple{15, 36, 2048}, 59 | ResourceTuple{5, 12, 0}, 60 | }, 61 | { 62 | ResourceTuple{0, 0, 0}, 63 | ResourceTuple{0, 0, 0}, 64 | ResourceTuple{0, 0, 0}, 65 | }, 66 | } { 67 | got := Sub(tt.r1, tt.r2) 68 | if !reflect.DeepEqual(got, tt.want) { 69 | t.Errorf("case %d: got %v, want %v", i, got, tt.want) 70 | } 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /vendor/src/github.com/coreos/fleet/scripts/build-release: -------------------------------------------------------------------------------- 1 | #!/bin/sh -e 2 | 3 | function usage { 4 | echo "Usage: $0 " 5 | exit 1 6 | } 7 | 8 | function build { 9 | proj=${1} 10 | ver=${2} 11 | 12 | if [ ! -d ${proj} ]; then 13 | git clone https://github.com/coreos/${proj} 14 | fi 15 | 16 | cd ${proj} 17 | git checkout master 18 | git fetch --all 19 | git reset --hard origin/master 20 | git checkout $ver 21 | ./build 22 | cd - 23 | } 24 | 25 | function package { 26 | proj=${1} 27 | target=${2} 28 | 29 | ccdir="${proj}/bin/${GOOS}_${GOARCH}" 30 | if [ -d ${ccdir} ]; then 31 | cp ${ccdir}/${proj}* ${target} 32 | else 33 | cp ${proj}/bin/${proj}* ${target} 34 | fi 35 | 36 | cp ${proj}/README.md ${target}/README.md 37 | } 38 | 39 | VER=$1 40 | GOOS=$2 41 | 42 | GOARCH="amd64" 43 | 44 | if [ "$GOOS" == "" ]; then 45 | usage 46 | fi 47 | 48 | build fleet ${VER} 49 | 50 | TARGET="fleet-${VER}-${GOOS}-${GOARCH}" 51 | mkdir ${TARGET} 52 | 53 | package fleet ${TARGET} 54 | 55 | if [ ${GOOS} == "linux" ]; then 56 | tar cvvfz ${TARGET}.tar.gz ${TARGET} 57 | else 58 | zip -r ${TARGET}.zip ${TARGET} 59 | fi 60 | -------------------------------------------------------------------------------- /vendor/src/github.com/coreos/fleet/scripts/bump-release: -------------------------------------------------------------------------------- 1 | #!/bin/bash -eu 2 | # 3 | # $1 = version string (e.g. 0.8.0) 4 | # $2 = remote configured to track github.com/coreos/fleet (defaults to "origin" if unset) 5 | 6 | VERSION="${1:?version must be set}" 7 | if [ "${VERSION:0:1}" == "v" ]; then 8 | echo "version tag shouldn't start with v" >> /dev/stderr 9 | exit 255 10 | fi 11 | REMOTE="${2:-origin}" 12 | VERSIONTAG="v${VERSION}" 13 | 14 | MASTERBR="v${VERSION}-master" 15 | TAGBR="v${VERSION}-branch" 16 | 17 | replace_version() { 18 | sed -i -e "s/const Version.*/const Version = \"$1\"/" version/version.go 19 | git commit -m "version: bump to v$1" version/version.go 20 | } 21 | 22 | # set up a new branch tracking the latest origin 23 | git fetch ${REMOTE} 24 | git checkout -b ${MASTERBR} ${REMOTE}/master 25 | 26 | # set up our local branch for the tag and bump the version 27 | git checkout -b ${TAGBR} ${REMOTE}/master 28 | replace_version ${VERSION} 29 | git tag -s -m "${VERSIONTAG}" "${VERSIONTAG}" 30 | git push "${REMOTE}" "${VERSIONTAG}" 31 | 32 | # return to the clean master and bump the version 33 | git checkout "${MASTERBR}" 34 | git branch -D "${TAGBR}" 35 | replace_version "${VERSION}+git" 36 | git push "${REMOTE}" "${MASTERBR}":master 37 | -------------------------------------------------------------------------------- /vendor/src/github.com/coreos/fleet/scripts/fleetctl-inject-ssh.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash -x 2 | 3 | name=$1 4 | if [ -z $name ]; then 5 | echo "Provide a name for the injected SSH key" 6 | exit 1 7 | fi 8 | 9 | shift 1 10 | 11 | pubkey=$(cat) 12 | 13 | for machine in $(fleetctl $@ list-machines --no-legend --full | awk '{ print $1;}'); do 14 | fleetctl $@ ssh $machine "echo '${pubkey}' | update-ssh-keys -a $name -n" 15 | done 16 | -------------------------------------------------------------------------------- /vendor/src/github.com/coreos/fleet/scripts/schema-generator: -------------------------------------------------------------------------------- 1 | #!/bin/bash -eu 2 | 3 | IN="schema/v1.json" 4 | OUT="schema/v1-json.go" 5 | GEN="schema/v1-gen.go" 6 | 7 | # See scripts/schema_generator_import.go for instructions on updating the dependency 8 | PKG="google.golang.org/api/google-api-go-generator" 9 | 10 | # First, write the discovery document into a go file so it can be served statically by the API 11 | cat << 'EOF' > "${OUT}" 12 | package schema 13 | // 14 | // This file is automatically generated by scripts/schema-generator 15 | // 16 | // **** DO NOT EDIT **** 17 | // 18 | EOF 19 | 20 | echo -n 'const DiscoveryJSON = `' >> ${OUT} 21 | cat ${IN} >> "${OUT}" 22 | echo -n '`' >> "${OUT}" 23 | 24 | # Now build google-api-go-generator - we vendor so this is consistently reproducible 25 | GEN_PATH="bin/google-api-go-generator" 26 | if [ ! -f ${GEN_PATH} ]; then 27 | GOPATH="${PWD}/Godeps/_workspace" go build -o ${GEN_PATH} ${PKG} 28 | fi 29 | 30 | # Build the bindings 31 | GOPATH=${PWD}/gopath ./bin/google-api-go-generator \ 32 | -googleapi_pkg "google.golang.org/api/googleapi" \ 33 | -api_json_file "${IN}" \ 34 | -output "${GEN}" 35 | 36 | 37 | # Finally, fix the import in the bindings to refer to the vendored google-api package 38 | sed -i -e "s%google.golang.org%github.com/coreos/fleet/Godeps/_workspace/src/google.golang.org%" "${GEN}" 39 | goimports -w ${GEN} 40 | -------------------------------------------------------------------------------- /vendor/src/github.com/coreos/fleet/scripts/schema_generator_import.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 CoreOS, Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | // +build ignore 16 | 17 | package scripts 18 | 19 | // This file exists to ensure Godep manages a vendored copy of the 20 | // `google-api-go-generator` library, used by scripts/schema-generator. 21 | // Unfortunately since this is a binary package and hence is not importable, we 22 | // need to trick godep into managing it. To update the dependency, do the following steps: 23 | // 1. Use `godep restore` to set up GOPATH with all the right package versions 24 | // 2. Uncomment the import line below 25 | // 3. Update the package in GOPATH as appropriate (e.g. `go get -u google.golang.org/api/google-api-go-generator`) 26 | // 4. Run `godep save` as usual across the entire project (e.g. `godep save -r ./...`) 27 | // 5. Revert this file (i.e. comment the line again, and revert to the original import) as it will not build properly 28 | // 29 | // import _ "google.golang.org/api/google-api-go-generator" 30 | -------------------------------------------------------------------------------- /vendor/src/github.com/coreos/fleet/ssh/LICENSE: -------------------------------------------------------------------------------- 1 | Portions of fleet's ssh package (particularly related to known_hosts handling) 2 | are derived from the OpenSSH source, the copyright notices and licenses for 3 | which follow below. 4 | 5 | /* 6 | * Author: Tatu Ylonen 7 | * Copyright (c) 1995 Tatu Ylonen , Espoo, Finland 8 | * All rights reserved 9 | * Simple pattern matching, with '*' and '?' as wildcards. 10 | * Functions for manipulating the known hosts files. 11 | * 12 | * As far as I am concerned, the code I have written for this software 13 | * can be used freely for any purpose. Any derived versions of this 14 | * software must be clearly marked as such, and if the derived work is 15 | * incompatible with the protocol description in the RFC file, it must be 16 | * called by a name other than "ssh" or "Secure Shell". 17 | */ 18 | 19 | /* 20 | * Copyright (c) 2000 Markus Friedl. All rights reserved. 21 | * Copyright (c) 1999 Niels Provos. All rights reserved. 22 | * 23 | * Redistribution and use in source and binary forms, with or without 24 | * modification, are permitted provided that the following conditions 25 | * are met: 26 | * 1. Redistributions of source code must retain the above copyright 27 | * notice, this list of conditions and the following disclaimer. 28 | * 2. Redistributions in binary form must reproduce the above copyright 29 | * notice, this list of conditions and the following disclaimer in the 30 | * documentation and/or other materials provided with the distribution. 31 | * 32 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 33 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 34 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 35 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 36 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 37 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 38 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 39 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 40 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 41 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 42 | */ 43 | -------------------------------------------------------------------------------- /vendor/src/github.com/coreos/fleet/test: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | # 3 | # Run all fleet tests (not including functional) 4 | # ./test 5 | # ./test -v 6 | # 7 | # Run tests for one package 8 | # PKG=./unit ./test 9 | # PKG=ssh ./test 10 | # 11 | 12 | # Invoke ./cover for HTML output 13 | COVER=${COVER:-"-cover"} 14 | 15 | source ./build 16 | 17 | TESTABLE="agent api config engine etcd fleetctl job machine pkg registry ssh systemd unit" 18 | FORMATTABLE="$TESTABLE client functional functional/platform heart server fleetd" 19 | 20 | # user has not provided PKG override 21 | if [ -z "$PKG" ]; then 22 | TEST=$TESTABLE 23 | FMT=$FORMATTABLE 24 | 25 | # user has provided PKG override 26 | else 27 | # strip out slashes and dots from PKG=./foo/ 28 | TEST=${PKG//\//} 29 | TEST=${TEST//./} 30 | 31 | # only run gofmt on packages provided by user 32 | FMT="$TEST" 33 | fi 34 | 35 | # split TEST into an array and prepend REPO_PATH to each local package 36 | split=(${TEST// / }) 37 | TEST=${split[@]/#/${REPO_PATH}/} 38 | 39 | echo "Running tests..." 40 | go test ${COVER} $@ ${TEST} 41 | 42 | echo "Checking gofmt..." 43 | fmtRes=$(gofmt -l $FMT) 44 | if [ -n "${fmtRes}" ]; then 45 | echo -e "gofmt checking failed:\n${fmtRes}" 46 | exit 255 47 | fi 48 | 49 | echo "Checking govet..." 50 | vetRes=$(go vet $TEST) 51 | if [ -n "${vetRes}" ]; then 52 | echo -e "govet checking failed:\n${vetRes}" 53 | exit 255 54 | fi 55 | 56 | echo "Success" 57 | -------------------------------------------------------------------------------- /vendor/src/github.com/coreos/fleet/test-docker: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | docker run -v $PWD:/opt/fleet google/golang:1.3.1 /bin/bash -c "cd /opt/fleet && ./test" 4 | -------------------------------------------------------------------------------- /vendor/src/github.com/coreos/fleet/unit/manager.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 CoreOS, Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package unit 16 | 17 | import ( 18 | "github.com/coreos/fleet/pkg" 19 | ) 20 | 21 | type UnitManager interface { 22 | Load(string, UnitFile) error 23 | Unload(string) 24 | ReloadUnitFiles() error 25 | 26 | TriggerStart(string) 27 | TriggerStop(string) 28 | 29 | Units() ([]string, error) 30 | GetUnitStates(pkg.Set) (map[string]*UnitState, error) 31 | GetUnitState(string) (*UnitState, error) 32 | } 33 | -------------------------------------------------------------------------------- /vendor/src/github.com/coreos/fleet/version/version.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 CoreOS, Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package version 16 | 17 | import ( 18 | "github.com/coreos/fleet/Godeps/_workspace/src/github.com/coreos/go-semver/semver" 19 | ) 20 | 21 | const Version = "0.10.1+git" 22 | 23 | var SemVersion semver.Version 24 | 25 | func init() { 26 | sv, err := semver.NewVersion(Version) 27 | if err != nil { 28 | panic("bad version string!") 29 | } 30 | SemVersion = *sv 31 | } 32 | --------------------------------------------------------------------------------