From e2ed97648ad63455743ebc16080a82ee47f8bb0c Mon Sep 17 00:00:00 2001 From: Sven Dowideit <SvenDowideit@home.org.au> Date: Wed, 22 Feb 2017 23:55:32 +0000 Subject: [PATCH] move coreos-cloudinit into config/cloudinit Signed-off-by: Sven Dowideit <SvenDowideit@home.org.au> --- cmd/cloudinitexecute/cloudinitexecute.go | 2 +- cmd/cloudinitsave/cloudinitsave.go | 20 +- cmd/cloudinitsave/gce/metadata.go | 4 +- .../cloudinit}/.gitignore | 0 .../cloudinit}/.travis.yml | 0 .../cloudinit}/CONTRIBUTING.md | 0 .../coreos-cloudinit => config/cloudinit}/DCO | 0 .../Documentation/cloud-config-deprecated.md | 0 .../Documentation/cloud-config-locations.md | 0 .../Documentation/cloud-config-oem.md | 0 .../cloudinit}/Documentation/cloud-config.md | 2 +- .../cloudinit}/Documentation/config-drive.md | 0 .../Documentation/debian-interfaces.md | 0 .../Documentation/vmware-guestinfo.md | 0 .../cloudinit}/LICENSE | 0 .../cloudinit}/MAINTAINERS | 0 .../cloudinit}/NOTICE | 0 .../cloudinit}/README.md | 4 +- .../cloudinit}/build | 0 .../cloudinit}/config/config.go | 0 .../cloudinit}/config/config_test.go | 0 .../cloudinit}/config/decode.go | 0 .../cloudinit}/config/etc_hosts.go | 0 .../cloudinit}/config/etcd.go | 0 .../cloudinit}/config/etcd2.go | 0 .../cloudinit}/config/file.go | 0 .../cloudinit}/config/file_test.go | 0 .../cloudinit}/config/flannel.go | 0 .../cloudinit}/config/fleet.go | 0 .../cloudinit}/config/ignition.go | 0 .../cloudinit}/config/locksmith.go | 0 .../cloudinit}/config/locksmith_test.go | 0 .../cloudinit}/config/oem.go | 0 .../cloudinit}/config/script.go | 0 .../cloudinit}/config/unit.go | 0 .../cloudinit}/config/unit_test.go | 0 .../cloudinit}/config/update.go | 0 .../cloudinit}/config/update_test.go | 0 .../cloudinit}/config/user.go | 0 .../cloudinit}/config/validate/context.go | 0 .../config/validate/context_test.go | 0 .../cloudinit}/config/validate/node.go | 0 .../cloudinit}/config/validate/node_test.go | 0 .../cloudinit}/config/validate/report.go | 0 .../cloudinit}/config/validate/report_test.go | 0 .../cloudinit}/config/validate/rules.go | 2 +- .../cloudinit}/config/validate/rules_test.go | 0 .../cloudinit}/config/validate/validate.go | 2 +- .../config/validate/validate_test.go | 0 .../cloudinit}/coreos-cloudinit.go | 36 +- .../cloudinit}/coreos-cloudinit_test.go | 4 +- .../cloudinit}/cover | 0 .../datasource/configdrive/configdrive.go | 2 +- .../configdrive/configdrive_test.go | 4 +- .../cloudinit}/datasource/datasource.go | 0 .../cloudinit}/datasource/file/file.go | 2 +- .../metadata/cloudsigma/server_context.go | 2 +- .../cloudsigma/server_context_test.go | 0 .../metadata/digitalocean/metadata.go | 4 +- .../metadata/digitalocean/metadata_test.go | 8 +- .../datasource/metadata/ec2/metadata.go | 6 +- .../datasource/metadata/ec2/metadata_test.go | 8 +- .../datasource/metadata/gce/metadata.go | 4 +- .../datasource/metadata/gce/metadata_test.go | 8 +- .../datasource/metadata/metadata.go | 2 +- .../datasource/metadata/metadata_test.go | 4 +- .../datasource/metadata/packet/metadata.go | 4 +- .../datasource/metadata/test/test.go | 2 +- .../datasource/proc_cmdline/proc_cmdline.go | 4 +- .../proc_cmdline/proc_cmdline_test.go | 0 .../cloudinit}/datasource/test/filesystem.go | 0 .../datasource/test/filesystem_test.go | 0 .../cloudinit}/datasource/url/url.go | 4 +- .../cloudinit}/datasource/vmware/vmware.go | 4 +- .../datasource/vmware/vmware_amd64.go | 2 +- .../datasource/vmware/vmware_test.go | 2 +- .../datasource/vmware/vmware_unsupported.go | 0 .../cloudinit}/datasource/waagent/waagent.go | 2 +- .../datasource/waagent/waagent_test.go | 4 +- .../cloudinit}/initialize/config.go | 6 +- .../cloudinit}/initialize/config_test.go | 6 +- .../cloudinit}/initialize/env.go | 6 +- .../cloudinit}/initialize/env_test.go | 4 +- .../cloudinit}/initialize/github.go | 2 +- .../cloudinit}/initialize/ssh_keys.go | 4 +- .../cloudinit}/initialize/ssh_keys_test.go | 0 .../cloudinit}/initialize/user_data.go | 2 +- .../cloudinit}/initialize/user_data_test.go | 2 +- .../cloudinit}/initialize/workspace.go | 4 +- .../cloudinit}/network/debian.go | 0 .../cloudinit}/network/debian_test.go | 0 .../cloudinit}/network/interface.go | 0 .../cloudinit}/network/interface_test.go | 0 .../cloudinit}/network/is_go15_false_test.go | 0 .../cloudinit}/network/is_go15_true_test.go | 0 .../cloudinit}/network/packet.go | 2 +- .../cloudinit}/network/stanza.go | 0 .../cloudinit}/network/stanza_test.go | 0 .../cloudinit}/network/vmware.go | 0 .../cloudinit}/network/vmware_test.go | 0 .../cloudinit}/pkg/http_client.go | 0 .../cloudinit}/pkg/http_client_test.go | 4 +- .../cloudinit}/system/env.go | 2 +- .../cloudinit}/system/env_file.go | 0 .../cloudinit}/system/env_file_test.go | 2 +- .../cloudinit}/system/env_test.go | 0 .../cloudinit}/system/etc_hosts.go | 2 +- .../cloudinit}/system/etc_hosts_test.go | 2 +- .../cloudinit}/system/etcd.go | 2 +- .../cloudinit}/system/etcd2.go | 2 +- .../cloudinit}/system/etcd_test.go | 2 +- .../cloudinit}/system/file.go | 2 +- .../cloudinit}/system/file_test.go | 2 +- .../cloudinit}/system/flannel.go | 2 +- .../cloudinit}/system/flannel_test.go | 2 +- .../cloudinit}/system/fleet.go | 2 +- .../cloudinit}/system/fleet_test.go | 2 +- .../cloudinit}/system/locksmith.go | 2 +- .../cloudinit}/system/locksmith_test.go | 2 +- .../cloudinit}/system/networkd.go | 6 +- .../cloudinit}/system/oem.go | 2 +- .../cloudinit}/system/oem_test.go | 2 +- .../cloudinit}/system/ssh_key.go | 0 .../cloudinit}/system/systemd.go | 2 +- .../cloudinit}/system/systemd_test.go | 2 +- .../cloudinit}/system/unit.go | 2 +- .../cloudinit}/system/unit_test.go | 2 +- .../cloudinit}/system/update.go | 2 +- .../cloudinit}/system/update_test.go | 2 +- .../cloudinit}/system/user.go | 2 +- .../cloudinit}/test | 0 .../cloudinit}/units/90-configdrive.rules | 0 .../cloudinit}/units/90-ovfenv.rules | 0 .../cloudinit}/units/media-configdrive.mount | 0 .../cloudinit}/units/media-configvirtfs.mount | 0 .../cloudinit}/units/media-ovfenv.mount | 0 .../units/system-cloudinit@.service | 0 .../cloudinit}/units/system-config.target | 0 .../units/user-cloudinit-proc-cmdline.service | 0 .../cloudinit}/units/user-cloudinit@.path | 0 .../cloudinit}/units/user-cloudinit@.service | 0 .../units/user-config-ovfenv.service | 0 .../cloudinit}/units/user-config.target | 0 .../cloudinit}/units/user-configdrive.service | 0 .../units/user-configvirtfs.service | 0 .../cloudinit}/vendor.manifest | 0 config/disk.go | 4 +- config/metadata_test.go | 2 +- config/types.go | 2 +- os-config.tpl.yml | 1 + trash.conf | 1 - .../github.com/cloudsigma/cepgo/.gitignore | 23 - .../github.com/cloudsigma/cepgo/LICENSE | 202 -- .../github.com/cloudsigma/cepgo/README.md | 43 - .../github.com/cloudsigma/cepgo/cepgo.go | 186 -- .../github.com/cloudsigma/cepgo/cepgo_test.go | 122 - .../github.com/coreos/go-systemd/dbus/dbus.go | 104 - .../coreos/go-systemd/dbus/dbus_test.go | 41 - .../coreos/go-systemd/dbus/methods.go | 354 --- .../coreos/go-systemd/dbus/methods_test.go | 314 -- .../coreos/go-systemd/dbus/properties.go | 220 -- .../github.com/coreos/go-systemd/dbus/set.go | 26 - .../coreos/go-systemd/dbus/set_test.go | 26 - .../coreos/go-systemd/dbus/subscription.go | 249 -- .../go-systemd/dbus/subscription_set.go | 32 - .../go-systemd/dbus/subscription_set_test.go | 67 - .../go-systemd/dbus/subscription_test.go | 90 - .../vendor/github.com/coreos/yaml/LICENSE | 188 -- .../github.com/coreos/yaml/LICENSE.libyaml | 31 - .../vendor/github.com/coreos/yaml/README.md | 131 - .../vendor/github.com/coreos/yaml/apic.go | 742 ----- .../vendor/github.com/coreos/yaml/decode.go | 571 ---- .../github.com/coreos/yaml/decode_test.go | 720 ----- .../vendor/github.com/coreos/yaml/emitterc.go | 1685 ---------- .../vendor/github.com/coreos/yaml/encode.go | 265 -- .../github.com/coreos/yaml/encode_test.go | 433 --- .../vendor/github.com/coreos/yaml/parserc.go | 1096 ------- .../vendor/github.com/coreos/yaml/readerc.go | 391 --- .../vendor/github.com/coreos/yaml/resolve.go | 190 -- .../vendor/github.com/coreos/yaml/scannerc.go | 2710 ----------------- .../vendor/github.com/coreos/yaml/sorter.go | 104 - .../github.com/coreos/yaml/suite_test.go | 12 - .../vendor/github.com/coreos/yaml/writerc.go | 89 - .../vendor/github.com/coreos/yaml/yaml.go | 312 -- .../vendor/github.com/coreos/yaml/yamlh.go | 716 ----- .../github.com/coreos/yaml/yamlprivateh.go | 173 -- .../dotcloud/docker/pkg/netlink/MAINTAINERS | 2 - .../dotcloud/docker/pkg/netlink/netlink.go | 23 - .../docker/pkg/netlink/netlink_linux.go | 891 ------ .../docker/pkg/netlink/netlink_unsupported.go | 69 - .../vendor/github.com/guelfey/go.dbus/LICENSE | 25 - .../guelfey/go.dbus/README.markdown | 36 - .../vendor/github.com/guelfey/go.dbus/auth.go | 255 -- .../guelfey/go.dbus/auth_external.go | 26 - .../github.com/guelfey/go.dbus/auth_sha1.go | 102 - .../vendor/github.com/guelfey/go.dbus/call.go | 147 - .../vendor/github.com/guelfey/go.dbus/conn.go | 597 ---- .../github.com/guelfey/go.dbus/conn_darwin.go | 21 - .../github.com/guelfey/go.dbus/conn_other.go | 27 - .../github.com/guelfey/go.dbus/conn_test.go | 199 -- .../vendor/github.com/guelfey/go.dbus/dbus.go | 258 -- .../github.com/guelfey/go.dbus/decoder.go | 228 -- .../vendor/github.com/guelfey/go.dbus/doc.go | 63 - .../github.com/guelfey/go.dbus/encoder.go | 179 -- .../guelfey/go.dbus/examples_test.go | 50 - .../github.com/guelfey/go.dbus/export.go | 300 -- .../guelfey/go.dbus/introspect/call.go | 27 - .../guelfey/go.dbus/introspect/introspect.go | 80 - .../go.dbus/introspect/introspectable.go | 74 - .../github.com/guelfey/go.dbus/message.go | 346 --- .../github.com/guelfey/go.dbus/prop/prop.go | 264 -- .../github.com/guelfey/go.dbus/proto_test.go | 369 --- .../vendor/github.com/guelfey/go.dbus/sig.go | 257 -- .../github.com/guelfey/go.dbus/sig_test.go | 70 - .../guelfey/go.dbus/transport_darwin.go | 6 - .../guelfey/go.dbus/transport_generic.go | 35 - .../guelfey/go.dbus/transport_unix.go | 190 -- .../guelfey/go.dbus/transport_unix_test.go | 49 - .../guelfey/go.dbus/transport_unixcred.go | 22 - .../github.com/guelfey/go.dbus/variant.go | 129 - .../guelfey/go.dbus/variant_lexer.go | 284 -- .../guelfey/go.dbus/variant_parser.go | 817 ----- .../guelfey/go.dbus/variant_test.go | 78 - .../vendor/github.com/sigma/bdoor/LICENSE | 201 -- .../vendor/github.com/sigma/bdoor/README | 1 - .../vendor/github.com/sigma/bdoor/check.go | 67 - .../github.com/sigma/vmw-guestinfo/CDDL.txt | 241 -- .../github.com/sigma/vmw-guestinfo/LGPL.txt | 502 --- .../github.com/sigma/vmw-guestinfo/LICENSE | 3 - .../github.com/sigma/vmw-guestinfo/README | 3 - .../sigma/vmw-guestinfo/bridge/backdoor.c | 272 -- .../sigma/vmw-guestinfo/bridge/backdoor_386.c | 235 -- .../vmw-guestinfo/bridge/backdoor_amd64.c | 243 -- .../sigma/vmw-guestinfo/bridge/bridge.go | 46 - .../sigma/vmw-guestinfo/bridge/message.c | 604 ---- .../sigma/vmw-guestinfo/examples/main.go | 27 - .../sigma/vmw-guestinfo/include/backdoor.h | 60 - .../sigma/vmw-guestinfo/include/backdoorInt.h | 40 - .../vmw-guestinfo/include/backdoor_def.h | 259 -- .../vmw-guestinfo/include/backdoor_types.h | 132 - .../vmw-guestinfo/include/community_source.h | 70 - .../vmw-guestinfo/include/guest_msg_def.h | 100 - .../sigma/vmw-guestinfo/include/message.h | 72 - .../sigma/vmw-guestinfo/include/vm_assert.h | 364 --- .../vmw-guestinfo/include/vm_basic_types.h | 1186 -------- .../sigma/vmw-guestinfo/include/vmware.h | 87 - .../sigma/vmw-guestinfo/message/message.go | 57 - .../sigma/vmw-guestinfo/rpcout/rpcout.go | 79 - .../sigma/vmw-guestinfo/rpcvmx/rpcvmx.go | 72 - .../sigma/vmw-guestinfo/vmcheck/vmcheck.go | 10 - .../vendor/github.com/sigma/vmw-ovflib/README | 1 - .../vendor/github.com/sigma/vmw-ovflib/ovf.go | 42 - .../github.com/sigma/vmw-ovflib/ovf_test.go | 110 - .../vendor/github.com/tarm/goserial/LICENSE | 27 - .../vendor/github.com/tarm/goserial/README.md | 63 - .../github.com/tarm/goserial/basic_test.go | 61 - .../vendor/github.com/tarm/goserial/serial.go | 99 - .../github.com/tarm/goserial/serial_linux.go | 90 - .../github.com/tarm/goserial/serial_posix.go | 107 - .../tarm/goserial/serial_windows.go | 263 -- 260 files changed, 132 insertions(+), 25281 deletions(-) rename {vendor/github.com/coreos/coreos-cloudinit => config/cloudinit}/.gitignore (100%) rename {vendor/github.com/coreos/coreos-cloudinit => config/cloudinit}/.travis.yml (100%) rename {vendor/github.com/coreos/coreos-cloudinit => config/cloudinit}/CONTRIBUTING.md (100%) rename {vendor/github.com/coreos/coreos-cloudinit => config/cloudinit}/DCO (100%) rename {vendor/github.com/coreos/coreos-cloudinit => config/cloudinit}/Documentation/cloud-config-deprecated.md (100%) rename {vendor/github.com/coreos/coreos-cloudinit => config/cloudinit}/Documentation/cloud-config-locations.md (100%) rename {vendor/github.com/coreos/coreos-cloudinit => config/cloudinit}/Documentation/cloud-config-oem.md (100%) rename {vendor/github.com/coreos/coreos-cloudinit => config/cloudinit}/Documentation/cloud-config.md (99%) rename {vendor/github.com/coreos/coreos-cloudinit => config/cloudinit}/Documentation/config-drive.md (100%) rename {vendor/github.com/coreos/coreos-cloudinit => config/cloudinit}/Documentation/debian-interfaces.md (100%) rename {vendor/github.com/coreos/coreos-cloudinit => config/cloudinit}/Documentation/vmware-guestinfo.md (100%) rename {vendor/github.com/coreos/coreos-cloudinit => config/cloudinit}/LICENSE (100%) rename {vendor/github.com/coreos/coreos-cloudinit => config/cloudinit}/MAINTAINERS (100%) rename {vendor/github.com/coreos/coreos-cloudinit => config/cloudinit}/NOTICE (100%) rename {vendor/github.com/coreos/coreos-cloudinit => config/cloudinit}/README.md (91%) rename {vendor/github.com/coreos/coreos-cloudinit => config/cloudinit}/build (100%) rename {vendor/github.com/coreos/coreos-cloudinit => config/cloudinit}/config/config.go (100%) rename {vendor/github.com/coreos/coreos-cloudinit => config/cloudinit}/config/config_test.go (100%) rename {vendor/github.com/coreos/coreos-cloudinit => config/cloudinit}/config/decode.go (100%) rename {vendor/github.com/coreos/coreos-cloudinit => config/cloudinit}/config/etc_hosts.go (100%) rename {vendor/github.com/coreos/coreos-cloudinit => config/cloudinit}/config/etcd.go (100%) rename {vendor/github.com/coreos/coreos-cloudinit => config/cloudinit}/config/etcd2.go (100%) rename {vendor/github.com/coreos/coreos-cloudinit => config/cloudinit}/config/file.go (100%) rename {vendor/github.com/coreos/coreos-cloudinit => config/cloudinit}/config/file_test.go (100%) rename {vendor/github.com/coreos/coreos-cloudinit => config/cloudinit}/config/flannel.go (100%) rename {vendor/github.com/coreos/coreos-cloudinit => config/cloudinit}/config/fleet.go (100%) rename {vendor/github.com/coreos/coreos-cloudinit => config/cloudinit}/config/ignition.go (100%) rename {vendor/github.com/coreos/coreos-cloudinit => config/cloudinit}/config/locksmith.go (100%) rename {vendor/github.com/coreos/coreos-cloudinit => config/cloudinit}/config/locksmith_test.go (100%) rename {vendor/github.com/coreos/coreos-cloudinit => config/cloudinit}/config/oem.go (100%) rename {vendor/github.com/coreos/coreos-cloudinit => config/cloudinit}/config/script.go (100%) rename {vendor/github.com/coreos/coreos-cloudinit => config/cloudinit}/config/unit.go (100%) rename {vendor/github.com/coreos/coreos-cloudinit => config/cloudinit}/config/unit_test.go (100%) rename {vendor/github.com/coreos/coreos-cloudinit => config/cloudinit}/config/update.go (100%) rename {vendor/github.com/coreos/coreos-cloudinit => config/cloudinit}/config/update_test.go (100%) rename {vendor/github.com/coreos/coreos-cloudinit => config/cloudinit}/config/user.go (100%) rename {vendor/github.com/coreos/coreos-cloudinit => config/cloudinit}/config/validate/context.go (100%) rename {vendor/github.com/coreos/coreos-cloudinit => config/cloudinit}/config/validate/context_test.go (100%) rename {vendor/github.com/coreos/coreos-cloudinit => config/cloudinit}/config/validate/node.go (100%) rename {vendor/github.com/coreos/coreos-cloudinit => config/cloudinit}/config/validate/node_test.go (100%) rename {vendor/github.com/coreos/coreos-cloudinit => config/cloudinit}/config/validate/report.go (100%) rename {vendor/github.com/coreos/coreos-cloudinit => config/cloudinit}/config/validate/report_test.go (100%) rename {vendor/github.com/coreos/coreos-cloudinit => config/cloudinit}/config/validate/rules.go (99%) rename {vendor/github.com/coreos/coreos-cloudinit => config/cloudinit}/config/validate/rules_test.go (100%) rename {vendor/github.com/coreos/coreos-cloudinit => config/cloudinit}/config/validate/validate.go (99%) rename {vendor/github.com/coreos/coreos-cloudinit => config/cloudinit}/config/validate/validate_test.go (100%) rename {vendor/github.com/coreos/coreos-cloudinit => config/cloudinit}/coreos-cloudinit.go (92%) rename {vendor/github.com/coreos/coreos-cloudinit => config/cloudinit}/coreos-cloudinit_test.go (97%) rename {vendor/github.com/coreos/coreos-cloudinit => config/cloudinit}/cover (100%) rename {vendor/github.com/coreos/coreos-cloudinit => config/cloudinit}/datasource/configdrive/configdrive.go (97%) rename {vendor/github.com/coreos/coreos-cloudinit => config/cloudinit}/datasource/configdrive/configdrive_test.go (97%) rename {vendor/github.com/coreos/coreos-cloudinit => config/cloudinit}/datasource/datasource.go (100%) rename {vendor/github.com/coreos/coreos-cloudinit => config/cloudinit}/datasource/file/file.go (95%) rename {vendor/github.com/coreos/coreos-cloudinit => config/cloudinit}/datasource/metadata/cloudsigma/server_context.go (98%) rename {vendor/github.com/coreos/coreos-cloudinit => config/cloudinit}/datasource/metadata/cloudsigma/server_context_test.go (100%) rename {vendor/github.com/coreos/coreos-cloudinit => config/cloudinit}/datasource/metadata/digitalocean/metadata.go (96%) rename {vendor/github.com/coreos/coreos-cloudinit => config/cloudinit}/datasource/metadata/digitalocean/metadata_test.go (93%) rename {vendor/github.com/coreos/coreos-cloudinit => config/cloudinit}/datasource/metadata/ec2/metadata.go (95%) rename {vendor/github.com/coreos/coreos-cloudinit => config/cloudinit}/datasource/metadata/ec2/metadata_test.go (96%) rename {vendor/github.com/coreos/coreos-cloudinit => config/cloudinit}/datasource/metadata/gce/metadata.go (94%) rename {vendor/github.com/coreos/coreos-cloudinit => config/cloudinit}/datasource/metadata/gce/metadata_test.go (92%) rename {vendor/github.com/coreos/coreos-cloudinit => config/cloudinit}/datasource/metadata/metadata.go (97%) rename {vendor/github.com/coreos/coreos-cloudinit => config/cloudinit}/datasource/metadata/metadata_test.go (97%) rename {vendor/github.com/coreos/coreos-cloudinit => config/cloudinit}/datasource/metadata/packet/metadata.go (95%) rename {vendor/github.com/coreos/coreos-cloudinit => config/cloudinit}/datasource/metadata/test/test.go (95%) rename {vendor/github.com/coreos/coreos-cloudinit => config/cloudinit}/datasource/proc_cmdline/proc_cmdline.go (95%) rename {vendor/github.com/coreos/coreos-cloudinit => config/cloudinit}/datasource/proc_cmdline/proc_cmdline_test.go (100%) rename {vendor/github.com/coreos/coreos-cloudinit => config/cloudinit}/datasource/test/filesystem.go (100%) rename {vendor/github.com/coreos/coreos-cloudinit => config/cloudinit}/datasource/test/filesystem_test.go (100%) rename {vendor/github.com/coreos/coreos-cloudinit => config/cloudinit}/datasource/url/url.go (92%) rename {vendor/github.com/coreos/coreos-cloudinit => config/cloudinit}/datasource/vmware/vmware.go (97%) rename {vendor/github.com/coreos/coreos-cloudinit => config/cloudinit}/datasource/vmware/vmware_amd64.go (98%) rename {vendor/github.com/coreos/coreos-cloudinit => config/cloudinit}/datasource/vmware/vmware_test.go (99%) rename {vendor/github.com/coreos/coreos-cloudinit => config/cloudinit}/datasource/vmware/vmware_unsupported.go (100%) rename {vendor/github.com/coreos/coreos-cloudinit => config/cloudinit}/datasource/waagent/waagent.go (98%) rename {vendor/github.com/coreos/coreos-cloudinit => config/cloudinit}/datasource/waagent/waagent_test.go (97%) rename {vendor/github.com/coreos/coreos-cloudinit => config/cloudinit}/initialize/config.go (98%) rename {vendor/github.com/coreos/coreos-cloudinit => config/cloudinit}/initialize/config_test.go (97%) rename {vendor/github.com/coreos/coreos-cloudinit => config/cloudinit}/initialize/env.go (95%) rename {vendor/github.com/coreos/coreos-cloudinit => config/cloudinit}/initialize/env_test.go (97%) rename {vendor/github.com/coreos/coreos-cloudinit => config/cloudinit}/initialize/github.go (95%) rename {vendor/github.com/coreos/coreos-cloudinit => config/cloudinit}/initialize/ssh_keys.go (93%) rename {vendor/github.com/coreos/coreos-cloudinit => config/cloudinit}/initialize/ssh_keys_test.go (100%) rename {vendor/github.com/coreos/coreos-cloudinit => config/cloudinit}/initialize/user_data.go (96%) rename {vendor/github.com/coreos/coreos-cloudinit => config/cloudinit}/initialize/user_data_test.go (97%) rename {vendor/github.com/coreos/coreos-cloudinit => config/cloudinit}/initialize/workspace.go (94%) rename {vendor/github.com/coreos/coreos-cloudinit => config/cloudinit}/network/debian.go (100%) rename {vendor/github.com/coreos/coreos-cloudinit => config/cloudinit}/network/debian_test.go (100%) rename {vendor/github.com/coreos/coreos-cloudinit => config/cloudinit}/network/interface.go (100%) rename {vendor/github.com/coreos/coreos-cloudinit => config/cloudinit}/network/interface_test.go (100%) rename {vendor/github.com/coreos/coreos-cloudinit => config/cloudinit}/network/is_go15_false_test.go (100%) rename {vendor/github.com/coreos/coreos-cloudinit => config/cloudinit}/network/is_go15_true_test.go (100%) rename {vendor/github.com/coreos/coreos-cloudinit => config/cloudinit}/network/packet.go (97%) rename {vendor/github.com/coreos/coreos-cloudinit => config/cloudinit}/network/stanza.go (100%) rename {vendor/github.com/coreos/coreos-cloudinit => config/cloudinit}/network/stanza_test.go (100%) rename {vendor/github.com/coreos/coreos-cloudinit => config/cloudinit}/network/vmware.go (100%) rename {vendor/github.com/coreos/coreos-cloudinit => config/cloudinit}/network/vmware_test.go (100%) rename {vendor/github.com/coreos/coreos-cloudinit => config/cloudinit}/pkg/http_client.go (100%) rename {vendor/github.com/coreos/coreos-cloudinit => config/cloudinit}/pkg/http_client_test.go (96%) rename {vendor/github.com/coreos/coreos-cloudinit => config/cloudinit}/system/env.go (96%) rename {vendor/github.com/coreos/coreos-cloudinit => config/cloudinit}/system/env_file.go (100%) rename {vendor/github.com/coreos/coreos-cloudinit => config/cloudinit}/system/env_file_test.go (99%) rename {vendor/github.com/coreos/coreos-cloudinit => config/cloudinit}/system/env_test.go (100%) rename {vendor/github.com/coreos/coreos-cloudinit => config/cloudinit}/system/etc_hosts.go (96%) rename {vendor/github.com/coreos/coreos-cloudinit => config/cloudinit}/system/etc_hosts_test.go (96%) rename {vendor/github.com/coreos/coreos-cloudinit => config/cloudinit}/system/etcd.go (95%) rename {vendor/github.com/coreos/coreos-cloudinit => config/cloudinit}/system/etcd2.go (95%) rename {vendor/github.com/coreos/coreos-cloudinit => config/cloudinit}/system/etcd_test.go (97%) rename {vendor/github.com/coreos/coreos-cloudinit => config/cloudinit}/system/file.go (98%) rename {vendor/github.com/coreos/coreos-cloudinit => config/cloudinit}/system/file_test.go (98%) rename {vendor/github.com/coreos/coreos-cloudinit => config/cloudinit}/system/flannel.go (95%) rename {vendor/github.com/coreos/coreos-cloudinit => config/cloudinit}/system/flannel_test.go (97%) rename {vendor/github.com/coreos/coreos-cloudinit => config/cloudinit}/system/fleet.go (95%) rename {vendor/github.com/coreos/coreos-cloudinit => config/cloudinit}/system/fleet_test.go (96%) rename {vendor/github.com/coreos/coreos-cloudinit => config/cloudinit}/system/locksmith.go (95%) rename {vendor/github.com/coreos/coreos-cloudinit => config/cloudinit}/system/locksmith_test.go (96%) rename {vendor/github.com/coreos/coreos-cloudinit => config/cloudinit}/system/networkd.go (94%) rename {vendor/github.com/coreos/coreos-cloudinit => config/cloudinit}/system/oem.go (96%) rename {vendor/github.com/coreos/coreos-cloudinit => config/cloudinit}/system/oem_test.go (97%) rename {vendor/github.com/coreos/coreos-cloudinit => config/cloudinit}/system/ssh_key.go (100%) rename {vendor/github.com/coreos/coreos-cloudinit => config/cloudinit}/system/systemd.go (99%) rename {vendor/github.com/coreos/coreos-cloudinit => config/cloudinit}/system/systemd_test.go (99%) rename {vendor/github.com/coreos/coreos-cloudinit => config/cloudinit}/system/unit.go (98%) rename {vendor/github.com/coreos/coreos-cloudinit => config/cloudinit}/system/unit_test.go (98%) rename {vendor/github.com/coreos/coreos-cloudinit => config/cloudinit}/system/update.go (98%) rename {vendor/github.com/coreos/coreos-cloudinit => config/cloudinit}/system/update_test.go (98%) rename {vendor/github.com/coreos/coreos-cloudinit => config/cloudinit}/system/user.go (97%) rename {vendor/github.com/coreos/coreos-cloudinit => config/cloudinit}/test (100%) rename {vendor/github.com/coreos/coreos-cloudinit => config/cloudinit}/units/90-configdrive.rules (100%) rename {vendor/github.com/coreos/coreos-cloudinit => config/cloudinit}/units/90-ovfenv.rules (100%) rename {vendor/github.com/coreos/coreos-cloudinit => config/cloudinit}/units/media-configdrive.mount (100%) rename {vendor/github.com/coreos/coreos-cloudinit => config/cloudinit}/units/media-configvirtfs.mount (100%) rename {vendor/github.com/coreos/coreos-cloudinit => config/cloudinit}/units/media-ovfenv.mount (100%) rename {vendor/github.com/coreos/coreos-cloudinit => config/cloudinit}/units/system-cloudinit@.service (100%) rename {vendor/github.com/coreos/coreos-cloudinit => config/cloudinit}/units/system-config.target (100%) rename {vendor/github.com/coreos/coreos-cloudinit => config/cloudinit}/units/user-cloudinit-proc-cmdline.service (100%) rename {vendor/github.com/coreos/coreos-cloudinit => config/cloudinit}/units/user-cloudinit@.path (100%) rename {vendor/github.com/coreos/coreos-cloudinit => config/cloudinit}/units/user-cloudinit@.service (100%) rename {vendor/github.com/coreos/coreos-cloudinit => config/cloudinit}/units/user-config-ovfenv.service (100%) rename {vendor/github.com/coreos/coreos-cloudinit => config/cloudinit}/units/user-config.target (100%) rename {vendor/github.com/coreos/coreos-cloudinit => config/cloudinit}/units/user-configdrive.service (100%) rename {vendor/github.com/coreos/coreos-cloudinit => config/cloudinit}/units/user-configvirtfs.service (100%) rename {vendor/github.com/coreos/coreos-cloudinit => config/cloudinit}/vendor.manifest (100%) delete mode 100644 vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/cloudsigma/cepgo/.gitignore delete mode 100644 vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/cloudsigma/cepgo/LICENSE delete mode 100644 vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/cloudsigma/cepgo/README.md delete mode 100644 vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/cloudsigma/cepgo/cepgo.go delete mode 100644 vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/cloudsigma/cepgo/cepgo_test.go delete mode 100644 vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/coreos/go-systemd/dbus/dbus.go delete mode 100644 vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/coreos/go-systemd/dbus/dbus_test.go delete mode 100644 vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/coreos/go-systemd/dbus/methods.go delete mode 100644 vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/coreos/go-systemd/dbus/methods_test.go delete mode 100644 vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/coreos/go-systemd/dbus/properties.go delete mode 100644 vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/coreos/go-systemd/dbus/set.go delete mode 100644 vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/coreos/go-systemd/dbus/set_test.go delete mode 100644 vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/coreos/go-systemd/dbus/subscription.go delete mode 100644 vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/coreos/go-systemd/dbus/subscription_set.go delete mode 100644 vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/coreos/go-systemd/dbus/subscription_set_test.go delete mode 100644 vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/coreos/go-systemd/dbus/subscription_test.go delete mode 100644 vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/coreos/yaml/LICENSE delete mode 100644 vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/coreos/yaml/LICENSE.libyaml delete mode 100644 vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/coreos/yaml/README.md delete mode 100644 vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/coreos/yaml/apic.go delete mode 100644 vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/coreos/yaml/decode.go delete mode 100644 vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/coreos/yaml/decode_test.go delete mode 100644 vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/coreos/yaml/emitterc.go delete mode 100644 vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/coreos/yaml/encode.go delete mode 100644 vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/coreos/yaml/encode_test.go delete mode 100644 vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/coreos/yaml/parserc.go delete mode 100644 vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/coreos/yaml/readerc.go delete mode 100644 vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/coreos/yaml/resolve.go delete mode 100644 vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/coreos/yaml/scannerc.go delete mode 100644 vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/coreos/yaml/sorter.go delete mode 100644 vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/coreos/yaml/suite_test.go delete mode 100644 vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/coreos/yaml/writerc.go delete mode 100644 vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/coreos/yaml/yaml.go delete mode 100644 vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/coreos/yaml/yamlh.go delete mode 100644 vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/coreos/yaml/yamlprivateh.go delete mode 100644 vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/dotcloud/docker/pkg/netlink/MAINTAINERS delete mode 100644 vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/dotcloud/docker/pkg/netlink/netlink.go delete mode 100644 vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/dotcloud/docker/pkg/netlink/netlink_linux.go delete mode 100644 vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/dotcloud/docker/pkg/netlink/netlink_unsupported.go delete mode 100644 vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/guelfey/go.dbus/LICENSE delete mode 100644 vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/guelfey/go.dbus/README.markdown delete mode 100644 vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/guelfey/go.dbus/auth.go delete mode 100644 vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/guelfey/go.dbus/auth_external.go delete mode 100644 vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/guelfey/go.dbus/auth_sha1.go delete mode 100644 vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/guelfey/go.dbus/call.go delete mode 100644 vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/guelfey/go.dbus/conn.go delete mode 100644 vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/guelfey/go.dbus/conn_darwin.go delete mode 100644 vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/guelfey/go.dbus/conn_other.go delete mode 100644 vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/guelfey/go.dbus/conn_test.go delete mode 100644 vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/guelfey/go.dbus/dbus.go delete mode 100644 vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/guelfey/go.dbus/decoder.go delete mode 100644 vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/guelfey/go.dbus/doc.go delete mode 100644 vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/guelfey/go.dbus/encoder.go delete mode 100644 vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/guelfey/go.dbus/examples_test.go delete mode 100644 vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/guelfey/go.dbus/export.go delete mode 100644 vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/guelfey/go.dbus/introspect/call.go delete mode 100644 vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/guelfey/go.dbus/introspect/introspect.go delete mode 100644 vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/guelfey/go.dbus/introspect/introspectable.go delete mode 100644 vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/guelfey/go.dbus/message.go delete mode 100644 vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/guelfey/go.dbus/prop/prop.go delete mode 100644 vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/guelfey/go.dbus/proto_test.go delete mode 100644 vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/guelfey/go.dbus/sig.go delete mode 100644 vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/guelfey/go.dbus/sig_test.go delete mode 100644 vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/guelfey/go.dbus/transport_darwin.go delete mode 100644 vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/guelfey/go.dbus/transport_generic.go delete mode 100644 vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/guelfey/go.dbus/transport_unix.go delete mode 100644 vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/guelfey/go.dbus/transport_unix_test.go delete mode 100644 vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/guelfey/go.dbus/transport_unixcred.go delete mode 100644 vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/guelfey/go.dbus/variant.go delete mode 100644 vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/guelfey/go.dbus/variant_lexer.go delete mode 100644 vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/guelfey/go.dbus/variant_parser.go delete mode 100644 vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/guelfey/go.dbus/variant_test.go delete mode 100644 vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/sigma/bdoor/LICENSE delete mode 100644 vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/sigma/bdoor/README delete mode 100644 vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/sigma/bdoor/check.go delete mode 100644 vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/sigma/vmw-guestinfo/CDDL.txt delete mode 100644 vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/sigma/vmw-guestinfo/LGPL.txt delete mode 100644 vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/sigma/vmw-guestinfo/LICENSE delete mode 100644 vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/sigma/vmw-guestinfo/README delete mode 100644 vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/sigma/vmw-guestinfo/bridge/backdoor.c delete mode 100644 vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/sigma/vmw-guestinfo/bridge/backdoor_386.c delete mode 100644 vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/sigma/vmw-guestinfo/bridge/backdoor_amd64.c delete mode 100644 vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/sigma/vmw-guestinfo/bridge/bridge.go delete mode 100644 vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/sigma/vmw-guestinfo/bridge/message.c delete mode 100644 vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/sigma/vmw-guestinfo/examples/main.go delete mode 100644 vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/sigma/vmw-guestinfo/include/backdoor.h delete mode 100644 vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/sigma/vmw-guestinfo/include/backdoorInt.h delete mode 100644 vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/sigma/vmw-guestinfo/include/backdoor_def.h delete mode 100644 vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/sigma/vmw-guestinfo/include/backdoor_types.h delete mode 100644 vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/sigma/vmw-guestinfo/include/community_source.h delete mode 100644 vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/sigma/vmw-guestinfo/include/guest_msg_def.h delete mode 100644 vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/sigma/vmw-guestinfo/include/message.h delete mode 100644 vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/sigma/vmw-guestinfo/include/vm_assert.h delete mode 100644 vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/sigma/vmw-guestinfo/include/vm_basic_types.h delete mode 100644 vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/sigma/vmw-guestinfo/include/vmware.h delete mode 100644 vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/sigma/vmw-guestinfo/message/message.go delete mode 100644 vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/sigma/vmw-guestinfo/rpcout/rpcout.go delete mode 100644 vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/sigma/vmw-guestinfo/rpcvmx/rpcvmx.go delete mode 100644 vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/sigma/vmw-guestinfo/vmcheck/vmcheck.go delete mode 100644 vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/sigma/vmw-ovflib/README delete mode 100644 vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/sigma/vmw-ovflib/ovf.go delete mode 100644 vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/sigma/vmw-ovflib/ovf_test.go delete mode 100644 vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/tarm/goserial/LICENSE delete mode 100644 vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/tarm/goserial/README.md delete mode 100644 vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/tarm/goserial/basic_test.go delete mode 100644 vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/tarm/goserial/serial.go delete mode 100644 vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/tarm/goserial/serial_linux.go delete mode 100644 vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/tarm/goserial/serial_posix.go delete mode 100644 vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/tarm/goserial/serial_windows.go diff --git a/cmd/cloudinitexecute/cloudinitexecute.go b/cmd/cloudinitexecute/cloudinitexecute.go index 37a8a7cd..e04f3074 100644 --- a/cmd/cloudinitexecute/cloudinitexecute.go +++ b/cmd/cloudinitexecute/cloudinitexecute.go @@ -9,7 +9,7 @@ import ( "path" "strings" - "github.com/coreos/coreos-cloudinit/system" + "github.com/rancher/os/config/cloudinit/system" rancherConfig "github.com/rancher/os/config" "github.com/rancher/os/docker" "github.com/rancher/os/log" diff --git a/cmd/cloudinitsave/cloudinitsave.go b/cmd/cloudinitsave/cloudinitsave.go index 75050031..41bdab24 100644 --- a/cmd/cloudinitsave/cloudinitsave.go +++ b/cmd/cloudinitsave/cloudinitsave.go @@ -25,16 +25,16 @@ import ( yaml "github.com/cloudfoundry-incubator/candiedyaml" - "github.com/coreos/coreos-cloudinit/config" - "github.com/coreos/coreos-cloudinit/datasource" - "github.com/coreos/coreos-cloudinit/datasource/configdrive" - "github.com/coreos/coreos-cloudinit/datasource/file" - "github.com/coreos/coreos-cloudinit/datasource/metadata/digitalocean" - "github.com/coreos/coreos-cloudinit/datasource/metadata/ec2" - "github.com/coreos/coreos-cloudinit/datasource/metadata/packet" - "github.com/coreos/coreos-cloudinit/datasource/proc_cmdline" - "github.com/coreos/coreos-cloudinit/datasource/url" - "github.com/coreos/coreos-cloudinit/pkg" + "github.com/rancher/os/config/cloudinit/config" + "github.com/rancher/os/config/cloudinit/datasource" + "github.com/rancher/os/config/cloudinit/datasource/configdrive" + "github.com/rancher/os/config/cloudinit/datasource/file" + "github.com/rancher/os/config/cloudinit/datasource/metadata/digitalocean" + "github.com/rancher/os/config/cloudinit/datasource/metadata/ec2" + "github.com/rancher/os/config/cloudinit/datasource/metadata/packet" + "github.com/rancher/os/config/cloudinit/datasource/proc_cmdline" + "github.com/rancher/os/config/cloudinit/datasource/url" + "github.com/rancher/os/config/cloudinit/pkg" "github.com/docker/docker/pkg/mount" "github.com/rancher/os/cmd/cloudinitsave/gce" "github.com/rancher/os/cmd/control" diff --git a/cmd/cloudinitsave/gce/metadata.go b/cmd/cloudinitsave/gce/metadata.go index c5200c16..56d6b31c 100644 --- a/cmd/cloudinitsave/gce/metadata.go +++ b/cmd/cloudinitsave/gce/metadata.go @@ -21,8 +21,8 @@ import ( "strconv" "strings" - "github.com/coreos/coreos-cloudinit/datasource" - "github.com/coreos/coreos-cloudinit/datasource/metadata" + "github.com/rancher/os/config/cloudinit/datasource" + "github.com/rancher/os/config/cloudinit/datasource/metadata" ) const ( diff --git a/vendor/github.com/coreos/coreos-cloudinit/.gitignore b/config/cloudinit/.gitignore similarity index 100% rename from vendor/github.com/coreos/coreos-cloudinit/.gitignore rename to config/cloudinit/.gitignore diff --git a/vendor/github.com/coreos/coreos-cloudinit/.travis.yml b/config/cloudinit/.travis.yml similarity index 100% rename from vendor/github.com/coreos/coreos-cloudinit/.travis.yml rename to config/cloudinit/.travis.yml diff --git a/vendor/github.com/coreos/coreos-cloudinit/CONTRIBUTING.md b/config/cloudinit/CONTRIBUTING.md similarity index 100% rename from vendor/github.com/coreos/coreos-cloudinit/CONTRIBUTING.md rename to config/cloudinit/CONTRIBUTING.md diff --git a/vendor/github.com/coreos/coreos-cloudinit/DCO b/config/cloudinit/DCO similarity index 100% rename from vendor/github.com/coreos/coreos-cloudinit/DCO rename to config/cloudinit/DCO diff --git a/vendor/github.com/coreos/coreos-cloudinit/Documentation/cloud-config-deprecated.md b/config/cloudinit/Documentation/cloud-config-deprecated.md similarity index 100% rename from vendor/github.com/coreos/coreos-cloudinit/Documentation/cloud-config-deprecated.md rename to config/cloudinit/Documentation/cloud-config-deprecated.md diff --git a/vendor/github.com/coreos/coreos-cloudinit/Documentation/cloud-config-locations.md b/config/cloudinit/Documentation/cloud-config-locations.md similarity index 100% rename from vendor/github.com/coreos/coreos-cloudinit/Documentation/cloud-config-locations.md rename to config/cloudinit/Documentation/cloud-config-locations.md diff --git a/vendor/github.com/coreos/coreos-cloudinit/Documentation/cloud-config-oem.md b/config/cloudinit/Documentation/cloud-config-oem.md similarity index 100% rename from vendor/github.com/coreos/coreos-cloudinit/Documentation/cloud-config-oem.md rename to config/cloudinit/Documentation/cloud-config-oem.md diff --git a/vendor/github.com/coreos/coreos-cloudinit/Documentation/cloud-config.md b/config/cloudinit/Documentation/cloud-config.md similarity index 99% rename from vendor/github.com/coreos/coreos-cloudinit/Documentation/cloud-config.md rename to config/cloudinit/Documentation/cloud-config.md index 66a7cd41..ecb3be0c 100644 --- a/vendor/github.com/coreos/coreos-cloudinit/Documentation/cloud-config.md +++ b/config/cloudinit/Documentation/cloud-config.md @@ -41,7 +41,7 @@ If cloud-config header starts on `#!` then coreos-cloudinit will recognize it as ### Providing Cloud-Config with Config-Drive -CoreOS tries to conform to each platform's native method to provide user data. Each cloud provider tends to be unique, but this complexity has been abstracted by CoreOS. You can view each platform's instructions on their documentation pages. The most universal way to provide cloud-config is [via config-drive](https://github.com/coreos/coreos-cloudinit/blob/master/Documentation/config-drive.md), which attaches a read-only device to the machine, that contains your cloud-config file. +CoreOS tries to conform to each platform's native method to provide user data. Each cloud provider tends to be unique, but this complexity has been abstracted by CoreOS. You can view each platform's instructions on their documentation pages. The most universal way to provide cloud-config is [via config-drive](https://github.com/rancher/os/config/cloudinit/blob/master/Documentation/config-drive.md), which attaches a read-only device to the machine, that contains your cloud-config file. ## Configuration Parameters diff --git a/vendor/github.com/coreos/coreos-cloudinit/Documentation/config-drive.md b/config/cloudinit/Documentation/config-drive.md similarity index 100% rename from vendor/github.com/coreos/coreos-cloudinit/Documentation/config-drive.md rename to config/cloudinit/Documentation/config-drive.md diff --git a/vendor/github.com/coreos/coreos-cloudinit/Documentation/debian-interfaces.md b/config/cloudinit/Documentation/debian-interfaces.md similarity index 100% rename from vendor/github.com/coreos/coreos-cloudinit/Documentation/debian-interfaces.md rename to config/cloudinit/Documentation/debian-interfaces.md diff --git a/vendor/github.com/coreos/coreos-cloudinit/Documentation/vmware-guestinfo.md b/config/cloudinit/Documentation/vmware-guestinfo.md similarity index 100% rename from vendor/github.com/coreos/coreos-cloudinit/Documentation/vmware-guestinfo.md rename to config/cloudinit/Documentation/vmware-guestinfo.md diff --git a/vendor/github.com/coreos/coreos-cloudinit/LICENSE b/config/cloudinit/LICENSE similarity index 100% rename from vendor/github.com/coreos/coreos-cloudinit/LICENSE rename to config/cloudinit/LICENSE diff --git a/vendor/github.com/coreos/coreos-cloudinit/MAINTAINERS b/config/cloudinit/MAINTAINERS similarity index 100% rename from vendor/github.com/coreos/coreos-cloudinit/MAINTAINERS rename to config/cloudinit/MAINTAINERS diff --git a/vendor/github.com/coreos/coreos-cloudinit/NOTICE b/config/cloudinit/NOTICE similarity index 100% rename from vendor/github.com/coreos/coreos-cloudinit/NOTICE rename to config/cloudinit/NOTICE diff --git a/vendor/github.com/coreos/coreos-cloudinit/README.md b/config/cloudinit/README.md similarity index 91% rename from vendor/github.com/coreos/coreos-cloudinit/README.md rename to config/cloudinit/README.md index a1e5a101..27a4f759 100644 --- a/vendor/github.com/coreos/coreos-cloudinit/README.md +++ b/config/cloudinit/README.md @@ -13,8 +13,8 @@ Additionally, several [CoreOS-specific options][custom-cloud-config] have been i All supported cloud-config parameters are [documented here][all-cloud-config]. [official-cloud-config]: http://cloudinit.readthedocs.org/en/latest/topics/format.html#cloud-config-data -[custom-cloud-config]: https://github.com/coreos/coreos-cloudinit/blob/master/Documentation/cloud-config.md#coreos-parameters -[all-cloud-config]: https://github.com/coreos/coreos-cloudinit/tree/master/Documentation/cloud-config.md +[custom-cloud-config]: https://github.com/rancher/os/config/cloudinit/blob/master/Documentation/cloud-config.md#coreos-parameters +[all-cloud-config]: https://github.com/rancher/os/config/cloudinit/tree/master/Documentation/cloud-config.md The following is an example cloud-config document: diff --git a/vendor/github.com/coreos/coreos-cloudinit/build b/config/cloudinit/build similarity index 100% rename from vendor/github.com/coreos/coreos-cloudinit/build rename to config/cloudinit/build diff --git a/vendor/github.com/coreos/coreos-cloudinit/config/config.go b/config/cloudinit/config/config.go similarity index 100% rename from vendor/github.com/coreos/coreos-cloudinit/config/config.go rename to config/cloudinit/config/config.go diff --git a/vendor/github.com/coreos/coreos-cloudinit/config/config_test.go b/config/cloudinit/config/config_test.go similarity index 100% rename from vendor/github.com/coreos/coreos-cloudinit/config/config_test.go rename to config/cloudinit/config/config_test.go diff --git a/vendor/github.com/coreos/coreos-cloudinit/config/decode.go b/config/cloudinit/config/decode.go similarity index 100% rename from vendor/github.com/coreos/coreos-cloudinit/config/decode.go rename to config/cloudinit/config/decode.go diff --git a/vendor/github.com/coreos/coreos-cloudinit/config/etc_hosts.go b/config/cloudinit/config/etc_hosts.go similarity index 100% rename from vendor/github.com/coreos/coreos-cloudinit/config/etc_hosts.go rename to config/cloudinit/config/etc_hosts.go diff --git a/vendor/github.com/coreos/coreos-cloudinit/config/etcd.go b/config/cloudinit/config/etcd.go similarity index 100% rename from vendor/github.com/coreos/coreos-cloudinit/config/etcd.go rename to config/cloudinit/config/etcd.go diff --git a/vendor/github.com/coreos/coreos-cloudinit/config/etcd2.go b/config/cloudinit/config/etcd2.go similarity index 100% rename from vendor/github.com/coreos/coreos-cloudinit/config/etcd2.go rename to config/cloudinit/config/etcd2.go diff --git a/vendor/github.com/coreos/coreos-cloudinit/config/file.go b/config/cloudinit/config/file.go similarity index 100% rename from vendor/github.com/coreos/coreos-cloudinit/config/file.go rename to config/cloudinit/config/file.go diff --git a/vendor/github.com/coreos/coreos-cloudinit/config/file_test.go b/config/cloudinit/config/file_test.go similarity index 100% rename from vendor/github.com/coreos/coreos-cloudinit/config/file_test.go rename to config/cloudinit/config/file_test.go diff --git a/vendor/github.com/coreos/coreos-cloudinit/config/flannel.go b/config/cloudinit/config/flannel.go similarity index 100% rename from vendor/github.com/coreos/coreos-cloudinit/config/flannel.go rename to config/cloudinit/config/flannel.go diff --git a/vendor/github.com/coreos/coreos-cloudinit/config/fleet.go b/config/cloudinit/config/fleet.go similarity index 100% rename from vendor/github.com/coreos/coreos-cloudinit/config/fleet.go rename to config/cloudinit/config/fleet.go diff --git a/vendor/github.com/coreos/coreos-cloudinit/config/ignition.go b/config/cloudinit/config/ignition.go similarity index 100% rename from vendor/github.com/coreos/coreos-cloudinit/config/ignition.go rename to config/cloudinit/config/ignition.go diff --git a/vendor/github.com/coreos/coreos-cloudinit/config/locksmith.go b/config/cloudinit/config/locksmith.go similarity index 100% rename from vendor/github.com/coreos/coreos-cloudinit/config/locksmith.go rename to config/cloudinit/config/locksmith.go diff --git a/vendor/github.com/coreos/coreos-cloudinit/config/locksmith_test.go b/config/cloudinit/config/locksmith_test.go similarity index 100% rename from vendor/github.com/coreos/coreos-cloudinit/config/locksmith_test.go rename to config/cloudinit/config/locksmith_test.go diff --git a/vendor/github.com/coreos/coreos-cloudinit/config/oem.go b/config/cloudinit/config/oem.go similarity index 100% rename from vendor/github.com/coreos/coreos-cloudinit/config/oem.go rename to config/cloudinit/config/oem.go diff --git a/vendor/github.com/coreos/coreos-cloudinit/config/script.go b/config/cloudinit/config/script.go similarity index 100% rename from vendor/github.com/coreos/coreos-cloudinit/config/script.go rename to config/cloudinit/config/script.go diff --git a/vendor/github.com/coreos/coreos-cloudinit/config/unit.go b/config/cloudinit/config/unit.go similarity index 100% rename from vendor/github.com/coreos/coreos-cloudinit/config/unit.go rename to config/cloudinit/config/unit.go diff --git a/vendor/github.com/coreos/coreos-cloudinit/config/unit_test.go b/config/cloudinit/config/unit_test.go similarity index 100% rename from vendor/github.com/coreos/coreos-cloudinit/config/unit_test.go rename to config/cloudinit/config/unit_test.go diff --git a/vendor/github.com/coreos/coreos-cloudinit/config/update.go b/config/cloudinit/config/update.go similarity index 100% rename from vendor/github.com/coreos/coreos-cloudinit/config/update.go rename to config/cloudinit/config/update.go diff --git a/vendor/github.com/coreos/coreos-cloudinit/config/update_test.go b/config/cloudinit/config/update_test.go similarity index 100% rename from vendor/github.com/coreos/coreos-cloudinit/config/update_test.go rename to config/cloudinit/config/update_test.go diff --git a/vendor/github.com/coreos/coreos-cloudinit/config/user.go b/config/cloudinit/config/user.go similarity index 100% rename from vendor/github.com/coreos/coreos-cloudinit/config/user.go rename to config/cloudinit/config/user.go diff --git a/vendor/github.com/coreos/coreos-cloudinit/config/validate/context.go b/config/cloudinit/config/validate/context.go similarity index 100% rename from vendor/github.com/coreos/coreos-cloudinit/config/validate/context.go rename to config/cloudinit/config/validate/context.go diff --git a/vendor/github.com/coreos/coreos-cloudinit/config/validate/context_test.go b/config/cloudinit/config/validate/context_test.go similarity index 100% rename from vendor/github.com/coreos/coreos-cloudinit/config/validate/context_test.go rename to config/cloudinit/config/validate/context_test.go diff --git a/vendor/github.com/coreos/coreos-cloudinit/config/validate/node.go b/config/cloudinit/config/validate/node.go similarity index 100% rename from vendor/github.com/coreos/coreos-cloudinit/config/validate/node.go rename to config/cloudinit/config/validate/node.go diff --git a/vendor/github.com/coreos/coreos-cloudinit/config/validate/node_test.go b/config/cloudinit/config/validate/node_test.go similarity index 100% rename from vendor/github.com/coreos/coreos-cloudinit/config/validate/node_test.go rename to config/cloudinit/config/validate/node_test.go diff --git a/vendor/github.com/coreos/coreos-cloudinit/config/validate/report.go b/config/cloudinit/config/validate/report.go similarity index 100% rename from vendor/github.com/coreos/coreos-cloudinit/config/validate/report.go rename to config/cloudinit/config/validate/report.go diff --git a/vendor/github.com/coreos/coreos-cloudinit/config/validate/report_test.go b/config/cloudinit/config/validate/report_test.go similarity index 100% rename from vendor/github.com/coreos/coreos-cloudinit/config/validate/report_test.go rename to config/cloudinit/config/validate/report_test.go diff --git a/vendor/github.com/coreos/coreos-cloudinit/config/validate/rules.go b/config/cloudinit/config/validate/rules.go similarity index 99% rename from vendor/github.com/coreos/coreos-cloudinit/config/validate/rules.go rename to config/cloudinit/config/validate/rules.go index 303a3cc1..748685e0 100644 --- a/vendor/github.com/coreos/coreos-cloudinit/config/validate/rules.go +++ b/config/cloudinit/config/validate/rules.go @@ -21,7 +21,7 @@ import ( "reflect" "strings" - "github.com/coreos/coreos-cloudinit/config" + "github.com/rancher/os/config/cloudinit/config" ) type rule func(config node, report *Report) diff --git a/vendor/github.com/coreos/coreos-cloudinit/config/validate/rules_test.go b/config/cloudinit/config/validate/rules_test.go similarity index 100% rename from vendor/github.com/coreos/coreos-cloudinit/config/validate/rules_test.go rename to config/cloudinit/config/validate/rules_test.go diff --git a/vendor/github.com/coreos/coreos-cloudinit/config/validate/validate.go b/config/cloudinit/config/validate/validate.go similarity index 99% rename from vendor/github.com/coreos/coreos-cloudinit/config/validate/validate.go rename to config/cloudinit/config/validate/validate.go index ad5c0b22..b38fd97e 100644 --- a/vendor/github.com/coreos/coreos-cloudinit/config/validate/validate.go +++ b/config/cloudinit/config/validate/validate.go @@ -21,7 +21,7 @@ import ( "strconv" "strings" - "github.com/coreos/coreos-cloudinit/config" + "github.com/rancher/os/config/cloudinit/config" "github.com/coreos/yaml" ) diff --git a/vendor/github.com/coreos/coreos-cloudinit/config/validate/validate_test.go b/config/cloudinit/config/validate/validate_test.go similarity index 100% rename from vendor/github.com/coreos/coreos-cloudinit/config/validate/validate_test.go rename to config/cloudinit/config/validate/validate_test.go diff --git a/vendor/github.com/coreos/coreos-cloudinit/coreos-cloudinit.go b/config/cloudinit/coreos-cloudinit.go similarity index 92% rename from vendor/github.com/coreos/coreos-cloudinit/coreos-cloudinit.go rename to config/cloudinit/coreos-cloudinit.go index d0d2c8a8..f7ec21c9 100644 --- a/vendor/github.com/coreos/coreos-cloudinit/coreos-cloudinit.go +++ b/config/cloudinit/coreos-cloudinit.go @@ -26,24 +26,24 @@ import ( "sync" "time" - "github.com/coreos/coreos-cloudinit/config" - "github.com/coreos/coreos-cloudinit/config/validate" - "github.com/coreos/coreos-cloudinit/datasource" - "github.com/coreos/coreos-cloudinit/datasource/configdrive" - "github.com/coreos/coreos-cloudinit/datasource/file" - "github.com/coreos/coreos-cloudinit/datasource/metadata/cloudsigma" - "github.com/coreos/coreos-cloudinit/datasource/metadata/digitalocean" - "github.com/coreos/coreos-cloudinit/datasource/metadata/ec2" - "github.com/coreos/coreos-cloudinit/datasource/metadata/gce" - "github.com/coreos/coreos-cloudinit/datasource/metadata/packet" - "github.com/coreos/coreos-cloudinit/datasource/proc_cmdline" - "github.com/coreos/coreos-cloudinit/datasource/url" - "github.com/coreos/coreos-cloudinit/datasource/vmware" - "github.com/coreos/coreos-cloudinit/datasource/waagent" - "github.com/coreos/coreos-cloudinit/initialize" - "github.com/coreos/coreos-cloudinit/network" - "github.com/coreos/coreos-cloudinit/pkg" - "github.com/coreos/coreos-cloudinit/system" + "github.com/rancher/os/config/cloudinit/config" + "github.com/rancher/os/config/cloudinit/config/validate" + "github.com/rancher/os/config/cloudinit/datasource" + "github.com/rancher/os/config/cloudinit/datasource/configdrive" + "github.com/rancher/os/config/cloudinit/datasource/file" + "github.com/rancher/os/config/cloudinit/datasource/metadata/cloudsigma" + "github.com/rancher/os/config/cloudinit/datasource/metadata/digitalocean" + "github.com/rancher/os/config/cloudinit/datasource/metadata/ec2" + "github.com/rancher/os/config/cloudinit/datasource/metadata/gce" + "github.com/rancher/os/config/cloudinit/datasource/metadata/packet" + "github.com/rancher/os/config/cloudinit/datasource/proc_cmdline" + "github.com/rancher/os/config/cloudinit/datasource/url" + "github.com/rancher/os/config/cloudinit/datasource/vmware" + "github.com/rancher/os/config/cloudinit/datasource/waagent" + "github.com/rancher/os/config/cloudinit/initialize" + "github.com/rancher/os/config/cloudinit/network" + "github.com/rancher/os/config/cloudinit/pkg" + "github.com/rancher/os/config/cloudinit/system" ) const ( diff --git a/vendor/github.com/coreos/coreos-cloudinit/coreos-cloudinit_test.go b/config/cloudinit/coreos-cloudinit_test.go similarity index 97% rename from vendor/github.com/coreos/coreos-cloudinit/coreos-cloudinit_test.go rename to config/cloudinit/coreos-cloudinit_test.go index cd5c6da4..6e074ea5 100644 --- a/vendor/github.com/coreos/coreos-cloudinit/coreos-cloudinit_test.go +++ b/config/cloudinit/coreos-cloudinit_test.go @@ -21,8 +21,8 @@ import ( "reflect" "testing" - "github.com/coreos/coreos-cloudinit/config" - "github.com/coreos/coreos-cloudinit/datasource" + "github.com/rancher/os/config/cloudinit/config" + "github.com/rancher/os/config/cloudinit/datasource" ) func TestMergeConfigs(t *testing.T) { diff --git a/vendor/github.com/coreos/coreos-cloudinit/cover b/config/cloudinit/cover similarity index 100% rename from vendor/github.com/coreos/coreos-cloudinit/cover rename to config/cloudinit/cover diff --git a/vendor/github.com/coreos/coreos-cloudinit/datasource/configdrive/configdrive.go b/config/cloudinit/datasource/configdrive/configdrive.go similarity index 97% rename from vendor/github.com/coreos/coreos-cloudinit/datasource/configdrive/configdrive.go rename to config/cloudinit/datasource/configdrive/configdrive.go index 6c65bfcc..7aa0f433 100644 --- a/vendor/github.com/coreos/coreos-cloudinit/datasource/configdrive/configdrive.go +++ b/config/cloudinit/datasource/configdrive/configdrive.go @@ -21,7 +21,7 @@ import ( "os" "path" - "github.com/coreos/coreos-cloudinit/datasource" + "github.com/rancher/os/config/cloudinit/datasource" ) const ( diff --git a/vendor/github.com/coreos/coreos-cloudinit/datasource/configdrive/configdrive_test.go b/config/cloudinit/datasource/configdrive/configdrive_test.go similarity index 97% rename from vendor/github.com/coreos/coreos-cloudinit/datasource/configdrive/configdrive_test.go rename to config/cloudinit/datasource/configdrive/configdrive_test.go index e40a8fd5..1b63fb90 100644 --- a/vendor/github.com/coreos/coreos-cloudinit/datasource/configdrive/configdrive_test.go +++ b/config/cloudinit/datasource/configdrive/configdrive_test.go @@ -18,8 +18,8 @@ import ( "reflect" "testing" - "github.com/coreos/coreos-cloudinit/datasource" - "github.com/coreos/coreos-cloudinit/datasource/test" + "github.com/rancher/os/config/cloudinit/datasource" + "github.com/rancher/os/config/cloudinit/datasource/test" ) func TestFetchMetadata(t *testing.T) { diff --git a/vendor/github.com/coreos/coreos-cloudinit/datasource/datasource.go b/config/cloudinit/datasource/datasource.go similarity index 100% rename from vendor/github.com/coreos/coreos-cloudinit/datasource/datasource.go rename to config/cloudinit/datasource/datasource.go diff --git a/vendor/github.com/coreos/coreos-cloudinit/datasource/file/file.go b/config/cloudinit/datasource/file/file.go similarity index 95% rename from vendor/github.com/coreos/coreos-cloudinit/datasource/file/file.go rename to config/cloudinit/datasource/file/file.go index 2700b460..4b68579d 100644 --- a/vendor/github.com/coreos/coreos-cloudinit/datasource/file/file.go +++ b/config/cloudinit/datasource/file/file.go @@ -18,7 +18,7 @@ import ( "io/ioutil" "os" - "github.com/coreos/coreos-cloudinit/datasource" + "github.com/rancher/os/config/cloudinit/datasource" ) type localFile struct { diff --git a/vendor/github.com/coreos/coreos-cloudinit/datasource/metadata/cloudsigma/server_context.go b/config/cloudinit/datasource/metadata/cloudsigma/server_context.go similarity index 98% rename from vendor/github.com/coreos/coreos-cloudinit/datasource/metadata/cloudsigma/server_context.go rename to config/cloudinit/datasource/metadata/cloudsigma/server_context.go index 0c3924cc..89f14eb0 100644 --- a/vendor/github.com/coreos/coreos-cloudinit/datasource/metadata/cloudsigma/server_context.go +++ b/config/cloudinit/datasource/metadata/cloudsigma/server_context.go @@ -24,7 +24,7 @@ import ( "os" "strings" - "github.com/coreos/coreos-cloudinit/datasource" + "github.com/rancher/os/config/cloudinit/datasource" "github.com/cloudsigma/cepgo" ) diff --git a/vendor/github.com/coreos/coreos-cloudinit/datasource/metadata/cloudsigma/server_context_test.go b/config/cloudinit/datasource/metadata/cloudsigma/server_context_test.go similarity index 100% rename from vendor/github.com/coreos/coreos-cloudinit/datasource/metadata/cloudsigma/server_context_test.go rename to config/cloudinit/datasource/metadata/cloudsigma/server_context_test.go diff --git a/vendor/github.com/coreos/coreos-cloudinit/datasource/metadata/digitalocean/metadata.go b/config/cloudinit/datasource/metadata/digitalocean/metadata.go similarity index 96% rename from vendor/github.com/coreos/coreos-cloudinit/datasource/metadata/digitalocean/metadata.go rename to config/cloudinit/datasource/metadata/digitalocean/metadata.go index 71982d0c..f6bb19bf 100644 --- a/vendor/github.com/coreos/coreos-cloudinit/datasource/metadata/digitalocean/metadata.go +++ b/config/cloudinit/datasource/metadata/digitalocean/metadata.go @@ -19,8 +19,8 @@ import ( "net" "strconv" - "github.com/coreos/coreos-cloudinit/datasource" - "github.com/coreos/coreos-cloudinit/datasource/metadata" + "github.com/rancher/os/config/cloudinit/datasource" + "github.com/rancher/os/config/cloudinit/datasource/metadata" ) const ( diff --git a/vendor/github.com/coreos/coreos-cloudinit/datasource/metadata/digitalocean/metadata_test.go b/config/cloudinit/datasource/metadata/digitalocean/metadata_test.go similarity index 93% rename from vendor/github.com/coreos/coreos-cloudinit/datasource/metadata/digitalocean/metadata_test.go rename to config/cloudinit/datasource/metadata/digitalocean/metadata_test.go index c38a490c..a6ca31b9 100644 --- a/vendor/github.com/coreos/coreos-cloudinit/datasource/metadata/digitalocean/metadata_test.go +++ b/config/cloudinit/datasource/metadata/digitalocean/metadata_test.go @@ -20,10 +20,10 @@ import ( "reflect" "testing" - "github.com/coreos/coreos-cloudinit/datasource" - "github.com/coreos/coreos-cloudinit/datasource/metadata" - "github.com/coreos/coreos-cloudinit/datasource/metadata/test" - "github.com/coreos/coreos-cloudinit/pkg" + "github.com/rancher/os/config/cloudinit/datasource" + "github.com/rancher/os/config/cloudinit/datasource/metadata" + "github.com/rancher/os/config/cloudinit/datasource/metadata/test" + "github.com/rancher/os/config/cloudinit/pkg" ) func TestType(t *testing.T) { diff --git a/vendor/github.com/coreos/coreos-cloudinit/datasource/metadata/ec2/metadata.go b/config/cloudinit/datasource/metadata/ec2/metadata.go similarity index 95% rename from vendor/github.com/coreos/coreos-cloudinit/datasource/metadata/ec2/metadata.go rename to config/cloudinit/datasource/metadata/ec2/metadata.go index 5489e1d3..51f6988c 100644 --- a/vendor/github.com/coreos/coreos-cloudinit/datasource/metadata/ec2/metadata.go +++ b/config/cloudinit/datasource/metadata/ec2/metadata.go @@ -22,9 +22,9 @@ import ( "net" "strings" - "github.com/coreos/coreos-cloudinit/datasource" - "github.com/coreos/coreos-cloudinit/datasource/metadata" - "github.com/coreos/coreos-cloudinit/pkg" + "github.com/rancher/os/config/cloudinit/datasource" + "github.com/rancher/os/config/cloudinit/datasource/metadata" + "github.com/rancher/os/config/cloudinit/pkg" ) const ( diff --git a/vendor/github.com/coreos/coreos-cloudinit/datasource/metadata/ec2/metadata_test.go b/config/cloudinit/datasource/metadata/ec2/metadata_test.go similarity index 96% rename from vendor/github.com/coreos/coreos-cloudinit/datasource/metadata/ec2/metadata_test.go rename to config/cloudinit/datasource/metadata/ec2/metadata_test.go index ba463c28..f892caea 100644 --- a/vendor/github.com/coreos/coreos-cloudinit/datasource/metadata/ec2/metadata_test.go +++ b/config/cloudinit/datasource/metadata/ec2/metadata_test.go @@ -20,10 +20,10 @@ import ( "reflect" "testing" - "github.com/coreos/coreos-cloudinit/datasource" - "github.com/coreos/coreos-cloudinit/datasource/metadata" - "github.com/coreos/coreos-cloudinit/datasource/metadata/test" - "github.com/coreos/coreos-cloudinit/pkg" + "github.com/rancher/os/config/cloudinit/datasource" + "github.com/rancher/os/config/cloudinit/datasource/metadata" + "github.com/rancher/os/config/cloudinit/datasource/metadata/test" + "github.com/rancher/os/config/cloudinit/pkg" ) func TestType(t *testing.T) { diff --git a/vendor/github.com/coreos/coreos-cloudinit/datasource/metadata/gce/metadata.go b/config/cloudinit/datasource/metadata/gce/metadata.go similarity index 94% rename from vendor/github.com/coreos/coreos-cloudinit/datasource/metadata/gce/metadata.go rename to config/cloudinit/datasource/metadata/gce/metadata.go index 494741c7..43fcd72c 100644 --- a/vendor/github.com/coreos/coreos-cloudinit/datasource/metadata/gce/metadata.go +++ b/config/cloudinit/datasource/metadata/gce/metadata.go @@ -19,8 +19,8 @@ import ( "net" "net/http" - "github.com/coreos/coreos-cloudinit/datasource" - "github.com/coreos/coreos-cloudinit/datasource/metadata" + "github.com/rancher/os/config/cloudinit/datasource" + "github.com/rancher/os/config/cloudinit/datasource/metadata" ) const ( diff --git a/vendor/github.com/coreos/coreos-cloudinit/datasource/metadata/gce/metadata_test.go b/config/cloudinit/datasource/metadata/gce/metadata_test.go similarity index 92% rename from vendor/github.com/coreos/coreos-cloudinit/datasource/metadata/gce/metadata_test.go rename to config/cloudinit/datasource/metadata/gce/metadata_test.go index 0cc59f1d..614d190c 100644 --- a/vendor/github.com/coreos/coreos-cloudinit/datasource/metadata/gce/metadata_test.go +++ b/config/cloudinit/datasource/metadata/gce/metadata_test.go @@ -20,10 +20,10 @@ import ( "reflect" "testing" - "github.com/coreos/coreos-cloudinit/datasource" - "github.com/coreos/coreos-cloudinit/datasource/metadata" - "github.com/coreos/coreos-cloudinit/datasource/metadata/test" - "github.com/coreos/coreos-cloudinit/pkg" + "github.com/rancher/os/config/cloudinit/datasource" + "github.com/rancher/os/config/cloudinit/datasource/metadata" + "github.com/rancher/os/config/cloudinit/datasource/metadata/test" + "github.com/rancher/os/config/cloudinit/pkg" ) func TestType(t *testing.T) { diff --git a/vendor/github.com/coreos/coreos-cloudinit/datasource/metadata/metadata.go b/config/cloudinit/datasource/metadata/metadata.go similarity index 97% rename from vendor/github.com/coreos/coreos-cloudinit/datasource/metadata/metadata.go rename to config/cloudinit/datasource/metadata/metadata.go index 9d52e933..a950e8c9 100644 --- a/vendor/github.com/coreos/coreos-cloudinit/datasource/metadata/metadata.go +++ b/config/cloudinit/datasource/metadata/metadata.go @@ -18,7 +18,7 @@ import ( "net/http" "strings" - "github.com/coreos/coreos-cloudinit/pkg" + "github.com/rancher/os/config/cloudinit/pkg" ) type MetadataService struct { diff --git a/vendor/github.com/coreos/coreos-cloudinit/datasource/metadata/metadata_test.go b/config/cloudinit/datasource/metadata/metadata_test.go similarity index 97% rename from vendor/github.com/coreos/coreos-cloudinit/datasource/metadata/metadata_test.go rename to config/cloudinit/datasource/metadata/metadata_test.go index 5d2258f0..e6c06ee7 100644 --- a/vendor/github.com/coreos/coreos-cloudinit/datasource/metadata/metadata_test.go +++ b/config/cloudinit/datasource/metadata/metadata_test.go @@ -19,8 +19,8 @@ import ( "fmt" "testing" - "github.com/coreos/coreos-cloudinit/datasource/metadata/test" - "github.com/coreos/coreos-cloudinit/pkg" + "github.com/rancher/os/config/cloudinit/datasource/metadata/test" + "github.com/rancher/os/config/cloudinit/pkg" ) func TestAvailabilityChanges(t *testing.T) { diff --git a/vendor/github.com/coreos/coreos-cloudinit/datasource/metadata/packet/metadata.go b/config/cloudinit/datasource/metadata/packet/metadata.go similarity index 95% rename from vendor/github.com/coreos/coreos-cloudinit/datasource/metadata/packet/metadata.go rename to config/cloudinit/datasource/metadata/packet/metadata.go index 19d3931a..a7aea9dc 100644 --- a/vendor/github.com/coreos/coreos-cloudinit/datasource/metadata/packet/metadata.go +++ b/config/cloudinit/datasource/metadata/packet/metadata.go @@ -19,8 +19,8 @@ import ( "net" "strconv" - "github.com/coreos/coreos-cloudinit/datasource" - "github.com/coreos/coreos-cloudinit/datasource/metadata" + "github.com/rancher/os/config/cloudinit/datasource" + "github.com/rancher/os/config/cloudinit/datasource/metadata" ) const ( diff --git a/vendor/github.com/coreos/coreos-cloudinit/datasource/metadata/test/test.go b/config/cloudinit/datasource/metadata/test/test.go similarity index 95% rename from vendor/github.com/coreos/coreos-cloudinit/datasource/metadata/test/test.go rename to config/cloudinit/datasource/metadata/test/test.go index 3be08f3b..1c062a74 100644 --- a/vendor/github.com/coreos/coreos-cloudinit/datasource/metadata/test/test.go +++ b/config/cloudinit/datasource/metadata/test/test.go @@ -17,7 +17,7 @@ package test import ( "fmt" - "github.com/coreos/coreos-cloudinit/pkg" + "github.com/rancher/os/config/cloudinit/pkg" ) type HttpClient struct { diff --git a/vendor/github.com/coreos/coreos-cloudinit/datasource/proc_cmdline/proc_cmdline.go b/config/cloudinit/datasource/proc_cmdline/proc_cmdline.go similarity index 95% rename from vendor/github.com/coreos/coreos-cloudinit/datasource/proc_cmdline/proc_cmdline.go rename to config/cloudinit/datasource/proc_cmdline/proc_cmdline.go index 8423b251..f44693f3 100644 --- a/vendor/github.com/coreos/coreos-cloudinit/datasource/proc_cmdline/proc_cmdline.go +++ b/config/cloudinit/datasource/proc_cmdline/proc_cmdline.go @@ -20,8 +20,8 @@ import ( "log" "strings" - "github.com/coreos/coreos-cloudinit/datasource" - "github.com/coreos/coreos-cloudinit/pkg" + "github.com/rancher/os/config/cloudinit/datasource" + "github.com/rancher/os/config/cloudinit/pkg" ) const ( diff --git a/vendor/github.com/coreos/coreos-cloudinit/datasource/proc_cmdline/proc_cmdline_test.go b/config/cloudinit/datasource/proc_cmdline/proc_cmdline_test.go similarity index 100% rename from vendor/github.com/coreos/coreos-cloudinit/datasource/proc_cmdline/proc_cmdline_test.go rename to config/cloudinit/datasource/proc_cmdline/proc_cmdline_test.go diff --git a/vendor/github.com/coreos/coreos-cloudinit/datasource/test/filesystem.go b/config/cloudinit/datasource/test/filesystem.go similarity index 100% rename from vendor/github.com/coreos/coreos-cloudinit/datasource/test/filesystem.go rename to config/cloudinit/datasource/test/filesystem.go diff --git a/vendor/github.com/coreos/coreos-cloudinit/datasource/test/filesystem_test.go b/config/cloudinit/datasource/test/filesystem_test.go similarity index 100% rename from vendor/github.com/coreos/coreos-cloudinit/datasource/test/filesystem_test.go rename to config/cloudinit/datasource/test/filesystem_test.go diff --git a/vendor/github.com/coreos/coreos-cloudinit/datasource/url/url.go b/config/cloudinit/datasource/url/url.go similarity index 92% rename from vendor/github.com/coreos/coreos-cloudinit/datasource/url/url.go rename to config/cloudinit/datasource/url/url.go index 8a9c5416..311f9a42 100644 --- a/vendor/github.com/coreos/coreos-cloudinit/datasource/url/url.go +++ b/config/cloudinit/datasource/url/url.go @@ -15,8 +15,8 @@ package url import ( - "github.com/coreos/coreos-cloudinit/datasource" - "github.com/coreos/coreos-cloudinit/pkg" + "github.com/rancher/os/config/cloudinit/datasource" + "github.com/rancher/os/config/cloudinit/pkg" ) type remoteFile struct { diff --git a/vendor/github.com/coreos/coreos-cloudinit/datasource/vmware/vmware.go b/config/cloudinit/datasource/vmware/vmware.go similarity index 97% rename from vendor/github.com/coreos/coreos-cloudinit/datasource/vmware/vmware.go rename to config/cloudinit/datasource/vmware/vmware.go index d74392c3..79d2e4ce 100644 --- a/vendor/github.com/coreos/coreos-cloudinit/datasource/vmware/vmware.go +++ b/config/cloudinit/datasource/vmware/vmware.go @@ -18,8 +18,8 @@ import ( "fmt" "net" - "github.com/coreos/coreos-cloudinit/config" - "github.com/coreos/coreos-cloudinit/datasource" + "github.com/rancher/os/config/cloudinit/config" + "github.com/rancher/os/config/cloudinit/datasource" ) type readConfigFunction func(key string) (string, error) diff --git a/vendor/github.com/coreos/coreos-cloudinit/datasource/vmware/vmware_amd64.go b/config/cloudinit/datasource/vmware/vmware_amd64.go similarity index 98% rename from vendor/github.com/coreos/coreos-cloudinit/datasource/vmware/vmware_amd64.go rename to config/cloudinit/datasource/vmware/vmware_amd64.go index 79c6ca34..eadd374c 100644 --- a/vendor/github.com/coreos/coreos-cloudinit/datasource/vmware/vmware_amd64.go +++ b/config/cloudinit/datasource/vmware/vmware_amd64.go @@ -19,7 +19,7 @@ import ( "log" "os" - "github.com/coreos/coreos-cloudinit/pkg" + "github.com/rancher/os/config/cloudinit/pkg" "github.com/sigma/vmw-guestinfo/rpcvmx" "github.com/sigma/vmw-guestinfo/vmcheck" diff --git a/vendor/github.com/coreos/coreos-cloudinit/datasource/vmware/vmware_test.go b/config/cloudinit/datasource/vmware/vmware_test.go similarity index 99% rename from vendor/github.com/coreos/coreos-cloudinit/datasource/vmware/vmware_test.go rename to config/cloudinit/datasource/vmware/vmware_test.go index 9ab645a7..c4ed5279 100644 --- a/vendor/github.com/coreos/coreos-cloudinit/datasource/vmware/vmware_test.go +++ b/config/cloudinit/datasource/vmware/vmware_test.go @@ -22,7 +22,7 @@ import ( "reflect" "testing" - "github.com/coreos/coreos-cloudinit/datasource" + "github.com/rancher/os/config/cloudinit/datasource" ) type MockHypervisor map[string]string diff --git a/vendor/github.com/coreos/coreos-cloudinit/datasource/vmware/vmware_unsupported.go b/config/cloudinit/datasource/vmware/vmware_unsupported.go similarity index 100% rename from vendor/github.com/coreos/coreos-cloudinit/datasource/vmware/vmware_unsupported.go rename to config/cloudinit/datasource/vmware/vmware_unsupported.go diff --git a/vendor/github.com/coreos/coreos-cloudinit/datasource/waagent/waagent.go b/config/cloudinit/datasource/waagent/waagent.go similarity index 98% rename from vendor/github.com/coreos/coreos-cloudinit/datasource/waagent/waagent.go rename to config/cloudinit/datasource/waagent/waagent.go index c70a60f4..6b7ac6f7 100644 --- a/vendor/github.com/coreos/coreos-cloudinit/datasource/waagent/waagent.go +++ b/config/cloudinit/datasource/waagent/waagent.go @@ -22,7 +22,7 @@ import ( "os" "path" - "github.com/coreos/coreos-cloudinit/datasource" + "github.com/rancher/os/config/cloudinit/datasource" ) type waagent struct { diff --git a/vendor/github.com/coreos/coreos-cloudinit/datasource/waagent/waagent_test.go b/config/cloudinit/datasource/waagent/waagent_test.go similarity index 97% rename from vendor/github.com/coreos/coreos-cloudinit/datasource/waagent/waagent_test.go rename to config/cloudinit/datasource/waagent/waagent_test.go index f60a4c2b..d80464e3 100644 --- a/vendor/github.com/coreos/coreos-cloudinit/datasource/waagent/waagent_test.go +++ b/config/cloudinit/datasource/waagent/waagent_test.go @@ -19,8 +19,8 @@ import ( "reflect" "testing" - "github.com/coreos/coreos-cloudinit/datasource" - "github.com/coreos/coreos-cloudinit/datasource/test" + "github.com/rancher/os/config/cloudinit/datasource" + "github.com/rancher/os/config/cloudinit/datasource/test" ) func TestFetchMetadata(t *testing.T) { diff --git a/vendor/github.com/coreos/coreos-cloudinit/initialize/config.go b/config/cloudinit/initialize/config.go similarity index 98% rename from vendor/github.com/coreos/coreos-cloudinit/initialize/config.go rename to config/cloudinit/initialize/config.go index d79c24b7..4d2e5b20 100644 --- a/vendor/github.com/coreos/coreos-cloudinit/initialize/config.go +++ b/config/cloudinit/initialize/config.go @@ -20,9 +20,9 @@ import ( "log" "path" - "github.com/coreos/coreos-cloudinit/config" - "github.com/coreos/coreos-cloudinit/network" - "github.com/coreos/coreos-cloudinit/system" + "github.com/rancher/os/config/cloudinit/config" + "github.com/rancher/os/config/cloudinit/network" + "github.com/rancher/os/config/cloudinit/system" ) // CloudConfigFile represents a CoreOS specific configuration option that can generate diff --git a/vendor/github.com/coreos/coreos-cloudinit/initialize/config_test.go b/config/cloudinit/initialize/config_test.go similarity index 97% rename from vendor/github.com/coreos/coreos-cloudinit/initialize/config_test.go rename to config/cloudinit/initialize/config_test.go index b8b92493..d9354c4c 100644 --- a/vendor/github.com/coreos/coreos-cloudinit/initialize/config_test.go +++ b/config/cloudinit/initialize/config_test.go @@ -18,9 +18,9 @@ import ( "reflect" "testing" - "github.com/coreos/coreos-cloudinit/config" - "github.com/coreos/coreos-cloudinit/network" - "github.com/coreos/coreos-cloudinit/system" + "github.com/rancher/os/config/cloudinit/config" + "github.com/rancher/os/config/cloudinit/network" + "github.com/rancher/os/config/cloudinit/system" ) type TestUnitManager struct { diff --git a/vendor/github.com/coreos/coreos-cloudinit/initialize/env.go b/config/cloudinit/initialize/env.go similarity index 95% rename from vendor/github.com/coreos/coreos-cloudinit/initialize/env.go rename to config/cloudinit/initialize/env.go index f90cc932..1bac8203 100644 --- a/vendor/github.com/coreos/coreos-cloudinit/initialize/env.go +++ b/config/cloudinit/initialize/env.go @@ -21,9 +21,9 @@ import ( "regexp" "strings" - "github.com/coreos/coreos-cloudinit/config" - "github.com/coreos/coreos-cloudinit/datasource" - "github.com/coreos/coreos-cloudinit/system" + "github.com/rancher/os/config/cloudinit/config" + "github.com/rancher/os/config/cloudinit/datasource" + "github.com/rancher/os/config/cloudinit/system" ) const DefaultSSHKeyName = "coreos-cloudinit" diff --git a/vendor/github.com/coreos/coreos-cloudinit/initialize/env_test.go b/config/cloudinit/initialize/env_test.go similarity index 97% rename from vendor/github.com/coreos/coreos-cloudinit/initialize/env_test.go rename to config/cloudinit/initialize/env_test.go index abb770cf..24092cd3 100644 --- a/vendor/github.com/coreos/coreos-cloudinit/initialize/env_test.go +++ b/config/cloudinit/initialize/env_test.go @@ -21,8 +21,8 @@ import ( "path" "testing" - "github.com/coreos/coreos-cloudinit/datasource" - "github.com/coreos/coreos-cloudinit/system" + "github.com/rancher/os/config/cloudinit/datasource" + "github.com/rancher/os/config/cloudinit/system" ) func TestEnvironmentApply(t *testing.T) { diff --git a/vendor/github.com/coreos/coreos-cloudinit/initialize/github.go b/config/cloudinit/initialize/github.go similarity index 95% rename from vendor/github.com/coreos/coreos-cloudinit/initialize/github.go rename to config/cloudinit/initialize/github.go index 2f7755fe..3781df3a 100644 --- a/vendor/github.com/coreos/coreos-cloudinit/initialize/github.go +++ b/config/cloudinit/initialize/github.go @@ -17,7 +17,7 @@ package initialize import ( "fmt" - "github.com/coreos/coreos-cloudinit/system" + "github.com/rancher/os/config/cloudinit/system" ) func SSHImportGithubUser(system_user string, github_user string) error { diff --git a/vendor/github.com/coreos/coreos-cloudinit/initialize/ssh_keys.go b/config/cloudinit/initialize/ssh_keys.go similarity index 93% rename from vendor/github.com/coreos/coreos-cloudinit/initialize/ssh_keys.go rename to config/cloudinit/initialize/ssh_keys.go index 17b0c4a9..945836c9 100644 --- a/vendor/github.com/coreos/coreos-cloudinit/initialize/ssh_keys.go +++ b/config/cloudinit/initialize/ssh_keys.go @@ -18,8 +18,8 @@ import ( "encoding/json" "fmt" - "github.com/coreos/coreos-cloudinit/pkg" - "github.com/coreos/coreos-cloudinit/system" + "github.com/rancher/os/config/cloudinit/pkg" + "github.com/rancher/os/config/cloudinit/system" ) type UserKey struct { diff --git a/vendor/github.com/coreos/coreos-cloudinit/initialize/ssh_keys_test.go b/config/cloudinit/initialize/ssh_keys_test.go similarity index 100% rename from vendor/github.com/coreos/coreos-cloudinit/initialize/ssh_keys_test.go rename to config/cloudinit/initialize/ssh_keys_test.go diff --git a/vendor/github.com/coreos/coreos-cloudinit/initialize/user_data.go b/config/cloudinit/initialize/user_data.go similarity index 96% rename from vendor/github.com/coreos/coreos-cloudinit/initialize/user_data.go rename to config/cloudinit/initialize/user_data.go index 42cbcd50..fdcb4271 100644 --- a/vendor/github.com/coreos/coreos-cloudinit/initialize/user_data.go +++ b/config/cloudinit/initialize/user_data.go @@ -18,7 +18,7 @@ import ( "errors" "log" - "github.com/coreos/coreos-cloudinit/config" + "github.com/rancher/os/config/cloudinit/config" ) var ( diff --git a/vendor/github.com/coreos/coreos-cloudinit/initialize/user_data_test.go b/config/cloudinit/initialize/user_data_test.go similarity index 97% rename from vendor/github.com/coreos/coreos-cloudinit/initialize/user_data_test.go rename to config/cloudinit/initialize/user_data_test.go index 7a5acc98..0c75aa10 100644 --- a/vendor/github.com/coreos/coreos-cloudinit/initialize/user_data_test.go +++ b/config/cloudinit/initialize/user_data_test.go @@ -17,7 +17,7 @@ package initialize import ( "testing" - "github.com/coreos/coreos-cloudinit/config" + "github.com/rancher/os/config/cloudinit/config" ) func TestParseHeaderCRLF(t *testing.T) { diff --git a/vendor/github.com/coreos/coreos-cloudinit/initialize/workspace.go b/config/cloudinit/initialize/workspace.go similarity index 94% rename from vendor/github.com/coreos/coreos-cloudinit/initialize/workspace.go rename to config/cloudinit/initialize/workspace.go index 540dcf41..08ed2ae2 100644 --- a/vendor/github.com/coreos/coreos-cloudinit/initialize/workspace.go +++ b/config/cloudinit/initialize/workspace.go @@ -19,8 +19,8 @@ import ( "path" "strings" - "github.com/coreos/coreos-cloudinit/config" - "github.com/coreos/coreos-cloudinit/system" + "github.com/rancher/os/config/cloudinit/config" + "github.com/rancher/os/config/cloudinit/system" ) func PrepWorkspace(workspace string) error { diff --git a/vendor/github.com/coreos/coreos-cloudinit/network/debian.go b/config/cloudinit/network/debian.go similarity index 100% rename from vendor/github.com/coreos/coreos-cloudinit/network/debian.go rename to config/cloudinit/network/debian.go diff --git a/vendor/github.com/coreos/coreos-cloudinit/network/debian_test.go b/config/cloudinit/network/debian_test.go similarity index 100% rename from vendor/github.com/coreos/coreos-cloudinit/network/debian_test.go rename to config/cloudinit/network/debian_test.go diff --git a/vendor/github.com/coreos/coreos-cloudinit/network/interface.go b/config/cloudinit/network/interface.go similarity index 100% rename from vendor/github.com/coreos/coreos-cloudinit/network/interface.go rename to config/cloudinit/network/interface.go diff --git a/vendor/github.com/coreos/coreos-cloudinit/network/interface_test.go b/config/cloudinit/network/interface_test.go similarity index 100% rename from vendor/github.com/coreos/coreos-cloudinit/network/interface_test.go rename to config/cloudinit/network/interface_test.go diff --git a/vendor/github.com/coreos/coreos-cloudinit/network/is_go15_false_test.go b/config/cloudinit/network/is_go15_false_test.go similarity index 100% rename from vendor/github.com/coreos/coreos-cloudinit/network/is_go15_false_test.go rename to config/cloudinit/network/is_go15_false_test.go diff --git a/vendor/github.com/coreos/coreos-cloudinit/network/is_go15_true_test.go b/config/cloudinit/network/is_go15_true_test.go similarity index 100% rename from vendor/github.com/coreos/coreos-cloudinit/network/is_go15_true_test.go rename to config/cloudinit/network/is_go15_true_test.go diff --git a/vendor/github.com/coreos/coreos-cloudinit/network/packet.go b/config/cloudinit/network/packet.go similarity index 97% rename from vendor/github.com/coreos/coreos-cloudinit/network/packet.go rename to config/cloudinit/network/packet.go index a2834ff9..f8699532 100644 --- a/vendor/github.com/coreos/coreos-cloudinit/network/packet.go +++ b/config/cloudinit/network/packet.go @@ -17,7 +17,7 @@ package network import ( "net" - "github.com/coreos/coreos-cloudinit/datasource/metadata/packet" + "github.com/rancher/os/config/cloudinit/datasource/metadata/packet" ) func ProcessPacketNetconf(netdata packet.NetworkData) ([]InterfaceGenerator, error) { diff --git a/vendor/github.com/coreos/coreos-cloudinit/network/stanza.go b/config/cloudinit/network/stanza.go similarity index 100% rename from vendor/github.com/coreos/coreos-cloudinit/network/stanza.go rename to config/cloudinit/network/stanza.go diff --git a/vendor/github.com/coreos/coreos-cloudinit/network/stanza_test.go b/config/cloudinit/network/stanza_test.go similarity index 100% rename from vendor/github.com/coreos/coreos-cloudinit/network/stanza_test.go rename to config/cloudinit/network/stanza_test.go diff --git a/vendor/github.com/coreos/coreos-cloudinit/network/vmware.go b/config/cloudinit/network/vmware.go similarity index 100% rename from vendor/github.com/coreos/coreos-cloudinit/network/vmware.go rename to config/cloudinit/network/vmware.go diff --git a/vendor/github.com/coreos/coreos-cloudinit/network/vmware_test.go b/config/cloudinit/network/vmware_test.go similarity index 100% rename from vendor/github.com/coreos/coreos-cloudinit/network/vmware_test.go rename to config/cloudinit/network/vmware_test.go diff --git a/vendor/github.com/coreos/coreos-cloudinit/pkg/http_client.go b/config/cloudinit/pkg/http_client.go similarity index 100% rename from vendor/github.com/coreos/coreos-cloudinit/pkg/http_client.go rename to config/cloudinit/pkg/http_client.go diff --git a/vendor/github.com/coreos/coreos-cloudinit/pkg/http_client_test.go b/config/cloudinit/pkg/http_client_test.go similarity index 96% rename from vendor/github.com/coreos/coreos-cloudinit/pkg/http_client_test.go rename to config/cloudinit/pkg/http_client_test.go index d581d94e..aca84abc 100644 --- a/vendor/github.com/coreos/coreos-cloudinit/pkg/http_client_test.go +++ b/config/cloudinit/pkg/http_client_test.go @@ -109,8 +109,8 @@ coreos: id: test name: CoreOS.box for Test version-id: %VERSION_ID%+%BUILD_ID% - home-url: https://github.com/coreos/coreos-cloudinit - bug-report-url: https://github.com/coreos/coreos-cloudinit + home-url: https://github.com/rancher/os/config/cloudinit + bug-report-url: https://github.com/rancher/os/config/cloudinit update: reboot-strategy: best-effort ` diff --git a/vendor/github.com/coreos/coreos-cloudinit/system/env.go b/config/cloudinit/system/env.go similarity index 96% rename from vendor/github.com/coreos/coreos-cloudinit/system/env.go rename to config/cloudinit/system/env.go index 60702b6d..6ed81bb0 100644 --- a/vendor/github.com/coreos/coreos-cloudinit/system/env.go +++ b/config/cloudinit/system/env.go @@ -18,7 +18,7 @@ import ( "fmt" "reflect" - "github.com/coreos/coreos-cloudinit/config" + "github.com/rancher/os/config/cloudinit/config" ) // serviceContents generates the contents for a drop-in unit given the config. diff --git a/vendor/github.com/coreos/coreos-cloudinit/system/env_file.go b/config/cloudinit/system/env_file.go similarity index 100% rename from vendor/github.com/coreos/coreos-cloudinit/system/env_file.go rename to config/cloudinit/system/env_file.go diff --git a/vendor/github.com/coreos/coreos-cloudinit/system/env_file_test.go b/config/cloudinit/system/env_file_test.go similarity index 99% rename from vendor/github.com/coreos/coreos-cloudinit/system/env_file_test.go rename to config/cloudinit/system/env_file_test.go index 5ec03640..53fd0132 100644 --- a/vendor/github.com/coreos/coreos-cloudinit/system/env_file_test.go +++ b/config/cloudinit/system/env_file_test.go @@ -22,7 +22,7 @@ import ( "syscall" "testing" - "github.com/coreos/coreos-cloudinit/config" + "github.com/rancher/os/config/cloudinit/config" ) const ( diff --git a/vendor/github.com/coreos/coreos-cloudinit/system/env_test.go b/config/cloudinit/system/env_test.go similarity index 100% rename from vendor/github.com/coreos/coreos-cloudinit/system/env_test.go rename to config/cloudinit/system/env_test.go diff --git a/vendor/github.com/coreos/coreos-cloudinit/system/etc_hosts.go b/config/cloudinit/system/etc_hosts.go similarity index 96% rename from vendor/github.com/coreos/coreos-cloudinit/system/etc_hosts.go rename to config/cloudinit/system/etc_hosts.go index 7208c161..8ee4093c 100644 --- a/vendor/github.com/coreos/coreos-cloudinit/system/etc_hosts.go +++ b/config/cloudinit/system/etc_hosts.go @@ -20,7 +20,7 @@ import ( "os" "path" - "github.com/coreos/coreos-cloudinit/config" + "github.com/rancher/os/config/cloudinit/config" ) const DefaultIpv4Address = "127.0.0.1" diff --git a/vendor/github.com/coreos/coreos-cloudinit/system/etc_hosts_test.go b/config/cloudinit/system/etc_hosts_test.go similarity index 96% rename from vendor/github.com/coreos/coreos-cloudinit/system/etc_hosts_test.go rename to config/cloudinit/system/etc_hosts_test.go index e5efd7c4..c7827a14 100644 --- a/vendor/github.com/coreos/coreos-cloudinit/system/etc_hosts_test.go +++ b/config/cloudinit/system/etc_hosts_test.go @@ -20,7 +20,7 @@ import ( "reflect" "testing" - "github.com/coreos/coreos-cloudinit/config" + "github.com/rancher/os/config/cloudinit/config" ) func TestEtcdHostsFile(t *testing.T) { diff --git a/vendor/github.com/coreos/coreos-cloudinit/system/etcd.go b/config/cloudinit/system/etcd.go similarity index 95% rename from vendor/github.com/coreos/coreos-cloudinit/system/etcd.go rename to config/cloudinit/system/etcd.go index 0c7faf4a..febdc8e8 100644 --- a/vendor/github.com/coreos/coreos-cloudinit/system/etcd.go +++ b/config/cloudinit/system/etcd.go @@ -15,7 +15,7 @@ package system import ( - "github.com/coreos/coreos-cloudinit/config" + "github.com/rancher/os/config/cloudinit/config" ) // Etcd is a top-level structure which embeds its underlying configuration, diff --git a/vendor/github.com/coreos/coreos-cloudinit/system/etcd2.go b/config/cloudinit/system/etcd2.go similarity index 95% rename from vendor/github.com/coreos/coreos-cloudinit/system/etcd2.go rename to config/cloudinit/system/etcd2.go index 9b243e0f..2d025712 100644 --- a/vendor/github.com/coreos/coreos-cloudinit/system/etcd2.go +++ b/config/cloudinit/system/etcd2.go @@ -15,7 +15,7 @@ package system import ( - "github.com/coreos/coreos-cloudinit/config" + "github.com/rancher/os/config/cloudinit/config" ) // Etcd2 is a top-level structure which embeds its underlying configuration, diff --git a/vendor/github.com/coreos/coreos-cloudinit/system/etcd_test.go b/config/cloudinit/system/etcd_test.go similarity index 97% rename from vendor/github.com/coreos/coreos-cloudinit/system/etcd_test.go rename to config/cloudinit/system/etcd_test.go index 5fc17f02..dbb39a2f 100644 --- a/vendor/github.com/coreos/coreos-cloudinit/system/etcd_test.go +++ b/config/cloudinit/system/etcd_test.go @@ -18,7 +18,7 @@ import ( "reflect" "testing" - "github.com/coreos/coreos-cloudinit/config" + "github.com/rancher/os/config/cloudinit/config" ) func TestEtcdUnits(t *testing.T) { diff --git a/vendor/github.com/coreos/coreos-cloudinit/system/file.go b/config/cloudinit/system/file.go similarity index 98% rename from vendor/github.com/coreos/coreos-cloudinit/system/file.go rename to config/cloudinit/system/file.go index 57f48e27..30ce4597 100644 --- a/vendor/github.com/coreos/coreos-cloudinit/system/file.go +++ b/config/cloudinit/system/file.go @@ -23,7 +23,7 @@ import ( "path" "strconv" - "github.com/coreos/coreos-cloudinit/config" + "github.com/rancher/os/config/cloudinit/config" ) // File is a top-level structure which embeds its underlying configuration, diff --git a/vendor/github.com/coreos/coreos-cloudinit/system/file_test.go b/config/cloudinit/system/file_test.go similarity index 98% rename from vendor/github.com/coreos/coreos-cloudinit/system/file_test.go rename to config/cloudinit/system/file_test.go index 99d0809c..2f74e541 100644 --- a/vendor/github.com/coreos/coreos-cloudinit/system/file_test.go +++ b/config/cloudinit/system/file_test.go @@ -20,7 +20,7 @@ import ( "path" "testing" - "github.com/coreos/coreos-cloudinit/config" + "github.com/rancher/os/config/cloudinit/config" ) func TestWriteFileUnencodedContent(t *testing.T) { diff --git a/vendor/github.com/coreos/coreos-cloudinit/system/flannel.go b/config/cloudinit/system/flannel.go similarity index 95% rename from vendor/github.com/coreos/coreos-cloudinit/system/flannel.go rename to config/cloudinit/system/flannel.go index 7442414c..ed367dbd 100644 --- a/vendor/github.com/coreos/coreos-cloudinit/system/flannel.go +++ b/config/cloudinit/system/flannel.go @@ -18,7 +18,7 @@ import ( "path" "strings" - "github.com/coreos/coreos-cloudinit/config" + "github.com/rancher/os/config/cloudinit/config" ) // flannel is a top-level structure which embeds its underlying configuration, diff --git a/vendor/github.com/coreos/coreos-cloudinit/system/flannel_test.go b/config/cloudinit/system/flannel_test.go similarity index 97% rename from vendor/github.com/coreos/coreos-cloudinit/system/flannel_test.go rename to config/cloudinit/system/flannel_test.go index 7bc9f7f6..b2eda6d0 100644 --- a/vendor/github.com/coreos/coreos-cloudinit/system/flannel_test.go +++ b/config/cloudinit/system/flannel_test.go @@ -18,7 +18,7 @@ import ( "reflect" "testing" - "github.com/coreos/coreos-cloudinit/config" + "github.com/rancher/os/config/cloudinit/config" ) func TestFlannelEnvVars(t *testing.T) { diff --git a/vendor/github.com/coreos/coreos-cloudinit/system/fleet.go b/config/cloudinit/system/fleet.go similarity index 95% rename from vendor/github.com/coreos/coreos-cloudinit/system/fleet.go rename to config/cloudinit/system/fleet.go index 2d12d819..d1536efd 100644 --- a/vendor/github.com/coreos/coreos-cloudinit/system/fleet.go +++ b/config/cloudinit/system/fleet.go @@ -15,7 +15,7 @@ package system import ( - "github.com/coreos/coreos-cloudinit/config" + "github.com/rancher/os/config/cloudinit/config" ) // Fleet is a top-level structure which embeds its underlying configuration, diff --git a/vendor/github.com/coreos/coreos-cloudinit/system/fleet_test.go b/config/cloudinit/system/fleet_test.go similarity index 96% rename from vendor/github.com/coreos/coreos-cloudinit/system/fleet_test.go rename to config/cloudinit/system/fleet_test.go index dfe7c3f5..235ad1ad 100644 --- a/vendor/github.com/coreos/coreos-cloudinit/system/fleet_test.go +++ b/config/cloudinit/system/fleet_test.go @@ -18,7 +18,7 @@ import ( "reflect" "testing" - "github.com/coreos/coreos-cloudinit/config" + "github.com/rancher/os/config/cloudinit/config" ) func TestFleetUnits(t *testing.T) { diff --git a/vendor/github.com/coreos/coreos-cloudinit/system/locksmith.go b/config/cloudinit/system/locksmith.go similarity index 95% rename from vendor/github.com/coreos/coreos-cloudinit/system/locksmith.go rename to config/cloudinit/system/locksmith.go index 6095e5f7..80d5f850 100644 --- a/vendor/github.com/coreos/coreos-cloudinit/system/locksmith.go +++ b/config/cloudinit/system/locksmith.go @@ -15,7 +15,7 @@ package system import ( - "github.com/coreos/coreos-cloudinit/config" + "github.com/rancher/os/config/cloudinit/config" ) // Locksmith is a top-level structure which embeds its underlying configuration, diff --git a/vendor/github.com/coreos/coreos-cloudinit/system/locksmith_test.go b/config/cloudinit/system/locksmith_test.go similarity index 96% rename from vendor/github.com/coreos/coreos-cloudinit/system/locksmith_test.go rename to config/cloudinit/system/locksmith_test.go index 6d7d9887..637503bc 100644 --- a/vendor/github.com/coreos/coreos-cloudinit/system/locksmith_test.go +++ b/config/cloudinit/system/locksmith_test.go @@ -18,7 +18,7 @@ import ( "reflect" "testing" - "github.com/coreos/coreos-cloudinit/config" + "github.com/rancher/os/config/cloudinit/config" ) func TestLocksmithUnits(t *testing.T) { diff --git a/vendor/github.com/coreos/coreos-cloudinit/system/networkd.go b/config/cloudinit/system/networkd.go similarity index 94% rename from vendor/github.com/coreos/coreos-cloudinit/system/networkd.go rename to config/cloudinit/system/networkd.go index ed9c1a5a..ce6e4ad5 100644 --- a/vendor/github.com/coreos/coreos-cloudinit/system/networkd.go +++ b/config/cloudinit/system/networkd.go @@ -20,10 +20,10 @@ import ( "os/exec" "strings" - "github.com/coreos/coreos-cloudinit/config" - "github.com/coreos/coreos-cloudinit/network" + "github.com/rancher/os/config/cloudinit/config" + "github.com/rancher/os/config/cloudinit/network" - "github.com/dotcloud/docker/pkg/netlink" + "github.com/docker/docker/pkg/netlink" ) func RestartNetwork(interfaces []network.InterfaceGenerator) (err error) { diff --git a/vendor/github.com/coreos/coreos-cloudinit/system/oem.go b/config/cloudinit/system/oem.go similarity index 96% rename from vendor/github.com/coreos/coreos-cloudinit/system/oem.go rename to config/cloudinit/system/oem.go index b77e9c8b..cc0d56a4 100644 --- a/vendor/github.com/coreos/coreos-cloudinit/system/oem.go +++ b/config/cloudinit/system/oem.go @@ -18,7 +18,7 @@ import ( "fmt" "path" - "github.com/coreos/coreos-cloudinit/config" + "github.com/rancher/os/config/cloudinit/config" ) // OEM is a top-level structure which embeds its underlying configuration, diff --git a/vendor/github.com/coreos/coreos-cloudinit/system/oem_test.go b/config/cloudinit/system/oem_test.go similarity index 97% rename from vendor/github.com/coreos/coreos-cloudinit/system/oem_test.go rename to config/cloudinit/system/oem_test.go index 38661201..a97757bc 100644 --- a/vendor/github.com/coreos/coreos-cloudinit/system/oem_test.go +++ b/config/cloudinit/system/oem_test.go @@ -18,7 +18,7 @@ import ( "reflect" "testing" - "github.com/coreos/coreos-cloudinit/config" + "github.com/rancher/os/config/cloudinit/config" ) func TestOEMFile(t *testing.T) { diff --git a/vendor/github.com/coreos/coreos-cloudinit/system/ssh_key.go b/config/cloudinit/system/ssh_key.go similarity index 100% rename from vendor/github.com/coreos/coreos-cloudinit/system/ssh_key.go rename to config/cloudinit/system/ssh_key.go diff --git a/vendor/github.com/coreos/coreos-cloudinit/system/systemd.go b/config/cloudinit/system/systemd.go similarity index 99% rename from vendor/github.com/coreos/coreos-cloudinit/system/systemd.go rename to config/cloudinit/system/systemd.go index 4385b556..4128a3c8 100644 --- a/vendor/github.com/coreos/coreos-cloudinit/system/systemd.go +++ b/config/cloudinit/system/systemd.go @@ -23,7 +23,7 @@ import ( "path" "strings" - "github.com/coreos/coreos-cloudinit/config" + "github.com/rancher/os/config/cloudinit/config" "github.com/coreos/go-systemd/dbus" ) diff --git a/vendor/github.com/coreos/coreos-cloudinit/system/systemd_test.go b/config/cloudinit/system/systemd_test.go similarity index 99% rename from vendor/github.com/coreos/coreos-cloudinit/system/systemd_test.go rename to config/cloudinit/system/systemd_test.go index 82052abc..d2f02157 100644 --- a/vendor/github.com/coreos/coreos-cloudinit/system/systemd_test.go +++ b/config/cloudinit/system/systemd_test.go @@ -21,7 +21,7 @@ import ( "path" "testing" - "github.com/coreos/coreos-cloudinit/config" + "github.com/rancher/os/config/cloudinit/config" ) func TestPlaceUnit(t *testing.T) { diff --git a/vendor/github.com/coreos/coreos-cloudinit/system/unit.go b/config/cloudinit/system/unit.go similarity index 98% rename from vendor/github.com/coreos/coreos-cloudinit/system/unit.go rename to config/cloudinit/system/unit.go index 22d006d1..56232848 100644 --- a/vendor/github.com/coreos/coreos-cloudinit/system/unit.go +++ b/config/cloudinit/system/unit.go @@ -20,7 +20,7 @@ import ( "path/filepath" "strings" - "github.com/coreos/coreos-cloudinit/config" + "github.com/rancher/os/config/cloudinit/config" ) type UnitManager interface { diff --git a/vendor/github.com/coreos/coreos-cloudinit/system/unit_test.go b/config/cloudinit/system/unit_test.go similarity index 98% rename from vendor/github.com/coreos/coreos-cloudinit/system/unit_test.go rename to config/cloudinit/system/unit_test.go index c995b592..94254616 100644 --- a/vendor/github.com/coreos/coreos-cloudinit/system/unit_test.go +++ b/config/cloudinit/system/unit_test.go @@ -17,7 +17,7 @@ package system import ( "testing" - "github.com/coreos/coreos-cloudinit/config" + "github.com/rancher/os/config/cloudinit/config" ) func TestType(t *testing.T) { diff --git a/vendor/github.com/coreos/coreos-cloudinit/system/update.go b/config/cloudinit/system/update.go similarity index 98% rename from vendor/github.com/coreos/coreos-cloudinit/system/update.go rename to config/cloudinit/system/update.go index 5e92dace..d0098a7b 100644 --- a/vendor/github.com/coreos/coreos-cloudinit/system/update.go +++ b/config/cloudinit/system/update.go @@ -24,7 +24,7 @@ import ( "sort" "strings" - "github.com/coreos/coreos-cloudinit/config" + "github.com/rancher/os/config/cloudinit/config" ) const ( diff --git a/vendor/github.com/coreos/coreos-cloudinit/system/update_test.go b/config/cloudinit/system/update_test.go similarity index 98% rename from vendor/github.com/coreos/coreos-cloudinit/system/update_test.go rename to config/cloudinit/system/update_test.go index ae3972b8..d1e1cb88 100644 --- a/vendor/github.com/coreos/coreos-cloudinit/system/update_test.go +++ b/config/cloudinit/system/update_test.go @@ -20,7 +20,7 @@ import ( "strings" "testing" - "github.com/coreos/coreos-cloudinit/config" + "github.com/rancher/os/config/cloudinit/config" ) func testReadConfig(config string) func() (io.Reader, error) { diff --git a/vendor/github.com/coreos/coreos-cloudinit/system/user.go b/config/cloudinit/system/user.go similarity index 97% rename from vendor/github.com/coreos/coreos-cloudinit/system/user.go rename to config/cloudinit/system/user.go index 7d56eca1..c1be4639 100644 --- a/vendor/github.com/coreos/coreos-cloudinit/system/user.go +++ b/config/cloudinit/system/user.go @@ -21,7 +21,7 @@ import ( "os/user" "strings" - "github.com/coreos/coreos-cloudinit/config" + "github.com/rancher/os/config/cloudinit/config" ) func UserExists(u *config.User) bool { diff --git a/vendor/github.com/coreos/coreos-cloudinit/test b/config/cloudinit/test similarity index 100% rename from vendor/github.com/coreos/coreos-cloudinit/test rename to config/cloudinit/test diff --git a/vendor/github.com/coreos/coreos-cloudinit/units/90-configdrive.rules b/config/cloudinit/units/90-configdrive.rules similarity index 100% rename from vendor/github.com/coreos/coreos-cloudinit/units/90-configdrive.rules rename to config/cloudinit/units/90-configdrive.rules diff --git a/vendor/github.com/coreos/coreos-cloudinit/units/90-ovfenv.rules b/config/cloudinit/units/90-ovfenv.rules similarity index 100% rename from vendor/github.com/coreos/coreos-cloudinit/units/90-ovfenv.rules rename to config/cloudinit/units/90-ovfenv.rules diff --git a/vendor/github.com/coreos/coreos-cloudinit/units/media-configdrive.mount b/config/cloudinit/units/media-configdrive.mount similarity index 100% rename from vendor/github.com/coreos/coreos-cloudinit/units/media-configdrive.mount rename to config/cloudinit/units/media-configdrive.mount diff --git a/vendor/github.com/coreos/coreos-cloudinit/units/media-configvirtfs.mount b/config/cloudinit/units/media-configvirtfs.mount similarity index 100% rename from vendor/github.com/coreos/coreos-cloudinit/units/media-configvirtfs.mount rename to config/cloudinit/units/media-configvirtfs.mount diff --git a/vendor/github.com/coreos/coreos-cloudinit/units/media-ovfenv.mount b/config/cloudinit/units/media-ovfenv.mount similarity index 100% rename from vendor/github.com/coreos/coreos-cloudinit/units/media-ovfenv.mount rename to config/cloudinit/units/media-ovfenv.mount diff --git a/vendor/github.com/coreos/coreos-cloudinit/units/system-cloudinit@.service b/config/cloudinit/units/system-cloudinit@.service similarity index 100% rename from vendor/github.com/coreos/coreos-cloudinit/units/system-cloudinit@.service rename to config/cloudinit/units/system-cloudinit@.service diff --git a/vendor/github.com/coreos/coreos-cloudinit/units/system-config.target b/config/cloudinit/units/system-config.target similarity index 100% rename from vendor/github.com/coreos/coreos-cloudinit/units/system-config.target rename to config/cloudinit/units/system-config.target diff --git a/vendor/github.com/coreos/coreos-cloudinit/units/user-cloudinit-proc-cmdline.service b/config/cloudinit/units/user-cloudinit-proc-cmdline.service similarity index 100% rename from vendor/github.com/coreos/coreos-cloudinit/units/user-cloudinit-proc-cmdline.service rename to config/cloudinit/units/user-cloudinit-proc-cmdline.service diff --git a/vendor/github.com/coreos/coreos-cloudinit/units/user-cloudinit@.path b/config/cloudinit/units/user-cloudinit@.path similarity index 100% rename from vendor/github.com/coreos/coreos-cloudinit/units/user-cloudinit@.path rename to config/cloudinit/units/user-cloudinit@.path diff --git a/vendor/github.com/coreos/coreos-cloudinit/units/user-cloudinit@.service b/config/cloudinit/units/user-cloudinit@.service similarity index 100% rename from vendor/github.com/coreos/coreos-cloudinit/units/user-cloudinit@.service rename to config/cloudinit/units/user-cloudinit@.service diff --git a/vendor/github.com/coreos/coreos-cloudinit/units/user-config-ovfenv.service b/config/cloudinit/units/user-config-ovfenv.service similarity index 100% rename from vendor/github.com/coreos/coreos-cloudinit/units/user-config-ovfenv.service rename to config/cloudinit/units/user-config-ovfenv.service diff --git a/vendor/github.com/coreos/coreos-cloudinit/units/user-config.target b/config/cloudinit/units/user-config.target similarity index 100% rename from vendor/github.com/coreos/coreos-cloudinit/units/user-config.target rename to config/cloudinit/units/user-config.target diff --git a/vendor/github.com/coreos/coreos-cloudinit/units/user-configdrive.service b/config/cloudinit/units/user-configdrive.service similarity index 100% rename from vendor/github.com/coreos/coreos-cloudinit/units/user-configdrive.service rename to config/cloudinit/units/user-configdrive.service diff --git a/vendor/github.com/coreos/coreos-cloudinit/units/user-configvirtfs.service b/config/cloudinit/units/user-configvirtfs.service similarity index 100% rename from vendor/github.com/coreos/coreos-cloudinit/units/user-configvirtfs.service rename to config/cloudinit/units/user-configvirtfs.service diff --git a/vendor/github.com/coreos/coreos-cloudinit/vendor.manifest b/config/cloudinit/vendor.manifest similarity index 100% rename from vendor/github.com/coreos/coreos-cloudinit/vendor.manifest rename to config/cloudinit/vendor.manifest diff --git a/config/disk.go b/config/disk.go index a1de8b36..7601c287 100644 --- a/config/disk.go +++ b/config/disk.go @@ -9,8 +9,8 @@ import ( "strings" yaml "github.com/cloudfoundry-incubator/candiedyaml" - "github.com/coreos/coreos-cloudinit/datasource" - "github.com/coreos/coreos-cloudinit/initialize" + "github.com/rancher/os/config/cloudinit/datasource" + "github.com/rancher/os/config/cloudinit/initialize" "github.com/docker/engine-api/types" composeConfig "github.com/docker/libcompose/config" "github.com/rancher/os/log" diff --git a/config/metadata_test.go b/config/metadata_test.go index 382588fe..0a589317 100644 --- a/config/metadata_test.go +++ b/config/metadata_test.go @@ -19,7 +19,7 @@ import ( "net" "testing" - "github.com/coreos/coreos-cloudinit/datasource" + "github.com/rancher/os/config/cloudinit/datasource" ) func TestSubstituteUserDataVars(t *testing.T) { diff --git a/config/types.go b/config/types.go index 588578ae..9353a63e 100644 --- a/config/types.go +++ b/config/types.go @@ -4,7 +4,7 @@ import ( "fmt" "runtime" - "github.com/coreos/coreos-cloudinit/config" + "github.com/rancher/os/config/cloudinit/config" "github.com/docker/engine-api/types" composeConfig "github.com/docker/libcompose/config" "github.com/rancher/os/config/yaml" diff --git a/os-config.tpl.yml b/os-config.tpl.yml index dcf3a9cb..ceb4dcbd 100644 --- a/os-config.tpl.yml +++ b/os-config.tpl.yml @@ -66,6 +66,7 @@ rancher: cloud_init: datasources: - configdrive:/media/config-2 + - url:http://example.com/cloud-config repositories: core: url: {{.OS_SERVICES_REPO}}/{{.REPO_VERSION}} diff --git a/trash.conf b/trash.conf index 11f34616..d120ff14 100644 --- a/trash.conf +++ b/trash.conf @@ -6,7 +6,6 @@ github.com/cloudfoundry-incubator/candiedyaml 01cbc92901719f599b11f3a7e3b1768d70 github.com/cloudfoundry/gosigar 3ed7c74352dae6dc00bdc8c74045375352e3ec05 github.com/codegangsta/cli d2b9ba9c38eb353ba3c6df3f57072348e19cc5c7 https://github.com/rancher/cli-1 github.com/containernetworking/cni a8e4fa0dffdac6a236f85be91502603ec06957f9 https://github.com/rancher/cni.git -github.com/coreos/coreos-cloudinit 759217189da3c4daa94f3f50c5fd88e8f4483121 github.com/coreos/go-iptables fbb73372b87f6e89951c2b6b31470c2c9d5cfae3 github.com/coreos/go-systemd v4 github.com/coreos/yaml 6b16a5714269b2f70720a45406b1babd947a17ef diff --git a/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/cloudsigma/cepgo/.gitignore b/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/cloudsigma/cepgo/.gitignore deleted file mode 100644 index 83656241..00000000 --- a/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/cloudsigma/cepgo/.gitignore +++ /dev/null @@ -1,23 +0,0 @@ -# Compiled Object files, Static and Dynamic libs (Shared Objects) -*.o -*.a -*.so - -# Folders -_obj -_test - -# Architecture specific extensions/prefixes -*.[568vq] -[568vq].out - -*.cgo1.go -*.cgo2.c -_cgo_defun.c -_cgo_gotypes.go -_cgo_export.* - -_testmain.go - -*.exe -*.test diff --git a/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/cloudsigma/cepgo/LICENSE b/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/cloudsigma/cepgo/LICENSE deleted file mode 100644 index e06d2081..00000000 --- a/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/cloudsigma/cepgo/LICENSE +++ /dev/null @@ -1,202 +0,0 @@ -Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "{}" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright {yyyy} {name of copyright owner} - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - diff --git a/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/cloudsigma/cepgo/README.md b/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/cloudsigma/cepgo/README.md deleted file mode 100644 index 1125d862..00000000 --- a/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/cloudsigma/cepgo/README.md +++ /dev/null @@ -1,43 +0,0 @@ -cepgo -===== - -Cepko implements easy-to-use communication with CloudSigma's VMs through a -virtual serial port without bothering with formatting the messages properly nor -parsing the output with the specific and sometimes confusing shell tools for -that purpose. - -Having the server definition accessible by the VM can be useful in various -ways. For example it is possible to easily determine from within the VM, which -network interfaces are connected to public and which to private network. -Another use is to pass some data to initial VM setup scripts, like setting the -hostname to the VM name or passing ssh public keys through server meta. - -Example usage: - - package main - - import ( - "fmt" - - "github.com/cloudsigma/cepgo" - ) - - func main() { - c := cepgo.NewCepgo() - result, err := c.Meta() - if err != nil { - panic(err) - } - fmt.Printf("%#v", result) - } - -Output: - - map[string]interface {}{ - "optimize_for":"custom", - "ssh_public_key":"ssh-rsa AAA...", - "description":"[...]", - } - -For more information take a look at the Server Context section of CloudSigma -API Docs: http://cloudsigma-docs.readthedocs.org/en/latest/server_context.html diff --git a/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/cloudsigma/cepgo/cepgo.go b/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/cloudsigma/cepgo/cepgo.go deleted file mode 100644 index 5250bcc0..00000000 --- a/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/cloudsigma/cepgo/cepgo.go +++ /dev/null @@ -1,186 +0,0 @@ -// Cepko implements easy-to-use communication with CloudSigma's VMs through a -// virtual serial port without bothering with formatting the messages properly -// nor parsing the output with the specific and sometimes confusing shell tools -// for that purpose. -// -// Having the server definition accessible by the VM can be useful in various -// ways. For example it is possible to easily determine from within the VM, -// which network interfaces are connected to public and which to private -// network. Another use is to pass some data to initial VM setup scripts, like -// setting the hostname to the VM name or passing ssh public keys through -// server meta. -// -// Example usage: -// -// package main -// -// import ( -// "fmt" -// -// "github.com/cloudsigma/cepgo" -// ) -// -// func main() { -// c := cepgo.NewCepgo() -// result, err := c.Meta() -// if err != nil { -// panic(err) -// } -// fmt.Printf("%#v", result) -// } -// -// Output: -// -// map[string]string{ -// "optimize_for":"custom", -// "ssh_public_key":"ssh-rsa AAA...", -// "description":"[...]", -// } -// -// For more information take a look at the Server Context section API Docs: -// http://cloudsigma-docs.readthedocs.org/en/latest/server_context.html -package cepgo - -import ( - "bufio" - "encoding/json" - "errors" - "fmt" - "runtime" - - "github.com/tarm/goserial" -) - -const ( - requestPattern = "<\n%s\n>" - EOT = '\x04' // End Of Transmission -) - -var ( - SerialPort string = "/dev/ttyS1" - Baud int = 115200 -) - -// Sets the serial port. If the operating system is windows CloudSigma's server -// context is at COM2 port, otherwise (linux, freebsd, darwin) the port is -// being left to the default /dev/ttyS1. -func init() { - if runtime.GOOS == "windows" { - SerialPort = "COM2" - } -} - -// The default fetcher makes the connection to the serial port, -// writes given query and reads until the EOT symbol. -func fetchViaSerialPort(key string) ([]byte, error) { - config := &serial.Config{Name: SerialPort, Baud: Baud} - connection, err := serial.OpenPort(config) - if err != nil { - return nil, err - } - - query := fmt.Sprintf(requestPattern, key) - if _, err := connection.Write([]byte(query)); err != nil { - return nil, err - } - - reader := bufio.NewReader(connection) - answer, err := reader.ReadBytes(EOT) - if err != nil { - return nil, err - } - - return answer[0 : len(answer)-1], nil -} - -// Queries to the serial port can be executed only from instance of this type. -// The result from each of them can be either interface{}, map[string]string or -// a single in case of single value is returned. There is also a public metod -// who directly calls the fetcher and returns raw []byte from the serial port. -type Cepgo struct { - fetcher func(string) ([]byte, error) -} - -// Creates a Cepgo instance with the default serial port fetcher. -func NewCepgo() *Cepgo { - cepgo := new(Cepgo) - cepgo.fetcher = fetchViaSerialPort - return cepgo -} - -// Creates a Cepgo instance with custom fetcher. -func NewCepgoFetcher(fetcher func(string) ([]byte, error)) *Cepgo { - cepgo := new(Cepgo) - cepgo.fetcher = fetcher - return cepgo -} - -// Fetches raw []byte from the serial port using directly the fetcher member. -func (c *Cepgo) FetchRaw(key string) ([]byte, error) { - return c.fetcher(key) -} - -// Fetches a single key and tries to unmarshal the result to json and returns -// it. If the unmarshalling fails it's safe to assume the result it's just a -// string and returns it. -func (c *Cepgo) Key(key string) (interface{}, error) { - var result interface{} - - fetched, err := c.FetchRaw(key) - if err != nil { - return nil, err - } - - err = json.Unmarshal(fetched, &result) - if err != nil { - return string(fetched), nil - } - return result, nil -} - -// Fetches all the server context. Equivalent of c.Key("") -func (c *Cepgo) All() (interface{}, error) { - return c.Key("") -} - -// Fetches only the object meta field and makes sure to return a proper -// map[string]string -func (c *Cepgo) Meta() (map[string]string, error) { - rawMeta, err := c.Key("/meta/") - if err != nil { - return nil, err - } - - return typeAssertToMapOfStrings(rawMeta) -} - -// Fetches only the global context and makes sure to return a proper -// map[string]string -func (c *Cepgo) GlobalContext() (map[string]string, error) { - rawContext, err := c.Key("/global_context/") - if err != nil { - return nil, err - } - - return typeAssertToMapOfStrings(rawContext) -} - -// Just a little helper function that uses type assertions in order to convert -// a interface{} to map[string]string if this is possible. -func typeAssertToMapOfStrings(raw interface{}) (map[string]string, error) { - result := make(map[string]string) - - dictionary, ok := raw.(map[string]interface{}) - if !ok { - return nil, errors.New("Received bytes are formatted badly") - } - - for key, rawValue := range dictionary { - if value, ok := rawValue.(string); ok { - result[key] = value - } else { - return nil, errors.New("Server context metadata is formatted badly") - } - } - return result, nil -} diff --git a/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/cloudsigma/cepgo/cepgo_test.go b/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/cloudsigma/cepgo/cepgo_test.go deleted file mode 100644 index 8de1df96..00000000 --- a/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/cloudsigma/cepgo/cepgo_test.go +++ /dev/null @@ -1,122 +0,0 @@ -package cepgo - -import ( - "encoding/json" - "testing" -) - -func fetchMock(key string) ([]byte, error) { - context := []byte(`{ - "context": true, - "cpu": 4000, - "cpu_model": null, - "cpus_instead_of_cores": false, - "enable_numa": false, - "global_context": { - "some_global_key": "some_global_val" - }, - "grantees": [], - "hv_relaxed": false, - "hv_tsc": false, - "jobs": [], - "mem": 4294967296, - "meta": { - "base64_fields": "cloudinit-user-data", - "cloudinit-user-data": "I2Nsb3VkLWNvbmZpZwoKaG9zdG5hbWU6IGNvcmVvczE=", - "ssh_public_key": "ssh-rsa AAAAB2NzaC1yc2E.../hQ5D5 john@doe" - }, - "name": "coreos", - "nics": [ - { - "runtime": { - "interface_type": "public", - "ip_v4": { - "uuid": "31.171.251.74" - }, - "ip_v6": null - }, - "vlan": null - } - ], - "smp": 2, - "status": "running", - "uuid": "20a0059b-041e-4d0c-bcc6-9b2852de48b3" - }`) - - if key == "" { - return context, nil - } - - var marshalledContext map[string]interface{} - - err := json.Unmarshal(context, &marshalledContext) - if err != nil { - return nil, err - } - - if key[0] == '/' { - key = key[1:] - } - if key[len(key)-1] == '/' { - key = key[:len(key)-1] - } - - return json.Marshal(marshalledContext[key]) -} - -func TestAll(t *testing.T) { - cepgo := NewCepgoFetcher(fetchMock) - - result, err := cepgo.All() - if err != nil { - t.Error(err) - } - - for _, key := range []string{"meta", "name", "uuid", "global_context"} { - if _, ok := result.(map[string]interface{})[key]; !ok { - t.Errorf("%s not in all keys", key) - } - } -} - -func TestKey(t *testing.T) { - cepgo := NewCepgoFetcher(fetchMock) - - result, err := cepgo.Key("uuid") - if err != nil { - t.Error(err) - } - - if _, ok := result.(string); !ok { - t.Errorf("%#v\n", result) - - t.Error("Fetching the uuid did not return a string") - } -} - -func TestMeta(t *testing.T) { - cepgo := NewCepgoFetcher(fetchMock) - - meta, err := cepgo.Meta() - if err != nil { - t.Errorf("%#v\n", meta) - t.Error(err) - } - - if _, ok := meta["ssh_public_key"]; !ok { - t.Error("ssh_public_key is not in the meta") - } -} - -func TestGlobalContext(t *testing.T) { - cepgo := NewCepgoFetcher(fetchMock) - - result, err := cepgo.GlobalContext() - if err != nil { - t.Error(err) - } - - if _, ok := result["some_global_key"]; !ok { - t.Error("some_global_key is not in the global context") - } -} diff --git a/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/coreos/go-systemd/dbus/dbus.go b/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/coreos/go-systemd/dbus/dbus.go deleted file mode 100644 index 88927b7f..00000000 --- a/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/coreos/go-systemd/dbus/dbus.go +++ /dev/null @@ -1,104 +0,0 @@ -/* -Copyright 2013 CoreOS Inc. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -// Integration with the systemd D-Bus API. See http://www.freedesktop.org/wiki/Software/systemd/dbus/ -package dbus - -import ( - "os" - "strconv" - "strings" - "sync" - - "github.com/guelfey/go.dbus" -) - -const signalBuffer = 100 - -// ObjectPath creates a dbus.ObjectPath using the rules that systemd uses for -// serializing special characters. -func ObjectPath(path string) dbus.ObjectPath { - path = strings.Replace(path, ".", "_2e", -1) - path = strings.Replace(path, "-", "_2d", -1) - path = strings.Replace(path, "@", "_40", -1) - - return dbus.ObjectPath(path) -} - -// Conn is a connection to systemds dbus endpoint. -type Conn struct { - sysconn *dbus.Conn - sysobj *dbus.Object - jobListener struct { - jobs map[dbus.ObjectPath]chan string - sync.Mutex - } - subscriber struct { - updateCh chan<- *SubStateUpdate - errCh chan<- error - sync.Mutex - ignore map[dbus.ObjectPath]int64 - cleanIgnore int64 - } - dispatch map[string]func(dbus.Signal) -} - -// New() establishes a connection to the system bus and authenticates. -func New() (*Conn, error) { - c := new(Conn) - - if err := c.initConnection(); err != nil { - return nil, err - } - - c.initJobs() - return c, nil -} - -func (c *Conn) initConnection() error { - var err error - c.sysconn, err = dbus.SystemBusPrivate() - if err != nil { - return err - } - - // Only use EXTERNAL method, and hardcode the uid (not username) - // to avoid a username lookup (which requires a dynamically linked - // libc) - methods := []dbus.Auth{dbus.AuthExternal(strconv.Itoa(os.Getuid()))} - - err = c.sysconn.Auth(methods) - if err != nil { - c.sysconn.Close() - return err - } - - err = c.sysconn.Hello() - if err != nil { - c.sysconn.Close() - return err - } - - c.sysobj = c.sysconn.Object("org.freedesktop.systemd1", dbus.ObjectPath("/org/freedesktop/systemd1")) - - // Setup the listeners on jobs so that we can get completions - c.sysconn.BusObject().Call("org.freedesktop.DBus.AddMatch", 0, - "type='signal', interface='org.freedesktop.systemd1.Manager', member='JobRemoved'") - c.initSubscription() - c.initDispatch() - - return nil -} diff --git a/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/coreos/go-systemd/dbus/dbus_test.go b/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/coreos/go-systemd/dbus/dbus_test.go deleted file mode 100644 index 2e80f73e..00000000 --- a/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/coreos/go-systemd/dbus/dbus_test.go +++ /dev/null @@ -1,41 +0,0 @@ -/* -Copyright 2013 CoreOS Inc. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package dbus - -import ( - "testing" -) - -// TestObjectPath ensures path encoding of the systemd rules works. -func TestObjectPath(t *testing.T) { - input := "/silly-path/to@a/unit..service" - output := ObjectPath(input) - expected := "/silly_2dpath/to_40a/unit_2e_2eservice" - - if string(output) != expected { - t.Fatalf("Output '%s' did not match expected '%s'", output, expected) - } -} - -// TestNew ensures that New() works without errors. -func TestNew(t *testing.T) { - _, err := New() - - if err != nil { - t.Fatal(err) - } -} diff --git a/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/coreos/go-systemd/dbus/methods.go b/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/coreos/go-systemd/dbus/methods.go deleted file mode 100644 index 372476c5..00000000 --- a/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/coreos/go-systemd/dbus/methods.go +++ /dev/null @@ -1,354 +0,0 @@ -/* -Copyright 2013 CoreOS Inc. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package dbus - -import ( - "errors" - "github.com/guelfey/go.dbus" -) - -func (c *Conn) initJobs() { - c.jobListener.jobs = make(map[dbus.ObjectPath]chan string) -} - -func (c *Conn) jobComplete(signal *dbus.Signal) { - var id uint32 - var job dbus.ObjectPath - var unit string - var result string - dbus.Store(signal.Body, &id, &job, &unit, &result) - c.jobListener.Lock() - out, ok := c.jobListener.jobs[job] - if ok { - out <- result - delete(c.jobListener.jobs, job) - } - c.jobListener.Unlock() -} - -func (c *Conn) startJob(job string, args ...interface{}) (<-chan string, error) { - c.jobListener.Lock() - defer c.jobListener.Unlock() - - ch := make(chan string, 1) - var path dbus.ObjectPath - err := c.sysobj.Call(job, 0, args...).Store(&path) - if err != nil { - return nil, err - } - c.jobListener.jobs[path] = ch - return ch, nil -} - -func (c *Conn) runJob(job string, args ...interface{}) (string, error) { - respCh, err := c.startJob(job, args...) - if err != nil { - return "", err - } - return <-respCh, nil -} - -// StartUnit enqeues a start job and depending jobs, if any (unless otherwise -// specified by the mode string). -// -// Takes the unit to activate, plus a mode string. The mode needs to be one of -// replace, fail, isolate, ignore-dependencies, ignore-requirements. If -// "replace" the call will start the unit and its dependencies, possibly -// replacing already queued jobs that conflict with this. If "fail" the call -// will start the unit and its dependencies, but will fail if this would change -// an already queued job. If "isolate" the call will start the unit in question -// and terminate all units that aren't dependencies of it. If -// "ignore-dependencies" it will start a unit but ignore all its dependencies. -// If "ignore-requirements" it will start a unit but only ignore the -// requirement dependencies. It is not recommended to make use of the latter -// two options. -// -// Result string: one of done, canceled, timeout, failed, dependency, skipped. -// done indicates successful execution of a job. canceled indicates that a job -// has been canceled before it finished execution. timeout indicates that the -// job timeout was reached. failed indicates that the job failed. dependency -// indicates that a job this job has been depending on failed and the job hence -// has been removed too. skipped indicates that a job was skipped because it -// didn't apply to the units current state. -func (c *Conn) StartUnit(name string, mode string) (string, error) { - return c.runJob("org.freedesktop.systemd1.Manager.StartUnit", name, mode) -} - -// StopUnit is similar to StartUnit but stops the specified unit rather -// than starting it. -func (c *Conn) StopUnit(name string, mode string) (string, error) { - return c.runJob("org.freedesktop.systemd1.Manager.StopUnit", name, mode) -} - -// ReloadUnit reloads a unit. Reloading is done only if the unit is already running and fails otherwise. -func (c *Conn) ReloadUnit(name string, mode string) (string, error) { - return c.runJob("org.freedesktop.systemd1.Manager.ReloadUnit", name, mode) -} - -// RestartUnit restarts a service. If a service is restarted that isn't -// running it will be started. -func (c *Conn) RestartUnit(name string, mode string) (string, error) { - return c.runJob("org.freedesktop.systemd1.Manager.RestartUnit", name, mode) -} - -// TryRestartUnit is like RestartUnit, except that a service that isn't running -// is not affected by the restart. -func (c *Conn) TryRestartUnit(name string, mode string) (string, error) { - return c.runJob("org.freedesktop.systemd1.Manager.TryRestartUnit", name, mode) -} - -// ReloadOrRestart attempts a reload if the unit supports it and use a restart -// otherwise. -func (c *Conn) ReloadOrRestartUnit(name string, mode string) (string, error) { - return c.runJob("org.freedesktop.systemd1.Manager.ReloadOrRestartUnit", name, mode) -} - -// ReloadOrTryRestart attempts a reload if the unit supports it and use a "Try" -// flavored restart otherwise. -func (c *Conn) ReloadOrTryRestartUnit(name string, mode string) (string, error) { - return c.runJob("org.freedesktop.systemd1.Manager.ReloadOrTryRestartUnit", name, mode) -} - -// StartTransientUnit() may be used to create and start a transient unit, which -// will be released as soon as it is not running or referenced anymore or the -// system is rebooted. name is the unit name including suffix, and must be -// unique. mode is the same as in StartUnit(), properties contains properties -// of the unit. -func (c *Conn) StartTransientUnit(name string, mode string, properties ...Property) (string, error) { - return c.runJob("org.freedesktop.systemd1.Manager.StartTransientUnit", name, mode, properties, make([]PropertyCollection, 0)) -} - -// KillUnit takes the unit name and a UNIX signal number to send. All of the unit's -// processes are killed. -func (c *Conn) KillUnit(name string, signal int32) { - c.sysobj.Call("org.freedesktop.systemd1.Manager.KillUnit", 0, name, "all", signal).Store() -} - -// getProperties takes the unit name and returns all of its dbus object properties, for the given dbus interface -func (c *Conn) getProperties(unit string, dbusInterface string) (map[string]interface{}, error) { - var err error - var props map[string]dbus.Variant - - path := ObjectPath("/org/freedesktop/systemd1/unit/" + unit) - if !path.IsValid() { - return nil, errors.New("invalid unit name: " + unit) - } - - obj := c.sysconn.Object("org.freedesktop.systemd1", path) - err = obj.Call("org.freedesktop.DBus.Properties.GetAll", 0, dbusInterface).Store(&props) - if err != nil { - return nil, err - } - - out := make(map[string]interface{}, len(props)) - for k, v := range props { - out[k] = v.Value() - } - - return out, nil -} - -// GetUnitProperties takes the unit name and returns all of its dbus object properties. -func (c *Conn) GetUnitProperties(unit string) (map[string]interface{}, error) { - return c.getProperties(unit, "org.freedesktop.systemd1.Unit") -} - -func (c *Conn) getProperty(unit string, dbusInterface string, propertyName string) (*Property, error) { - var err error - var prop dbus.Variant - - path := ObjectPath("/org/freedesktop/systemd1/unit/" + unit) - if !path.IsValid() { - return nil, errors.New("invalid unit name: " + unit) - } - - obj := c.sysconn.Object("org.freedesktop.systemd1", path) - err = obj.Call("org.freedesktop.DBus.Properties.Get", 0, dbusInterface, propertyName).Store(&prop) - if err != nil { - return nil, err - } - - return &Property{Name: propertyName, Value: prop}, nil -} - -func (c *Conn) GetUnitProperty(unit string, propertyName string) (*Property, error) { - return c.getProperty(unit, "org.freedesktop.systemd1.Unit", propertyName) -} - -// GetUnitTypeProperties returns the extra properties for a unit, specific to the unit type. -// Valid values for unitType: Service, Socket, Target, Device, Mount, Automount, Snapshot, Timer, Swap, Path, Slice, Scope -// return "dbus.Error: Unknown interface" if the unitType is not the correct type of the unit -func (c *Conn) GetUnitTypeProperties(unit string, unitType string) (map[string]interface{}, error) { - return c.getProperties(unit, "org.freedesktop.systemd1."+unitType) -} - -// SetUnitProperties() may be used to modify certain unit properties at runtime. -// Not all properties may be changed at runtime, but many resource management -// settings (primarily those in systemd.cgroup(5)) may. The changes are applied -// instantly, and stored on disk for future boots, unless runtime is true, in which -// case the settings only apply until the next reboot. name is the name of the unit -// to modify. properties are the settings to set, encoded as an array of property -// name and value pairs. -func (c *Conn) SetUnitProperties(name string, runtime bool, properties ...Property) error { - return c.sysobj.Call("SetUnitProperties", 0, name, runtime, properties).Store() -} - -func (c *Conn) GetUnitTypeProperty(unit string, unitType string, propertyName string) (*Property, error) { - return c.getProperty(unit, "org.freedesktop.systemd1."+unitType, propertyName) -} - -// ListUnits returns an array with all currently loaded units. Note that -// units may be known by multiple names at the same time, and hence there might -// be more unit names loaded than actual units behind them. -func (c *Conn) ListUnits() ([]UnitStatus, error) { - result := make([][]interface{}, 0) - err := c.sysobj.Call("org.freedesktop.systemd1.Manager.ListUnits", 0).Store(&result) - if err != nil { - return nil, err - } - - resultInterface := make([]interface{}, len(result)) - for i := range result { - resultInterface[i] = result[i] - } - - status := make([]UnitStatus, len(result)) - statusInterface := make([]interface{}, len(status)) - for i := range status { - statusInterface[i] = &status[i] - } - - err = dbus.Store(resultInterface, statusInterface...) - if err != nil { - return nil, err - } - - return status, nil -} - -type UnitStatus struct { - Name string // The primary unit name as string - Description string // The human readable description string - LoadState string // The load state (i.e. whether the unit file has been loaded successfully) - ActiveState string // The active state (i.e. whether the unit is currently started or not) - SubState string // The sub state (a more fine-grained version of the active state that is specific to the unit type, which the active state is not) - Followed string // A unit that is being followed in its state by this unit, if there is any, otherwise the empty string. - Path dbus.ObjectPath // The unit object path - JobId uint32 // If there is a job queued for the job unit the numeric job id, 0 otherwise - JobType string // The job type as string - JobPath dbus.ObjectPath // The job object path -} - -// EnableUnitFiles() may be used to enable one or more units in the system (by -// creating symlinks to them in /etc or /run). -// -// It takes a list of unit files to enable (either just file names or full -// absolute paths if the unit files are residing outside the usual unit -// search paths), and two booleans: the first controls whether the unit shall -// be enabled for runtime only (true, /run), or persistently (false, /etc). -// The second one controls whether symlinks pointing to other units shall -// be replaced if necessary. -// -// This call returns one boolean and an array with the changes made. The -// boolean signals whether the unit files contained any enablement -// information (i.e. an [Install]) section. The changes list consists of -// structures with three strings: the type of the change (one of symlink -// or unlink), the file name of the symlink and the destination of the -// symlink. -func (c *Conn) EnableUnitFiles(files []string, runtime bool, force bool) (bool, []EnableUnitFileChange, error) { - var carries_install_info bool - - result := make([][]interface{}, 0) - err := c.sysobj.Call("org.freedesktop.systemd1.Manager.EnableUnitFiles", 0, files, runtime, force).Store(&carries_install_info, &result) - if err != nil { - return false, nil, err - } - - resultInterface := make([]interface{}, len(result)) - for i := range result { - resultInterface[i] = result[i] - } - - changes := make([]EnableUnitFileChange, len(result)) - changesInterface := make([]interface{}, len(changes)) - for i := range changes { - changesInterface[i] = &changes[i] - } - - err = dbus.Store(resultInterface, changesInterface...) - if err != nil { - return false, nil, err - } - - return carries_install_info, changes, nil -} - -type EnableUnitFileChange struct { - Type string // Type of the change (one of symlink or unlink) - Filename string // File name of the symlink - Destination string // Destination of the symlink -} - -// DisableUnitFiles() may be used to disable one or more units in the system (by -// removing symlinks to them from /etc or /run). -// -// It takes a list of unit files to disable (either just file names or full -// absolute paths if the unit files are residing outside the usual unit -// search paths), and one boolean: whether the unit was enabled for runtime -// only (true, /run), or persistently (false, /etc). -// -// This call returns an array with the changes made. The changes list -// consists of structures with three strings: the type of the change (one of -// symlink or unlink), the file name of the symlink and the destination of the -// symlink. -func (c *Conn) DisableUnitFiles(files []string, runtime bool) ([]DisableUnitFileChange, error) { - result := make([][]interface{}, 0) - err := c.sysobj.Call("DisableUnitFiles", 0, files, runtime).Store(&result) - if err != nil { - return nil, err - } - - resultInterface := make([]interface{}, len(result)) - for i := range result { - resultInterface[i] = result[i] - } - - changes := make([]DisableUnitFileChange, len(result)) - changesInterface := make([]interface{}, len(changes)) - for i := range changes { - changesInterface[i] = &changes[i] - } - - err = dbus.Store(resultInterface, changesInterface...) - if err != nil { - return nil, err - } - - return changes, nil -} - -type DisableUnitFileChange struct { - Type string // Type of the change (one of symlink or unlink) - Filename string // File name of the symlink - Destination string // Destination of the symlink -} - -// Reload instructs systemd to scan for and reload unit files. This is -// equivalent to a 'systemctl daemon-reload'. -func (c *Conn) Reload() error { - return c.sysobj.Call("org.freedesktop.systemd1.Manager.Reload", 0).Store() -} diff --git a/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/coreos/go-systemd/dbus/methods_test.go b/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/coreos/go-systemd/dbus/methods_test.go deleted file mode 100644 index 9e2f2232..00000000 --- a/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/coreos/go-systemd/dbus/methods_test.go +++ /dev/null @@ -1,314 +0,0 @@ -/* -Copyright 2013 CoreOS Inc. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package dbus - -import ( - "fmt" - "github.com/guelfey/go.dbus" - "math/rand" - "os" - "path/filepath" - "reflect" - "testing" -) - -func setupConn(t *testing.T) *Conn { - conn, err := New() - if err != nil { - t.Fatal(err) - } - - return conn -} - -func setupUnit(target string, conn *Conn, t *testing.T) { - // Blindly stop the unit in case it is running - conn.StopUnit(target, "replace") - - // Blindly remove the symlink in case it exists - targetRun := filepath.Join("/run/systemd/system/", target) - err := os.Remove(targetRun) - - // 1. Enable the unit - abs, err := filepath.Abs("../fixtures/" + target) - if err != nil { - t.Fatal(err) - } - - fixture := []string{abs} - - install, changes, err := conn.EnableUnitFiles(fixture, true, true) - if err != nil { - t.Fatal(err) - } - - if install != false { - t.Fatal("Install was true") - } - - if len(changes) < 1 { - t.Fatalf("Expected one change, got %v", changes) - } - - if changes[0].Filename != targetRun { - t.Fatal("Unexpected target filename") - } -} - -// Ensure that basic unit starting and stopping works. -func TestStartStopUnit(t *testing.T) { - target := "start-stop.service" - conn := setupConn(t) - - setupUnit(target, conn, t) - - // 2. Start the unit - job, err := conn.StartUnit(target, "replace") - if err != nil { - t.Fatal(err) - } - - if job != "done" { - t.Fatal("Job is not done, %v", job) - } - - units, err := conn.ListUnits() - - var unit *UnitStatus - for _, u := range units { - if u.Name == target { - unit = &u - } - } - - if unit == nil { - t.Fatalf("Test unit not found in list") - } - - if unit.ActiveState != "active" { - t.Fatalf("Test unit not active") - } - - // 3. Stop the unit - job, err = conn.StopUnit(target, "replace") - if err != nil { - t.Fatal(err) - } - - units, err = conn.ListUnits() - - unit = nil - for _, u := range units { - if u.Name == target { - unit = &u - } - } - - if unit != nil { - t.Fatalf("Test unit found in list, should be stopped") - } -} - -// Enables a unit and then immediately tears it down -func TestEnableDisableUnit(t *testing.T) { - target := "enable-disable.service" - conn := setupConn(t) - - setupUnit(target, conn, t) - - abs, err := filepath.Abs("../fixtures/" + target) - if err != nil { - t.Fatal(err) - } - - path := filepath.Join("/run/systemd/system/", target) - - // 2. Disable the unit - changes, err := conn.DisableUnitFiles([]string{abs}, true) - if err != nil { - t.Fatal(err) - } - - if len(changes) != 1 { - t.Fatalf("Changes should include the path, %v", changes) - } - if changes[0].Filename != path { - t.Fatalf("Change should include correct filename, %+v", changes[0]) - } - if changes[0].Destination != "" { - t.Fatalf("Change destination should be empty, %+v", changes[0]) - } -} - -// TestGetUnitProperties reads the `-.mount` which should exist on all systemd -// systems and ensures that one of its properties is valid. -func TestGetUnitProperties(t *testing.T) { - conn := setupConn(t) - - unit := "-.mount" - - info, err := conn.GetUnitProperties(unit) - if err != nil { - t.Fatal(err) - } - - names := info["Wants"].([]string) - - if len(names) < 1 { - t.Fatal("/ is unwanted") - } - - if names[0] != "system.slice" { - t.Fatal("unexpected wants for /") - } - - prop, err := conn.GetUnitProperty(unit, "Wants") - if err != nil { - t.Fatal(err) - } - - if prop.Name != "Wants" { - t.Fatal("unexpected property name") - } - - val := prop.Value.Value().([]string) - if !reflect.DeepEqual(val, names) { - t.Fatal("unexpected property value") - } -} - -// TestGetUnitPropertiesRejectsInvalidName attempts to get the properties for a -// unit with an invalid name. This test should be run with --test.timeout set, -// as a fail will manifest as GetUnitProperties hanging indefinitely. -func TestGetUnitPropertiesRejectsInvalidName(t *testing.T) { - conn := setupConn(t) - - unit := "//invalid#$^/" - - _, err := conn.GetUnitProperties(unit) - if err == nil { - t.Fatal("Expected an error, got nil") - } - - _, err = conn.GetUnitProperty(unit, "Wants") - if err == nil { - t.Fatal("Expected an error, got nil") - } -} - -// TestSetUnitProperties changes a cgroup setting on the `tmp.mount` -// which should exist on all systemd systems and ensures that the -// property was set. -func TestSetUnitProperties(t *testing.T) { - conn := setupConn(t) - - unit := "tmp.mount" - - if err := conn.SetUnitProperties(unit, true, Property{"CPUShares", dbus.MakeVariant(uint64(1023))}); err != nil { - t.Fatal(err) - } - - info, err := conn.GetUnitTypeProperties(unit, "Mount") - if err != nil { - t.Fatal(err) - } - - value := info["CPUShares"].(uint64) - if value != 1023 { - t.Fatal("CPUShares of unit is not 1023, %s", value) - } -} - -// Ensure that basic transient unit starting and stopping works. -func TestStartStopTransientUnit(t *testing.T) { - conn := setupConn(t) - - props := []Property{ - PropExecStart([]string{"/bin/sleep", "400"}, false), - } - target := fmt.Sprintf("testing-transient-%d.service", rand.Int()) - - // Start the unit - job, err := conn.StartTransientUnit(target, "replace", props...) - if err != nil { - t.Fatal(err) - } - - if job != "done" { - t.Fatal("Job is not done, %v", job) - } - - units, err := conn.ListUnits() - - var unit *UnitStatus - for _, u := range units { - if u.Name == target { - unit = &u - } - } - - if unit == nil { - t.Fatalf("Test unit not found in list") - } - - if unit.ActiveState != "active" { - t.Fatalf("Test unit not active") - } - - // 3. Stop the unit - job, err = conn.StopUnit(target, "replace") - if err != nil { - t.Fatal(err) - } - - units, err = conn.ListUnits() - - unit = nil - for _, u := range units { - if u.Name == target { - unit = &u - } - } - - if unit != nil { - t.Fatalf("Test unit found in list, should be stopped") - } -} - -func TestConnJobListener(t *testing.T) { - target := "start-stop.service" - conn := setupConn(t) - - setupUnit(target, conn, t) - - jobSize := len(conn.jobListener.jobs) - - _, err := conn.StartUnit(target, "replace") - if err != nil { - t.Fatal(err) - } - - _, err = conn.StopUnit(target, "replace") - if err != nil { - t.Fatal(err) - } - - currentJobSize := len(conn.jobListener.jobs) - if jobSize != currentJobSize { - t.Fatal("JobListener jobs leaked") - } -} diff --git a/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/coreos/go-systemd/dbus/properties.go b/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/coreos/go-systemd/dbus/properties.go deleted file mode 100644 index 83dc1ab6..00000000 --- a/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/coreos/go-systemd/dbus/properties.go +++ /dev/null @@ -1,220 +0,0 @@ -/* -Copyright 2013 CoreOS Inc. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package dbus - -import ( - "github.com/guelfey/go.dbus" -) - -// From the systemd docs: -// -// The properties array of StartTransientUnit() may take many of the settings -// that may also be configured in unit files. Not all parameters are currently -// accepted though, but we plan to cover more properties with future release. -// Currently you may set the Description, Slice and all dependency types of -// units, as well as RemainAfterExit, ExecStart for service units, -// TimeoutStopUSec and PIDs for scope units, and CPUAccounting, CPUShares, -// BlockIOAccounting, BlockIOWeight, BlockIOReadBandwidth, -// BlockIOWriteBandwidth, BlockIODeviceWeight, MemoryAccounting, MemoryLimit, -// DevicePolicy, DeviceAllow for services/scopes/slices. These fields map -// directly to their counterparts in unit files and as normal D-Bus object -// properties. The exception here is the PIDs field of scope units which is -// used for construction of the scope only and specifies the initial PIDs to -// add to the scope object. - -type Property struct { - Name string - Value dbus.Variant -} - -type PropertyCollection struct { - Name string - Properties []Property -} - -type execStart struct { - Path string // the binary path to execute - Args []string // an array with all arguments to pass to the executed command, starting with argument 0 - UncleanIsFailure bool // a boolean whether it should be considered a failure if the process exits uncleanly -} - -// PropExecStart sets the ExecStart service property. The first argument is a -// slice with the binary path to execute followed by the arguments to pass to -// the executed command. See -// http://www.freedesktop.org/software/systemd/man/systemd.service.html#ExecStart= -func PropExecStart(command []string, uncleanIsFailure bool) Property { - execStarts := []execStart{ - execStart{ - Path: command[0], - Args: command, - UncleanIsFailure: uncleanIsFailure, - }, - } - - return Property{ - Name: "ExecStart", - Value: dbus.MakeVariant(execStarts), - } -} - -// PropRemainAfterExit sets the RemainAfterExit service property. See -// http://www.freedesktop.org/software/systemd/man/systemd.service.html#RemainAfterExit= -func PropRemainAfterExit(b bool) Property { - return Property{ - Name: "RemainAfterExit", - Value: dbus.MakeVariant(b), - } -} - -// PropDescription sets the Description unit property. See -// http://www.freedesktop.org/software/systemd/man/systemd.unit#Description= -func PropDescription(desc string) Property { - return Property{ - Name: "Description", - Value: dbus.MakeVariant(desc), - } -} - -func propDependency(name string, units []string) Property { - return Property{ - Name: name, - Value: dbus.MakeVariant(units), - } -} - -// PropRequires sets the Requires unit property. See -// http://www.freedesktop.org/software/systemd/man/systemd.unit.html#Requires= -func PropRequires(units ...string) Property { - return propDependency("Requires", units) -} - -// PropRequiresOverridable sets the RequiresOverridable unit property. See -// http://www.freedesktop.org/software/systemd/man/systemd.unit.html#RequiresOverridable= -func PropRequiresOverridable(units ...string) Property { - return propDependency("RequiresOverridable", units) -} - -// PropRequisite sets the Requisite unit property. See -// http://www.freedesktop.org/software/systemd/man/systemd.unit.html#Requisite= -func PropRequisite(units ...string) Property { - return propDependency("Requisite", units) -} - -// PropRequisiteOverridable sets the RequisiteOverridable unit property. See -// http://www.freedesktop.org/software/systemd/man/systemd.unit.html#RequisiteOverridable= -func PropRequisiteOverridable(units ...string) Property { - return propDependency("RequisiteOverridable", units) -} - -// PropWants sets the Wants unit property. See -// http://www.freedesktop.org/software/systemd/man/systemd.unit.html#Wants= -func PropWants(units ...string) Property { - return propDependency("Wants", units) -} - -// PropBindsTo sets the BindsTo unit property. See -// http://www.freedesktop.org/software/systemd/man/systemd.unit.html#BindsTo= -func PropBindsTo(units ...string) Property { - return propDependency("BindsTo", units) -} - -// PropRequiredBy sets the RequiredBy unit property. See -// http://www.freedesktop.org/software/systemd/man/systemd.unit.html#RequiredBy= -func PropRequiredBy(units ...string) Property { - return propDependency("RequiredBy", units) -} - -// PropRequiredByOverridable sets the RequiredByOverridable unit property. See -// http://www.freedesktop.org/software/systemd/man/systemd.unit.html#RequiredByOverridable= -func PropRequiredByOverridable(units ...string) Property { - return propDependency("RequiredByOverridable", units) -} - -// PropWantedBy sets the WantedBy unit property. See -// http://www.freedesktop.org/software/systemd/man/systemd.unit.html#WantedBy= -func PropWantedBy(units ...string) Property { - return propDependency("WantedBy", units) -} - -// PropBoundBy sets the BoundBy unit property. See -// http://www.freedesktop.org/software/systemd/main/systemd.unit.html#BoundBy= -func PropBoundBy(units ...string) Property { - return propDependency("BoundBy", units) -} - -// PropConflicts sets the Conflicts unit property. See -// http://www.freedesktop.org/software/systemd/man/systemd.unit.html#Conflicts= -func PropConflicts(units ...string) Property { - return propDependency("Conflicts", units) -} - -// PropConflictedBy sets the ConflictedBy unit property. See -// http://www.freedesktop.org/software/systemd/man/systemd.unit.html#ConflictedBy= -func PropConflictedBy(units ...string) Property { - return propDependency("ConflictedBy", units) -} - -// PropBefore sets the Before unit property. See -// http://www.freedesktop.org/software/systemd/man/systemd.unit.html#Before= -func PropBefore(units ...string) Property { - return propDependency("Before", units) -} - -// PropAfter sets the After unit property. See -// http://www.freedesktop.org/software/systemd/man/systemd.unit.html#After= -func PropAfter(units ...string) Property { - return propDependency("After", units) -} - -// PropOnFailure sets the OnFailure unit property. See -// http://www.freedesktop.org/software/systemd/man/systemd.unit.html#OnFailure= -func PropOnFailure(units ...string) Property { - return propDependency("OnFailure", units) -} - -// PropTriggers sets the Triggers unit property. See -// http://www.freedesktop.org/software/systemd/man/systemd.unit.html#Triggers= -func PropTriggers(units ...string) Property { - return propDependency("Triggers", units) -} - -// PropTriggeredBy sets the TriggeredBy unit property. See -// http://www.freedesktop.org/software/systemd/man/systemd.unit.html#TriggeredBy= -func PropTriggeredBy(units ...string) Property { - return propDependency("TriggeredBy", units) -} - -// PropPropagatesReloadTo sets the PropagatesReloadTo unit property. See -// http://www.freedesktop.org/software/systemd/man/systemd.unit.html#PropagatesReloadTo= -func PropPropagatesReloadTo(units ...string) Property { - return propDependency("PropagatesReloadTo", units) -} - -// PropRequiresMountsFor sets the RequiresMountsFor unit property. See -// http://www.freedesktop.org/software/systemd/man/systemd.unit.html#RequiresMountsFor= -func PropRequiresMountsFor(units ...string) Property { - return propDependency("RequiresMountsFor", units) -} - -// PropSlice sets the Slice unit property. See -// http://www.freedesktop.org/software/systemd/man/systemd.resource-control.html#Slice= -func PropSlice(slice string) Property { - return Property{ - Name: "Slice", - Value: dbus.MakeVariant(slice), - } -} diff --git a/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/coreos/go-systemd/dbus/set.go b/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/coreos/go-systemd/dbus/set.go deleted file mode 100644 index 88378b29..00000000 --- a/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/coreos/go-systemd/dbus/set.go +++ /dev/null @@ -1,26 +0,0 @@ -package dbus - -type set struct { - data map[string]bool -} - -func (s *set) Add(value string) { - s.data[value] = true -} - -func (s *set) Remove(value string) { - delete(s.data, value) -} - -func (s *set) Contains(value string) (exists bool) { - _, exists = s.data[value] - return -} - -func (s *set) Length() (int) { - return len(s.data) -} - -func newSet() (*set) { - return &set{make(map[string] bool)} -} diff --git a/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/coreos/go-systemd/dbus/set_test.go b/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/coreos/go-systemd/dbus/set_test.go deleted file mode 100644 index d8d174d0..00000000 --- a/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/coreos/go-systemd/dbus/set_test.go +++ /dev/null @@ -1,26 +0,0 @@ -package dbus - -import ( - "testing" -) - -// TestBasicSetActions asserts that Add & Remove behavior is correct -func TestBasicSetActions(t *testing.T) { - s := newSet() - - if s.Contains("foo") { - t.Fatal("set should not contain 'foo'") - } - - s.Add("foo") - - if !s.Contains("foo") { - t.Fatal("set should contain 'foo'") - } - - s.Remove("foo") - - if s.Contains("foo") { - t.Fatal("set should not contain 'foo'") - } -} diff --git a/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/coreos/go-systemd/dbus/subscription.go b/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/coreos/go-systemd/dbus/subscription.go deleted file mode 100644 index c545c05b..00000000 --- a/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/coreos/go-systemd/dbus/subscription.go +++ /dev/null @@ -1,249 +0,0 @@ -/* -Copyright 2013 CoreOS Inc. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package dbus - -import ( - "errors" - "time" - - "github.com/guelfey/go.dbus" -) - -const ( - cleanIgnoreInterval = int64(10 * time.Second) - ignoreInterval = int64(30 * time.Millisecond) -) - -// Subscribe sets up this connection to subscribe to all systemd dbus events. -// This is required before calling SubscribeUnits. When the connection closes -// systemd will automatically stop sending signals so there is no need to -// explicitly call Unsubscribe(). -func (c *Conn) Subscribe() error { - c.sysconn.BusObject().Call("org.freedesktop.DBus.AddMatch", 0, - "type='signal',interface='org.freedesktop.systemd1.Manager',member='UnitNew'") - c.sysconn.BusObject().Call("org.freedesktop.DBus.AddMatch", 0, - "type='signal',interface='org.freedesktop.DBus.Properties',member='PropertiesChanged'") - - err := c.sysobj.Call("org.freedesktop.systemd1.Manager.Subscribe", 0).Store() - if err != nil { - c.sysconn.Close() - return err - } - - return nil -} - -// Unsubscribe this connection from systemd dbus events. -func (c *Conn) Unsubscribe() error { - err := c.sysobj.Call("org.freedesktop.systemd1.Manager.Unsubscribe", 0).Store() - if err != nil { - c.sysconn.Close() - return err - } - - return nil -} - -func (c *Conn) initSubscription() { - c.subscriber.ignore = make(map[dbus.ObjectPath]int64) -} - -func (c *Conn) initDispatch() { - ch := make(chan *dbus.Signal, signalBuffer) - - c.sysconn.Signal(ch) - - go func() { - for { - signal := <-ch - switch signal.Name { - case "org.freedesktop.systemd1.Manager.JobRemoved": - c.jobComplete(signal) - - unitName := signal.Body[2].(string) - var unitPath dbus.ObjectPath - c.sysobj.Call("org.freedesktop.systemd1.Manager.GetUnit", 0, unitName).Store(&unitPath) - if unitPath != dbus.ObjectPath("") { - c.sendSubStateUpdate(unitPath) - } - case "org.freedesktop.systemd1.Manager.UnitNew": - c.sendSubStateUpdate(signal.Body[1].(dbus.ObjectPath)) - case "org.freedesktop.DBus.Properties.PropertiesChanged": - if signal.Body[0].(string) == "org.freedesktop.systemd1.Unit" { - // we only care about SubState updates, which are a Unit property - c.sendSubStateUpdate(signal.Path) - } - } - } - }() -} - -// Returns two unbuffered channels which will receive all changed units every -// interval. Deleted units are sent as nil. -func (c *Conn) SubscribeUnits(interval time.Duration) (<-chan map[string]*UnitStatus, <-chan error) { - return c.SubscribeUnitsCustom(interval, 0, func(u1, u2 *UnitStatus) bool { return *u1 != *u2 }, nil) -} - -// SubscribeUnitsCustom is like SubscribeUnits but lets you specify the buffer -// size of the channels, the comparison function for detecting changes and a filter -// function for cutting down on the noise that your channel receives. -func (c *Conn) SubscribeUnitsCustom(interval time.Duration, buffer int, isChanged func(*UnitStatus, *UnitStatus) bool, filterUnit func(string) bool) (<-chan map[string]*UnitStatus, <-chan error) { - old := make(map[string]*UnitStatus) - statusChan := make(chan map[string]*UnitStatus, buffer) - errChan := make(chan error, buffer) - - go func() { - for { - timerChan := time.After(interval) - - units, err := c.ListUnits() - if err == nil { - cur := make(map[string]*UnitStatus) - for i := range units { - if filterUnit != nil && filterUnit(units[i].Name) { - continue - } - cur[units[i].Name] = &units[i] - } - - // add all new or changed units - changed := make(map[string]*UnitStatus) - for n, u := range cur { - if oldU, ok := old[n]; !ok || isChanged(oldU, u) { - changed[n] = u - } - delete(old, n) - } - - // add all deleted units - for oldN := range old { - changed[oldN] = nil - } - - old = cur - - if len(changed) != 0 { - statusChan <- changed - } - } else { - errChan <- err - } - - <-timerChan - } - }() - - return statusChan, errChan -} - -type SubStateUpdate struct { - UnitName string - SubState string -} - -// SetSubStateSubscriber writes to updateCh when any unit's substate changes. -// Although this writes to updateCh on every state change, the reported state -// may be more recent than the change that generated it (due to an unavoidable -// race in the systemd dbus interface). That is, this method provides a good -// way to keep a current view of all units' states, but is not guaranteed to -// show every state transition they go through. Furthermore, state changes -// will only be written to the channel with non-blocking writes. If updateCh -// is full, it attempts to write an error to errCh; if errCh is full, the error -// passes silently. -func (c *Conn) SetSubStateSubscriber(updateCh chan<- *SubStateUpdate, errCh chan<- error) { - c.subscriber.Lock() - defer c.subscriber.Unlock() - c.subscriber.updateCh = updateCh - c.subscriber.errCh = errCh -} - -func (c *Conn) sendSubStateUpdate(path dbus.ObjectPath) { - c.subscriber.Lock() - defer c.subscriber.Unlock() - if c.subscriber.updateCh == nil { - return - } - - if c.shouldIgnore(path) { - return - } - - info, err := c.GetUnitProperties(string(path)) - if err != nil { - select { - case c.subscriber.errCh <- err: - default: - } - } - - name := info["Id"].(string) - substate := info["SubState"].(string) - - update := &SubStateUpdate{name, substate} - select { - case c.subscriber.updateCh <- update: - default: - select { - case c.subscriber.errCh <- errors.New("update channel full!"): - default: - } - } - - c.updateIgnore(path, info) -} - -// The ignore functions work around a wart in the systemd dbus interface. -// Requesting the properties of an unloaded unit will cause systemd to send a -// pair of UnitNew/UnitRemoved signals. Because we need to get a unit's -// properties on UnitNew (as that's the only indication of a new unit coming up -// for the first time), we would enter an infinite loop if we did not attempt -// to detect and ignore these spurious signals. The signal themselves are -// indistinguishable from relevant ones, so we (somewhat hackishly) ignore an -// unloaded unit's signals for a short time after requesting its properties. -// This means that we will miss e.g. a transient unit being restarted -// *immediately* upon failure and also a transient unit being started -// immediately after requesting its status (with systemctl status, for example, -// because this causes a UnitNew signal to be sent which then causes us to fetch -// the properties). - -func (c *Conn) shouldIgnore(path dbus.ObjectPath) bool { - t, ok := c.subscriber.ignore[path] - return ok && t >= time.Now().UnixNano() -} - -func (c *Conn) updateIgnore(path dbus.ObjectPath, info map[string]interface{}) { - c.cleanIgnore() - - // unit is unloaded - it will trigger bad systemd dbus behavior - if info["LoadState"].(string) == "not-found" { - c.subscriber.ignore[path] = time.Now().UnixNano() + ignoreInterval - } -} - -// without this, ignore would grow unboundedly over time -func (c *Conn) cleanIgnore() { - now := time.Now().UnixNano() - if c.subscriber.cleanIgnore < now { - c.subscriber.cleanIgnore = now + cleanIgnoreInterval - - for p, t := range c.subscriber.ignore { - if t < now { - delete(c.subscriber.ignore, p) - } - } - } -} diff --git a/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/coreos/go-systemd/dbus/subscription_set.go b/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/coreos/go-systemd/dbus/subscription_set.go deleted file mode 100644 index 26257860..00000000 --- a/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/coreos/go-systemd/dbus/subscription_set.go +++ /dev/null @@ -1,32 +0,0 @@ -package dbus - -import ( - "time" -) - -// SubscriptionSet returns a subscription set which is like conn.Subscribe but -// can filter to only return events for a set of units. -type SubscriptionSet struct { - *set - conn *Conn -} - - -func (s *SubscriptionSet) filter(unit string) bool { - return !s.Contains(unit) -} - -// Subscribe starts listening for dbus events for all of the units in the set. -// Returns channels identical to conn.SubscribeUnits. -func (s *SubscriptionSet) Subscribe() (<-chan map[string]*UnitStatus, <-chan error) { - // TODO: Make fully evented by using systemd 209 with properties changed values - return s.conn.SubscribeUnitsCustom(time.Second, 0, - func(u1, u2 *UnitStatus) bool { return *u1 != *u2 }, - func(unit string) bool { return s.filter(unit) }, - ) -} - -// NewSubscriptionSet returns a new subscription set. -func (conn *Conn) NewSubscriptionSet() (*SubscriptionSet) { - return &SubscriptionSet{newSet(), conn} -} diff --git a/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/coreos/go-systemd/dbus/subscription_set_test.go b/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/coreos/go-systemd/dbus/subscription_set_test.go deleted file mode 100644 index db600850..00000000 --- a/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/coreos/go-systemd/dbus/subscription_set_test.go +++ /dev/null @@ -1,67 +0,0 @@ -package dbus - -import ( - "testing" - "time" -) - -// TestSubscribeUnit exercises the basics of subscription of a particular unit. -func TestSubscriptionSetUnit(t *testing.T) { - target := "subscribe-events-set.service" - - conn, err := New() - - if err != nil { - t.Fatal(err) - } - - err = conn.Subscribe() - if err != nil { - t.Fatal(err) - } - - subSet := conn.NewSubscriptionSet() - evChan, errChan := subSet.Subscribe() - - subSet.Add(target) - setupUnit(target, conn, t) - - job, err := conn.StartUnit(target, "replace") - if err != nil { - t.Fatal(err) - } - - if job != "done" { - t.Fatal("Couldn't start", target) - } - - timeout := make(chan bool, 1) - go func() { - time.Sleep(3 * time.Second) - close(timeout) - }() - - for { - select { - case changes := <-evChan: - tCh, ok := changes[target] - - if !ok { - t.Fatal("Unexpected event %v", changes) - } - - if tCh.ActiveState == "active" && tCh.Name == target { - goto success - } - case err = <-errChan: - t.Fatal(err) - case <-timeout: - t.Fatal("Reached timeout") - } - } - -success: - return -} - - diff --git a/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/coreos/go-systemd/dbus/subscription_test.go b/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/coreos/go-systemd/dbus/subscription_test.go deleted file mode 100644 index 6f4d0b32..00000000 --- a/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/coreos/go-systemd/dbus/subscription_test.go +++ /dev/null @@ -1,90 +0,0 @@ -package dbus - -import ( - "testing" - "time" -) - -// TestSubscribe exercises the basics of subscription -func TestSubscribe(t *testing.T) { - conn, err := New() - - if err != nil { - t.Fatal(err) - } - - err = conn.Subscribe() - if err != nil { - t.Fatal(err) - } - - err = conn.Unsubscribe() - if err != nil { - t.Fatal(err) - } -} - -// TestSubscribeUnit exercises the basics of subscription of a particular unit. -func TestSubscribeUnit(t *testing.T) { - target := "subscribe-events.service" - - conn, err := New() - - if err != nil { - t.Fatal(err) - } - - err = conn.Subscribe() - if err != nil { - t.Fatal(err) - } - - err = conn.Unsubscribe() - if err != nil { - t.Fatal(err) - } - - evChan, errChan := conn.SubscribeUnits(time.Second) - - setupUnit(target, conn, t) - - job, err := conn.StartUnit(target, "replace") - if err != nil { - t.Fatal(err) - } - - if job != "done" { - t.Fatal("Couldn't start", target) - } - - timeout := make(chan bool, 1) - go func() { - time.Sleep(3 * time.Second) - close(timeout) - }() - - for { - select { - case changes := <-evChan: - tCh, ok := changes[target] - - // Just continue until we see our event. - if !ok { - continue - } - - if tCh.ActiveState == "active" && tCh.Name == target { - goto success - } - case err = <-errChan: - t.Fatal(err) - case <-timeout: - t.Fatal("Reached timeout") - } - } - -success: - return -} - - diff --git a/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/coreos/yaml/LICENSE b/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/coreos/yaml/LICENSE deleted file mode 100644 index a68e67f0..00000000 --- a/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/coreos/yaml/LICENSE +++ /dev/null @@ -1,188 +0,0 @@ - -Copyright (c) 2011-2014 - Canonical Inc. - -This software is licensed under the LGPLv3, included below. - -As a special exception to the GNU Lesser General Public License version 3 -("LGPL3"), the copyright holders of this Library give you permission to -convey to a third party a Combined Work that links statically or dynamically -to this Library without providing any Minimal Corresponding Source or -Minimal Application Code as set out in 4d or providing the installation -information set out in section 4e, provided that you comply with the other -provisions of LGPL3 and provided that you meet, for the Application the -terms and conditions of the license(s) which apply to the Application. - -Except as stated in this special exception, the provisions of LGPL3 will -continue to comply in full to this Library. If you modify this Library, you -may apply this exception to your version of this Library, but you are not -obliged to do so. If you do not wish to do so, delete this exception -statement from your version. This exception does not (and cannot) modify any -license terms which apply to the Application, with which you must still -comply. - - - GNU LESSER GENERAL PUBLIC LICENSE - Version 3, 29 June 2007 - - Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/> - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - - This version of the GNU Lesser General Public License incorporates -the terms and conditions of version 3 of the GNU General Public -License, supplemented by the additional permissions listed below. - - 0. Additional Definitions. - - As used herein, "this License" refers to version 3 of the GNU Lesser -General Public License, and the "GNU GPL" refers to version 3 of the GNU -General Public License. - - "The Library" refers to a covered work governed by this License, -other than an Application or a Combined Work as defined below. - - An "Application" is any work that makes use of an interface provided -by the Library, but which is not otherwise based on the Library. -Defining a subclass of a class defined by the Library is deemed a mode -of using an interface provided by the Library. - - A "Combined Work" is a work produced by combining or linking an -Application with the Library. The particular version of the Library -with which the Combined Work was made is also called the "Linked -Version". - - The "Minimal Corresponding Source" for a Combined Work means the -Corresponding Source for the Combined Work, excluding any source code -for portions of the Combined Work that, considered in isolation, are -based on the Application, and not on the Linked Version. - - The "Corresponding Application Code" for a Combined Work means the -object code and/or source code for the Application, including any data -and utility programs needed for reproducing the Combined Work from the -Application, but excluding the System Libraries of the Combined Work. - - 1. Exception to Section 3 of the GNU GPL. - - You may convey a covered work under sections 3 and 4 of this License -without being bound by section 3 of the GNU GPL. - - 2. Conveying Modified Versions. - - If you modify a copy of the Library, and, in your modifications, a -facility refers to a function or data to be supplied by an Application -that uses the facility (other than as an argument passed when the -facility is invoked), then you may convey a copy of the modified -version: - - a) under this License, provided that you make a good faith effort to - ensure that, in the event an Application does not supply the - function or data, the facility still operates, and performs - whatever part of its purpose remains meaningful, or - - b) under the GNU GPL, with none of the additional permissions of - this License applicable to that copy. - - 3. Object Code Incorporating Material from Library Header Files. - - The object code form of an Application may incorporate material from -a header file that is part of the Library. You may convey such object -code under terms of your choice, provided that, if the incorporated -material is not limited to numerical parameters, data structure -layouts and accessors, or small macros, inline functions and templates -(ten or fewer lines in length), you do both of the following: - - a) Give prominent notice with each copy of the object code that the - Library is used in it and that the Library and its use are - covered by this License. - - b) Accompany the object code with a copy of the GNU GPL and this license - document. - - 4. Combined Works. - - You may convey a Combined Work under terms of your choice that, -taken together, effectively do not restrict modification of the -portions of the Library contained in the Combined Work and reverse -engineering for debugging such modifications, if you also do each of -the following: - - a) Give prominent notice with each copy of the Combined Work that - the Library is used in it and that the Library and its use are - covered by this License. - - b) Accompany the Combined Work with a copy of the GNU GPL and this license - document. - - c) For a Combined Work that displays copyright notices during - execution, include the copyright notice for the Library among - these notices, as well as a reference directing the user to the - copies of the GNU GPL and this license document. - - d) Do one of the following: - - 0) Convey the Minimal Corresponding Source under the terms of this - License, and the Corresponding Application Code in a form - suitable for, and under terms that permit, the user to - recombine or relink the Application with a modified version of - the Linked Version to produce a modified Combined Work, in the - manner specified by section 6 of the GNU GPL for conveying - Corresponding Source. - - 1) Use a suitable shared library mechanism for linking with the - Library. A suitable mechanism is one that (a) uses at run time - a copy of the Library already present on the user's computer - system, and (b) will operate properly with a modified version - of the Library that is interface-compatible with the Linked - Version. - - e) Provide Installation Information, but only if you would otherwise - be required to provide such information under section 6 of the - GNU GPL, and only to the extent that such information is - necessary to install and execute a modified version of the - Combined Work produced by recombining or relinking the - Application with a modified version of the Linked Version. (If - you use option 4d0, the Installation Information must accompany - the Minimal Corresponding Source and Corresponding Application - Code. If you use option 4d1, you must provide the Installation - Information in the manner specified by section 6 of the GNU GPL - for conveying Corresponding Source.) - - 5. Combined Libraries. - - You may place library facilities that are a work based on the -Library side by side in a single library together with other library -facilities that are not Applications and are not covered by this -License, and convey such a combined library under terms of your -choice, if you do both of the following: - - a) Accompany the combined library with a copy of the same work based - on the Library, uncombined with any other library facilities, - conveyed under the terms of this License. - - b) Give prominent notice with the combined library that part of it - is a work based on the Library, and explaining where to find the - accompanying uncombined form of the same work. - - 6. Revised Versions of the GNU Lesser General Public License. - - The Free Software Foundation may publish revised and/or new versions -of the GNU Lesser General Public License from time to time. Such new -versions will be similar in spirit to the present version, but may -differ in detail to address new problems or concerns. - - Each version is given a distinguishing version number. If the -Library as you received it specifies that a certain numbered version -of the GNU Lesser General Public License "or any later version" -applies to it, you have the option of following the terms and -conditions either of that published version or of any later version -published by the Free Software Foundation. If the Library as you -received it does not specify a version number of the GNU Lesser -General Public License, you may choose any version of the GNU Lesser -General Public License ever published by the Free Software Foundation. - - If the Library as you received it specifies that a proxy can decide -whether future versions of the GNU Lesser General Public License shall -apply, that proxy's public statement of acceptance of any version is -permanent authorization for you to choose that version for the -Library. diff --git a/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/coreos/yaml/LICENSE.libyaml b/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/coreos/yaml/LICENSE.libyaml deleted file mode 100644 index 8da58fbf..00000000 --- a/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/coreos/yaml/LICENSE.libyaml +++ /dev/null @@ -1,31 +0,0 @@ -The following files were ported to Go from C files of libyaml, and thus -are still covered by their original copyright and license: - - apic.go - emitterc.go - parserc.go - readerc.go - scannerc.go - writerc.go - yamlh.go - yamlprivateh.go - -Copyright (c) 2006 Kirill Simonov - -Permission is hereby granted, free of charge, to any person obtaining a copy of -this software and associated documentation files (the "Software"), to deal in -the Software without restriction, including without limitation the rights to -use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies -of the Software, and to permit persons to whom the Software is furnished to do -so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/coreos/yaml/README.md b/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/coreos/yaml/README.md deleted file mode 100644 index 44270051..00000000 --- a/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/coreos/yaml/README.md +++ /dev/null @@ -1,131 +0,0 @@ -Note: This is a fork of https://github.com/go-yaml/yaml. The following README -doesn't necessarily apply to this fork. - -# YAML support for the Go language - -Introduction ------------- - -The yaml package enables Go programs to comfortably encode and decode YAML -values. It was developed within [Canonical](https://www.canonical.com) as -part of the [juju](https://juju.ubuntu.com) project, and is based on a -pure Go port of the well-known [libyaml](http://pyyaml.org/wiki/LibYAML) -C library to parse and generate YAML data quickly and reliably. - -Compatibility -------------- - -The yaml package supports most of YAML 1.1 and 1.2, including support for -anchors, tags, map merging, etc. Multi-document unmarshalling is not yet -implemented, and base-60 floats from YAML 1.1 are purposefully not -supported since they're a poor design and are gone in YAML 1.2. - -Installation and usage ----------------------- - -The import path for the package is *gopkg.in/yaml.v1*. - -To install it, run: - - go get gopkg.in/yaml.v1 - -API documentation ------------------ - -If opened in a browser, the import path itself leads to the API documentation: - - * [https://gopkg.in/yaml.v1](https://gopkg.in/yaml.v1) - -API stability -------------- - -The package API for yaml v1 will remain stable as described in [gopkg.in](https://gopkg.in). - - -License -------- - -The yaml package is licensed under the LGPL with an exception that allows it to be linked statically. Please see the LICENSE file for details. - - -Example -------- - -```Go -package main - -import ( - "fmt" - "log" - - "gopkg.in/yaml.v1" -) - -var data = ` -a: Easy! -b: - c: 2 - d: [3, 4] -` - -type T struct { - A string - B struct{C int; D []int ",flow"} -} - -func main() { - t := T{} - - err := yaml.Unmarshal([]byte(data), &t) - if err != nil { - log.Fatalf("error: %v", err) - } - fmt.Printf("--- t:\n%v\n\n", t) - - d, err := yaml.Marshal(&t) - if err != nil { - log.Fatalf("error: %v", err) - } - fmt.Printf("--- t dump:\n%s\n\n", string(d)) - - m := make(map[interface{}]interface{}) - - err = yaml.Unmarshal([]byte(data), &m) - if err != nil { - log.Fatalf("error: %v", err) - } - fmt.Printf("--- m:\n%v\n\n", m) - - d, err = yaml.Marshal(&m) - if err != nil { - log.Fatalf("error: %v", err) - } - fmt.Printf("--- m dump:\n%s\n\n", string(d)) -} -``` - -This example will generate the following output: - -``` ---- t: -{Easy! {2 [3 4]}} - ---- t dump: -a: Easy! -b: - c: 2 - d: [3, 4] - - ---- m: -map[a:Easy! b:map[c:2 d:[3 4]]] - ---- m dump: -a: Easy! -b: - c: 2 - d: - - 3 - - 4 -``` - diff --git a/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/coreos/yaml/apic.go b/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/coreos/yaml/apic.go deleted file mode 100644 index 95ec014e..00000000 --- a/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/coreos/yaml/apic.go +++ /dev/null @@ -1,742 +0,0 @@ -package yaml - -import ( - "io" - "os" -) - -func yaml_insert_token(parser *yaml_parser_t, pos int, token *yaml_token_t) { - //fmt.Println("yaml_insert_token", "pos:", pos, "typ:", token.typ, "head:", parser.tokens_head, "len:", len(parser.tokens)) - - // Check if we can move the queue at the beginning of the buffer. - if parser.tokens_head > 0 && len(parser.tokens) == cap(parser.tokens) { - if parser.tokens_head != len(parser.tokens) { - copy(parser.tokens, parser.tokens[parser.tokens_head:]) - } - parser.tokens = parser.tokens[:len(parser.tokens)-parser.tokens_head] - parser.tokens_head = 0 - } - parser.tokens = append(parser.tokens, *token) - if pos < 0 { - return - } - copy(parser.tokens[parser.tokens_head+pos+1:], parser.tokens[parser.tokens_head+pos:]) - parser.tokens[parser.tokens_head+pos] = *token -} - -// Create a new parser object. -func yaml_parser_initialize(parser *yaml_parser_t) bool { - *parser = yaml_parser_t{ - raw_buffer: make([]byte, 0, input_raw_buffer_size), - buffer: make([]byte, 0, input_buffer_size), - } - return true -} - -// Destroy a parser object. -func yaml_parser_delete(parser *yaml_parser_t) { - *parser = yaml_parser_t{} -} - -// String read handler. -func yaml_string_read_handler(parser *yaml_parser_t, buffer []byte) (n int, err error) { - if parser.input_pos == len(parser.input) { - return 0, io.EOF - } - n = copy(buffer, parser.input[parser.input_pos:]) - parser.input_pos += n - return n, nil -} - -// File read handler. -func yaml_file_read_handler(parser *yaml_parser_t, buffer []byte) (n int, err error) { - return parser.input_file.Read(buffer) -} - -// Set a string input. -func yaml_parser_set_input_string(parser *yaml_parser_t, input []byte) { - if parser.read_handler != nil { - panic("must set the input source only once") - } - parser.read_handler = yaml_string_read_handler - parser.input = input - parser.input_pos = 0 -} - -// Set a file input. -func yaml_parser_set_input_file(parser *yaml_parser_t, file *os.File) { - if parser.read_handler != nil { - panic("must set the input source only once") - } - parser.read_handler = yaml_file_read_handler - parser.input_file = file -} - -// Set the source encoding. -func yaml_parser_set_encoding(parser *yaml_parser_t, encoding yaml_encoding_t) { - if parser.encoding != yaml_ANY_ENCODING { - panic("must set the encoding only once") - } - parser.encoding = encoding -} - -// Create a new emitter object. -func yaml_emitter_initialize(emitter *yaml_emitter_t) bool { - *emitter = yaml_emitter_t{ - buffer: make([]byte, output_buffer_size), - raw_buffer: make([]byte, 0, output_raw_buffer_size), - states: make([]yaml_emitter_state_t, 0, initial_stack_size), - events: make([]yaml_event_t, 0, initial_queue_size), - } - return true -} - -// Destroy an emitter object. -func yaml_emitter_delete(emitter *yaml_emitter_t) { - *emitter = yaml_emitter_t{} -} - -// String write handler. -func yaml_string_write_handler(emitter *yaml_emitter_t, buffer []byte) error { - *emitter.output_buffer = append(*emitter.output_buffer, buffer...) - return nil -} - -// File write handler. -func yaml_file_write_handler(emitter *yaml_emitter_t, buffer []byte) error { - _, err := emitter.output_file.Write(buffer) - return err -} - -// Set a string output. -func yaml_emitter_set_output_string(emitter *yaml_emitter_t, output_buffer *[]byte) { - if emitter.write_handler != nil { - panic("must set the output target only once") - } - emitter.write_handler = yaml_string_write_handler - emitter.output_buffer = output_buffer -} - -// Set a file output. -func yaml_emitter_set_output_file(emitter *yaml_emitter_t, file io.Writer) { - if emitter.write_handler != nil { - panic("must set the output target only once") - } - emitter.write_handler = yaml_file_write_handler - emitter.output_file = file -} - -// Set the output encoding. -func yaml_emitter_set_encoding(emitter *yaml_emitter_t, encoding yaml_encoding_t) { - if emitter.encoding != yaml_ANY_ENCODING { - panic("must set the output encoding only once") - } - emitter.encoding = encoding -} - -// Set the canonical output style. -func yaml_emitter_set_canonical(emitter *yaml_emitter_t, canonical bool) { - emitter.canonical = canonical -} - -//// Set the indentation increment. -func yaml_emitter_set_indent(emitter *yaml_emitter_t, indent int) { - if indent < 2 || indent > 9 { - indent = 2 - } - emitter.best_indent = indent -} - -// Set the preferred line width. -func yaml_emitter_set_width(emitter *yaml_emitter_t, width int) { - if width < 0 { - width = -1 - } - emitter.best_width = width -} - -// Set if unescaped non-ASCII characters are allowed. -func yaml_emitter_set_unicode(emitter *yaml_emitter_t, unicode bool) { - emitter.unicode = unicode -} - -// Set the preferred line break character. -func yaml_emitter_set_break(emitter *yaml_emitter_t, line_break yaml_break_t) { - emitter.line_break = line_break -} - -///* -// * Destroy a token object. -// */ -// -//YAML_DECLARE(void) -//yaml_token_delete(yaml_token_t *token) -//{ -// assert(token); // Non-NULL token object expected. -// -// switch (token.type) -// { -// case YAML_TAG_DIRECTIVE_TOKEN: -// yaml_free(token.data.tag_directive.handle); -// yaml_free(token.data.tag_directive.prefix); -// break; -// -// case YAML_ALIAS_TOKEN: -// yaml_free(token.data.alias.value); -// break; -// -// case YAML_ANCHOR_TOKEN: -// yaml_free(token.data.anchor.value); -// break; -// -// case YAML_TAG_TOKEN: -// yaml_free(token.data.tag.handle); -// yaml_free(token.data.tag.suffix); -// break; -// -// case YAML_SCALAR_TOKEN: -// yaml_free(token.data.scalar.value); -// break; -// -// default: -// break; -// } -// -// memset(token, 0, sizeof(yaml_token_t)); -//} -// -///* -// * Check if a string is a valid UTF-8 sequence. -// * -// * Check 'reader.c' for more details on UTF-8 encoding. -// */ -// -//static int -//yaml_check_utf8(yaml_char_t *start, size_t length) -//{ -// yaml_char_t *end = start+length; -// yaml_char_t *pointer = start; -// -// while (pointer < end) { -// unsigned char octet; -// unsigned int width; -// unsigned int value; -// size_t k; -// -// octet = pointer[0]; -// width = (octet & 0x80) == 0x00 ? 1 : -// (octet & 0xE0) == 0xC0 ? 2 : -// (octet & 0xF0) == 0xE0 ? 3 : -// (octet & 0xF8) == 0xF0 ? 4 : 0; -// value = (octet & 0x80) == 0x00 ? octet & 0x7F : -// (octet & 0xE0) == 0xC0 ? octet & 0x1F : -// (octet & 0xF0) == 0xE0 ? octet & 0x0F : -// (octet & 0xF8) == 0xF0 ? octet & 0x07 : 0; -// if (!width) return 0; -// if (pointer+width > end) return 0; -// for (k = 1; k < width; k ++) { -// octet = pointer[k]; -// if ((octet & 0xC0) != 0x80) return 0; -// value = (value << 6) + (octet & 0x3F); -// } -// if (!((width == 1) || -// (width == 2 && value >= 0x80) || -// (width == 3 && value >= 0x800) || -// (width == 4 && value >= 0x10000))) return 0; -// -// pointer += width; -// } -// -// return 1; -//} -// - -// Create STREAM-START. -func yaml_stream_start_event_initialize(event *yaml_event_t, encoding yaml_encoding_t) bool { - *event = yaml_event_t{ - typ: yaml_STREAM_START_EVENT, - encoding: encoding, - } - return true -} - -// Create STREAM-END. -func yaml_stream_end_event_initialize(event *yaml_event_t) bool { - *event = yaml_event_t{ - typ: yaml_STREAM_END_EVENT, - } - return true -} - -// Create DOCUMENT-START. -func yaml_document_start_event_initialize(event *yaml_event_t, version_directive *yaml_version_directive_t, - tag_directives []yaml_tag_directive_t, implicit bool) bool { - *event = yaml_event_t{ - typ: yaml_DOCUMENT_START_EVENT, - version_directive: version_directive, - tag_directives: tag_directives, - implicit: implicit, - } - return true -} - -// Create DOCUMENT-END. -func yaml_document_end_event_initialize(event *yaml_event_t, implicit bool) bool { - *event = yaml_event_t{ - typ: yaml_DOCUMENT_END_EVENT, - implicit: implicit, - } - return true -} - -///* -// * Create ALIAS. -// */ -// -//YAML_DECLARE(int) -//yaml_alias_event_initialize(event *yaml_event_t, anchor *yaml_char_t) -//{ -// mark yaml_mark_t = { 0, 0, 0 } -// anchor_copy *yaml_char_t = NULL -// -// assert(event) // Non-NULL event object is expected. -// assert(anchor) // Non-NULL anchor is expected. -// -// if (!yaml_check_utf8(anchor, strlen((char *)anchor))) return 0 -// -// anchor_copy = yaml_strdup(anchor) -// if (!anchor_copy) -// return 0 -// -// ALIAS_EVENT_INIT(*event, anchor_copy, mark, mark) -// -// return 1 -//} - -// Create SCALAR. -func yaml_scalar_event_initialize(event *yaml_event_t, anchor, tag, value []byte, plain_implicit, quoted_implicit bool, style yaml_scalar_style_t) bool { - *event = yaml_event_t{ - typ: yaml_SCALAR_EVENT, - anchor: anchor, - tag: tag, - value: value, - implicit: plain_implicit, - quoted_implicit: quoted_implicit, - style: yaml_style_t(style), - } - return true -} - -// Create SEQUENCE-START. -func yaml_sequence_start_event_initialize(event *yaml_event_t, anchor, tag []byte, implicit bool, style yaml_sequence_style_t) bool { - *event = yaml_event_t{ - typ: yaml_SEQUENCE_START_EVENT, - anchor: anchor, - tag: tag, - implicit: implicit, - style: yaml_style_t(style), - } - return true -} - -// Create SEQUENCE-END. -func yaml_sequence_end_event_initialize(event *yaml_event_t) bool { - *event = yaml_event_t{ - typ: yaml_SEQUENCE_END_EVENT, - } - return true -} - -// Create MAPPING-START. -func yaml_mapping_start_event_initialize(event *yaml_event_t, anchor, tag []byte, implicit bool, style yaml_mapping_style_t) bool { - *event = yaml_event_t{ - typ: yaml_MAPPING_START_EVENT, - anchor: anchor, - tag: tag, - implicit: implicit, - style: yaml_style_t(style), - } - return true -} - -// Create MAPPING-END. -func yaml_mapping_end_event_initialize(event *yaml_event_t) bool { - *event = yaml_event_t{ - typ: yaml_MAPPING_END_EVENT, - } - return true -} - -// Destroy an event object. -func yaml_event_delete(event *yaml_event_t) { - *event = yaml_event_t{} -} - -///* -// * Create a document object. -// */ -// -//YAML_DECLARE(int) -//yaml_document_initialize(document *yaml_document_t, -// version_directive *yaml_version_directive_t, -// tag_directives_start *yaml_tag_directive_t, -// tag_directives_end *yaml_tag_directive_t, -// start_implicit int, end_implicit int) -//{ -// struct { -// error yaml_error_type_t -// } context -// struct { -// start *yaml_node_t -// end *yaml_node_t -// top *yaml_node_t -// } nodes = { NULL, NULL, NULL } -// version_directive_copy *yaml_version_directive_t = NULL -// struct { -// start *yaml_tag_directive_t -// end *yaml_tag_directive_t -// top *yaml_tag_directive_t -// } tag_directives_copy = { NULL, NULL, NULL } -// value yaml_tag_directive_t = { NULL, NULL } -// mark yaml_mark_t = { 0, 0, 0 } -// -// assert(document) // Non-NULL document object is expected. -// assert((tag_directives_start && tag_directives_end) || -// (tag_directives_start == tag_directives_end)) -// // Valid tag directives are expected. -// -// if (!STACK_INIT(&context, nodes, INITIAL_STACK_SIZE)) goto error -// -// if (version_directive) { -// version_directive_copy = yaml_malloc(sizeof(yaml_version_directive_t)) -// if (!version_directive_copy) goto error -// version_directive_copy.major = version_directive.major -// version_directive_copy.minor = version_directive.minor -// } -// -// if (tag_directives_start != tag_directives_end) { -// tag_directive *yaml_tag_directive_t -// if (!STACK_INIT(&context, tag_directives_copy, INITIAL_STACK_SIZE)) -// goto error -// for (tag_directive = tag_directives_start -// tag_directive != tag_directives_end; tag_directive ++) { -// assert(tag_directive.handle) -// assert(tag_directive.prefix) -// if (!yaml_check_utf8(tag_directive.handle, -// strlen((char *)tag_directive.handle))) -// goto error -// if (!yaml_check_utf8(tag_directive.prefix, -// strlen((char *)tag_directive.prefix))) -// goto error -// value.handle = yaml_strdup(tag_directive.handle) -// value.prefix = yaml_strdup(tag_directive.prefix) -// if (!value.handle || !value.prefix) goto error -// if (!PUSH(&context, tag_directives_copy, value)) -// goto error -// value.handle = NULL -// value.prefix = NULL -// } -// } -// -// DOCUMENT_INIT(*document, nodes.start, nodes.end, version_directive_copy, -// tag_directives_copy.start, tag_directives_copy.top, -// start_implicit, end_implicit, mark, mark) -// -// return 1 -// -//error: -// STACK_DEL(&context, nodes) -// yaml_free(version_directive_copy) -// while (!STACK_EMPTY(&context, tag_directives_copy)) { -// value yaml_tag_directive_t = POP(&context, tag_directives_copy) -// yaml_free(value.handle) -// yaml_free(value.prefix) -// } -// STACK_DEL(&context, tag_directives_copy) -// yaml_free(value.handle) -// yaml_free(value.prefix) -// -// return 0 -//} -// -///* -// * Destroy a document object. -// */ -// -//YAML_DECLARE(void) -//yaml_document_delete(document *yaml_document_t) -//{ -// struct { -// error yaml_error_type_t -// } context -// tag_directive *yaml_tag_directive_t -// -// context.error = YAML_NO_ERROR // Eliminate a compliler warning. -// -// assert(document) // Non-NULL document object is expected. -// -// while (!STACK_EMPTY(&context, document.nodes)) { -// node yaml_node_t = POP(&context, document.nodes) -// yaml_free(node.tag) -// switch (node.type) { -// case YAML_SCALAR_NODE: -// yaml_free(node.data.scalar.value) -// break -// case YAML_SEQUENCE_NODE: -// STACK_DEL(&context, node.data.sequence.items) -// break -// case YAML_MAPPING_NODE: -// STACK_DEL(&context, node.data.mapping.pairs) -// break -// default: -// assert(0) // Should not happen. -// } -// } -// STACK_DEL(&context, document.nodes) -// -// yaml_free(document.version_directive) -// for (tag_directive = document.tag_directives.start -// tag_directive != document.tag_directives.end -// tag_directive++) { -// yaml_free(tag_directive.handle) -// yaml_free(tag_directive.prefix) -// } -// yaml_free(document.tag_directives.start) -// -// memset(document, 0, sizeof(yaml_document_t)) -//} -// -///** -// * Get a document node. -// */ -// -//YAML_DECLARE(yaml_node_t *) -//yaml_document_get_node(document *yaml_document_t, index int) -//{ -// assert(document) // Non-NULL document object is expected. -// -// if (index > 0 && document.nodes.start + index <= document.nodes.top) { -// return document.nodes.start + index - 1 -// } -// return NULL -//} -// -///** -// * Get the root object. -// */ -// -//YAML_DECLARE(yaml_node_t *) -//yaml_document_get_root_node(document *yaml_document_t) -//{ -// assert(document) // Non-NULL document object is expected. -// -// if (document.nodes.top != document.nodes.start) { -// return document.nodes.start -// } -// return NULL -//} -// -///* -// * Add a scalar node to a document. -// */ -// -//YAML_DECLARE(int) -//yaml_document_add_scalar(document *yaml_document_t, -// tag *yaml_char_t, value *yaml_char_t, length int, -// style yaml_scalar_style_t) -//{ -// struct { -// error yaml_error_type_t -// } context -// mark yaml_mark_t = { 0, 0, 0 } -// tag_copy *yaml_char_t = NULL -// value_copy *yaml_char_t = NULL -// node yaml_node_t -// -// assert(document) // Non-NULL document object is expected. -// assert(value) // Non-NULL value is expected. -// -// if (!tag) { -// tag = (yaml_char_t *)YAML_DEFAULT_SCALAR_TAG -// } -// -// if (!yaml_check_utf8(tag, strlen((char *)tag))) goto error -// tag_copy = yaml_strdup(tag) -// if (!tag_copy) goto error -// -// if (length < 0) { -// length = strlen((char *)value) -// } -// -// if (!yaml_check_utf8(value, length)) goto error -// value_copy = yaml_malloc(length+1) -// if (!value_copy) goto error -// memcpy(value_copy, value, length) -// value_copy[length] = '\0' -// -// SCALAR_NODE_INIT(node, tag_copy, value_copy, length, style, mark, mark) -// if (!PUSH(&context, document.nodes, node)) goto error -// -// return document.nodes.top - document.nodes.start -// -//error: -// yaml_free(tag_copy) -// yaml_free(value_copy) -// -// return 0 -//} -// -///* -// * Add a sequence node to a document. -// */ -// -//YAML_DECLARE(int) -//yaml_document_add_sequence(document *yaml_document_t, -// tag *yaml_char_t, style yaml_sequence_style_t) -//{ -// struct { -// error yaml_error_type_t -// } context -// mark yaml_mark_t = { 0, 0, 0 } -// tag_copy *yaml_char_t = NULL -// struct { -// start *yaml_node_item_t -// end *yaml_node_item_t -// top *yaml_node_item_t -// } items = { NULL, NULL, NULL } -// node yaml_node_t -// -// assert(document) // Non-NULL document object is expected. -// -// if (!tag) { -// tag = (yaml_char_t *)YAML_DEFAULT_SEQUENCE_TAG -// } -// -// if (!yaml_check_utf8(tag, strlen((char *)tag))) goto error -// tag_copy = yaml_strdup(tag) -// if (!tag_copy) goto error -// -// if (!STACK_INIT(&context, items, INITIAL_STACK_SIZE)) goto error -// -// SEQUENCE_NODE_INIT(node, tag_copy, items.start, items.end, -// style, mark, mark) -// if (!PUSH(&context, document.nodes, node)) goto error -// -// return document.nodes.top - document.nodes.start -// -//error: -// STACK_DEL(&context, items) -// yaml_free(tag_copy) -// -// return 0 -//} -// -///* -// * Add a mapping node to a document. -// */ -// -//YAML_DECLARE(int) -//yaml_document_add_mapping(document *yaml_document_t, -// tag *yaml_char_t, style yaml_mapping_style_t) -//{ -// struct { -// error yaml_error_type_t -// } context -// mark yaml_mark_t = { 0, 0, 0 } -// tag_copy *yaml_char_t = NULL -// struct { -// start *yaml_node_pair_t -// end *yaml_node_pair_t -// top *yaml_node_pair_t -// } pairs = { NULL, NULL, NULL } -// node yaml_node_t -// -// assert(document) // Non-NULL document object is expected. -// -// if (!tag) { -// tag = (yaml_char_t *)YAML_DEFAULT_MAPPING_TAG -// } -// -// if (!yaml_check_utf8(tag, strlen((char *)tag))) goto error -// tag_copy = yaml_strdup(tag) -// if (!tag_copy) goto error -// -// if (!STACK_INIT(&context, pairs, INITIAL_STACK_SIZE)) goto error -// -// MAPPING_NODE_INIT(node, tag_copy, pairs.start, pairs.end, -// style, mark, mark) -// if (!PUSH(&context, document.nodes, node)) goto error -// -// return document.nodes.top - document.nodes.start -// -//error: -// STACK_DEL(&context, pairs) -// yaml_free(tag_copy) -// -// return 0 -//} -// -///* -// * Append an item to a sequence node. -// */ -// -//YAML_DECLARE(int) -//yaml_document_append_sequence_item(document *yaml_document_t, -// sequence int, item int) -//{ -// struct { -// error yaml_error_type_t -// } context -// -// assert(document) // Non-NULL document is required. -// assert(sequence > 0 -// && document.nodes.start + sequence <= document.nodes.top) -// // Valid sequence id is required. -// assert(document.nodes.start[sequence-1].type == YAML_SEQUENCE_NODE) -// // A sequence node is required. -// assert(item > 0 && document.nodes.start + item <= document.nodes.top) -// // Valid item id is required. -// -// if (!PUSH(&context, -// document.nodes.start[sequence-1].data.sequence.items, item)) -// return 0 -// -// return 1 -//} -// -///* -// * Append a pair of a key and a value to a mapping node. -// */ -// -//YAML_DECLARE(int) -//yaml_document_append_mapping_pair(document *yaml_document_t, -// mapping int, key int, value int) -//{ -// struct { -// error yaml_error_type_t -// } context -// -// pair yaml_node_pair_t -// -// assert(document) // Non-NULL document is required. -// assert(mapping > 0 -// && document.nodes.start + mapping <= document.nodes.top) -// // Valid mapping id is required. -// assert(document.nodes.start[mapping-1].type == YAML_MAPPING_NODE) -// // A mapping node is required. -// assert(key > 0 && document.nodes.start + key <= document.nodes.top) -// // Valid key id is required. -// assert(value > 0 && document.nodes.start + value <= document.nodes.top) -// // Valid value id is required. -// -// pair.key = key -// pair.value = value -// -// if (!PUSH(&context, -// document.nodes.start[mapping-1].data.mapping.pairs, pair)) -// return 0 -// -// return 1 -//} -// -// diff --git a/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/coreos/yaml/decode.go b/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/coreos/yaml/decode.go deleted file mode 100644 index e219d4bd..00000000 --- a/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/coreos/yaml/decode.go +++ /dev/null @@ -1,571 +0,0 @@ -package yaml - -import ( - "encoding/base64" - "fmt" - "reflect" - "strconv" - "time" -) - -const ( - documentNode = 1 << iota - mappingNode - sequenceNode - scalarNode - aliasNode -) - -type node struct { - kind int - line, column int - tag string - value string - implicit bool - children []*node - anchors map[string]*node -} - -// ---------------------------------------------------------------------------- -// Parser, produces a node tree out of a libyaml event stream. - -type parser struct { - parser yaml_parser_t - event yaml_event_t - doc *node - transform transformString -} - -func newParser(b []byte, t transformString) *parser { - p := parser{transform: t} - - if !yaml_parser_initialize(&p.parser) { - panic("Failed to initialize YAML emitter") - } - - if len(b) == 0 { - b = []byte{'\n'} - } - - yaml_parser_set_input_string(&p.parser, b) - - p.skip() - if p.event.typ != yaml_STREAM_START_EVENT { - panic("Expected stream start event, got " + strconv.Itoa(int(p.event.typ))) - } - p.skip() - return &p -} - -func (p *parser) destroy() { - if p.event.typ != yaml_NO_EVENT { - yaml_event_delete(&p.event) - } - yaml_parser_delete(&p.parser) -} - -func (p *parser) skip() { - if p.event.typ != yaml_NO_EVENT { - if p.event.typ == yaml_STREAM_END_EVENT { - fail("Attempted to go past the end of stream. Corrupted value?") - } - yaml_event_delete(&p.event) - } - if !yaml_parser_parse(&p.parser, &p.event) { - p.fail() - } -} - -func (p *parser) fail() { - var where string - var line int - if p.parser.problem_mark.line != 0 { - line = p.parser.problem_mark.line - } else if p.parser.context_mark.line != 0 { - line = p.parser.context_mark.line - } - if line != 0 { - where = "line " + strconv.Itoa(line) + ": " - } - var msg string - if len(p.parser.problem) > 0 { - msg = p.parser.problem - } else { - msg = "Unknown problem parsing YAML content" - } - fail(where + msg) -} - -func (p *parser) anchor(n *node, anchor []byte) { - if anchor != nil { - p.doc.anchors[string(anchor)] = n - } -} - -func (p *parser) parse() *node { - switch p.event.typ { - case yaml_SCALAR_EVENT: - return p.scalar() - case yaml_ALIAS_EVENT: - return p.alias() - case yaml_MAPPING_START_EVENT: - return p.mapping() - case yaml_SEQUENCE_START_EVENT: - return p.sequence() - case yaml_DOCUMENT_START_EVENT: - return p.document() - case yaml_STREAM_END_EVENT: - // Happens when attempting to decode an empty buffer. - return nil - default: - panic("Attempted to parse unknown event: " + strconv.Itoa(int(p.event.typ))) - } - panic("unreachable") -} - -func (p *parser) node(kind int) *node { - return &node{ - kind: kind, - line: p.event.start_mark.line, - column: p.event.start_mark.column, - } -} - -func (p *parser) document() *node { - n := p.node(documentNode) - n.anchors = make(map[string]*node) - p.doc = n - p.skip() - n.children = append(n.children, p.parse()) - if p.event.typ != yaml_DOCUMENT_END_EVENT { - panic("Expected end of document event but got " + strconv.Itoa(int(p.event.typ))) - } - p.skip() - return n -} - -func (p *parser) alias() *node { - n := p.node(aliasNode) - n.value = string(p.event.anchor) - p.skip() - return n -} - -func (p *parser) scalar() *node { - n := p.node(scalarNode) - n.value = string(p.event.value) - n.tag = string(p.event.tag) - n.implicit = p.event.implicit - p.anchor(n, p.event.anchor) - p.skip() - return n -} - -func (p *parser) sequence() *node { - n := p.node(sequenceNode) - p.anchor(n, p.event.anchor) - p.skip() - for p.event.typ != yaml_SEQUENCE_END_EVENT { - n.children = append(n.children, p.parse()) - } - p.skip() - return n -} - -func (p *parser) mapping() *node { - n := p.node(mappingNode) - p.anchor(n, p.event.anchor) - p.skip() - for p.event.typ != yaml_MAPPING_END_EVENT { - key := p.parse() - key.value = p.transform(key.value) - value := p.parse() - n.children = append(n.children, key, value) - } - p.skip() - return n -} - -// ---------------------------------------------------------------------------- -// Decoder, unmarshals a node into a provided value. - -type decoder struct { - doc *node - aliases map[string]bool -} - -func newDecoder() *decoder { - d := &decoder{} - d.aliases = make(map[string]bool) - return d -} - -// d.setter deals with setters and pointer dereferencing and initialization. -// -// It's a slightly convoluted case to handle properly: -// -// - nil pointers should be initialized, unless being set to nil -// - we don't know at this point yet what's the value to SetYAML() with. -// - we can't separate pointer deref/init and setter checking, because -// a setter may be found while going down a pointer chain. -// -// Thus, here is how it takes care of it: -// -// - out is provided as a pointer, so that it can be replaced. -// - when looking at a non-setter ptr, *out=ptr.Elem(), unless tag=!!null -// - when a setter is found, *out=interface{}, and a set() function is -// returned to call SetYAML() with the value of *out once it's defined. -// -func (d *decoder) setter(tag string, out *reflect.Value, good *bool) (set func()) { - if (*out).Kind() != reflect.Ptr && (*out).CanAddr() { - setter, _ := (*out).Addr().Interface().(Setter) - if setter != nil { - var arg interface{} - *out = reflect.ValueOf(&arg).Elem() - return func() { - *good = setter.SetYAML(shortTag(tag), arg) - } - } - } - again := true - for again { - again = false - setter, _ := (*out).Interface().(Setter) - if tag != yaml_NULL_TAG || setter != nil { - if pv := (*out); pv.Kind() == reflect.Ptr { - if pv.IsNil() { - *out = reflect.New(pv.Type().Elem()).Elem() - pv.Set((*out).Addr()) - } else { - *out = pv.Elem() - } - setter, _ = pv.Interface().(Setter) - again = true - } - } - if setter != nil { - var arg interface{} - *out = reflect.ValueOf(&arg).Elem() - return func() { - *good = setter.SetYAML(shortTag(tag), arg) - } - } - } - return nil -} - -func (d *decoder) unmarshal(n *node, out reflect.Value) (good bool) { - switch n.kind { - case documentNode: - good = d.document(n, out) - case scalarNode: - good = d.scalar(n, out) - case aliasNode: - good = d.alias(n, out) - case mappingNode: - good = d.mapping(n, out) - case sequenceNode: - good = d.sequence(n, out) - default: - panic("Internal error: unknown node kind: " + strconv.Itoa(n.kind)) - } - return -} - -func (d *decoder) document(n *node, out reflect.Value) (good bool) { - if len(n.children) == 1 { - d.doc = n - d.unmarshal(n.children[0], out) - return true - } - return false -} - -func (d *decoder) alias(n *node, out reflect.Value) (good bool) { - an, ok := d.doc.anchors[n.value] - if !ok { - fail("Unknown anchor '" + n.value + "' referenced") - } - if d.aliases[n.value] { - fail("Anchor '" + n.value + "' value contains itself") - } - d.aliases[n.value] = true - good = d.unmarshal(an, out) - delete(d.aliases, n.value) - return good -} - -var zeroValue reflect.Value - -func resetMap(out reflect.Value) { - for _, k := range out.MapKeys() { - out.SetMapIndex(k, zeroValue) - } -} - -var durationType = reflect.TypeOf(time.Duration(0)) - -func (d *decoder) scalar(n *node, out reflect.Value) (good bool) { - var tag string - var resolved interface{} - if n.tag == "" && !n.implicit { - tag = yaml_STR_TAG - resolved = n.value - } else { - tag, resolved = resolve(n.tag, n.value) - if tag == yaml_BINARY_TAG { - data, err := base64.StdEncoding.DecodeString(resolved.(string)) - if err != nil { - fail("!!binary value contains invalid base64 data") - } - resolved = string(data) - } - } - if set := d.setter(tag, &out, &good); set != nil { - defer set() - } - if resolved == nil { - if out.Kind() == reflect.Map && !out.CanAddr() { - resetMap(out) - } else { - out.Set(reflect.Zero(out.Type())) - } - good = true - return - } - switch out.Kind() { - case reflect.String: - if tag == yaml_BINARY_TAG { - out.SetString(resolved.(string)) - good = true - } else if resolved != nil { - out.SetString(n.value) - good = true - } - case reflect.Interface: - if resolved == nil { - out.Set(reflect.Zero(out.Type())) - } else { - out.Set(reflect.ValueOf(resolved)) - } - good = true - case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: - switch resolved := resolved.(type) { - case int: - if !out.OverflowInt(int64(resolved)) { - out.SetInt(int64(resolved)) - good = true - } - case int64: - if !out.OverflowInt(resolved) { - out.SetInt(resolved) - good = true - } - case float64: - if resolved < 1<<63-1 && !out.OverflowInt(int64(resolved)) { - out.SetInt(int64(resolved)) - good = true - } - case string: - if out.Type() == durationType { - d, err := time.ParseDuration(resolved) - if err == nil { - out.SetInt(int64(d)) - good = true - } - } - } - case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr: - switch resolved := resolved.(type) { - case int: - if resolved >= 0 { - out.SetUint(uint64(resolved)) - good = true - } - case int64: - if resolved >= 0 { - out.SetUint(uint64(resolved)) - good = true - } - case float64: - if resolved < 1<<64-1 && !out.OverflowUint(uint64(resolved)) { - out.SetUint(uint64(resolved)) - good = true - } - } - case reflect.Bool: - switch resolved := resolved.(type) { - case bool: - out.SetBool(resolved) - good = true - } - case reflect.Float32, reflect.Float64: - switch resolved := resolved.(type) { - case int: - out.SetFloat(float64(resolved)) - good = true - case int64: - out.SetFloat(float64(resolved)) - good = true - case float64: - out.SetFloat(resolved) - good = true - } - case reflect.Ptr: - if out.Type().Elem() == reflect.TypeOf(resolved) { - elem := reflect.New(out.Type().Elem()) - elem.Elem().Set(reflect.ValueOf(resolved)) - out.Set(elem) - good = true - } - } - return good -} - -func settableValueOf(i interface{}) reflect.Value { - v := reflect.ValueOf(i) - sv := reflect.New(v.Type()).Elem() - sv.Set(v) - return sv -} - -func (d *decoder) sequence(n *node, out reflect.Value) (good bool) { - if set := d.setter(yaml_SEQ_TAG, &out, &good); set != nil { - defer set() - } - var iface reflect.Value - if out.Kind() == reflect.Interface { - // No type hints. Will have to use a generic sequence. - iface = out - out = settableValueOf(make([]interface{}, 0)) - } - - if out.Kind() != reflect.Slice { - return false - } - et := out.Type().Elem() - - l := len(n.children) - for i := 0; i < l; i++ { - e := reflect.New(et).Elem() - if ok := d.unmarshal(n.children[i], e); ok { - out.Set(reflect.Append(out, e)) - } - } - if iface.IsValid() { - iface.Set(out) - } - return true -} - -func (d *decoder) mapping(n *node, out reflect.Value) (good bool) { - if set := d.setter(yaml_MAP_TAG, &out, &good); set != nil { - defer set() - } - if out.Kind() == reflect.Struct { - return d.mappingStruct(n, out) - } - - if out.Kind() == reflect.Interface { - // No type hints. Will have to use a generic map. - iface := out - out = settableValueOf(make(map[interface{}]interface{})) - iface.Set(out) - } - - if out.Kind() != reflect.Map { - return false - } - outt := out.Type() - kt := outt.Key() - et := outt.Elem() - - if out.IsNil() { - out.Set(reflect.MakeMap(outt)) - } - l := len(n.children) - for i := 0; i < l; i += 2 { - if isMerge(n.children[i]) { - d.merge(n.children[i+1], out) - continue - } - k := reflect.New(kt).Elem() - if d.unmarshal(n.children[i], k) { - kkind := k.Kind() - if kkind == reflect.Interface { - kkind = k.Elem().Kind() - } - if kkind == reflect.Map || kkind == reflect.Slice { - fail(fmt.Sprintf("invalid map key: %#v", k.Interface())) - } - e := reflect.New(et).Elem() - if d.unmarshal(n.children[i+1], e) { - out.SetMapIndex(k, e) - } - } - } - return true -} - -func (d *decoder) mappingStruct(n *node, out reflect.Value) (good bool) { - sinfo, err := getStructInfo(out.Type()) - if err != nil { - panic(err) - } - name := settableValueOf("") - l := len(n.children) - for i := 0; i < l; i += 2 { - ni := n.children[i] - if isMerge(ni) { - d.merge(n.children[i+1], out) - continue - } - if !d.unmarshal(ni, name) { - continue - } - if info, ok := sinfo.FieldsMap[name.String()]; ok { - var field reflect.Value - if info.Inline == nil { - field = out.Field(info.Num) - } else { - field = out.FieldByIndex(info.Inline) - } - d.unmarshal(n.children[i+1], field) - } - } - return true -} - -func (d *decoder) merge(n *node, out reflect.Value) { - const wantMap = "map merge requires map or sequence of maps as the value" - switch n.kind { - case mappingNode: - d.unmarshal(n, out) - case aliasNode: - an, ok := d.doc.anchors[n.value] - if ok && an.kind != mappingNode { - fail(wantMap) - } - d.unmarshal(n, out) - case sequenceNode: - // Step backwards as earlier nodes take precedence. - for i := len(n.children) - 1; i >= 0; i-- { - ni := n.children[i] - if ni.kind == aliasNode { - an, ok := d.doc.anchors[ni.value] - if ok && an.kind != mappingNode { - fail(wantMap) - } - } else if ni.kind != mappingNode { - fail(wantMap) - } - d.unmarshal(ni, out) - } - default: - fail(wantMap) - } -} - -func isMerge(n *node) bool { - return n.kind == scalarNode && n.value == "<<" && (n.implicit == true || n.tag == yaml_MERGE_TAG) -} diff --git a/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/coreos/yaml/decode_test.go b/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/coreos/yaml/decode_test.go deleted file mode 100644 index 349bee7d..00000000 --- a/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/coreos/yaml/decode_test.go +++ /dev/null @@ -1,720 +0,0 @@ -package yaml_test - -import ( - "github.com/coreos/yaml" - . "gopkg.in/check.v1" - "math" - "reflect" - "strings" - "time" -) - -var unmarshalIntTest = 123 - -var unmarshalTests = []struct { - data string - value interface{} -}{ - { - "", - &struct{}{}, - }, { - "{}", &struct{}{}, - }, { - "v: hi", - map[string]string{"v": "hi"}, - }, { - "v: hi", map[string]interface{}{"v": "hi"}, - }, { - "v: true", - map[string]string{"v": "true"}, - }, { - "v: true", - map[string]interface{}{"v": true}, - }, { - "v: 10", - map[string]interface{}{"v": 10}, - }, { - "v: 0b10", - map[string]interface{}{"v": 2}, - }, { - "v: 0xA", - map[string]interface{}{"v": 10}, - }, { - "v: 4294967296", - map[string]int64{"v": 4294967296}, - }, { - "v: 0.1", - map[string]interface{}{"v": 0.1}, - }, { - "v: .1", - map[string]interface{}{"v": 0.1}, - }, { - "v: .Inf", - map[string]interface{}{"v": math.Inf(+1)}, - }, { - "v: -.Inf", - map[string]interface{}{"v": math.Inf(-1)}, - }, { - "v: -10", - map[string]interface{}{"v": -10}, - }, { - "v: -.1", - map[string]interface{}{"v": -0.1}, - }, - - // Simple values. - { - "123", - &unmarshalIntTest, - }, - - // Floats from spec - { - "canonical: 6.8523e+5", - map[string]interface{}{"canonical": 6.8523e+5}, - }, { - "expo: 685.230_15e+03", - map[string]interface{}{"expo": 685.23015e+03}, - }, { - "fixed: 685_230.15", - map[string]interface{}{"fixed": 685230.15}, - }, { - "neginf: -.inf", - map[string]interface{}{"neginf": math.Inf(-1)}, - }, { - "fixed: 685_230.15", - map[string]float64{"fixed": 685230.15}, - }, - //{"sexa: 190:20:30.15", map[string]interface{}{"sexa": 0}}, // Unsupported - //{"notanum: .NaN", map[string]interface{}{"notanum": math.NaN()}}, // Equality of NaN fails. - - // Bools from spec - { - "canonical: y", - map[string]interface{}{"canonical": true}, - }, { - "answer: NO", - map[string]interface{}{"answer": false}, - }, { - "logical: True", - map[string]interface{}{"logical": true}, - }, { - "option: on", - map[string]interface{}{"option": true}, - }, { - "option: on", - map[string]bool{"option": true}, - }, - // Ints from spec - { - "canonical: 685230", - map[string]interface{}{"canonical": 685230}, - }, { - "decimal: +685_230", - map[string]interface{}{"decimal": 685230}, - }, { - "octal: 02472256", - map[string]interface{}{"octal": 685230}, - }, { - "hexa: 0x_0A_74_AE", - map[string]interface{}{"hexa": 685230}, - }, { - "bin: 0b1010_0111_0100_1010_1110", - map[string]interface{}{"bin": 685230}, - }, { - "bin: -0b101010", - map[string]interface{}{"bin": -42}, - }, { - "decimal: +685_230", - map[string]int{"decimal": 685230}, - }, - - //{"sexa: 190:20:30", map[string]interface{}{"sexa": 0}}, // Unsupported - - // Nulls from spec - { - "empty:", - map[string]interface{}{"empty": nil}, - }, { - "canonical: ~", - map[string]interface{}{"canonical": nil}, - }, { - "english: null", - map[string]interface{}{"english": nil}, - }, { - "~: null key", - map[interface{}]string{nil: "null key"}, - }, { - "empty:", - map[string]*bool{"empty": nil}, - }, - - // Flow sequence - { - "seq: [A,B]", - map[string]interface{}{"seq": []interface{}{"A", "B"}}, - }, { - "seq: [A,B,C,]", - map[string][]string{"seq": []string{"A", "B", "C"}}, - }, { - "seq: [A,1,C]", - map[string][]string{"seq": []string{"A", "1", "C"}}, - }, { - "seq: [A,1,C]", - map[string][]int{"seq": []int{1}}, - }, { - "seq: [A,1,C]", - map[string]interface{}{"seq": []interface{}{"A", 1, "C"}}, - }, - // Block sequence - { - "seq:\n - A\n - B", - map[string]interface{}{"seq": []interface{}{"A", "B"}}, - }, { - "seq:\n - A\n - B\n - C", - map[string][]string{"seq": []string{"A", "B", "C"}}, - }, { - "seq:\n - A\n - 1\n - C", - map[string][]string{"seq": []string{"A", "1", "C"}}, - }, { - "seq:\n - A\n - 1\n - C", - map[string][]int{"seq": []int{1}}, - }, { - "seq:\n - A\n - 1\n - C", - map[string]interface{}{"seq": []interface{}{"A", 1, "C"}}, - }, - - // Literal block scalar - { - "scalar: | # Comment\n\n literal\n\n \ttext\n\n", - map[string]string{"scalar": "\nliteral\n\n\ttext\n"}, - }, - - // Folded block scalar - { - "scalar: > # Comment\n\n folded\n line\n \n next\n line\n * one\n * two\n\n last\n line\n\n", - map[string]string{"scalar": "\nfolded line\nnext line\n * one\n * two\n\nlast line\n"}, - }, - - // Map inside interface with no type hints. - { - "a: {b: c}", - map[string]interface{}{"a": map[interface{}]interface{}{"b": "c"}}, - }, - - // Structs and type conversions. - { - "hello: world", - &struct{ Hello string }{"world"}, - }, { - "a: {b: c}", - &struct{ A struct{ B string } }{struct{ B string }{"c"}}, - }, { - "a: {b: c}", - &struct{ A *struct{ B string } }{&struct{ B string }{"c"}}, - }, { - "a: {b: c}", - &struct{ A map[string]string }{map[string]string{"b": "c"}}, - }, { - "a: {b: c}", - &struct{ A *map[string]string }{&map[string]string{"b": "c"}}, - }, { - "a:", - &struct{ A map[string]string }{}, - }, { - "a: 1", - &struct{ A int }{1}, - }, { - "a: 1", - &struct{ A float64 }{1}, - }, { - "a: 1.0", - &struct{ A int }{1}, - }, { - "a: 1.0", - &struct{ A uint }{1}, - }, { - "a: [1, 2]", - &struct{ A []int }{[]int{1, 2}}, - }, { - "a: 1", - &struct{ B int }{0}, - }, { - "a: 1", - &struct { - B int "a" - }{1}, - }, { - "a: y", - &struct{ A bool }{true}, - }, - - // Some cross type conversions - { - "v: 42", - map[string]uint{"v": 42}, - }, { - "v: -42", - map[string]uint{}, - }, { - "v: 4294967296", - map[string]uint64{"v": 4294967296}, - }, { - "v: -4294967296", - map[string]uint64{}, - }, - - // Overflow cases. - { - "v: 4294967297", - map[string]int32{}, - }, { - "v: 128", - map[string]int8{}, - }, - - // Quoted values. - { - "'1': '\"2\"'", - map[interface{}]interface{}{"1": "\"2\""}, - }, { - "v:\n- A\n- 'B\n\n C'\n", - map[string][]string{"v": []string{"A", "B\nC"}}, - }, - - // Explicit tags. - { - "v: !!float '1.1'", - map[string]interface{}{"v": 1.1}, - }, { - "v: !!null ''", - map[string]interface{}{"v": nil}, - }, { - "%TAG !y! tag:yaml.org,2002:\n---\nv: !y!int '1'", - map[string]interface{}{"v": 1}, - }, - - // Anchors and aliases. - { - "a: &x 1\nb: &y 2\nc: *x\nd: *y\n", - &struct{ A, B, C, D int }{1, 2, 1, 2}, - }, { - "a: &a {c: 1}\nb: *a", - &struct { - A, B struct { - C int - } - }{struct{ C int }{1}, struct{ C int }{1}}, - }, { - "a: &a [1, 2]\nb: *a", - &struct{ B []int }{[]int{1, 2}}, - }, - - // Bug #1133337 - { - "foo: ''", - map[string]*string{"foo": new(string)}, - }, { - "foo: null", - map[string]string{"foo": ""}, - }, { - "foo: null", - map[string]interface{}{"foo": nil}, - }, - - // Ignored field - { - "a: 1\nb: 2\n", - &struct { - A int - B int "-" - }{1, 0}, - }, - - // Bug #1191981 - { - "" + - "%YAML 1.1\n" + - "--- !!str\n" + - `"Generic line break (no glyph)\n\` + "\n" + - ` Generic line break (glyphed)\n\` + "\n" + - ` Line separator\u2028\` + "\n" + - ` Paragraph separator\u2029"` + "\n", - "" + - "Generic line break (no glyph)\n" + - "Generic line break (glyphed)\n" + - "Line separator\u2028Paragraph separator\u2029", - }, - - // Struct inlining - { - "a: 1\nb: 2\nc: 3\n", - &struct { - A int - C inlineB `yaml:",inline"` - }{1, inlineB{2, inlineC{3}}}, - }, - - // bug 1243827 - { - "a: -b_c", - map[string]interface{}{"a": "-b_c"}, - }, - { - "a: +b_c", - map[string]interface{}{"a": "+b_c"}, - }, - { - "a: 50cent_of_dollar", - map[string]interface{}{"a": "50cent_of_dollar"}, - }, - - // Duration - { - "a: 3s", - map[string]time.Duration{"a": 3 * time.Second}, - }, - - // Issue #24. - { - "a: <foo>", - map[string]string{"a": "<foo>"}, - }, - - // Base 60 floats are obsolete and unsupported. - { - "a: 1:1\n", - map[string]string{"a": "1:1"}, - }, - - // Binary data. - { - "a: !!binary gIGC\n", - map[string]string{"a": "\x80\x81\x82"}, - }, { - "a: !!binary |\n " + strings.Repeat("kJCQ", 17) + "kJ\n CQ\n", - map[string]string{"a": strings.Repeat("\x90", 54)}, - }, { - "a: !!binary |\n " + strings.Repeat("A", 70) + "\n ==\n", - map[string]string{"a": strings.Repeat("\x00", 52)}, - }, -} - -type inlineB struct { - B int - inlineC `yaml:",inline"` -} - -type inlineC struct { - C int -} - -func (s *S) TestUnmarshal(c *C) { - for i, item := range unmarshalTests { - t := reflect.ValueOf(item.value).Type() - var value interface{} - switch t.Kind() { - case reflect.Map: - value = reflect.MakeMap(t).Interface() - case reflect.String: - t := reflect.ValueOf(item.value).Type() - v := reflect.New(t) - value = v.Interface() - default: - pt := reflect.ValueOf(item.value).Type() - pv := reflect.New(pt.Elem()) - value = pv.Interface() - } - err := yaml.Unmarshal([]byte(item.data), value) - c.Assert(err, IsNil, Commentf("Item #%d", i)) - if t.Kind() == reflect.String { - c.Assert(*value.(*string), Equals, item.value, Commentf("Item #%d", i)) - } else { - c.Assert(value, DeepEquals, item.value, Commentf("Item #%d", i)) - } - } -} - -func (s *S) TestUnmarshalNaN(c *C) { - value := map[string]interface{}{} - err := yaml.Unmarshal([]byte("notanum: .NaN"), &value) - c.Assert(err, IsNil) - c.Assert(math.IsNaN(value["notanum"].(float64)), Equals, true) -} - -var unmarshalErrorTests = []struct { - data, error string -}{ - {"v: !!float 'error'", "YAML error: cannot decode !!str `error` as a !!float"}, - {"v: [A,", "YAML error: line 1: did not find expected node content"}, - {"v:\n- [A,", "YAML error: line 2: did not find expected node content"}, - {"a: *b\n", "YAML error: Unknown anchor 'b' referenced"}, - {"a: &a\n b: *a\n", "YAML error: Anchor 'a' value contains itself"}, - {"value: -", "YAML error: block sequence entries are not allowed in this context"}, - {"a: !!binary ==", "YAML error: !!binary value contains invalid base64 data"}, - {"{[.]}", `YAML error: invalid map key: \[\]interface \{\}\{"\."\}`}, - {"{{.}}", `YAML error: invalid map key: map\[interface\ \{\}\]interface \{\}\{".":interface \{\}\(nil\)\}`}, -} - -func (s *S) TestUnmarshalErrors(c *C) { - for _, item := range unmarshalErrorTests { - var value interface{} - err := yaml.Unmarshal([]byte(item.data), &value) - c.Assert(err, ErrorMatches, item.error, Commentf("Partial unmarshal: %#v", value)) - } -} - -var setterTests = []struct { - data, tag string - value interface{} -}{ - {"_: {hi: there}", "!!map", map[interface{}]interface{}{"hi": "there"}}, - {"_: [1,A]", "!!seq", []interface{}{1, "A"}}, - {"_: 10", "!!int", 10}, - {"_: null", "!!null", nil}, - {`_: BAR!`, "!!str", "BAR!"}, - {`_: "BAR!"`, "!!str", "BAR!"}, - {"_: !!foo 'BAR!'", "!!foo", "BAR!"}, -} - -var setterResult = map[int]bool{} - -type typeWithSetter struct { - tag string - value interface{} -} - -func (o *typeWithSetter) SetYAML(tag string, value interface{}) (ok bool) { - o.tag = tag - o.value = value - if i, ok := value.(int); ok { - if result, ok := setterResult[i]; ok { - return result - } - } - return true -} - -type setterPointerType struct { - Field *typeWithSetter "_" -} - -type setterValueType struct { - Field typeWithSetter "_" -} - -func (s *S) TestUnmarshalWithPointerSetter(c *C) { - for _, item := range setterTests { - obj := &setterPointerType{} - err := yaml.Unmarshal([]byte(item.data), obj) - c.Assert(err, IsNil) - c.Assert(obj.Field, NotNil, Commentf("Pointer not initialized (%#v)", item.value)) - c.Assert(obj.Field.tag, Equals, item.tag) - c.Assert(obj.Field.value, DeepEquals, item.value) - } -} - -func (s *S) TestUnmarshalWithValueSetter(c *C) { - for _, item := range setterTests { - obj := &setterValueType{} - err := yaml.Unmarshal([]byte(item.data), obj) - c.Assert(err, IsNil) - c.Assert(obj.Field, NotNil, Commentf("Pointer not initialized (%#v)", item.value)) - c.Assert(obj.Field.tag, Equals, item.tag) - c.Assert(obj.Field.value, DeepEquals, item.value) - } -} - -func (s *S) TestUnmarshalWholeDocumentWithSetter(c *C) { - obj := &typeWithSetter{} - err := yaml.Unmarshal([]byte(setterTests[0].data), obj) - c.Assert(err, IsNil) - c.Assert(obj.tag, Equals, setterTests[0].tag) - value, ok := obj.value.(map[interface{}]interface{}) - c.Assert(ok, Equals, true) - c.Assert(value["_"], DeepEquals, setterTests[0].value) -} - -func (s *S) TestUnmarshalWithFalseSetterIgnoresValue(c *C) { - setterResult[2] = false - setterResult[4] = false - defer func() { - delete(setterResult, 2) - delete(setterResult, 4) - }() - - m := map[string]*typeWithSetter{} - data := `{abc: 1, def: 2, ghi: 3, jkl: 4}` - err := yaml.Unmarshal([]byte(data), m) - c.Assert(err, IsNil) - c.Assert(m["abc"], NotNil) - c.Assert(m["def"], IsNil) - c.Assert(m["ghi"], NotNil) - c.Assert(m["jkl"], IsNil) - - c.Assert(m["abc"].value, Equals, 1) - c.Assert(m["ghi"].value, Equals, 3) -} - -func (s *S) TestUnmarshalWithTransform(c *C) { - data := `{a_b: 1, c-d: 2, e-f_g: 3, h_i-j: 4}` - expect := map[string]int{ - "a_b": 1, - "c_d": 2, - "e_f_g": 3, - "h_i_j": 4, - } - m := map[string]int{} - yaml.UnmarshalMappingKeyTransform = func(i string) string { - return strings.Replace(i, "-", "_", -1) - } - err := yaml.Unmarshal([]byte(data), m) - c.Assert(err, IsNil) - c.Assert(m, DeepEquals, expect) -} - -// From http://yaml.org/type/merge.html -var mergeTests = ` -anchors: - - &CENTER { "x": 1, "y": 2 } - - &LEFT { "x": 0, "y": 2 } - - &BIG { "r": 10 } - - &SMALL { "r": 1 } - -# All the following maps are equal: - -plain: - # Explicit keys - "x": 1 - "y": 2 - "r": 10 - label: center/big - -mergeOne: - # Merge one map - << : *CENTER - "r": 10 - label: center/big - -mergeMultiple: - # Merge multiple maps - << : [ *CENTER, *BIG ] - label: center/big - -override: - # Override - << : [ *BIG, *LEFT, *SMALL ] - "x": 1 - label: center/big - -shortTag: - # Explicit short merge tag - !!merge "<<" : [ *CENTER, *BIG ] - label: center/big - -longTag: - # Explicit merge long tag - !<tag:yaml.org,2002:merge> "<<" : [ *CENTER, *BIG ] - label: center/big - -inlineMap: - # Inlined map - << : {"x": 1, "y": 2, "r": 10} - label: center/big - -inlineSequenceMap: - # Inlined map in sequence - << : [ *CENTER, {"r": 10} ] - label: center/big -` - -func (s *S) TestMerge(c *C) { - var want = map[interface{}]interface{}{ - "x": 1, - "y": 2, - "r": 10, - "label": "center/big", - } - - var m map[string]interface{} - err := yaml.Unmarshal([]byte(mergeTests), &m) - c.Assert(err, IsNil) - for name, test := range m { - if name == "anchors" { - continue - } - c.Assert(test, DeepEquals, want, Commentf("test %q failed", name)) - } -} - -func (s *S) TestMergeStruct(c *C) { - type Data struct { - X, Y, R int - Label string - } - want := Data{1, 2, 10, "center/big"} - - var m map[string]Data - err := yaml.Unmarshal([]byte(mergeTests), &m) - c.Assert(err, IsNil) - for name, test := range m { - if name == "anchors" { - continue - } - c.Assert(test, Equals, want, Commentf("test %q failed", name)) - } -} - -var unmarshalNullTests = []func() interface{}{ - func() interface{} { var v interface{}; v = "v"; return &v }, - func() interface{} { var s = "s"; return &s }, - func() interface{} { var s = "s"; sptr := &s; return &sptr }, - func() interface{} { var i = 1; return &i }, - func() interface{} { var i = 1; iptr := &i; return &iptr }, - func() interface{} { m := map[string]int{"s": 1}; return &m }, - func() interface{} { m := map[string]int{"s": 1}; return m }, -} - -func (s *S) TestUnmarshalNull(c *C) { - for _, test := range unmarshalNullTests { - item := test() - zero := reflect.Zero(reflect.TypeOf(item).Elem()).Interface() - err := yaml.Unmarshal([]byte("null"), item) - c.Assert(err, IsNil) - if reflect.TypeOf(item).Kind() == reflect.Map { - c.Assert(reflect.ValueOf(item).Interface(), DeepEquals, reflect.MakeMap(reflect.TypeOf(item)).Interface()) - } else { - c.Assert(reflect.ValueOf(item).Elem().Interface(), DeepEquals, zero) - } - } -} - -//var data []byte -//func init() { -// var err error -// data, err = ioutil.ReadFile("/tmp/file.yaml") -// if err != nil { -// panic(err) -// } -//} -// -//func (s *S) BenchmarkUnmarshal(c *C) { -// var err error -// for i := 0; i < c.N; i++ { -// var v map[string]interface{} -// err = yaml.Unmarshal(data, &v) -// } -// if err != nil { -// panic(err) -// } -//} -// -//func (s *S) BenchmarkMarshal(c *C) { -// var v map[string]interface{} -// yaml.Unmarshal(data, &v) -// c.ResetTimer() -// for i := 0; i < c.N; i++ { -// yaml.Marshal(&v) -// } -//} diff --git a/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/coreos/yaml/emitterc.go b/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/coreos/yaml/emitterc.go deleted file mode 100644 index 9b3dc4a4..00000000 --- a/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/coreos/yaml/emitterc.go +++ /dev/null @@ -1,1685 +0,0 @@ -package yaml - -import ( - "bytes" -) - -// Flush the buffer if needed. -func flush(emitter *yaml_emitter_t) bool { - if emitter.buffer_pos+5 >= len(emitter.buffer) { - return yaml_emitter_flush(emitter) - } - return true -} - -// Put a character to the output buffer. -func put(emitter *yaml_emitter_t, value byte) bool { - if emitter.buffer_pos+5 >= len(emitter.buffer) && !yaml_emitter_flush(emitter) { - return false - } - emitter.buffer[emitter.buffer_pos] = value - emitter.buffer_pos++ - emitter.column++ - return true -} - -// Put a line break to the output buffer. -func put_break(emitter *yaml_emitter_t) bool { - if emitter.buffer_pos+5 >= len(emitter.buffer) && !yaml_emitter_flush(emitter) { - return false - } - switch emitter.line_break { - case yaml_CR_BREAK: - emitter.buffer[emitter.buffer_pos] = '\r' - emitter.buffer_pos += 1 - case yaml_LN_BREAK: - emitter.buffer[emitter.buffer_pos] = '\n' - emitter.buffer_pos += 1 - case yaml_CRLN_BREAK: - emitter.buffer[emitter.buffer_pos+0] = '\r' - emitter.buffer[emitter.buffer_pos+1] = '\n' - emitter.buffer_pos += 2 - default: - panic("unknown line break setting") - } - emitter.column = 0 - emitter.line++ - return true -} - -// Copy a character from a string into buffer. -func write(emitter *yaml_emitter_t, s []byte, i *int) bool { - if emitter.buffer_pos+5 >= len(emitter.buffer) && !yaml_emitter_flush(emitter) { - return false - } - p := emitter.buffer_pos - w := width(s[*i]) - switch w { - case 4: - emitter.buffer[p+3] = s[*i+3] - fallthrough - case 3: - emitter.buffer[p+2] = s[*i+2] - fallthrough - case 2: - emitter.buffer[p+1] = s[*i+1] - fallthrough - case 1: - emitter.buffer[p+0] = s[*i+0] - default: - panic("unknown character width") - } - emitter.column++ - emitter.buffer_pos += w - *i += w - return true -} - -// Write a whole string into buffer. -func write_all(emitter *yaml_emitter_t, s []byte) bool { - for i := 0; i < len(s); { - if !write(emitter, s, &i) { - return false - } - } - return true -} - -// Copy a line break character from a string into buffer. -func write_break(emitter *yaml_emitter_t, s []byte, i *int) bool { - if s[*i] == '\n' { - if !put_break(emitter) { - return false - } - *i++ - } else { - if !write(emitter, s, i) { - return false - } - emitter.column = 0 - emitter.line++ - } - return true -} - -// Set an emitter error and return false. -func yaml_emitter_set_emitter_error(emitter *yaml_emitter_t, problem string) bool { - emitter.error = yaml_EMITTER_ERROR - emitter.problem = problem - return false -} - -// Emit an event. -func yaml_emitter_emit(emitter *yaml_emitter_t, event *yaml_event_t) bool { - emitter.events = append(emitter.events, *event) - for !yaml_emitter_need_more_events(emitter) { - event := &emitter.events[emitter.events_head] - if !yaml_emitter_analyze_event(emitter, event) { - return false - } - if !yaml_emitter_state_machine(emitter, event) { - return false - } - yaml_event_delete(event) - emitter.events_head++ - } - return true -} - -// Check if we need to accumulate more events before emitting. -// -// We accumulate extra -// - 1 event for DOCUMENT-START -// - 2 events for SEQUENCE-START -// - 3 events for MAPPING-START -// -func yaml_emitter_need_more_events(emitter *yaml_emitter_t) bool { - if emitter.events_head == len(emitter.events) { - return true - } - var accumulate int - switch emitter.events[emitter.events_head].typ { - case yaml_DOCUMENT_START_EVENT: - accumulate = 1 - break - case yaml_SEQUENCE_START_EVENT: - accumulate = 2 - break - case yaml_MAPPING_START_EVENT: - accumulate = 3 - break - default: - return false - } - if len(emitter.events)-emitter.events_head > accumulate { - return false - } - var level int - for i := emitter.events_head; i < len(emitter.events); i++ { - switch emitter.events[i].typ { - case yaml_STREAM_START_EVENT, yaml_DOCUMENT_START_EVENT, yaml_SEQUENCE_START_EVENT, yaml_MAPPING_START_EVENT: - level++ - case yaml_STREAM_END_EVENT, yaml_DOCUMENT_END_EVENT, yaml_SEQUENCE_END_EVENT, yaml_MAPPING_END_EVENT: - level-- - } - if level == 0 { - return false - } - } - return true -} - -// Append a directive to the directives stack. -func yaml_emitter_append_tag_directive(emitter *yaml_emitter_t, value *yaml_tag_directive_t, allow_duplicates bool) bool { - for i := 0; i < len(emitter.tag_directives); i++ { - if bytes.Equal(value.handle, emitter.tag_directives[i].handle) { - if allow_duplicates { - return true - } - return yaml_emitter_set_emitter_error(emitter, "duplicate %TAG directive") - } - } - - // [Go] Do we actually need to copy this given garbage collection - // and the lack of deallocating destructors? - tag_copy := yaml_tag_directive_t{ - handle: make([]byte, len(value.handle)), - prefix: make([]byte, len(value.prefix)), - } - copy(tag_copy.handle, value.handle) - copy(tag_copy.prefix, value.prefix) - emitter.tag_directives = append(emitter.tag_directives, tag_copy) - return true -} - -// Increase the indentation level. -func yaml_emitter_increase_indent(emitter *yaml_emitter_t, flow, indentless bool) bool { - emitter.indents = append(emitter.indents, emitter.indent) - if emitter.indent < 0 { - if flow { - emitter.indent = emitter.best_indent - } else { - emitter.indent = 0 - } - } else if !indentless { - emitter.indent += emitter.best_indent - } - return true -} - -// State dispatcher. -func yaml_emitter_state_machine(emitter *yaml_emitter_t, event *yaml_event_t) bool { - switch emitter.state { - default: - case yaml_EMIT_STREAM_START_STATE: - return yaml_emitter_emit_stream_start(emitter, event) - - case yaml_EMIT_FIRST_DOCUMENT_START_STATE: - return yaml_emitter_emit_document_start(emitter, event, true) - - case yaml_EMIT_DOCUMENT_START_STATE: - return yaml_emitter_emit_document_start(emitter, event, false) - - case yaml_EMIT_DOCUMENT_CONTENT_STATE: - return yaml_emitter_emit_document_content(emitter, event) - - case yaml_EMIT_DOCUMENT_END_STATE: - return yaml_emitter_emit_document_end(emitter, event) - - case yaml_EMIT_FLOW_SEQUENCE_FIRST_ITEM_STATE: - return yaml_emitter_emit_flow_sequence_item(emitter, event, true) - - case yaml_EMIT_FLOW_SEQUENCE_ITEM_STATE: - return yaml_emitter_emit_flow_sequence_item(emitter, event, false) - - case yaml_EMIT_FLOW_MAPPING_FIRST_KEY_STATE: - return yaml_emitter_emit_flow_mapping_key(emitter, event, true) - - case yaml_EMIT_FLOW_MAPPING_KEY_STATE: - return yaml_emitter_emit_flow_mapping_key(emitter, event, false) - - case yaml_EMIT_FLOW_MAPPING_SIMPLE_VALUE_STATE: - return yaml_emitter_emit_flow_mapping_value(emitter, event, true) - - case yaml_EMIT_FLOW_MAPPING_VALUE_STATE: - return yaml_emitter_emit_flow_mapping_value(emitter, event, false) - - case yaml_EMIT_BLOCK_SEQUENCE_FIRST_ITEM_STATE: - return yaml_emitter_emit_block_sequence_item(emitter, event, true) - - case yaml_EMIT_BLOCK_SEQUENCE_ITEM_STATE: - return yaml_emitter_emit_block_sequence_item(emitter, event, false) - - case yaml_EMIT_BLOCK_MAPPING_FIRST_KEY_STATE: - return yaml_emitter_emit_block_mapping_key(emitter, event, true) - - case yaml_EMIT_BLOCK_MAPPING_KEY_STATE: - return yaml_emitter_emit_block_mapping_key(emitter, event, false) - - case yaml_EMIT_BLOCK_MAPPING_SIMPLE_VALUE_STATE: - return yaml_emitter_emit_block_mapping_value(emitter, event, true) - - case yaml_EMIT_BLOCK_MAPPING_VALUE_STATE: - return yaml_emitter_emit_block_mapping_value(emitter, event, false) - - case yaml_EMIT_END_STATE: - return yaml_emitter_set_emitter_error(emitter, "expected nothing after STREAM-END") - } - panic("invalid emitter state") -} - -// Expect STREAM-START. -func yaml_emitter_emit_stream_start(emitter *yaml_emitter_t, event *yaml_event_t) bool { - if event.typ != yaml_STREAM_START_EVENT { - return yaml_emitter_set_emitter_error(emitter, "expected STREAM-START") - } - if emitter.encoding == yaml_ANY_ENCODING { - emitter.encoding = event.encoding - if emitter.encoding == yaml_ANY_ENCODING { - emitter.encoding = yaml_UTF8_ENCODING - } - } - if emitter.best_indent < 2 || emitter.best_indent > 9 { - emitter.best_indent = 2 - } - if emitter.best_width >= 0 && emitter.best_width <= emitter.best_indent*2 { - emitter.best_width = 80 - } - if emitter.best_width < 0 { - emitter.best_width = 1<<31 - 1 - } - if emitter.line_break == yaml_ANY_BREAK { - emitter.line_break = yaml_LN_BREAK - } - - emitter.indent = -1 - emitter.line = 0 - emitter.column = 0 - emitter.whitespace = true - emitter.indention = true - - if emitter.encoding != yaml_UTF8_ENCODING { - if !yaml_emitter_write_bom(emitter) { - return false - } - } - emitter.state = yaml_EMIT_FIRST_DOCUMENT_START_STATE - return true -} - -// Expect DOCUMENT-START or STREAM-END. -func yaml_emitter_emit_document_start(emitter *yaml_emitter_t, event *yaml_event_t, first bool) bool { - - if event.typ == yaml_DOCUMENT_START_EVENT { - - if event.version_directive != nil { - if !yaml_emitter_analyze_version_directive(emitter, event.version_directive) { - return false - } - } - - for i := 0; i < len(event.tag_directives); i++ { - tag_directive := &event.tag_directives[i] - if !yaml_emitter_analyze_tag_directive(emitter, tag_directive) { - return false - } - if !yaml_emitter_append_tag_directive(emitter, tag_directive, false) { - return false - } - } - - for i := 0; i < len(default_tag_directives); i++ { - tag_directive := &default_tag_directives[i] - if !yaml_emitter_append_tag_directive(emitter, tag_directive, true) { - return false - } - } - - implicit := event.implicit - if !first || emitter.canonical { - implicit = false - } - - if emitter.open_ended && (event.version_directive != nil || len(event.tag_directives) > 0) { - if !yaml_emitter_write_indicator(emitter, []byte("..."), true, false, false) { - return false - } - if !yaml_emitter_write_indent(emitter) { - return false - } - } - - if event.version_directive != nil { - implicit = false - if !yaml_emitter_write_indicator(emitter, []byte("%YAML"), true, false, false) { - return false - } - if !yaml_emitter_write_indicator(emitter, []byte("1.1"), true, false, false) { - return false - } - if !yaml_emitter_write_indent(emitter) { - return false - } - } - - if len(event.tag_directives) > 0 { - implicit = false - for i := 0; i < len(event.tag_directives); i++ { - tag_directive := &event.tag_directives[i] - if !yaml_emitter_write_indicator(emitter, []byte("%TAG"), true, false, false) { - return false - } - if !yaml_emitter_write_tag_handle(emitter, tag_directive.handle) { - return false - } - if !yaml_emitter_write_tag_content(emitter, tag_directive.prefix, true) { - return false - } - if !yaml_emitter_write_indent(emitter) { - return false - } - } - } - - if yaml_emitter_check_empty_document(emitter) { - implicit = false - } - if !implicit { - if !yaml_emitter_write_indent(emitter) { - return false - } - if !yaml_emitter_write_indicator(emitter, []byte("---"), true, false, false) { - return false - } - if emitter.canonical { - if !yaml_emitter_write_indent(emitter) { - return false - } - } - } - - emitter.state = yaml_EMIT_DOCUMENT_CONTENT_STATE - return true - } - - if event.typ == yaml_STREAM_END_EVENT { - if emitter.open_ended { - if !yaml_emitter_write_indicator(emitter, []byte("..."), true, false, false) { - return false - } - if !yaml_emitter_write_indent(emitter) { - return false - } - } - if !yaml_emitter_flush(emitter) { - return false - } - emitter.state = yaml_EMIT_END_STATE - return true - } - - return yaml_emitter_set_emitter_error(emitter, "expected DOCUMENT-START or STREAM-END") -} - -// Expect the root node. -func yaml_emitter_emit_document_content(emitter *yaml_emitter_t, event *yaml_event_t) bool { - emitter.states = append(emitter.states, yaml_EMIT_DOCUMENT_END_STATE) - return yaml_emitter_emit_node(emitter, event, true, false, false, false) -} - -// Expect DOCUMENT-END. -func yaml_emitter_emit_document_end(emitter *yaml_emitter_t, event *yaml_event_t) bool { - if event.typ != yaml_DOCUMENT_END_EVENT { - return yaml_emitter_set_emitter_error(emitter, "expected DOCUMENT-END") - } - if !yaml_emitter_write_indent(emitter) { - return false - } - if !event.implicit { - // [Go] Allocate the slice elsewhere. - if !yaml_emitter_write_indicator(emitter, []byte("..."), true, false, false) { - return false - } - if !yaml_emitter_write_indent(emitter) { - return false - } - } - if !yaml_emitter_flush(emitter) { - return false - } - emitter.state = yaml_EMIT_DOCUMENT_START_STATE - emitter.tag_directives = emitter.tag_directives[:0] - return true -} - -// Expect a flow item node. -func yaml_emitter_emit_flow_sequence_item(emitter *yaml_emitter_t, event *yaml_event_t, first bool) bool { - if first { - if !yaml_emitter_write_indicator(emitter, []byte{'['}, true, true, false) { - return false - } - if !yaml_emitter_increase_indent(emitter, true, false) { - return false - } - emitter.flow_level++ - } - - if event.typ == yaml_SEQUENCE_END_EVENT { - emitter.flow_level-- - emitter.indent = emitter.indents[len(emitter.indents)-1] - emitter.indents = emitter.indents[:len(emitter.indents)-1] - if emitter.canonical && !first { - if !yaml_emitter_write_indicator(emitter, []byte{','}, false, false, false) { - return false - } - if !yaml_emitter_write_indent(emitter) { - return false - } - } - if !yaml_emitter_write_indicator(emitter, []byte{']'}, false, false, false) { - return false - } - emitter.state = emitter.states[len(emitter.states)-1] - emitter.states = emitter.states[:len(emitter.states)-1] - - return true - } - - if !first { - if !yaml_emitter_write_indicator(emitter, []byte{','}, false, false, false) { - return false - } - } - - if emitter.canonical || emitter.column > emitter.best_width { - if !yaml_emitter_write_indent(emitter) { - return false - } - } - emitter.states = append(emitter.states, yaml_EMIT_FLOW_SEQUENCE_ITEM_STATE) - return yaml_emitter_emit_node(emitter, event, false, true, false, false) -} - -// Expect a flow key node. -func yaml_emitter_emit_flow_mapping_key(emitter *yaml_emitter_t, event *yaml_event_t, first bool) bool { - if first { - if !yaml_emitter_write_indicator(emitter, []byte{'{'}, true, true, false) { - return false - } - if !yaml_emitter_increase_indent(emitter, true, false) { - return false - } - emitter.flow_level++ - } - - if event.typ == yaml_MAPPING_END_EVENT { - emitter.flow_level-- - emitter.indent = emitter.indents[len(emitter.indents)-1] - emitter.indents = emitter.indents[:len(emitter.indents)-1] - if emitter.canonical && !first { - if !yaml_emitter_write_indicator(emitter, []byte{','}, false, false, false) { - return false - } - if !yaml_emitter_write_indent(emitter) { - return false - } - } - if !yaml_emitter_write_indicator(emitter, []byte{'}'}, false, false, false) { - return false - } - emitter.state = emitter.states[len(emitter.states)-1] - emitter.states = emitter.states[:len(emitter.states)-1] - return true - } - - if !first { - if !yaml_emitter_write_indicator(emitter, []byte{','}, false, false, false) { - return false - } - } - if emitter.canonical || emitter.column > emitter.best_width { - if !yaml_emitter_write_indent(emitter) { - return false - } - } - - if !emitter.canonical && yaml_emitter_check_simple_key(emitter) { - emitter.states = append(emitter.states, yaml_EMIT_FLOW_MAPPING_SIMPLE_VALUE_STATE) - return yaml_emitter_emit_node(emitter, event, false, false, true, true) - } - if !yaml_emitter_write_indicator(emitter, []byte{'?'}, true, false, false) { - return false - } - emitter.states = append(emitter.states, yaml_EMIT_FLOW_MAPPING_VALUE_STATE) - return yaml_emitter_emit_node(emitter, event, false, false, true, false) -} - -// Expect a flow value node. -func yaml_emitter_emit_flow_mapping_value(emitter *yaml_emitter_t, event *yaml_event_t, simple bool) bool { - if simple { - if !yaml_emitter_write_indicator(emitter, []byte{':'}, false, false, false) { - return false - } - } else { - if emitter.canonical || emitter.column > emitter.best_width { - if !yaml_emitter_write_indent(emitter) { - return false - } - } - if !yaml_emitter_write_indicator(emitter, []byte{':'}, true, false, false) { - return false - } - } - emitter.states = append(emitter.states, yaml_EMIT_FLOW_MAPPING_KEY_STATE) - return yaml_emitter_emit_node(emitter, event, false, false, true, false) -} - -// Expect a block item node. -func yaml_emitter_emit_block_sequence_item(emitter *yaml_emitter_t, event *yaml_event_t, first bool) bool { - if first { - if !yaml_emitter_increase_indent(emitter, false, emitter.mapping_context && !emitter.indention) { - return false - } - } - if event.typ == yaml_SEQUENCE_END_EVENT { - emitter.indent = emitter.indents[len(emitter.indents)-1] - emitter.indents = emitter.indents[:len(emitter.indents)-1] - emitter.state = emitter.states[len(emitter.states)-1] - emitter.states = emitter.states[:len(emitter.states)-1] - return true - } - if !yaml_emitter_write_indent(emitter) { - return false - } - if !yaml_emitter_write_indicator(emitter, []byte{'-'}, true, false, true) { - return false - } - emitter.states = append(emitter.states, yaml_EMIT_BLOCK_SEQUENCE_ITEM_STATE) - return yaml_emitter_emit_node(emitter, event, false, true, false, false) -} - -// Expect a block key node. -func yaml_emitter_emit_block_mapping_key(emitter *yaml_emitter_t, event *yaml_event_t, first bool) bool { - if first { - if !yaml_emitter_increase_indent(emitter, false, false) { - return false - } - } - if event.typ == yaml_MAPPING_END_EVENT { - emitter.indent = emitter.indents[len(emitter.indents)-1] - emitter.indents = emitter.indents[:len(emitter.indents)-1] - emitter.state = emitter.states[len(emitter.states)-1] - emitter.states = emitter.states[:len(emitter.states)-1] - return true - } - if !yaml_emitter_write_indent(emitter) { - return false - } - if yaml_emitter_check_simple_key(emitter) { - emitter.states = append(emitter.states, yaml_EMIT_BLOCK_MAPPING_SIMPLE_VALUE_STATE) - return yaml_emitter_emit_node(emitter, event, false, false, true, true) - } - if !yaml_emitter_write_indicator(emitter, []byte{'?'}, true, false, true) { - return false - } - emitter.states = append(emitter.states, yaml_EMIT_BLOCK_MAPPING_VALUE_STATE) - return yaml_emitter_emit_node(emitter, event, false, false, true, false) -} - -// Expect a block value node. -func yaml_emitter_emit_block_mapping_value(emitter *yaml_emitter_t, event *yaml_event_t, simple bool) bool { - if simple { - if !yaml_emitter_write_indicator(emitter, []byte{':'}, false, false, false) { - return false - } - } else { - if !yaml_emitter_write_indent(emitter) { - return false - } - if !yaml_emitter_write_indicator(emitter, []byte{':'}, true, false, true) { - return false - } - } - emitter.states = append(emitter.states, yaml_EMIT_BLOCK_MAPPING_KEY_STATE) - return yaml_emitter_emit_node(emitter, event, false, false, true, false) -} - -// Expect a node. -func yaml_emitter_emit_node(emitter *yaml_emitter_t, event *yaml_event_t, - root bool, sequence bool, mapping bool, simple_key bool) bool { - - emitter.root_context = root - emitter.sequence_context = sequence - emitter.mapping_context = mapping - emitter.simple_key_context = simple_key - - switch event.typ { - case yaml_ALIAS_EVENT: - return yaml_emitter_emit_alias(emitter, event) - case yaml_SCALAR_EVENT: - return yaml_emitter_emit_scalar(emitter, event) - case yaml_SEQUENCE_START_EVENT: - return yaml_emitter_emit_sequence_start(emitter, event) - case yaml_MAPPING_START_EVENT: - return yaml_emitter_emit_mapping_start(emitter, event) - default: - return yaml_emitter_set_emitter_error(emitter, - "expected SCALAR, SEQUENCE-START, MAPPING-START, or ALIAS") - } - return false -} - -// Expect ALIAS. -func yaml_emitter_emit_alias(emitter *yaml_emitter_t, event *yaml_event_t) bool { - if !yaml_emitter_process_anchor(emitter) { - return false - } - emitter.state = emitter.states[len(emitter.states)-1] - emitter.states = emitter.states[:len(emitter.states)-1] - return true -} - -// Expect SCALAR. -func yaml_emitter_emit_scalar(emitter *yaml_emitter_t, event *yaml_event_t) bool { - if !yaml_emitter_select_scalar_style(emitter, event) { - return false - } - if !yaml_emitter_process_anchor(emitter) { - return false - } - if !yaml_emitter_process_tag(emitter) { - return false - } - if !yaml_emitter_increase_indent(emitter, true, false) { - return false - } - if !yaml_emitter_process_scalar(emitter) { - return false - } - emitter.indent = emitter.indents[len(emitter.indents)-1] - emitter.indents = emitter.indents[:len(emitter.indents)-1] - emitter.state = emitter.states[len(emitter.states)-1] - emitter.states = emitter.states[:len(emitter.states)-1] - return true -} - -// Expect SEQUENCE-START. -func yaml_emitter_emit_sequence_start(emitter *yaml_emitter_t, event *yaml_event_t) bool { - if !yaml_emitter_process_anchor(emitter) { - return false - } - if !yaml_emitter_process_tag(emitter) { - return false - } - if emitter.flow_level > 0 || emitter.canonical || event.sequence_style() == yaml_FLOW_SEQUENCE_STYLE || - yaml_emitter_check_empty_sequence(emitter) { - emitter.state = yaml_EMIT_FLOW_SEQUENCE_FIRST_ITEM_STATE - } else { - emitter.state = yaml_EMIT_BLOCK_SEQUENCE_FIRST_ITEM_STATE - } - return true -} - -// Expect MAPPING-START. -func yaml_emitter_emit_mapping_start(emitter *yaml_emitter_t, event *yaml_event_t) bool { - if !yaml_emitter_process_anchor(emitter) { - return false - } - if !yaml_emitter_process_tag(emitter) { - return false - } - if emitter.flow_level > 0 || emitter.canonical || event.mapping_style() == yaml_FLOW_MAPPING_STYLE || - yaml_emitter_check_empty_mapping(emitter) { - emitter.state = yaml_EMIT_FLOW_MAPPING_FIRST_KEY_STATE - } else { - emitter.state = yaml_EMIT_BLOCK_MAPPING_FIRST_KEY_STATE - } - return true -} - -// Check if the document content is an empty scalar. -func yaml_emitter_check_empty_document(emitter *yaml_emitter_t) bool { - return false // [Go] Huh? -} - -// Check if the next events represent an empty sequence. -func yaml_emitter_check_empty_sequence(emitter *yaml_emitter_t) bool { - if len(emitter.events)-emitter.events_head < 2 { - return false - } - return emitter.events[emitter.events_head].typ == yaml_SEQUENCE_START_EVENT && - emitter.events[emitter.events_head+1].typ == yaml_SEQUENCE_END_EVENT -} - -// Check if the next events represent an empty mapping. -func yaml_emitter_check_empty_mapping(emitter *yaml_emitter_t) bool { - if len(emitter.events)-emitter.events_head < 2 { - return false - } - return emitter.events[emitter.events_head].typ == yaml_MAPPING_START_EVENT && - emitter.events[emitter.events_head+1].typ == yaml_MAPPING_END_EVENT -} - -// Check if the next node can be expressed as a simple key. -func yaml_emitter_check_simple_key(emitter *yaml_emitter_t) bool { - length := 0 - switch emitter.events[emitter.events_head].typ { - case yaml_ALIAS_EVENT: - length += len(emitter.anchor_data.anchor) - case yaml_SCALAR_EVENT: - if emitter.scalar_data.multiline { - return false - } - length += len(emitter.anchor_data.anchor) + - len(emitter.tag_data.handle) + - len(emitter.tag_data.suffix) + - len(emitter.scalar_data.value) - case yaml_SEQUENCE_START_EVENT: - if !yaml_emitter_check_empty_sequence(emitter) { - return false - } - length += len(emitter.anchor_data.anchor) + - len(emitter.tag_data.handle) + - len(emitter.tag_data.suffix) - case yaml_MAPPING_START_EVENT: - if !yaml_emitter_check_empty_mapping(emitter) { - return false - } - length += len(emitter.anchor_data.anchor) + - len(emitter.tag_data.handle) + - len(emitter.tag_data.suffix) - default: - return false - } - return length <= 128 -} - -// Determine an acceptable scalar style. -func yaml_emitter_select_scalar_style(emitter *yaml_emitter_t, event *yaml_event_t) bool { - - no_tag := len(emitter.tag_data.handle) == 0 && len(emitter.tag_data.suffix) == 0 - if no_tag && !event.implicit && !event.quoted_implicit { - return yaml_emitter_set_emitter_error(emitter, "neither tag nor implicit flags are specified") - } - - style := event.scalar_style() - if style == yaml_ANY_SCALAR_STYLE { - style = yaml_PLAIN_SCALAR_STYLE - } - if emitter.canonical { - style = yaml_DOUBLE_QUOTED_SCALAR_STYLE - } - if emitter.simple_key_context && emitter.scalar_data.multiline { - style = yaml_DOUBLE_QUOTED_SCALAR_STYLE - } - - if style == yaml_PLAIN_SCALAR_STYLE { - if emitter.flow_level > 0 && !emitter.scalar_data.flow_plain_allowed || - emitter.flow_level == 0 && !emitter.scalar_data.block_plain_allowed { - style = yaml_SINGLE_QUOTED_SCALAR_STYLE - } - if len(emitter.scalar_data.value) == 0 && (emitter.flow_level > 0 || emitter.simple_key_context) { - style = yaml_SINGLE_QUOTED_SCALAR_STYLE - } - if no_tag && !event.implicit { - style = yaml_SINGLE_QUOTED_SCALAR_STYLE - } - } - if style == yaml_SINGLE_QUOTED_SCALAR_STYLE { - if !emitter.scalar_data.single_quoted_allowed { - style = yaml_DOUBLE_QUOTED_SCALAR_STYLE - } - } - if style == yaml_LITERAL_SCALAR_STYLE || style == yaml_FOLDED_SCALAR_STYLE { - if !emitter.scalar_data.block_allowed || emitter.flow_level > 0 || emitter.simple_key_context { - style = yaml_DOUBLE_QUOTED_SCALAR_STYLE - } - } - - if no_tag && !event.quoted_implicit && style != yaml_PLAIN_SCALAR_STYLE { - emitter.tag_data.handle = []byte{'!'} - } - emitter.scalar_data.style = style - return true -} - -// Write an achor. -func yaml_emitter_process_anchor(emitter *yaml_emitter_t) bool { - if emitter.anchor_data.anchor == nil { - return true - } - c := []byte{'&'} - if emitter.anchor_data.alias { - c[0] = '*' - } - if !yaml_emitter_write_indicator(emitter, c, true, false, false) { - return false - } - return yaml_emitter_write_anchor(emitter, emitter.anchor_data.anchor) -} - -// Write a tag. -func yaml_emitter_process_tag(emitter *yaml_emitter_t) bool { - if len(emitter.tag_data.handle) == 0 && len(emitter.tag_data.suffix) == 0 { - return true - } - if len(emitter.tag_data.handle) > 0 { - if !yaml_emitter_write_tag_handle(emitter, emitter.tag_data.handle) { - return false - } - if len(emitter.tag_data.suffix) > 0 { - if !yaml_emitter_write_tag_content(emitter, emitter.tag_data.suffix, false) { - return false - } - } - } else { - // [Go] Allocate these slices elsewhere. - if !yaml_emitter_write_indicator(emitter, []byte("!<"), true, false, false) { - return false - } - if !yaml_emitter_write_tag_content(emitter, emitter.tag_data.suffix, false) { - return false - } - if !yaml_emitter_write_indicator(emitter, []byte{'>'}, false, false, false) { - return false - } - } - return true -} - -// Write a scalar. -func yaml_emitter_process_scalar(emitter *yaml_emitter_t) bool { - switch emitter.scalar_data.style { - case yaml_PLAIN_SCALAR_STYLE: - return yaml_emitter_write_plain_scalar(emitter, emitter.scalar_data.value, !emitter.simple_key_context) - - case yaml_SINGLE_QUOTED_SCALAR_STYLE: - return yaml_emitter_write_single_quoted_scalar(emitter, emitter.scalar_data.value, !emitter.simple_key_context) - - case yaml_DOUBLE_QUOTED_SCALAR_STYLE: - return yaml_emitter_write_double_quoted_scalar(emitter, emitter.scalar_data.value, !emitter.simple_key_context) - - case yaml_LITERAL_SCALAR_STYLE: - return yaml_emitter_write_literal_scalar(emitter, emitter.scalar_data.value) - - case yaml_FOLDED_SCALAR_STYLE: - return yaml_emitter_write_folded_scalar(emitter, emitter.scalar_data.value) - } - panic("unknown scalar style") -} - -// Check if a %YAML directive is valid. -func yaml_emitter_analyze_version_directive(emitter *yaml_emitter_t, version_directive *yaml_version_directive_t) bool { - if version_directive.major != 1 || version_directive.minor != 1 { - return yaml_emitter_set_emitter_error(emitter, "incompatible %YAML directive") - } - return true -} - -// Check if a %TAG directive is valid. -func yaml_emitter_analyze_tag_directive(emitter *yaml_emitter_t, tag_directive *yaml_tag_directive_t) bool { - handle := tag_directive.handle - prefix := tag_directive.prefix - if len(handle) == 0 { - return yaml_emitter_set_emitter_error(emitter, "tag handle must not be empty") - } - if handle[0] != '!' { - return yaml_emitter_set_emitter_error(emitter, "tag handle must start with '!'") - } - if handle[len(handle)-1] != '!' { - return yaml_emitter_set_emitter_error(emitter, "tag handle must end with '!'") - } - for i := 1; i < len(handle)-1; i += width(handle[i]) { - if !is_alpha(handle, i) { - return yaml_emitter_set_emitter_error(emitter, "tag handle must contain alphanumerical characters only") - } - } - if len(prefix) == 0 { - return yaml_emitter_set_emitter_error(emitter, "tag prefix must not be empty") - } - return true -} - -// Check if an anchor is valid. -func yaml_emitter_analyze_anchor(emitter *yaml_emitter_t, anchor []byte, alias bool) bool { - if len(anchor) == 0 { - problem := "anchor value must not be empty" - if alias { - problem = "alias value must not be empty" - } - return yaml_emitter_set_emitter_error(emitter, problem) - } - for i := 0; i < len(anchor); i += width(anchor[i]) { - if !is_alpha(anchor, i) { - problem := "anchor value must contain alphanumerical characters only" - if alias { - problem = "alias value must contain alphanumerical characters only" - } - return yaml_emitter_set_emitter_error(emitter, problem) - } - } - emitter.anchor_data.anchor = anchor - emitter.anchor_data.alias = alias - return true -} - -// Check if a tag is valid. -func yaml_emitter_analyze_tag(emitter *yaml_emitter_t, tag []byte) bool { - if len(tag) == 0 { - return yaml_emitter_set_emitter_error(emitter, "tag value must not be empty") - } - for i := 0; i < len(emitter.tag_directives); i++ { - tag_directive := &emitter.tag_directives[i] - if bytes.HasPrefix(tag, tag_directive.prefix) { - emitter.tag_data.handle = tag_directive.handle - emitter.tag_data.suffix = tag[len(tag_directive.prefix):] - return true - } - } - emitter.tag_data.suffix = tag - return true -} - -// Check if a scalar is valid. -func yaml_emitter_analyze_scalar(emitter *yaml_emitter_t, value []byte) bool { - var ( - block_indicators = false - flow_indicators = false - line_breaks = false - special_characters = false - - leading_space = false - leading_break = false - trailing_space = false - trailing_break = false - break_space = false - space_break = false - - preceeded_by_whitespace = false - followed_by_whitespace = false - previous_space = false - previous_break = false - ) - - emitter.scalar_data.value = value - - if len(value) == 0 { - emitter.scalar_data.multiline = false - emitter.scalar_data.flow_plain_allowed = false - emitter.scalar_data.block_plain_allowed = true - emitter.scalar_data.single_quoted_allowed = true - emitter.scalar_data.block_allowed = false - return true - } - - if len(value) >= 3 && ((value[0] == '-' && value[1] == '-' && value[2] == '-') || (value[0] == '.' && value[1] == '.' && value[2] == '.')) { - block_indicators = true - flow_indicators = true - } - - preceeded_by_whitespace = true - for i, w := 0, 0; i < len(value); i += w { - w = width(value[0]) - followed_by_whitespace = i+w >= len(value) || is_blank(value, i+w) - - if i == 0 { - switch value[i] { - case '#', ',', '[', ']', '{', '}', '&', '*', '!', '|', '>', '\'', '"', '%', '@', '`': - flow_indicators = true - block_indicators = true - case '?', ':': - flow_indicators = true - if followed_by_whitespace { - block_indicators = true - } - case '-': - if followed_by_whitespace { - flow_indicators = true - block_indicators = true - } - } - } else { - switch value[i] { - case ',', '?', '[', ']', '{', '}': - flow_indicators = true - case ':': - flow_indicators = true - if followed_by_whitespace { - block_indicators = true - } - case '#': - if preceeded_by_whitespace { - flow_indicators = true - block_indicators = true - } - } - } - - if !is_printable(value, i) || !is_ascii(value, i) && !emitter.unicode { - special_characters = true - } - if is_space(value, i) { - if i == 0 { - leading_space = true - } - if i+width(value[i]) == len(value) { - trailing_space = true - } - if previous_break { - break_space = true - } - previous_space = true - previous_break = false - } else if is_break(value, i) { - line_breaks = true - if i == 0 { - leading_break = true - } - if i+width(value[i]) == len(value) { - trailing_break = true - } - if previous_space { - space_break = true - } - previous_space = false - previous_break = true - } else { - previous_space = false - previous_break = false - } - - // [Go]: Why 'z'? Couldn't be the end of the string as that's the loop condition. - preceeded_by_whitespace = is_blankz(value, i) - } - - emitter.scalar_data.multiline = line_breaks - emitter.scalar_data.flow_plain_allowed = true - emitter.scalar_data.block_plain_allowed = true - emitter.scalar_data.single_quoted_allowed = true - emitter.scalar_data.block_allowed = true - - if leading_space || leading_break || trailing_space || trailing_break { - emitter.scalar_data.flow_plain_allowed = false - emitter.scalar_data.block_plain_allowed = false - } - if trailing_space { - emitter.scalar_data.block_allowed = false - } - if break_space { - emitter.scalar_data.flow_plain_allowed = false - emitter.scalar_data.block_plain_allowed = false - emitter.scalar_data.single_quoted_allowed = false - } - if space_break || special_characters { - emitter.scalar_data.flow_plain_allowed = false - emitter.scalar_data.block_plain_allowed = false - emitter.scalar_data.single_quoted_allowed = false - emitter.scalar_data.block_allowed = false - } - if line_breaks { - emitter.scalar_data.flow_plain_allowed = false - emitter.scalar_data.block_plain_allowed = false - } - if flow_indicators { - emitter.scalar_data.flow_plain_allowed = false - } - if block_indicators { - emitter.scalar_data.block_plain_allowed = false - } - return true -} - -// Check if the event data is valid. -func yaml_emitter_analyze_event(emitter *yaml_emitter_t, event *yaml_event_t) bool { - - emitter.anchor_data.anchor = nil - emitter.tag_data.handle = nil - emitter.tag_data.suffix = nil - emitter.scalar_data.value = nil - - switch event.typ { - case yaml_ALIAS_EVENT: - if !yaml_emitter_analyze_anchor(emitter, event.anchor, true) { - return false - } - - case yaml_SCALAR_EVENT: - if len(event.anchor) > 0 { - if !yaml_emitter_analyze_anchor(emitter, event.anchor, false) { - return false - } - } - if len(event.tag) > 0 && (emitter.canonical || (!event.implicit && !event.quoted_implicit)) { - if !yaml_emitter_analyze_tag(emitter, event.tag) { - return false - } - } - if !yaml_emitter_analyze_scalar(emitter, event.value) { - return false - } - - case yaml_SEQUENCE_START_EVENT: - if len(event.anchor) > 0 { - if !yaml_emitter_analyze_anchor(emitter, event.anchor, false) { - return false - } - } - if len(event.tag) > 0 && (emitter.canonical || !event.implicit) { - if !yaml_emitter_analyze_tag(emitter, event.tag) { - return false - } - } - - case yaml_MAPPING_START_EVENT: - if len(event.anchor) > 0 { - if !yaml_emitter_analyze_anchor(emitter, event.anchor, false) { - return false - } - } - if len(event.tag) > 0 && (emitter.canonical || !event.implicit) { - if !yaml_emitter_analyze_tag(emitter, event.tag) { - return false - } - } - } - return true -} - -// Write the BOM character. -func yaml_emitter_write_bom(emitter *yaml_emitter_t) bool { - if !flush(emitter) { - return false - } - pos := emitter.buffer_pos - emitter.buffer[pos+0] = '\xEF' - emitter.buffer[pos+1] = '\xBB' - emitter.buffer[pos+2] = '\xBF' - emitter.buffer_pos += 3 - return true -} - -func yaml_emitter_write_indent(emitter *yaml_emitter_t) bool { - indent := emitter.indent - if indent < 0 { - indent = 0 - } - if !emitter.indention || emitter.column > indent || (emitter.column == indent && !emitter.whitespace) { - if !put_break(emitter) { - return false - } - } - for emitter.column < indent { - if !put(emitter, ' ') { - return false - } - } - emitter.whitespace = true - emitter.indention = true - return true -} - -func yaml_emitter_write_indicator(emitter *yaml_emitter_t, indicator []byte, need_whitespace, is_whitespace, is_indention bool) bool { - if need_whitespace && !emitter.whitespace { - if !put(emitter, ' ') { - return false - } - } - if !write_all(emitter, indicator) { - return false - } - emitter.whitespace = is_whitespace - emitter.indention = (emitter.indention && is_indention) - emitter.open_ended = false - return true -} - -func yaml_emitter_write_anchor(emitter *yaml_emitter_t, value []byte) bool { - if !write_all(emitter, value) { - return false - } - emitter.whitespace = false - emitter.indention = false - return true -} - -func yaml_emitter_write_tag_handle(emitter *yaml_emitter_t, value []byte) bool { - if !emitter.whitespace { - if !put(emitter, ' ') { - return false - } - } - if !write_all(emitter, value) { - return false - } - emitter.whitespace = false - emitter.indention = false - return true -} - -func yaml_emitter_write_tag_content(emitter *yaml_emitter_t, value []byte, need_whitespace bool) bool { - if need_whitespace && !emitter.whitespace { - if !put(emitter, ' ') { - return false - } - } - for i := 0; i < len(value); { - var must_write bool - switch value[i] { - case ';', '/', '?', ':', '@', '&', '=', '+', '$', ',', '_', '.', '~', '*', '\'', '(', ')', '[', ']': - must_write = true - default: - must_write = is_alpha(value, i) - } - if must_write { - if !write(emitter, value, &i) { - return false - } - } else { - w := width(value[i]) - for k := 0; k < w; k++ { - octet := value[i] - i++ - if !put(emitter, '%') { - return false - } - - c := octet >> 4 - if c < 10 { - c += '0' - } else { - c += 'A' - 10 - } - if !put(emitter, c) { - return false - } - - c = octet & 0x0f - if c < 10 { - c += '0' - } else { - c += 'A' - 10 - } - if !put(emitter, c) { - return false - } - } - } - } - emitter.whitespace = false - emitter.indention = false - return true -} - -func yaml_emitter_write_plain_scalar(emitter *yaml_emitter_t, value []byte, allow_breaks bool) bool { - if !emitter.whitespace { - if !put(emitter, ' ') { - return false - } - } - - spaces := false - breaks := false - for i := 0; i < len(value); { - if is_space(value, i) { - if allow_breaks && !spaces && emitter.column > emitter.best_width && !is_space(value, i+1) { - if !yaml_emitter_write_indent(emitter) { - return false - } - i += width(value[i]) - } else { - if !write(emitter, value, &i) { - return false - } - } - spaces = true - } else if is_break(value, i) { - if !breaks && value[i] == '\n' { - if !put_break(emitter) { - return false - } - } - if !write_break(emitter, value, &i) { - return false - } - emitter.indention = true - breaks = true - } else { - if breaks { - if !yaml_emitter_write_indent(emitter) { - return false - } - } - if !write(emitter, value, &i) { - return false - } - emitter.indention = false - spaces = false - breaks = false - } - } - - emitter.whitespace = false - emitter.indention = false - if emitter.root_context { - emitter.open_ended = true - } - - return true -} - -func yaml_emitter_write_single_quoted_scalar(emitter *yaml_emitter_t, value []byte, allow_breaks bool) bool { - - if !yaml_emitter_write_indicator(emitter, []byte{'\''}, true, false, false) { - return false - } - - spaces := false - breaks := false - for i := 0; i < len(value); { - if is_space(value, i) { - if allow_breaks && !spaces && emitter.column > emitter.best_width && i > 0 && i < len(value)-1 && !is_space(value, i+1) { - if !yaml_emitter_write_indent(emitter) { - return false - } - i += width(value[i]) - } else { - if !write(emitter, value, &i) { - return false - } - } - spaces = true - } else if is_break(value, i) { - if !breaks && value[i] == '\n' { - if !put_break(emitter) { - return false - } - } - if !write_break(emitter, value, &i) { - return false - } - emitter.indention = true - breaks = true - } else { - if breaks { - if !yaml_emitter_write_indent(emitter) { - return false - } - } - if value[i] == '\'' { - if !put(emitter, '\'') { - return false - } - } - if !write(emitter, value, &i) { - return false - } - emitter.indention = false - spaces = false - breaks = false - } - } - if !yaml_emitter_write_indicator(emitter, []byte{'\''}, false, false, false) { - return false - } - emitter.whitespace = false - emitter.indention = false - return true -} - -func yaml_emitter_write_double_quoted_scalar(emitter *yaml_emitter_t, value []byte, allow_breaks bool) bool { - spaces := false - if !yaml_emitter_write_indicator(emitter, []byte{'"'}, true, false, false) { - return false - } - - for i := 0; i < len(value); { - if !is_printable(value, i) || (!emitter.unicode && !is_ascii(value, i)) || - is_bom(value, i) || is_break(value, i) || - value[i] == '"' || value[i] == '\\' { - - octet := value[i] - - var w int - var v rune - switch { - case octet&0x80 == 0x00: - w, v = 1, rune(octet&0x7F) - case octet&0xE0 == 0xC0: - w, v = 2, rune(octet&0x1F) - case octet&0xF0 == 0xE0: - w, v = 3, rune(octet&0x0F) - case octet&0xF8 == 0xF0: - w, v = 4, rune(octet&0x07) - } - for k := 1; k < w; k++ { - octet = value[i+k] - v = (v << 6) + (rune(octet) & 0x3F) - } - i += w - - if !put(emitter, '\\') { - return false - } - - var ok bool - switch v { - case 0x00: - ok = put(emitter, '0') - case 0x07: - ok = put(emitter, 'a') - case 0x08: - ok = put(emitter, 'b') - case 0x09: - ok = put(emitter, 't') - case 0x0A: - ok = put(emitter, 'n') - case 0x0b: - ok = put(emitter, 'v') - case 0x0c: - ok = put(emitter, 'f') - case 0x0d: - ok = put(emitter, 'r') - case 0x1b: - ok = put(emitter, 'e') - case 0x22: - ok = put(emitter, '"') - case 0x5c: - ok = put(emitter, '\\') - case 0x85: - ok = put(emitter, 'N') - case 0xA0: - ok = put(emitter, '_') - case 0x2028: - ok = put(emitter, 'L') - case 0x2029: - ok = put(emitter, 'P') - default: - if v <= 0xFF { - ok = put(emitter, 'x') - w = 2 - } else if v <= 0xFFFF { - ok = put(emitter, 'u') - w = 4 - } else { - ok = put(emitter, 'U') - w = 8 - } - for k := (w - 1) * 4; ok && k >= 0; k -= 4 { - digit := byte((v >> uint(k)) & 0x0F) - if digit < 10 { - ok = put(emitter, digit+'0') - } else { - ok = put(emitter, digit+'A'-10) - } - } - } - if !ok { - return false - } - spaces = false - } else if is_space(value, i) { - if allow_breaks && !spaces && emitter.column > emitter.best_width && i > 0 && i < len(value)-1 { - if !yaml_emitter_write_indent(emitter) { - return false - } - if is_space(value, i+1) { - if !put(emitter, '\\') { - return false - } - } - i += width(value[i]) - } else if !write(emitter, value, &i) { - return false - } - spaces = true - } else { - if !write(emitter, value, &i) { - return false - } - spaces = false - } - } - if !yaml_emitter_write_indicator(emitter, []byte{'"'}, false, false, false) { - return false - } - emitter.whitespace = false - emitter.indention = false - return true -} - -func yaml_emitter_write_block_scalar_hints(emitter *yaml_emitter_t, value []byte) bool { - if is_space(value, 0) || is_break(value, 0) { - indent_hint := []byte{'0' + byte(emitter.best_indent)} - if !yaml_emitter_write_indicator(emitter, indent_hint, false, false, false) { - return false - } - } - - emitter.open_ended = false - - var chomp_hint [1]byte - if len(value) == 0 { - chomp_hint[0] = '-' - } else { - i := len(value) - 1 - for value[i]&0xC0 == 0x80 { - i-- - } - if !is_break(value, i) { - chomp_hint[0] = '-' - } else if i == 0 { - chomp_hint[0] = '+' - emitter.open_ended = true - } else { - i-- - for value[i]&0xC0 == 0x80 { - i-- - } - if is_break(value, i) { - chomp_hint[0] = '+' - emitter.open_ended = true - } - } - } - if chomp_hint[0] != 0 { - if !yaml_emitter_write_indicator(emitter, chomp_hint[:], false, false, false) { - return false - } - } - return true -} - -func yaml_emitter_write_literal_scalar(emitter *yaml_emitter_t, value []byte) bool { - if !yaml_emitter_write_indicator(emitter, []byte{'|'}, true, false, false) { - return false - } - if !yaml_emitter_write_block_scalar_hints(emitter, value) { - return false - } - if !put_break(emitter) { - return false - } - emitter.indention = true - emitter.whitespace = true - breaks := true - for i := 0; i < len(value); { - if is_break(value, i) { - if !write_break(emitter, value, &i) { - return false - } - emitter.indention = true - breaks = true - } else { - if breaks { - if !yaml_emitter_write_indent(emitter) { - return false - } - } - if !write(emitter, value, &i) { - return false - } - emitter.indention = false - breaks = false - } - } - - return true -} - -func yaml_emitter_write_folded_scalar(emitter *yaml_emitter_t, value []byte) bool { - if !yaml_emitter_write_indicator(emitter, []byte{'>'}, true, false, false) { - return false - } - if !yaml_emitter_write_block_scalar_hints(emitter, value) { - return false - } - - if !put_break(emitter) { - return false - } - emitter.indention = true - emitter.whitespace = true - - breaks := true - leading_spaces := true - for i := 0; i < len(value); { - if is_break(value, i) { - if !breaks && !leading_spaces && value[i] == '\n' { - k := 0 - for is_break(value, k) { - k += width(value[k]) - } - if !is_blankz(value, k) { - if !put_break(emitter) { - return false - } - } - } - if !write_break(emitter, value, &i) { - return false - } - emitter.indention = true - breaks = true - } else { - if breaks { - if !yaml_emitter_write_indent(emitter) { - return false - } - leading_spaces = is_blank(value, i) - } - if !breaks && is_space(value, i) && !is_space(value, i+1) && emitter.column > emitter.best_width { - if !yaml_emitter_write_indent(emitter) { - return false - } - i += width(value[i]) - } else { - if !write(emitter, value, &i) { - return false - } - } - emitter.indention = false - breaks = false - } - } - return true -} diff --git a/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/coreos/yaml/encode.go b/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/coreos/yaml/encode.go deleted file mode 100644 index 0b9048d7..00000000 --- a/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/coreos/yaml/encode.go +++ /dev/null @@ -1,265 +0,0 @@ -package yaml - -import ( - "reflect" - "regexp" - "sort" - "strconv" - "strings" - "time" -) - -type encoder struct { - emitter yaml_emitter_t - event yaml_event_t - out []byte - flow bool -} - -func newEncoder() (e *encoder) { - e = &encoder{} - e.must(yaml_emitter_initialize(&e.emitter)) - yaml_emitter_set_output_string(&e.emitter, &e.out) - e.must(yaml_stream_start_event_initialize(&e.event, yaml_UTF8_ENCODING)) - e.emit() - e.must(yaml_document_start_event_initialize(&e.event, nil, nil, true)) - e.emit() - return e -} - -func (e *encoder) finish() { - e.must(yaml_document_end_event_initialize(&e.event, true)) - e.emit() - e.emitter.open_ended = false - e.must(yaml_stream_end_event_initialize(&e.event)) - e.emit() -} - -func (e *encoder) destroy() { - yaml_emitter_delete(&e.emitter) -} - -func (e *encoder) emit() { - // This will internally delete the e.event value. - if !yaml_emitter_emit(&e.emitter, &e.event) && e.event.typ != yaml_DOCUMENT_END_EVENT && e.event.typ != yaml_STREAM_END_EVENT { - e.must(false) - } -} - -func (e *encoder) must(ok bool) { - if !ok { - msg := e.emitter.problem - if msg == "" { - msg = "Unknown problem generating YAML content" - } - fail(msg) - } -} - -func (e *encoder) marshal(tag string, in reflect.Value) { - if !in.IsValid() { - e.nilv() - return - } - var value interface{} - if getter, ok := in.Interface().(Getter); ok { - tag, value = getter.GetYAML() - tag = longTag(tag) - if value == nil { - e.nilv() - return - } - in = reflect.ValueOf(value) - } - switch in.Kind() { - case reflect.Interface: - if in.IsNil() { - e.nilv() - } else { - e.marshal(tag, in.Elem()) - } - case reflect.Map: - e.mapv(tag, in) - case reflect.Ptr: - if in.IsNil() { - e.nilv() - } else { - e.marshal(tag, in.Elem()) - } - case reflect.Struct: - e.structv(tag, in) - case reflect.Slice: - e.slicev(tag, in) - case reflect.String: - e.stringv(tag, in) - case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: - if in.Type() == durationType { - e.stringv(tag, reflect.ValueOf(in.Interface().(time.Duration).String())) - } else { - e.intv(tag, in) - } - case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr: - e.uintv(tag, in) - case reflect.Float32, reflect.Float64: - e.floatv(tag, in) - case reflect.Bool: - e.boolv(tag, in) - default: - panic("Can't marshal type: " + in.Type().String()) - } -} - -func (e *encoder) mapv(tag string, in reflect.Value) { - e.mappingv(tag, func() { - keys := keyList(in.MapKeys()) - sort.Sort(keys) - for _, k := range keys { - e.marshal("", k) - e.marshal("", in.MapIndex(k)) - } - }) -} - -func (e *encoder) structv(tag string, in reflect.Value) { - sinfo, err := getStructInfo(in.Type()) - if err != nil { - panic(err) - } - e.mappingv(tag, func() { - for _, info := range sinfo.FieldsList { - var value reflect.Value - if info.Inline == nil { - value = in.Field(info.Num) - } else { - value = in.FieldByIndex(info.Inline) - } - if info.OmitEmpty && isZero(value) { - continue - } - e.marshal("", reflect.ValueOf(info.Key)) - e.flow = info.Flow - e.marshal("", value) - } - }) -} - -func (e *encoder) mappingv(tag string, f func()) { - implicit := tag == "" - style := yaml_BLOCK_MAPPING_STYLE - if e.flow { - e.flow = false - style = yaml_FLOW_MAPPING_STYLE - } - e.must(yaml_mapping_start_event_initialize(&e.event, nil, []byte(tag), implicit, style)) - e.emit() - f() - e.must(yaml_mapping_end_event_initialize(&e.event)) - e.emit() -} - -func (e *encoder) slicev(tag string, in reflect.Value) { - implicit := tag == "" - style := yaml_BLOCK_SEQUENCE_STYLE - if e.flow { - e.flow = false - style = yaml_FLOW_SEQUENCE_STYLE - } - e.must(yaml_sequence_start_event_initialize(&e.event, nil, []byte(tag), implicit, style)) - e.emit() - n := in.Len() - for i := 0; i < n; i++ { - e.marshal("", in.Index(i)) - } - e.must(yaml_sequence_end_event_initialize(&e.event)) - e.emit() -} - -// isBase60 returns whether s is in base 60 notation as defined in YAML 1.1. -// -// The base 60 float notation in YAML 1.1 is a terrible idea and is unsupported -// in YAML 1.2 and by this package, but these should be marshalled quoted for -// the time being for compatibility with other parsers. -func isBase60Float(s string) (result bool) { - // Fast path. - if s == "" { - return false - } - c := s[0] - if !(c == '+' || c == '-' || c >= '0' && c <= '9') || strings.IndexByte(s, ':') < 0 { - return false - } - // Do the full match. - return base60float.MatchString(s) -} - -// From http://yaml.org/type/float.html, except the regular expression there -// is bogus. In practice parsers do not enforce the "\.[0-9_]*" suffix. -var base60float = regexp.MustCompile(`^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+(?:\.[0-9_]*)?$`) - -func (e *encoder) stringv(tag string, in reflect.Value) { - var style yaml_scalar_style_t - s := in.String() - rtag, rs := resolve("", s) - if rtag == yaml_BINARY_TAG { - if tag == "" || tag == yaml_STR_TAG { - tag = rtag - s = rs.(string) - } else if tag == yaml_BINARY_TAG { - fail("explicitly tagged !!binary data must be base64-encoded") - } else { - fail("cannot marshal invalid UTF-8 data as " + shortTag(tag)) - } - } - if tag == "" && (rtag != yaml_STR_TAG || isBase60Float(s)) { - style = yaml_DOUBLE_QUOTED_SCALAR_STYLE - } else if strings.Contains(s, "\n") { - style = yaml_LITERAL_SCALAR_STYLE - } else { - style = yaml_PLAIN_SCALAR_STYLE - } - e.emitScalar(s, "", tag, style) -} - -func (e *encoder) boolv(tag string, in reflect.Value) { - var s string - if in.Bool() { - s = "true" - } else { - s = "false" - } - e.emitScalar(s, "", tag, yaml_PLAIN_SCALAR_STYLE) -} - -func (e *encoder) intv(tag string, in reflect.Value) { - s := strconv.FormatInt(in.Int(), 10) - e.emitScalar(s, "", tag, yaml_PLAIN_SCALAR_STYLE) -} - -func (e *encoder) uintv(tag string, in reflect.Value) { - s := strconv.FormatUint(in.Uint(), 10) - e.emitScalar(s, "", tag, yaml_PLAIN_SCALAR_STYLE) -} - -func (e *encoder) floatv(tag string, in reflect.Value) { - // FIXME: Handle 64 bits here. - s := strconv.FormatFloat(float64(in.Float()), 'g', -1, 32) - switch s { - case "+Inf": - s = ".inf" - case "-Inf": - s = "-.inf" - case "NaN": - s = ".nan" - } - e.emitScalar(s, "", tag, yaml_PLAIN_SCALAR_STYLE) -} - -func (e *encoder) nilv() { - e.emitScalar("null", "", "", yaml_PLAIN_SCALAR_STYLE) -} - -func (e *encoder) emitScalar(value, anchor, tag string, style yaml_scalar_style_t) { - implicit := tag == "" - e.must(yaml_scalar_event_initialize(&e.event, []byte(anchor), []byte(tag), []byte(value), implicit, implicit, style)) - e.emit() -} diff --git a/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/coreos/yaml/encode_test.go b/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/coreos/yaml/encode_test.go deleted file mode 100644 index 2cd0ea7f..00000000 --- a/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/coreos/yaml/encode_test.go +++ /dev/null @@ -1,433 +0,0 @@ -package yaml_test - -import ( - "fmt" - "math" - "strconv" - "strings" - "time" - - "github.com/coreos/yaml" - . "gopkg.in/check.v1" -) - -var marshalIntTest = 123 - -var marshalTests = []struct { - value interface{} - data string -}{ - { - nil, - "null\n", - }, { - &struct{}{}, - "{}\n", - }, { - map[string]string{"v": "hi"}, - "v: hi\n", - }, { - map[string]interface{}{"v": "hi"}, - "v: hi\n", - }, { - map[string]string{"v": "true"}, - "v: \"true\"\n", - }, { - map[string]string{"v": "false"}, - "v: \"false\"\n", - }, { - map[string]interface{}{"v": true}, - "v: true\n", - }, { - map[string]interface{}{"v": false}, - "v: false\n", - }, { - map[string]interface{}{"v": 10}, - "v: 10\n", - }, { - map[string]interface{}{"v": -10}, - "v: -10\n", - }, { - map[string]uint{"v": 42}, - "v: 42\n", - }, { - map[string]interface{}{"v": int64(4294967296)}, - "v: 4294967296\n", - }, { - map[string]int64{"v": int64(4294967296)}, - "v: 4294967296\n", - }, { - map[string]uint64{"v": 4294967296}, - "v: 4294967296\n", - }, { - map[string]interface{}{"v": "10"}, - "v: \"10\"\n", - }, { - map[string]interface{}{"v": 0.1}, - "v: 0.1\n", - }, { - map[string]interface{}{"v": float64(0.1)}, - "v: 0.1\n", - }, { - map[string]interface{}{"v": -0.1}, - "v: -0.1\n", - }, { - map[string]interface{}{"v": math.Inf(+1)}, - "v: .inf\n", - }, { - map[string]interface{}{"v": math.Inf(-1)}, - "v: -.inf\n", - }, { - map[string]interface{}{"v": math.NaN()}, - "v: .nan\n", - }, { - map[string]interface{}{"v": nil}, - "v: null\n", - }, { - map[string]interface{}{"v": ""}, - "v: \"\"\n", - }, { - map[string][]string{"v": []string{"A", "B"}}, - "v:\n- A\n- B\n", - }, { - map[string][]string{"v": []string{"A", "B\nC"}}, - "v:\n- A\n- |-\n B\n C\n", - }, { - map[string][]interface{}{"v": []interface{}{"A", 1, map[string][]int{"B": []int{2, 3}}}}, - "v:\n- A\n- 1\n- B:\n - 2\n - 3\n", - }, { - map[string]interface{}{"a": map[interface{}]interface{}{"b": "c"}}, - "a:\n b: c\n", - }, { - map[string]interface{}{"a": "-"}, - "a: '-'\n", - }, - - // Simple values. - { - &marshalIntTest, - "123\n", - }, - - // Structures - { - &struct{ Hello string }{"world"}, - "hello: world\n", - }, { - &struct { - A struct { - B string - } - }{struct{ B string }{"c"}}, - "a:\n b: c\n", - }, { - &struct { - A *struct { - B string - } - }{&struct{ B string }{"c"}}, - "a:\n b: c\n", - }, { - &struct { - A *struct { - B string - } - }{}, - "a: null\n", - }, { - &struct{ A int }{1}, - "a: 1\n", - }, { - &struct{ A []int }{[]int{1, 2}}, - "a:\n- 1\n- 2\n", - }, { - &struct { - B int "a" - }{1}, - "a: 1\n", - }, { - &struct{ A bool }{true}, - "a: true\n", - }, - - // Conditional flag - { - &struct { - A int "a,omitempty" - B int "b,omitempty" - }{1, 0}, - "a: 1\n", - }, { - &struct { - A int "a,omitempty" - B int "b,omitempty" - }{0, 0}, - "{}\n", - }, { - &struct { - A *struct{ X int } "a,omitempty" - B int "b,omitempty" - }{nil, 0}, - "{}\n", - }, - - // Flow flag - { - &struct { - A []int "a,flow" - }{[]int{1, 2}}, - "a: [1, 2]\n", - }, { - &struct { - A map[string]string "a,flow" - }{map[string]string{"b": "c", "d": "e"}}, - "a: {b: c, d: e}\n", - }, { - &struct { - A struct { - B, D string - } "a,flow" - }{struct{ B, D string }{"c", "e"}}, - "a: {b: c, d: e}\n", - }, - - // Unexported field - { - &struct { - u int - A int - }{0, 1}, - "a: 1\n", - }, - - // Ignored field - { - &struct { - A int - B int "-" - }{1, 2}, - "a: 1\n", - }, - - // Struct inlining - { - &struct { - A int - C inlineB `yaml:",inline"` - }{1, inlineB{2, inlineC{3}}}, - "a: 1\nb: 2\nc: 3\n", - }, - - // Duration - { - map[string]time.Duration{"a": 3 * time.Second}, - "a: 3s\n", - }, - - // Issue #24: bug in map merging logic. - { - map[string]string{"a": "<foo>"}, - "a: <foo>\n", - }, - - // Issue #34: marshal unsupported base 60 floats quoted for compatibility - // with old YAML 1.1 parsers. - { - map[string]string{"a": "1:1"}, - "a: \"1:1\"\n", - }, - - // Binary data. - { - map[string]string{"a": "\x00"}, - "a: \"\\0\"\n", - }, { - map[string]string{"a": "\x80\x81\x82"}, - "a: !!binary gIGC\n", - }, { - map[string]string{"a": strings.Repeat("\x90", 54)}, - "a: !!binary |\n " + strings.Repeat("kJCQ", 17) + "kJ\n CQ\n", - }, { - map[string]interface{}{"a": typeWithGetter{"!!str", "\x80\x81\x82"}}, - "a: !!binary gIGC\n", - }, - - // Escaping of tags. - { - map[string]interface{}{"a": typeWithGetter{"foo!bar", 1}}, - "a: !<foo%21bar> 1\n", - }, -} - -func (s *S) TestMarshal(c *C) { - for _, item := range marshalTests { - data, err := yaml.Marshal(item.value) - c.Assert(err, IsNil) - c.Assert(string(data), Equals, item.data) - } -} - -var marshalErrorTests = []struct { - value interface{} - error string - panic string -}{{ - value: &struct { - B int - inlineB ",inline" - }{1, inlineB{2, inlineC{3}}}, - panic: `Duplicated key 'b' in struct struct \{ B int; .*`, -}, { - value: typeWithGetter{"!!binary", "\x80"}, - error: "YAML error: explicitly tagged !!binary data must be base64-encoded", -}, { - value: typeWithGetter{"!!float", "\x80"}, - error: `YAML error: cannot marshal invalid UTF-8 data as !!float`, -}} - -func (s *S) TestMarshalErrors(c *C) { - for _, item := range marshalErrorTests { - if item.panic != "" { - c.Assert(func() { yaml.Marshal(item.value) }, PanicMatches, item.panic) - } else { - _, err := yaml.Marshal(item.value) - c.Assert(err, ErrorMatches, item.error) - } - } -} - -var marshalTaggedIfaceTest interface{} = &struct{ A string }{"B"} - -var getterTests = []struct { - data, tag string - value interface{} -}{ - {"_:\n hi: there\n", "", map[interface{}]interface{}{"hi": "there"}}, - {"_:\n- 1\n- A\n", "", []interface{}{1, "A"}}, - {"_: 10\n", "", 10}, - {"_: null\n", "", nil}, - {"_: !foo BAR!\n", "!foo", "BAR!"}, - {"_: !foo 1\n", "!foo", "1"}, - {"_: !foo '\"1\"'\n", "!foo", "\"1\""}, - {"_: !foo 1.1\n", "!foo", 1.1}, - {"_: !foo 1\n", "!foo", 1}, - {"_: !foo 1\n", "!foo", uint(1)}, - {"_: !foo true\n", "!foo", true}, - {"_: !foo\n- A\n- B\n", "!foo", []string{"A", "B"}}, - {"_: !foo\n A: B\n", "!foo", map[string]string{"A": "B"}}, - {"_: !foo\n a: B\n", "!foo", &marshalTaggedIfaceTest}, -} - -func (s *S) TestMarshalTypeCache(c *C) { - var data []byte - var err error - func() { - type T struct{ A int } - data, err = yaml.Marshal(&T{}) - c.Assert(err, IsNil) - }() - func() { - type T struct{ B int } - data, err = yaml.Marshal(&T{}) - c.Assert(err, IsNil) - }() - c.Assert(string(data), Equals, "b: 0\n") -} - -type typeWithGetter struct { - tag string - value interface{} -} - -func (o typeWithGetter) GetYAML() (tag string, value interface{}) { - return o.tag, o.value -} - -type typeWithGetterField struct { - Field typeWithGetter "_" -} - -func (s *S) TestMashalWithGetter(c *C) { - for _, item := range getterTests { - obj := &typeWithGetterField{} - obj.Field.tag = item.tag - obj.Field.value = item.value - data, err := yaml.Marshal(obj) - c.Assert(err, IsNil) - c.Assert(string(data), Equals, string(item.data)) - } -} - -func (s *S) TestUnmarshalWholeDocumentWithGetter(c *C) { - obj := &typeWithGetter{} - obj.tag = "" - obj.value = map[string]string{"hello": "world!"} - data, err := yaml.Marshal(obj) - c.Assert(err, IsNil) - c.Assert(string(data), Equals, "hello: world!\n") -} - -func (s *S) TestSortedOutput(c *C) { - order := []interface{}{ - false, - true, - 1, - uint(1), - 1.0, - 1.1, - 1.2, - 2, - uint(2), - 2.0, - 2.1, - "", - ".1", - ".2", - ".a", - "1", - "2", - "a!10", - "a/2", - "a/10", - "a~10", - "ab/1", - "b/1", - "b/01", - "b/2", - "b/02", - "b/3", - "b/03", - "b1", - "b01", - "b3", - "c2.10", - "c10.2", - "d1", - "d12", - "d12a", - } - m := make(map[interface{}]int) - for _, k := range order { - m[k] = 1 - } - data, err := yaml.Marshal(m) - c.Assert(err, IsNil) - out := "\n" + string(data) - last := 0 - for i, k := range order { - repr := fmt.Sprint(k) - if s, ok := k.(string); ok { - if _, err = strconv.ParseFloat(repr, 32); s == "" || err == nil { - repr = `"` + repr + `"` - } - } - index := strings.Index(out, "\n"+repr+":") - if index == -1 { - c.Fatalf("%#v is not in the output: %#v", k, out) - } - if index < last { - c.Fatalf("%#v was generated before %#v: %q", k, order[i-1], out) - } - last = index - } -} diff --git a/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/coreos/yaml/parserc.go b/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/coreos/yaml/parserc.go deleted file mode 100644 index 0a7037ad..00000000 --- a/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/coreos/yaml/parserc.go +++ /dev/null @@ -1,1096 +0,0 @@ -package yaml - -import ( - "bytes" -) - -// The parser implements the following grammar: -// -// stream ::= STREAM-START implicit_document? explicit_document* STREAM-END -// implicit_document ::= block_node DOCUMENT-END* -// explicit_document ::= DIRECTIVE* DOCUMENT-START block_node? DOCUMENT-END* -// block_node_or_indentless_sequence ::= -// ALIAS -// | properties (block_content | indentless_block_sequence)? -// | block_content -// | indentless_block_sequence -// block_node ::= ALIAS -// | properties block_content? -// | block_content -// flow_node ::= ALIAS -// | properties flow_content? -// | flow_content -// properties ::= TAG ANCHOR? | ANCHOR TAG? -// block_content ::= block_collection | flow_collection | SCALAR -// flow_content ::= flow_collection | SCALAR -// block_collection ::= block_sequence | block_mapping -// flow_collection ::= flow_sequence | flow_mapping -// block_sequence ::= BLOCK-SEQUENCE-START (BLOCK-ENTRY block_node?)* BLOCK-END -// indentless_sequence ::= (BLOCK-ENTRY block_node?)+ -// block_mapping ::= BLOCK-MAPPING_START -// ((KEY block_node_or_indentless_sequence?)? -// (VALUE block_node_or_indentless_sequence?)?)* -// BLOCK-END -// flow_sequence ::= FLOW-SEQUENCE-START -// (flow_sequence_entry FLOW-ENTRY)* -// flow_sequence_entry? -// FLOW-SEQUENCE-END -// flow_sequence_entry ::= flow_node | KEY flow_node? (VALUE flow_node?)? -// flow_mapping ::= FLOW-MAPPING-START -// (flow_mapping_entry FLOW-ENTRY)* -// flow_mapping_entry? -// FLOW-MAPPING-END -// flow_mapping_entry ::= flow_node | KEY flow_node? (VALUE flow_node?)? - -// Peek the next token in the token queue. -func peek_token(parser *yaml_parser_t) *yaml_token_t { - if parser.token_available || yaml_parser_fetch_more_tokens(parser) { - return &parser.tokens[parser.tokens_head] - } - return nil -} - -// Remove the next token from the queue (must be called after peek_token). -func skip_token(parser *yaml_parser_t) { - parser.token_available = false - parser.tokens_parsed++ - parser.stream_end_produced = parser.tokens[parser.tokens_head].typ == yaml_STREAM_END_TOKEN - parser.tokens_head++ -} - -// Get the next event. -func yaml_parser_parse(parser *yaml_parser_t, event *yaml_event_t) bool { - // Erase the event object. - *event = yaml_event_t{} - - // No events after the end of the stream or error. - if parser.stream_end_produced || parser.error != yaml_NO_ERROR || parser.state == yaml_PARSE_END_STATE { - return true - } - - // Generate the next event. - return yaml_parser_state_machine(parser, event) -} - -// Set parser error. -func yaml_parser_set_parser_error(parser *yaml_parser_t, problem string, problem_mark yaml_mark_t) bool { - parser.error = yaml_PARSER_ERROR - parser.problem = problem - parser.problem_mark = problem_mark - return false -} - -func yaml_parser_set_parser_error_context(parser *yaml_parser_t, context string, context_mark yaml_mark_t, problem string, problem_mark yaml_mark_t) bool { - parser.error = yaml_PARSER_ERROR - parser.context = context - parser.context_mark = context_mark - parser.problem = problem - parser.problem_mark = problem_mark - return false -} - -// State dispatcher. -func yaml_parser_state_machine(parser *yaml_parser_t, event *yaml_event_t) bool { - //trace("yaml_parser_state_machine", "state:", parser.state.String()) - - switch parser.state { - case yaml_PARSE_STREAM_START_STATE: - return yaml_parser_parse_stream_start(parser, event) - - case yaml_PARSE_IMPLICIT_DOCUMENT_START_STATE: - return yaml_parser_parse_document_start(parser, event, true) - - case yaml_PARSE_DOCUMENT_START_STATE: - return yaml_parser_parse_document_start(parser, event, false) - - case yaml_PARSE_DOCUMENT_CONTENT_STATE: - return yaml_parser_parse_document_content(parser, event) - - case yaml_PARSE_DOCUMENT_END_STATE: - return yaml_parser_parse_document_end(parser, event) - - case yaml_PARSE_BLOCK_NODE_STATE: - return yaml_parser_parse_node(parser, event, true, false) - - case yaml_PARSE_BLOCK_NODE_OR_INDENTLESS_SEQUENCE_STATE: - return yaml_parser_parse_node(parser, event, true, true) - - case yaml_PARSE_FLOW_NODE_STATE: - return yaml_parser_parse_node(parser, event, false, false) - - case yaml_PARSE_BLOCK_SEQUENCE_FIRST_ENTRY_STATE: - return yaml_parser_parse_block_sequence_entry(parser, event, true) - - case yaml_PARSE_BLOCK_SEQUENCE_ENTRY_STATE: - return yaml_parser_parse_block_sequence_entry(parser, event, false) - - case yaml_PARSE_INDENTLESS_SEQUENCE_ENTRY_STATE: - return yaml_parser_parse_indentless_sequence_entry(parser, event) - - case yaml_PARSE_BLOCK_MAPPING_FIRST_KEY_STATE: - return yaml_parser_parse_block_mapping_key(parser, event, true) - - case yaml_PARSE_BLOCK_MAPPING_KEY_STATE: - return yaml_parser_parse_block_mapping_key(parser, event, false) - - case yaml_PARSE_BLOCK_MAPPING_VALUE_STATE: - return yaml_parser_parse_block_mapping_value(parser, event) - - case yaml_PARSE_FLOW_SEQUENCE_FIRST_ENTRY_STATE: - return yaml_parser_parse_flow_sequence_entry(parser, event, true) - - case yaml_PARSE_FLOW_SEQUENCE_ENTRY_STATE: - return yaml_parser_parse_flow_sequence_entry(parser, event, false) - - case yaml_PARSE_FLOW_SEQUENCE_ENTRY_MAPPING_KEY_STATE: - return yaml_parser_parse_flow_sequence_entry_mapping_key(parser, event) - - case yaml_PARSE_FLOW_SEQUENCE_ENTRY_MAPPING_VALUE_STATE: - return yaml_parser_parse_flow_sequence_entry_mapping_value(parser, event) - - case yaml_PARSE_FLOW_SEQUENCE_ENTRY_MAPPING_END_STATE: - return yaml_parser_parse_flow_sequence_entry_mapping_end(parser, event) - - case yaml_PARSE_FLOW_MAPPING_FIRST_KEY_STATE: - return yaml_parser_parse_flow_mapping_key(parser, event, true) - - case yaml_PARSE_FLOW_MAPPING_KEY_STATE: - return yaml_parser_parse_flow_mapping_key(parser, event, false) - - case yaml_PARSE_FLOW_MAPPING_VALUE_STATE: - return yaml_parser_parse_flow_mapping_value(parser, event, false) - - case yaml_PARSE_FLOW_MAPPING_EMPTY_VALUE_STATE: - return yaml_parser_parse_flow_mapping_value(parser, event, true) - - default: - panic("invalid parser state") - } - return false -} - -// Parse the production: -// stream ::= STREAM-START implicit_document? explicit_document* STREAM-END -// ************ -func yaml_parser_parse_stream_start(parser *yaml_parser_t, event *yaml_event_t) bool { - token := peek_token(parser) - if token == nil { - return false - } - if token.typ != yaml_STREAM_START_TOKEN { - return yaml_parser_set_parser_error(parser, "did not find expected <stream-start>", token.start_mark) - } - parser.state = yaml_PARSE_IMPLICIT_DOCUMENT_START_STATE - *event = yaml_event_t{ - typ: yaml_STREAM_START_EVENT, - start_mark: token.start_mark, - end_mark: token.end_mark, - encoding: token.encoding, - } - skip_token(parser) - return true -} - -// Parse the productions: -// implicit_document ::= block_node DOCUMENT-END* -// * -// explicit_document ::= DIRECTIVE* DOCUMENT-START block_node? DOCUMENT-END* -// ************************* -func yaml_parser_parse_document_start(parser *yaml_parser_t, event *yaml_event_t, implicit bool) bool { - - token := peek_token(parser) - if token == nil { - return false - } - - // Parse extra document end indicators. - if !implicit { - for token.typ == yaml_DOCUMENT_END_TOKEN { - skip_token(parser) - token = peek_token(parser) - if token == nil { - return false - } - } - } - - if implicit && token.typ != yaml_VERSION_DIRECTIVE_TOKEN && - token.typ != yaml_TAG_DIRECTIVE_TOKEN && - token.typ != yaml_DOCUMENT_START_TOKEN && - token.typ != yaml_STREAM_END_TOKEN { - // Parse an implicit document. - if !yaml_parser_process_directives(parser, nil, nil) { - return false - } - parser.states = append(parser.states, yaml_PARSE_DOCUMENT_END_STATE) - parser.state = yaml_PARSE_BLOCK_NODE_STATE - - *event = yaml_event_t{ - typ: yaml_DOCUMENT_START_EVENT, - start_mark: token.start_mark, - end_mark: token.end_mark, - } - - } else if token.typ != yaml_STREAM_END_TOKEN { - // Parse an explicit document. - var version_directive *yaml_version_directive_t - var tag_directives []yaml_tag_directive_t - start_mark := token.start_mark - if !yaml_parser_process_directives(parser, &version_directive, &tag_directives) { - return false - } - token = peek_token(parser) - if token == nil { - return false - } - if token.typ != yaml_DOCUMENT_START_TOKEN { - yaml_parser_set_parser_error(parser, - "did not find expected <document start>", token.start_mark) - return false - } - parser.states = append(parser.states, yaml_PARSE_DOCUMENT_END_STATE) - parser.state = yaml_PARSE_DOCUMENT_CONTENT_STATE - end_mark := token.end_mark - - *event = yaml_event_t{ - typ: yaml_DOCUMENT_START_EVENT, - start_mark: start_mark, - end_mark: end_mark, - version_directive: version_directive, - tag_directives: tag_directives, - implicit: false, - } - skip_token(parser) - - } else { - // Parse the stream end. - parser.state = yaml_PARSE_END_STATE - *event = yaml_event_t{ - typ: yaml_STREAM_END_EVENT, - start_mark: token.start_mark, - end_mark: token.end_mark, - } - skip_token(parser) - } - - return true -} - -// Parse the productions: -// explicit_document ::= DIRECTIVE* DOCUMENT-START block_node? DOCUMENT-END* -// *********** -// -func yaml_parser_parse_document_content(parser *yaml_parser_t, event *yaml_event_t) bool { - token := peek_token(parser) - if token == nil { - return false - } - if token.typ == yaml_VERSION_DIRECTIVE_TOKEN || - token.typ == yaml_TAG_DIRECTIVE_TOKEN || - token.typ == yaml_DOCUMENT_START_TOKEN || - token.typ == yaml_DOCUMENT_END_TOKEN || - token.typ == yaml_STREAM_END_TOKEN { - parser.state = parser.states[len(parser.states)-1] - parser.states = parser.states[:len(parser.states)-1] - return yaml_parser_process_empty_scalar(parser, event, - token.start_mark) - } - return yaml_parser_parse_node(parser, event, true, false) -} - -// Parse the productions: -// implicit_document ::= block_node DOCUMENT-END* -// ************* -// explicit_document ::= DIRECTIVE* DOCUMENT-START block_node? DOCUMENT-END* -// -func yaml_parser_parse_document_end(parser *yaml_parser_t, event *yaml_event_t) bool { - token := peek_token(parser) - if token == nil { - return false - } - - start_mark := token.start_mark - end_mark := token.start_mark - - implicit := true - if token.typ == yaml_DOCUMENT_END_TOKEN { - end_mark = token.end_mark - skip_token(parser) - implicit = false - } - - parser.tag_directives = parser.tag_directives[:0] - - parser.state = yaml_PARSE_DOCUMENT_START_STATE - *event = yaml_event_t{ - typ: yaml_DOCUMENT_END_EVENT, - start_mark: start_mark, - end_mark: end_mark, - implicit: implicit, - } - return true -} - -// Parse the productions: -// block_node_or_indentless_sequence ::= -// ALIAS -// ***** -// | properties (block_content | indentless_block_sequence)? -// ********** * -// | block_content | indentless_block_sequence -// * -// block_node ::= ALIAS -// ***** -// | properties block_content? -// ********** * -// | block_content -// * -// flow_node ::= ALIAS -// ***** -// | properties flow_content? -// ********** * -// | flow_content -// * -// properties ::= TAG ANCHOR? | ANCHOR TAG? -// ************************* -// block_content ::= block_collection | flow_collection | SCALAR -// ****** -// flow_content ::= flow_collection | SCALAR -// ****** -func yaml_parser_parse_node(parser *yaml_parser_t, event *yaml_event_t, block, indentless_sequence bool) bool { - //defer trace("yaml_parser_parse_node", "block:", block, "indentless_sequence:", indentless_sequence)() - - token := peek_token(parser) - if token == nil { - return false - } - - if token.typ == yaml_ALIAS_TOKEN { - parser.state = parser.states[len(parser.states)-1] - parser.states = parser.states[:len(parser.states)-1] - *event = yaml_event_t{ - typ: yaml_ALIAS_EVENT, - start_mark: token.start_mark, - end_mark: token.end_mark, - anchor: token.value, - } - skip_token(parser) - return true - } - - start_mark := token.start_mark - end_mark := token.start_mark - - var tag_token bool - var tag_handle, tag_suffix, anchor []byte - var tag_mark yaml_mark_t - if token.typ == yaml_ANCHOR_TOKEN { - anchor = token.value - start_mark = token.start_mark - end_mark = token.end_mark - skip_token(parser) - token = peek_token(parser) - if token == nil { - return false - } - if token.typ == yaml_TAG_TOKEN { - tag_token = true - tag_handle = token.value - tag_suffix = token.suffix - tag_mark = token.start_mark - end_mark = token.end_mark - skip_token(parser) - token = peek_token(parser) - if token == nil { - return false - } - } - } else if token.typ == yaml_TAG_TOKEN { - tag_token = true - tag_handle = token.value - tag_suffix = token.suffix - start_mark = token.start_mark - tag_mark = token.start_mark - end_mark = token.end_mark - skip_token(parser) - token = peek_token(parser) - if token == nil { - return false - } - if token.typ == yaml_ANCHOR_TOKEN { - anchor = token.value - end_mark = token.end_mark - skip_token(parser) - token = peek_token(parser) - if token == nil { - return false - } - } - } - - var tag []byte - if tag_token { - if len(tag_handle) == 0 { - tag = tag_suffix - tag_suffix = nil - } else { - for i := range parser.tag_directives { - if bytes.Equal(parser.tag_directives[i].handle, tag_handle) { - tag = append([]byte(nil), parser.tag_directives[i].prefix...) - tag = append(tag, tag_suffix...) - break - } - } - if len(tag) == 0 { - yaml_parser_set_parser_error_context(parser, - "while parsing a node", start_mark, - "found undefined tag handle", tag_mark) - return false - } - } - } - - implicit := len(tag) == 0 - if indentless_sequence && token.typ == yaml_BLOCK_ENTRY_TOKEN { - end_mark = token.end_mark - parser.state = yaml_PARSE_INDENTLESS_SEQUENCE_ENTRY_STATE - *event = yaml_event_t{ - typ: yaml_SEQUENCE_START_EVENT, - start_mark: start_mark, - end_mark: end_mark, - anchor: anchor, - tag: tag, - implicit: implicit, - style: yaml_style_t(yaml_BLOCK_SEQUENCE_STYLE), - } - return true - } - if token.typ == yaml_SCALAR_TOKEN { - var plain_implicit, quoted_implicit bool - end_mark = token.end_mark - if (len(tag) == 0 && token.style == yaml_PLAIN_SCALAR_STYLE) || (len(tag) == 1 && tag[0] == '!') { - plain_implicit = true - } else if len(tag) == 0 { - quoted_implicit = true - } - parser.state = parser.states[len(parser.states)-1] - parser.states = parser.states[:len(parser.states)-1] - - *event = yaml_event_t{ - typ: yaml_SCALAR_EVENT, - start_mark: start_mark, - end_mark: end_mark, - anchor: anchor, - tag: tag, - value: token.value, - implicit: plain_implicit, - quoted_implicit: quoted_implicit, - style: yaml_style_t(token.style), - } - skip_token(parser) - return true - } - if token.typ == yaml_FLOW_SEQUENCE_START_TOKEN { - // [Go] Some of the events below can be merged as they differ only on style. - end_mark = token.end_mark - parser.state = yaml_PARSE_FLOW_SEQUENCE_FIRST_ENTRY_STATE - *event = yaml_event_t{ - typ: yaml_SEQUENCE_START_EVENT, - start_mark: start_mark, - end_mark: end_mark, - anchor: anchor, - tag: tag, - implicit: implicit, - style: yaml_style_t(yaml_FLOW_SEQUENCE_STYLE), - } - return true - } - if token.typ == yaml_FLOW_MAPPING_START_TOKEN { - end_mark = token.end_mark - parser.state = yaml_PARSE_FLOW_MAPPING_FIRST_KEY_STATE - *event = yaml_event_t{ - typ: yaml_MAPPING_START_EVENT, - start_mark: start_mark, - end_mark: end_mark, - anchor: anchor, - tag: tag, - implicit: implicit, - style: yaml_style_t(yaml_FLOW_MAPPING_STYLE), - } - return true - } - if block && token.typ == yaml_BLOCK_SEQUENCE_START_TOKEN { - end_mark = token.end_mark - parser.state = yaml_PARSE_BLOCK_SEQUENCE_FIRST_ENTRY_STATE - *event = yaml_event_t{ - typ: yaml_SEQUENCE_START_EVENT, - start_mark: start_mark, - end_mark: end_mark, - anchor: anchor, - tag: tag, - implicit: implicit, - style: yaml_style_t(yaml_BLOCK_SEQUENCE_STYLE), - } - return true - } - if block && token.typ == yaml_BLOCK_MAPPING_START_TOKEN { - end_mark = token.end_mark - parser.state = yaml_PARSE_BLOCK_MAPPING_FIRST_KEY_STATE - *event = yaml_event_t{ - typ: yaml_MAPPING_START_EVENT, - start_mark: start_mark, - end_mark: end_mark, - anchor: anchor, - tag: tag, - implicit: implicit, - style: yaml_style_t(yaml_BLOCK_MAPPING_STYLE), - } - return true - } - if len(anchor) > 0 || len(tag) > 0 { - parser.state = parser.states[len(parser.states)-1] - parser.states = parser.states[:len(parser.states)-1] - - *event = yaml_event_t{ - typ: yaml_SCALAR_EVENT, - start_mark: start_mark, - end_mark: end_mark, - anchor: anchor, - tag: tag, - implicit: implicit, - quoted_implicit: false, - style: yaml_style_t(yaml_PLAIN_SCALAR_STYLE), - } - return true - } - - context := "while parsing a flow node" - if block { - context = "while parsing a block node" - } - yaml_parser_set_parser_error_context(parser, context, start_mark, - "did not find expected node content", token.start_mark) - return false -} - -// Parse the productions: -// block_sequence ::= BLOCK-SEQUENCE-START (BLOCK-ENTRY block_node?)* BLOCK-END -// ******************** *********** * ********* -// -func yaml_parser_parse_block_sequence_entry(parser *yaml_parser_t, event *yaml_event_t, first bool) bool { - if first { - token := peek_token(parser) - parser.marks = append(parser.marks, token.start_mark) - skip_token(parser) - } - - token := peek_token(parser) - if token == nil { - return false - } - - if token.typ == yaml_BLOCK_ENTRY_TOKEN { - mark := token.end_mark - skip_token(parser) - token = peek_token(parser) - if token == nil { - return false - } - if token.typ != yaml_BLOCK_ENTRY_TOKEN && token.typ != yaml_BLOCK_END_TOKEN { - parser.states = append(parser.states, yaml_PARSE_BLOCK_SEQUENCE_ENTRY_STATE) - return yaml_parser_parse_node(parser, event, true, false) - } else { - parser.state = yaml_PARSE_BLOCK_SEQUENCE_ENTRY_STATE - return yaml_parser_process_empty_scalar(parser, event, mark) - } - } - if token.typ == yaml_BLOCK_END_TOKEN { - parser.state = parser.states[len(parser.states)-1] - parser.states = parser.states[:len(parser.states)-1] - parser.marks = parser.marks[:len(parser.marks)-1] - - *event = yaml_event_t{ - typ: yaml_SEQUENCE_END_EVENT, - start_mark: token.start_mark, - end_mark: token.end_mark, - } - - skip_token(parser) - return true - } - - context_mark := parser.marks[len(parser.marks)-1] - parser.marks = parser.marks[:len(parser.marks)-1] - return yaml_parser_set_parser_error_context(parser, - "while parsing a block collection", context_mark, - "did not find expected '-' indicator", token.start_mark) -} - -// Parse the productions: -// indentless_sequence ::= (BLOCK-ENTRY block_node?)+ -// *********** * -func yaml_parser_parse_indentless_sequence_entry(parser *yaml_parser_t, event *yaml_event_t) bool { - token := peek_token(parser) - if token == nil { - return false - } - - if token.typ == yaml_BLOCK_ENTRY_TOKEN { - mark := token.end_mark - skip_token(parser) - token = peek_token(parser) - if token == nil { - return false - } - if token.typ != yaml_BLOCK_ENTRY_TOKEN && - token.typ != yaml_KEY_TOKEN && - token.typ != yaml_VALUE_TOKEN && - token.typ != yaml_BLOCK_END_TOKEN { - parser.states = append(parser.states, yaml_PARSE_INDENTLESS_SEQUENCE_ENTRY_STATE) - return yaml_parser_parse_node(parser, event, true, false) - } - parser.state = yaml_PARSE_INDENTLESS_SEQUENCE_ENTRY_STATE - return yaml_parser_process_empty_scalar(parser, event, mark) - } - parser.state = parser.states[len(parser.states)-1] - parser.states = parser.states[:len(parser.states)-1] - - *event = yaml_event_t{ - typ: yaml_SEQUENCE_END_EVENT, - start_mark: token.start_mark, - end_mark: token.start_mark, // [Go] Shouldn't this be token.end_mark? - } - return true -} - -// Parse the productions: -// block_mapping ::= BLOCK-MAPPING_START -// ******************* -// ((KEY block_node_or_indentless_sequence?)? -// *** * -// (VALUE block_node_or_indentless_sequence?)?)* -// -// BLOCK-END -// ********* -// -func yaml_parser_parse_block_mapping_key(parser *yaml_parser_t, event *yaml_event_t, first bool) bool { - if first { - token := peek_token(parser) - parser.marks = append(parser.marks, token.start_mark) - skip_token(parser) - } - - token := peek_token(parser) - if token == nil { - return false - } - - if token.typ == yaml_KEY_TOKEN { - mark := token.end_mark - skip_token(parser) - token = peek_token(parser) - if token == nil { - return false - } - if token.typ != yaml_KEY_TOKEN && - token.typ != yaml_VALUE_TOKEN && - token.typ != yaml_BLOCK_END_TOKEN { - parser.states = append(parser.states, yaml_PARSE_BLOCK_MAPPING_VALUE_STATE) - return yaml_parser_parse_node(parser, event, true, true) - } else { - parser.state = yaml_PARSE_BLOCK_MAPPING_VALUE_STATE - return yaml_parser_process_empty_scalar(parser, event, mark) - } - } else if token.typ == yaml_BLOCK_END_TOKEN { - parser.state = parser.states[len(parser.states)-1] - parser.states = parser.states[:len(parser.states)-1] - parser.marks = parser.marks[:len(parser.marks)-1] - *event = yaml_event_t{ - typ: yaml_MAPPING_END_EVENT, - start_mark: token.start_mark, - end_mark: token.end_mark, - } - skip_token(parser) - return true - } - - context_mark := parser.marks[len(parser.marks)-1] - parser.marks = parser.marks[:len(parser.marks)-1] - return yaml_parser_set_parser_error_context(parser, - "while parsing a block mapping", context_mark, - "did not find expected key", token.start_mark) -} - -// Parse the productions: -// block_mapping ::= BLOCK-MAPPING_START -// -// ((KEY block_node_or_indentless_sequence?)? -// -// (VALUE block_node_or_indentless_sequence?)?)* -// ***** * -// BLOCK-END -// -// -func yaml_parser_parse_block_mapping_value(parser *yaml_parser_t, event *yaml_event_t) bool { - token := peek_token(parser) - if token == nil { - return false - } - if token.typ == yaml_VALUE_TOKEN { - mark := token.end_mark - skip_token(parser) - token = peek_token(parser) - if token == nil { - return false - } - if token.typ != yaml_KEY_TOKEN && - token.typ != yaml_VALUE_TOKEN && - token.typ != yaml_BLOCK_END_TOKEN { - parser.states = append(parser.states, yaml_PARSE_BLOCK_MAPPING_KEY_STATE) - return yaml_parser_parse_node(parser, event, true, true) - } - parser.state = yaml_PARSE_BLOCK_MAPPING_KEY_STATE - return yaml_parser_process_empty_scalar(parser, event, mark) - } - parser.state = yaml_PARSE_BLOCK_MAPPING_KEY_STATE - return yaml_parser_process_empty_scalar(parser, event, token.start_mark) -} - -// Parse the productions: -// flow_sequence ::= FLOW-SEQUENCE-START -// ******************* -// (flow_sequence_entry FLOW-ENTRY)* -// * ********** -// flow_sequence_entry? -// * -// FLOW-SEQUENCE-END -// ***************** -// flow_sequence_entry ::= flow_node | KEY flow_node? (VALUE flow_node?)? -// * -// -func yaml_parser_parse_flow_sequence_entry(parser *yaml_parser_t, event *yaml_event_t, first bool) bool { - if first { - token := peek_token(parser) - parser.marks = append(parser.marks, token.start_mark) - skip_token(parser) - } - token := peek_token(parser) - if token == nil { - return false - } - if token.typ != yaml_FLOW_SEQUENCE_END_TOKEN { - if !first { - if token.typ == yaml_FLOW_ENTRY_TOKEN { - skip_token(parser) - token = peek_token(parser) - if token == nil { - return false - } - } else { - context_mark := parser.marks[len(parser.marks)-1] - parser.marks = parser.marks[:len(parser.marks)-1] - return yaml_parser_set_parser_error_context(parser, - "while parsing a flow sequence", context_mark, - "did not find expected ',' or ']'", token.start_mark) - } - } - - if token.typ == yaml_KEY_TOKEN { - parser.state = yaml_PARSE_FLOW_SEQUENCE_ENTRY_MAPPING_KEY_STATE - *event = yaml_event_t{ - typ: yaml_MAPPING_START_EVENT, - start_mark: token.start_mark, - end_mark: token.end_mark, - implicit: true, - style: yaml_style_t(yaml_FLOW_MAPPING_STYLE), - } - skip_token(parser) - return true - } else if token.typ != yaml_FLOW_SEQUENCE_END_TOKEN { - parser.states = append(parser.states, yaml_PARSE_FLOW_SEQUENCE_ENTRY_STATE) - return yaml_parser_parse_node(parser, event, false, false) - } - } - - parser.state = parser.states[len(parser.states)-1] - parser.states = parser.states[:len(parser.states)-1] - parser.marks = parser.marks[:len(parser.marks)-1] - - *event = yaml_event_t{ - typ: yaml_SEQUENCE_END_EVENT, - start_mark: token.start_mark, - end_mark: token.end_mark, - } - - skip_token(parser) - return true -} - -// -// Parse the productions: -// flow_sequence_entry ::= flow_node | KEY flow_node? (VALUE flow_node?)? -// *** * -// -func yaml_parser_parse_flow_sequence_entry_mapping_key(parser *yaml_parser_t, event *yaml_event_t) bool { - token := peek_token(parser) - if token == nil { - return false - } - if token.typ != yaml_VALUE_TOKEN && - token.typ != yaml_FLOW_ENTRY_TOKEN && - token.typ != yaml_FLOW_SEQUENCE_END_TOKEN { - parser.states = append(parser.states, yaml_PARSE_FLOW_SEQUENCE_ENTRY_MAPPING_VALUE_STATE) - return yaml_parser_parse_node(parser, event, false, false) - } - mark := token.end_mark - skip_token(parser) - parser.state = yaml_PARSE_FLOW_SEQUENCE_ENTRY_MAPPING_VALUE_STATE - return yaml_parser_process_empty_scalar(parser, event, mark) -} - -// Parse the productions: -// flow_sequence_entry ::= flow_node | KEY flow_node? (VALUE flow_node?)? -// ***** * -// -func yaml_parser_parse_flow_sequence_entry_mapping_value(parser *yaml_parser_t, event *yaml_event_t) bool { - token := peek_token(parser) - if token == nil { - return false - } - if token.typ == yaml_VALUE_TOKEN { - skip_token(parser) - token := peek_token(parser) - if token == nil { - return false - } - if token.typ != yaml_FLOW_ENTRY_TOKEN && token.typ != yaml_FLOW_SEQUENCE_END_TOKEN { - parser.states = append(parser.states, yaml_PARSE_FLOW_SEQUENCE_ENTRY_MAPPING_END_STATE) - return yaml_parser_parse_node(parser, event, false, false) - } - } - parser.state = yaml_PARSE_FLOW_SEQUENCE_ENTRY_MAPPING_END_STATE - return yaml_parser_process_empty_scalar(parser, event, token.start_mark) -} - -// Parse the productions: -// flow_sequence_entry ::= flow_node | KEY flow_node? (VALUE flow_node?)? -// * -// -func yaml_parser_parse_flow_sequence_entry_mapping_end(parser *yaml_parser_t, event *yaml_event_t) bool { - token := peek_token(parser) - if token == nil { - return false - } - parser.state = yaml_PARSE_FLOW_SEQUENCE_ENTRY_STATE - *event = yaml_event_t{ - typ: yaml_MAPPING_END_EVENT, - start_mark: token.start_mark, - end_mark: token.start_mark, // [Go] Shouldn't this be end_mark? - } - return true -} - -// Parse the productions: -// flow_mapping ::= FLOW-MAPPING-START -// ****************** -// (flow_mapping_entry FLOW-ENTRY)* -// * ********** -// flow_mapping_entry? -// ****************** -// FLOW-MAPPING-END -// **************** -// flow_mapping_entry ::= flow_node | KEY flow_node? (VALUE flow_node?)? -// * *** * -// -func yaml_parser_parse_flow_mapping_key(parser *yaml_parser_t, event *yaml_event_t, first bool) bool { - if first { - token := peek_token(parser) - parser.marks = append(parser.marks, token.start_mark) - skip_token(parser) - } - - token := peek_token(parser) - if token == nil { - return false - } - - if token.typ != yaml_FLOW_MAPPING_END_TOKEN { - if !first { - if token.typ == yaml_FLOW_ENTRY_TOKEN { - skip_token(parser) - token = peek_token(parser) - if token == nil { - return false - } - } else { - context_mark := parser.marks[len(parser.marks)-1] - parser.marks = parser.marks[:len(parser.marks)-1] - return yaml_parser_set_parser_error_context(parser, - "while parsing a flow mapping", context_mark, - "did not find expected ',' or '}'", token.start_mark) - } - } - - if token.typ == yaml_KEY_TOKEN { - skip_token(parser) - token = peek_token(parser) - if token == nil { - return false - } - if token.typ != yaml_VALUE_TOKEN && - token.typ != yaml_FLOW_ENTRY_TOKEN && - token.typ != yaml_FLOW_MAPPING_END_TOKEN { - parser.states = append(parser.states, yaml_PARSE_FLOW_MAPPING_VALUE_STATE) - return yaml_parser_parse_node(parser, event, false, false) - } else { - parser.state = yaml_PARSE_FLOW_MAPPING_VALUE_STATE - return yaml_parser_process_empty_scalar(parser, event, token.start_mark) - } - } else if token.typ != yaml_FLOW_MAPPING_END_TOKEN { - parser.states = append(parser.states, yaml_PARSE_FLOW_MAPPING_EMPTY_VALUE_STATE) - return yaml_parser_parse_node(parser, event, false, false) - } - } - - parser.state = parser.states[len(parser.states)-1] - parser.states = parser.states[:len(parser.states)-1] - parser.marks = parser.marks[:len(parser.marks)-1] - *event = yaml_event_t{ - typ: yaml_MAPPING_END_EVENT, - start_mark: token.start_mark, - end_mark: token.end_mark, - } - skip_token(parser) - return true -} - -// Parse the productions: -// flow_mapping_entry ::= flow_node | KEY flow_node? (VALUE flow_node?)? -// * ***** * -// -func yaml_parser_parse_flow_mapping_value(parser *yaml_parser_t, event *yaml_event_t, empty bool) bool { - token := peek_token(parser) - if token == nil { - return false - } - if empty { - parser.state = yaml_PARSE_FLOW_MAPPING_KEY_STATE - return yaml_parser_process_empty_scalar(parser, event, token.start_mark) - } - if token.typ == yaml_VALUE_TOKEN { - skip_token(parser) - token = peek_token(parser) - if token == nil { - return false - } - if token.typ != yaml_FLOW_ENTRY_TOKEN && token.typ != yaml_FLOW_MAPPING_END_TOKEN { - parser.states = append(parser.states, yaml_PARSE_FLOW_MAPPING_KEY_STATE) - return yaml_parser_parse_node(parser, event, false, false) - } - } - parser.state = yaml_PARSE_FLOW_MAPPING_KEY_STATE - return yaml_parser_process_empty_scalar(parser, event, token.start_mark) -} - -// Generate an empty scalar event. -func yaml_parser_process_empty_scalar(parser *yaml_parser_t, event *yaml_event_t, mark yaml_mark_t) bool { - *event = yaml_event_t{ - typ: yaml_SCALAR_EVENT, - start_mark: mark, - end_mark: mark, - value: nil, // Empty - implicit: true, - style: yaml_style_t(yaml_PLAIN_SCALAR_STYLE), - } - return true -} - -var default_tag_directives = []yaml_tag_directive_t{ - {[]byte("!"), []byte("!")}, - {[]byte("!!"), []byte("tag:yaml.org,2002:")}, -} - -// Parse directives. -func yaml_parser_process_directives(parser *yaml_parser_t, - version_directive_ref **yaml_version_directive_t, - tag_directives_ref *[]yaml_tag_directive_t) bool { - - var version_directive *yaml_version_directive_t - var tag_directives []yaml_tag_directive_t - - token := peek_token(parser) - if token == nil { - return false - } - - for token.typ == yaml_VERSION_DIRECTIVE_TOKEN || token.typ == yaml_TAG_DIRECTIVE_TOKEN { - if token.typ == yaml_VERSION_DIRECTIVE_TOKEN { - if version_directive != nil { - yaml_parser_set_parser_error(parser, - "found duplicate %YAML directive", token.start_mark) - return false - } - if token.major != 1 || token.minor != 1 { - yaml_parser_set_parser_error(parser, - "found incompatible YAML document", token.start_mark) - return false - } - version_directive = &yaml_version_directive_t{ - major: token.major, - minor: token.minor, - } - } else if token.typ == yaml_TAG_DIRECTIVE_TOKEN { - value := yaml_tag_directive_t{ - handle: token.value, - prefix: token.prefix, - } - if !yaml_parser_append_tag_directive(parser, value, false, token.start_mark) { - return false - } - tag_directives = append(tag_directives, value) - } - - skip_token(parser) - token = peek_token(parser) - if token == nil { - return false - } - } - - for i := range default_tag_directives { - if !yaml_parser_append_tag_directive(parser, default_tag_directives[i], true, token.start_mark) { - return false - } - } - - if version_directive_ref != nil { - *version_directive_ref = version_directive - } - if tag_directives_ref != nil { - *tag_directives_ref = tag_directives - } - return true -} - -// Append a tag directive to the directives stack. -func yaml_parser_append_tag_directive(parser *yaml_parser_t, value yaml_tag_directive_t, allow_duplicates bool, mark yaml_mark_t) bool { - for i := range parser.tag_directives { - if bytes.Equal(value.handle, parser.tag_directives[i].handle) { - if allow_duplicates { - return true - } - return yaml_parser_set_parser_error(parser, "found duplicate %TAG directive", mark) - } - } - - // [Go] I suspect the copy is unnecessary. This was likely done - // because there was no way to track ownership of the data. - value_copy := yaml_tag_directive_t{ - handle: make([]byte, len(value.handle)), - prefix: make([]byte, len(value.prefix)), - } - copy(value_copy.handle, value.handle) - copy(value_copy.prefix, value.prefix) - parser.tag_directives = append(parser.tag_directives, value_copy) - return true -} diff --git a/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/coreos/yaml/readerc.go b/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/coreos/yaml/readerc.go deleted file mode 100644 index d5fb0972..00000000 --- a/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/coreos/yaml/readerc.go +++ /dev/null @@ -1,391 +0,0 @@ -package yaml - -import ( - "io" -) - -// Set the reader error and return 0. -func yaml_parser_set_reader_error(parser *yaml_parser_t, problem string, offset int, value int) bool { - parser.error = yaml_READER_ERROR - parser.problem = problem - parser.problem_offset = offset - parser.problem_value = value - return false -} - -// Byte order marks. -const ( - bom_UTF8 = "\xef\xbb\xbf" - bom_UTF16LE = "\xff\xfe" - bom_UTF16BE = "\xfe\xff" -) - -// Determine the input stream encoding by checking the BOM symbol. If no BOM is -// found, the UTF-8 encoding is assumed. Return 1 on success, 0 on failure. -func yaml_parser_determine_encoding(parser *yaml_parser_t) bool { - // Ensure that we had enough bytes in the raw buffer. - for !parser.eof && len(parser.raw_buffer)-parser.raw_buffer_pos < 3 { - if !yaml_parser_update_raw_buffer(parser) { - return false - } - } - - // Determine the encoding. - buf := parser.raw_buffer - pos := parser.raw_buffer_pos - avail := len(buf) - pos - if avail >= 2 && buf[pos] == bom_UTF16LE[0] && buf[pos+1] == bom_UTF16LE[1] { - parser.encoding = yaml_UTF16LE_ENCODING - parser.raw_buffer_pos += 2 - parser.offset += 2 - } else if avail >= 2 && buf[pos] == bom_UTF16BE[0] && buf[pos+1] == bom_UTF16BE[1] { - parser.encoding = yaml_UTF16BE_ENCODING - parser.raw_buffer_pos += 2 - parser.offset += 2 - } else if avail >= 3 && buf[pos] == bom_UTF8[0] && buf[pos+1] == bom_UTF8[1] && buf[pos+2] == bom_UTF8[2] { - parser.encoding = yaml_UTF8_ENCODING - parser.raw_buffer_pos += 3 - parser.offset += 3 - } else { - parser.encoding = yaml_UTF8_ENCODING - } - return true -} - -// Update the raw buffer. -func yaml_parser_update_raw_buffer(parser *yaml_parser_t) bool { - size_read := 0 - - // Return if the raw buffer is full. - if parser.raw_buffer_pos == 0 && len(parser.raw_buffer) == cap(parser.raw_buffer) { - return true - } - - // Return on EOF. - if parser.eof { - return true - } - - // Move the remaining bytes in the raw buffer to the beginning. - if parser.raw_buffer_pos > 0 && parser.raw_buffer_pos < len(parser.raw_buffer) { - copy(parser.raw_buffer, parser.raw_buffer[parser.raw_buffer_pos:]) - } - parser.raw_buffer = parser.raw_buffer[:len(parser.raw_buffer)-parser.raw_buffer_pos] - parser.raw_buffer_pos = 0 - - // Call the read handler to fill the buffer. - size_read, err := parser.read_handler(parser, parser.raw_buffer[len(parser.raw_buffer):cap(parser.raw_buffer)]) - parser.raw_buffer = parser.raw_buffer[:len(parser.raw_buffer)+size_read] - if err == io.EOF { - parser.eof = true - } else if err != nil { - return yaml_parser_set_reader_error(parser, "input error: "+err.Error(), parser.offset, -1) - } - return true -} - -// Ensure that the buffer contains at least `length` characters. -// Return true on success, false on failure. -// -// The length is supposed to be significantly less that the buffer size. -func yaml_parser_update_buffer(parser *yaml_parser_t, length int) bool { - if parser.read_handler == nil { - panic("read handler must be set") - } - - // If the EOF flag is set and the raw buffer is empty, do nothing. - if parser.eof && parser.raw_buffer_pos == len(parser.raw_buffer) { - return true - } - - // Return if the buffer contains enough characters. - if parser.unread >= length { - return true - } - - // Determine the input encoding if it is not known yet. - if parser.encoding == yaml_ANY_ENCODING { - if !yaml_parser_determine_encoding(parser) { - return false - } - } - - // Move the unread characters to the beginning of the buffer. - buffer_len := len(parser.buffer) - if parser.buffer_pos > 0 && parser.buffer_pos < buffer_len { - copy(parser.buffer, parser.buffer[parser.buffer_pos:]) - buffer_len -= parser.buffer_pos - parser.buffer_pos = 0 - } else if parser.buffer_pos == buffer_len { - buffer_len = 0 - parser.buffer_pos = 0 - } - - // Open the whole buffer for writing, and cut it before returning. - parser.buffer = parser.buffer[:cap(parser.buffer)] - - // Fill the buffer until it has enough characters. - first := true - for parser.unread < length { - - // Fill the raw buffer if necessary. - if !first || parser.raw_buffer_pos == len(parser.raw_buffer) { - if !yaml_parser_update_raw_buffer(parser) { - parser.buffer = parser.buffer[:buffer_len] - return false - } - } - first = false - - // Decode the raw buffer. - inner: - for parser.raw_buffer_pos != len(parser.raw_buffer) { - var value rune - var width int - - raw_unread := len(parser.raw_buffer) - parser.raw_buffer_pos - - // Decode the next character. - switch parser.encoding { - case yaml_UTF8_ENCODING: - // Decode a UTF-8 character. Check RFC 3629 - // (http://www.ietf.org/rfc/rfc3629.txt) for more details. - // - // The following table (taken from the RFC) is used for - // decoding. - // - // Char. number range | UTF-8 octet sequence - // (hexadecimal) | (binary) - // --------------------+------------------------------------ - // 0000 0000-0000 007F | 0xxxxxxx - // 0000 0080-0000 07FF | 110xxxxx 10xxxxxx - // 0000 0800-0000 FFFF | 1110xxxx 10xxxxxx 10xxxxxx - // 0001 0000-0010 FFFF | 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx - // - // Additionally, the characters in the range 0xD800-0xDFFF - // are prohibited as they are reserved for use with UTF-16 - // surrogate pairs. - - // Determine the length of the UTF-8 sequence. - octet := parser.raw_buffer[parser.raw_buffer_pos] - switch { - case octet&0x80 == 0x00: - width = 1 - case octet&0xE0 == 0xC0: - width = 2 - case octet&0xF0 == 0xE0: - width = 3 - case octet&0xF8 == 0xF0: - width = 4 - default: - // The leading octet is invalid. - return yaml_parser_set_reader_error(parser, - "invalid leading UTF-8 octet", - parser.offset, int(octet)) - } - - // Check if the raw buffer contains an incomplete character. - if width > raw_unread { - if parser.eof { - return yaml_parser_set_reader_error(parser, - "incomplete UTF-8 octet sequence", - parser.offset, -1) - } - break inner - } - - // Decode the leading octet. - switch { - case octet&0x80 == 0x00: - value = rune(octet & 0x7F) - case octet&0xE0 == 0xC0: - value = rune(octet & 0x1F) - case octet&0xF0 == 0xE0: - value = rune(octet & 0x0F) - case octet&0xF8 == 0xF0: - value = rune(octet & 0x07) - default: - value = 0 - } - - // Check and decode the trailing octets. - for k := 1; k < width; k++ { - octet = parser.raw_buffer[parser.raw_buffer_pos+k] - - // Check if the octet is valid. - if (octet & 0xC0) != 0x80 { - return yaml_parser_set_reader_error(parser, - "invalid trailing UTF-8 octet", - parser.offset+k, int(octet)) - } - - // Decode the octet. - value = (value << 6) + rune(octet&0x3F) - } - - // Check the length of the sequence against the value. - switch { - case width == 1: - case width == 2 && value >= 0x80: - case width == 3 && value >= 0x800: - case width == 4 && value >= 0x10000: - default: - return yaml_parser_set_reader_error(parser, - "invalid length of a UTF-8 sequence", - parser.offset, -1) - } - - // Check the range of the value. - if value >= 0xD800 && value <= 0xDFFF || value > 0x10FFFF { - return yaml_parser_set_reader_error(parser, - "invalid Unicode character", - parser.offset, int(value)) - } - - case yaml_UTF16LE_ENCODING, yaml_UTF16BE_ENCODING: - var low, high int - if parser.encoding == yaml_UTF16LE_ENCODING { - low, high = 0, 1 - } else { - high, low = 1, 0 - } - - // The UTF-16 encoding is not as simple as one might - // naively think. Check RFC 2781 - // (http://www.ietf.org/rfc/rfc2781.txt). - // - // Normally, two subsequent bytes describe a Unicode - // character. However a special technique (called a - // surrogate pair) is used for specifying character - // values larger than 0xFFFF. - // - // A surrogate pair consists of two pseudo-characters: - // high surrogate area (0xD800-0xDBFF) - // low surrogate area (0xDC00-0xDFFF) - // - // The following formulas are used for decoding - // and encoding characters using surrogate pairs: - // - // U = U' + 0x10000 (0x01 00 00 <= U <= 0x10 FF FF) - // U' = yyyyyyyyyyxxxxxxxxxx (0 <= U' <= 0x0F FF FF) - // W1 = 110110yyyyyyyyyy - // W2 = 110111xxxxxxxxxx - // - // where U is the character value, W1 is the high surrogate - // area, W2 is the low surrogate area. - - // Check for incomplete UTF-16 character. - if raw_unread < 2 { - if parser.eof { - return yaml_parser_set_reader_error(parser, - "incomplete UTF-16 character", - parser.offset, -1) - } - break inner - } - - // Get the character. - value = rune(parser.raw_buffer[parser.raw_buffer_pos+low]) + - (rune(parser.raw_buffer[parser.raw_buffer_pos+high]) << 8) - - // Check for unexpected low surrogate area. - if value&0xFC00 == 0xDC00 { - return yaml_parser_set_reader_error(parser, - "unexpected low surrogate area", - parser.offset, int(value)) - } - - // Check for a high surrogate area. - if value&0xFC00 == 0xD800 { - width = 4 - - // Check for incomplete surrogate pair. - if raw_unread < 4 { - if parser.eof { - return yaml_parser_set_reader_error(parser, - "incomplete UTF-16 surrogate pair", - parser.offset, -1) - } - break inner - } - - // Get the next character. - value2 := rune(parser.raw_buffer[parser.raw_buffer_pos+low+2]) + - (rune(parser.raw_buffer[parser.raw_buffer_pos+high+2]) << 8) - - // Check for a low surrogate area. - if value2&0xFC00 != 0xDC00 { - return yaml_parser_set_reader_error(parser, - "expected low surrogate area", - parser.offset+2, int(value2)) - } - - // Generate the value of the surrogate pair. - value = 0x10000 + ((value & 0x3FF) << 10) + (value2 & 0x3FF) - } else { - width = 2 - } - - default: - panic("impossible") - } - - // Check if the character is in the allowed range: - // #x9 | #xA | #xD | [#x20-#x7E] (8 bit) - // | #x85 | [#xA0-#xD7FF] | [#xE000-#xFFFD] (16 bit) - // | [#x10000-#x10FFFF] (32 bit) - switch { - case value == 0x09: - case value == 0x0A: - case value == 0x0D: - case value >= 0x20 && value <= 0x7E: - case value == 0x85: - case value >= 0xA0 && value <= 0xD7FF: - case value >= 0xE000 && value <= 0xFFFD: - case value >= 0x10000 && value <= 0x10FFFF: - default: - return yaml_parser_set_reader_error(parser, - "control characters are not allowed", - parser.offset, int(value)) - } - - // Move the raw pointers. - parser.raw_buffer_pos += width - parser.offset += width - - // Finally put the character into the buffer. - if value <= 0x7F { - // 0000 0000-0000 007F . 0xxxxxxx - parser.buffer[buffer_len+0] = byte(value) - } else if value <= 0x7FF { - // 0000 0080-0000 07FF . 110xxxxx 10xxxxxx - parser.buffer[buffer_len+0] = byte(0xC0 + (value >> 6)) - parser.buffer[buffer_len+1] = byte(0x80 + (value & 0x3F)) - } else if value <= 0xFFFF { - // 0000 0800-0000 FFFF . 1110xxxx 10xxxxxx 10xxxxxx - parser.buffer[buffer_len+0] = byte(0xE0 + (value >> 12)) - parser.buffer[buffer_len+1] = byte(0x80 + ((value >> 6) & 0x3F)) - parser.buffer[buffer_len+2] = byte(0x80 + (value & 0x3F)) - } else { - // 0001 0000-0010 FFFF . 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx - parser.buffer[buffer_len+0] = byte(0xF0 + (value >> 18)) - parser.buffer[buffer_len+1] = byte(0x80 + ((value >> 12) & 0x3F)) - parser.buffer[buffer_len+2] = byte(0x80 + ((value >> 6) & 0x3F)) - parser.buffer[buffer_len+3] = byte(0x80 + (value & 0x3F)) - } - buffer_len += width - - parser.unread++ - } - - // On EOF, put NUL into the buffer and return. - if parser.eof { - parser.buffer[buffer_len] = 0 - buffer_len++ - parser.unread++ - break - } - } - parser.buffer = parser.buffer[:buffer_len] - return true -} diff --git a/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/coreos/yaml/resolve.go b/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/coreos/yaml/resolve.go deleted file mode 100644 index 06c698a2..00000000 --- a/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/coreos/yaml/resolve.go +++ /dev/null @@ -1,190 +0,0 @@ -package yaml - -import ( - "encoding/base64" - "fmt" - "math" - "strconv" - "strings" - "unicode/utf8" -) - -// TODO: merge, timestamps, base 60 floats, omap. - -type resolveMapItem struct { - value interface{} - tag string -} - -var resolveTable = make([]byte, 256) -var resolveMap = make(map[string]resolveMapItem) - -func init() { - t := resolveTable - t[int('+')] = 'S' // Sign - t[int('-')] = 'S' - for _, c := range "0123456789" { - t[int(c)] = 'D' // Digit - } - for _, c := range "yYnNtTfFoO~" { - t[int(c)] = 'M' // In map - } - t[int('.')] = '.' // Float (potentially in map) - - var resolveMapList = []struct { - v interface{} - tag string - l []string - }{ - {true, yaml_BOOL_TAG, []string{"y", "Y", "yes", "Yes", "YES"}}, - {true, yaml_BOOL_TAG, []string{"true", "True", "TRUE"}}, - {true, yaml_BOOL_TAG, []string{"on", "On", "ON"}}, - {false, yaml_BOOL_TAG, []string{"n", "N", "no", "No", "NO"}}, - {false, yaml_BOOL_TAG, []string{"false", "False", "FALSE"}}, - {false, yaml_BOOL_TAG, []string{"off", "Off", "OFF"}}, - {nil, yaml_NULL_TAG, []string{"", "~", "null", "Null", "NULL"}}, - {math.NaN(), yaml_FLOAT_TAG, []string{".nan", ".NaN", ".NAN"}}, - {math.Inf(+1), yaml_FLOAT_TAG, []string{".inf", ".Inf", ".INF"}}, - {math.Inf(+1), yaml_FLOAT_TAG, []string{"+.inf", "+.Inf", "+.INF"}}, - {math.Inf(-1), yaml_FLOAT_TAG, []string{"-.inf", "-.Inf", "-.INF"}}, - {"<<", yaml_MERGE_TAG, []string{"<<"}}, - } - - m := resolveMap - for _, item := range resolveMapList { - for _, s := range item.l { - m[s] = resolveMapItem{item.v, item.tag} - } - } -} - -const longTagPrefix = "tag:yaml.org,2002:" - -func shortTag(tag string) string { - // TODO This can easily be made faster and produce less garbage. - if strings.HasPrefix(tag, longTagPrefix) { - return "!!" + tag[len(longTagPrefix):] - } - return tag -} - -func longTag(tag string) string { - if strings.HasPrefix(tag, "!!") { - return longTagPrefix + tag[2:] - } - return tag -} - -func resolvableTag(tag string) bool { - switch tag { - case "", yaml_STR_TAG, yaml_BOOL_TAG, yaml_INT_TAG, yaml_FLOAT_TAG, yaml_NULL_TAG: - return true - } - return false -} - -func resolve(tag string, in string) (rtag string, out interface{}) { - if !resolvableTag(tag) { - return tag, in - } - - defer func() { - switch tag { - case "", rtag, yaml_STR_TAG, yaml_BINARY_TAG: - return - } - fail(fmt.Sprintf("cannot decode %s `%s` as a %s", shortTag(rtag), in, shortTag(tag))) - }() - - // Any data is accepted as a !!str or !!binary. - // Otherwise, the prefix is enough of a hint about what it might be. - hint := byte('N') - if in != "" { - hint = resolveTable[in[0]] - } - if hint != 0 && tag != yaml_STR_TAG && tag != yaml_BINARY_TAG { - // Handle things we can lookup in a map. - if item, ok := resolveMap[in]; ok { - return item.tag, item.value - } - - // Base 60 floats are a bad idea, were dropped in YAML 1.2, and - // are purposefully unsupported here. They're still quoted on - // the way out for compatibility with other parser, though. - - switch hint { - case 'M': - // We've already checked the map above. - - case '.': - // Not in the map, so maybe a normal float. - floatv, err := strconv.ParseFloat(in, 64) - if err == nil { - return yaml_FLOAT_TAG, floatv - } - - case 'D', 'S': - // Int, float, or timestamp. - plain := strings.Replace(in, "_", "", -1) - intv, err := strconv.ParseInt(plain, 0, 64) - if err == nil { - if intv == int64(int(intv)) { - return yaml_INT_TAG, int(intv) - } else { - return yaml_INT_TAG, intv - } - } - floatv, err := strconv.ParseFloat(plain, 64) - if err == nil { - return yaml_FLOAT_TAG, floatv - } - if strings.HasPrefix(plain, "0b") { - intv, err := strconv.ParseInt(plain[2:], 2, 64) - if err == nil { - return yaml_INT_TAG, int(intv) - } - } else if strings.HasPrefix(plain, "-0b") { - intv, err := strconv.ParseInt(plain[3:], 2, 64) - if err == nil { - return yaml_INT_TAG, -int(intv) - } - } - // XXX Handle timestamps here. - - default: - panic("resolveTable item not yet handled: " + string(rune(hint)) + " (with " + in + ")") - } - } - if tag == yaml_BINARY_TAG { - return yaml_BINARY_TAG, in - } - if utf8.ValidString(in) { - return yaml_STR_TAG, in - } - return yaml_BINARY_TAG, encodeBase64(in) -} - -// encodeBase64 encodes s as base64 that is broken up into multiple lines -// as appropriate for the resulting length. -func encodeBase64(s string) string { - const lineLen = 70 - encLen := base64.StdEncoding.EncodedLen(len(s)) - lines := encLen/lineLen + 1 - buf := make([]byte, encLen*2+lines) - in := buf[0:encLen] - out := buf[encLen:] - base64.StdEncoding.Encode(in, []byte(s)) - k := 0 - for i := 0; i < len(in); i += lineLen { - j := i + lineLen - if j > len(in) { - j = len(in) - } - k += copy(out[k:], in[i:j]) - if lines > 1 { - out[k] = '\n' - k++ - } - } - return string(out[:k]) -} diff --git a/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/coreos/yaml/scannerc.go b/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/coreos/yaml/scannerc.go deleted file mode 100644 index fe93b190..00000000 --- a/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/coreos/yaml/scannerc.go +++ /dev/null @@ -1,2710 +0,0 @@ -package yaml - -import ( - "bytes" - "fmt" -) - -// Introduction -// ************ -// -// The following notes assume that you are familiar with the YAML specification -// (http://yaml.org/spec/cvs/current.html). We mostly follow it, although in -// some cases we are less restrictive that it requires. -// -// The process of transforming a YAML stream into a sequence of events is -// divided on two steps: Scanning and Parsing. -// -// The Scanner transforms the input stream into a sequence of tokens, while the -// parser transform the sequence of tokens produced by the Scanner into a -// sequence of parsing events. -// -// The Scanner is rather clever and complicated. The Parser, on the contrary, -// is a straightforward implementation of a recursive-descendant parser (or, -// LL(1) parser, as it is usually called). -// -// Actually there are two issues of Scanning that might be called "clever", the -// rest is quite straightforward. The issues are "block collection start" and -// "simple keys". Both issues are explained below in details. -// -// Here the Scanning step is explained and implemented. We start with the list -// of all the tokens produced by the Scanner together with short descriptions. -// -// Now, tokens: -// -// STREAM-START(encoding) # The stream start. -// STREAM-END # The stream end. -// VERSION-DIRECTIVE(major,minor) # The '%YAML' directive. -// TAG-DIRECTIVE(handle,prefix) # The '%TAG' directive. -// DOCUMENT-START # '---' -// DOCUMENT-END # '...' -// BLOCK-SEQUENCE-START # Indentation increase denoting a block -// BLOCK-MAPPING-START # sequence or a block mapping. -// BLOCK-END # Indentation decrease. -// FLOW-SEQUENCE-START # '[' -// FLOW-SEQUENCE-END # ']' -// BLOCK-SEQUENCE-START # '{' -// BLOCK-SEQUENCE-END # '}' -// BLOCK-ENTRY # '-' -// FLOW-ENTRY # ',' -// KEY # '?' or nothing (simple keys). -// VALUE # ':' -// ALIAS(anchor) # '*anchor' -// ANCHOR(anchor) # '&anchor' -// TAG(handle,suffix) # '!handle!suffix' -// SCALAR(value,style) # A scalar. -// -// The following two tokens are "virtual" tokens denoting the beginning and the -// end of the stream: -// -// STREAM-START(encoding) -// STREAM-END -// -// We pass the information about the input stream encoding with the -// STREAM-START token. -// -// The next two tokens are responsible for tags: -// -// VERSION-DIRECTIVE(major,minor) -// TAG-DIRECTIVE(handle,prefix) -// -// Example: -// -// %YAML 1.1 -// %TAG ! !foo -// %TAG !yaml! tag:yaml.org,2002: -// --- -// -// The correspoding sequence of tokens: -// -// STREAM-START(utf-8) -// VERSION-DIRECTIVE(1,1) -// TAG-DIRECTIVE("!","!foo") -// TAG-DIRECTIVE("!yaml","tag:yaml.org,2002:") -// DOCUMENT-START -// STREAM-END -// -// Note that the VERSION-DIRECTIVE and TAG-DIRECTIVE tokens occupy a whole -// line. -// -// The document start and end indicators are represented by: -// -// DOCUMENT-START -// DOCUMENT-END -// -// Note that if a YAML stream contains an implicit document (without '---' -// and '...' indicators), no DOCUMENT-START and DOCUMENT-END tokens will be -// produced. -// -// In the following examples, we present whole documents together with the -// produced tokens. -// -// 1. An implicit document: -// -// 'a scalar' -// -// Tokens: -// -// STREAM-START(utf-8) -// SCALAR("a scalar",single-quoted) -// STREAM-END -// -// 2. An explicit document: -// -// --- -// 'a scalar' -// ... -// -// Tokens: -// -// STREAM-START(utf-8) -// DOCUMENT-START -// SCALAR("a scalar",single-quoted) -// DOCUMENT-END -// STREAM-END -// -// 3. Several documents in a stream: -// -// 'a scalar' -// --- -// 'another scalar' -// --- -// 'yet another scalar' -// -// Tokens: -// -// STREAM-START(utf-8) -// SCALAR("a scalar",single-quoted) -// DOCUMENT-START -// SCALAR("another scalar",single-quoted) -// DOCUMENT-START -// SCALAR("yet another scalar",single-quoted) -// STREAM-END -// -// We have already introduced the SCALAR token above. The following tokens are -// used to describe aliases, anchors, tag, and scalars: -// -// ALIAS(anchor) -// ANCHOR(anchor) -// TAG(handle,suffix) -// SCALAR(value,style) -// -// The following series of examples illustrate the usage of these tokens: -// -// 1. A recursive sequence: -// -// &A [ *A ] -// -// Tokens: -// -// STREAM-START(utf-8) -// ANCHOR("A") -// FLOW-SEQUENCE-START -// ALIAS("A") -// FLOW-SEQUENCE-END -// STREAM-END -// -// 2. A tagged scalar: -// -// !!float "3.14" # A good approximation. -// -// Tokens: -// -// STREAM-START(utf-8) -// TAG("!!","float") -// SCALAR("3.14",double-quoted) -// STREAM-END -// -// 3. Various scalar styles: -// -// --- # Implicit empty plain scalars do not produce tokens. -// --- a plain scalar -// --- 'a single-quoted scalar' -// --- "a double-quoted scalar" -// --- |- -// a literal scalar -// --- >- -// a folded -// scalar -// -// Tokens: -// -// STREAM-START(utf-8) -// DOCUMENT-START -// DOCUMENT-START -// SCALAR("a plain scalar",plain) -// DOCUMENT-START -// SCALAR("a single-quoted scalar",single-quoted) -// DOCUMENT-START -// SCALAR("a double-quoted scalar",double-quoted) -// DOCUMENT-START -// SCALAR("a literal scalar",literal) -// DOCUMENT-START -// SCALAR("a folded scalar",folded) -// STREAM-END -// -// Now it's time to review collection-related tokens. We will start with -// flow collections: -// -// FLOW-SEQUENCE-START -// FLOW-SEQUENCE-END -// FLOW-MAPPING-START -// FLOW-MAPPING-END -// FLOW-ENTRY -// KEY -// VALUE -// -// The tokens FLOW-SEQUENCE-START, FLOW-SEQUENCE-END, FLOW-MAPPING-START, and -// FLOW-MAPPING-END represent the indicators '[', ']', '{', and '}' -// correspondingly. FLOW-ENTRY represent the ',' indicator. Finally the -// indicators '?' and ':', which are used for denoting mapping keys and values, -// are represented by the KEY and VALUE tokens. -// -// The following examples show flow collections: -// -// 1. A flow sequence: -// -// [item 1, item 2, item 3] -// -// Tokens: -// -// STREAM-START(utf-8) -// FLOW-SEQUENCE-START -// SCALAR("item 1",plain) -// FLOW-ENTRY -// SCALAR("item 2",plain) -// FLOW-ENTRY -// SCALAR("item 3",plain) -// FLOW-SEQUENCE-END -// STREAM-END -// -// 2. A flow mapping: -// -// { -// a simple key: a value, # Note that the KEY token is produced. -// ? a complex key: another value, -// } -// -// Tokens: -// -// STREAM-START(utf-8) -// FLOW-MAPPING-START -// KEY -// SCALAR("a simple key",plain) -// VALUE -// SCALAR("a value",plain) -// FLOW-ENTRY -// KEY -// SCALAR("a complex key",plain) -// VALUE -// SCALAR("another value",plain) -// FLOW-ENTRY -// FLOW-MAPPING-END -// STREAM-END -// -// A simple key is a key which is not denoted by the '?' indicator. Note that -// the Scanner still produce the KEY token whenever it encounters a simple key. -// -// For scanning block collections, the following tokens are used (note that we -// repeat KEY and VALUE here): -// -// BLOCK-SEQUENCE-START -// BLOCK-MAPPING-START -// BLOCK-END -// BLOCK-ENTRY -// KEY -// VALUE -// -// The tokens BLOCK-SEQUENCE-START and BLOCK-MAPPING-START denote indentation -// increase that precedes a block collection (cf. the INDENT token in Python). -// The token BLOCK-END denote indentation decrease that ends a block collection -// (cf. the DEDENT token in Python). However YAML has some syntax pecularities -// that makes detections of these tokens more complex. -// -// The tokens BLOCK-ENTRY, KEY, and VALUE are used to represent the indicators -// '-', '?', and ':' correspondingly. -// -// The following examples show how the tokens BLOCK-SEQUENCE-START, -// BLOCK-MAPPING-START, and BLOCK-END are emitted by the Scanner: -// -// 1. Block sequences: -// -// - item 1 -// - item 2 -// - -// - item 3.1 -// - item 3.2 -// - -// key 1: value 1 -// key 2: value 2 -// -// Tokens: -// -// STREAM-START(utf-8) -// BLOCK-SEQUENCE-START -// BLOCK-ENTRY -// SCALAR("item 1",plain) -// BLOCK-ENTRY -// SCALAR("item 2",plain) -// BLOCK-ENTRY -// BLOCK-SEQUENCE-START -// BLOCK-ENTRY -// SCALAR("item 3.1",plain) -// BLOCK-ENTRY -// SCALAR("item 3.2",plain) -// BLOCK-END -// BLOCK-ENTRY -// BLOCK-MAPPING-START -// KEY -// SCALAR("key 1",plain) -// VALUE -// SCALAR("value 1",plain) -// KEY -// SCALAR("key 2",plain) -// VALUE -// SCALAR("value 2",plain) -// BLOCK-END -// BLOCK-END -// STREAM-END -// -// 2. Block mappings: -// -// a simple key: a value # The KEY token is produced here. -// ? a complex key -// : another value -// a mapping: -// key 1: value 1 -// key 2: value 2 -// a sequence: -// - item 1 -// - item 2 -// -// Tokens: -// -// STREAM-START(utf-8) -// BLOCK-MAPPING-START -// KEY -// SCALAR("a simple key",plain) -// VALUE -// SCALAR("a value",plain) -// KEY -// SCALAR("a complex key",plain) -// VALUE -// SCALAR("another value",plain) -// KEY -// SCALAR("a mapping",plain) -// BLOCK-MAPPING-START -// KEY -// SCALAR("key 1",plain) -// VALUE -// SCALAR("value 1",plain) -// KEY -// SCALAR("key 2",plain) -// VALUE -// SCALAR("value 2",plain) -// BLOCK-END -// KEY -// SCALAR("a sequence",plain) -// VALUE -// BLOCK-SEQUENCE-START -// BLOCK-ENTRY -// SCALAR("item 1",plain) -// BLOCK-ENTRY -// SCALAR("item 2",plain) -// BLOCK-END -// BLOCK-END -// STREAM-END -// -// YAML does not always require to start a new block collection from a new -// line. If the current line contains only '-', '?', and ':' indicators, a new -// block collection may start at the current line. The following examples -// illustrate this case: -// -// 1. Collections in a sequence: -// -// - - item 1 -// - item 2 -// - key 1: value 1 -// key 2: value 2 -// - ? complex key -// : complex value -// -// Tokens: -// -// STREAM-START(utf-8) -// BLOCK-SEQUENCE-START -// BLOCK-ENTRY -// BLOCK-SEQUENCE-START -// BLOCK-ENTRY -// SCALAR("item 1",plain) -// BLOCK-ENTRY -// SCALAR("item 2",plain) -// BLOCK-END -// BLOCK-ENTRY -// BLOCK-MAPPING-START -// KEY -// SCALAR("key 1",plain) -// VALUE -// SCALAR("value 1",plain) -// KEY -// SCALAR("key 2",plain) -// VALUE -// SCALAR("value 2",plain) -// BLOCK-END -// BLOCK-ENTRY -// BLOCK-MAPPING-START -// KEY -// SCALAR("complex key") -// VALUE -// SCALAR("complex value") -// BLOCK-END -// BLOCK-END -// STREAM-END -// -// 2. Collections in a mapping: -// -// ? a sequence -// : - item 1 -// - item 2 -// ? a mapping -// : key 1: value 1 -// key 2: value 2 -// -// Tokens: -// -// STREAM-START(utf-8) -// BLOCK-MAPPING-START -// KEY -// SCALAR("a sequence",plain) -// VALUE -// BLOCK-SEQUENCE-START -// BLOCK-ENTRY -// SCALAR("item 1",plain) -// BLOCK-ENTRY -// SCALAR("item 2",plain) -// BLOCK-END -// KEY -// SCALAR("a mapping",plain) -// VALUE -// BLOCK-MAPPING-START -// KEY -// SCALAR("key 1",plain) -// VALUE -// SCALAR("value 1",plain) -// KEY -// SCALAR("key 2",plain) -// VALUE -// SCALAR("value 2",plain) -// BLOCK-END -// BLOCK-END -// STREAM-END -// -// YAML also permits non-indented sequences if they are included into a block -// mapping. In this case, the token BLOCK-SEQUENCE-START is not produced: -// -// key: -// - item 1 # BLOCK-SEQUENCE-START is NOT produced here. -// - item 2 -// -// Tokens: -// -// STREAM-START(utf-8) -// BLOCK-MAPPING-START -// KEY -// SCALAR("key",plain) -// VALUE -// BLOCK-ENTRY -// SCALAR("item 1",plain) -// BLOCK-ENTRY -// SCALAR("item 2",plain) -// BLOCK-END -// - -// Ensure that the buffer contains the required number of characters. -// Return true on success, false on failure (reader error or memory error). -func cache(parser *yaml_parser_t, length int) bool { - // [Go] This was inlined: !cache(A, B) -> unread < B && !update(A, B) - return parser.unread >= length || yaml_parser_update_buffer(parser, length) -} - -// Advance the buffer pointer. -func skip(parser *yaml_parser_t) { - parser.mark.index++ - parser.mark.column++ - parser.unread-- - parser.buffer_pos += width(parser.buffer[parser.buffer_pos]) -} - -func skip_line(parser *yaml_parser_t) { - if is_crlf(parser.buffer, parser.buffer_pos) { - parser.mark.index += 2 - parser.mark.column = 0 - parser.mark.line++ - parser.unread -= 2 - parser.buffer_pos += 2 - } else if is_break(parser.buffer, parser.buffer_pos) { - parser.mark.index++ - parser.mark.column = 0 - parser.mark.line++ - parser.unread-- - parser.buffer_pos += width(parser.buffer[parser.buffer_pos]) - } -} - -// Copy a character to a string buffer and advance pointers. -func read(parser *yaml_parser_t, s []byte) []byte { - w := width(parser.buffer[parser.buffer_pos]) - if w == 0 { - panic("invalid character sequence") - } - if len(s) == 0 { - s = make([]byte, 0, 32) - } - if w == 1 && len(s)+w <= cap(s) { - s = s[:len(s)+1] - s[len(s)-1] = parser.buffer[parser.buffer_pos] - parser.buffer_pos++ - } else { - s = append(s, parser.buffer[parser.buffer_pos:parser.buffer_pos+w]...) - parser.buffer_pos += w - } - parser.mark.index++ - parser.mark.column++ - parser.unread-- - return s -} - -// Copy a line break character to a string buffer and advance pointers. -func read_line(parser *yaml_parser_t, s []byte) []byte { - buf := parser.buffer - pos := parser.buffer_pos - switch { - case buf[pos] == '\r' && buf[pos+1] == '\n': - // CR LF . LF - s = append(s, '\n') - parser.buffer_pos += 2 - parser.mark.index++ - parser.unread-- - case buf[pos] == '\r' || buf[pos] == '\n': - // CR|LF . LF - s = append(s, '\n') - parser.buffer_pos += 1 - case buf[pos] == '\xC2' && buf[pos+1] == '\x85': - // NEL . LF - s = append(s, '\n') - parser.buffer_pos += 2 - case buf[pos] == '\xE2' && buf[pos+1] == '\x80' && (buf[pos+2] == '\xA8' || buf[pos+2] == '\xA9'): - // LS|PS . LS|PS - s = append(s, buf[parser.buffer_pos:pos+3]...) - parser.buffer_pos += 3 - default: - return s - } - parser.mark.index++ - parser.mark.column = 0 - parser.mark.line++ - parser.unread-- - return s -} - -// Get the next token. -func yaml_parser_scan(parser *yaml_parser_t, token *yaml_token_t) bool { - // Erase the token object. - *token = yaml_token_t{} // [Go] Is this necessary? - - // No tokens after STREAM-END or error. - if parser.stream_end_produced || parser.error != yaml_NO_ERROR { - return true - } - - // Ensure that the tokens queue contains enough tokens. - if !parser.token_available { - if !yaml_parser_fetch_more_tokens(parser) { - return false - } - } - - // Fetch the next token from the queue. - *token = parser.tokens[parser.tokens_head] - parser.tokens_head++ - parser.tokens_parsed++ - parser.token_available = false - - if token.typ == yaml_STREAM_END_TOKEN { - parser.stream_end_produced = true - } - return true -} - -// Set the scanner error and return false. -func yaml_parser_set_scanner_error(parser *yaml_parser_t, context string, context_mark yaml_mark_t, problem string) bool { - parser.error = yaml_SCANNER_ERROR - parser.context = context - parser.context_mark = context_mark - parser.problem = problem - parser.problem_mark = parser.mark - return false -} - -func yaml_parser_set_scanner_tag_error(parser *yaml_parser_t, directive bool, context_mark yaml_mark_t, problem string) bool { - context := "while parsing a tag" - if directive { - context = "while parsing a %TAG directive" - } - return yaml_parser_set_scanner_error(parser, context, context_mark, "did not find URI escaped octet") -} - -func trace(args ...interface{}) func() { - pargs := append([]interface{}{"+++"}, args...) - fmt.Println(pargs...) - pargs = append([]interface{}{"---"}, args...) - return func() { fmt.Println(pargs...) } -} - -// Ensure that the tokens queue contains at least one token which can be -// returned to the Parser. -func yaml_parser_fetch_more_tokens(parser *yaml_parser_t) bool { - // While we need more tokens to fetch, do it. - for { - // Check if we really need to fetch more tokens. - need_more_tokens := false - - if parser.tokens_head == len(parser.tokens) { - // Queue is empty. - need_more_tokens = true - } else { - // Check if any potential simple key may occupy the head position. - if !yaml_parser_stale_simple_keys(parser) { - return false - } - - for i := range parser.simple_keys { - simple_key := &parser.simple_keys[i] - if simple_key.possible && simple_key.token_number == parser.tokens_parsed { - need_more_tokens = true - break - } - } - } - - // We are finished. - if !need_more_tokens { - break - } - // Fetch the next token. - if !yaml_parser_fetch_next_token(parser) { - return false - } - } - - parser.token_available = true - return true -} - -// The dispatcher for token fetchers. -func yaml_parser_fetch_next_token(parser *yaml_parser_t) bool { - // Ensure that the buffer is initialized. - if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) { - return false - } - - // Check if we just started scanning. Fetch STREAM-START then. - if !parser.stream_start_produced { - return yaml_parser_fetch_stream_start(parser) - } - - // Eat whitespaces and comments until we reach the next token. - if !yaml_parser_scan_to_next_token(parser) { - return false - } - - // Remove obsolete potential simple keys. - if !yaml_parser_stale_simple_keys(parser) { - return false - } - - // Check the indentation level against the current column. - if !yaml_parser_unroll_indent(parser, parser.mark.column) { - return false - } - - // Ensure that the buffer contains at least 4 characters. 4 is the length - // of the longest indicators ('--- ' and '... '). - if parser.unread < 4 && !yaml_parser_update_buffer(parser, 4) { - return false - } - - // Is it the end of the stream? - if is_z(parser.buffer, parser.buffer_pos) { - return yaml_parser_fetch_stream_end(parser) - } - - // Is it a directive? - if parser.mark.column == 0 && parser.buffer[parser.buffer_pos] == '%' { - return yaml_parser_fetch_directive(parser) - } - - buf := parser.buffer - pos := parser.buffer_pos - - // Is it the document start indicator? - if parser.mark.column == 0 && buf[pos] == '-' && buf[pos+1] == '-' && buf[pos+2] == '-' && is_blankz(buf, pos+3) { - return yaml_parser_fetch_document_indicator(parser, yaml_DOCUMENT_START_TOKEN) - } - - // Is it the document end indicator? - if parser.mark.column == 0 && buf[pos] == '.' && buf[pos+1] == '.' && buf[pos+2] == '.' && is_blankz(buf, pos+3) { - return yaml_parser_fetch_document_indicator(parser, yaml_DOCUMENT_END_TOKEN) - } - - // Is it the flow sequence start indicator? - if buf[pos] == '[' { - return yaml_parser_fetch_flow_collection_start(parser, yaml_FLOW_SEQUENCE_START_TOKEN) - } - - // Is it the flow mapping start indicator? - if parser.buffer[parser.buffer_pos] == '{' { - return yaml_parser_fetch_flow_collection_start(parser, yaml_FLOW_MAPPING_START_TOKEN) - } - - // Is it the flow sequence end indicator? - if parser.buffer[parser.buffer_pos] == ']' { - return yaml_parser_fetch_flow_collection_end(parser, - yaml_FLOW_SEQUENCE_END_TOKEN) - } - - // Is it the flow mapping end indicator? - if parser.buffer[parser.buffer_pos] == '}' { - return yaml_parser_fetch_flow_collection_end(parser, - yaml_FLOW_MAPPING_END_TOKEN) - } - - // Is it the flow entry indicator? - if parser.buffer[parser.buffer_pos] == ',' { - return yaml_parser_fetch_flow_entry(parser) - } - - // Is it the block entry indicator? - if parser.buffer[parser.buffer_pos] == '-' && is_blankz(parser.buffer, parser.buffer_pos+1) { - return yaml_parser_fetch_block_entry(parser) - } - - // Is it the key indicator? - if parser.buffer[parser.buffer_pos] == '?' && (parser.flow_level > 0 || is_blankz(parser.buffer, parser.buffer_pos+1)) { - return yaml_parser_fetch_key(parser) - } - - // Is it the value indicator? - if parser.buffer[parser.buffer_pos] == ':' && (parser.flow_level > 0 || is_blankz(parser.buffer, parser.buffer_pos+1)) { - return yaml_parser_fetch_value(parser) - } - - // Is it an alias? - if parser.buffer[parser.buffer_pos] == '*' { - return yaml_parser_fetch_anchor(parser, yaml_ALIAS_TOKEN) - } - - // Is it an anchor? - if parser.buffer[parser.buffer_pos] == '&' { - return yaml_parser_fetch_anchor(parser, yaml_ANCHOR_TOKEN) - } - - // Is it a tag? - if parser.buffer[parser.buffer_pos] == '!' { - return yaml_parser_fetch_tag(parser) - } - - // Is it a literal scalar? - if parser.buffer[parser.buffer_pos] == '|' && parser.flow_level == 0 { - return yaml_parser_fetch_block_scalar(parser, true) - } - - // Is it a folded scalar? - if parser.buffer[parser.buffer_pos] == '>' && parser.flow_level == 0 { - return yaml_parser_fetch_block_scalar(parser, false) - } - - // Is it a single-quoted scalar? - if parser.buffer[parser.buffer_pos] == '\'' { - return yaml_parser_fetch_flow_scalar(parser, true) - } - - // Is it a double-quoted scalar? - if parser.buffer[parser.buffer_pos] == '"' { - return yaml_parser_fetch_flow_scalar(parser, false) - } - - // Is it a plain scalar? - // - // A plain scalar may start with any non-blank characters except - // - // '-', '?', ':', ',', '[', ']', '{', '}', - // '#', '&', '*', '!', '|', '>', '\'', '\"', - // '%', '@', '`'. - // - // In the block context (and, for the '-' indicator, in the flow context - // too), it may also start with the characters - // - // '-', '?', ':' - // - // if it is followed by a non-space character. - // - // The last rule is more restrictive than the specification requires. - // [Go] Make this logic more reasonable. - //switch parser.buffer[parser.buffer_pos] { - //case '-', '?', ':', ',', '?', '-', ',', ':', ']', '[', '}', '{', '&', '#', '!', '*', '>', '|', '"', '\'', '@', '%', '-', '`': - //} - if !(is_blankz(parser.buffer, parser.buffer_pos) || parser.buffer[parser.buffer_pos] == '-' || - parser.buffer[parser.buffer_pos] == '?' || parser.buffer[parser.buffer_pos] == ':' || - parser.buffer[parser.buffer_pos] == ',' || parser.buffer[parser.buffer_pos] == '[' || - parser.buffer[parser.buffer_pos] == ']' || parser.buffer[parser.buffer_pos] == '{' || - parser.buffer[parser.buffer_pos] == '}' || parser.buffer[parser.buffer_pos] == '#' || - parser.buffer[parser.buffer_pos] == '&' || parser.buffer[parser.buffer_pos] == '*' || - parser.buffer[parser.buffer_pos] == '!' || parser.buffer[parser.buffer_pos] == '|' || - parser.buffer[parser.buffer_pos] == '>' || parser.buffer[parser.buffer_pos] == '\'' || - parser.buffer[parser.buffer_pos] == '"' || parser.buffer[parser.buffer_pos] == '%' || - parser.buffer[parser.buffer_pos] == '@' || parser.buffer[parser.buffer_pos] == '`') || - (parser.buffer[parser.buffer_pos] == '-' && !is_blank(parser.buffer, parser.buffer_pos+1)) || - (parser.flow_level == 0 && - (parser.buffer[parser.buffer_pos] == '?' || parser.buffer[parser.buffer_pos] == ':') && - !is_blankz(parser.buffer, parser.buffer_pos+1)) { - return yaml_parser_fetch_plain_scalar(parser) - } - - // If we don't determine the token type so far, it is an error. - return yaml_parser_set_scanner_error(parser, - "while scanning for the next token", parser.mark, - "found character that cannot start any token") -} - -// Check the list of potential simple keys and remove the positions that -// cannot contain simple keys anymore. -func yaml_parser_stale_simple_keys(parser *yaml_parser_t) bool { - // Check for a potential simple key for each flow level. - for i := range parser.simple_keys { - simple_key := &parser.simple_keys[i] - - // The specification requires that a simple key - // - // - is limited to a single line, - // - is shorter than 1024 characters. - if simple_key.possible && (simple_key.mark.line < parser.mark.line || simple_key.mark.index+1024 < parser.mark.index) { - - // Check if the potential simple key to be removed is required. - if simple_key.required { - return yaml_parser_set_scanner_error(parser, - "while scanning a simple key", simple_key.mark, - "could not find expected ':'") - } - simple_key.possible = false - } - } - return true -} - -// Check if a simple key may start at the current position and add it if -// needed. -func yaml_parser_save_simple_key(parser *yaml_parser_t) bool { - // A simple key is required at the current position if the scanner is in - // the block context and the current column coincides with the indentation - // level. - - required := parser.flow_level == 0 && parser.indent == parser.mark.column - - // A simple key is required only when it is the first token in the current - // line. Therefore it is always allowed. But we add a check anyway. - if required && !parser.simple_key_allowed { - panic("should not happen") - } - - // - // If the current position may start a simple key, save it. - // - if parser.simple_key_allowed { - simple_key := yaml_simple_key_t{ - possible: true, - required: required, - token_number: parser.tokens_parsed + (len(parser.tokens) - parser.tokens_head), - } - simple_key.mark = parser.mark - - if !yaml_parser_remove_simple_key(parser) { - return false - } - parser.simple_keys[len(parser.simple_keys)-1] = simple_key - } - return true -} - -// Remove a potential simple key at the current flow level. -func yaml_parser_remove_simple_key(parser *yaml_parser_t) bool { - i := len(parser.simple_keys) - 1 - if parser.simple_keys[i].possible { - // If the key is required, it is an error. - if parser.simple_keys[i].required { - return yaml_parser_set_scanner_error(parser, - "while scanning a simple key", parser.simple_keys[i].mark, - "could not find expected ':'") - } - } - // Remove the key from the stack. - parser.simple_keys[i].possible = false - return true -} - -// Increase the flow level and resize the simple key list if needed. -func yaml_parser_increase_flow_level(parser *yaml_parser_t) bool { - // Reset the simple key on the next level. - parser.simple_keys = append(parser.simple_keys, yaml_simple_key_t{}) - - // Increase the flow level. - parser.flow_level++ - return true -} - -// Decrease the flow level. -func yaml_parser_decrease_flow_level(parser *yaml_parser_t) bool { - if parser.flow_level > 0 { - parser.flow_level-- - parser.simple_keys = parser.simple_keys[:len(parser.simple_keys)-1] - } - return true -} - -// Push the current indentation level to the stack and set the new level -// the current column is greater than the indentation level. In this case, -// append or insert the specified token into the token queue. -func yaml_parser_roll_indent(parser *yaml_parser_t, column, number int, typ yaml_token_type_t, mark yaml_mark_t) bool { - // In the flow context, do nothing. - if parser.flow_level > 0 { - return true - } - - if parser.indent < column { - // Push the current indentation level to the stack and set the new - // indentation level. - parser.indents = append(parser.indents, parser.indent) - parser.indent = column - - // Create a token and insert it into the queue. - token := yaml_token_t{ - typ: typ, - start_mark: mark, - end_mark: mark, - } - if number > -1 { - number -= parser.tokens_parsed - } - yaml_insert_token(parser, number, &token) - } - return true -} - -// Pop indentation levels from the indents stack until the current level -// becomes less or equal to the column. For each intendation level, append -// the BLOCK-END token. -func yaml_parser_unroll_indent(parser *yaml_parser_t, column int) bool { - // In the flow context, do nothing. - if parser.flow_level > 0 { - return true - } - - // Loop through the intendation levels in the stack. - for parser.indent > column { - // Create a token and append it to the queue. - token := yaml_token_t{ - typ: yaml_BLOCK_END_TOKEN, - start_mark: parser.mark, - end_mark: parser.mark, - } - yaml_insert_token(parser, -1, &token) - - // Pop the indentation level. - parser.indent = parser.indents[len(parser.indents)-1] - parser.indents = parser.indents[:len(parser.indents)-1] - } - return true -} - -// Initialize the scanner and produce the STREAM-START token. -func yaml_parser_fetch_stream_start(parser *yaml_parser_t) bool { - - // Set the initial indentation. - parser.indent = -1 - - // Initialize the simple key stack. - parser.simple_keys = append(parser.simple_keys, yaml_simple_key_t{}) - - // A simple key is allowed at the beginning of the stream. - parser.simple_key_allowed = true - - // We have started. - parser.stream_start_produced = true - - // Create the STREAM-START token and append it to the queue. - token := yaml_token_t{ - typ: yaml_STREAM_START_TOKEN, - start_mark: parser.mark, - end_mark: parser.mark, - encoding: parser.encoding, - } - yaml_insert_token(parser, -1, &token) - return true -} - -// Produce the STREAM-END token and shut down the scanner. -func yaml_parser_fetch_stream_end(parser *yaml_parser_t) bool { - - // Force new line. - if parser.mark.column != 0 { - parser.mark.column = 0 - parser.mark.line++ - } - - // Reset the indentation level. - if !yaml_parser_unroll_indent(parser, -1) { - return false - } - - // Reset simple keys. - if !yaml_parser_remove_simple_key(parser) { - return false - } - - parser.simple_key_allowed = false - - // Create the STREAM-END token and append it to the queue. - token := yaml_token_t{ - typ: yaml_STREAM_END_TOKEN, - start_mark: parser.mark, - end_mark: parser.mark, - } - yaml_insert_token(parser, -1, &token) - return true -} - -// Produce a VERSION-DIRECTIVE or TAG-DIRECTIVE token. -func yaml_parser_fetch_directive(parser *yaml_parser_t) bool { - // Reset the indentation level. - if !yaml_parser_unroll_indent(parser, -1) { - return false - } - - // Reset simple keys. - if !yaml_parser_remove_simple_key(parser) { - return false - } - - parser.simple_key_allowed = false - - // Create the YAML-DIRECTIVE or TAG-DIRECTIVE token. - token := yaml_token_t{} - if !yaml_parser_scan_directive(parser, &token) { - return false - } - // Append the token to the queue. - yaml_insert_token(parser, -1, &token) - return true -} - -// Produce the DOCUMENT-START or DOCUMENT-END token. -func yaml_parser_fetch_document_indicator(parser *yaml_parser_t, typ yaml_token_type_t) bool { - // Reset the indentation level. - if !yaml_parser_unroll_indent(parser, -1) { - return false - } - - // Reset simple keys. - if !yaml_parser_remove_simple_key(parser) { - return false - } - - parser.simple_key_allowed = false - - // Consume the token. - start_mark := parser.mark - - skip(parser) - skip(parser) - skip(parser) - - end_mark := parser.mark - - // Create the DOCUMENT-START or DOCUMENT-END token. - token := yaml_token_t{ - typ: typ, - start_mark: start_mark, - end_mark: end_mark, - } - // Append the token to the queue. - yaml_insert_token(parser, -1, &token) - return true -} - -// Produce the FLOW-SEQUENCE-START or FLOW-MAPPING-START token. -func yaml_parser_fetch_flow_collection_start(parser *yaml_parser_t, typ yaml_token_type_t) bool { - // The indicators '[' and '{' may start a simple key. - if !yaml_parser_save_simple_key(parser) { - return false - } - - // Increase the flow level. - if !yaml_parser_increase_flow_level(parser) { - return false - } - - // A simple key may follow the indicators '[' and '{'. - parser.simple_key_allowed = true - - // Consume the token. - start_mark := parser.mark - skip(parser) - end_mark := parser.mark - - // Create the FLOW-SEQUENCE-START of FLOW-MAPPING-START token. - token := yaml_token_t{ - typ: typ, - start_mark: start_mark, - end_mark: end_mark, - } - // Append the token to the queue. - yaml_insert_token(parser, -1, &token) - return true -} - -// Produce the FLOW-SEQUENCE-END or FLOW-MAPPING-END token. -func yaml_parser_fetch_flow_collection_end(parser *yaml_parser_t, typ yaml_token_type_t) bool { - // Reset any potential simple key on the current flow level. - if !yaml_parser_remove_simple_key(parser) { - return false - } - - // Decrease the flow level. - if !yaml_parser_decrease_flow_level(parser) { - return false - } - - // No simple keys after the indicators ']' and '}'. - parser.simple_key_allowed = false - - // Consume the token. - - start_mark := parser.mark - skip(parser) - end_mark := parser.mark - - // Create the FLOW-SEQUENCE-END of FLOW-MAPPING-END token. - token := yaml_token_t{ - typ: typ, - start_mark: start_mark, - end_mark: end_mark, - } - // Append the token to the queue. - yaml_insert_token(parser, -1, &token) - return true -} - -// Produce the FLOW-ENTRY token. -func yaml_parser_fetch_flow_entry(parser *yaml_parser_t) bool { - // Reset any potential simple keys on the current flow level. - if !yaml_parser_remove_simple_key(parser) { - return false - } - - // Simple keys are allowed after ','. - parser.simple_key_allowed = true - - // Consume the token. - start_mark := parser.mark - skip(parser) - end_mark := parser.mark - - // Create the FLOW-ENTRY token and append it to the queue. - token := yaml_token_t{ - typ: yaml_FLOW_ENTRY_TOKEN, - start_mark: start_mark, - end_mark: end_mark, - } - yaml_insert_token(parser, -1, &token) - return true -} - -// Produce the BLOCK-ENTRY token. -func yaml_parser_fetch_block_entry(parser *yaml_parser_t) bool { - // Check if the scanner is in the block context. - if parser.flow_level == 0 { - // Check if we are allowed to start a new entry. - if !parser.simple_key_allowed { - return yaml_parser_set_scanner_error(parser, "", parser.mark, - "block sequence entries are not allowed in this context") - } - // Add the BLOCK-SEQUENCE-START token if needed. - if !yaml_parser_roll_indent(parser, parser.mark.column, -1, yaml_BLOCK_SEQUENCE_START_TOKEN, parser.mark) { - return false - } - } else { - // It is an error for the '-' indicator to occur in the flow context, - // but we let the Parser detect and report about it because the Parser - // is able to point to the context. - } - - // Reset any potential simple keys on the current flow level. - if !yaml_parser_remove_simple_key(parser) { - return false - } - - // Simple keys are allowed after '-'. - parser.simple_key_allowed = true - - // Consume the token. - start_mark := parser.mark - skip(parser) - end_mark := parser.mark - - // Create the BLOCK-ENTRY token and append it to the queue. - token := yaml_token_t{ - typ: yaml_BLOCK_ENTRY_TOKEN, - start_mark: start_mark, - end_mark: end_mark, - } - yaml_insert_token(parser, -1, &token) - return true -} - -// Produce the KEY token. -func yaml_parser_fetch_key(parser *yaml_parser_t) bool { - - // In the block context, additional checks are required. - if parser.flow_level == 0 { - // Check if we are allowed to start a new key (not nessesary simple). - if !parser.simple_key_allowed { - return yaml_parser_set_scanner_error(parser, "", parser.mark, - "mapping keys are not allowed in this context") - } - // Add the BLOCK-MAPPING-START token if needed. - if !yaml_parser_roll_indent(parser, parser.mark.column, -1, yaml_BLOCK_MAPPING_START_TOKEN, parser.mark) { - return false - } - } - - // Reset any potential simple keys on the current flow level. - if !yaml_parser_remove_simple_key(parser) { - return false - } - - // Simple keys are allowed after '?' in the block context. - parser.simple_key_allowed = parser.flow_level == 0 - - // Consume the token. - start_mark := parser.mark - skip(parser) - end_mark := parser.mark - - // Create the KEY token and append it to the queue. - token := yaml_token_t{ - typ: yaml_KEY_TOKEN, - start_mark: start_mark, - end_mark: end_mark, - } - yaml_insert_token(parser, -1, &token) - return true -} - -// Produce the VALUE token. -func yaml_parser_fetch_value(parser *yaml_parser_t) bool { - - simple_key := &parser.simple_keys[len(parser.simple_keys)-1] - - // Have we found a simple key? - if simple_key.possible { - // Create the KEY token and insert it into the queue. - token := yaml_token_t{ - typ: yaml_KEY_TOKEN, - start_mark: simple_key.mark, - end_mark: simple_key.mark, - } - yaml_insert_token(parser, simple_key.token_number-parser.tokens_parsed, &token) - - // In the block context, we may need to add the BLOCK-MAPPING-START token. - if !yaml_parser_roll_indent(parser, simple_key.mark.column, - simple_key.token_number, - yaml_BLOCK_MAPPING_START_TOKEN, simple_key.mark) { - return false - } - - // Remove the simple key. - simple_key.possible = false - - // A simple key cannot follow another simple key. - parser.simple_key_allowed = false - - } else { - // The ':' indicator follows a complex key. - - // In the block context, extra checks are required. - if parser.flow_level == 0 { - - // Check if we are allowed to start a complex value. - if !parser.simple_key_allowed { - return yaml_parser_set_scanner_error(parser, "", parser.mark, - "mapping values are not allowed in this context") - } - - // Add the BLOCK-MAPPING-START token if needed. - if !yaml_parser_roll_indent(parser, parser.mark.column, -1, yaml_BLOCK_MAPPING_START_TOKEN, parser.mark) { - return false - } - } - - // Simple keys after ':' are allowed in the block context. - parser.simple_key_allowed = parser.flow_level == 0 - } - - // Consume the token. - start_mark := parser.mark - skip(parser) - end_mark := parser.mark - - // Create the VALUE token and append it to the queue. - token := yaml_token_t{ - typ: yaml_VALUE_TOKEN, - start_mark: start_mark, - end_mark: end_mark, - } - yaml_insert_token(parser, -1, &token) - return true -} - -// Produce the ALIAS or ANCHOR token. -func yaml_parser_fetch_anchor(parser *yaml_parser_t, typ yaml_token_type_t) bool { - // An anchor or an alias could be a simple key. - if !yaml_parser_save_simple_key(parser) { - return false - } - - // A simple key cannot follow an anchor or an alias. - parser.simple_key_allowed = false - - // Create the ALIAS or ANCHOR token and append it to the queue. - var token yaml_token_t - if !yaml_parser_scan_anchor(parser, &token, typ) { - return false - } - yaml_insert_token(parser, -1, &token) - return true -} - -// Produce the TAG token. -func yaml_parser_fetch_tag(parser *yaml_parser_t) bool { - // A tag could be a simple key. - if !yaml_parser_save_simple_key(parser) { - return false - } - - // A simple key cannot follow a tag. - parser.simple_key_allowed = false - - // Create the TAG token and append it to the queue. - var token yaml_token_t - if !yaml_parser_scan_tag(parser, &token) { - return false - } - yaml_insert_token(parser, -1, &token) - return true -} - -// Produce the SCALAR(...,literal) or SCALAR(...,folded) tokens. -func yaml_parser_fetch_block_scalar(parser *yaml_parser_t, literal bool) bool { - // Remove any potential simple keys. - if !yaml_parser_remove_simple_key(parser) { - return false - } - - // A simple key may follow a block scalar. - parser.simple_key_allowed = true - - // Create the SCALAR token and append it to the queue. - var token yaml_token_t - if !yaml_parser_scan_block_scalar(parser, &token, literal) { - return false - } - yaml_insert_token(parser, -1, &token) - return true -} - -// Produce the SCALAR(...,single-quoted) or SCALAR(...,double-quoted) tokens. -func yaml_parser_fetch_flow_scalar(parser *yaml_parser_t, single bool) bool { - // A plain scalar could be a simple key. - if !yaml_parser_save_simple_key(parser) { - return false - } - - // A simple key cannot follow a flow scalar. - parser.simple_key_allowed = false - - // Create the SCALAR token and append it to the queue. - var token yaml_token_t - if !yaml_parser_scan_flow_scalar(parser, &token, single) { - return false - } - yaml_insert_token(parser, -1, &token) - return true -} - -// Produce the SCALAR(...,plain) token. -func yaml_parser_fetch_plain_scalar(parser *yaml_parser_t) bool { - // A plain scalar could be a simple key. - if !yaml_parser_save_simple_key(parser) { - return false - } - - // A simple key cannot follow a flow scalar. - parser.simple_key_allowed = false - - // Create the SCALAR token and append it to the queue. - var token yaml_token_t - if !yaml_parser_scan_plain_scalar(parser, &token) { - return false - } - yaml_insert_token(parser, -1, &token) - return true -} - -// Eat whitespaces and comments until the next token is found. -func yaml_parser_scan_to_next_token(parser *yaml_parser_t) bool { - - // Until the next token is not found. - for { - // Allow the BOM mark to start a line. - if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) { - return false - } - if parser.mark.column == 0 && is_bom(parser.buffer, parser.buffer_pos) { - skip(parser) - } - - // Eat whitespaces. - // Tabs are allowed: - // - in the flow context - // - in the block context, but not at the beginning of the line or - // after '-', '?', or ':' (complex value). - if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) { - return false - } - - for parser.buffer[parser.buffer_pos] == ' ' || ((parser.flow_level > 0 || !parser.simple_key_allowed) && parser.buffer[parser.buffer_pos] == '\t') { - skip(parser) - if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) { - return false - } - } - - // Eat a comment until a line break. - if parser.buffer[parser.buffer_pos] == '#' { - for !is_breakz(parser.buffer, parser.buffer_pos) { - skip(parser) - if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) { - return false - } - } - } - - // If it is a line break, eat it. - if is_break(parser.buffer, parser.buffer_pos) { - if parser.unread < 2 && !yaml_parser_update_buffer(parser, 2) { - return false - } - skip_line(parser) - - // In the block context, a new line may start a simple key. - if parser.flow_level == 0 { - parser.simple_key_allowed = true - } - } else { - break // We have found a token. - } - } - - return true -} - -// Scan a YAML-DIRECTIVE or TAG-DIRECTIVE token. -// -// Scope: -// %YAML 1.1 # a comment \n -// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -// %TAG !yaml! tag:yaml.org,2002: \n -// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -// -func yaml_parser_scan_directive(parser *yaml_parser_t, token *yaml_token_t) bool { - // Eat '%'. - start_mark := parser.mark - skip(parser) - - // Scan the directive name. - var name []byte - if !yaml_parser_scan_directive_name(parser, start_mark, &name) { - return false - } - - // Is it a YAML directive? - if bytes.Equal(name, []byte("YAML")) { - // Scan the VERSION directive value. - var major, minor int8 - if !yaml_parser_scan_version_directive_value(parser, start_mark, &major, &minor) { - return false - } - end_mark := parser.mark - - // Create a VERSION-DIRECTIVE token. - *token = yaml_token_t{ - typ: yaml_VERSION_DIRECTIVE_TOKEN, - start_mark: start_mark, - end_mark: end_mark, - major: major, - minor: minor, - } - - // Is it a TAG directive? - } else if bytes.Equal(name, []byte("TAG")) { - // Scan the TAG directive value. - var handle, prefix []byte - if !yaml_parser_scan_tag_directive_value(parser, start_mark, &handle, &prefix) { - return false - } - end_mark := parser.mark - - // Create a TAG-DIRECTIVE token. - *token = yaml_token_t{ - typ: yaml_TAG_DIRECTIVE_TOKEN, - start_mark: start_mark, - end_mark: end_mark, - value: handle, - prefix: prefix, - } - - // Unknown directive. - } else { - yaml_parser_set_scanner_error(parser, "while scanning a directive", - start_mark, "found uknown directive name") - return false - } - - // Eat the rest of the line including any comments. - if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) { - return false - } - - for is_blank(parser.buffer, parser.buffer_pos) { - skip(parser) - if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) { - return false - } - } - - if parser.buffer[parser.buffer_pos] == '#' { - for !is_breakz(parser.buffer, parser.buffer_pos) { - skip(parser) - if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) { - return false - } - } - } - - // Check if we are at the end of the line. - if !is_breakz(parser.buffer, parser.buffer_pos) { - yaml_parser_set_scanner_error(parser, "while scanning a directive", - start_mark, "did not find expected comment or line break") - return false - } - - // Eat a line break. - if is_break(parser.buffer, parser.buffer_pos) { - if parser.unread < 2 && !yaml_parser_update_buffer(parser, 2) { - return false - } - skip_line(parser) - } - - return true -} - -// Scan the directive name. -// -// Scope: -// %YAML 1.1 # a comment \n -// ^^^^ -// %TAG !yaml! tag:yaml.org,2002: \n -// ^^^ -// -func yaml_parser_scan_directive_name(parser *yaml_parser_t, start_mark yaml_mark_t, name *[]byte) bool { - // Consume the directive name. - if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) { - return false - } - - var s []byte - for is_alpha(parser.buffer, parser.buffer_pos) { - s = read(parser, s) - if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) { - return false - } - } - - // Check if the name is empty. - if len(s) == 0 { - yaml_parser_set_scanner_error(parser, "while scanning a directive", - start_mark, "could not find expected directive name") - return false - } - - // Check for an blank character after the name. - if !is_blankz(parser.buffer, parser.buffer_pos) { - yaml_parser_set_scanner_error(parser, "while scanning a directive", - start_mark, "found unexpected non-alphabetical character") - return false - } - *name = s - return true -} - -// Scan the value of VERSION-DIRECTIVE. -// -// Scope: -// %YAML 1.1 # a comment \n -// ^^^^^^ -func yaml_parser_scan_version_directive_value(parser *yaml_parser_t, start_mark yaml_mark_t, major, minor *int8) bool { - // Eat whitespaces. - if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) { - return false - } - for is_blank(parser.buffer, parser.buffer_pos) { - skip(parser) - if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) { - return false - } - } - - // Consume the major version number. - if !yaml_parser_scan_version_directive_number(parser, start_mark, major) { - return false - } - - // Eat '.'. - if parser.buffer[parser.buffer_pos] != '.' { - return yaml_parser_set_scanner_error(parser, "while scanning a %YAML directive", - start_mark, "did not find expected digit or '.' character") - } - - skip(parser) - - // Consume the minor version number. - if !yaml_parser_scan_version_directive_number(parser, start_mark, minor) { - return false - } - return true -} - -const max_number_length = 2 - -// Scan the version number of VERSION-DIRECTIVE. -// -// Scope: -// %YAML 1.1 # a comment \n -// ^ -// %YAML 1.1 # a comment \n -// ^ -func yaml_parser_scan_version_directive_number(parser *yaml_parser_t, start_mark yaml_mark_t, number *int8) bool { - - // Repeat while the next character is digit. - if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) { - return false - } - var value, length int8 - for is_digit(parser.buffer, parser.buffer_pos) { - // Check if the number is too long. - length++ - if length > max_number_length { - return yaml_parser_set_scanner_error(parser, "while scanning a %YAML directive", - start_mark, "found extremely long version number") - } - value = value*10 + int8(as_digit(parser.buffer, parser.buffer_pos)) - skip(parser) - if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) { - return false - } - } - - // Check if the number was present. - if length == 0 { - return yaml_parser_set_scanner_error(parser, "while scanning a %YAML directive", - start_mark, "did not find expected version number") - } - *number = value - return true -} - -// Scan the value of a TAG-DIRECTIVE token. -// -// Scope: -// %TAG !yaml! tag:yaml.org,2002: \n -// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -// -func yaml_parser_scan_tag_directive_value(parser *yaml_parser_t, start_mark yaml_mark_t, handle, prefix *[]byte) bool { - var handle_value, prefix_value []byte - - // Eat whitespaces. - if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) { - return false - } - - for is_blank(parser.buffer, parser.buffer_pos) { - skip(parser) - if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) { - return false - } - } - - // Scan a handle. - if !yaml_parser_scan_tag_handle(parser, true, start_mark, &handle_value) { - return false - } - - // Expect a whitespace. - if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) { - return false - } - if !is_blank(parser.buffer, parser.buffer_pos) { - yaml_parser_set_scanner_error(parser, "while scanning a %TAG directive", - start_mark, "did not find expected whitespace") - return false - } - - // Eat whitespaces. - for is_blank(parser.buffer, parser.buffer_pos) { - skip(parser) - if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) { - return false - } - } - - // Scan a prefix. - if !yaml_parser_scan_tag_uri(parser, true, nil, start_mark, &prefix_value) { - return false - } - - // Expect a whitespace or line break. - if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) { - return false - } - if !is_blankz(parser.buffer, parser.buffer_pos) { - yaml_parser_set_scanner_error(parser, "while scanning a %TAG directive", - start_mark, "did not find expected whitespace or line break") - return false - } - - *handle = handle_value - *prefix = prefix_value - return true -} - -func yaml_parser_scan_anchor(parser *yaml_parser_t, token *yaml_token_t, typ yaml_token_type_t) bool { - var s []byte - - // Eat the indicator character. - start_mark := parser.mark - skip(parser) - - // Consume the value. - if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) { - return false - } - - for is_alpha(parser.buffer, parser.buffer_pos) { - s = read(parser, s) - if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) { - return false - } - } - - end_mark := parser.mark - - /* - * Check if length of the anchor is greater than 0 and it is followed by - * a whitespace character or one of the indicators: - * - * '?', ':', ',', ']', '}', '%', '@', '`'. - */ - - if len(s) == 0 || - !(is_blankz(parser.buffer, parser.buffer_pos) || parser.buffer[parser.buffer_pos] == '?' || - parser.buffer[parser.buffer_pos] == ':' || parser.buffer[parser.buffer_pos] == ',' || - parser.buffer[parser.buffer_pos] == ']' || parser.buffer[parser.buffer_pos] == '}' || - parser.buffer[parser.buffer_pos] == '%' || parser.buffer[parser.buffer_pos] == '@' || - parser.buffer[parser.buffer_pos] == '`') { - context := "while scanning an alias" - if typ == yaml_ANCHOR_TOKEN { - context = "while scanning an anchor" - } - yaml_parser_set_scanner_error(parser, context, start_mark, - "did not find expected alphabetic or numeric character") - return false - } - - // Create a token. - *token = yaml_token_t{ - typ: typ, - start_mark: start_mark, - end_mark: end_mark, - value: s, - } - - return true -} - -/* - * Scan a TAG token. - */ - -func yaml_parser_scan_tag(parser *yaml_parser_t, token *yaml_token_t) bool { - var handle, suffix []byte - - start_mark := parser.mark - - // Check if the tag is in the canonical form. - if parser.unread < 2 && !yaml_parser_update_buffer(parser, 2) { - return false - } - - if parser.buffer[parser.buffer_pos+1] == '<' { - // Keep the handle as '' - - // Eat '!<' - skip(parser) - skip(parser) - - // Consume the tag value. - if !yaml_parser_scan_tag_uri(parser, false, nil, start_mark, &suffix) { - return false - } - - // Check for '>' and eat it. - if parser.buffer[parser.buffer_pos] != '>' { - yaml_parser_set_scanner_error(parser, "while scanning a tag", - start_mark, "did not find the expected '>'") - return false - } - - skip(parser) - } else { - // The tag has either the '!suffix' or the '!handle!suffix' form. - - // First, try to scan a handle. - if !yaml_parser_scan_tag_handle(parser, false, start_mark, &handle) { - return false - } - - // Check if it is, indeed, handle. - if handle[0] == '!' && len(handle) > 1 && handle[len(handle)-1] == '!' { - // Scan the suffix now. - if !yaml_parser_scan_tag_uri(parser, false, nil, start_mark, &suffix) { - return false - } - } else { - // It wasn't a handle after all. Scan the rest of the tag. - if !yaml_parser_scan_tag_uri(parser, false, handle, start_mark, &suffix) { - return false - } - - // Set the handle to '!'. - handle = []byte{'!'} - - // A special case: the '!' tag. Set the handle to '' and the - // suffix to '!'. - if len(suffix) == 0 { - handle, suffix = suffix, handle - } - } - } - - // Check the character which ends the tag. - if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) { - return false - } - if !is_blankz(parser.buffer, parser.buffer_pos) { - yaml_parser_set_scanner_error(parser, "while scanning a tag", - start_mark, "did not find expected whitespace or line break") - return false - } - - end_mark := parser.mark - - // Create a token. - *token = yaml_token_t{ - typ: yaml_TAG_TOKEN, - start_mark: start_mark, - end_mark: end_mark, - value: handle, - suffix: suffix, - } - return true -} - -// Scan a tag handle. -func yaml_parser_scan_tag_handle(parser *yaml_parser_t, directive bool, start_mark yaml_mark_t, handle *[]byte) bool { - // Check the initial '!' character. - if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) { - return false - } - if parser.buffer[parser.buffer_pos] != '!' { - yaml_parser_set_scanner_tag_error(parser, directive, - start_mark, "did not find expected '!'") - return false - } - - var s []byte - - // Copy the '!' character. - s = read(parser, s) - - // Copy all subsequent alphabetical and numerical characters. - if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) { - return false - } - for is_alpha(parser.buffer, parser.buffer_pos) { - s = read(parser, s) - if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) { - return false - } - } - - // Check if the trailing character is '!' and copy it. - if parser.buffer[parser.buffer_pos] == '!' { - s = read(parser, s) - } else { - // It's either the '!' tag or not really a tag handle. If it's a %TAG - // directive, it's an error. If it's a tag token, it must be a part of URI. - if directive && !(s[0] == '!' && s[1] == 0) { - yaml_parser_set_scanner_tag_error(parser, directive, - start_mark, "did not find expected '!'") - return false - } - } - - *handle = s - return true -} - -// Scan a tag. -func yaml_parser_scan_tag_uri(parser *yaml_parser_t, directive bool, head []byte, start_mark yaml_mark_t, uri *[]byte) bool { - //size_t length = head ? strlen((char *)head) : 0 - var s []byte - - // Copy the head if needed. - // - // Note that we don't copy the leading '!' character. - if len(head) > 1 { - s = append(s, head[1:]...) - } - - // Scan the tag. - if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) { - return false - } - - // The set of characters that may appear in URI is as follows: - // - // '0'-'9', 'A'-'Z', 'a'-'z', '_', '-', ';', '/', '?', ':', '@', '&', - // '=', '+', '$', ',', '.', '!', '~', '*', '\'', '(', ')', '[', ']', - // '%'. - // [Go] Convert this into more reasonable logic. - for is_alpha(parser.buffer, parser.buffer_pos) || parser.buffer[parser.buffer_pos] == ';' || - parser.buffer[parser.buffer_pos] == '/' || parser.buffer[parser.buffer_pos] == '?' || - parser.buffer[parser.buffer_pos] == ':' || parser.buffer[parser.buffer_pos] == '@' || - parser.buffer[parser.buffer_pos] == '&' || parser.buffer[parser.buffer_pos] == '=' || - parser.buffer[parser.buffer_pos] == '+' || parser.buffer[parser.buffer_pos] == '$' || - parser.buffer[parser.buffer_pos] == ',' || parser.buffer[parser.buffer_pos] == '.' || - parser.buffer[parser.buffer_pos] == '!' || parser.buffer[parser.buffer_pos] == '~' || - parser.buffer[parser.buffer_pos] == '*' || parser.buffer[parser.buffer_pos] == '\'' || - parser.buffer[parser.buffer_pos] == '(' || parser.buffer[parser.buffer_pos] == ')' || - parser.buffer[parser.buffer_pos] == '[' || parser.buffer[parser.buffer_pos] == ']' || - parser.buffer[parser.buffer_pos] == '%' { - // Check if it is a URI-escape sequence. - if parser.buffer[parser.buffer_pos] == '%' { - if !yaml_parser_scan_uri_escapes(parser, directive, start_mark, &s) { - return false - } - } else { - s = read(parser, s) - } - if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) { - return false - } - } - - // Check if the tag is non-empty. - if len(s) == 0 { - yaml_parser_set_scanner_tag_error(parser, directive, - start_mark, "did not find expected tag URI") - return false - } - *uri = s - return true -} - -// Decode an URI-escape sequence corresponding to a single UTF-8 character. -func yaml_parser_scan_uri_escapes(parser *yaml_parser_t, directive bool, start_mark yaml_mark_t, s *[]byte) bool { - - // Decode the required number of characters. - w := 1024 - for w > 0 { - // Check for a URI-escaped octet. - if parser.unread < 3 && !yaml_parser_update_buffer(parser, 3) { - return false - } - - if !(parser.buffer[parser.buffer_pos] == '%' && - is_hex(parser.buffer, parser.buffer_pos+1) && - is_hex(parser.buffer, parser.buffer_pos+2)) { - return yaml_parser_set_scanner_tag_error(parser, directive, - start_mark, "did not find URI escaped octet") - } - - // Get the octet. - octet := byte((as_hex(parser.buffer, parser.buffer_pos+1) << 4) + as_hex(parser.buffer, parser.buffer_pos+2)) - - // If it is the leading octet, determine the length of the UTF-8 sequence. - if w == 1024 { - w = width(octet) - if w == 0 { - return yaml_parser_set_scanner_tag_error(parser, directive, - start_mark, "found an incorrect leading UTF-8 octet") - } - } else { - // Check if the trailing octet is correct. - if octet&0xC0 != 0x80 { - return yaml_parser_set_scanner_tag_error(parser, directive, - start_mark, "found an incorrect trailing UTF-8 octet") - } - } - - // Copy the octet and move the pointers. - *s = append(*s, octet) - skip(parser) - skip(parser) - skip(parser) - w-- - } - return true -} - -// Scan a block scalar. -func yaml_parser_scan_block_scalar(parser *yaml_parser_t, token *yaml_token_t, literal bool) bool { - // Eat the indicator '|' or '>'. - start_mark := parser.mark - skip(parser) - - // Scan the additional block scalar indicators. - if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) { - return false - } - - // Check for a chomping indicator. - var chomping, increment int - if parser.buffer[parser.buffer_pos] == '+' || parser.buffer[parser.buffer_pos] == '-' { - // Set the chomping method and eat the indicator. - if parser.buffer[parser.buffer_pos] == '+' { - chomping = +1 - } else { - chomping = -1 - } - skip(parser) - - // Check for an indentation indicator. - if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) { - return false - } - if is_digit(parser.buffer, parser.buffer_pos) { - // Check that the intendation is greater than 0. - if parser.buffer[parser.buffer_pos] == '0' { - yaml_parser_set_scanner_error(parser, "while scanning a block scalar", - start_mark, "found an intendation indicator equal to 0") - return false - } - - // Get the intendation level and eat the indicator. - increment = as_digit(parser.buffer, parser.buffer_pos) - skip(parser) - } - - } else if is_digit(parser.buffer, parser.buffer_pos) { - // Do the same as above, but in the opposite order. - - if parser.buffer[parser.buffer_pos] == '0' { - yaml_parser_set_scanner_error(parser, "while scanning a block scalar", - start_mark, "found an intendation indicator equal to 0") - return false - } - increment = as_digit(parser.buffer, parser.buffer_pos) - skip(parser) - - if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) { - return false - } - if parser.buffer[parser.buffer_pos] == '+' || parser.buffer[parser.buffer_pos] == '-' { - if parser.buffer[parser.buffer_pos] == '+' { - chomping = +1 - } else { - chomping = -1 - } - skip(parser) - } - } - - // Eat whitespaces and comments to the end of the line. - if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) { - return false - } - for is_blank(parser.buffer, parser.buffer_pos) { - skip(parser) - if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) { - return false - } - } - if parser.buffer[parser.buffer_pos] == '#' { - for !is_breakz(parser.buffer, parser.buffer_pos) { - skip(parser) - if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) { - return false - } - } - } - - // Check if we are at the end of the line. - if !is_breakz(parser.buffer, parser.buffer_pos) { - yaml_parser_set_scanner_error(parser, "while scanning a block scalar", - start_mark, "did not find expected comment or line break") - return false - } - - // Eat a line break. - if is_break(parser.buffer, parser.buffer_pos) { - if parser.unread < 2 && !yaml_parser_update_buffer(parser, 2) { - return false - } - skip_line(parser) - } - - end_mark := parser.mark - - // Set the intendation level if it was specified. - var indent int - if increment > 0 { - if parser.indent >= 0 { - indent = parser.indent + increment - } else { - indent = increment - } - } - - // Scan the leading line breaks and determine the indentation level if needed. - var s, leading_break, trailing_breaks []byte - if !yaml_parser_scan_block_scalar_breaks(parser, &indent, &trailing_breaks, start_mark, &end_mark) { - return false - } - - // Scan the block scalar content. - if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) { - return false - } - var leading_blank, trailing_blank bool - for parser.mark.column == indent && !is_z(parser.buffer, parser.buffer_pos) { - // We are at the beginning of a non-empty line. - - // Is it a trailing whitespace? - trailing_blank = is_blank(parser.buffer, parser.buffer_pos) - - // Check if we need to fold the leading line break. - if !literal && !leading_blank && !trailing_blank && len(leading_break) > 0 && leading_break[0] == '\n' { - // Do we need to join the lines by space? - if len(trailing_breaks) == 0 { - s = append(s, ' ') - } - } else { - s = append(s, leading_break...) - } - leading_break = leading_break[:0] - - // Append the remaining line breaks. - s = append(s, trailing_breaks...) - trailing_breaks = trailing_breaks[:0] - - // Is it a leading whitespace? - leading_blank = is_blank(parser.buffer, parser.buffer_pos) - - // Consume the current line. - for !is_breakz(parser.buffer, parser.buffer_pos) { - s = read(parser, s) - if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) { - return false - } - } - - // Consume the line break. - if parser.unread < 2 && !yaml_parser_update_buffer(parser, 2) { - return false - } - - leading_break = read_line(parser, leading_break) - - // Eat the following intendation spaces and line breaks. - if !yaml_parser_scan_block_scalar_breaks(parser, &indent, &trailing_breaks, start_mark, &end_mark) { - return false - } - } - - // Chomp the tail. - if chomping != -1 { - s = append(s, leading_break...) - } - if chomping == 1 { - s = append(s, trailing_breaks...) - } - - // Create a token. - *token = yaml_token_t{ - typ: yaml_SCALAR_TOKEN, - start_mark: start_mark, - end_mark: end_mark, - value: s, - style: yaml_LITERAL_SCALAR_STYLE, - } - if !literal { - token.style = yaml_FOLDED_SCALAR_STYLE - } - return true -} - -// Scan intendation spaces and line breaks for a block scalar. Determine the -// intendation level if needed. -func yaml_parser_scan_block_scalar_breaks(parser *yaml_parser_t, indent *int, breaks *[]byte, start_mark yaml_mark_t, end_mark *yaml_mark_t) bool { - *end_mark = parser.mark - - // Eat the intendation spaces and line breaks. - max_indent := 0 - for { - // Eat the intendation spaces. - if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) { - return false - } - for (*indent == 0 || parser.mark.column < *indent) && is_space(parser.buffer, parser.buffer_pos) { - skip(parser) - if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) { - return false - } - } - if parser.mark.column > max_indent { - max_indent = parser.mark.column - } - - // Check for a tab character messing the intendation. - if (*indent == 0 || parser.mark.column < *indent) && is_tab(parser.buffer, parser.buffer_pos) { - return yaml_parser_set_scanner_error(parser, "while scanning a block scalar", - start_mark, "found a tab character where an intendation space is expected") - } - - // Have we found a non-empty line? - if !is_break(parser.buffer, parser.buffer_pos) { - break - } - - // Consume the line break. - if parser.unread < 2 && !yaml_parser_update_buffer(parser, 2) { - return false - } - // [Go] Should really be returning breaks instead. - *breaks = read_line(parser, *breaks) - *end_mark = parser.mark - } - - // Determine the indentation level if needed. - if *indent == 0 { - *indent = max_indent - if *indent < parser.indent+1 { - *indent = parser.indent + 1 - } - if *indent < 1 { - *indent = 1 - } - } - return true -} - -// Scan a quoted scalar. -func yaml_parser_scan_flow_scalar(parser *yaml_parser_t, token *yaml_token_t, single bool) bool { - // Eat the left quote. - start_mark := parser.mark - skip(parser) - - // Consume the content of the quoted scalar. - var s, leading_break, trailing_breaks, whitespaces []byte - for { - // Check that there are no document indicators at the beginning of the line. - if parser.unread < 4 && !yaml_parser_update_buffer(parser, 4) { - return false - } - - if parser.mark.column == 0 && - ((parser.buffer[parser.buffer_pos+0] == '-' && - parser.buffer[parser.buffer_pos+1] == '-' && - parser.buffer[parser.buffer_pos+2] == '-') || - (parser.buffer[parser.buffer_pos+0] == '.' && - parser.buffer[parser.buffer_pos+1] == '.' && - parser.buffer[parser.buffer_pos+2] == '.')) && - is_blankz(parser.buffer, parser.buffer_pos+3) { - yaml_parser_set_scanner_error(parser, "while scanning a quoted scalar", - start_mark, "found unexpected document indicator") - return false - } - - // Check for EOF. - if is_z(parser.buffer, parser.buffer_pos) { - yaml_parser_set_scanner_error(parser, "while scanning a quoted scalar", - start_mark, "found unexpected end of stream") - return false - } - - // Consume non-blank characters. - leading_blanks := false - for !is_blankz(parser.buffer, parser.buffer_pos) { - if single && parser.buffer[parser.buffer_pos] == '\'' && parser.buffer[parser.buffer_pos+1] == '\'' { - // Is is an escaped single quote. - s = append(s, '\'') - skip(parser) - skip(parser) - - } else if single && parser.buffer[parser.buffer_pos] == '\'' { - // It is a right single quote. - break - } else if !single && parser.buffer[parser.buffer_pos] == '"' { - // It is a right double quote. - break - - } else if !single && parser.buffer[parser.buffer_pos] == '\\' && is_break(parser.buffer, parser.buffer_pos+1) { - // It is an escaped line break. - if parser.unread < 3 && !yaml_parser_update_buffer(parser, 3) { - return false - } - skip(parser) - skip_line(parser) - leading_blanks = true - break - - } else if !single && parser.buffer[parser.buffer_pos] == '\\' { - // It is an escape sequence. - code_length := 0 - - // Check the escape character. - switch parser.buffer[parser.buffer_pos+1] { - case '0': - s = append(s, 0) - case 'a': - s = append(s, '\x07') - case 'b': - s = append(s, '\x08') - case 't', '\t': - s = append(s, '\x09') - case 'n': - s = append(s, '\x0A') - case 'v': - s = append(s, '\x0B') - case 'f': - s = append(s, '\x0C') - case 'r': - s = append(s, '\x0D') - case 'e': - s = append(s, '\x1B') - case ' ': - s = append(s, '\x20') - case '"': - s = append(s, '"') - case '\'': - s = append(s, '\'') - case '\\': - s = append(s, '\\') - case 'N': // NEL (#x85) - s = append(s, '\xC2') - s = append(s, '\x85') - case '_': // #xA0 - s = append(s, '\xC2') - s = append(s, '\xA0') - case 'L': // LS (#x2028) - s = append(s, '\xE2') - s = append(s, '\x80') - s = append(s, '\xA8') - case 'P': // PS (#x2029) - s = append(s, '\xE2') - s = append(s, '\x80') - s = append(s, '\xA9') - case 'x': - code_length = 2 - case 'u': - code_length = 4 - case 'U': - code_length = 8 - default: - yaml_parser_set_scanner_error(parser, "while parsing a quoted scalar", - start_mark, "found unknown escape character") - return false - } - - skip(parser) - skip(parser) - - // Consume an arbitrary escape code. - if code_length > 0 { - var value int - - // Scan the character value. - if parser.unread < code_length && !yaml_parser_update_buffer(parser, code_length) { - return false - } - for k := 0; k < code_length; k++ { - if !is_hex(parser.buffer, parser.buffer_pos+k) { - yaml_parser_set_scanner_error(parser, "while parsing a quoted scalar", - start_mark, "did not find expected hexdecimal number") - return false - } - value = (value << 4) + as_hex(parser.buffer, parser.buffer_pos+k) - } - - // Check the value and write the character. - if (value >= 0xD800 && value <= 0xDFFF) || value > 0x10FFFF { - yaml_parser_set_scanner_error(parser, "while parsing a quoted scalar", - start_mark, "found invalid Unicode character escape code") - return false - } - if value <= 0x7F { - s = append(s, byte(value)) - } else if value <= 0x7FF { - s = append(s, byte(0xC0+(value>>6))) - s = append(s, byte(0x80+(value&0x3F))) - } else if value <= 0xFFFF { - s = append(s, byte(0xE0+(value>>12))) - s = append(s, byte(0x80+((value>>6)&0x3F))) - s = append(s, byte(0x80+(value&0x3F))) - } else { - s = append(s, byte(0xF0+(value>>18))) - s = append(s, byte(0x80+((value>>12)&0x3F))) - s = append(s, byte(0x80+((value>>6)&0x3F))) - s = append(s, byte(0x80+(value&0x3F))) - } - - // Advance the pointer. - for k := 0; k < code_length; k++ { - skip(parser) - } - } - } else { - // It is a non-escaped non-blank character. - s = read(parser, s) - } - if parser.unread < 2 && !yaml_parser_update_buffer(parser, 2) { - return false - } - } - - // Check if we are at the end of the scalar. - if single { - if parser.buffer[parser.buffer_pos] == '\'' { - break - } - } else { - if parser.buffer[parser.buffer_pos] == '"' { - break - } - } - - // Consume blank characters. - if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) { - return false - } - - for is_blank(parser.buffer, parser.buffer_pos) || is_break(parser.buffer, parser.buffer_pos) { - if is_blank(parser.buffer, parser.buffer_pos) { - // Consume a space or a tab character. - if !leading_blanks { - whitespaces = read(parser, whitespaces) - } else { - skip(parser) - } - } else { - if parser.unread < 2 && !yaml_parser_update_buffer(parser, 2) { - return false - } - - // Check if it is a first line break. - if !leading_blanks { - whitespaces = whitespaces[:0] - leading_break = read_line(parser, leading_break) - leading_blanks = true - } else { - trailing_breaks = read_line(parser, trailing_breaks) - } - } - if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) { - return false - } - } - - // Join the whitespaces or fold line breaks. - if leading_blanks { - // Do we need to fold line breaks? - if len(leading_break) > 0 && leading_break[0] == '\n' { - if len(trailing_breaks) == 0 { - s = append(s, ' ') - } else { - s = append(s, trailing_breaks...) - } - } else { - s = append(s, leading_break...) - s = append(s, trailing_breaks...) - } - trailing_breaks = trailing_breaks[:0] - leading_break = leading_break[:0] - } else { - s = append(s, whitespaces...) - whitespaces = whitespaces[:0] - } - } - - // Eat the right quote. - skip(parser) - end_mark := parser.mark - - // Create a token. - *token = yaml_token_t{ - typ: yaml_SCALAR_TOKEN, - start_mark: start_mark, - end_mark: end_mark, - value: s, - style: yaml_SINGLE_QUOTED_SCALAR_STYLE, - } - if !single { - token.style = yaml_DOUBLE_QUOTED_SCALAR_STYLE - } - return true -} - -// Scan a plain scalar. -func yaml_parser_scan_plain_scalar(parser *yaml_parser_t, token *yaml_token_t) bool { - - var s, leading_break, trailing_breaks, whitespaces []byte - var leading_blanks bool - var indent = parser.indent + 1 - - start_mark := parser.mark - end_mark := parser.mark - - // Consume the content of the plain scalar. - for { - // Check for a document indicator. - if parser.unread < 4 && !yaml_parser_update_buffer(parser, 4) { - return false - } - if parser.mark.column == 0 && - ((parser.buffer[parser.buffer_pos+0] == '-' && - parser.buffer[parser.buffer_pos+1] == '-' && - parser.buffer[parser.buffer_pos+2] == '-') || - (parser.buffer[parser.buffer_pos+0] == '.' && - parser.buffer[parser.buffer_pos+1] == '.' && - parser.buffer[parser.buffer_pos+2] == '.')) && - is_blankz(parser.buffer, parser.buffer_pos+3) { - break - } - - // Check for a comment. - if parser.buffer[parser.buffer_pos] == '#' { - break - } - - // Consume non-blank characters. - for !is_blankz(parser.buffer, parser.buffer_pos) { - - // Check for 'x:x' in the flow context. TODO: Fix the test "spec-08-13". - if parser.flow_level > 0 && - parser.buffer[parser.buffer_pos] == ':' && - !is_blankz(parser.buffer, parser.buffer_pos+1) { - yaml_parser_set_scanner_error(parser, "while scanning a plain scalar", - start_mark, "found unexpected ':'") - return false - } - - // Check for indicators that may end a plain scalar. - if (parser.buffer[parser.buffer_pos] == ':' && is_blankz(parser.buffer, parser.buffer_pos+1)) || - (parser.flow_level > 0 && - (parser.buffer[parser.buffer_pos] == ',' || parser.buffer[parser.buffer_pos] == ':' || - parser.buffer[parser.buffer_pos] == '?' || parser.buffer[parser.buffer_pos] == '[' || - parser.buffer[parser.buffer_pos] == ']' || parser.buffer[parser.buffer_pos] == '{' || - parser.buffer[parser.buffer_pos] == '}')) { - break - } - - // Check if we need to join whitespaces and breaks. - if leading_blanks || len(whitespaces) > 0 { - if leading_blanks { - // Do we need to fold line breaks? - if leading_break[0] == '\n' { - if len(trailing_breaks) == 0 { - s = append(s, ' ') - } else { - s = append(s, trailing_breaks...) - } - } else { - s = append(s, leading_break...) - s = append(s, trailing_breaks...) - } - trailing_breaks = trailing_breaks[:0] - leading_break = leading_break[:0] - leading_blanks = false - } else { - s = append(s, whitespaces...) - whitespaces = whitespaces[:0] - } - } - - // Copy the character. - s = read(parser, s) - - end_mark = parser.mark - if parser.unread < 2 && !yaml_parser_update_buffer(parser, 2) { - return false - } - } - - // Is it the end? - if !(is_blank(parser.buffer, parser.buffer_pos) || is_break(parser.buffer, parser.buffer_pos)) { - break - } - - // Consume blank characters. - if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) { - return false - } - - for is_blank(parser.buffer, parser.buffer_pos) || is_break(parser.buffer, parser.buffer_pos) { - if is_blank(parser.buffer, parser.buffer_pos) { - - // Check for tab character that abuse intendation. - if leading_blanks && parser.mark.column < indent && is_tab(parser.buffer, parser.buffer_pos) { - yaml_parser_set_scanner_error(parser, "while scanning a plain scalar", - start_mark, "found a tab character that violate intendation") - return false - } - - // Consume a space or a tab character. - if !leading_blanks { - whitespaces = read(parser, whitespaces) - } else { - skip(parser) - } - } else { - if parser.unread < 2 && !yaml_parser_update_buffer(parser, 2) { - return false - } - - // Check if it is a first line break. - if !leading_blanks { - whitespaces = whitespaces[:0] - leading_break = read_line(parser, leading_break) - leading_blanks = true - } else { - trailing_breaks = read_line(parser, trailing_breaks) - } - } - if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) { - return false - } - } - - // Check intendation level. - if parser.flow_level == 0 && parser.mark.column < indent { - break - } - } - - // Create a token. - *token = yaml_token_t{ - typ: yaml_SCALAR_TOKEN, - start_mark: start_mark, - end_mark: end_mark, - value: s, - style: yaml_PLAIN_SCALAR_STYLE, - } - - // Note that we change the 'simple_key_allowed' flag. - if leading_blanks { - parser.simple_key_allowed = true - } - return true -} diff --git a/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/coreos/yaml/sorter.go b/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/coreos/yaml/sorter.go deleted file mode 100644 index 5958822f..00000000 --- a/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/coreos/yaml/sorter.go +++ /dev/null @@ -1,104 +0,0 @@ -package yaml - -import ( - "reflect" - "unicode" -) - -type keyList []reflect.Value - -func (l keyList) Len() int { return len(l) } -func (l keyList) Swap(i, j int) { l[i], l[j] = l[j], l[i] } -func (l keyList) Less(i, j int) bool { - a := l[i] - b := l[j] - ak := a.Kind() - bk := b.Kind() - for (ak == reflect.Interface || ak == reflect.Ptr) && !a.IsNil() { - a = a.Elem() - ak = a.Kind() - } - for (bk == reflect.Interface || bk == reflect.Ptr) && !b.IsNil() { - b = b.Elem() - bk = b.Kind() - } - af, aok := keyFloat(a) - bf, bok := keyFloat(b) - if aok && bok { - if af != bf { - return af < bf - } - if ak != bk { - return ak < bk - } - return numLess(a, b) - } - if ak != reflect.String || bk != reflect.String { - return ak < bk - } - ar, br := []rune(a.String()), []rune(b.String()) - for i := 0; i < len(ar) && i < len(br); i++ { - if ar[i] == br[i] { - continue - } - al := unicode.IsLetter(ar[i]) - bl := unicode.IsLetter(br[i]) - if al && bl { - return ar[i] < br[i] - } - if al || bl { - return bl - } - var ai, bi int - var an, bn int64 - for ai = i; ai < len(ar) && unicode.IsDigit(ar[ai]); ai++ { - an = an*10 + int64(ar[ai]-'0') - } - for bi = i; bi < len(br) && unicode.IsDigit(br[bi]); bi++ { - bn = bn*10 + int64(br[bi]-'0') - } - if an != bn { - return an < bn - } - if ai != bi { - return ai < bi - } - return ar[i] < br[i] - } - return len(ar) < len(br) -} - -// keyFloat returns a float value for v if it is a number/bool -// and whether it is a number/bool or not. -func keyFloat(v reflect.Value) (f float64, ok bool) { - switch v.Kind() { - case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: - return float64(v.Int()), true - case reflect.Float32, reflect.Float64: - return v.Float(), true - case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr: - return float64(v.Uint()), true - case reflect.Bool: - if v.Bool() { - return 1, true - } - return 0, true - } - return 0, false -} - -// numLess returns whether a < b. -// a and b must necessarily have the same kind. -func numLess(a, b reflect.Value) bool { - switch a.Kind() { - case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: - return a.Int() < b.Int() - case reflect.Float32, reflect.Float64: - return a.Float() < b.Float() - case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr: - return a.Uint() < b.Uint() - case reflect.Bool: - return !a.Bool() && b.Bool() - } - panic("not a number") -} diff --git a/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/coreos/yaml/suite_test.go b/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/coreos/yaml/suite_test.go deleted file mode 100644 index c5cf1ed4..00000000 --- a/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/coreos/yaml/suite_test.go +++ /dev/null @@ -1,12 +0,0 @@ -package yaml_test - -import ( - . "gopkg.in/check.v1" - "testing" -) - -func Test(t *testing.T) { TestingT(t) } - -type S struct{} - -var _ = Suite(&S{}) diff --git a/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/coreos/yaml/writerc.go b/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/coreos/yaml/writerc.go deleted file mode 100644 index 190362f2..00000000 --- a/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/coreos/yaml/writerc.go +++ /dev/null @@ -1,89 +0,0 @@ -package yaml - -// Set the writer error and return false. -func yaml_emitter_set_writer_error(emitter *yaml_emitter_t, problem string) bool { - emitter.error = yaml_WRITER_ERROR - emitter.problem = problem - return false -} - -// Flush the output buffer. -func yaml_emitter_flush(emitter *yaml_emitter_t) bool { - if emitter.write_handler == nil { - panic("write handler not set") - } - - // Check if the buffer is empty. - if emitter.buffer_pos == 0 { - return true - } - - // If the output encoding is UTF-8, we don't need to recode the buffer. - if emitter.encoding == yaml_UTF8_ENCODING { - if err := emitter.write_handler(emitter, emitter.buffer[:emitter.buffer_pos]); err != nil { - return yaml_emitter_set_writer_error(emitter, "write error: "+err.Error()) - } - emitter.buffer_pos = 0 - return true - } - - // Recode the buffer into the raw buffer. - var low, high int - if emitter.encoding == yaml_UTF16LE_ENCODING { - low, high = 0, 1 - } else { - high, low = 1, 0 - } - - pos := 0 - for pos < emitter.buffer_pos { - // See the "reader.c" code for more details on UTF-8 encoding. Note - // that we assume that the buffer contains a valid UTF-8 sequence. - - // Read the next UTF-8 character. - octet := emitter.buffer[pos] - - var w int - var value rune - switch { - case octet&0x80 == 0x00: - w, value = 1, rune(octet&0x7F) - case octet&0xE0 == 0xC0: - w, value = 2, rune(octet&0x1F) - case octet&0xF0 == 0xE0: - w, value = 3, rune(octet&0x0F) - case octet&0xF8 == 0xF0: - w, value = 4, rune(octet&0x07) - } - for k := 1; k < w; k++ { - octet = emitter.buffer[pos+k] - value = (value << 6) + (rune(octet) & 0x3F) - } - pos += w - - // Write the character. - if value < 0x10000 { - var b [2]byte - b[high] = byte(value >> 8) - b[low] = byte(value & 0xFF) - emitter.raw_buffer = append(emitter.raw_buffer, b[0], b[1]) - } else { - // Write the character using a surrogate pair (check "reader.c"). - var b [4]byte - value -= 0x10000 - b[high] = byte(0xD8 + (value >> 18)) - b[low] = byte((value >> 10) & 0xFF) - b[high+2] = byte(0xDC + ((value >> 8) & 0xFF)) - b[low+2] = byte(value & 0xFF) - emitter.raw_buffer = append(emitter.raw_buffer, b[0], b[1], b[2], b[3]) - } - } - - // Write the raw buffer. - if err := emitter.write_handler(emitter, emitter.raw_buffer); err != nil { - return yaml_emitter_set_writer_error(emitter, "write error: "+err.Error()) - } - emitter.buffer_pos = 0 - emitter.raw_buffer = emitter.raw_buffer[:0] - return true -} diff --git a/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/coreos/yaml/yaml.go b/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/coreos/yaml/yaml.go deleted file mode 100644 index 16e13654..00000000 --- a/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/coreos/yaml/yaml.go +++ /dev/null @@ -1,312 +0,0 @@ -// Package yaml implements YAML support for the Go language. -// -// Source code and other details for the project are available at GitHub: -// -// https://github.com/go-yaml/yaml -// -package yaml - -import ( - "errors" - "fmt" - "reflect" - "strings" - "sync" -) - -type yamlError string - -func fail(msg string) { - panic(yamlError(msg)) -} - -func handleErr(err *error) { - if r := recover(); r != nil { - if e, ok := r.(yamlError); ok { - *err = errors.New("YAML error: " + string(e)) - } else { - panic(r) - } - } -} - -// The Setter interface may be implemented by types to do their own custom -// unmarshalling of YAML values, rather than being implicitly assigned by -// the yaml package machinery. If setting the value works, the method should -// return true. If it returns false, the value is considered unsupported -// and is omitted from maps and slices. -type Setter interface { - SetYAML(tag string, value interface{}) bool -} - -// The Getter interface is implemented by types to do their own custom -// marshalling into a YAML tag and value. -type Getter interface { - GetYAML() (tag string, value interface{}) -} - -// Unmarshal decodes the first document found within the in byte slice -// and assigns decoded values into the out value. -// -// Maps and pointers (to a struct, string, int, etc) are accepted as out -// values. If an internal pointer within a struct is not initialized, -// the yaml package will initialize it if necessary for unmarshalling -// the provided data. The out parameter must not be nil. -// -// The type of the decoded values and the type of out will be considered, -// and Unmarshal will do the best possible job to unmarshal values -// appropriately. It is NOT considered an error, though, to skip values -// because they are not available in the decoded YAML, or if they are not -// compatible with the out value. To ensure something was properly -// unmarshaled use a map or compare against the previous value for the -// field (usually the zero value). -// -// Struct fields are only unmarshalled if they are exported (have an -// upper case first letter), and are unmarshalled using the field name -// lowercased as the default key. Custom keys may be defined via the -// "yaml" name in the field tag: the content preceding the first comma -// is used as the key, and the following comma-separated options are -// used to tweak the marshalling process (see Marshal). -// Conflicting names result in a runtime error. -// -// For example: -// -// type T struct { -// F int `yaml:"a,omitempty"` -// B int -// } -// var t T -// yaml.Unmarshal([]byte("a: 1\nb: 2"), &t) -// -// See the documentation of Marshal for the format of tags and a list of -// supported tag options. -// -func Unmarshal(in []byte, out interface{}) (err error) { - defer handleErr(&err) - d := newDecoder() - p := newParser(in, UnmarshalMappingKeyTransform) - defer p.destroy() - node := p.parse() - if node != nil { - v := reflect.ValueOf(out) - if v.Kind() == reflect.Ptr && !v.IsNil() { - v = v.Elem() - } - d.unmarshal(node, v) - } - return nil -} - -// Marshal serializes the value provided into a YAML document. The structure -// of the generated document will reflect the structure of the value itself. -// Maps and pointers (to struct, string, int, etc) are accepted as the in value. -// -// Struct fields are only unmarshalled if they are exported (have an upper case -// first letter), and are unmarshalled using the field name lowercased as the -// default key. Custom keys may be defined via the "yaml" name in the field -// tag: the content preceding the first comma is used as the key, and the -// following comma-separated options are used to tweak the marshalling process. -// Conflicting names result in a runtime error. -// -// The field tag format accepted is: -// -// `(...) yaml:"[<key>][,<flag1>[,<flag2>]]" (...)` -// -// The following flags are currently supported: -// -// omitempty Only include the field if it's not set to the zero -// value for the type or to empty slices or maps. -// Does not apply to zero valued structs. -// -// flow Marshal using a flow style (useful for structs, -// sequences and maps. -// -// inline Inline the struct it's applied to, so its fields -// are processed as if they were part of the outer -// struct. -// -// In addition, if the key is "-", the field is ignored. -// -// For example: -// -// type T struct { -// F int "a,omitempty" -// B int -// } -// yaml.Marshal(&T{B: 2}) // Returns "b: 2\n" -// yaml.Marshal(&T{F: 1}} // Returns "a: 1\nb: 0\n" -// -func Marshal(in interface{}) (out []byte, err error) { - defer handleErr(&err) - e := newEncoder() - defer e.destroy() - e.marshal("", reflect.ValueOf(in)) - e.finish() - out = e.out - return -} - -// UnmarshalMappingKeyTransform is a string transformation that is applied to -// each mapping key in a YAML document before it is unmarshalled. By default, -// UnmarshalMappingKeyTransform is an identity transform (no modification). -var UnmarshalMappingKeyTransform transformString = identityTransform - -type transformString func(in string) (out string) - -func identityTransform(in string) (out string) { - return in -} - -// -------------------------------------------------------------------------- -// Maintain a mapping of keys to structure field indexes - -// The code in this section was copied from mgo/bson. - -// structInfo holds details for the serialization of fields of -// a given struct. -type structInfo struct { - FieldsMap map[string]fieldInfo - FieldsList []fieldInfo - - // InlineMap is the number of the field in the struct that - // contains an ,inline map, or -1 if there's none. - InlineMap int -} - -type fieldInfo struct { - Key string - Num int - OmitEmpty bool - Flow bool - - // Inline holds the field index if the field is part of an inlined struct. - Inline []int -} - -var structMap = make(map[reflect.Type]*structInfo) -var fieldMapMutex sync.RWMutex - -func getStructInfo(st reflect.Type) (*structInfo, error) { - fieldMapMutex.RLock() - sinfo, found := structMap[st] - fieldMapMutex.RUnlock() - if found { - return sinfo, nil - } - - n := st.NumField() - fieldsMap := make(map[string]fieldInfo) - fieldsList := make([]fieldInfo, 0, n) - inlineMap := -1 - for i := 0; i != n; i++ { - field := st.Field(i) - if field.PkgPath != "" { - continue // Private field - } - - info := fieldInfo{Num: i} - - tag := field.Tag.Get("yaml") - if tag == "" && strings.Index(string(field.Tag), ":") < 0 { - tag = string(field.Tag) - } - if tag == "-" { - continue - } - - inline := false - fields := strings.Split(tag, ",") - if len(fields) > 1 { - for _, flag := range fields[1:] { - switch flag { - case "omitempty": - info.OmitEmpty = true - case "flow": - info.Flow = true - case "inline": - inline = true - default: - return nil, errors.New(fmt.Sprintf("Unsupported flag %q in tag %q of type %s", flag, tag, st)) - } - } - tag = fields[0] - } - - if inline { - switch field.Type.Kind() { - // TODO: Implement support for inline maps. - //case reflect.Map: - // if inlineMap >= 0 { - // return nil, errors.New("Multiple ,inline maps in struct " + st.String()) - // } - // if field.Type.Key() != reflect.TypeOf("") { - // return nil, errors.New("Option ,inline needs a map with string keys in struct " + st.String()) - // } - // inlineMap = info.Num - case reflect.Struct: - sinfo, err := getStructInfo(field.Type) - if err != nil { - return nil, err - } - for _, finfo := range sinfo.FieldsList { - if _, found := fieldsMap[finfo.Key]; found { - msg := "Duplicated key '" + finfo.Key + "' in struct " + st.String() - return nil, errors.New(msg) - } - if finfo.Inline == nil { - finfo.Inline = []int{i, finfo.Num} - } else { - finfo.Inline = append([]int{i}, finfo.Inline...) - } - fieldsMap[finfo.Key] = finfo - fieldsList = append(fieldsList, finfo) - } - default: - //return nil, errors.New("Option ,inline needs a struct value or map field") - return nil, errors.New("Option ,inline needs a struct value field") - } - continue - } - - if tag != "" { - info.Key = tag - } else { - info.Key = strings.ToLower(field.Name) - } - - if _, found = fieldsMap[info.Key]; found { - msg := "Duplicated key '" + info.Key + "' in struct " + st.String() - return nil, errors.New(msg) - } - - fieldsList = append(fieldsList, info) - fieldsMap[info.Key] = info - } - - sinfo = &structInfo{fieldsMap, fieldsList, inlineMap} - - fieldMapMutex.Lock() - structMap[st] = sinfo - fieldMapMutex.Unlock() - return sinfo, nil -} - -func isZero(v reflect.Value) bool { - switch v.Kind() { - case reflect.String: - return len(v.String()) == 0 - case reflect.Interface, reflect.Ptr: - return v.IsNil() - case reflect.Slice: - return v.Len() == 0 - case reflect.Map: - return v.Len() == 0 - case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: - return v.Int() == 0 - case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr: - return v.Uint() == 0 - case reflect.Bool: - return !v.Bool() - } - return false -} diff --git a/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/coreos/yaml/yamlh.go b/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/coreos/yaml/yamlh.go deleted file mode 100644 index 4b020b1b..00000000 --- a/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/coreos/yaml/yamlh.go +++ /dev/null @@ -1,716 +0,0 @@ -package yaml - -import ( - "io" -) - -// The version directive data. -type yaml_version_directive_t struct { - major int8 // The major version number. - minor int8 // The minor version number. -} - -// The tag directive data. -type yaml_tag_directive_t struct { - handle []byte // The tag handle. - prefix []byte // The tag prefix. -} - -type yaml_encoding_t int - -// The stream encoding. -const ( - // Let the parser choose the encoding. - yaml_ANY_ENCODING yaml_encoding_t = iota - - yaml_UTF8_ENCODING // The default UTF-8 encoding. - yaml_UTF16LE_ENCODING // The UTF-16-LE encoding with BOM. - yaml_UTF16BE_ENCODING // The UTF-16-BE encoding with BOM. -) - -type yaml_break_t int - -// Line break types. -const ( - // Let the parser choose the break type. - yaml_ANY_BREAK yaml_break_t = iota - - yaml_CR_BREAK // Use CR for line breaks (Mac style). - yaml_LN_BREAK // Use LN for line breaks (Unix style). - yaml_CRLN_BREAK // Use CR LN for line breaks (DOS style). -) - -type yaml_error_type_t int - -// Many bad things could happen with the parser and emitter. -const ( - // No error is produced. - yaml_NO_ERROR yaml_error_type_t = iota - - yaml_MEMORY_ERROR // Cannot allocate or reallocate a block of memory. - yaml_READER_ERROR // Cannot read or decode the input stream. - yaml_SCANNER_ERROR // Cannot scan the input stream. - yaml_PARSER_ERROR // Cannot parse the input stream. - yaml_COMPOSER_ERROR // Cannot compose a YAML document. - yaml_WRITER_ERROR // Cannot write to the output stream. - yaml_EMITTER_ERROR // Cannot emit a YAML stream. -) - -// The pointer position. -type yaml_mark_t struct { - index int // The position index. - line int // The position line. - column int // The position column. -} - -// Node Styles - -type yaml_style_t int8 - -type yaml_scalar_style_t yaml_style_t - -// Scalar styles. -const ( - // Let the emitter choose the style. - yaml_ANY_SCALAR_STYLE yaml_scalar_style_t = iota - - yaml_PLAIN_SCALAR_STYLE // The plain scalar style. - yaml_SINGLE_QUOTED_SCALAR_STYLE // The single-quoted scalar style. - yaml_DOUBLE_QUOTED_SCALAR_STYLE // The double-quoted scalar style. - yaml_LITERAL_SCALAR_STYLE // The literal scalar style. - yaml_FOLDED_SCALAR_STYLE // The folded scalar style. -) - -type yaml_sequence_style_t yaml_style_t - -// Sequence styles. -const ( - // Let the emitter choose the style. - yaml_ANY_SEQUENCE_STYLE yaml_sequence_style_t = iota - - yaml_BLOCK_SEQUENCE_STYLE // The block sequence style. - yaml_FLOW_SEQUENCE_STYLE // The flow sequence style. -) - -type yaml_mapping_style_t yaml_style_t - -// Mapping styles. -const ( - // Let the emitter choose the style. - yaml_ANY_MAPPING_STYLE yaml_mapping_style_t = iota - - yaml_BLOCK_MAPPING_STYLE // The block mapping style. - yaml_FLOW_MAPPING_STYLE // The flow mapping style. -) - -// Tokens - -type yaml_token_type_t int - -// Token types. -const ( - // An empty token. - yaml_NO_TOKEN yaml_token_type_t = iota - - yaml_STREAM_START_TOKEN // A STREAM-START token. - yaml_STREAM_END_TOKEN // A STREAM-END token. - - yaml_VERSION_DIRECTIVE_TOKEN // A VERSION-DIRECTIVE token. - yaml_TAG_DIRECTIVE_TOKEN // A TAG-DIRECTIVE token. - yaml_DOCUMENT_START_TOKEN // A DOCUMENT-START token. - yaml_DOCUMENT_END_TOKEN // A DOCUMENT-END token. - - yaml_BLOCK_SEQUENCE_START_TOKEN // A BLOCK-SEQUENCE-START token. - yaml_BLOCK_MAPPING_START_TOKEN // A BLOCK-SEQUENCE-END token. - yaml_BLOCK_END_TOKEN // A BLOCK-END token. - - yaml_FLOW_SEQUENCE_START_TOKEN // A FLOW-SEQUENCE-START token. - yaml_FLOW_SEQUENCE_END_TOKEN // A FLOW-SEQUENCE-END token. - yaml_FLOW_MAPPING_START_TOKEN // A FLOW-MAPPING-START token. - yaml_FLOW_MAPPING_END_TOKEN // A FLOW-MAPPING-END token. - - yaml_BLOCK_ENTRY_TOKEN // A BLOCK-ENTRY token. - yaml_FLOW_ENTRY_TOKEN // A FLOW-ENTRY token. - yaml_KEY_TOKEN // A KEY token. - yaml_VALUE_TOKEN // A VALUE token. - - yaml_ALIAS_TOKEN // An ALIAS token. - yaml_ANCHOR_TOKEN // An ANCHOR token. - yaml_TAG_TOKEN // A TAG token. - yaml_SCALAR_TOKEN // A SCALAR token. -) - -func (tt yaml_token_type_t) String() string { - switch tt { - case yaml_NO_TOKEN: - return "yaml_NO_TOKEN" - case yaml_STREAM_START_TOKEN: - return "yaml_STREAM_START_TOKEN" - case yaml_STREAM_END_TOKEN: - return "yaml_STREAM_END_TOKEN" - case yaml_VERSION_DIRECTIVE_TOKEN: - return "yaml_VERSION_DIRECTIVE_TOKEN" - case yaml_TAG_DIRECTIVE_TOKEN: - return "yaml_TAG_DIRECTIVE_TOKEN" - case yaml_DOCUMENT_START_TOKEN: - return "yaml_DOCUMENT_START_TOKEN" - case yaml_DOCUMENT_END_TOKEN: - return "yaml_DOCUMENT_END_TOKEN" - case yaml_BLOCK_SEQUENCE_START_TOKEN: - return "yaml_BLOCK_SEQUENCE_START_TOKEN" - case yaml_BLOCK_MAPPING_START_TOKEN: - return "yaml_BLOCK_MAPPING_START_TOKEN" - case yaml_BLOCK_END_TOKEN: - return "yaml_BLOCK_END_TOKEN" - case yaml_FLOW_SEQUENCE_START_TOKEN: - return "yaml_FLOW_SEQUENCE_START_TOKEN" - case yaml_FLOW_SEQUENCE_END_TOKEN: - return "yaml_FLOW_SEQUENCE_END_TOKEN" - case yaml_FLOW_MAPPING_START_TOKEN: - return "yaml_FLOW_MAPPING_START_TOKEN" - case yaml_FLOW_MAPPING_END_TOKEN: - return "yaml_FLOW_MAPPING_END_TOKEN" - case yaml_BLOCK_ENTRY_TOKEN: - return "yaml_BLOCK_ENTRY_TOKEN" - case yaml_FLOW_ENTRY_TOKEN: - return "yaml_FLOW_ENTRY_TOKEN" - case yaml_KEY_TOKEN: - return "yaml_KEY_TOKEN" - case yaml_VALUE_TOKEN: - return "yaml_VALUE_TOKEN" - case yaml_ALIAS_TOKEN: - return "yaml_ALIAS_TOKEN" - case yaml_ANCHOR_TOKEN: - return "yaml_ANCHOR_TOKEN" - case yaml_TAG_TOKEN: - return "yaml_TAG_TOKEN" - case yaml_SCALAR_TOKEN: - return "yaml_SCALAR_TOKEN" - } - return "<unknown token>" -} - -// The token structure. -type yaml_token_t struct { - // The token type. - typ yaml_token_type_t - - // The start/end of the token. - start_mark, end_mark yaml_mark_t - - // The stream encoding (for yaml_STREAM_START_TOKEN). - encoding yaml_encoding_t - - // The alias/anchor/scalar value or tag/tag directive handle - // (for yaml_ALIAS_TOKEN, yaml_ANCHOR_TOKEN, yaml_SCALAR_TOKEN, yaml_TAG_TOKEN, yaml_TAG_DIRECTIVE_TOKEN). - value []byte - - // The tag suffix (for yaml_TAG_TOKEN). - suffix []byte - - // The tag directive prefix (for yaml_TAG_DIRECTIVE_TOKEN). - prefix []byte - - // The scalar style (for yaml_SCALAR_TOKEN). - style yaml_scalar_style_t - - // The version directive major/minor (for yaml_VERSION_DIRECTIVE_TOKEN). - major, minor int8 -} - -// Events - -type yaml_event_type_t int8 - -// Event types. -const ( - // An empty event. - yaml_NO_EVENT yaml_event_type_t = iota - - yaml_STREAM_START_EVENT // A STREAM-START event. - yaml_STREAM_END_EVENT // A STREAM-END event. - yaml_DOCUMENT_START_EVENT // A DOCUMENT-START event. - yaml_DOCUMENT_END_EVENT // A DOCUMENT-END event. - yaml_ALIAS_EVENT // An ALIAS event. - yaml_SCALAR_EVENT // A SCALAR event. - yaml_SEQUENCE_START_EVENT // A SEQUENCE-START event. - yaml_SEQUENCE_END_EVENT // A SEQUENCE-END event. - yaml_MAPPING_START_EVENT // A MAPPING-START event. - yaml_MAPPING_END_EVENT // A MAPPING-END event. -) - -// The event structure. -type yaml_event_t struct { - - // The event type. - typ yaml_event_type_t - - // The start and end of the event. - start_mark, end_mark yaml_mark_t - - // The document encoding (for yaml_STREAM_START_EVENT). - encoding yaml_encoding_t - - // The version directive (for yaml_DOCUMENT_START_EVENT). - version_directive *yaml_version_directive_t - - // The list of tag directives (for yaml_DOCUMENT_START_EVENT). - tag_directives []yaml_tag_directive_t - - // The anchor (for yaml_SCALAR_EVENT, yaml_SEQUENCE_START_EVENT, yaml_MAPPING_START_EVENT, yaml_ALIAS_EVENT). - anchor []byte - - // The tag (for yaml_SCALAR_EVENT, yaml_SEQUENCE_START_EVENT, yaml_MAPPING_START_EVENT). - tag []byte - - // The scalar value (for yaml_SCALAR_EVENT). - value []byte - - // Is the document start/end indicator implicit, or the tag optional? - // (for yaml_DOCUMENT_START_EVENT, yaml_DOCUMENT_END_EVENT, yaml_SEQUENCE_START_EVENT, yaml_MAPPING_START_EVENT, yaml_SCALAR_EVENT). - implicit bool - - // Is the tag optional for any non-plain style? (for yaml_SCALAR_EVENT). - quoted_implicit bool - - // The style (for yaml_SCALAR_EVENT, yaml_SEQUENCE_START_EVENT, yaml_MAPPING_START_EVENT). - style yaml_style_t -} - -func (e *yaml_event_t) scalar_style() yaml_scalar_style_t { return yaml_scalar_style_t(e.style) } -func (e *yaml_event_t) sequence_style() yaml_sequence_style_t { return yaml_sequence_style_t(e.style) } -func (e *yaml_event_t) mapping_style() yaml_mapping_style_t { return yaml_mapping_style_t(e.style) } - -// Nodes - -const ( - yaml_NULL_TAG = "tag:yaml.org,2002:null" // The tag !!null with the only possible value: null. - yaml_BOOL_TAG = "tag:yaml.org,2002:bool" // The tag !!bool with the values: true and false. - yaml_STR_TAG = "tag:yaml.org,2002:str" // The tag !!str for string values. - yaml_INT_TAG = "tag:yaml.org,2002:int" // The tag !!int for integer values. - yaml_FLOAT_TAG = "tag:yaml.org,2002:float" // The tag !!float for float values. - yaml_TIMESTAMP_TAG = "tag:yaml.org,2002:timestamp" // The tag !!timestamp for date and time values. - - yaml_SEQ_TAG = "tag:yaml.org,2002:seq" // The tag !!seq is used to denote sequences. - yaml_MAP_TAG = "tag:yaml.org,2002:map" // The tag !!map is used to denote mapping. - - // Not in original libyaml. - yaml_BINARY_TAG = "tag:yaml.org,2002:binary" - yaml_MERGE_TAG = "tag:yaml.org,2002:merge" - - yaml_DEFAULT_SCALAR_TAG = yaml_STR_TAG // The default scalar tag is !!str. - yaml_DEFAULT_SEQUENCE_TAG = yaml_SEQ_TAG // The default sequence tag is !!seq. - yaml_DEFAULT_MAPPING_TAG = yaml_MAP_TAG // The default mapping tag is !!map. -) - -type yaml_node_type_t int - -// Node types. -const ( - // An empty node. - yaml_NO_NODE yaml_node_type_t = iota - - yaml_SCALAR_NODE // A scalar node. - yaml_SEQUENCE_NODE // A sequence node. - yaml_MAPPING_NODE // A mapping node. -) - -// An element of a sequence node. -type yaml_node_item_t int - -// An element of a mapping node. -type yaml_node_pair_t struct { - key int // The key of the element. - value int // The value of the element. -} - -// The node structure. -type yaml_node_t struct { - typ yaml_node_type_t // The node type. - tag []byte // The node tag. - - // The node data. - - // The scalar parameters (for yaml_SCALAR_NODE). - scalar struct { - value []byte // The scalar value. - length int // The length of the scalar value. - style yaml_scalar_style_t // The scalar style. - } - - // The sequence parameters (for YAML_SEQUENCE_NODE). - sequence struct { - items_data []yaml_node_item_t // The stack of sequence items. - style yaml_sequence_style_t // The sequence style. - } - - // The mapping parameters (for yaml_MAPPING_NODE). - mapping struct { - pairs_data []yaml_node_pair_t // The stack of mapping pairs (key, value). - pairs_start *yaml_node_pair_t // The beginning of the stack. - pairs_end *yaml_node_pair_t // The end of the stack. - pairs_top *yaml_node_pair_t // The top of the stack. - style yaml_mapping_style_t // The mapping style. - } - - start_mark yaml_mark_t // The beginning of the node. - end_mark yaml_mark_t // The end of the node. - -} - -// The document structure. -type yaml_document_t struct { - - // The document nodes. - nodes []yaml_node_t - - // The version directive. - version_directive *yaml_version_directive_t - - // The list of tag directives. - tag_directives_data []yaml_tag_directive_t - tag_directives_start int // The beginning of the tag directives list. - tag_directives_end int // The end of the tag directives list. - - start_implicit int // Is the document start indicator implicit? - end_implicit int // Is the document end indicator implicit? - - // The start/end of the document. - start_mark, end_mark yaml_mark_t -} - -// The prototype of a read handler. -// -// The read handler is called when the parser needs to read more bytes from the -// source. The handler should write not more than size bytes to the buffer. -// The number of written bytes should be set to the size_read variable. -// -// [in,out] data A pointer to an application data specified by -// yaml_parser_set_input(). -// [out] buffer The buffer to write the data from the source. -// [in] size The size of the buffer. -// [out] size_read The actual number of bytes read from the source. -// -// On success, the handler should return 1. If the handler failed, -// the returned value should be 0. On EOF, the handler should set the -// size_read to 0 and return 1. -type yaml_read_handler_t func(parser *yaml_parser_t, buffer []byte) (n int, err error) - -// This structure holds information about a potential simple key. -type yaml_simple_key_t struct { - possible bool // Is a simple key possible? - required bool // Is a simple key required? - token_number int // The number of the token. - mark yaml_mark_t // The position mark. -} - -// The states of the parser. -type yaml_parser_state_t int - -const ( - yaml_PARSE_STREAM_START_STATE yaml_parser_state_t = iota - - yaml_PARSE_IMPLICIT_DOCUMENT_START_STATE // Expect the beginning of an implicit document. - yaml_PARSE_DOCUMENT_START_STATE // Expect DOCUMENT-START. - yaml_PARSE_DOCUMENT_CONTENT_STATE // Expect the content of a document. - yaml_PARSE_DOCUMENT_END_STATE // Expect DOCUMENT-END. - yaml_PARSE_BLOCK_NODE_STATE // Expect a block node. - yaml_PARSE_BLOCK_NODE_OR_INDENTLESS_SEQUENCE_STATE // Expect a block node or indentless sequence. - yaml_PARSE_FLOW_NODE_STATE // Expect a flow node. - yaml_PARSE_BLOCK_SEQUENCE_FIRST_ENTRY_STATE // Expect the first entry of a block sequence. - yaml_PARSE_BLOCK_SEQUENCE_ENTRY_STATE // Expect an entry of a block sequence. - yaml_PARSE_INDENTLESS_SEQUENCE_ENTRY_STATE // Expect an entry of an indentless sequence. - yaml_PARSE_BLOCK_MAPPING_FIRST_KEY_STATE // Expect the first key of a block mapping. - yaml_PARSE_BLOCK_MAPPING_KEY_STATE // Expect a block mapping key. - yaml_PARSE_BLOCK_MAPPING_VALUE_STATE // Expect a block mapping value. - yaml_PARSE_FLOW_SEQUENCE_FIRST_ENTRY_STATE // Expect the first entry of a flow sequence. - yaml_PARSE_FLOW_SEQUENCE_ENTRY_STATE // Expect an entry of a flow sequence. - yaml_PARSE_FLOW_SEQUENCE_ENTRY_MAPPING_KEY_STATE // Expect a key of an ordered mapping. - yaml_PARSE_FLOW_SEQUENCE_ENTRY_MAPPING_VALUE_STATE // Expect a value of an ordered mapping. - yaml_PARSE_FLOW_SEQUENCE_ENTRY_MAPPING_END_STATE // Expect the and of an ordered mapping entry. - yaml_PARSE_FLOW_MAPPING_FIRST_KEY_STATE // Expect the first key of a flow mapping. - yaml_PARSE_FLOW_MAPPING_KEY_STATE // Expect a key of a flow mapping. - yaml_PARSE_FLOW_MAPPING_VALUE_STATE // Expect a value of a flow mapping. - yaml_PARSE_FLOW_MAPPING_EMPTY_VALUE_STATE // Expect an empty value of a flow mapping. - yaml_PARSE_END_STATE // Expect nothing. -) - -func (ps yaml_parser_state_t) String() string { - switch ps { - case yaml_PARSE_STREAM_START_STATE: - return "yaml_PARSE_STREAM_START_STATE" - case yaml_PARSE_IMPLICIT_DOCUMENT_START_STATE: - return "yaml_PARSE_IMPLICIT_DOCUMENT_START_STATE" - case yaml_PARSE_DOCUMENT_START_STATE: - return "yaml_PARSE_DOCUMENT_START_STATE" - case yaml_PARSE_DOCUMENT_CONTENT_STATE: - return "yaml_PARSE_DOCUMENT_CONTENT_STATE" - case yaml_PARSE_DOCUMENT_END_STATE: - return "yaml_PARSE_DOCUMENT_END_STATE" - case yaml_PARSE_BLOCK_NODE_STATE: - return "yaml_PARSE_BLOCK_NODE_STATE" - case yaml_PARSE_BLOCK_NODE_OR_INDENTLESS_SEQUENCE_STATE: - return "yaml_PARSE_BLOCK_NODE_OR_INDENTLESS_SEQUENCE_STATE" - case yaml_PARSE_FLOW_NODE_STATE: - return "yaml_PARSE_FLOW_NODE_STATE" - case yaml_PARSE_BLOCK_SEQUENCE_FIRST_ENTRY_STATE: - return "yaml_PARSE_BLOCK_SEQUENCE_FIRST_ENTRY_STATE" - case yaml_PARSE_BLOCK_SEQUENCE_ENTRY_STATE: - return "yaml_PARSE_BLOCK_SEQUENCE_ENTRY_STATE" - case yaml_PARSE_INDENTLESS_SEQUENCE_ENTRY_STATE: - return "yaml_PARSE_INDENTLESS_SEQUENCE_ENTRY_STATE" - case yaml_PARSE_BLOCK_MAPPING_FIRST_KEY_STATE: - return "yaml_PARSE_BLOCK_MAPPING_FIRST_KEY_STATE" - case yaml_PARSE_BLOCK_MAPPING_KEY_STATE: - return "yaml_PARSE_BLOCK_MAPPING_KEY_STATE" - case yaml_PARSE_BLOCK_MAPPING_VALUE_STATE: - return "yaml_PARSE_BLOCK_MAPPING_VALUE_STATE" - case yaml_PARSE_FLOW_SEQUENCE_FIRST_ENTRY_STATE: - return "yaml_PARSE_FLOW_SEQUENCE_FIRST_ENTRY_STATE" - case yaml_PARSE_FLOW_SEQUENCE_ENTRY_STATE: - return "yaml_PARSE_FLOW_SEQUENCE_ENTRY_STATE" - case yaml_PARSE_FLOW_SEQUENCE_ENTRY_MAPPING_KEY_STATE: - return "yaml_PARSE_FLOW_SEQUENCE_ENTRY_MAPPING_KEY_STATE" - case yaml_PARSE_FLOW_SEQUENCE_ENTRY_MAPPING_VALUE_STATE: - return "yaml_PARSE_FLOW_SEQUENCE_ENTRY_MAPPING_VALUE_STATE" - case yaml_PARSE_FLOW_SEQUENCE_ENTRY_MAPPING_END_STATE: - return "yaml_PARSE_FLOW_SEQUENCE_ENTRY_MAPPING_END_STATE" - case yaml_PARSE_FLOW_MAPPING_FIRST_KEY_STATE: - return "yaml_PARSE_FLOW_MAPPING_FIRST_KEY_STATE" - case yaml_PARSE_FLOW_MAPPING_KEY_STATE: - return "yaml_PARSE_FLOW_MAPPING_KEY_STATE" - case yaml_PARSE_FLOW_MAPPING_VALUE_STATE: - return "yaml_PARSE_FLOW_MAPPING_VALUE_STATE" - case yaml_PARSE_FLOW_MAPPING_EMPTY_VALUE_STATE: - return "yaml_PARSE_FLOW_MAPPING_EMPTY_VALUE_STATE" - case yaml_PARSE_END_STATE: - return "yaml_PARSE_END_STATE" - } - return "<unknown parser state>" -} - -// This structure holds aliases data. -type yaml_alias_data_t struct { - anchor []byte // The anchor. - index int // The node id. - mark yaml_mark_t // The anchor mark. -} - -// The parser structure. -// -// All members are internal. Manage the structure using the -// yaml_parser_ family of functions. -type yaml_parser_t struct { - - // Error handling - - error yaml_error_type_t // Error type. - - problem string // Error description. - - // The byte about which the problem occured. - problem_offset int - problem_value int - problem_mark yaml_mark_t - - // The error context. - context string - context_mark yaml_mark_t - - // Reader stuff - - read_handler yaml_read_handler_t // Read handler. - - input_file io.Reader // File input data. - input []byte // String input data. - input_pos int - - eof bool // EOF flag - - buffer []byte // The working buffer. - buffer_pos int // The current position of the buffer. - - unread int // The number of unread characters in the buffer. - - raw_buffer []byte // The raw buffer. - raw_buffer_pos int // The current position of the buffer. - - encoding yaml_encoding_t // The input encoding. - - offset int // The offset of the current position (in bytes). - mark yaml_mark_t // The mark of the current position. - - // Scanner stuff - - stream_start_produced bool // Have we started to scan the input stream? - stream_end_produced bool // Have we reached the end of the input stream? - - flow_level int // The number of unclosed '[' and '{' indicators. - - tokens []yaml_token_t // The tokens queue. - tokens_head int // The head of the tokens queue. - tokens_parsed int // The number of tokens fetched from the queue. - token_available bool // Does the tokens queue contain a token ready for dequeueing. - - indent int // The current indentation level. - indents []int // The indentation levels stack. - - simple_key_allowed bool // May a simple key occur at the current position? - simple_keys []yaml_simple_key_t // The stack of simple keys. - - // Parser stuff - - state yaml_parser_state_t // The current parser state. - states []yaml_parser_state_t // The parser states stack. - marks []yaml_mark_t // The stack of marks. - tag_directives []yaml_tag_directive_t // The list of TAG directives. - - // Dumper stuff - - aliases []yaml_alias_data_t // The alias data. - - document *yaml_document_t // The currently parsed document. -} - -// Emitter Definitions - -// The prototype of a write handler. -// -// The write handler is called when the emitter needs to flush the accumulated -// characters to the output. The handler should write @a size bytes of the -// @a buffer to the output. -// -// @param[in,out] data A pointer to an application data specified by -// yaml_emitter_set_output(). -// @param[in] buffer The buffer with bytes to be written. -// @param[in] size The size of the buffer. -// -// @returns On success, the handler should return @c 1. If the handler failed, -// the returned value should be @c 0. -// -type yaml_write_handler_t func(emitter *yaml_emitter_t, buffer []byte) error - -type yaml_emitter_state_t int - -// The emitter states. -const ( - // Expect STREAM-START. - yaml_EMIT_STREAM_START_STATE yaml_emitter_state_t = iota - - yaml_EMIT_FIRST_DOCUMENT_START_STATE // Expect the first DOCUMENT-START or STREAM-END. - yaml_EMIT_DOCUMENT_START_STATE // Expect DOCUMENT-START or STREAM-END. - yaml_EMIT_DOCUMENT_CONTENT_STATE // Expect the content of a document. - yaml_EMIT_DOCUMENT_END_STATE // Expect DOCUMENT-END. - yaml_EMIT_FLOW_SEQUENCE_FIRST_ITEM_STATE // Expect the first item of a flow sequence. - yaml_EMIT_FLOW_SEQUENCE_ITEM_STATE // Expect an item of a flow sequence. - yaml_EMIT_FLOW_MAPPING_FIRST_KEY_STATE // Expect the first key of a flow mapping. - yaml_EMIT_FLOW_MAPPING_KEY_STATE // Expect a key of a flow mapping. - yaml_EMIT_FLOW_MAPPING_SIMPLE_VALUE_STATE // Expect a value for a simple key of a flow mapping. - yaml_EMIT_FLOW_MAPPING_VALUE_STATE // Expect a value of a flow mapping. - yaml_EMIT_BLOCK_SEQUENCE_FIRST_ITEM_STATE // Expect the first item of a block sequence. - yaml_EMIT_BLOCK_SEQUENCE_ITEM_STATE // Expect an item of a block sequence. - yaml_EMIT_BLOCK_MAPPING_FIRST_KEY_STATE // Expect the first key of a block mapping. - yaml_EMIT_BLOCK_MAPPING_KEY_STATE // Expect the key of a block mapping. - yaml_EMIT_BLOCK_MAPPING_SIMPLE_VALUE_STATE // Expect a value for a simple key of a block mapping. - yaml_EMIT_BLOCK_MAPPING_VALUE_STATE // Expect a value of a block mapping. - yaml_EMIT_END_STATE // Expect nothing. -) - -// The emitter structure. -// -// All members are internal. Manage the structure using the @c yaml_emitter_ -// family of functions. -type yaml_emitter_t struct { - - // Error handling - - error yaml_error_type_t // Error type. - problem string // Error description. - - // Writer stuff - - write_handler yaml_write_handler_t // Write handler. - - output_buffer *[]byte // String output data. - output_file io.Writer // File output data. - - buffer []byte // The working buffer. - buffer_pos int // The current position of the buffer. - - raw_buffer []byte // The raw buffer. - raw_buffer_pos int // The current position of the buffer. - - encoding yaml_encoding_t // The stream encoding. - - // Emitter stuff - - canonical bool // If the output is in the canonical style? - best_indent int // The number of indentation spaces. - best_width int // The preferred width of the output lines. - unicode bool // Allow unescaped non-ASCII characters? - line_break yaml_break_t // The preferred line break. - - state yaml_emitter_state_t // The current emitter state. - states []yaml_emitter_state_t // The stack of states. - - events []yaml_event_t // The event queue. - events_head int // The head of the event queue. - - indents []int // The stack of indentation levels. - - tag_directives []yaml_tag_directive_t // The list of tag directives. - - indent int // The current indentation level. - - flow_level int // The current flow level. - - root_context bool // Is it the document root context? - sequence_context bool // Is it a sequence context? - mapping_context bool // Is it a mapping context? - simple_key_context bool // Is it a simple mapping key context? - - line int // The current line. - column int // The current column. - whitespace bool // If the last character was a whitespace? - indention bool // If the last character was an indentation character (' ', '-', '?', ':')? - open_ended bool // If an explicit document end is required? - - // Anchor analysis. - anchor_data struct { - anchor []byte // The anchor value. - alias bool // Is it an alias? - } - - // Tag analysis. - tag_data struct { - handle []byte // The tag handle. - suffix []byte // The tag suffix. - } - - // Scalar analysis. - scalar_data struct { - value []byte // The scalar value. - multiline bool // Does the scalar contain line breaks? - flow_plain_allowed bool // Can the scalar be expessed in the flow plain style? - block_plain_allowed bool // Can the scalar be expressed in the block plain style? - single_quoted_allowed bool // Can the scalar be expressed in the single quoted style? - block_allowed bool // Can the scalar be expressed in the literal or folded styles? - style yaml_scalar_style_t // The output style. - } - - // Dumper stuff - - opened bool // If the stream was already opened? - closed bool // If the stream was already closed? - - // The information associated with the document nodes. - anchors *struct { - references int // The number of references. - anchor int // The anchor id. - serialized bool // If the node has been emitted? - } - - last_anchor_id int // The last assigned anchor id. - - document *yaml_document_t // The currently emitted document. -} diff --git a/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/coreos/yaml/yamlprivateh.go b/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/coreos/yaml/yamlprivateh.go deleted file mode 100644 index 8110ce3c..00000000 --- a/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/coreos/yaml/yamlprivateh.go +++ /dev/null @@ -1,173 +0,0 @@ -package yaml - -const ( - // The size of the input raw buffer. - input_raw_buffer_size = 512 - - // The size of the input buffer. - // It should be possible to decode the whole raw buffer. - input_buffer_size = input_raw_buffer_size * 3 - - // The size of the output buffer. - output_buffer_size = 128 - - // The size of the output raw buffer. - // It should be possible to encode the whole output buffer. - output_raw_buffer_size = (output_buffer_size*2 + 2) - - // The size of other stacks and queues. - initial_stack_size = 16 - initial_queue_size = 16 - initial_string_size = 16 -) - -// Check if the character at the specified position is an alphabetical -// character, a digit, '_', or '-'. -func is_alpha(b []byte, i int) bool { - return b[i] >= '0' && b[i] <= '9' || b[i] >= 'A' && b[i] <= 'Z' || b[i] >= 'a' && b[i] <= 'z' || b[i] == '_' || b[i] == '-' -} - -// Check if the character at the specified position is a digit. -func is_digit(b []byte, i int) bool { - return b[i] >= '0' && b[i] <= '9' -} - -// Get the value of a digit. -func as_digit(b []byte, i int) int { - return int(b[i]) - '0' -} - -// Check if the character at the specified position is a hex-digit. -func is_hex(b []byte, i int) bool { - return b[i] >= '0' && b[i] <= '9' || b[i] >= 'A' && b[i] <= 'F' || b[i] >= 'a' && b[i] <= 'f' -} - -// Get the value of a hex-digit. -func as_hex(b []byte, i int) int { - bi := b[i] - if bi >= 'A' && bi <= 'F' { - return int(bi) - 'A' + 10 - } - if bi >= 'a' && bi <= 'f' { - return int(bi) - 'a' + 10 - } - return int(bi) - '0' -} - -// Check if the character is ASCII. -func is_ascii(b []byte, i int) bool { - return b[i] <= 0x7F -} - -// Check if the character at the start of the buffer can be printed unescaped. -func is_printable(b []byte, i int) bool { - return ((b[i] == 0x0A) || // . == #x0A - (b[i] >= 0x20 && b[i] <= 0x7E) || // #x20 <= . <= #x7E - (b[i] == 0xC2 && b[i+1] >= 0xA0) || // #0xA0 <= . <= #xD7FF - (b[i] > 0xC2 && b[i] < 0xED) || - (b[i] == 0xED && b[i+1] < 0xA0) || - (b[i] == 0xEE) || - (b[i] == 0xEF && // #xE000 <= . <= #xFFFD - !(b[i+1] == 0xBB && b[i+2] == 0xBF) && // && . != #xFEFF - !(b[i+1] == 0xBF && (b[i+2] == 0xBE || b[i+2] == 0xBF)))) -} - -// Check if the character at the specified position is NUL. -func is_z(b []byte, i int) bool { - return b[i] == 0x00 -} - -// Check if the beginning of the buffer is a BOM. -func is_bom(b []byte, i int) bool { - return b[0] == 0xEF && b[1] == 0xBB && b[2] == 0xBF -} - -// Check if the character at the specified position is space. -func is_space(b []byte, i int) bool { - return b[i] == ' ' -} - -// Check if the character at the specified position is tab. -func is_tab(b []byte, i int) bool { - return b[i] == '\t' -} - -// Check if the character at the specified position is blank (space or tab). -func is_blank(b []byte, i int) bool { - //return is_space(b, i) || is_tab(b, i) - return b[i] == ' ' || b[i] == '\t' -} - -// Check if the character at the specified position is a line break. -func is_break(b []byte, i int) bool { - return (b[i] == '\r' || // CR (#xD) - b[i] == '\n' || // LF (#xA) - b[i] == 0xC2 && b[i+1] == 0x85 || // NEL (#x85) - b[i] == 0xE2 && b[i+1] == 0x80 && b[i+2] == 0xA8 || // LS (#x2028) - b[i] == 0xE2 && b[i+1] == 0x80 && b[i+2] == 0xA9) // PS (#x2029) -} - -func is_crlf(b []byte, i int) bool { - return b[i] == '\r' && b[i+1] == '\n' -} - -// Check if the character is a line break or NUL. -func is_breakz(b []byte, i int) bool { - //return is_break(b, i) || is_z(b, i) - return ( // is_break: - b[i] == '\r' || // CR (#xD) - b[i] == '\n' || // LF (#xA) - b[i] == 0xC2 && b[i+1] == 0x85 || // NEL (#x85) - b[i] == 0xE2 && b[i+1] == 0x80 && b[i+2] == 0xA8 || // LS (#x2028) - b[i] == 0xE2 && b[i+1] == 0x80 && b[i+2] == 0xA9 || // PS (#x2029) - // is_z: - b[i] == 0) -} - -// Check if the character is a line break, space, or NUL. -func is_spacez(b []byte, i int) bool { - //return is_space(b, i) || is_breakz(b, i) - return ( // is_space: - b[i] == ' ' || - // is_breakz: - b[i] == '\r' || // CR (#xD) - b[i] == '\n' || // LF (#xA) - b[i] == 0xC2 && b[i+1] == 0x85 || // NEL (#x85) - b[i] == 0xE2 && b[i+1] == 0x80 && b[i+2] == 0xA8 || // LS (#x2028) - b[i] == 0xE2 && b[i+1] == 0x80 && b[i+2] == 0xA9 || // PS (#x2029) - b[i] == 0) -} - -// Check if the character is a line break, space, tab, or NUL. -func is_blankz(b []byte, i int) bool { - //return is_blank(b, i) || is_breakz(b, i) - return ( // is_blank: - b[i] == ' ' || b[i] == '\t' || - // is_breakz: - b[i] == '\r' || // CR (#xD) - b[i] == '\n' || // LF (#xA) - b[i] == 0xC2 && b[i+1] == 0x85 || // NEL (#x85) - b[i] == 0xE2 && b[i+1] == 0x80 && b[i+2] == 0xA8 || // LS (#x2028) - b[i] == 0xE2 && b[i+1] == 0x80 && b[i+2] == 0xA9 || // PS (#x2029) - b[i] == 0) -} - -// Determine the width of the character. -func width(b byte) int { - // Don't replace these by a switch without first - // confirming that it is being inlined. - if b&0x80 == 0x00 { - return 1 - } - if b&0xE0 == 0xC0 { - return 2 - } - if b&0xF0 == 0xE0 { - return 3 - } - if b&0xF8 == 0xF0 { - return 4 - } - return 0 - -} diff --git a/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/dotcloud/docker/pkg/netlink/MAINTAINERS b/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/dotcloud/docker/pkg/netlink/MAINTAINERS deleted file mode 100644 index 1cb55136..00000000 --- a/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/dotcloud/docker/pkg/netlink/MAINTAINERS +++ /dev/null @@ -1,2 +0,0 @@ -Michael Crosby <michael@crosbymichael.com> (@crosbymichael) -Guillaume J. Charmes <guillaume@docker.com> (@creack) diff --git a/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/dotcloud/docker/pkg/netlink/netlink.go b/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/dotcloud/docker/pkg/netlink/netlink.go deleted file mode 100644 index 5cc75625..00000000 --- a/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/dotcloud/docker/pkg/netlink/netlink.go +++ /dev/null @@ -1,23 +0,0 @@ -// Packet netlink provide access to low level Netlink sockets and messages. -// -// Actual implementations are in: -// netlink_linux.go -// netlink_darwin.go -package netlink - -import ( - "errors" - "net" -) - -var ( - ErrWrongSockType = errors.New("Wrong socket type") - ErrShortResponse = errors.New("Got short response from netlink") -) - -// A Route is a subnet associated with the interface to reach it. -type Route struct { - *net.IPNet - Iface *net.Interface - Default bool -} diff --git a/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/dotcloud/docker/pkg/netlink/netlink_linux.go b/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/dotcloud/docker/pkg/netlink/netlink_linux.go deleted file mode 100644 index 6de293d4..00000000 --- a/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/dotcloud/docker/pkg/netlink/netlink_linux.go +++ /dev/null @@ -1,891 +0,0 @@ -// +build amd64 - -package netlink - -import ( - "encoding/binary" - "fmt" - "math/rand" - "net" - "syscall" - "unsafe" -) - -const ( - IFNAMSIZ = 16 - DEFAULT_CHANGE = 0xFFFFFFFF - IFLA_INFO_KIND = 1 - IFLA_INFO_DATA = 2 - VETH_INFO_PEER = 1 - IFLA_NET_NS_FD = 28 - SIOC_BRADDBR = 0x89a0 - SIOC_BRADDIF = 0x89a2 -) - -var nextSeqNr int - -type ifreqHwaddr struct { - IfrnName [16]byte - IfruHwaddr syscall.RawSockaddr -} - -type ifreqIndex struct { - IfrnName [16]byte - IfruIndex int32 -} - -func nativeEndian() binary.ByteOrder { - var x uint32 = 0x01020304 - if *(*byte)(unsafe.Pointer(&x)) == 0x01 { - return binary.BigEndian - } - return binary.LittleEndian -} - -func getSeq() int { - nextSeqNr = nextSeqNr + 1 - return nextSeqNr -} - -func getIpFamily(ip net.IP) int { - if len(ip) <= net.IPv4len { - return syscall.AF_INET - } - if ip.To4() != nil { - return syscall.AF_INET - } - return syscall.AF_INET6 -} - -type NetlinkRequestData interface { - Len() int - ToWireFormat() []byte -} - -type IfInfomsg struct { - syscall.IfInfomsg -} - -func newIfInfomsg(family int) *IfInfomsg { - return &IfInfomsg{ - IfInfomsg: syscall.IfInfomsg{ - Family: uint8(family), - }, - } -} - -func newIfInfomsgChild(parent *RtAttr, family int) *IfInfomsg { - msg := newIfInfomsg(family) - parent.children = append(parent.children, msg) - return msg -} - -func (msg *IfInfomsg) ToWireFormat() []byte { - native := nativeEndian() - - length := syscall.SizeofIfInfomsg - b := make([]byte, length) - b[0] = msg.Family - b[1] = 0 - native.PutUint16(b[2:4], msg.Type) - native.PutUint32(b[4:8], uint32(msg.Index)) - native.PutUint32(b[8:12], msg.Flags) - native.PutUint32(b[12:16], msg.Change) - return b -} - -func (msg *IfInfomsg) Len() int { - return syscall.SizeofIfInfomsg -} - -type IfAddrmsg struct { - syscall.IfAddrmsg -} - -func newIfAddrmsg(family int) *IfAddrmsg { - return &IfAddrmsg{ - IfAddrmsg: syscall.IfAddrmsg{ - Family: uint8(family), - }, - } -} - -func (msg *IfAddrmsg) ToWireFormat() []byte { - native := nativeEndian() - - length := syscall.SizeofIfAddrmsg - b := make([]byte, length) - b[0] = msg.Family - b[1] = msg.Prefixlen - b[2] = msg.Flags - b[3] = msg.Scope - native.PutUint32(b[4:8], msg.Index) - return b -} - -func (msg *IfAddrmsg) Len() int { - return syscall.SizeofIfAddrmsg -} - -type RtMsg struct { - syscall.RtMsg -} - -func newRtMsg(family int) *RtMsg { - return &RtMsg{ - RtMsg: syscall.RtMsg{ - Family: uint8(family), - Table: syscall.RT_TABLE_MAIN, - Scope: syscall.RT_SCOPE_UNIVERSE, - Protocol: syscall.RTPROT_BOOT, - Type: syscall.RTN_UNICAST, - }, - } -} - -func (msg *RtMsg) ToWireFormat() []byte { - native := nativeEndian() - - length := syscall.SizeofRtMsg - b := make([]byte, length) - b[0] = msg.Family - b[1] = msg.Dst_len - b[2] = msg.Src_len - b[3] = msg.Tos - b[4] = msg.Table - b[5] = msg.Protocol - b[6] = msg.Scope - b[7] = msg.Type - native.PutUint32(b[8:12], msg.Flags) - return b -} - -func (msg *RtMsg) Len() int { - return syscall.SizeofRtMsg -} - -func rtaAlignOf(attrlen int) int { - return (attrlen + syscall.RTA_ALIGNTO - 1) & ^(syscall.RTA_ALIGNTO - 1) -} - -type RtAttr struct { - syscall.RtAttr - Data []byte - children []NetlinkRequestData -} - -func newRtAttr(attrType int, data []byte) *RtAttr { - return &RtAttr{ - RtAttr: syscall.RtAttr{ - Type: uint16(attrType), - }, - children: []NetlinkRequestData{}, - Data: data, - } -} - -func newRtAttrChild(parent *RtAttr, attrType int, data []byte) *RtAttr { - attr := newRtAttr(attrType, data) - parent.children = append(parent.children, attr) - return attr -} - -func (a *RtAttr) Len() int { - l := 0 - for _, child := range a.children { - l += child.Len() + syscall.SizeofRtAttr - } - if l == 0 { - l++ - } - return rtaAlignOf(l + len(a.Data)) -} - -func (a *RtAttr) ToWireFormat() []byte { - native := nativeEndian() - - length := a.Len() - buf := make([]byte, rtaAlignOf(length+syscall.SizeofRtAttr)) - - if a.Data != nil { - copy(buf[4:], a.Data) - } else { - next := 4 - for _, child := range a.children { - childBuf := child.ToWireFormat() - copy(buf[next:], childBuf) - next += rtaAlignOf(len(childBuf)) - } - } - - if l := uint16(rtaAlignOf(length)); l != 0 { - native.PutUint16(buf[0:2], l+1) - } - native.PutUint16(buf[2:4], a.Type) - - return buf -} - -type NetlinkRequest struct { - syscall.NlMsghdr - Data []NetlinkRequestData -} - -func (rr *NetlinkRequest) ToWireFormat() []byte { - native := nativeEndian() - - length := rr.Len - dataBytes := make([][]byte, len(rr.Data)) - for i, data := range rr.Data { - dataBytes[i] = data.ToWireFormat() - length += uint32(len(dataBytes[i])) - } - b := make([]byte, length) - native.PutUint32(b[0:4], length) - native.PutUint16(b[4:6], rr.Type) - native.PutUint16(b[6:8], rr.Flags) - native.PutUint32(b[8:12], rr.Seq) - native.PutUint32(b[12:16], rr.Pid) - - next := 16 - for _, data := range dataBytes { - copy(b[next:], data) - next += len(data) - } - return b -} - -func (rr *NetlinkRequest) AddData(data NetlinkRequestData) { - if data != nil { - rr.Data = append(rr.Data, data) - } -} - -func newNetlinkRequest(proto, flags int) *NetlinkRequest { - return &NetlinkRequest{ - NlMsghdr: syscall.NlMsghdr{ - Len: uint32(syscall.NLMSG_HDRLEN), - Type: uint16(proto), - Flags: syscall.NLM_F_REQUEST | uint16(flags), - Seq: uint32(getSeq()), - }, - } -} - -type NetlinkSocket struct { - fd int - lsa syscall.SockaddrNetlink -} - -func getNetlinkSocket() (*NetlinkSocket, error) { - fd, err := syscall.Socket(syscall.AF_NETLINK, syscall.SOCK_RAW, syscall.NETLINK_ROUTE) - if err != nil { - return nil, err - } - s := &NetlinkSocket{ - fd: fd, - } - s.lsa.Family = syscall.AF_NETLINK - if err := syscall.Bind(fd, &s.lsa); err != nil { - syscall.Close(fd) - return nil, err - } - - return s, nil -} - -func (s *NetlinkSocket) Close() { - syscall.Close(s.fd) -} - -func (s *NetlinkSocket) Send(request *NetlinkRequest) error { - if err := syscall.Sendto(s.fd, request.ToWireFormat(), 0, &s.lsa); err != nil { - return err - } - return nil -} - -func (s *NetlinkSocket) Receive() ([]syscall.NetlinkMessage, error) { - rb := make([]byte, syscall.Getpagesize()) - nr, _, err := syscall.Recvfrom(s.fd, rb, 0) - if err != nil { - return nil, err - } - if nr < syscall.NLMSG_HDRLEN { - return nil, ErrShortResponse - } - rb = rb[:nr] - return syscall.ParseNetlinkMessage(rb) -} - -func (s *NetlinkSocket) GetPid() (uint32, error) { - lsa, err := syscall.Getsockname(s.fd) - if err != nil { - return 0, err - } - switch v := lsa.(type) { - case *syscall.SockaddrNetlink: - return v.Pid, nil - } - return 0, ErrWrongSockType -} - -func (s *NetlinkSocket) HandleAck(seq uint32) error { - native := nativeEndian() - - pid, err := s.GetPid() - if err != nil { - return err - } - -done: - for { - msgs, err := s.Receive() - if err != nil { - return err - } - for _, m := range msgs { - if m.Header.Seq != seq { - return fmt.Errorf("Wrong Seq nr %d, expected %d", m.Header.Seq, seq) - } - if m.Header.Pid != pid { - return fmt.Errorf("Wrong pid %d, expected %d", m.Header.Pid, pid) - } - if m.Header.Type == syscall.NLMSG_DONE { - break done - } - if m.Header.Type == syscall.NLMSG_ERROR { - error := int32(native.Uint32(m.Data[0:4])) - if error == 0 { - break done - } - return syscall.Errno(-error) - } - } - } - - return nil -} - -// Add a new default gateway. Identical to: -// ip route add default via $ip -func AddDefaultGw(ip net.IP) error { - s, err := getNetlinkSocket() - if err != nil { - return err - } - defer s.Close() - - family := getIpFamily(ip) - - wb := newNetlinkRequest(syscall.RTM_NEWROUTE, syscall.NLM_F_CREATE|syscall.NLM_F_EXCL|syscall.NLM_F_ACK) - - msg := newRtMsg(family) - wb.AddData(msg) - - var ipData []byte - if family == syscall.AF_INET { - ipData = ip.To4() - } else { - ipData = ip.To16() - } - - gateway := newRtAttr(syscall.RTA_GATEWAY, ipData) - - wb.AddData(gateway) - - if err := s.Send(wb); err != nil { - return err - } - - return s.HandleAck(wb.Seq) -} - -// Bring up a particular network interface -func NetworkLinkUp(iface *net.Interface) error { - s, err := getNetlinkSocket() - if err != nil { - return err - } - defer s.Close() - - wb := newNetlinkRequest(syscall.RTM_NEWLINK, syscall.NLM_F_ACK) - - msg := newIfInfomsg(syscall.AF_UNSPEC) - msg.Change = syscall.IFF_UP - msg.Flags = syscall.IFF_UP - msg.Index = int32(iface.Index) - wb.AddData(msg) - - if err := s.Send(wb); err != nil { - return err - } - - return s.HandleAck(wb.Seq) -} - -func NetworkLinkDown(iface *net.Interface) error { - s, err := getNetlinkSocket() - if err != nil { - return err - } - defer s.Close() - - wb := newNetlinkRequest(syscall.RTM_NEWLINK, syscall.NLM_F_ACK) - - msg := newIfInfomsg(syscall.AF_UNSPEC) - msg.Change = syscall.IFF_UP - msg.Flags = 0 & ^syscall.IFF_UP - msg.Index = int32(iface.Index) - wb.AddData(msg) - - if err := s.Send(wb); err != nil { - return err - } - - return s.HandleAck(wb.Seq) -} - -func NetworkSetMTU(iface *net.Interface, mtu int) error { - s, err := getNetlinkSocket() - if err != nil { - return err - } - defer s.Close() - - wb := newNetlinkRequest(syscall.RTM_SETLINK, syscall.NLM_F_ACK) - - msg := newIfInfomsg(syscall.AF_UNSPEC) - msg.Type = syscall.RTM_SETLINK - msg.Flags = syscall.NLM_F_REQUEST - msg.Index = int32(iface.Index) - msg.Change = DEFAULT_CHANGE - wb.AddData(msg) - - var ( - b = make([]byte, 4) - native = nativeEndian() - ) - native.PutUint32(b, uint32(mtu)) - - data := newRtAttr(syscall.IFLA_MTU, b) - wb.AddData(data) - - if err := s.Send(wb); err != nil { - return err - } - return s.HandleAck(wb.Seq) -} - -// same as ip link set $name master $master -func NetworkSetMaster(iface, master *net.Interface) error { - s, err := getNetlinkSocket() - if err != nil { - return err - } - defer s.Close() - - wb := newNetlinkRequest(syscall.RTM_SETLINK, syscall.NLM_F_ACK) - - msg := newIfInfomsg(syscall.AF_UNSPEC) - msg.Type = syscall.RTM_SETLINK - msg.Flags = syscall.NLM_F_REQUEST - msg.Index = int32(iface.Index) - msg.Change = DEFAULT_CHANGE - wb.AddData(msg) - - var ( - b = make([]byte, 4) - native = nativeEndian() - ) - native.PutUint32(b, uint32(master.Index)) - - data := newRtAttr(syscall.IFLA_MASTER, b) - wb.AddData(data) - - if err := s.Send(wb); err != nil { - return err - } - - return s.HandleAck(wb.Seq) -} - -func NetworkSetNsPid(iface *net.Interface, nspid int) error { - s, err := getNetlinkSocket() - if err != nil { - return err - } - defer s.Close() - - wb := newNetlinkRequest(syscall.RTM_SETLINK, syscall.NLM_F_ACK) - - msg := newIfInfomsg(syscall.AF_UNSPEC) - msg.Type = syscall.RTM_SETLINK - msg.Flags = syscall.NLM_F_REQUEST - msg.Index = int32(iface.Index) - msg.Change = DEFAULT_CHANGE - wb.AddData(msg) - - var ( - b = make([]byte, 4) - native = nativeEndian() - ) - native.PutUint32(b, uint32(nspid)) - - data := newRtAttr(syscall.IFLA_NET_NS_PID, b) - wb.AddData(data) - - if err := s.Send(wb); err != nil { - return err - } - - return s.HandleAck(wb.Seq) -} - -func NetworkSetNsFd(iface *net.Interface, fd int) error { - s, err := getNetlinkSocket() - if err != nil { - return err - } - defer s.Close() - - wb := newNetlinkRequest(syscall.RTM_SETLINK, syscall.NLM_F_ACK) - - msg := newIfInfomsg(syscall.AF_UNSPEC) - msg.Type = syscall.RTM_SETLINK - msg.Flags = syscall.NLM_F_REQUEST - msg.Index = int32(iface.Index) - msg.Change = DEFAULT_CHANGE - wb.AddData(msg) - - var ( - b = make([]byte, 4) - native = nativeEndian() - ) - native.PutUint32(b, uint32(fd)) - - data := newRtAttr(IFLA_NET_NS_FD, b) - wb.AddData(data) - - if err := s.Send(wb); err != nil { - return err - } - - return s.HandleAck(wb.Seq) -} - -// Add an Ip address to an interface. This is identical to: -// ip addr add $ip/$ipNet dev $iface -func NetworkLinkAddIp(iface *net.Interface, ip net.IP, ipNet *net.IPNet) error { - s, err := getNetlinkSocket() - if err != nil { - return err - } - defer s.Close() - - family := getIpFamily(ip) - - wb := newNetlinkRequest(syscall.RTM_NEWADDR, syscall.NLM_F_CREATE|syscall.NLM_F_EXCL|syscall.NLM_F_ACK) - - msg := newIfAddrmsg(family) - msg.Index = uint32(iface.Index) - prefixLen, _ := ipNet.Mask.Size() - msg.Prefixlen = uint8(prefixLen) - wb.AddData(msg) - - var ipData []byte - if family == syscall.AF_INET { - ipData = ip.To4() - } else { - ipData = ip.To16() - } - - localData := newRtAttr(syscall.IFA_LOCAL, ipData) - wb.AddData(localData) - - addrData := newRtAttr(syscall.IFA_ADDRESS, ipData) - wb.AddData(addrData) - - if err := s.Send(wb); err != nil { - return err - } - - return s.HandleAck(wb.Seq) -} - -func zeroTerminated(s string) []byte { - return []byte(s + "\000") -} - -func nonZeroTerminated(s string) []byte { - return []byte(s) -} - -// Add a new network link of a specified type. This is identical to -// running: ip add link $name type $linkType -func NetworkLinkAdd(name string, linkType string) error { - s, err := getNetlinkSocket() - if err != nil { - return err - } - defer s.Close() - - wb := newNetlinkRequest(syscall.RTM_NEWLINK, syscall.NLM_F_CREATE|syscall.NLM_F_EXCL|syscall.NLM_F_ACK) - - msg := newIfInfomsg(syscall.AF_UNSPEC) - wb.AddData(msg) - - if name != "" { - nameData := newRtAttr(syscall.IFLA_IFNAME, zeroTerminated(name)) - wb.AddData(nameData) - } - - kindData := newRtAttr(IFLA_INFO_KIND, nonZeroTerminated(linkType)) - - infoData := newRtAttr(syscall.IFLA_LINKINFO, kindData.ToWireFormat()) - wb.AddData(infoData) - - if err := s.Send(wb); err != nil { - return err - } - - return s.HandleAck(wb.Seq) -} - -// Returns an array of IPNet for all the currently routed subnets on ipv4 -// This is similar to the first column of "ip route" output -func NetworkGetRoutes() ([]Route, error) { - native := nativeEndian() - - s, err := getNetlinkSocket() - if err != nil { - return nil, err - } - defer s.Close() - - wb := newNetlinkRequest(syscall.RTM_GETROUTE, syscall.NLM_F_DUMP) - - msg := newIfInfomsg(syscall.AF_UNSPEC) - wb.AddData(msg) - - if err := s.Send(wb); err != nil { - return nil, err - } - - pid, err := s.GetPid() - if err != nil { - return nil, err - } - - res := make([]Route, 0) - -done: - for { - msgs, err := s.Receive() - if err != nil { - return nil, err - } - for _, m := range msgs { - if m.Header.Seq != wb.Seq { - return nil, fmt.Errorf("Wrong Seq nr %d, expected 1", m.Header.Seq) - } - if m.Header.Pid != pid { - return nil, fmt.Errorf("Wrong pid %d, expected %d", m.Header.Pid, pid) - } - if m.Header.Type == syscall.NLMSG_DONE { - break done - } - if m.Header.Type == syscall.NLMSG_ERROR { - error := int32(native.Uint32(m.Data[0:4])) - if error == 0 { - break done - } - return nil, syscall.Errno(-error) - } - if m.Header.Type != syscall.RTM_NEWROUTE { - continue - } - - var r Route - - msg := (*RtMsg)(unsafe.Pointer(&m.Data[0:syscall.SizeofRtMsg][0])) - - if msg.Flags&syscall.RTM_F_CLONED != 0 { - // Ignore cloned routes - continue - } - - if msg.Table != syscall.RT_TABLE_MAIN { - // Ignore non-main tables - continue - } - - if msg.Family != syscall.AF_INET { - // Ignore non-ipv4 routes - continue - } - - if msg.Dst_len == 0 { - // Default routes - r.Default = true - } - - attrs, err := syscall.ParseNetlinkRouteAttr(&m) - if err != nil { - return nil, err - } - for _, attr := range attrs { - switch attr.Attr.Type { - case syscall.RTA_DST: - ip := attr.Value - r.IPNet = &net.IPNet{ - IP: ip, - Mask: net.CIDRMask(int(msg.Dst_len), 8*len(ip)), - } - case syscall.RTA_OIF: - index := int(native.Uint32(attr.Value[0:4])) - r.Iface, _ = net.InterfaceByIndex(index) - } - } - if r.Default || r.IPNet != nil { - res = append(res, r) - } - } - } - - return res, nil -} - -func getIfSocket() (fd int, err error) { - for _, socket := range []int{ - syscall.AF_INET, - syscall.AF_PACKET, - syscall.AF_INET6, - } { - if fd, err = syscall.Socket(socket, syscall.SOCK_DGRAM, 0); err == nil { - break - } - } - if err == nil { - return fd, nil - } - return -1, err -} - -func NetworkChangeName(iface *net.Interface, newName string) error { - fd, err := getIfSocket() - if err != nil { - return err - } - defer syscall.Close(fd) - - data := [IFNAMSIZ * 2]byte{} - // the "-1"s here are very important for ensuring we get proper null - // termination of our new C strings - copy(data[:IFNAMSIZ-1], iface.Name) - copy(data[IFNAMSIZ:IFNAMSIZ*2-1], newName) - - if _, _, errno := syscall.Syscall(syscall.SYS_IOCTL, uintptr(fd), syscall.SIOCSIFNAME, uintptr(unsafe.Pointer(&data[0]))); errno != 0 { - return errno - } - return nil -} - -func NetworkCreateVethPair(name1, name2 string) error { - s, err := getNetlinkSocket() - if err != nil { - return err - } - defer s.Close() - - wb := newNetlinkRequest(syscall.RTM_NEWLINK, syscall.NLM_F_CREATE|syscall.NLM_F_EXCL|syscall.NLM_F_ACK) - - msg := newIfInfomsg(syscall.AF_UNSPEC) - wb.AddData(msg) - - nameData := newRtAttr(syscall.IFLA_IFNAME, zeroTerminated(name1)) - wb.AddData(nameData) - - nest1 := newRtAttr(syscall.IFLA_LINKINFO, nil) - newRtAttrChild(nest1, IFLA_INFO_KIND, zeroTerminated("veth")) - nest2 := newRtAttrChild(nest1, IFLA_INFO_DATA, nil) - nest3 := newRtAttrChild(nest2, VETH_INFO_PEER, nil) - - newIfInfomsgChild(nest3, syscall.AF_UNSPEC) - newRtAttrChild(nest3, syscall.IFLA_IFNAME, zeroTerminated(name2)) - - wb.AddData(nest1) - - if err := s.Send(wb); err != nil { - return err - } - return s.HandleAck(wb.Seq) -} - -// Create the actual bridge device. This is more backward-compatible than -// netlink.NetworkLinkAdd and works on RHEL 6. -func CreateBridge(name string, setMacAddr bool) error { - s, err := syscall.Socket(syscall.AF_INET6, syscall.SOCK_STREAM, syscall.IPPROTO_IP) - if err != nil { - // ipv6 issue, creating with ipv4 - s, err = syscall.Socket(syscall.AF_INET, syscall.SOCK_STREAM, syscall.IPPROTO_IP) - if err != nil { - return err - } - } - defer syscall.Close(s) - - nameBytePtr, err := syscall.BytePtrFromString(name) - if err != nil { - return err - } - if _, _, err := syscall.Syscall(syscall.SYS_IOCTL, uintptr(s), SIOC_BRADDBR, uintptr(unsafe.Pointer(nameBytePtr))); err != 0 { - return err - } - if setMacAddr { - return setBridgeMacAddress(s, name) - } - return nil -} - -// Add a slave to abridge device. This is more backward-compatible than -// netlink.NetworkSetMaster and works on RHEL 6. -func AddToBridge(iface, master *net.Interface) error { - s, err := syscall.Socket(syscall.AF_INET6, syscall.SOCK_STREAM, syscall.IPPROTO_IP) - if err != nil { - // ipv6 issue, creating with ipv4 - s, err = syscall.Socket(syscall.AF_INET, syscall.SOCK_STREAM, syscall.IPPROTO_IP) - if err != nil { - return err - } - } - defer syscall.Close(s) - - ifr := ifreqIndex{} - copy(ifr.IfrnName[:], master.Name) - ifr.IfruIndex = int32(iface.Index) - - if _, _, err := syscall.Syscall(syscall.SYS_IOCTL, uintptr(s), SIOC_BRADDIF, uintptr(unsafe.Pointer(&ifr))); err != 0 { - return err - } - - return nil -} - -func setBridgeMacAddress(s int, name string) error { - ifr := ifreqHwaddr{} - ifr.IfruHwaddr.Family = syscall.ARPHRD_ETHER - copy(ifr.IfrnName[:], name) - - for i := 0; i < 6; i++ { - ifr.IfruHwaddr.Data[i] = int8(rand.Intn(255)) - } - - ifr.IfruHwaddr.Data[0] &^= 0x1 // clear multicast bit - ifr.IfruHwaddr.Data[0] |= 0x2 // set local assignment bit (IEEE802) - - if _, _, err := syscall.Syscall(syscall.SYS_IOCTL, uintptr(s), syscall.SIOCSIFHWADDR, uintptr(unsafe.Pointer(&ifr))); err != 0 { - return err - } - return nil -} diff --git a/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/dotcloud/docker/pkg/netlink/netlink_unsupported.go b/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/dotcloud/docker/pkg/netlink/netlink_unsupported.go deleted file mode 100644 index 8a5531b9..00000000 --- a/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/dotcloud/docker/pkg/netlink/netlink_unsupported.go +++ /dev/null @@ -1,69 +0,0 @@ -// +build !linux !amd64 - -package netlink - -import ( - "errors" - "net" -) - -var ( - ErrNotImplemented = errors.New("not implemented") -) - -func NetworkGetRoutes() ([]Route, error) { - return nil, ErrNotImplemented -} - -func NetworkLinkAdd(name string, linkType string) error { - return ErrNotImplemented -} - -func NetworkLinkUp(iface *net.Interface) error { - return ErrNotImplemented -} - -func NetworkLinkAddIp(iface *net.Interface, ip net.IP, ipNet *net.IPNet) error { - return ErrNotImplemented -} - -func AddDefaultGw(ip net.IP) error { - return ErrNotImplemented - -} - -func NetworkSetMTU(iface *net.Interface, mtu int) error { - return ErrNotImplemented -} - -func NetworkCreateVethPair(name1, name2 string) error { - return ErrNotImplemented -} - -func NetworkChangeName(iface *net.Interface, newName string) error { - return ErrNotImplemented -} - -func NetworkSetNsFd(iface *net.Interface, fd int) error { - return ErrNotImplemented -} - -func NetworkSetNsPid(iface *net.Interface, nspid int) error { - return ErrNotImplemented -} - -func NetworkSetMaster(iface, master *net.Interface) error { - return ErrNotImplemented -} - -func NetworkLinkDown(iface *net.Interface) error { - return ErrNotImplemented -} - -func CreateBridge(name string, setMacAddr bool) error { - return ErrNotImplemented -} - -func AddToBridge(iface, master *net.Interface) error { - return ErrNotImplemented -} diff --git a/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/guelfey/go.dbus/LICENSE b/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/guelfey/go.dbus/LICENSE deleted file mode 100644 index 06b252bc..00000000 --- a/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/guelfey/go.dbus/LICENSE +++ /dev/null @@ -1,25 +0,0 @@ -Copyright (c) 2013, Georg Reinke (<guelfey at gmail dot com>) -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions -are met: - -1. Redistributions of source code must retain the above copyright notice, -this list of conditions and the following disclaimer. - -2. Redistributions in binary form must reproduce the above copyright -notice, this list of conditions and the following disclaimer in the -documentation and/or other materials provided with the distribution. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/guelfey/go.dbus/README.markdown b/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/guelfey/go.dbus/README.markdown deleted file mode 100644 index dc467fdb..00000000 --- a/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/guelfey/go.dbus/README.markdown +++ /dev/null @@ -1,36 +0,0 @@ -go.dbus -------- - -go.dbus is a simple library that implements native Go client bindings for the -D-Bus message bus system. - -### Features - -* Complete native implementation of the D-Bus message protocol -* Go-like API (channels for signals / asynchronous method calls, Goroutine-safe connections) -* Subpackages that help with the introspection / property interfaces - -### Installation - -This packages requires Go 1.1. If you installed it and set up your GOPATH, just run: - -``` -go get github.com/guelfey/go.dbus -``` - -If you want to use the subpackages, you can install them the same way. - -### Usage - -The complete package documentation and some simple examples are available at -[godoc.org](http://godoc.org/github.com/guelfey/go.dbus). Also, the -[_examples](https://github.com/guelfey/go.dbus/tree/master/_examples) directory -gives a short overview over the basic usage. - -Please note that the API is considered unstable for now and may change without -further notice. - -### License - -go.dbus is available under the Simplified BSD License; see LICENSE for the full -text. diff --git a/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/guelfey/go.dbus/auth.go b/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/guelfey/go.dbus/auth.go deleted file mode 100644 index bf70a896..00000000 --- a/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/guelfey/go.dbus/auth.go +++ /dev/null @@ -1,255 +0,0 @@ -package dbus - -import ( - "bufio" - "bytes" - "errors" - "io" - "os/user" -) - -// AuthStatus represents the Status of an authentication mechanism. -type AuthStatus byte - -const ( - // AuthOk signals that authentication is finished; the next command - // from the server should be an OK. - AuthOk AuthStatus = iota - - // AuthContinue signals that additional data is needed; the next command - // from the server should be a DATA. - AuthContinue - - // AuthError signals an error; the server sent invalid data or some - // other unexpected thing happened and the current authentication - // process should be aborted. - AuthError -) - -type authState byte - -const ( - waitingForData authState = iota - waitingForOk - waitingForReject -) - -// Auth defines the behaviour of an authentication mechanism. -type Auth interface { - // Return the name of the mechnism, the argument to the first AUTH command - // and the next status. - FirstData() (name, resp []byte, status AuthStatus) - - // Process the given DATA command, and return the argument to the DATA - // command and the next status. If len(resp) == 0, no DATA command is sent. - HandleData(data []byte) (resp []byte, status AuthStatus) -} - -// Auth authenticates the connection, trying the given list of authentication -// mechanisms (in that order). If nil is passed, the EXTERNAL and -// DBUS_COOKIE_SHA1 mechanisms are tried for the current user. For private -// connections, this method must be called before sending any messages to the -// bus. Auth must not be called on shared connections. -func (conn *Conn) Auth(methods []Auth) error { - if methods == nil { - u, err := user.Current() - if err != nil { - return err - } - methods = []Auth{AuthExternal(u.Username), AuthCookieSha1(u.Username, u.HomeDir)} - } - in := bufio.NewReader(conn.transport) - err := conn.transport.SendNullByte() - if err != nil { - return err - } - err = authWriteLine(conn.transport, []byte("AUTH")) - if err != nil { - return err - } - s, err := authReadLine(in) - if err != nil { - return err - } - if len(s) < 2 || !bytes.Equal(s[0], []byte("REJECTED")) { - return errors.New("dbus: authentication protocol error") - } - s = s[1:] - for _, v := range s { - for _, m := range methods { - if name, data, status := m.FirstData(); bytes.Equal(v, name) { - var ok bool - err = authWriteLine(conn.transport, []byte("AUTH"), []byte(v), data) - if err != nil { - return err - } - switch status { - case AuthOk: - err, ok = conn.tryAuth(m, waitingForOk, in) - case AuthContinue: - err, ok = conn.tryAuth(m, waitingForData, in) - default: - panic("dbus: invalid authentication status") - } - if err != nil { - return err - } - if ok { - if conn.transport.SupportsUnixFDs() { - err = authWriteLine(conn, []byte("NEGOTIATE_UNIX_FD")) - if err != nil { - return err - } - line, err := authReadLine(in) - if err != nil { - return err - } - switch { - case bytes.Equal(line[0], []byte("AGREE_UNIX_FD")): - conn.EnableUnixFDs() - conn.unixFD = true - case bytes.Equal(line[0], []byte("ERROR")): - default: - return errors.New("dbus: authentication protocol error") - } - } - err = authWriteLine(conn.transport, []byte("BEGIN")) - if err != nil { - return err - } - go conn.inWorker() - go conn.outWorker() - return nil - } - } - } - } - return errors.New("dbus: authentication failed") -} - -// tryAuth tries to authenticate with m as the mechanism, using state as the -// initial authState and in for reading input. It returns (nil, true) on -// success, (nil, false) on a REJECTED and (someErr, false) if some other -// error occured. -func (conn *Conn) tryAuth(m Auth, state authState, in *bufio.Reader) (error, bool) { - for { - s, err := authReadLine(in) - if err != nil { - return err, false - } - switch { - case state == waitingForData && string(s[0]) == "DATA": - if len(s) != 2 { - err = authWriteLine(conn.transport, []byte("ERROR")) - if err != nil { - return err, false - } - continue - } - data, status := m.HandleData(s[1]) - switch status { - case AuthOk, AuthContinue: - if len(data) != 0 { - err = authWriteLine(conn.transport, []byte("DATA"), data) - if err != nil { - return err, false - } - } - if status == AuthOk { - state = waitingForOk - } - case AuthError: - err = authWriteLine(conn.transport, []byte("ERROR")) - if err != nil { - return err, false - } - } - case state == waitingForData && string(s[0]) == "REJECTED": - return nil, false - case state == waitingForData && string(s[0]) == "ERROR": - err = authWriteLine(conn.transport, []byte("CANCEL")) - if err != nil { - return err, false - } - state = waitingForReject - case state == waitingForData && string(s[0]) == "OK": - if len(s) != 2 { - err = authWriteLine(conn.transport, []byte("CANCEL")) - if err != nil { - return err, false - } - state = waitingForReject - } - conn.uuid = string(s[1]) - return nil, true - case state == waitingForData: - err = authWriteLine(conn.transport, []byte("ERROR")) - if err != nil { - return err, false - } - case state == waitingForOk && string(s[0]) == "OK": - if len(s) != 2 { - err = authWriteLine(conn.transport, []byte("CANCEL")) - if err != nil { - return err, false - } - state = waitingForReject - } - conn.uuid = string(s[1]) - return nil, true - case state == waitingForOk && string(s[0]) == "REJECTED": - return nil, false - case state == waitingForOk && (string(s[0]) == "DATA" || - string(s[0]) == "ERROR"): - - err = authWriteLine(conn.transport, []byte("CANCEL")) - if err != nil { - return err, false - } - state = waitingForReject - case state == waitingForOk: - err = authWriteLine(conn.transport, []byte("ERROR")) - if err != nil { - return err, false - } - case state == waitingForReject && string(s[0]) == "REJECTED": - return nil, false - case state == waitingForReject: - return errors.New("dbus: authentication protocol error"), false - default: - panic("dbus: invalid auth state") - } - } -} - -// authReadLine reads a line and separates it into its fields. -func authReadLine(in *bufio.Reader) ([][]byte, error) { - data, err := in.ReadBytes('\n') - if err != nil { - return nil, err - } - data = bytes.TrimSuffix(data, []byte("\r\n")) - return bytes.Split(data, []byte{' '}), nil -} - -// authWriteLine writes the given line in the authentication protocol format -// (elements of data separated by a " " and terminated by "\r\n"). -func authWriteLine(out io.Writer, data ...[]byte) error { - buf := make([]byte, 0) - for i, v := range data { - buf = append(buf, v...) - if i != len(data)-1 { - buf = append(buf, ' ') - } - } - buf = append(buf, '\r') - buf = append(buf, '\n') - n, err := out.Write(buf) - if err != nil { - return err - } - if n != len(buf) { - return io.ErrUnexpectedEOF - } - return nil -} diff --git a/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/guelfey/go.dbus/auth_external.go b/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/guelfey/go.dbus/auth_external.go deleted file mode 100644 index 7e376d3e..00000000 --- a/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/guelfey/go.dbus/auth_external.go +++ /dev/null @@ -1,26 +0,0 @@ -package dbus - -import ( - "encoding/hex" -) - -// AuthExternal returns an Auth that authenticates as the given user with the -// EXTERNAL mechanism. -func AuthExternal(user string) Auth { - return authExternal{user} -} - -// AuthExternal implements the EXTERNAL authentication mechanism. -type authExternal struct { - user string -} - -func (a authExternal) FirstData() ([]byte, []byte, AuthStatus) { - b := make([]byte, 2*len(a.user)) - hex.Encode(b, []byte(a.user)) - return []byte("EXTERNAL"), b, AuthOk -} - -func (a authExternal) HandleData(b []byte) ([]byte, AuthStatus) { - return nil, AuthError -} diff --git a/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/guelfey/go.dbus/auth_sha1.go b/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/guelfey/go.dbus/auth_sha1.go deleted file mode 100644 index df15b461..00000000 --- a/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/guelfey/go.dbus/auth_sha1.go +++ /dev/null @@ -1,102 +0,0 @@ -package dbus - -import ( - "bufio" - "bytes" - "crypto/rand" - "crypto/sha1" - "encoding/hex" - "os" -) - -// AuthCookieSha1 returns an Auth that authenticates as the given user with the -// DBUS_COOKIE_SHA1 mechanism. The home parameter should specify the home -// directory of the user. -func AuthCookieSha1(user, home string) Auth { - return authCookieSha1{user, home} -} - -type authCookieSha1 struct { - user, home string -} - -func (a authCookieSha1) FirstData() ([]byte, []byte, AuthStatus) { - b := make([]byte, 2*len(a.user)) - hex.Encode(b, []byte(a.user)) - return []byte("DBUS_COOKIE_SHA1"), b, AuthContinue -} - -func (a authCookieSha1) HandleData(data []byte) ([]byte, AuthStatus) { - challenge := make([]byte, len(data)/2) - _, err := hex.Decode(challenge, data) - if err != nil { - return nil, AuthError - } - b := bytes.Split(challenge, []byte{' '}) - if len(b) != 3 { - return nil, AuthError - } - context := b[0] - id := b[1] - svchallenge := b[2] - cookie := a.getCookie(context, id) - if cookie == nil { - return nil, AuthError - } - clchallenge := a.generateChallenge() - if clchallenge == nil { - return nil, AuthError - } - hash := sha1.New() - hash.Write(bytes.Join([][]byte{svchallenge, clchallenge, cookie}, []byte{':'})) - hexhash := make([]byte, 2*hash.Size()) - hex.Encode(hexhash, hash.Sum(nil)) - data = append(clchallenge, ' ') - data = append(data, hexhash...) - resp := make([]byte, 2*len(data)) - hex.Encode(resp, data) - return resp, AuthOk -} - -// getCookie searches for the cookie identified by id in context and returns -// the cookie content or nil. (Since HandleData can't return a specific error, -// but only whether an error occured, this function also doesn't bother to -// return an error.) -func (a authCookieSha1) getCookie(context, id []byte) []byte { - file, err := os.Open(a.home + "/.dbus-keyrings/" + string(context)) - if err != nil { - return nil - } - defer file.Close() - rd := bufio.NewReader(file) - for { - line, err := rd.ReadBytes('\n') - if err != nil { - return nil - } - line = line[:len(line)-1] - b := bytes.Split(line, []byte{' '}) - if len(b) != 3 { - return nil - } - if bytes.Equal(b[0], id) { - return b[2] - } - } -} - -// generateChallenge returns a random, hex-encoded challenge, or nil on error -// (see above). -func (a authCookieSha1) generateChallenge() []byte { - b := make([]byte, 16) - n, err := rand.Read(b) - if err != nil { - return nil - } - if n != 16 { - return nil - } - enc := make([]byte, 32) - hex.Encode(enc, b) - return enc -} diff --git a/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/guelfey/go.dbus/call.go b/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/guelfey/go.dbus/call.go deleted file mode 100644 index 1d2fbc7e..00000000 --- a/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/guelfey/go.dbus/call.go +++ /dev/null @@ -1,147 +0,0 @@ -package dbus - -import ( - "errors" - "strings" -) - -// Call represents a pending or completed method call. -type Call struct { - Destination string - Path ObjectPath - Method string - Args []interface{} - - // Strobes when the call is complete. - Done chan *Call - - // After completion, the error status. If this is non-nil, it may be an - // error message from the peer (with Error as its type) or some other error. - Err error - - // Holds the response once the call is done. - Body []interface{} -} - -var errSignature = errors.New("dbus: mismatched signature") - -// Store stores the body of the reply into the provided pointers. It returns -// an error if the signatures of the body and retvalues don't match, or if -// the error status is not nil. -func (c *Call) Store(retvalues ...interface{}) error { - if c.Err != nil { - return c.Err - } - - return Store(c.Body, retvalues...) -} - -// Object represents a remote object on which methods can be invoked. -type Object struct { - conn *Conn - dest string - path ObjectPath -} - -// Call calls a method with (*Object).Go and waits for its reply. -func (o *Object) Call(method string, flags Flags, args ...interface{}) *Call { - return <-o.Go(method, flags, make(chan *Call, 1), args...).Done -} - -// GetProperty calls org.freedesktop.DBus.Properties.GetProperty on the given -// object. The property name must be given in interface.member notation. -func (o *Object) GetProperty(p string) (Variant, error) { - idx := strings.LastIndex(p, ".") - if idx == -1 || idx+1 == len(p) { - return Variant{}, errors.New("dbus: invalid property " + p) - } - - iface := p[:idx] - prop := p[idx+1:] - - result := Variant{} - err := o.Call("org.freedesktop.DBus.Properties.Get", 0, iface, prop).Store(&result) - - if err != nil { - return Variant{}, err - } - - return result, nil -} - -// Go calls a method with the given arguments asynchronously. It returns a -// Call structure representing this method call. The passed channel will -// return the same value once the call is done. If ch is nil, a new channel -// will be allocated. Otherwise, ch has to be buffered or Go will panic. -// -// If the flags include FlagNoReplyExpected, ch is ignored and a Call structure -// is returned of which only the Err member is valid. -// -// If the method parameter contains a dot ('.'), the part before the last dot -// specifies the interface on which the method is called. -func (o *Object) Go(method string, flags Flags, ch chan *Call, args ...interface{}) *Call { - iface := "" - i := strings.LastIndex(method, ".") - if i != -1 { - iface = method[:i] - } - method = method[i+1:] - msg := new(Message) - msg.Type = TypeMethodCall - msg.serial = o.conn.getSerial() - msg.Flags = flags & (FlagNoAutoStart | FlagNoReplyExpected) - msg.Headers = make(map[HeaderField]Variant) - msg.Headers[FieldPath] = MakeVariant(o.path) - msg.Headers[FieldDestination] = MakeVariant(o.dest) - msg.Headers[FieldMember] = MakeVariant(method) - if iface != "" { - msg.Headers[FieldInterface] = MakeVariant(iface) - } - msg.Body = args - if len(args) > 0 { - msg.Headers[FieldSignature] = MakeVariant(SignatureOf(args...)) - } - if msg.Flags&FlagNoReplyExpected == 0 { - if ch == nil { - ch = make(chan *Call, 10) - } else if cap(ch) == 0 { - panic("dbus: unbuffered channel passed to (*Object).Go") - } - call := &Call{ - Destination: o.dest, - Path: o.path, - Method: method, - Args: args, - Done: ch, - } - o.conn.callsLck.Lock() - o.conn.calls[msg.serial] = call - o.conn.callsLck.Unlock() - o.conn.outLck.RLock() - if o.conn.closed { - call.Err = ErrClosed - call.Done <- call - } else { - o.conn.out <- msg - } - o.conn.outLck.RUnlock() - return call - } - o.conn.outLck.RLock() - defer o.conn.outLck.RUnlock() - if o.conn.closed { - return &Call{Err: ErrClosed} - } - o.conn.out <- msg - return &Call{Err: nil} -} - -// Destination returns the destination that calls on o are sent to. -func (o *Object) Destination() string { - return o.dest -} - -// Path returns the path that calls on o are sent to. -func (o *Object) Path() ObjectPath { - return o.path -} diff --git a/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/guelfey/go.dbus/conn.go b/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/guelfey/go.dbus/conn.go deleted file mode 100644 index b38f852f..00000000 --- a/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/guelfey/go.dbus/conn.go +++ /dev/null @@ -1,597 +0,0 @@ -package dbus - -import ( - "errors" - "io" - "os" - "reflect" - "strings" - "sync" -) - -const defaultSystemBusAddress = "unix:path=/var/run/dbus/system_bus_socket" - -var ( - systemBus *Conn - systemBusLck sync.Mutex - sessionBus *Conn - sessionBusLck sync.Mutex -) - -// ErrClosed is the error returned by calls on a closed connection. -var ErrClosed = errors.New("dbus: connection closed by user") - -// Conn represents a connection to a message bus (usually, the system or -// session bus). -// -// Connections are either shared or private. Shared connections -// are shared between calls to the functions that return them. As a result, -// the methods Close, Auth and Hello must not be called on them. -// -// Multiple goroutines may invoke methods on a connection simultaneously. -type Conn struct { - transport - - busObj *Object - unixFD bool - uuid string - - names []string - namesLck sync.RWMutex - - serialLck sync.Mutex - nextSerial uint32 - serialUsed map[uint32]bool - - calls map[uint32]*Call - callsLck sync.RWMutex - - handlers map[ObjectPath]map[string]interface{} - handlersLck sync.RWMutex - - out chan *Message - closed bool - outLck sync.RWMutex - - signals []chan<- *Signal - signalsLck sync.Mutex - - eavesdropped chan<- *Message - eavesdroppedLck sync.Mutex -} - -// SessionBus returns a shared connection to the session bus, connecting to it -// if not already done. -func SessionBus() (conn *Conn, err error) { - sessionBusLck.Lock() - defer sessionBusLck.Unlock() - if sessionBus != nil { - return sessionBus, nil - } - defer func() { - if conn != nil { - sessionBus = conn - } - }() - conn, err = SessionBusPrivate() - if err != nil { - return - } - if err = conn.Auth(nil); err != nil { - conn.Close() - conn = nil - return - } - if err = conn.Hello(); err != nil { - conn.Close() - conn = nil - } - return -} - -// SessionBusPrivate returns a new private connection to the session bus. -func SessionBusPrivate() (*Conn, error) { - address := os.Getenv("DBUS_SESSION_BUS_ADDRESS") - if address != "" && address != "autolaunch:" { - return Dial(address) - } - - return sessionBusPlatform() -} - -// SystemBus returns a shared connection to the system bus, connecting to it if -// not already done. -func SystemBus() (conn *Conn, err error) { - systemBusLck.Lock() - defer systemBusLck.Unlock() - if systemBus != nil { - return systemBus, nil - } - defer func() { - if conn != nil { - systemBus = conn - } - }() - conn, err = SystemBusPrivate() - if err != nil { - return - } - if err = conn.Auth(nil); err != nil { - conn.Close() - conn = nil - return - } - if err = conn.Hello(); err != nil { - conn.Close() - conn = nil - } - return -} - -// SystemBusPrivate returns a new private connection to the system bus. -func SystemBusPrivate() (*Conn, error) { - address := os.Getenv("DBUS_SYSTEM_BUS_ADDRESS") - if address != "" { - return Dial(address) - } - return Dial(defaultSystemBusAddress) -} - -// Dial establishes a new private connection to the message bus specified by address. -func Dial(address string) (*Conn, error) { - tr, err := getTransport(address) - if err != nil { - return nil, err - } - return newConn(tr) -} - -// NewConn creates a new private *Conn from an already established connection. -func NewConn(conn io.ReadWriteCloser) (*Conn, error) { - return newConn(genericTransport{conn}) -} - -// newConn creates a new *Conn from a transport. -func newConn(tr transport) (*Conn, error) { - conn := new(Conn) - conn.transport = tr - conn.calls = make(map[uint32]*Call) - conn.out = make(chan *Message, 10) - conn.handlers = make(map[ObjectPath]map[string]interface{}) - conn.nextSerial = 1 - conn.serialUsed = map[uint32]bool{0: true} - conn.busObj = conn.Object("org.freedesktop.DBus", "/org/freedesktop/DBus") - return conn, nil -} - -// BusObject returns the object owned by the bus daemon which handles -// administrative requests. -func (conn *Conn) BusObject() *Object { - return conn.busObj -} - -// Close closes the connection. Any blocked operations will return with errors -// and the channels passed to Eavesdrop and Signal are closed. This method must -// not be called on shared connections. -func (conn *Conn) Close() error { - conn.outLck.Lock() - close(conn.out) - conn.closed = true - conn.outLck.Unlock() - conn.signalsLck.Lock() - for _, ch := range conn.signals { - close(ch) - } - conn.signalsLck.Unlock() - conn.eavesdroppedLck.Lock() - if conn.eavesdropped != nil { - close(conn.eavesdropped) - } - conn.eavesdroppedLck.Unlock() - return conn.transport.Close() -} - -// Eavesdrop causes conn to send all incoming messages to the given channel -// without further processing. Method replies, errors and signals will not be -// sent to the appropiate channels and method calls will not be handled. If nil -// is passed, the normal behaviour is restored. -// -// The caller has to make sure that ch is sufficiently buffered; -// if a message arrives when a write to ch is not possible, the message is -// discarded. -func (conn *Conn) Eavesdrop(ch chan<- *Message) { - conn.eavesdroppedLck.Lock() - conn.eavesdropped = ch - conn.eavesdroppedLck.Unlock() -} - -// getSerial returns an unused serial. -func (conn *Conn) getSerial() uint32 { - conn.serialLck.Lock() - defer conn.serialLck.Unlock() - n := conn.nextSerial - for conn.serialUsed[n] { - n++ - } - conn.serialUsed[n] = true - conn.nextSerial = n + 1 - return n -} - -// Hello sends the initial org.freedesktop.DBus.Hello call. This method must be -// called after authentication, but before sending any other messages to the -// bus. Hello must not be called for shared connections. -func (conn *Conn) Hello() error { - var s string - err := conn.busObj.Call("org.freedesktop.DBus.Hello", 0).Store(&s) - if err != nil { - return err - } - conn.namesLck.Lock() - conn.names = make([]string, 1) - conn.names[0] = s - conn.namesLck.Unlock() - return nil -} - -// inWorker runs in an own goroutine, reading incoming messages from the -// transport and dispatching them appropiately. -func (conn *Conn) inWorker() { - for { - msg, err := conn.ReadMessage() - if err == nil { - conn.eavesdroppedLck.Lock() - if conn.eavesdropped != nil { - select { - case conn.eavesdropped <- msg: - default: - } - conn.eavesdroppedLck.Unlock() - continue - } - conn.eavesdroppedLck.Unlock() - dest, _ := msg.Headers[FieldDestination].value.(string) - found := false - if dest == "" { - found = true - } else { - conn.namesLck.RLock() - if len(conn.names) == 0 { - found = true - } - for _, v := range conn.names { - if dest == v { - found = true - break - } - } - conn.namesLck.RUnlock() - } - if !found { - // Eavesdropped a message, but no channel for it is registered. - // Ignore it. - continue - } - switch msg.Type { - case TypeMethodReply, TypeError: - serial := msg.Headers[FieldReplySerial].value.(uint32) - conn.callsLck.Lock() - if c, ok := conn.calls[serial]; ok { - if msg.Type == TypeError { - name, _ := msg.Headers[FieldErrorName].value.(string) - c.Err = Error{name, msg.Body} - } else { - c.Body = msg.Body - } - c.Done <- c - conn.serialLck.Lock() - delete(conn.serialUsed, serial) - conn.serialLck.Unlock() - delete(conn.calls, serial) - } - conn.callsLck.Unlock() - case TypeSignal: - iface := msg.Headers[FieldInterface].value.(string) - member := msg.Headers[FieldMember].value.(string) - // as per http://dbus.freedesktop.org/doc/dbus-specification.html , - // sender is optional for signals. - sender, _ := msg.Headers[FieldSender].value.(string) - if iface == "org.freedesktop.DBus" && member == "NameLost" && - sender == "org.freedesktop.DBus" { - - name, _ := msg.Body[0].(string) - conn.namesLck.Lock() - for i, v := range conn.names { - if v == name { - copy(conn.names[i:], conn.names[i+1:]) - conn.names = conn.names[:len(conn.names)-1] - } - } - conn.namesLck.Unlock() - } - signal := &Signal{ - Sender: sender, - Path: msg.Headers[FieldPath].value.(ObjectPath), - Name: iface + "." + member, - Body: msg.Body, - } - conn.signalsLck.Lock() - for _, ch := range conn.signals { - // don't block trying to send a signal - select { - case ch <- signal: - default: - } - } - conn.signalsLck.Unlock() - case TypeMethodCall: - go conn.handleCall(msg) - } - } else if _, ok := err.(InvalidMessageError); !ok { - // Some read error occured (usually EOF); we can't really do - // anything but to shut down all stuff and returns errors to all - // pending replies. - conn.Close() - conn.callsLck.RLock() - for _, v := range conn.calls { - v.Err = err - v.Done <- v - } - conn.callsLck.RUnlock() - return - } - // invalid messages are ignored - } -} - -// Names returns the list of all names that are currently owned by this -// connection. The slice is always at least one element long, the first element -// being the unique name of the connection. -func (conn *Conn) Names() []string { - conn.namesLck.RLock() - // copy the slice so it can't be modified - s := make([]string, len(conn.names)) - copy(s, conn.names) - conn.namesLck.RUnlock() - return s -} - -// Object returns the object identified by the given destination name and path. -func (conn *Conn) Object(dest string, path ObjectPath) *Object { - return &Object{conn, dest, path} -} - -// outWorker runs in an own goroutine, encoding and sending messages that are -// sent to conn.out. -func (conn *Conn) outWorker() { - for msg := range conn.out { - err := conn.SendMessage(msg) - conn.callsLck.RLock() - if err != nil { - if c := conn.calls[msg.serial]; c != nil { - c.Err = err - c.Done <- c - } - conn.serialLck.Lock() - delete(conn.serialUsed, msg.serial) - conn.serialLck.Unlock() - } else if msg.Type != TypeMethodCall { - conn.serialLck.Lock() - delete(conn.serialUsed, msg.serial) - conn.serialLck.Unlock() - } - conn.callsLck.RUnlock() - } -} - -// Send sends the given message to the message bus. You usually don't need to -// use this; use the higher-level equivalents (Call / Go, Emit and Export) -// instead. If msg is a method call and NoReplyExpected is not set, a non-nil -// call is returned and the same value is sent to ch (which must be buffered) -// once the call is complete. Otherwise, ch is ignored and a Call structure is -// returned of which only the Err member is valid. -func (conn *Conn) Send(msg *Message, ch chan *Call) *Call { - var call *Call - - msg.serial = conn.getSerial() - if msg.Type == TypeMethodCall && msg.Flags&FlagNoReplyExpected == 0 { - if ch == nil { - ch = make(chan *Call, 5) - } else if cap(ch) == 0 { - panic("dbus: unbuffered channel passed to (*Conn).Send") - } - call = new(Call) - call.Destination, _ = msg.Headers[FieldDestination].value.(string) - call.Path, _ = msg.Headers[FieldPath].value.(ObjectPath) - iface, _ := msg.Headers[FieldInterface].value.(string) - member, _ := msg.Headers[FieldMember].value.(string) - call.Method = iface + "." + member - call.Args = msg.Body - call.Done = ch - conn.callsLck.Lock() - conn.calls[msg.serial] = call - conn.callsLck.Unlock() - conn.outLck.RLock() - if conn.closed { - call.Err = ErrClosed - call.Done <- call - } else { - conn.out <- msg - } - conn.outLck.RUnlock() - } else { - conn.outLck.RLock() - if conn.closed { - call = &Call{Err: ErrClosed} - } else { - conn.out <- msg - call = &Call{Err: nil} - } - conn.outLck.RUnlock() - } - return call -} - -// sendError creates an error message corresponding to the parameters and sends -// it to conn.out. -func (conn *Conn) sendError(e Error, dest string, serial uint32) { - msg := new(Message) - msg.Type = TypeError - msg.serial = conn.getSerial() - msg.Headers = make(map[HeaderField]Variant) - msg.Headers[FieldDestination] = MakeVariant(dest) - msg.Headers[FieldErrorName] = MakeVariant(e.Name) - msg.Headers[FieldReplySerial] = MakeVariant(serial) - msg.Body = e.Body - if len(e.Body) > 0 { - msg.Headers[FieldSignature] = MakeVariant(SignatureOf(e.Body...)) - } - conn.outLck.RLock() - if !conn.closed { - conn.out <- msg - } - conn.outLck.RUnlock() -} - -// sendReply creates a method reply message corresponding to the parameters and -// sends it to conn.out. -func (conn *Conn) sendReply(dest string, serial uint32, values ...interface{}) { - msg := new(Message) - msg.Type = TypeMethodReply - msg.serial = conn.getSerial() - msg.Headers = make(map[HeaderField]Variant) - msg.Headers[FieldDestination] = MakeVariant(dest) - msg.Headers[FieldReplySerial] = MakeVariant(serial) - msg.Body = values - if len(values) > 0 { - msg.Headers[FieldSignature] = MakeVariant(SignatureOf(values...)) - } - conn.outLck.RLock() - if !conn.closed { - conn.out <- msg - } - conn.outLck.RUnlock() -} - -// Signal registers the given channel to be passed all received signal messages. -// The caller has to make sure that ch is sufficiently buffered; if a message -// arrives when a write to c is not possible, it is discarded. -// -// Multiple of these channels can be registered at the same time. Passing a -// channel that already is registered will remove it from the list of the -// registered channels. -// -// These channels are "overwritten" by Eavesdrop; i.e., if there currently is a -// channel for eavesdropped messages, this channel receives all signals, and -// none of the channels passed to Signal will receive any signals. -func (conn *Conn) Signal(ch chan<- *Signal) { - conn.signalsLck.Lock() - conn.signals = append(conn.signals, ch) - conn.signalsLck.Unlock() -} - -// SupportsUnixFDs returns whether the underlying transport supports passing of -// unix file descriptors. If this is false, method calls containing unix file -// descriptors will return an error and emitted signals containing them will -// not be sent. -func (conn *Conn) SupportsUnixFDs() bool { - return conn.unixFD -} - -// Error represents a D-Bus message of type Error. -type Error struct { - Name string - Body []interface{} -} - -func (e Error) Error() string { - if len(e.Body) >= 1 { - s, ok := e.Body[0].(string) - if ok { - return s - } - } - return e.Name -} - -// Signal represents a D-Bus message of type Signal. The name member is given in -// "interface.member" notation, e.g. org.freedesktop.D-Bus.NameLost. -type Signal struct { - Sender string - Path ObjectPath - Name string - Body []interface{} -} - -// transport is a D-Bus transport. -type transport interface { - // Read and Write raw data (for example, for the authentication protocol). - io.ReadWriteCloser - - // Send the initial null byte used for the EXTERNAL mechanism. - SendNullByte() error - - // Returns whether this transport supports passing Unix FDs. - SupportsUnixFDs() bool - - // Signal the transport that Unix FD passing is enabled for this connection. - EnableUnixFDs() - - // Read / send a message, handling things like Unix FDs. - ReadMessage() (*Message, error) - SendMessage(*Message) error -} - -func getTransport(address string) (transport, error) { - var err error - var t transport - - m := map[string]func(string) (transport, error){ - "unix": newUnixTransport, - } - addresses := strings.Split(address, ";") - for _, v := range addresses { - i := strings.IndexRune(v, ':') - if i == -1 { - err = errors.New("dbus: invalid bus address (no transport)") - continue - } - f := m[v[:i]] - if f == nil { - err = errors.New("dbus: invalid bus address (invalid or unsupported transport)") - } - t, err = f(v[i+1:]) - if err == nil { - return t, nil - } - } - return nil, err -} - -// dereferenceAll returns a slice that, assuming that vs is a slice of pointers -// of arbitrary types, containes the values that are obtained from dereferencing -// all elements in vs. -func dereferenceAll(vs []interface{}) []interface{} { - for i := range vs { - v := reflect.ValueOf(vs[i]) - v = v.Elem() - vs[i] = v.Interface() - } - return vs -} - -// getKey gets a key from a the list of keys. Returns "" on error / not found... -func getKey(s, key string) string { - i := strings.Index(s, key) - if i == -1 { - return "" - } - if i+len(key)+1 >= len(s) || s[i+len(key)] != '=' { - return "" - } - j := strings.Index(s, ",") - if j == -1 { - j = len(s) - } - return s[i+len(key)+1 : j] -} diff --git a/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/guelfey/go.dbus/conn_darwin.go b/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/guelfey/go.dbus/conn_darwin.go deleted file mode 100644 index b67bb1b8..00000000 --- a/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/guelfey/go.dbus/conn_darwin.go +++ /dev/null @@ -1,21 +0,0 @@ -package dbus - -import ( - "errors" - "os/exec" -) - -func sessionBusPlatform() (*Conn, error) { - cmd := exec.Command("launchctl", "getenv", "DBUS_LAUNCHD_SESSION_BUS_SOCKET") - b, err := cmd.CombinedOutput() - - if err != nil { - return nil, err - } - - if len(b) == 0 { - return nil, errors.New("dbus: couldn't determine address of session bus") - } - - return Dial("unix:path=" + string(b[:len(b)-1])) -} diff --git a/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/guelfey/go.dbus/conn_other.go b/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/guelfey/go.dbus/conn_other.go deleted file mode 100644 index f74b8758..00000000 --- a/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/guelfey/go.dbus/conn_other.go +++ /dev/null @@ -1,27 +0,0 @@ -// +build !darwin - -package dbus - -import ( - "bytes" - "errors" - "os/exec" -) - -func sessionBusPlatform() (*Conn, error) { - cmd := exec.Command("dbus-launch") - b, err := cmd.CombinedOutput() - - if err != nil { - return nil, err - } - - i := bytes.IndexByte(b, '=') - j := bytes.IndexByte(b, '\n') - - if i == -1 || j == -1 { - return nil, errors.New("dbus: couldn't determine address of session bus") - } - - return Dial(string(b[i+1 : j])) -} diff --git a/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/guelfey/go.dbus/conn_test.go b/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/guelfey/go.dbus/conn_test.go deleted file mode 100644 index a2b14e8c..00000000 --- a/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/guelfey/go.dbus/conn_test.go +++ /dev/null @@ -1,199 +0,0 @@ -package dbus - -import "testing" - -func TestSessionBus(t *testing.T) { - _, err := SessionBus() - if err != nil { - t.Error(err) - } -} - -func TestSystemBus(t *testing.T) { - _, err := SystemBus() - if err != nil { - t.Error(err) - } -} - -func TestSend(t *testing.T) { - bus, err := SessionBus() - if err != nil { - t.Error(err) - } - ch := make(chan *Call, 1) - msg := &Message{ - Type: TypeMethodCall, - Flags: 0, - Headers: map[HeaderField]Variant{ - FieldDestination: MakeVariant(bus.Names()[0]), - FieldPath: MakeVariant(ObjectPath("/org/freedesktop/DBus")), - FieldInterface: MakeVariant("org.freedesktop.DBus.Peer"), - FieldMember: MakeVariant("Ping"), - }, - } - call := bus.Send(msg, ch) - <-ch - if call.Err != nil { - t.Error(call.Err) - } -} - -type server struct{} - -func (server) Double(i int64) (int64, *Error) { - return 2 * i, nil -} - -func BenchmarkCall(b *testing.B) { - b.StopTimer() - var s string - bus, err := SessionBus() - if err != nil { - b.Fatal(err) - } - name := bus.Names()[0] - obj := bus.BusObject() - b.StartTimer() - for i := 0; i < b.N; i++ { - err := obj.Call("org.freedesktop.DBus.GetNameOwner", 0, name).Store(&s) - if err != nil { - b.Fatal(err) - } - if s != name { - b.Errorf("got %s, wanted %s", s, name) - } - } -} - -func BenchmarkCallAsync(b *testing.B) { - b.StopTimer() - bus, err := SessionBus() - if err != nil { - b.Fatal(err) - } - name := bus.Names()[0] - obj := bus.BusObject() - c := make(chan *Call, 50) - done := make(chan struct{}) - go func() { - for i := 0; i < b.N; i++ { - v := <-c - if v.Err != nil { - b.Error(v.Err) - } - s := v.Body[0].(string) - if s != name { - b.Errorf("got %s, wanted %s", s, name) - } - } - close(done) - }() - b.StartTimer() - for i := 0; i < b.N; i++ { - obj.Go("org.freedesktop.DBus.GetNameOwner", 0, c, name) - } - <-done -} - -func BenchmarkServe(b *testing.B) { - b.StopTimer() - srv, err := SessionBus() - if err != nil { - b.Fatal(err) - } - cli, err := SessionBusPrivate() - if err != nil { - b.Fatal(err) - } - if err = cli.Auth(nil); err != nil { - b.Fatal(err) - } - if err = cli.Hello(); err != nil { - b.Fatal(err) - } - benchmarkServe(b, srv, cli) -} - -func BenchmarkServeAsync(b *testing.B) { - b.StopTimer() - srv, err := SessionBus() - if err != nil { - b.Fatal(err) - } - cli, err := SessionBusPrivate() - if err != nil { - b.Fatal(err) - } - if err = cli.Auth(nil); err != nil { - b.Fatal(err) - } - if err = cli.Hello(); err != nil { - b.Fatal(err) - } - benchmarkServeAsync(b, srv, cli) -} - -func BenchmarkServeSameConn(b *testing.B) { - b.StopTimer() - bus, err := SessionBus() - if err != nil { - b.Fatal(err) - } - - benchmarkServe(b, bus, bus) -} - -func BenchmarkServeSameConnAsync(b *testing.B) { - b.StopTimer() - bus, err := SessionBus() - if err != nil { - b.Fatal(err) - } - - benchmarkServeAsync(b, bus, bus) -} - -func benchmarkServe(b *testing.B, srv, cli *Conn) { - var r int64 - var err error - dest := srv.Names()[0] - srv.Export(server{}, "/org/guelfey/DBus/Test", "org.guelfey.DBus.Test") - obj := cli.Object(dest, "/org/guelfey/DBus/Test") - b.StartTimer() - for i := 0; i < b.N; i++ { - err = obj.Call("org.guelfey.DBus.Test.Double", 0, int64(i)).Store(&r) - if err != nil { - b.Fatal(err) - } - if r != 2*int64(i) { - b.Errorf("got %d, wanted %d", r, 2*int64(i)) - } - } -} - -func benchmarkServeAsync(b *testing.B, srv, cli *Conn) { - dest := srv.Names()[0] - srv.Export(server{}, "/org/guelfey/DBus/Test", "org.guelfey.DBus.Test") - obj := cli.Object(dest, "/org/guelfey/DBus/Test") - c := make(chan *Call, 50) - done := make(chan struct{}) - go func() { - for i := 0; i < b.N; i++ { - v := <-c - if v.Err != nil { - b.Fatal(v.Err) - } - i, r := v.Args[0].(int64), v.Body[0].(int64) - if 2*i != r { - b.Errorf("got %d, wanted %d", r, 2*i) - } - } - close(done) - }() - b.StartTimer() - for i := 0; i < b.N; i++ { - obj.Go("org.guelfey.DBus.Test.Double", 0, c, int64(i)) - } - <-done -} diff --git a/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/guelfey/go.dbus/dbus.go b/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/guelfey/go.dbus/dbus.go deleted file mode 100644 index 2ce68735..00000000 --- a/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/guelfey/go.dbus/dbus.go +++ /dev/null @@ -1,258 +0,0 @@ -package dbus - -import ( - "errors" - "reflect" - "strings" -) - -var ( - byteType = reflect.TypeOf(byte(0)) - boolType = reflect.TypeOf(false) - uint8Type = reflect.TypeOf(uint8(0)) - int16Type = reflect.TypeOf(int16(0)) - uint16Type = reflect.TypeOf(uint16(0)) - int32Type = reflect.TypeOf(int32(0)) - uint32Type = reflect.TypeOf(uint32(0)) - int64Type = reflect.TypeOf(int64(0)) - uint64Type = reflect.TypeOf(uint64(0)) - float64Type = reflect.TypeOf(float64(0)) - stringType = reflect.TypeOf("") - signatureType = reflect.TypeOf(Signature{""}) - objectPathType = reflect.TypeOf(ObjectPath("")) - variantType = reflect.TypeOf(Variant{Signature{""}, nil}) - interfacesType = reflect.TypeOf([]interface{}{}) - unixFDType = reflect.TypeOf(UnixFD(0)) - unixFDIndexType = reflect.TypeOf(UnixFDIndex(0)) -) - -// An InvalidTypeError signals that a value which cannot be represented in the -// D-Bus wire format was passed to a function. -type InvalidTypeError struct { - Type reflect.Type -} - -func (e InvalidTypeError) Error() string { - return "dbus: invalid type " + e.Type.String() -} - -// Store copies the values contained in src to dest, which must be a slice of -// pointers. It converts slices of interfaces from src to corresponding structs -// in dest. An error is returned if the lengths of src and dest or the types of -// their elements don't match. -func Store(src []interface{}, dest ...interface{}) error { - if len(src) != len(dest) { - return errors.New("dbus.Store: length mismatch") - } - - for i := range src { - if err := store(src[i], dest[i]); err != nil { - return err - } - } - return nil -} - -func store(src, dest interface{}) error { - if reflect.TypeOf(dest).Elem() == reflect.TypeOf(src) { - reflect.ValueOf(dest).Elem().Set(reflect.ValueOf(src)) - return nil - } else if hasStruct(dest) { - rv := reflect.ValueOf(dest).Elem() - switch rv.Kind() { - case reflect.Struct: - vs, ok := src.([]interface{}) - if !ok { - return errors.New("dbus.Store: type mismatch") - } - t := rv.Type() - ndest := make([]interface{}, 0, rv.NumField()) - for i := 0; i < rv.NumField(); i++ { - field := t.Field(i) - if field.PkgPath == "" && field.Tag.Get("dbus") != "-" { - ndest = append(ndest, rv.Field(i).Addr().Interface()) - } - } - if len(vs) != len(ndest) { - return errors.New("dbus.Store: type mismatch") - } - err := Store(vs, ndest...) - if err != nil { - return errors.New("dbus.Store: type mismatch") - } - case reflect.Slice: - sv := reflect.ValueOf(src) - if sv.Kind() != reflect.Slice { - return errors.New("dbus.Store: type mismatch") - } - rv.Set(reflect.MakeSlice(rv.Type(), sv.Len(), sv.Len())) - for i := 0; i < sv.Len(); i++ { - if err := store(sv.Index(i).Interface(), rv.Index(i).Addr().Interface()); err != nil { - return err - } - } - case reflect.Map: - sv := reflect.ValueOf(src) - if sv.Kind() != reflect.Map { - return errors.New("dbus.Store: type mismatch") - } - keys := sv.MapKeys() - rv.Set(reflect.MakeMap(sv.Type())) - for _, key := range keys { - v := reflect.New(sv.Type().Elem()) - if err := store(v, sv.MapIndex(key).Interface()); err != nil { - return err - } - rv.SetMapIndex(key, v.Elem()) - } - default: - return errors.New("dbus.Store: type mismatch") - } - return nil - } else { - return errors.New("dbus.Store: type mismatch") - } -} - -func hasStruct(v interface{}) bool { - t := reflect.TypeOf(v) - for { - switch t.Kind() { - case reflect.Struct: - return true - case reflect.Slice, reflect.Ptr, reflect.Map: - t = t.Elem() - default: - return false - } - } -} - -// An ObjectPath is an object path as defined by the D-Bus spec. -type ObjectPath string - -// IsValid returns whether the object path is valid. -func (o ObjectPath) IsValid() bool { - s := string(o) - if len(s) == 0 { - return false - } - if s[0] != '/' { - return false - } - if s[len(s)-1] == '/' && len(s) != 1 { - return false - } - // probably not used, but technically possible - if s == "/" { - return true - } - split := strings.Split(s[1:], "/") - for _, v := range split { - if len(v) == 0 { - return false - } - for _, c := range v { - if !isMemberChar(c) { - return false - } - } - } - return true -} - -// A UnixFD is a Unix file descriptor sent over the wire. See the package-level -// documentation for more information about Unix file descriptor passsing. -type UnixFD int32 - -// A UnixFDIndex is the representation of a Unix file descriptor in a message. -type UnixFDIndex uint32 - -// alignment returns the alignment of values of type t. -func alignment(t reflect.Type) int { - switch t { - case variantType: - return 1 - case objectPathType: - return 4 - case signatureType: - return 1 - case interfacesType: // sometimes used for structs - return 8 - } - switch t.Kind() { - case reflect.Uint8: - return 1 - case reflect.Uint16, reflect.Int16: - return 2 - case reflect.Uint32, reflect.Int32, reflect.String, reflect.Array, reflect.Slice, reflect.Map: - return 4 - case reflect.Uint64, reflect.Int64, reflect.Float64, reflect.Struct: - return 8 - case reflect.Ptr: - return alignment(t.Elem()) - } - return 1 -} - -// isKeyType returns whether t is a valid type for a D-Bus dict. -func isKeyType(t reflect.Type) bool { - switch t.Kind() { - case reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, - reflect.Int16, reflect.Int32, reflect.Int64, reflect.Float64, - reflect.String: - - return true - } - return false -} - -// isValidInterface returns whether s is a valid name for an interface. -func isValidInterface(s string) bool { - if len(s) == 0 || len(s) > 255 || s[0] == '.' { - return false - } - elem := strings.Split(s, ".") - if len(elem) < 2 { - return false - } - for _, v := range elem { - if len(v) == 0 { - return false - } - if v[0] >= '0' && v[0] <= '9' { - return false - } - for _, c := range v { - if !isMemberChar(c) { - return false - } - } - } - return true -} - -// isValidMember returns whether s is a valid name for a member. -func isValidMember(s string) bool { - if len(s) == 0 || len(s) > 255 { - return false - } - i := strings.Index(s, ".") - if i != -1 { - return false - } - if s[0] >= '0' && s[0] <= '9' { - return false - } - for _, c := range s { - if !isMemberChar(c) { - return false - } - } - return true -} - -func isMemberChar(c rune) bool { - return (c >= '0' && c <= '9') || (c >= 'A' && c <= 'Z') || - (c >= 'a' && c <= 'z') || c == '_' -} diff --git a/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/guelfey/go.dbus/decoder.go b/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/guelfey/go.dbus/decoder.go deleted file mode 100644 index ef50dcab..00000000 --- a/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/guelfey/go.dbus/decoder.go +++ /dev/null @@ -1,228 +0,0 @@ -package dbus - -import ( - "encoding/binary" - "io" - "reflect" -) - -type decoder struct { - in io.Reader - order binary.ByteOrder - pos int -} - -// newDecoder returns a new decoder that reads values from in. The input is -// expected to be in the given byte order. -func newDecoder(in io.Reader, order binary.ByteOrder) *decoder { - dec := new(decoder) - dec.in = in - dec.order = order - return dec -} - -// align aligns the input to the given boundary and panics on error. -func (dec *decoder) align(n int) { - if dec.pos%n != 0 { - newpos := (dec.pos + n - 1) & ^(n - 1) - empty := make([]byte, newpos-dec.pos) - if _, err := io.ReadFull(dec.in, empty); err != nil { - panic(err) - } - dec.pos = newpos - } -} - -// Calls binary.Read(dec.in, dec.order, v) and panics on read errors. -func (dec *decoder) binread(v interface{}) { - if err := binary.Read(dec.in, dec.order, v); err != nil { - panic(err) - } -} - -func (dec *decoder) Decode(sig Signature) (vs []interface{}, err error) { - defer func() { - var ok bool - v := recover() - if err, ok = v.(error); ok { - if err == io.EOF || err == io.ErrUnexpectedEOF { - err = FormatError("unexpected EOF") - } - } - }() - vs = make([]interface{}, 0) - s := sig.str - for s != "" { - err, rem := validSingle(s, 0) - if err != nil { - return nil, err - } - v := dec.decode(s[:len(s)-len(rem)], 0) - vs = append(vs, v) - s = rem - } - return vs, nil -} - -func (dec *decoder) decode(s string, depth int) interface{} { - dec.align(alignment(typeFor(s))) - switch s[0] { - case 'y': - var b [1]byte - if _, err := dec.in.Read(b[:]); err != nil { - panic(err) - } - dec.pos++ - return b[0] - case 'b': - i := dec.decode("u", depth).(uint32) - switch { - case i == 0: - return false - case i == 1: - return true - default: - panic(FormatError("invalid value for boolean")) - } - case 'n': - var i int16 - dec.binread(&i) - dec.pos += 2 - return i - case 'i': - var i int32 - dec.binread(&i) - dec.pos += 4 - return i - case 'x': - var i int64 - dec.binread(&i) - dec.pos += 8 - return i - case 'q': - var i uint16 - dec.binread(&i) - dec.pos += 2 - return i - case 'u': - var i uint32 - dec.binread(&i) - dec.pos += 4 - return i - case 't': - var i uint64 - dec.binread(&i) - dec.pos += 8 - return i - case 'd': - var f float64 - dec.binread(&f) - dec.pos += 8 - return f - case 's': - length := dec.decode("u", depth).(uint32) - b := make([]byte, int(length)+1) - if _, err := io.ReadFull(dec.in, b); err != nil { - panic(err) - } - dec.pos += int(length) + 1 - return string(b[:len(b)-1]) - case 'o': - return ObjectPath(dec.decode("s", depth).(string)) - case 'g': - length := dec.decode("y", depth).(byte) - b := make([]byte, int(length)+1) - if _, err := io.ReadFull(dec.in, b); err != nil { - panic(err) - } - dec.pos += int(length) + 1 - sig, err := ParseSignature(string(b[:len(b)-1])) - if err != nil { - panic(err) - } - return sig - case 'v': - if depth >= 64 { - panic(FormatError("input exceeds container depth limit")) - } - var variant Variant - sig := dec.decode("g", depth).(Signature) - if len(sig.str) == 0 { - panic(FormatError("variant signature is empty")) - } - err, rem := validSingle(sig.str, 0) - if err != nil { - panic(err) - } - if rem != "" { - panic(FormatError("variant signature has multiple types")) - } - variant.sig = sig - variant.value = dec.decode(sig.str, depth+1) - return variant - case 'h': - return UnixFDIndex(dec.decode("u", depth).(uint32)) - case 'a': - if len(s) > 1 && s[1] == '{' { - ksig := s[2:3] - vsig := s[3 : len(s)-1] - v := reflect.MakeMap(reflect.MapOf(typeFor(ksig), typeFor(vsig))) - if depth >= 63 { - panic(FormatError("input exceeds container depth limit")) - } - length := dec.decode("u", depth).(uint32) - // Even for empty maps, the correct padding must be included - dec.align(8) - spos := dec.pos - for dec.pos < spos+int(length) { - dec.align(8) - if !isKeyType(v.Type().Key()) { - panic(InvalidTypeError{v.Type()}) - } - kv := dec.decode(ksig, depth+2) - vv := dec.decode(vsig, depth+2) - v.SetMapIndex(reflect.ValueOf(kv), reflect.ValueOf(vv)) - } - return v.Interface() - } - if depth >= 64 { - panic(FormatError("input exceeds container depth limit")) - } - length := dec.decode("u", depth).(uint32) - v := reflect.MakeSlice(reflect.SliceOf(typeFor(s[1:])), 0, int(length)) - // Even for empty arrays, the correct padding must be included - dec.align(alignment(typeFor(s[1:]))) - spos := dec.pos - for dec.pos < spos+int(length) { - ev := dec.decode(s[1:], depth+1) - v = reflect.Append(v, reflect.ValueOf(ev)) - } - return v.Interface() - case '(': - if depth >= 64 { - panic(FormatError("input exceeds container depth limit")) - } - dec.align(8) - v := make([]interface{}, 0) - s = s[1 : len(s)-1] - for s != "" { - err, rem := validSingle(s, 0) - if err != nil { - panic(err) - } - ev := dec.decode(s[:len(s)-len(rem)], depth+1) - v = append(v, ev) - s = rem - } - return v - default: - panic(SignatureError{Sig: s}) - } -} - -// A FormatError is an error in the wire format. -type FormatError string - -func (e FormatError) Error() string { - return "dbus: wire format error: " + string(e) -} diff --git a/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/guelfey/go.dbus/doc.go b/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/guelfey/go.dbus/doc.go deleted file mode 100644 index deff554a..00000000 --- a/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/guelfey/go.dbus/doc.go +++ /dev/null @@ -1,63 +0,0 @@ -/* -Package dbus implements bindings to the D-Bus message bus system. - -To use the message bus API, you first need to connect to a bus (usually the -session or system bus). The acquired connection then can be used to call methods -on remote objects and emit or receive signals. Using the Export method, you can -arrange D-Bus methods calls to be directly translated to method calls on a Go -value. - -Conversion Rules - -For outgoing messages, Go types are automatically converted to the -corresponding D-Bus types. The following types are directly encoded as their -respective D-Bus equivalents: - - Go type | D-Bus type - ------------+----------- - byte | BYTE - bool | BOOLEAN - int16 | INT16 - uint16 | UINT16 - int32 | INT32 - uint32 | UINT32 - int64 | INT64 - uint64 | UINT64 - float64 | DOUBLE - string | STRING - ObjectPath | OBJECT_PATH - Signature | SIGNATURE - Variant | VARIANT - UnixFDIndex | UNIX_FD - -Slices and arrays encode as ARRAYs of their element type. - -Maps encode as DICTs, provided that their key type can be used as a key for -a DICT. - -Structs other than Variant and Signature encode as a STRUCT containing their -exported fields. Fields whose tags contain `dbus:"-"` and unexported fields will -be skipped. - -Pointers encode as the value they're pointed to. - -Trying to encode any other type or a slice, map or struct containing an -unsupported type will result in an InvalidTypeError. - -For incoming messages, the inverse of these rules are used, with the exception -of STRUCTs. Incoming STRUCTS are represented as a slice of empty interfaces -containing the struct fields in the correct order. The Store function can be -used to convert such values to Go structs. - -Unix FD passing - -Handling Unix file descriptors deserves special mention. To use them, you should -first check that they are supported on a connection by calling SupportsUnixFDs. -If it returns true, all method of Connection will translate messages containing -UnixFD's to messages that are accompanied by the given file descriptors with the -UnixFD values being substituted by the correct indices. Similarily, the indices -of incoming messages are automatically resolved. It shouldn't be necessary to use -UnixFDIndex. - -*/ -package dbus diff --git a/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/guelfey/go.dbus/encoder.go b/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/guelfey/go.dbus/encoder.go deleted file mode 100644 index f9d2f057..00000000 --- a/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/guelfey/go.dbus/encoder.go +++ /dev/null @@ -1,179 +0,0 @@ -package dbus - -import ( - "bytes" - "encoding/binary" - "io" - "reflect" -) - -// An encoder encodes values to the D-Bus wire format. -type encoder struct { - out io.Writer - order binary.ByteOrder - pos int -} - -// NewEncoder returns a new encoder that writes to out in the given byte order. -func newEncoder(out io.Writer, order binary.ByteOrder) *encoder { - enc := new(encoder) - enc.out = out - enc.order = order - return enc -} - -// Aligns the next output to be on a multiple of n. Panics on write errors. -func (enc *encoder) align(n int) { - if enc.pos%n != 0 { - newpos := (enc.pos + n - 1) & ^(n - 1) - empty := make([]byte, newpos-enc.pos) - if _, err := enc.out.Write(empty); err != nil { - panic(err) - } - enc.pos = newpos - } -} - -// Calls binary.Write(enc.out, enc.order, v) and panics on write errors. -func (enc *encoder) binwrite(v interface{}) { - if err := binary.Write(enc.out, enc.order, v); err != nil { - panic(err) - } -} - -// Encode encodes the given values to the underyling reader. All written values -// are aligned properly as required by the D-Bus spec. -func (enc *encoder) Encode(vs ...interface{}) (err error) { - defer func() { - err, _ = recover().(error) - }() - for _, v := range vs { - enc.encode(reflect.ValueOf(v), 0) - } - return nil -} - -// encode encodes the given value to the writer and panics on error. depth holds -// the depth of the container nesting. -func (enc *encoder) encode(v reflect.Value, depth int) { - enc.align(alignment(v.Type())) - switch v.Kind() { - case reflect.Uint8: - var b [1]byte - b[0] = byte(v.Uint()) - if _, err := enc.out.Write(b[:]); err != nil { - panic(err) - } - enc.pos++ - case reflect.Bool: - if v.Bool() { - enc.encode(reflect.ValueOf(uint32(1)), depth) - } else { - enc.encode(reflect.ValueOf(uint32(0)), depth) - } - case reflect.Int16: - enc.binwrite(int16(v.Int())) - enc.pos += 2 - case reflect.Uint16: - enc.binwrite(uint16(v.Uint())) - enc.pos += 2 - case reflect.Int32: - enc.binwrite(int32(v.Int())) - enc.pos += 4 - case reflect.Uint32: - enc.binwrite(uint32(v.Uint())) - enc.pos += 4 - case reflect.Int64: - enc.binwrite(v.Int()) - enc.pos += 8 - case reflect.Uint64: - enc.binwrite(v.Uint()) - enc.pos += 8 - case reflect.Float64: - enc.binwrite(v.Float()) - enc.pos += 8 - case reflect.String: - enc.encode(reflect.ValueOf(uint32(len(v.String()))), depth) - b := make([]byte, v.Len()+1) - copy(b, v.String()) - b[len(b)-1] = 0 - n, err := enc.out.Write(b) - if err != nil { - panic(err) - } - enc.pos += n - case reflect.Ptr: - enc.encode(v.Elem(), depth) - case reflect.Slice, reflect.Array: - if depth >= 64 { - panic(FormatError("input exceeds container depth limit")) - } - var buf bytes.Buffer - bufenc := newEncoder(&buf, enc.order) - - for i := 0; i < v.Len(); i++ { - bufenc.encode(v.Index(i), depth+1) - } - enc.encode(reflect.ValueOf(uint32(buf.Len())), depth) - length := buf.Len() - enc.align(alignment(v.Type().Elem())) - if _, err := buf.WriteTo(enc.out); err != nil { - panic(err) - } - enc.pos += length - case reflect.Struct: - if depth >= 64 && v.Type() != signatureType { - panic(FormatError("input exceeds container depth limit")) - } - switch t := v.Type(); t { - case signatureType: - str := v.Field(0) - enc.encode(reflect.ValueOf(byte(str.Len())), depth+1) - b := make([]byte, str.Len()+1) - copy(b, str.String()) - b[len(b)-1] = 0 - n, err := enc.out.Write(b) - if err != nil { - panic(err) - } - enc.pos += n - case variantType: - variant := v.Interface().(Variant) - enc.encode(reflect.ValueOf(variant.sig), depth+1) - enc.encode(reflect.ValueOf(variant.value), depth+1) - default: - for i := 0; i < v.Type().NumField(); i++ { - field := t.Field(i) - if field.PkgPath == "" && field.Tag.Get("dbus") != "-" { - enc.encode(v.Field(i), depth+1) - } - } - } - case reflect.Map: - // Maps are arrays of structures, so they actually increase the depth by - // 2. - if depth >= 63 { - panic(FormatError("input exceeds container depth limit")) - } - if !isKeyType(v.Type().Key()) { - panic(InvalidTypeError{v.Type()}) - } - keys := v.MapKeys() - var buf bytes.Buffer - bufenc := newEncoder(&buf, enc.order) - for _, k := range keys { - bufenc.align(8) - bufenc.encode(k, depth+2) - bufenc.encode(v.MapIndex(k), depth+2) - } - enc.encode(reflect.ValueOf(uint32(buf.Len())), depth) - length := buf.Len() - enc.align(8) - if _, err := buf.WriteTo(enc.out); err != nil { - panic(err) - } - enc.pos += length - default: - panic(InvalidTypeError{v.Type()}) - } -} diff --git a/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/guelfey/go.dbus/examples_test.go b/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/guelfey/go.dbus/examples_test.go deleted file mode 100644 index 0218ac55..00000000 --- a/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/guelfey/go.dbus/examples_test.go +++ /dev/null @@ -1,50 +0,0 @@ -package dbus - -import "fmt" - -func ExampleConn_Emit() { - conn, err := SessionBus() - if err != nil { - panic(err) - } - - conn.Emit("/foo/bar", "foo.bar.Baz", uint32(0xDAEDBEEF)) -} - -func ExampleObject_Call() { - var list []string - - conn, err := SessionBus() - if err != nil { - panic(err) - } - - err = conn.BusObject().Call("org.freedesktop.DBus.ListNames", 0).Store(&list) - if err != nil { - panic(err) - } - for _, v := range list { - fmt.Println(v) - } -} - -func ExampleObject_Go() { - conn, err := SessionBus() - if err != nil { - panic(err) - } - - ch := make(chan *Call, 10) - conn.BusObject().Go("org.freedesktop.DBus.ListActivatableNames", 0, ch) - select { - case call := <-ch: - if call.Err != nil { - panic(err) - } - list := call.Body[0].([]string) - for _, v := range list { - fmt.Println(v) - } - // put some other cases here - } -} diff --git a/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/guelfey/go.dbus/export.go b/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/guelfey/go.dbus/export.go deleted file mode 100644 index d95b092c..00000000 --- a/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/guelfey/go.dbus/export.go +++ /dev/null @@ -1,300 +0,0 @@ -package dbus - -import ( - "errors" - "reflect" - "strings" - "unicode" -) - -var ( - errmsgInvalidArg = Error{ - "org.freedesktop.DBus.Error.InvalidArgs", - []interface{}{"Invalid type / number of args"}, - } - errmsgNoObject = Error{ - "org.freedesktop.DBus.Error.NoSuchObject", - []interface{}{"No such object"}, - } - errmsgUnknownMethod = Error{ - "org.freedesktop.DBus.Error.UnknownMethod", - []interface{}{"Unknown / invalid method"}, - } -) - -// Sender is a type which can be used in exported methods to receive the message -// sender. -type Sender string - -func exportedMethod(v interface{}, name string) reflect.Value { - if v == nil { - return reflect.Value{} - } - m := reflect.ValueOf(v).MethodByName(name) - if !m.IsValid() { - return reflect.Value{} - } - t := m.Type() - if t.NumOut() == 0 || - t.Out(t.NumOut()-1) != reflect.TypeOf(&errmsgInvalidArg) { - - return reflect.Value{} - } - return m -} - -// handleCall handles the given method call (i.e. looks if it's one of the -// pre-implemented ones and searches for a corresponding handler if not). -func (conn *Conn) handleCall(msg *Message) { - name := msg.Headers[FieldMember].value.(string) - path := msg.Headers[FieldPath].value.(ObjectPath) - ifaceName, hasIface := msg.Headers[FieldInterface].value.(string) - sender := msg.Headers[FieldSender].value.(string) - serial := msg.serial - if ifaceName == "org.freedesktop.DBus.Peer" { - switch name { - case "Ping": - conn.sendReply(sender, serial) - case "GetMachineId": - conn.sendReply(sender, serial, conn.uuid) - default: - conn.sendError(errmsgUnknownMethod, sender, serial) - } - return - } - if len(name) == 0 || unicode.IsLower([]rune(name)[0]) { - conn.sendError(errmsgUnknownMethod, sender, serial) - } - var m reflect.Value - if hasIface { - conn.handlersLck.RLock() - obj, ok := conn.handlers[path] - if !ok { - conn.sendError(errmsgNoObject, sender, serial) - conn.handlersLck.RUnlock() - return - } - iface := obj[ifaceName] - conn.handlersLck.RUnlock() - m = exportedMethod(iface, name) - } else { - conn.handlersLck.RLock() - if _, ok := conn.handlers[path]; !ok { - conn.sendError(errmsgNoObject, sender, serial) - conn.handlersLck.RUnlock() - return - } - for _, v := range conn.handlers[path] { - m = exportedMethod(v, name) - if m.IsValid() { - break - } - } - conn.handlersLck.RUnlock() - } - if !m.IsValid() { - conn.sendError(errmsgUnknownMethod, sender, serial) - return - } - t := m.Type() - vs := msg.Body - pointers := make([]interface{}, t.NumIn()) - decode := make([]interface{}, 0, len(vs)) - for i := 0; i < t.NumIn(); i++ { - tp := t.In(i) - val := reflect.New(tp) - pointers[i] = val.Interface() - if tp == reflect.TypeOf((*Sender)(nil)).Elem() { - val.Elem().SetString(sender) - } else { - decode = append(decode, pointers[i]) - } - } - if len(decode) != len(vs) { - conn.sendError(errmsgInvalidArg, sender, serial) - return - } - if err := Store(vs, decode...); err != nil { - conn.sendError(errmsgInvalidArg, sender, serial) - return - } - params := make([]reflect.Value, len(pointers)) - for i := 0; i < len(pointers); i++ { - params[i] = reflect.ValueOf(pointers[i]).Elem() - } - ret := m.Call(params) - if em := ret[t.NumOut()-1].Interface().(*Error); em != nil { - conn.sendError(*em, sender, serial) - return - } - if msg.Flags&FlagNoReplyExpected == 0 { - reply := new(Message) - reply.Type = TypeMethodReply - reply.serial = conn.getSerial() - reply.Headers = make(map[HeaderField]Variant) - reply.Headers[FieldDestination] = msg.Headers[FieldSender] - reply.Headers[FieldReplySerial] = MakeVariant(msg.serial) - reply.Body = make([]interface{}, len(ret)-1) - for i := 0; i < len(ret)-1; i++ { - reply.Body[i] = ret[i].Interface() - } - if len(ret) != 1 { - reply.Headers[FieldSignature] = MakeVariant(SignatureOf(reply.Body...)) - } - conn.outLck.RLock() - if !conn.closed { - conn.out <- reply - } - conn.outLck.RUnlock() - } -} - -// Emit emits the given signal on the message bus. The name parameter must be -// formatted as "interface.member", e.g., "org.freedesktop.DBus.NameLost". -func (conn *Conn) Emit(path ObjectPath, name string, values ...interface{}) error { - if !path.IsValid() { - return errors.New("dbus: invalid object path") - } - i := strings.LastIndex(name, ".") - if i == -1 { - return errors.New("dbus: invalid method name") - } - iface := name[:i] - member := name[i+1:] - if !isValidMember(member) { - return errors.New("dbus: invalid method name") - } - if !isValidInterface(iface) { - return errors.New("dbus: invalid interface name") - } - msg := new(Message) - msg.Type = TypeSignal - msg.serial = conn.getSerial() - msg.Headers = make(map[HeaderField]Variant) - msg.Headers[FieldInterface] = MakeVariant(iface) - msg.Headers[FieldMember] = MakeVariant(member) - msg.Headers[FieldPath] = MakeVariant(path) - msg.Body = values - if len(values) > 0 { - msg.Headers[FieldSignature] = MakeVariant(SignatureOf(values...)) - } - conn.outLck.RLock() - defer conn.outLck.RUnlock() - if conn.closed { - return ErrClosed - } - conn.out <- msg - return nil -} - -// Export registers the given value to be exported as an object on the -// message bus. -// -// If a method call on the given path and interface is received, an exported -// method with the same name is called with v as the receiver if the -// parameters match and the last return value is of type *Error. If this -// *Error is not nil, it is sent back to the caller as an error. -// Otherwise, a method reply is sent with the other return values as its body. -// -// Any parameters with the special type Sender are set to the sender of the -// dbus message when the method is called. Parameters of this type do not -// contribute to the dbus signature of the method (i.e. the method is exposed -// as if the parameters of type Sender were not there). -// -// Every method call is executed in a new goroutine, so the method may be called -// in multiple goroutines at once. -// -// Method calls on the interface org.freedesktop.DBus.Peer will be automatically -// handled for every object. -// -// Passing nil as the first parameter will cause conn to cease handling calls on -// the given combination of path and interface. -// -// Export returns an error if path is not a valid path name. -func (conn *Conn) Export(v interface{}, path ObjectPath, iface string) error { - if !path.IsValid() { - return errors.New("dbus: invalid path name") - } - conn.handlersLck.Lock() - if v == nil { - if _, ok := conn.handlers[path]; ok { - delete(conn.handlers[path], iface) - if len(conn.handlers[path]) == 0 { - delete(conn.handlers, path) - } - } - return nil - } - if _, ok := conn.handlers[path]; !ok { - conn.handlers[path] = make(map[string]interface{}) - } - conn.handlers[path][iface] = v - conn.handlersLck.Unlock() - return nil -} - -// ReleaseName calls org.freedesktop.DBus.ReleaseName. You should use only this -// method to release a name (see below). -func (conn *Conn) ReleaseName(name string) (ReleaseNameReply, error) { - var r uint32 - err := conn.busObj.Call("org.freedesktop.DBus.ReleaseName", 0, name).Store(&r) - if err != nil { - return 0, err - } - if r == uint32(ReleaseNameReplyReleased) { - conn.namesLck.Lock() - for i, v := range conn.names { - if v == name { - copy(conn.names[i:], conn.names[i+1:]) - conn.names = conn.names[:len(conn.names)-1] - } - } - conn.namesLck.Unlock() - } - return ReleaseNameReply(r), nil -} - -// RequestName calls org.freedesktop.DBus.RequestName. You should use only this -// method to request a name because package dbus needs to keep track of all -// names that the connection has. -func (conn *Conn) RequestName(name string, flags RequestNameFlags) (RequestNameReply, error) { - var r uint32 - err := conn.busObj.Call("org.freedesktop.DBus.RequestName", 0, name, flags).Store(&r) - if err != nil { - return 0, err - } - if r == uint32(RequestNameReplyPrimaryOwner) { - conn.namesLck.Lock() - conn.names = append(conn.names, name) - conn.namesLck.Unlock() - } - return RequestNameReply(r), nil -} - -// ReleaseNameReply is the reply to a ReleaseName call. -type ReleaseNameReply uint32 - -const ( - ReleaseNameReplyReleased ReleaseNameReply = 1 + iota - ReleaseNameReplyNonExistent - ReleaseNameReplyNotOwner -) - -// RequestNameFlags represents the possible flags for a RequestName call. -type RequestNameFlags uint32 - -const ( - NameFlagAllowReplacement RequestNameFlags = 1 << iota - NameFlagReplaceExisting - NameFlagDoNotQueue -) - -// RequestNameReply is the reply to a RequestName call. -type RequestNameReply uint32 - -const ( - RequestNameReplyPrimaryOwner RequestNameReply = 1 + iota - RequestNameReplyInQueue - RequestNameReplyExists - RequestNameReplyAlreadyOwner -) diff --git a/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/guelfey/go.dbus/introspect/call.go b/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/guelfey/go.dbus/introspect/call.go deleted file mode 100644 index 180ba58d..00000000 --- a/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/guelfey/go.dbus/introspect/call.go +++ /dev/null @@ -1,27 +0,0 @@ -package introspect - -import ( - "encoding/xml" - "github.com/guelfey/go.dbus" - "strings" -) - -// Call calls org.freedesktop.Introspectable.Introspect on a remote object -// and returns the introspection data. -func Call(o *dbus.Object) (*Node, error) { - var xmldata string - var node Node - - err := o.Call("org.freedesktop.DBus.Introspectable.Introspect", 0).Store(&xmldata) - if err != nil { - return nil, err - } - err = xml.NewDecoder(strings.NewReader(xmldata)).Decode(&node) - if err != nil { - return nil, err - } - if node.Name == "" { - node.Name = string(o.Path()) - } - return &node, nil -} diff --git a/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/guelfey/go.dbus/introspect/introspect.go b/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/guelfey/go.dbus/introspect/introspect.go deleted file mode 100644 index dafcdb8b..00000000 --- a/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/guelfey/go.dbus/introspect/introspect.go +++ /dev/null @@ -1,80 +0,0 @@ -// Package introspect provides some utilities for dealing with the DBus -// introspection format. -package introspect - -import "encoding/xml" - -// The introspection data for the org.freedesktop.DBus.Introspectable interface. -var IntrospectData = Interface{ - Name: "org.freedesktop.DBus.Introspectable", - Methods: []Method{ - { - Name: "Introspect", - Args: []Arg{ - {"out", "s", "out"}, - }, - }, - }, -} - -// The introspection data for the org.freedesktop.DBus.Introspectable interface, -// as a string. -const IntrospectDataString = ` - <interface name="org.freedesktop.DBus.Introspectable"> - <method name="Introspect"> - <arg name="out" direction="out" type="s"/> - </method> - </interface> -` - -// Node is the root element of an introspection. -type Node struct { - XMLName xml.Name `xml:"node"` - Name string `xml:"name,attr,omitempty"` - Interfaces []Interface `xml:"interface"` - Children []Node `xml:"node,omitempty"` -} - -// Interface describes a DBus interface that is available on the message bus. -type Interface struct { - Name string `xml:"name,attr"` - Methods []Method `xml:"method"` - Signals []Signal `xml:"signal"` - Properties []Property `xml:"property"` - Annotations []Annotation `xml:"annotation"` -} - -// Method describes a Method on an Interface as retured by an introspection. -type Method struct { - Name string `xml:"name,attr"` - Args []Arg `xml:"arg"` - Annotations []Annotation `xml:"annotation"` -} - -// Signal describes a Signal emitted on an Interface. -type Signal struct { - Name string `xml:"name,attr"` - Args []Arg `xml:"arg"` - Annotations []Annotation `xml:"annotation"` -} - -// Property describes a property of an Interface. -type Property struct { - Name string `xml:"name,attr"` - Type string `xml:"type,attr"` - Access string `xml:"access,attr"` - Annotations []Annotation `xml:"annotation"` -} - -// Arg represents an argument of a method or a signal. -type Arg struct { - Name string `xml:"name,attr,omitempty"` - Type string `xml:"type,attr"` - Direction string `xml:"direction,attr,omitempty"` -} - -// Annotation is an annotation in the introspection format. -type Annotation struct { - Name string `xml:"name,attr"` - Value string `xml:"value,attr"` -} diff --git a/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/guelfey/go.dbus/introspect/introspectable.go b/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/guelfey/go.dbus/introspect/introspectable.go deleted file mode 100644 index ca1f8b57..00000000 --- a/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/guelfey/go.dbus/introspect/introspectable.go +++ /dev/null @@ -1,74 +0,0 @@ -package introspect - -import ( - "encoding/xml" - "github.com/guelfey/go.dbus" - "reflect" -) - -// Introspectable implements org.freedesktop.Introspectable. -// -// You can create it by converting the XML-formatted introspection data from a -// string to an Introspectable or call NewIntrospectable with a Node. Then, -// export it as org.freedesktop.Introspectable on you object. -type Introspectable string - -// NewIntrospectable returns an Introspectable that returns the introspection -// data that corresponds to the given Node. If n.Interfaces doesn't contain the -// data for org.freedesktop.DBus.Introspectable, it is added automatically. -func NewIntrospectable(n *Node) Introspectable { - found := false - for _, v := range n.Interfaces { - if v.Name == "org.freedesktop.DBus.Introspectable" { - found = true - break - } - } - if !found { - n.Interfaces = append(n.Interfaces, IntrospectData) - } - b, err := xml.Marshal(n) - if err != nil { - panic(err) - } - return Introspectable(b) -} - -// Introspect implements org.freedesktop.Introspectable.Introspect. -func (i Introspectable) Introspect() (string, *dbus.Error) { - return string(i), nil -} - -// Methods returns the description of the methods of v. This can be used to -// create a Node which can be passed to NewIntrospectable. -func Methods(v interface{}) []Method { - t := reflect.TypeOf(v) - ms := make([]Method, 0, t.NumMethod()) - for i := 0; i < t.NumMethod(); i++ { - if t.Method(i).PkgPath != "" { - continue - } - mt := t.Method(i).Type - if mt.NumOut() == 0 || - mt.Out(mt.NumOut()-1) != reflect.TypeOf(&dbus.Error{"", nil}) { - - continue - } - var m Method - m.Name = t.Method(i).Name - m.Args = make([]Arg, 0, mt.NumIn()+mt.NumOut()-2) - for j := 1; j < mt.NumIn(); j++ { - if mt.In(j) != reflect.TypeOf((*dbus.Sender)(nil)).Elem() { - arg := Arg{"", dbus.SignatureOfType(mt.In(j)).String(), "in"} - m.Args = append(m.Args, arg) - } - } - for j := 0; j < mt.NumOut()-1; j++ { - arg := Arg{"", dbus.SignatureOfType(mt.Out(j)).String(), "out"} - m.Args = append(m.Args, arg) - } - m.Annotations = make([]Annotation, 0) - ms = append(ms, m) - } - return ms -} diff --git a/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/guelfey/go.dbus/message.go b/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/guelfey/go.dbus/message.go deleted file mode 100644 index 075d6e38..00000000 --- a/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/guelfey/go.dbus/message.go +++ /dev/null @@ -1,346 +0,0 @@ -package dbus - -import ( - "bytes" - "encoding/binary" - "errors" - "io" - "reflect" - "strconv" -) - -const protoVersion byte = 1 - -// Flags represents the possible flags of a D-Bus message. -type Flags byte - -const ( - // FlagNoReplyExpected signals that the message is not expected to generate - // a reply. If this flag is set on outgoing messages, any possible reply - // will be discarded. - FlagNoReplyExpected Flags = 1 << iota - // FlagNoAutoStart signals that the message bus should not automatically - // start an application when handling this message. - FlagNoAutoStart -) - -// Type represents the possible types of a D-Bus message. -type Type byte - -const ( - TypeMethodCall Type = 1 + iota - TypeMethodReply - TypeError - TypeSignal - typeMax -) - -func (t Type) String() string { - switch t { - case TypeMethodCall: - return "method call" - case TypeMethodReply: - return "reply" - case TypeError: - return "error" - case TypeSignal: - return "signal" - } - return "invalid" -} - -// HeaderField represents the possible byte codes for the headers -// of a D-Bus message. -type HeaderField byte - -const ( - FieldPath HeaderField = 1 + iota - FieldInterface - FieldMember - FieldErrorName - FieldReplySerial - FieldDestination - FieldSender - FieldSignature - FieldUnixFDs - fieldMax -) - -// An InvalidMessageError describes the reason why a D-Bus message is regarded as -// invalid. -type InvalidMessageError string - -func (e InvalidMessageError) Error() string { - return "dbus: invalid message: " + string(e) -} - -// fieldType are the types of the various header fields. -var fieldTypes = [fieldMax]reflect.Type{ - FieldPath: objectPathType, - FieldInterface: stringType, - FieldMember: stringType, - FieldErrorName: stringType, - FieldReplySerial: uint32Type, - FieldDestination: stringType, - FieldSender: stringType, - FieldSignature: signatureType, - FieldUnixFDs: uint32Type, -} - -// requiredFields lists the header fields that are required by the different -// message types. -var requiredFields = [typeMax][]HeaderField{ - TypeMethodCall: {FieldPath, FieldMember}, - TypeMethodReply: {FieldReplySerial}, - TypeError: {FieldErrorName, FieldReplySerial}, - TypeSignal: {FieldPath, FieldInterface, FieldMember}, -} - -// Message represents a single D-Bus message. -type Message struct { - Type - Flags - Headers map[HeaderField]Variant - Body []interface{} - - serial uint32 -} - -type header struct { - Field byte - Variant -} - -// DecodeMessage tries to decode a single message in the D-Bus wire format -// from the given reader. The byte order is figured out from the first byte. -// The possibly returned error can be an error of the underlying reader, an -// InvalidMessageError or a FormatError. -func DecodeMessage(rd io.Reader) (msg *Message, err error) { - var order binary.ByteOrder - var hlength, length uint32 - var typ, flags, proto byte - var headers []header - - b := make([]byte, 1) - _, err = rd.Read(b) - if err != nil { - return - } - switch b[0] { - case 'l': - order = binary.LittleEndian - case 'B': - order = binary.BigEndian - default: - return nil, InvalidMessageError("invalid byte order") - } - - dec := newDecoder(rd, order) - dec.pos = 1 - - msg = new(Message) - vs, err := dec.Decode(Signature{"yyyuu"}) - if err != nil { - return nil, err - } - if err = Store(vs, &typ, &flags, &proto, &length, &msg.serial); err != nil { - return nil, err - } - msg.Type = Type(typ) - msg.Flags = Flags(flags) - - // get the header length separately because we need it later - b = make([]byte, 4) - _, err = io.ReadFull(rd, b) - if err != nil { - return nil, err - } - binary.Read(bytes.NewBuffer(b), order, &hlength) - if hlength+length+16 > 1<<27 { - return nil, InvalidMessageError("message is too long") - } - dec = newDecoder(io.MultiReader(bytes.NewBuffer(b), rd), order) - dec.pos = 12 - vs, err = dec.Decode(Signature{"a(yv)"}) - if err != nil { - return nil, err - } - if err = Store(vs, &headers); err != nil { - return nil, err - } - - msg.Headers = make(map[HeaderField]Variant) - for _, v := range headers { - msg.Headers[HeaderField(v.Field)] = v.Variant - } - - dec.align(8) - body := make([]byte, int(length)) - if length != 0 { - _, err := io.ReadFull(rd, body) - if err != nil { - return nil, err - } - } - - if err = msg.IsValid(); err != nil { - return nil, err - } - sig, _ := msg.Headers[FieldSignature].value.(Signature) - if sig.str != "" { - buf := bytes.NewBuffer(body) - dec = newDecoder(buf, order) - vs, err := dec.Decode(sig) - if err != nil { - return nil, err - } - msg.Body = vs - } - - return -} - -// EncodeTo encodes and sends a message to the given writer. The byte order must -// be either binary.LittleEndian or binary.BigEndian. If the message is not -// valid or an error occurs when writing, an error is returned. -func (msg *Message) EncodeTo(out io.Writer, order binary.ByteOrder) error { - if err := msg.IsValid(); err != nil { - return err - } - var vs [7]interface{} - switch order { - case binary.LittleEndian: - vs[0] = byte('l') - case binary.BigEndian: - vs[0] = byte('B') - default: - return errors.New("dbus: invalid byte order") - } - body := new(bytes.Buffer) - enc := newEncoder(body, order) - if len(msg.Body) != 0 { - enc.Encode(msg.Body...) - } - vs[1] = msg.Type - vs[2] = msg.Flags - vs[3] = protoVersion - vs[4] = uint32(len(body.Bytes())) - vs[5] = msg.serial - headers := make([]header, 0, len(msg.Headers)) - for k, v := range msg.Headers { - headers = append(headers, header{byte(k), v}) - } - vs[6] = headers - var buf bytes.Buffer - enc = newEncoder(&buf, order) - enc.Encode(vs[:]...) - enc.align(8) - body.WriteTo(&buf) - if buf.Len() > 1<<27 { - return InvalidMessageError("message is too long") - } - if _, err := buf.WriteTo(out); err != nil { - return err - } - return nil -} - -// IsValid checks whether msg is a valid message and returns an -// InvalidMessageError if it is not. -func (msg *Message) IsValid() error { - if msg.Flags & ^(FlagNoAutoStart|FlagNoReplyExpected) != 0 { - return InvalidMessageError("invalid flags") - } - if msg.Type == 0 || msg.Type >= typeMax { - return InvalidMessageError("invalid message type") - } - for k, v := range msg.Headers { - if k == 0 || k >= fieldMax { - return InvalidMessageError("invalid header") - } - if reflect.TypeOf(v.value) != fieldTypes[k] { - return InvalidMessageError("invalid type of header field") - } - } - for _, v := range requiredFields[msg.Type] { - if _, ok := msg.Headers[v]; !ok { - return InvalidMessageError("missing required header") - } - } - if path, ok := msg.Headers[FieldPath]; ok { - if !path.value.(ObjectPath).IsValid() { - return InvalidMessageError("invalid path name") - } - } - if iface, ok := msg.Headers[FieldInterface]; ok { - if !isValidInterface(iface.value.(string)) { - return InvalidMessageError("invalid interface name") - } - } - if member, ok := msg.Headers[FieldMember]; ok { - if !isValidMember(member.value.(string)) { - return InvalidMessageError("invalid member name") - } - } - if errname, ok := msg.Headers[FieldErrorName]; ok { - if !isValidInterface(errname.value.(string)) { - return InvalidMessageError("invalid error name") - } - } - if len(msg.Body) != 0 { - if _, ok := msg.Headers[FieldSignature]; !ok { - return InvalidMessageError("missing signature") - } - } - return nil -} - -// Serial returns the message's serial number. The returned value is only valid -// for messages received by eavesdropping. -func (msg *Message) Serial() uint32 { - return msg.serial -} - -// String returns a string representation of a message similar to the format of -// dbus-monitor. -func (msg *Message) String() string { - if err := msg.IsValid(); err != nil { - return "<invalid>" - } - s := msg.Type.String() - if v, ok := msg.Headers[FieldSender]; ok { - s += " from " + v.value.(string) - } - if v, ok := msg.Headers[FieldDestination]; ok { - s += " to " + v.value.(string) - } - s += " serial " + strconv.FormatUint(uint64(msg.serial), 10) - if v, ok := msg.Headers[FieldReplySerial]; ok { - s += " reply_serial " + strconv.FormatUint(uint64(v.value.(uint32)), 10) - } - if v, ok := msg.Headers[FieldUnixFDs]; ok { - s += " unixfds " + strconv.FormatUint(uint64(v.value.(uint32)), 10) - } - if v, ok := msg.Headers[FieldPath]; ok { - s += " path " + string(v.value.(ObjectPath)) - } - if v, ok := msg.Headers[FieldInterface]; ok { - s += " interface " + v.value.(string) - } - if v, ok := msg.Headers[FieldErrorName]; ok { - s += " error " + v.value.(string) - } - if v, ok := msg.Headers[FieldMember]; ok { - s += " member " + v.value.(string) - } - if len(msg.Body) != 0 { - s += "\n" - } - for i, v := range msg.Body { - s += " " + MakeVariant(v).String() - if i != len(msg.Body)-1 { - s += "\n" - } - } - return s -} diff --git a/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/guelfey/go.dbus/prop/prop.go b/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/guelfey/go.dbus/prop/prop.go deleted file mode 100644 index bc695207..00000000 --- a/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/guelfey/go.dbus/prop/prop.go +++ /dev/null @@ -1,264 +0,0 @@ -// Package prop provides the Properties struct which can be used to implement -// org.freedesktop.DBus.Properties. -package prop - -import ( - "github.com/guelfey/go.dbus" - "github.com/guelfey/go.dbus/introspect" - "sync" -) - -// EmitType controls how org.freedesktop.DBus.Properties.PropertiesChanged is -// emitted for a property. If it is EmitTrue, the signal is emitted. If it is -// EmitInvalidates, the signal is also emitted, but the new value of the property -// is not disclosed. -type EmitType byte - -const ( - EmitFalse EmitType = iota - EmitTrue - EmitInvalidates -) - -// ErrIfaceNotFound is the error returned to peers who try to access properties -// on interfaces that aren't found. -var ErrIfaceNotFound = &dbus.Error{"org.freedesktop.DBus.Properties.Error.InterfaceNotFound", nil} - -// ErrPropNotFound is the error returned to peers trying to access properties -// that aren't found. -var ErrPropNotFound = &dbus.Error{"org.freedesktop.DBus.Properties.Error.PropertyNotFound", nil} - -// ErrReadOnly is the error returned to peers trying to set a read-only -// property. -var ErrReadOnly = &dbus.Error{"org.freedesktop.DBus.Properties.Error.ReadOnly", nil} - -// ErrInvalidArg is returned to peers if the type of the property that is being -// changed and the argument don't match. -var ErrInvalidArg = &dbus.Error{"org.freedesktop.DBus.Properties.Error.InvalidArg", nil} - -// The introspection data for the org.freedesktop.DBus.Properties interface. -var IntrospectData = introspect.Interface{ - Name: "org.freedesktop.DBus.Properties", - Methods: []introspect.Method{ - { - Name: "Get", - Args: []introspect.Arg{ - {"interface", "s", "in"}, - {"property", "s", "in"}, - {"value", "v", "out"}, - }, - }, - { - Name: "GetAll", - Args: []introspect.Arg{ - {"interface", "s", "in"}, - {"props", "a{sv}", "out"}, - }, - }, - { - Name: "Set", - Args: []introspect.Arg{ - {"interface", "s", "in"}, - {"property", "s", "in"}, - {"value", "v", "in"}, - }, - }, - }, - Signals: []introspect.Signal{ - { - Name: "PropertiesChanged", - Args: []introspect.Arg{ - {"interface", "s", "out"}, - {"changed_properties", "a{sv}", "out"}, - {"invalidates_properties", "as", "out"}, - }, - }, - }, -} - -// The introspection data for the org.freedesktop.DBus.Properties interface, as -// a string. -const IntrospectDataString = ` - <interface name="org.freedesktop.DBus.Introspectable"> - <method name="Get"> - <arg name="interface" direction="in" type="s"/> - <arg name="property" direction="in" type="s"/> - <arg name="value" direction="out" type="v"/> - </method> - <method name="GetAll"> - <arg name="interface" direction="in" type="s"/> - <arg name="props" direction="out" type="a{sv}"/> - </method> - <method name="Set"> - <arg name="interface" direction="in" type="s"/> - <arg name="property" direction="in" type="s"/> - <arg name="value" direction="in" type="v"/> - </method> - <signal name="PropertiesChanged"> - <arg name="interface" type="s"/> - <arg name="changed_properties" type="a{sv}"/> - <arg name="invalidates_properties" type="as"/> - </signal> - </interface> -` - -// Prop represents a single property. It is used for creating a Properties -// value. -type Prop struct { - // Initial value. Must be a DBus-representable type. - Value interface{} - - // If true, the value can be modified by calls to Set. - Writable bool - - // Controls how org.freedesktop.DBus.Properties.PropertiesChanged is - // emitted if this property changes. - Emit EmitType - - // If not nil, anytime this property is changed by Set, this function is - // called with an appropiate Change as its argument. If the returned error - // is not nil, it is sent back to the caller of Set and the property is not - // changed. - Callback func(*Change) *dbus.Error -} - -// Change represents a change of a property by a call to Set. -type Change struct { - Props *Properties - Iface string - Name string - Value interface{} -} - -// Properties is a set of values that can be made available to the message bus -// using the org.freedesktop.DBus.Properties interface. It is safe for -// concurrent use by multiple goroutines. -type Properties struct { - m map[string]map[string]*Prop - mut sync.RWMutex - conn *dbus.Conn - path dbus.ObjectPath -} - -// New returns a new Properties structure that manages the given properties. -// The key for the first-level map of props is the name of the interface; the -// second-level key is the name of the property. The returned structure will be -// exported as org.freedesktop.DBus.Properties on path. -func New(conn *dbus.Conn, path dbus.ObjectPath, props map[string]map[string]*Prop) *Properties { - p := &Properties{m: props, conn: conn, path: path} - conn.Export(p, path, "org.freedesktop.DBus.Properties") - return p -} - -// Get implements org.freedesktop.DBus.Properties.Get. -func (p *Properties) Get(iface, property string) (dbus.Variant, *dbus.Error) { - p.mut.RLock() - defer p.mut.RUnlock() - m, ok := p.m[iface] - if !ok { - return dbus.Variant{}, ErrIfaceNotFound - } - prop, ok := m[property] - if !ok { - return dbus.Variant{}, ErrPropNotFound - } - return dbus.MakeVariant(prop.Value), nil -} - -// GetAll implements org.freedesktop.DBus.Properties.GetAll. -func (p *Properties) GetAll(iface string) (map[string]dbus.Variant, *dbus.Error) { - p.mut.RLock() - defer p.mut.RUnlock() - m, ok := p.m[iface] - if !ok { - return nil, ErrIfaceNotFound - } - rm := make(map[string]dbus.Variant, len(m)) - for k, v := range m { - rm[k] = dbus.MakeVariant(v.Value) - } - return rm, nil -} - -// GetMust returns the value of the given property and panics if either the -// interface or the property name are invalid. -func (p *Properties) GetMust(iface, property string) interface{} { - p.mut.RLock() - defer p.mut.RUnlock() - return p.m[iface][property].Value -} - -// Introspection returns the introspection data that represents the properties -// of iface. -func (p *Properties) Introspection(iface string) []introspect.Property { - p.mut.RLock() - defer p.mut.RUnlock() - m := p.m[iface] - s := make([]introspect.Property, 0, len(m)) - for k, v := range m { - p := introspect.Property{Name: k, Type: dbus.SignatureOf(v.Value).String()} - if v.Writable { - p.Access = "readwrite" - } else { - p.Access = "read" - } - s = append(s, p) - } - return s -} - -// set sets the given property and emits PropertyChanged if appropiate. p.mut -// must already be locked. -func (p *Properties) set(iface, property string, v interface{}) { - prop := p.m[iface][property] - prop.Value = v - switch prop.Emit { - case EmitFalse: - // do nothing - case EmitInvalidates: - p.conn.Emit(p.path, "org.freedesktop.DBus.Properties.PropertiesChanged", - iface, map[string]dbus.Variant{}, []string{property}) - case EmitTrue: - p.conn.Emit(p.path, "org.freedesktop.DBus.Properties.PropertiesChanged", - iface, map[string]dbus.Variant{property: dbus.MakeVariant(v)}, - []string{}) - default: - panic("invalid value for EmitType") - } -} - -// Set implements org.freedesktop.Properties.Set. -func (p *Properties) Set(iface, property string, newv dbus.Variant) *dbus.Error { - p.mut.Lock() - defer p.mut.Unlock() - m, ok := p.m[iface] - if !ok { - return ErrIfaceNotFound - } - prop, ok := m[property] - if !ok { - return ErrPropNotFound - } - if !prop.Writable { - return ErrReadOnly - } - if newv.Signature() != dbus.SignatureOf(prop.Value) { - return ErrInvalidArg - } - if prop.Callback != nil { - err := prop.Callback(&Change{p, iface, property, newv.Value()}) - if err != nil { - return err - } - } - p.set(iface, property, newv.Value()) - return nil -} - -// SetMust sets the value of the given property and panics if the interface or -// the property name are invalid. -func (p *Properties) SetMust(iface, property string, v interface{}) { - p.mut.Lock() - p.set(iface, property, v) - p.mut.Unlock() -} diff --git a/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/guelfey/go.dbus/proto_test.go b/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/guelfey/go.dbus/proto_test.go deleted file mode 100644 index 608a770d..00000000 --- a/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/guelfey/go.dbus/proto_test.go +++ /dev/null @@ -1,369 +0,0 @@ -package dbus - -import ( - "bytes" - "encoding/binary" - "io/ioutil" - "math" - "reflect" - "testing" -) - -var protoTests = []struct { - vs []interface{} - bigEndian []byte - littleEndian []byte -}{ - { - []interface{}{int32(0)}, - []byte{0, 0, 0, 0}, - []byte{0, 0, 0, 0}, - }, - { - []interface{}{true, false}, - []byte{0, 0, 0, 1, 0, 0, 0, 0}, - []byte{1, 0, 0, 0, 0, 0, 0, 0}, - }, - { - []interface{}{byte(0), uint16(12), int16(32), uint32(43)}, - []byte{0, 0, 0, 12, 0, 32, 0, 0, 0, 0, 0, 43}, - []byte{0, 0, 12, 0, 32, 0, 0, 0, 43, 0, 0, 0}, - }, - { - []interface{}{int64(-1), uint64(1<<64 - 1)}, - bytes.Repeat([]byte{255}, 16), - bytes.Repeat([]byte{255}, 16), - }, - { - []interface{}{math.Inf(+1)}, - []byte{0x7f, 0xf0, 0, 0, 0, 0, 0, 0}, - []byte{0, 0, 0, 0, 0, 0, 0xf0, 0x7f}, - }, - { - []interface{}{"foo"}, - []byte{0, 0, 0, 3, 'f', 'o', 'o', 0}, - []byte{3, 0, 0, 0, 'f', 'o', 'o', 0}, - }, - { - []interface{}{Signature{"ai"}}, - []byte{2, 'a', 'i', 0}, - []byte{2, 'a', 'i', 0}, - }, - { - []interface{}{[]int16{42, 256}}, - []byte{0, 0, 0, 4, 0, 42, 1, 0}, - []byte{4, 0, 0, 0, 42, 0, 0, 1}, - }, - { - []interface{}{MakeVariant("foo")}, - []byte{1, 's', 0, 0, 0, 0, 0, 3, 'f', 'o', 'o', 0}, - []byte{1, 's', 0, 0, 3, 0, 0, 0, 'f', 'o', 'o', 0}, - }, - { - []interface{}{MakeVariant(MakeVariant(Signature{"v"}))}, - []byte{1, 'v', 0, 1, 'g', 0, 1, 'v', 0}, - []byte{1, 'v', 0, 1, 'g', 0, 1, 'v', 0}, - }, - { - []interface{}{map[int32]bool{42: true}}, - []byte{0, 0, 0, 8, 0, 0, 0, 0, 0, 0, 0, 42, 0, 0, 0, 1}, - []byte{8, 0, 0, 0, 0, 0, 0, 0, 42, 0, 0, 0, 1, 0, 0, 0}, - }, - { - []interface{}{map[string]Variant{}, byte(42)}, - []byte{0, 0, 0, 0, 0, 0, 0, 0, 42}, - []byte{0, 0, 0, 0, 0, 0, 0, 0, 42}, - }, - { - []interface{}{[]uint64{}, byte(42)}, - []byte{0, 0, 0, 0, 0, 0, 0, 0, 42}, - []byte{0, 0, 0, 0, 0, 0, 0, 0, 42}, - }, -} - -func TestProto(t *testing.T) { - for i, v := range protoTests { - buf := new(bytes.Buffer) - bigEnc := newEncoder(buf, binary.BigEndian) - bigEnc.Encode(v.vs...) - marshalled := buf.Bytes() - if bytes.Compare(marshalled, v.bigEndian) != 0 { - t.Errorf("test %d (marshal be): got '%v', but expected '%v'\n", i+1, marshalled, - v.bigEndian) - } - buf.Reset() - litEnc := newEncoder(buf, binary.LittleEndian) - litEnc.Encode(v.vs...) - marshalled = buf.Bytes() - if bytes.Compare(marshalled, v.littleEndian) != 0 { - t.Errorf("test %d (marshal le): got '%v', but expected '%v'\n", i+1, marshalled, - v.littleEndian) - } - unmarshalled := reflect.MakeSlice(reflect.TypeOf(v.vs), - 0, 0) - for i := range v.vs { - unmarshalled = reflect.Append(unmarshalled, - reflect.New(reflect.TypeOf(v.vs[i]))) - } - bigDec := newDecoder(bytes.NewReader(v.bigEndian), binary.BigEndian) - vs, err := bigDec.Decode(SignatureOf(v.vs...)) - if err != nil { - t.Errorf("test %d (unmarshal be): %s\n", i+1, err) - continue - } - if !reflect.DeepEqual(vs, v.vs) { - t.Errorf("test %d (unmarshal be): got %#v, but expected %#v\n", i+1, vs, v.vs) - } - litDec := newDecoder(bytes.NewReader(v.littleEndian), binary.LittleEndian) - vs, err = litDec.Decode(SignatureOf(v.vs...)) - if err != nil { - t.Errorf("test %d (unmarshal le): %s\n", i+1, err) - continue - } - if !reflect.DeepEqual(vs, v.vs) { - t.Errorf("test %d (unmarshal le): got %#v, but expected %#v\n", i+1, vs, v.vs) - } - - } -} - -func TestProtoMap(t *testing.T) { - m := map[string]uint8{ - "foo": 23, - "bar": 2, - } - var n map[string]uint8 - buf := new(bytes.Buffer) - enc := newEncoder(buf, binary.LittleEndian) - enc.Encode(m) - dec := newDecoder(buf, binary.LittleEndian) - vs, err := dec.Decode(Signature{"a{sy}"}) - if err != nil { - t.Fatal(err) - } - if err = Store(vs, &n); err != nil { - t.Fatal(err) - } - if len(n) != 2 || n["foo"] != 23 || n["bar"] != 2 { - t.Error("got", n) - } -} - -func TestProtoVariantStruct(t *testing.T) { - var variant Variant - v := MakeVariant(struct { - A int32 - B int16 - }{1, 2}) - buf := new(bytes.Buffer) - enc := newEncoder(buf, binary.LittleEndian) - enc.Encode(v) - dec := newDecoder(buf, binary.LittleEndian) - vs, err := dec.Decode(Signature{"v"}) - if err != nil { - t.Fatal(err) - } - if err = Store(vs, &variant); err != nil { - t.Fatal(err) - } - sl := variant.Value().([]interface{}) - v1, v2 := sl[0].(int32), sl[1].(int16) - if v1 != int32(1) { - t.Error("got", v1, "as first int") - } - if v2 != int16(2) { - t.Error("got", v2, "as second int") - } -} - -func TestProtoStructTag(t *testing.T) { - type Bar struct { - A int32 - B chan interface{} `dbus:"-"` - C int32 - } - var bar1, bar2 Bar - bar1.A = 234 - bar2.C = 345 - buf := new(bytes.Buffer) - enc := newEncoder(buf, binary.LittleEndian) - enc.Encode(bar1) - dec := newDecoder(buf, binary.LittleEndian) - vs, err := dec.Decode(Signature{"(ii)"}) - if err != nil { - t.Fatal(err) - } - if err = Store(vs, &bar2); err != nil { - t.Fatal(err) - } - if bar1 != bar2 { - t.Error("struct tag test: got", bar2) - } -} - -func TestProtoStoreStruct(t *testing.T) { - var foo struct { - A int32 - B string - c chan interface{} - D interface{} `dbus:"-"` - } - src := []interface{}{[]interface{}{int32(42), "foo"}} - err := Store(src, &foo) - if err != nil { - t.Fatal(err) - } -} - -func TestProtoStoreNestedStruct(t *testing.T) { - var foo struct { - A int32 - B struct { - C string - D float64 - } - } - src := []interface{}{ - []interface{}{ - int32(42), - []interface{}{ - "foo", - 3.14, - }, - }, - } - err := Store(src, &foo) - if err != nil { - t.Fatal(err) - } -} - -func TestMessage(t *testing.T) { - buf := new(bytes.Buffer) - message := new(Message) - message.Type = TypeMethodCall - message.serial = 32 - message.Headers = map[HeaderField]Variant{ - FieldPath: MakeVariant(ObjectPath("/org/foo/bar")), - FieldMember: MakeVariant("baz"), - } - message.Body = make([]interface{}, 0) - err := message.EncodeTo(buf, binary.LittleEndian) - if err != nil { - t.Error(err) - } - _, err = DecodeMessage(buf) - if err != nil { - t.Error(err) - } -} - -func TestProtoStructInterfaces(t *testing.T) { - b := []byte{42} - vs, err := newDecoder(bytes.NewReader(b), binary.LittleEndian).Decode(Signature{"(y)"}) - if err != nil { - t.Fatal(err) - } - if vs[0].([]interface{})[0].(byte) != 42 { - t.Errorf("wrongs results (got %v)", vs) - } -} - -// ordinary org.freedesktop.DBus.Hello call -var smallMessage = &Message{ - Type: TypeMethodCall, - serial: 1, - Headers: map[HeaderField]Variant{ - FieldDestination: MakeVariant("org.freedesktop.DBus"), - FieldPath: MakeVariant(ObjectPath("/org/freedesktop/DBus")), - FieldInterface: MakeVariant("org.freedesktop.DBus"), - FieldMember: MakeVariant("Hello"), - }, -} - -// org.freedesktop.Notifications.Notify -var bigMessage = &Message{ - Type: TypeMethodCall, - serial: 2, - Headers: map[HeaderField]Variant{ - FieldDestination: MakeVariant("org.freedesktop.Notifications"), - FieldPath: MakeVariant(ObjectPath("/org/freedesktop/Notifications")), - FieldInterface: MakeVariant("org.freedesktop.Notifications"), - FieldMember: MakeVariant("Notify"), - FieldSignature: MakeVariant(Signature{"susssasa{sv}i"}), - }, - Body: []interface{}{ - "app_name", - uint32(0), - "dialog-information", - "Notification", - "This is the body of a notification", - []string{"ok", "Ok"}, - map[string]Variant{ - "sound-name": MakeVariant("dialog-information"), - }, - int32(-1), - }, -} - -func BenchmarkDecodeMessageSmall(b *testing.B) { - var err error - var rd *bytes.Reader - - b.StopTimer() - buf := new(bytes.Buffer) - err = smallMessage.EncodeTo(buf, binary.LittleEndian) - if err != nil { - b.Fatal(err) - } - decoded := buf.Bytes() - b.StartTimer() - for i := 0; i < b.N; i++ { - rd = bytes.NewReader(decoded) - _, err = DecodeMessage(rd) - if err != nil { - b.Fatal(err) - } - } -} - -func BenchmarkDecodeMessageBig(b *testing.B) { - var err error - var rd *bytes.Reader - - b.StopTimer() - buf := new(bytes.Buffer) - err = bigMessage.EncodeTo(buf, binary.LittleEndian) - if err != nil { - b.Fatal(err) - } - decoded := buf.Bytes() - b.StartTimer() - for i := 0; i < b.N; i++ { - rd = bytes.NewReader(decoded) - _, err = DecodeMessage(rd) - if err != nil { - b.Fatal(err) - } - } -} - -func BenchmarkEncodeMessageSmall(b *testing.B) { - var err error - for i := 0; i < b.N; i++ { - err = smallMessage.EncodeTo(ioutil.Discard, binary.LittleEndian) - if err != nil { - b.Fatal(err) - } - } -} - -func BenchmarkEncodeMessageBig(b *testing.B) { - var err error - for i := 0; i < b.N; i++ { - err = bigMessage.EncodeTo(ioutil.Discard, binary.LittleEndian) - if err != nil { - b.Fatal(err) - } - } -} diff --git a/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/guelfey/go.dbus/sig.go b/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/guelfey/go.dbus/sig.go deleted file mode 100644 index f45b53ce..00000000 --- a/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/guelfey/go.dbus/sig.go +++ /dev/null @@ -1,257 +0,0 @@ -package dbus - -import ( - "fmt" - "reflect" - "strings" -) - -var sigToType = map[byte]reflect.Type{ - 'y': byteType, - 'b': boolType, - 'n': int16Type, - 'q': uint16Type, - 'i': int32Type, - 'u': uint32Type, - 'x': int64Type, - 't': uint64Type, - 'd': float64Type, - 's': stringType, - 'g': signatureType, - 'o': objectPathType, - 'v': variantType, - 'h': unixFDIndexType, -} - -// Signature represents a correct type signature as specified by the D-Bus -// specification. The zero value represents the empty signature, "". -type Signature struct { - str string -} - -// SignatureOf returns the concatenation of all the signatures of the given -// values. It panics if one of them is not representable in D-Bus. -func SignatureOf(vs ...interface{}) Signature { - var s string - for _, v := range vs { - s += getSignature(reflect.TypeOf(v)) - } - return Signature{s} -} - -// SignatureOfType returns the signature of the given type. It panics if the -// type is not representable in D-Bus. -func SignatureOfType(t reflect.Type) Signature { - return Signature{getSignature(t)} -} - -// getSignature returns the signature of the given type and panics on unknown types. -func getSignature(t reflect.Type) string { - // handle simple types first - switch t.Kind() { - case reflect.Uint8: - return "y" - case reflect.Bool: - return "b" - case reflect.Int16: - return "n" - case reflect.Uint16: - return "q" - case reflect.Int32: - if t == unixFDType { - return "h" - } - return "i" - case reflect.Uint32: - if t == unixFDIndexType { - return "h" - } - return "u" - case reflect.Int64: - return "x" - case reflect.Uint64: - return "t" - case reflect.Float64: - return "d" - case reflect.Ptr: - return getSignature(t.Elem()) - case reflect.String: - if t == objectPathType { - return "o" - } - return "s" - case reflect.Struct: - if t == variantType { - return "v" - } else if t == signatureType { - return "g" - } - var s string - for i := 0; i < t.NumField(); i++ { - field := t.Field(i) - if field.PkgPath == "" && field.Tag.Get("dbus") != "-" { - s += getSignature(t.Field(i).Type) - } - } - return "(" + s + ")" - case reflect.Array, reflect.Slice: - return "a" + getSignature(t.Elem()) - case reflect.Map: - if !isKeyType(t.Key()) { - panic(InvalidTypeError{t}) - } - return "a{" + getSignature(t.Key()) + getSignature(t.Elem()) + "}" - } - panic(InvalidTypeError{t}) -} - -// ParseSignature returns the signature represented by this string, or a -// SignatureError if the string is not a valid signature. -func ParseSignature(s string) (sig Signature, err error) { - if len(s) == 0 { - return - } - if len(s) > 255 { - return Signature{""}, SignatureError{s, "too long"} - } - sig.str = s - for err == nil && len(s) != 0 { - err, s = validSingle(s, 0) - } - if err != nil { - sig = Signature{""} - } - - return -} - -// ParseSignatureMust behaves like ParseSignature, except that it panics if s -// is not valid. -func ParseSignatureMust(s string) Signature { - sig, err := ParseSignature(s) - if err != nil { - panic(err) - } - return sig -} - -// Empty retruns whether the signature is the empty signature. -func (s Signature) Empty() bool { - return s.str == "" -} - -// Single returns whether the signature represents a single, complete type. -func (s Signature) Single() bool { - err, r := validSingle(s.str, 0) - return err != nil && r == "" -} - -// String returns the signature's string representation. -func (s Signature) String() string { - return s.str -} - -// A SignatureError indicates that a signature passed to a function or received -// on a connection is not a valid signature. -type SignatureError struct { - Sig string - Reason string -} - -func (e SignatureError) Error() string { - return fmt.Sprintf("dbus: invalid signature: %q (%s)", e.Sig, e.Reason) -} - -// Try to read a single type from this string. If it was successfull, err is nil -// and rem is the remaining unparsed part. Otherwise, err is a non-nil -// SignatureError and rem is "". depth is the current recursion depth which may -// not be greater than 64 and should be given as 0 on the first call. -func validSingle(s string, depth int) (err error, rem string) { - if s == "" { - return SignatureError{Sig: s, Reason: "empty signature"}, "" - } - if depth > 64 { - return SignatureError{Sig: s, Reason: "container nesting too deep"}, "" - } - switch s[0] { - case 'y', 'b', 'n', 'q', 'i', 'u', 'x', 't', 'd', 's', 'g', 'o', 'v', 'h': - return nil, s[1:] - case 'a': - if len(s) > 1 && s[1] == '{' { - i := findMatching(s[1:], '{', '}') - if i == -1 { - return SignatureError{Sig: s, Reason: "unmatched '{'"}, "" - } - i++ - rem = s[i+1:] - s = s[2:i] - if err, _ = validSingle(s[:1], depth+1); err != nil { - return err, "" - } - err, nr := validSingle(s[1:], depth+1) - if err != nil { - return err, "" - } - if nr != "" { - return SignatureError{Sig: s, Reason: "too many types in dict"}, "" - } - return nil, rem - } - return validSingle(s[1:], depth+1) - case '(': - i := findMatching(s, '(', ')') - if i == -1 { - return SignatureError{Sig: s, Reason: "unmatched ')'"}, "" - } - rem = s[i+1:] - s = s[1:i] - for err == nil && s != "" { - err, s = validSingle(s, depth+1) - } - if err != nil { - rem = "" - } - return - } - return SignatureError{Sig: s, Reason: "invalid type character"}, "" -} - -func findMatching(s string, left, right rune) int { - n := 0 - for i, v := range s { - if v == left { - n++ - } else if v == right { - n-- - } - if n == 0 { - return i - } - } - return -1 -} - -// typeFor returns the type of the given signature. It ignores any left over -// characters and panics if s doesn't start with a valid type signature. -func typeFor(s string) (t reflect.Type) { - err, _ := validSingle(s, 0) - if err != nil { - panic(err) - } - - if t, ok := sigToType[s[0]]; ok { - return t - } - switch s[0] { - case 'a': - if s[1] == '{' { - i := strings.LastIndex(s, "}") - t = reflect.MapOf(sigToType[s[2]], typeFor(s[3:i])) - } else { - t = reflect.SliceOf(typeFor(s[1:])) - } - case '(': - t = interfacesType - } - return -} diff --git a/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/guelfey/go.dbus/sig_test.go b/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/guelfey/go.dbus/sig_test.go deleted file mode 100644 index da37bc96..00000000 --- a/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/guelfey/go.dbus/sig_test.go +++ /dev/null @@ -1,70 +0,0 @@ -package dbus - -import ( - "testing" -) - -var sigTests = []struct { - vs []interface{} - sig Signature -}{ - { - []interface{}{new(int32)}, - Signature{"i"}, - }, - { - []interface{}{new(string)}, - Signature{"s"}, - }, - { - []interface{}{new(Signature)}, - Signature{"g"}, - }, - { - []interface{}{new([]int16)}, - Signature{"an"}, - }, - { - []interface{}{new(int16), new(uint32)}, - Signature{"nu"}, - }, - { - []interface{}{new(map[byte]Variant)}, - Signature{"a{yv}"}, - }, - { - []interface{}{new(Variant), new([]map[int32]string)}, - Signature{"vaa{is}"}, - }, -} - -func TestSig(t *testing.T) { - for i, v := range sigTests { - sig := SignatureOf(v.vs...) - if sig != v.sig { - t.Errorf("test %d: got %q, expected %q", i+1, sig.str, v.sig.str) - } - } -} - -var getSigTest = []interface{}{ - []struct { - b byte - i int32 - t uint64 - s string - }{}, - map[string]Variant{}, -} - -func BenchmarkGetSignatureSimple(b *testing.B) { - for i := 0; i < b.N; i++ { - SignatureOf("", int32(0)) - } -} - -func BenchmarkGetSignatureLong(b *testing.B) { - for i := 0; i < b.N; i++ { - SignatureOf(getSigTest...) - } -} diff --git a/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/guelfey/go.dbus/transport_darwin.go b/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/guelfey/go.dbus/transport_darwin.go deleted file mode 100644 index 1bba0d6b..00000000 --- a/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/guelfey/go.dbus/transport_darwin.go +++ /dev/null @@ -1,6 +0,0 @@ -package dbus - -func (t *unixTransport) SendNullByte() error { - _, err := t.Write([]byte{0}) - return err -} diff --git a/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/guelfey/go.dbus/transport_generic.go b/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/guelfey/go.dbus/transport_generic.go deleted file mode 100644 index 46f8f49d..00000000 --- a/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/guelfey/go.dbus/transport_generic.go +++ /dev/null @@ -1,35 +0,0 @@ -package dbus - -import ( - "encoding/binary" - "errors" - "io" -) - -type genericTransport struct { - io.ReadWriteCloser -} - -func (t genericTransport) SendNullByte() error { - _, err := t.Write([]byte{0}) - return err -} - -func (t genericTransport) SupportsUnixFDs() bool { - return false -} - -func (t genericTransport) EnableUnixFDs() {} - -func (t genericTransport) ReadMessage() (*Message, error) { - return DecodeMessage(t) -} - -func (t genericTransport) SendMessage(msg *Message) error { - for _, v := range msg.Body { - if _, ok := v.(UnixFD); ok { - return errors.New("dbus: unix fd passing not enabled") - } - } - return msg.EncodeTo(t, binary.LittleEndian) -} diff --git a/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/guelfey/go.dbus/transport_unix.go b/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/guelfey/go.dbus/transport_unix.go deleted file mode 100644 index d16229be..00000000 --- a/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/guelfey/go.dbus/transport_unix.go +++ /dev/null @@ -1,190 +0,0 @@ -package dbus - -import ( - "bytes" - "encoding/binary" - "errors" - "io" - "net" - "syscall" -) - -type oobReader struct { - conn *net.UnixConn - oob []byte - buf [4096]byte -} - -func (o *oobReader) Read(b []byte) (n int, err error) { - n, oobn, flags, _, err := o.conn.ReadMsgUnix(b, o.buf[:]) - if err != nil { - return n, err - } - if flags&syscall.MSG_CTRUNC != 0 { - return n, errors.New("dbus: control data truncated (too many fds received)") - } - o.oob = append(o.oob, o.buf[:oobn]...) - return n, nil -} - -type unixTransport struct { - *net.UnixConn - hasUnixFDs bool -} - -func newUnixTransport(keys string) (transport, error) { - var err error - - t := new(unixTransport) - abstract := getKey(keys, "abstract") - path := getKey(keys, "path") - switch { - case abstract == "" && path == "": - return nil, errors.New("dbus: invalid address (neither path nor abstract set)") - case abstract != "" && path == "": - t.UnixConn, err = net.DialUnix("unix", nil, &net.UnixAddr{Name: "@" + abstract, Net: "unix"}) - if err != nil { - return nil, err - } - return t, nil - case abstract == "" && path != "": - t.UnixConn, err = net.DialUnix("unix", nil, &net.UnixAddr{Name: path, Net: "unix"}) - if err != nil { - return nil, err - } - return t, nil - default: - return nil, errors.New("dbus: invalid address (both path and abstract set)") - } -} - -func (t *unixTransport) EnableUnixFDs() { - t.hasUnixFDs = true -} - -func (t *unixTransport) ReadMessage() (*Message, error) { - var ( - blen, hlen uint32 - csheader [16]byte - headers []header - order binary.ByteOrder - unixfds uint32 - ) - // To be sure that all bytes of out-of-band data are read, we use a special - // reader that uses ReadUnix on the underlying connection instead of Read - // and gathers the out-of-band data in a buffer. - rd := &oobReader{conn: t.UnixConn} - // read the first 16 bytes (the part of the header that has a constant size), - // from which we can figure out the length of the rest of the message - if _, err := io.ReadFull(rd, csheader[:]); err != nil { - return nil, err - } - switch csheader[0] { - case 'l': - order = binary.LittleEndian - case 'B': - order = binary.BigEndian - default: - return nil, InvalidMessageError("invalid byte order") - } - // csheader[4:8] -> length of message body, csheader[12:16] -> length of - // header fields (without alignment) - binary.Read(bytes.NewBuffer(csheader[4:8]), order, &blen) - binary.Read(bytes.NewBuffer(csheader[12:]), order, &hlen) - if hlen%8 != 0 { - hlen += 8 - (hlen % 8) - } - - // decode headers and look for unix fds - headerdata := make([]byte, hlen+4) - copy(headerdata, csheader[12:]) - if _, err := io.ReadFull(t, headerdata[4:]); err != nil { - return nil, err - } - dec := newDecoder(bytes.NewBuffer(headerdata), order) - dec.pos = 12 - vs, err := dec.Decode(Signature{"a(yv)"}) - if err != nil { - return nil, err - } - Store(vs, &headers) - for _, v := range headers { - if v.Field == byte(FieldUnixFDs) { - unixfds, _ = v.Variant.value.(uint32) - } - } - all := make([]byte, 16+hlen+blen) - copy(all, csheader[:]) - copy(all[16:], headerdata[4:]) - if _, err := io.ReadFull(rd, all[16+hlen:]); err != nil { - return nil, err - } - if unixfds != 0 { - if !t.hasUnixFDs { - return nil, errors.New("dbus: got unix fds on unsupported transport") - } - // read the fds from the OOB data - scms, err := syscall.ParseSocketControlMessage(rd.oob) - if err != nil { - return nil, err - } - if len(scms) != 1 { - return nil, errors.New("dbus: received more than one socket control message") - } - fds, err := syscall.ParseUnixRights(&scms[0]) - if err != nil { - return nil, err - } - msg, err := DecodeMessage(bytes.NewBuffer(all)) - if err != nil { - return nil, err - } - // substitute the values in the message body (which are indices for the - // array receiver via OOB) with the actual values - for i, v := range msg.Body { - if j, ok := v.(UnixFDIndex); ok { - if uint32(j) >= unixfds { - return nil, InvalidMessageError("invalid index for unix fd") - } - msg.Body[i] = UnixFD(fds[j]) - } - } - return msg, nil - } - return DecodeMessage(bytes.NewBuffer(all)) -} - -func (t *unixTransport) SendMessage(msg *Message) error { - fds := make([]int, 0) - for i, v := range msg.Body { - if fd, ok := v.(UnixFD); ok { - msg.Body[i] = UnixFDIndex(len(fds)) - fds = append(fds, int(fd)) - } - } - if len(fds) != 0 { - if !t.hasUnixFDs { - return errors.New("dbus: unix fd passing not enabled") - } - msg.Headers[FieldUnixFDs] = MakeVariant(uint32(len(fds))) - oob := syscall.UnixRights(fds...) - buf := new(bytes.Buffer) - msg.EncodeTo(buf, binary.LittleEndian) - n, oobn, err := t.UnixConn.WriteMsgUnix(buf.Bytes(), oob, nil) - if err != nil { - return err - } - if n != buf.Len() || oobn != len(oob) { - return io.ErrShortWrite - } - } else { - if err := msg.EncodeTo(t, binary.LittleEndian); err != nil { - return nil - } - } - return nil -} - -func (t *unixTransport) SupportsUnixFDs() bool { - return true -} diff --git a/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/guelfey/go.dbus/transport_unix_test.go b/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/guelfey/go.dbus/transport_unix_test.go deleted file mode 100644 index 302233fc..00000000 --- a/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/guelfey/go.dbus/transport_unix_test.go +++ /dev/null @@ -1,49 +0,0 @@ -package dbus - -import ( - "os" - "testing" -) - -const testString = `This is a test! -This text should be read from the file that is created by this test.` - -type unixFDTest struct{} - -func (t unixFDTest) Test(fd UnixFD) (string, *Error) { - var b [4096]byte - file := os.NewFile(uintptr(fd), "testfile") - defer file.Close() - n, err := file.Read(b[:]) - if err != nil { - return "", &Error{"com.github.guelfey.test.Error", nil} - } - return string(b[:n]), nil -} - -func TestUnixFDs(t *testing.T) { - conn, err := SessionBus() - if err != nil { - t.Fatal(err) - } - r, w, err := os.Pipe() - if err != nil { - t.Fatal(err) - } - defer w.Close() - if _, err := w.Write([]byte(testString)); err != nil { - t.Fatal(err) - } - name := conn.Names()[0] - test := unixFDTest{} - conn.Export(test, "/com/github/guelfey/test", "com.github.guelfey.test") - var s string - obj := conn.Object(name, "/com/github/guelfey/test") - err = obj.Call("com.github.guelfey.test.Test", 0, UnixFD(r.Fd())).Store(&s) - if err != nil { - t.Fatal(err) - } - if s != testString { - t.Fatal("got", s, "wanted", testString) - } -} diff --git a/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/guelfey/go.dbus/transport_unixcred.go b/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/guelfey/go.dbus/transport_unixcred.go deleted file mode 100644 index 42a0e769..00000000 --- a/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/guelfey/go.dbus/transport_unixcred.go +++ /dev/null @@ -1,22 +0,0 @@ -// +build !darwin - -package dbus - -import ( - "io" - "os" - "syscall" -) - -func (t *unixTransport) SendNullByte() error { - ucred := &syscall.Ucred{Pid: int32(os.Getpid()), Uid: uint32(os.Getuid()), Gid: uint32(os.Getgid())} - b := syscall.UnixCredentials(ucred) - _, oobn, err := t.UnixConn.WriteMsgUnix([]byte{0}, b, nil) - if err != nil { - return err - } - if oobn != len(b) { - return io.ErrShortWrite - } - return nil -} diff --git a/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/guelfey/go.dbus/variant.go b/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/guelfey/go.dbus/variant.go deleted file mode 100644 index b1b53ceb..00000000 --- a/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/guelfey/go.dbus/variant.go +++ /dev/null @@ -1,129 +0,0 @@ -package dbus - -import ( - "bytes" - "fmt" - "reflect" - "strconv" -) - -// Variant represents the D-Bus variant type. -type Variant struct { - sig Signature - value interface{} -} - -// MakeVariant converts the given value to a Variant. It panics if v cannot be -// represented as a D-Bus type. -func MakeVariant(v interface{}) Variant { - return Variant{SignatureOf(v), v} -} - -// ParseVariant parses the given string as a variant as described at -// https://developer.gnome.org/glib/unstable/gvariant-text.html. If sig is not -// empty, it is taken to be the expected signature for the variant. -func ParseVariant(s string, sig Signature) (Variant, error) { - tokens := varLex(s) - p := &varParser{tokens: tokens} - n, err := varMakeNode(p) - if err != nil { - return Variant{}, err - } - if sig.str == "" { - sig, err = varInfer(n) - if err != nil { - return Variant{}, err - } - } - v, err := n.Value(sig) - if err != nil { - return Variant{}, err - } - return MakeVariant(v), nil -} - -// format returns a formatted version of v and whether this string can be parsed -// unambigously. -func (v Variant) format() (string, bool) { - switch v.sig.str[0] { - case 'b', 'i': - return fmt.Sprint(v.value), true - case 'n', 'q', 'u', 'x', 't', 'd', 'h': - return fmt.Sprint(v.value), false - case 's': - return strconv.Quote(v.value.(string)), true - case 'o': - return strconv.Quote(string(v.value.(ObjectPath))), false - case 'g': - return strconv.Quote(v.value.(Signature).str), false - case 'v': - s, unamb := v.value.(Variant).format() - if !unamb { - return "<@" + v.value.(Variant).sig.str + " " + s + ">", true - } - return "<" + s + ">", true - case 'y': - return fmt.Sprintf("%#x", v.value.(byte)), false - } - rv := reflect.ValueOf(v.value) - switch rv.Kind() { - case reflect.Slice: - if rv.Len() == 0 { - return "[]", false - } - unamb := true - buf := bytes.NewBuffer([]byte("[")) - for i := 0; i < rv.Len(); i++ { - // TODO: slooow - s, b := MakeVariant(rv.Index(i).Interface()).format() - unamb = unamb && b - buf.WriteString(s) - if i != rv.Len()-1 { - buf.WriteString(", ") - } - } - buf.WriteByte(']') - return buf.String(), unamb - case reflect.Map: - if rv.Len() == 0 { - return "{}", false - } - unamb := true - buf := bytes.NewBuffer([]byte("{")) - for i, k := range rv.MapKeys() { - s, b := MakeVariant(k.Interface()).format() - unamb = unamb && b - buf.WriteString(s) - buf.WriteString(": ") - s, b = MakeVariant(rv.MapIndex(k).Interface()).format() - unamb = unamb && b - buf.WriteString(s) - if i != rv.Len()-1 { - buf.WriteString(", ") - } - } - buf.WriteByte('}') - return buf.String(), unamb - } - return `"INVALID"`, true -} - -// Signature returns the D-Bus signature of the underlying value of v. -func (v Variant) Signature() Signature { - return v.sig -} - -// String returns the string representation of the underlying value of v as -// described at https://developer.gnome.org/glib/unstable/gvariant-text.html. -func (v Variant) String() string { - s, unamb := v.format() - if !unamb { - return "@" + v.sig.str + " " + s - } - return s -} - -// Value returns the underlying value of v. -func (v Variant) Value() interface{} { - return v.value -} diff --git a/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/guelfey/go.dbus/variant_lexer.go b/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/guelfey/go.dbus/variant_lexer.go deleted file mode 100644 index 332007d6..00000000 --- a/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/guelfey/go.dbus/variant_lexer.go +++ /dev/null @@ -1,284 +0,0 @@ -package dbus - -import ( - "fmt" - "strings" - "unicode" - "unicode/utf8" -) - -// Heavily inspired by the lexer from text/template. - -type varToken struct { - typ varTokenType - val string -} - -type varTokenType byte - -const ( - tokEOF varTokenType = iota - tokError - tokNumber - tokString - tokBool - tokArrayStart - tokArrayEnd - tokDictStart - tokDictEnd - tokVariantStart - tokVariantEnd - tokComma - tokColon - tokType - tokByteString -) - -type varLexer struct { - input string - start int - pos int - width int - tokens []varToken -} - -type lexState func(*varLexer) lexState - -func varLex(s string) []varToken { - l := &varLexer{input: s} - l.run() - return l.tokens -} - -func (l *varLexer) accept(valid string) bool { - if strings.IndexRune(valid, l.next()) >= 0 { - return true - } - l.backup() - return false -} - -func (l *varLexer) backup() { - l.pos -= l.width -} - -func (l *varLexer) emit(t varTokenType) { - l.tokens = append(l.tokens, varToken{t, l.input[l.start:l.pos]}) - l.start = l.pos -} - -func (l *varLexer) errorf(format string, v ...interface{}) lexState { - l.tokens = append(l.tokens, varToken{ - tokError, - fmt.Sprintf(format, v...), - }) - return nil -} - -func (l *varLexer) ignore() { - l.start = l.pos -} - -func (l *varLexer) next() rune { - var r rune - - if l.pos >= len(l.input) { - l.width = 0 - return -1 - } - r, l.width = utf8.DecodeRuneInString(l.input[l.pos:]) - l.pos += l.width - return r -} - -func (l *varLexer) run() { - for state := varLexNormal; state != nil; { - state = state(l) - } -} - -func (l *varLexer) peek() rune { - r := l.next() - l.backup() - return r -} - -func varLexNormal(l *varLexer) lexState { - for { - r := l.next() - switch { - case r == -1: - l.emit(tokEOF) - return nil - case r == '[': - l.emit(tokArrayStart) - case r == ']': - l.emit(tokArrayEnd) - case r == '{': - l.emit(tokDictStart) - case r == '}': - l.emit(tokDictEnd) - case r == '<': - l.emit(tokVariantStart) - case r == '>': - l.emit(tokVariantEnd) - case r == ':': - l.emit(tokColon) - case r == ',': - l.emit(tokComma) - case r == '\'' || r == '"': - l.backup() - return varLexString - case r == '@': - l.backup() - return varLexType - case unicode.IsSpace(r): - l.ignore() - case unicode.IsNumber(r) || r == '+' || r == '-': - l.backup() - return varLexNumber - case r == 'b': - pos := l.start - if n := l.peek(); n == '"' || n == '\'' { - return varLexByteString - } - // not a byte string; try to parse it as a type or bool below - l.pos = pos + 1 - l.width = 1 - fallthrough - default: - // either a bool or a type. Try bools first. - l.backup() - if l.pos+4 <= len(l.input) { - if l.input[l.pos:l.pos+4] == "true" { - l.pos += 4 - l.emit(tokBool) - continue - } - } - if l.pos+5 <= len(l.input) { - if l.input[l.pos:l.pos+5] == "false" { - l.pos += 5 - l.emit(tokBool) - continue - } - } - // must be a type. - return varLexType - } - } -} - -var varTypeMap = map[string]string{ - "boolean": "b", - "byte": "y", - "int16": "n", - "uint16": "q", - "int32": "i", - "uint32": "u", - "int64": "x", - "uint64": "t", - "double": "f", - "string": "s", - "objectpath": "o", - "signature": "g", -} - -func varLexByteString(l *varLexer) lexState { - q := l.next() -Loop: - for { - switch l.next() { - case '\\': - if r := l.next(); r != -1 { - break - } - fallthrough - case -1: - return l.errorf("unterminated bytestring") - case q: - break Loop - } - } - l.emit(tokByteString) - return varLexNormal -} - -func varLexNumber(l *varLexer) lexState { - l.accept("+-") - digits := "0123456789" - if l.accept("0") { - if l.accept("x") { - digits = "0123456789abcdefABCDEF" - } else { - digits = "01234567" - } - } - for strings.IndexRune(digits, l.next()) >= 0 { - } - l.backup() - if l.accept(".") { - for strings.IndexRune(digits, l.next()) >= 0 { - } - l.backup() - } - if l.accept("eE") { - l.accept("+-") - for strings.IndexRune("0123456789", l.next()) >= 0 { - } - l.backup() - } - if r := l.peek(); unicode.IsLetter(r) { - l.next() - return l.errorf("bad number syntax: %q", l.input[l.start:l.pos]) - } - l.emit(tokNumber) - return varLexNormal -} - -func varLexString(l *varLexer) lexState { - q := l.next() -Loop: - for { - switch l.next() { - case '\\': - if r := l.next(); r != -1 { - break - } - fallthrough - case -1: - return l.errorf("unterminated string") - case q: - break Loop - } - } - l.emit(tokString) - return varLexNormal -} - -func varLexType(l *varLexer) lexState { - at := l.accept("@") - for { - r := l.next() - if r == -1 { - break - } - if unicode.IsSpace(r) { - l.backup() - break - } - } - if at { - if _, err := ParseSignature(l.input[l.start+1 : l.pos]); err != nil { - return l.errorf("%s", err) - } - } else { - if _, ok := varTypeMap[l.input[l.start:l.pos]]; ok { - l.emit(tokType) - return varLexNormal - } - return l.errorf("unrecognized type %q", l.input[l.start:l.pos]) - } - l.emit(tokType) - return varLexNormal -} diff --git a/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/guelfey/go.dbus/variant_parser.go b/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/guelfey/go.dbus/variant_parser.go deleted file mode 100644 index d20f5da6..00000000 --- a/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/guelfey/go.dbus/variant_parser.go +++ /dev/null @@ -1,817 +0,0 @@ -package dbus - -import ( - "bytes" - "errors" - "fmt" - "io" - "reflect" - "strconv" - "strings" - "unicode/utf8" -) - -type varParser struct { - tokens []varToken - i int -} - -func (p *varParser) backup() { - p.i-- -} - -func (p *varParser) next() varToken { - if p.i < len(p.tokens) { - t := p.tokens[p.i] - p.i++ - return t - } - return varToken{typ: tokEOF} -} - -type varNode interface { - Infer() (Signature, error) - String() string - Sigs() sigSet - Value(Signature) (interface{}, error) -} - -func varMakeNode(p *varParser) (varNode, error) { - var sig Signature - - for { - t := p.next() - switch t.typ { - case tokEOF: - return nil, io.ErrUnexpectedEOF - case tokError: - return nil, errors.New(t.val) - case tokNumber: - return varMakeNumNode(t, sig) - case tokString: - return varMakeStringNode(t, sig) - case tokBool: - if sig.str != "" && sig.str != "b" { - return nil, varTypeError{t.val, sig} - } - b, err := strconv.ParseBool(t.val) - if err != nil { - return nil, err - } - return boolNode(b), nil - case tokArrayStart: - return varMakeArrayNode(p, sig) - case tokVariantStart: - return varMakeVariantNode(p, sig) - case tokDictStart: - return varMakeDictNode(p, sig) - case tokType: - if sig.str != "" { - return nil, errors.New("unexpected type annotation") - } - if t.val[0] == '@' { - sig.str = t.val[1:] - } else { - sig.str = varTypeMap[t.val] - } - case tokByteString: - if sig.str != "" && sig.str != "ay" { - return nil, varTypeError{t.val, sig} - } - b, err := varParseByteString(t.val) - if err != nil { - return nil, err - } - return byteStringNode(b), nil - default: - return nil, fmt.Errorf("unexpected %q", t.val) - } - } -} - -type varTypeError struct { - val string - sig Signature -} - -func (e varTypeError) Error() string { - return fmt.Sprintf("dbus: can't parse %q as type %q", e.val, e.sig.str) -} - -type sigSet map[Signature]bool - -func (s sigSet) Empty() bool { - return len(s) == 0 -} - -func (s sigSet) Intersect(s2 sigSet) sigSet { - r := make(sigSet) - for k := range s { - if s2[k] { - r[k] = true - } - } - return r -} - -func (s sigSet) Single() (Signature, bool) { - if len(s) == 1 { - for k := range s { - return k, true - } - } - return Signature{}, false -} - -func (s sigSet) ToArray() sigSet { - r := make(sigSet, len(s)) - for k := range s { - r[Signature{"a" + k.str}] = true - } - return r -} - -type numNode struct { - sig Signature - str string - val interface{} -} - -var numSigSet = sigSet{ - Signature{"y"}: true, - Signature{"n"}: true, - Signature{"q"}: true, - Signature{"i"}: true, - Signature{"u"}: true, - Signature{"x"}: true, - Signature{"t"}: true, - Signature{"d"}: true, -} - -func (n numNode) Infer() (Signature, error) { - if strings.ContainsAny(n.str, ".e") { - return Signature{"d"}, nil - } - return Signature{"i"}, nil -} - -func (n numNode) String() string { - return n.str -} - -func (n numNode) Sigs() sigSet { - if n.sig.str != "" { - return sigSet{n.sig: true} - } - if strings.ContainsAny(n.str, ".e") { - return sigSet{Signature{"d"}: true} - } - return numSigSet -} - -func (n numNode) Value(sig Signature) (interface{}, error) { - if n.sig.str != "" && n.sig != sig { - return nil, varTypeError{n.str, sig} - } - if n.val != nil { - return n.val, nil - } - return varNumAs(n.str, sig) -} - -func varMakeNumNode(tok varToken, sig Signature) (varNode, error) { - if sig.str == "" { - return numNode{str: tok.val}, nil - } - num, err := varNumAs(tok.val, sig) - if err != nil { - return nil, err - } - return numNode{sig: sig, val: num}, nil -} - -func varNumAs(s string, sig Signature) (interface{}, error) { - isUnsigned := false - size := 32 - switch sig.str { - case "n": - size = 16 - case "i": - case "x": - size = 64 - case "y": - size = 8 - isUnsigned = true - case "q": - size = 16 - isUnsigned = true - case "u": - isUnsigned = true - case "t": - size = 64 - isUnsigned = true - case "d": - d, err := strconv.ParseFloat(s, 64) - if err != nil { - return nil, err - } - return d, nil - default: - return nil, varTypeError{s, sig} - } - base := 10 - if strings.HasPrefix(s, "0x") { - base = 16 - s = s[2:] - } - if strings.HasPrefix(s, "0") && len(s) != 1 { - base = 8 - s = s[1:] - } - if isUnsigned { - i, err := strconv.ParseUint(s, base, size) - if err != nil { - return nil, err - } - var v interface{} = i - switch sig.str { - case "y": - v = byte(i) - case "q": - v = uint16(i) - case "u": - v = uint32(i) - } - return v, nil - } - i, err := strconv.ParseInt(s, base, size) - if err != nil { - return nil, err - } - var v interface{} = i - switch sig.str { - case "n": - v = int16(i) - case "i": - v = int32(i) - } - return v, nil -} - -type stringNode struct { - sig Signature - str string // parsed - val interface{} // has correct type -} - -var stringSigSet = sigSet{ - Signature{"s"}: true, - Signature{"g"}: true, - Signature{"o"}: true, -} - -func (n stringNode) Infer() (Signature, error) { - return Signature{"s"}, nil -} - -func (n stringNode) String() string { - return n.str -} - -func (n stringNode) Sigs() sigSet { - if n.sig.str != "" { - return sigSet{n.sig: true} - } - return stringSigSet -} - -func (n stringNode) Value(sig Signature) (interface{}, error) { - if n.sig.str != "" && n.sig != sig { - return nil, varTypeError{n.str, sig} - } - if n.val != nil { - return n.val, nil - } - switch { - case sig.str == "g": - return Signature{n.str}, nil - case sig.str == "o": - return ObjectPath(n.str), nil - case sig.str == "s": - return n.str, nil - default: - return nil, varTypeError{n.str, sig} - } -} - -func varMakeStringNode(tok varToken, sig Signature) (varNode, error) { - if sig.str != "" && sig.str != "s" && sig.str != "g" && sig.str != "o" { - return nil, fmt.Errorf("invalid type %q for string", sig.str) - } - s, err := varParseString(tok.val) - if err != nil { - return nil, err - } - n := stringNode{str: s} - if sig.str == "" { - return stringNode{str: s}, nil - } - n.sig = sig - switch sig.str { - case "o": - n.val = ObjectPath(s) - case "g": - n.val = Signature{s} - case "s": - n.val = s - } - return n, nil -} - -func varParseString(s string) (string, error) { - // quotes are guaranteed to be there - s = s[1 : len(s)-1] - buf := new(bytes.Buffer) - for len(s) != 0 { - r, size := utf8.DecodeRuneInString(s) - if r == utf8.RuneError && size == 1 { - return "", errors.New("invalid UTF-8") - } - s = s[size:] - if r != '\\' { - buf.WriteRune(r) - continue - } - r, size = utf8.DecodeRuneInString(s) - if r == utf8.RuneError && size == 1 { - return "", errors.New("invalid UTF-8") - } - s = s[size:] - switch r { - case 'a': - buf.WriteRune(0x7) - case 'b': - buf.WriteRune(0x8) - case 'f': - buf.WriteRune(0xc) - case 'n': - buf.WriteRune('\n') - case 'r': - buf.WriteRune('\r') - case 't': - buf.WriteRune('\t') - case '\n': - case 'u': - if len(s) < 4 { - return "", errors.New("short unicode escape") - } - r, err := strconv.ParseUint(s[:4], 16, 32) - if err != nil { - return "", err - } - buf.WriteRune(rune(r)) - s = s[4:] - case 'U': - if len(s) < 8 { - return "", errors.New("short unicode escape") - } - r, err := strconv.ParseUint(s[:8], 16, 32) - if err != nil { - return "", err - } - buf.WriteRune(rune(r)) - s = s[8:] - default: - buf.WriteRune(r) - } - } - return buf.String(), nil -} - -var boolSigSet = sigSet{Signature{"b"}: true} - -type boolNode bool - -func (boolNode) Infer() (Signature, error) { - return Signature{"b"}, nil -} - -func (b boolNode) String() string { - if b { - return "true" - } - return "false" -} - -func (boolNode) Sigs() sigSet { - return boolSigSet -} - -func (b boolNode) Value(sig Signature) (interface{}, error) { - if sig.str != "b" { - return nil, varTypeError{b.String(), sig} - } - return bool(b), nil -} - -type arrayNode struct { - set sigSet - children []varNode - val interface{} -} - -func (n arrayNode) Infer() (Signature, error) { - for _, v := range n.children { - csig, err := varInfer(v) - if err != nil { - continue - } - return Signature{"a" + csig.str}, nil - } - return Signature{}, fmt.Errorf("can't infer type for %q", n.String()) -} - -func (n arrayNode) String() string { - s := "[" - for i, v := range n.children { - s += v.String() - if i != len(n.children)-1 { - s += ", " - } - } - return s + "]" -} - -func (n arrayNode) Sigs() sigSet { - return n.set -} - -func (n arrayNode) Value(sig Signature) (interface{}, error) { - if n.set.Empty() { - // no type information whatsoever, so this must be an empty slice - return reflect.MakeSlice(typeFor(sig.str), 0, 0).Interface(), nil - } - if !n.set[sig] { - return nil, varTypeError{n.String(), sig} - } - s := reflect.MakeSlice(typeFor(sig.str), len(n.children), len(n.children)) - for i, v := range n.children { - rv, err := v.Value(Signature{sig.str[1:]}) - if err != nil { - return nil, err - } - s.Index(i).Set(reflect.ValueOf(rv)) - } - return s.Interface(), nil -} - -func varMakeArrayNode(p *varParser, sig Signature) (varNode, error) { - var n arrayNode - if sig.str != "" { - n.set = sigSet{sig: true} - } - if t := p.next(); t.typ == tokArrayEnd { - return n, nil - } else { - p.backup() - } -Loop: - for { - t := p.next() - switch t.typ { - case tokEOF: - return nil, io.ErrUnexpectedEOF - case tokError: - return nil, errors.New(t.val) - } - p.backup() - cn, err := varMakeNode(p) - if err != nil { - return nil, err - } - if cset := cn.Sigs(); !cset.Empty() { - if n.set.Empty() { - n.set = cset.ToArray() - } else { - nset := cset.ToArray().Intersect(n.set) - if nset.Empty() { - return nil, fmt.Errorf("can't parse %q with given type information", cn.String()) - } - n.set = nset - } - } - n.children = append(n.children, cn) - switch t := p.next(); t.typ { - case tokEOF: - return nil, io.ErrUnexpectedEOF - case tokError: - return nil, errors.New(t.val) - case tokArrayEnd: - break Loop - case tokComma: - continue - default: - return nil, fmt.Errorf("unexpected %q", t.val) - } - } - return n, nil -} - -type variantNode struct { - n varNode -} - -var variantSet = sigSet{ - Signature{"v"}: true, -} - -func (variantNode) Infer() (Signature, error) { - return Signature{"v"}, nil -} - -func (n variantNode) String() string { - return "<" + n.n.String() + ">" -} - -func (variantNode) Sigs() sigSet { - return variantSet -} - -func (n variantNode) Value(sig Signature) (interface{}, error) { - if sig.str != "v" { - return nil, varTypeError{n.String(), sig} - } - sig, err := varInfer(n.n) - if err != nil { - return nil, err - } - v, err := n.n.Value(sig) - if err != nil { - return nil, err - } - return MakeVariant(v), nil -} - -func varMakeVariantNode(p *varParser, sig Signature) (varNode, error) { - n, err := varMakeNode(p) - if err != nil { - return nil, err - } - if t := p.next(); t.typ != tokVariantEnd { - return nil, fmt.Errorf("unexpected %q", t.val) - } - vn := variantNode{n} - if sig.str != "" && sig.str != "v" { - return nil, varTypeError{vn.String(), sig} - } - return variantNode{n}, nil -} - -type dictEntry struct { - key, val varNode -} - -type dictNode struct { - kset, vset sigSet - children []dictEntry - val interface{} -} - -func (n dictNode) Infer() (Signature, error) { - for _, v := range n.children { - ksig, err := varInfer(v.key) - if err != nil { - continue - } - vsig, err := varInfer(v.val) - if err != nil { - continue - } - return Signature{"a{" + ksig.str + vsig.str + "}"}, nil - } - return Signature{}, fmt.Errorf("can't infer type for %q", n.String()) -} - -func (n dictNode) String() string { - s := "{" - for i, v := range n.children { - s += v.key.String() + ": " + v.val.String() - if i != len(n.children)-1 { - s += ", " - } - } - return s + "}" -} - -func (n dictNode) Sigs() sigSet { - r := sigSet{} - for k := range n.kset { - for v := range n.vset { - sig := "a{" + k.str + v.str + "}" - r[Signature{sig}] = true - } - } - return r -} - -func (n dictNode) Value(sig Signature) (interface{}, error) { - set := n.Sigs() - if set.Empty() { - // no type information -> empty dict - return reflect.MakeMap(typeFor(sig.str)).Interface(), nil - } - if !set[sig] { - return nil, varTypeError{n.String(), sig} - } - m := reflect.MakeMap(typeFor(sig.str)) - ksig := Signature{sig.str[2:3]} - vsig := Signature{sig.str[3 : len(sig.str)-1]} - for _, v := range n.children { - kv, err := v.key.Value(ksig) - if err != nil { - return nil, err - } - vv, err := v.val.Value(vsig) - if err != nil { - return nil, err - } - m.SetMapIndex(reflect.ValueOf(kv), reflect.ValueOf(vv)) - } - return m.Interface(), nil -} - -func varMakeDictNode(p *varParser, sig Signature) (varNode, error) { - var n dictNode - - if sig.str != "" { - if len(sig.str) < 5 { - return nil, fmt.Errorf("invalid signature %q for dict type", sig) - } - ksig := Signature{string(sig.str[2])} - vsig := Signature{sig.str[3 : len(sig.str)-1]} - n.kset = sigSet{ksig: true} - n.vset = sigSet{vsig: true} - } - if t := p.next(); t.typ == tokDictEnd { - return n, nil - } else { - p.backup() - } -Loop: - for { - t := p.next() - switch t.typ { - case tokEOF: - return nil, io.ErrUnexpectedEOF - case tokError: - return nil, errors.New(t.val) - } - p.backup() - kn, err := varMakeNode(p) - if err != nil { - return nil, err - } - if kset := kn.Sigs(); !kset.Empty() { - if n.kset.Empty() { - n.kset = kset - } else { - n.kset = kset.Intersect(n.kset) - if n.kset.Empty() { - return nil, fmt.Errorf("can't parse %q with given type information", kn.String()) - } - } - } - t = p.next() - switch t.typ { - case tokEOF: - return nil, io.ErrUnexpectedEOF - case tokError: - return nil, errors.New(t.val) - case tokColon: - default: - return nil, fmt.Errorf("unexpected %q", t.val) - } - t = p.next() - switch t.typ { - case tokEOF: - return nil, io.ErrUnexpectedEOF - case tokError: - return nil, errors.New(t.val) - } - p.backup() - vn, err := varMakeNode(p) - if err != nil { - return nil, err - } - if vset := vn.Sigs(); !vset.Empty() { - if n.vset.Empty() { - n.vset = vset - } else { - n.vset = n.vset.Intersect(vset) - if n.vset.Empty() { - return nil, fmt.Errorf("can't parse %q with given type information", vn.String()) - } - } - } - n.children = append(n.children, dictEntry{kn, vn}) - t = p.next() - switch t.typ { - case tokEOF: - return nil, io.ErrUnexpectedEOF - case tokError: - return nil, errors.New(t.val) - case tokDictEnd: - break Loop - case tokComma: - continue - default: - return nil, fmt.Errorf("unexpected %q", t.val) - } - } - return n, nil -} - -type byteStringNode []byte - -var byteStringSet = sigSet{ - Signature{"ay"}: true, -} - -func (byteStringNode) Infer() (Signature, error) { - return Signature{"ay"}, nil -} - -func (b byteStringNode) String() string { - return string(b) -} - -func (b byteStringNode) Sigs() sigSet { - return byteStringSet -} - -func (b byteStringNode) Value(sig Signature) (interface{}, error) { - if sig.str != "ay" { - return nil, varTypeError{b.String(), sig} - } - return []byte(b), nil -} - -func varParseByteString(s string) ([]byte, error) { - // quotes and b at start are guaranteed to be there - b := make([]byte, 0, 1) - s = s[2 : len(s)-1] - for len(s) != 0 { - c := s[0] - s = s[1:] - if c != '\\' { - b = append(b, c) - continue - } - c = s[0] - s = s[1:] - switch c { - case 'a': - b = append(b, 0x7) - case 'b': - b = append(b, 0x8) - case 'f': - b = append(b, 0xc) - case 'n': - b = append(b, '\n') - case 'r': - b = append(b, '\r') - case 't': - b = append(b, '\t') - case 'x': - if len(s) < 2 { - return nil, errors.New("short escape") - } - n, err := strconv.ParseUint(s[:2], 16, 8) - if err != nil { - return nil, err - } - b = append(b, byte(n)) - s = s[2:] - case '0': - if len(s) < 3 { - return nil, errors.New("short escape") - } - n, err := strconv.ParseUint(s[:3], 8, 8) - if err != nil { - return nil, err - } - b = append(b, byte(n)) - s = s[3:] - default: - b = append(b, c) - } - } - return append(b, 0), nil -} - -func varInfer(n varNode) (Signature, error) { - if sig, ok := n.Sigs().Single(); ok { - return sig, nil - } - return n.Infer() -} diff --git a/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/guelfey/go.dbus/variant_test.go b/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/guelfey/go.dbus/variant_test.go deleted file mode 100644 index da917c8e..00000000 --- a/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/guelfey/go.dbus/variant_test.go +++ /dev/null @@ -1,78 +0,0 @@ -package dbus - -import "reflect" -import "testing" - -var variantFormatTests = []struct { - v interface{} - s string -}{ - {int32(1), `1`}, - {"foo", `"foo"`}, - {ObjectPath("/org/foo"), `@o "/org/foo"`}, - {Signature{"i"}, `@g "i"`}, - {[]byte{}, `@ay []`}, - {[]int32{1, 2}, `[1, 2]`}, - {[]int64{1, 2}, `@ax [1, 2]`}, - {[][]int32{{3, 4}, {5, 6}}, `[[3, 4], [5, 6]]`}, - {[]Variant{MakeVariant(int32(1)), MakeVariant(1.0)}, `[<1>, <@d 1>]`}, - {map[string]int32{"one": 1, "two": 2}, `{"one": 1, "two": 2}`}, - {map[int32]ObjectPath{1: "/org/foo"}, `@a{io} {1: "/org/foo"}`}, - {map[string]Variant{}, `@a{sv} {}`}, -} - -func TestFormatVariant(t *testing.T) { - for i, v := range variantFormatTests { - if s := MakeVariant(v.v).String(); s != v.s { - t.Errorf("test %d: got %q, wanted %q", i+1, s, v.s) - } - } -} - -var variantParseTests = []struct { - s string - v interface{} -}{ - {"1", int32(1)}, - {"true", true}, - {"false", false}, - {"1.0", float64(1.0)}, - {"0x10", int32(16)}, - {"1e1", float64(10)}, - {`"foo"`, "foo"}, - {`"\a\b\f\n\r\t"`, "\x07\x08\x0c\n\r\t"}, - {`"\u00e4\U0001f603"`, "\u00e4\U0001f603"}, - {"[1]", []int32{1}}, - {"[1, 2, 3]", []int32{1, 2, 3}}, - {"@ai []", []int32{}}, - {"[1, 5.0]", []float64{1, 5.0}}, - {"[[1, 2], [3, 4.0]]", [][]float64{{1, 2}, {3, 4}}}, - {`[@o "/org/foo", "/org/bar"]`, []ObjectPath{"/org/foo", "/org/bar"}}, - {"<1>", MakeVariant(int32(1))}, - {"[<1>, <2.0>]", []Variant{MakeVariant(int32(1)), MakeVariant(2.0)}}, - {`[[], [""]]`, [][]string{{}, {""}}}, - {`@a{ss} {}`, map[string]string{}}, - {`{"foo": 1}`, map[string]int32{"foo": 1}}, - {`[{}, {"foo": "bar"}]`, []map[string]string{{}, {"foo": "bar"}}}, - {`{"a": <1>, "b": <"foo">}`, - map[string]Variant{"a": MakeVariant(int32(1)), "b": MakeVariant("foo")}}, - {`b''`, []byte{0}}, - {`b"abc"`, []byte{'a', 'b', 'c', 0}}, - {`b"\x01\0002\a\b\f\n\r\t"`, []byte{1, 2, 0x7, 0x8, 0xc, '\n', '\r', '\t', 0}}, - {`[[0], b""]`, [][]byte{{0}, {0}}}, - {"int16 0", int16(0)}, - {"byte 0", byte(0)}, -} - -func TestParseVariant(t *testing.T) { - for i, v := range variantParseTests { - nv, err := ParseVariant(v.s, Signature{}) - if err != nil { - t.Errorf("test %d: parsing failed: %s", i+1, err) - continue - } - if !reflect.DeepEqual(nv.value, v.v) { - t.Errorf("test %d: got %q, wanted %q", i+1, nv, v.v) - } - } -} diff --git a/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/sigma/bdoor/LICENSE b/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/sigma/bdoor/LICENSE deleted file mode 100644 index 8dada3ed..00000000 --- a/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/sigma/bdoor/LICENSE +++ /dev/null @@ -1,201 +0,0 @@ - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "{}" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright {yyyy} {name of copyright owner} - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. diff --git a/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/sigma/bdoor/README b/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/sigma/bdoor/README deleted file mode 100644 index 6ed2adb3..00000000 --- a/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/sigma/bdoor/README +++ /dev/null @@ -1 +0,0 @@ -ping the VMware backdoor diff --git a/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/sigma/bdoor/check.go b/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/sigma/bdoor/check.go deleted file mode 100644 index f209c91e..00000000 --- a/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/sigma/bdoor/check.go +++ /dev/null @@ -1,67 +0,0 @@ -// Copyright 2016 Yann Hodique -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package bdoor - -// #include <limits.h> -// #include <stdint.h> -// #include <signal.h> -// #include <setjmp.h> -// -// #define VMWARE_BDOOR_MAGIC 0x564D5868 -// #define VMWARE_BDOOR_PORT 0x5658 -// #define VMWARE_BDOOR_CMD_GETVERSION 10 -// #define VMWARE_BDOOR_RUN(cmd, eax, ebx, ecx, edx) \ -// __asm__("inl %%dx, %%eax" : \ -// "=a"(eax), "=c"(ecx), "=d"(edx), "=b"(ebx) : \ -// "0"(VMWARE_BDOOR_MAGIC), \ -// "1"(VMWARE_BDOOR_CMD_##cmd), \ -// "2"(VMWARE_BDOOR_PORT), \ -// "3"(UINT_MAX) : \ -// "memory"); -// -// static sigjmp_buf env; -// -// void handler(int signal) { -// siglongjmp(env, 1); -// } -// -// int hypervisor_bdoor_check(void) { -// uint32_t eax, ebx, ecx, edx; -// struct sigaction sa; -// int res = 0; -// -// sa.sa_handler = handler; -// sigemptyset(&sa.sa_mask); -// sa.sa_flags = SA_RESTART; -// sigaction(SIGSEGV, &sa, 0); -// sigaction(SIGILL, &sa, 0); -// -// if(sigsetjmp(env, 1)==0) { -// VMWARE_BDOOR_RUN(GETVERSION, eax, ebx, ecx, edx); -// if (ebx == VMWARE_BDOOR_MAGIC) -// res = 1; -// } -// -// sa.sa_handler = SIG_DFL; -// sigaction(SIGSEGV, &sa, 0); -// sigaction(SIGILL, &sa, 0); -// return res; -// } -// -import "C" - -func HypervisorPortCheck() bool { - return C.hypervisor_bdoor_check() != 0 -} diff --git a/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/sigma/vmw-guestinfo/CDDL.txt b/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/sigma/vmw-guestinfo/CDDL.txt deleted file mode 100644 index 0116b7a9..00000000 --- a/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/sigma/vmw-guestinfo/CDDL.txt +++ /dev/null @@ -1,241 +0,0 @@ - COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) - Version 1.0 - - -1. Definitions. - - 1.1. “Contributor” means each individual or entity that creates or contributes to the creation of Modifications. - - 1.2. “Contributor Version” means the combination of the Original Software, prior Modifications used by a Contributor - (if any), and the Modifications made by that particular Contributor. - - 1.3. “Covered Software” means (a) the Original Software, or (b) Modifications, or (c) the combination - of files containing Original Software with files containing Modifications, in each case including portions thereof. - - 1.4. “Executable” means the Covered Software in any form other than Source Code. - - 1.5. “Initial Developer” means the individual or entity that first makes Original Software available under this License. - - 1.6. “Larger Work” means a work which combines Covered Software or portions thereof with code not governed by the terms - of this License. - - 1.7. “License” means this document. - - 1.8. “Licensable” means having the right to grant, to the maximum extent possible, whether at the time of the - initial grant or subsequently acquired, any and all of the rights conveyed herein. - - 1.9. “Modifications” means the Source Code and Executable form of any of the following: - A. Any file that results from an addition to, deletion from or modification of the contents of a file - containing Original Software or previous Modifications; - B. Any new file that contains any part of the Original Software or previous Modification; or - C. Any new file that is contributed or otherwise made available under the terms of this License. - - 1.10. “Original Software” means the Source Code and Executable form of computer software code that is originally - released under this License. - - 1.11. “Patent Claims” means any patent claim(s), now owned or hereafter acquired, including without limitation, - method, process, and apparatus claims, in any patent Licensable by grantor. - - 1.12. “Source Code” means (a) the common form of computer software code in which modifications are made and - (b) associated documentation included in or with such code. - - 1.13. “You” (or “Your”) means an individual or a legal entity exercising rights under, and complying with all of - the terms of, this License. For legal entities, “You” includes any entity which controls, is controlled by, or is - under common control with You. For purposes of this definition, “control” means (a) the power, direct or indirect, - to cause the direction or management of such entity, whether by contract or otherwise, or (b) ownership of more - than fifty percent (50%) of the outstanding shares or beneficial ownership of such entity. - -2. License Grants. - - 2.1. The Initial Developer Grant. - Conditioned upon Your compliance with Section 3.1 below and subject to third party intellectual property claims, - the Initial Developer hereby grants You a world-wide, royalty-free, non-exclusive license: - - (a) under intellectual property rights (other than patent or trademark) Licensable by Initial Developer, - to use, reproduce, modify, display, perform, sublicense and distribute the Original Software (or portions - thereof), with or without Modifications, and/or as part of a Larger Work; and - - (b) under Patent Claims infringed by the making, using or selling of Original Software, to make, have made, - use, practice, sell, and offer for sale, and/or otherwise dispose of the Original Software (or portions thereof). - - (c) The licenses granted in Sections 2.1(a) and (b) are effective on the date Initial Developer first - distributes or otherwise makes the Original Software available to a third party under the terms of this License. - - (d) Notwithstanding Section 2.1(b) above, no patent license is granted: (1) for code that You delete from - the Original Software, or (2) for infringements caused by: (i) the modification of the Original Software, - or (ii) the combination of the Original Software with other software or devices. - - 2.2. Contributor Grant. - Conditioned upon Your compliance with Section 3.1 below and subject to third party intellectual property claims, - each Contributor hereby grants You a world-wide, royalty-free, non-exclusive license: - - (a) under intellectual property rights (other than patent or trademark) Licensable by Contributor to use, - reproduce, modify, display, perform, sublicense and distribute the Modifications created by such Contributor - (or portions thereof), either on an unmodified basis, with other Modifications, as Covered Software and/or - as part of a Larger Work; and - - (b) under Patent Claims infringed by the making, using, or selling of Modifications made by that Contributor - either alone and/or in combination with its Contributor Version (or portions of such combination), to make, - use, sell, offer for sale, have made, and/or otherwise dispose of: (1) Modifications made by that Contributor - (or portions thereof); and (2) the combination of Modifications made by that Contributor with its Contributor - Version (or portions of such combination). - - (c) The licenses granted in Sections 2.2(a) and 2.2(b) are effective on the date Contributor first distributes - or otherwise makes the Modifications available to a third party. - - (d) Notwithstanding Section 2.2(b) above, no patent license is granted: (1) for any code that Contributor has - deleted from the Contributor Version; (2) for infringements caused by: (i) third party modifications of - Contributor Version, or (ii) the combination of Modifications made by that Contributor with other software - (except as part of the Contributor Version) or other devices; or (3) under Patent Claims infringed by Covered - Software in the absence of Modifications made by that Contributor. - -3. Distribution Obligations. - - 3.1. Availability of Source Code. - Any Covered Software that You distribute or otherwise make available in Executable form must also be made available - in Source Code form and that Source Code form must be distributed only under the terms of this License. You must - include a copy of this License with every copy of the Source Code form of the Covered Software You distribute or - otherwise make available. You must inform recipients of any such Covered Software in Executable form as to how they - can obtain such Covered Software in Source Code form in a reasonable manner on or through a medium customarily used - for software exchange. - - 3.2. Modifications. - The Modifications that You create or to which You contribute are governed by the terms of this License. You - represent that You believe Your Modifications are Your original creation(s) and/or You have sufficient rights to - grant the rights conveyed by this License. - - 3.3. Required Notices. - You must include a notice in each of Your Modifications that identifies You as the Contributor of the Modification. - You may not remove or alter any copyright, patent or trademark notices contained within the Covered Software, or - any notices of licensing or any descriptive text giving attribution to any Contributor or the Initial Developer. - - 3.4. Application of Additional Terms. - You may not offer or impose any terms on any Covered Software in Source Code form that alters or restricts the - applicable version of this License or the recipients’ rights hereunder. You may choose to offer, and to charge a - fee for, warranty, support, indemnity or liability obligations to one or more recipients of Covered Software. - However, you may do so only on Your own behalf, and not on behalf of the Initial Developer or any Contributor. - You must make it absolutely clear that any such warranty, support, indemnity or liability obligation is offered - by You alone, and You hereby agree to indemnify the Initial Developer and every Contributor for any liability - incurred by the Initial Developer or such Contributor as a result of warranty, support, indemnity or liability - terms You offer. - - 3.5. Distribution of Executable Versions. - You may distribute the Executable form of the Covered Software under the terms of this License or under the terms - of a license of Your choice, which may contain terms different from this License, provided that You are in compliance - with the terms of this License and that the license for the Executable form does not attempt to limit or alter - the recipient’s rights in the Source Code form from the rights set forth in this License. If You distribute the - Covered Software in Executable form under a different license, You must make it absolutely clear that any terms - which differ from this License are offered by You alone, not by the Initial Developer or Contributor. You hereby - agree to indemnify the Initial Developer and every Contributor for any liability incurred by the Initial Developer - or such Contributor as a result of any such terms You offer. - - 3.6. Larger Works. - You may create a Larger Work by combining Covered Software with other code not governed by the terms of this License - and distribute the Larger Work as a single product. In such a case, You must make sure the requirements of this - License are fulfilled for the Covered Software. - -4. Versions of the License. - - 4.1. New Versions. - Sun Microsystems, Inc. is the initial license steward and may publish revised and/or new versions of this License - from time to time. Each version will be given a distinguishing version number. Except as provided in Section 4.3, - no one other than the license steward has the right to modify this License. - - 4.2. Effect of New Versions. - You may always continue to use, distribute or otherwise make the Covered Software available under the terms of - the version of the License under which You originally received the Covered Software. If the Initial Developer - includes a notice in the Original Software prohibiting it from being distributed or otherwise made available under - any subsequent version of the License, You must distribute and make the Covered Software available under the terms - of the version of the License under which You originally received the Covered Software. Otherwise, You may also - choose to use, distribute or otherwise make the Covered Software available under the terms of any subsequent version - of the License published by the license steward. - - 4.3. Modified Versions. - When You are an Initial Developer and You want to create a new license for Your Original Software, You may create - and use a modified version of this License if You: (a) rename the license and remove any references to the name of - the license steward (except to note that the license differs from this License); and (b) otherwise make it clear that - the license contains terms which differ from this License. - -5. DISCLAIMER OF WARRANTY. - -COVERED SOFTWARE IS PROVIDED UNDER THIS LICENSE ON AN “AS IS” BASIS, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR -IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES THAT THE COVERED SOFTWARE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A -PARTICULAR PURPOSE OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED SOFTWARE IS WITH YOU. -SHOULD ANY COVERED SOFTWARE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE -COST OF ANY NECESSARY SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS LICENSE. -NO USE OF ANY COVERED SOFTWARE IS AUTHORIZED HEREUNDER EXCEPT UNDER THIS DISCLAIMER. - -6. TERMINATION. - - 6.1. This License and the rights granted hereunder will terminate automatically if You fail to comply with terms - herein and fail to cure such breach within 30 days of becoming aware of the breach. Provisions which, by their - nature, must remain in effect beyond the termination of this License shall survive. - - 6.2. If You assert a patent infringement claim (excluding declaratory judgment actions) against Initial Developer - or a Contributor (the Initial Developer or Contributor against whom You assert such claim is referred to as - “Participant”) alleging that the Participant Software (meaning the Contributor Version where the Participant - is a Contributor or the Original Software where the Participant is the Initial Developer) directly or - indirectly infringes any patent, then any and all rights granted directly or indirectly to You by such Participant, - the Initial Developer (if the Initial Developer is not the Participant) and all Contributors under Sections 2.1 - and/or 2.2 of this License shall, upon 60 days notice from Participant terminate prospectively and automatically - at the expiration of such 60 day notice period, unless if within such 60 day period You withdraw Your claim with - respect to the Participant Software against such Participant either unilaterally or pursuant to a written agreement - with Participant. - - 6.3. If You assert a patent infringement claim against Participant alleging that the Participant Software directly - or indirectly infringes any patent where such claim is resolved (such as by license or settlement) prior to the - initiation of patent infringement litigation, then the reasonable value of the licenses granted by such Participant - under Sections 2.1 or 2.2 shall be taken into account in determining the amount or value of any payment or license. - - 6.4. In the event of termination under Sections 6.1 or 6.2 above, all end user licenses that have been validly granted - by You or any distributor hereunder prior to termination (excluding licenses granted to You by any distributor) - shall survive termination. - -7. LIMITATION OF LIABILITY. - -UNDER NO CIRCUMSTANCES AND UNDER NO LEGAL THEORY, WHETHER TORT (INCLUDING NEGLIGENCE), CONTRACT, OR OTHERWISE, SHALL YOU, THE -INITIAL DEVELOPER, ANY OTHER CONTRIBUTOR, OR ANY DISTRIBUTOR OF COVERED SOFTWARE, OR ANY SUPPLIER OF ANY OF SUCH PARTIES, BE LIABLE TO -ANY PERSON FOR ANY INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES OF ANY CHARACTER INCLUDING, WITHOUT LIMITATION, DAMAGES FOR -LOSS OF GOODWILL, WORK STOPPAGE, COMPUTER FAILURE OR MALFUNCTION, OR ANY AND ALL OTHER COMMERCIAL DAMAGES OR LOSSES, EVEN IF SUCH PARTY -SHALL HAVE BEEN INFORMED OF THE POSSIBILITY OF SUCH DAMAGES. THIS LIMITATION OF LIABILITY SHALL NOT APPLY TO LIABILITY FOR DEATH OR PERSONAL -INJURY RESULTING FROM SUCH PARTY’S NEGLIGENCE TO THE EXTENT APPLICABLE LAW PROHIBITS SUCH LIMITATION. SOME JURISDICTIONS DO NOT ALLOW THE -EXCLUSION OR LIMITATION OF INCIDENTAL OR CONSEQUENTIAL DAMAGES, SO THIS EXCLUSION AND LIMITATION MAY NOT APPLY TO YOU. - -8. U.S. GOVERNMENT END USERS. - -The Covered Software is a “commercial item,” as that term is defined in 48 C.F.R. 2.101 (Oct. 1995), consisting of -“commercial computer software” (as that term is defined at 48 C.F.R. § 252.227-7014(a)(1)) and “commercial computer software documentation” -as such terms are used in 48 C.F.R. 12.212 Sept. 1995). Consistent with 48 C.F.R. 12.212 and 48 C.F.R. 227.7202-1 through 227.7202-4 (June 1995), -all U.S. Government End Users acquire Covered Software with only those rights set forth herein. This U.S. Government Rights clause is in lieu of, -and supersedes, any other FAR, DFAR, or other clause or provision that addresses Government rights in computer software under this License. - -9. MISCELLANEOUS. - -This License represents the complete agreement concerning subject matter hereof. If any provision of this License is held to be -unenforceable, such provision shall be reformed only to the extent necessary to make it enforceable. This License shall be governed -by the law of the jurisdiction specified in a notice contained within the Original Software (except to the extent applicable law, if any, -provides otherwise), excluding such jurisdiction’s conflict-of-law provisions. Any litigation relating to this License shall be subject -to the jurisdiction of the courts located in the jurisdiction and venue specified in a notice contained within the Original Software, with the -losing party responsible for costs, including, without limitation, court costs and reasonable attorneys’ fees and expenses. The application of -the United Nations Convention on Contracts for the International Sale of Goods is expressly excluded. Any law or regulation which provides that -the language of a contract shall be construed against the drafter shall not apply to this License. You agree that You alone are responsible for -compliance with the United States export administration regulations (and the export control laws and regulation of any other countries) when You use, -distribute or otherwise make available any Covered Software. - -10. RESPONSIBILITY FOR CLAIMS. - -As between Initial Developer and the Contributors, each party is responsible for claims and damages arising, directly or indirectly, out of -its utilization of rights under this License and You agree to work with Initial Developer and Contributors to distribute such responsibility on -an equitable basis. Nothing herein is intended or shall be deemed to constitute any admission of liability. - --------- - -NOTICE PURSUANT TO SECTION 9 OF THE COMMON DEVELOPMENT AND DISTRIBUTION -LICENSE (CDDL) - -The OpenSolaris code released under the CDDL shall be governed by the laws -of the State of California (excluding conflict-of-law provisions). Any -litigation relating to this License shall be subject to the jurisdiction of -the Federal Courts of the Northern District of California and the state -courts of the State of California, with venue lying in Santa Clara County, -California. diff --git a/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/sigma/vmw-guestinfo/LGPL.txt b/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/sigma/vmw-guestinfo/LGPL.txt deleted file mode 100644 index 09f465ab..00000000 --- a/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/sigma/vmw-guestinfo/LGPL.txt +++ /dev/null @@ -1,502 +0,0 @@ - GNU LESSER GENERAL PUBLIC LICENSE - Version 2.1, February 1999 - - Copyright (C) 1991, 1999 Free Software Foundation, Inc. - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - -[This is the first released version of the Lesser GPL. It also counts - as the successor of the GNU Library Public License, version 2, hence - the version number 2.1.] - - Preamble - - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -Licenses are intended to guarantee your freedom to share and change -free software--to make sure the software is free for all its users. - - This license, the Lesser General Public License, applies to some -specially designated software packages--typically libraries--of the -Free Software Foundation and other authors who decide to use it. You -can use it too, but we suggest you first think carefully about whether -this license or the ordinary General Public License is the better -strategy to use in any particular case, based on the explanations below. - - When we speak of free software, we are referring to freedom of use, -not price. Our General Public Licenses are designed to make sure that -you have the freedom to distribute copies of free software (and charge -for this service if you wish); that you receive source code or can get -it if you want it; that you can change the software and use pieces of -it in new free programs; and that you are informed that you can do -these things. - - To protect your rights, we need to make restrictions that forbid -distributors to deny you these rights or to ask you to surrender these -rights. These restrictions translate to certain responsibilities for -you if you distribute copies of the library or if you modify it. - - For example, if you distribute copies of the library, whether gratis -or for a fee, you must give the recipients all the rights that we gave -you. You must make sure that they, too, receive or can get the source -code. If you link other code with the library, you must provide -complete object files to the recipients, so that they can relink them -with the library after making changes to the library and recompiling -it. And you must show them these terms so they know their rights. - - We protect your rights with a two-step method: (1) we copyright the -library, and (2) we offer you this license, which gives you legal -permission to copy, distribute and/or modify the library. - - To protect each distributor, we want to make it very clear that -there is no warranty for the free library. Also, if the library is -modified by someone else and passed on, the recipients should know -that what they have is not the original version, so that the original -author's reputation will not be affected by problems that might be -introduced by others. - - Finally, software patents pose a constant threat to the existence of -any free program. We wish to make sure that a company cannot -effectively restrict the users of a free program by obtaining a -restrictive license from a patent holder. Therefore, we insist that -any patent license obtained for a version of the library must be -consistent with the full freedom of use specified in this license. - - Most GNU software, including some libraries, is covered by the -ordinary GNU General Public License. This license, the GNU Lesser -General Public License, applies to certain designated libraries, and -is quite different from the ordinary General Public License. We use -this license for certain libraries in order to permit linking those -libraries into non-free programs. - - When a program is linked with a library, whether statically or using -a shared library, the combination of the two is legally speaking a -combined work, a derivative of the original library. The ordinary -General Public License therefore permits such linking only if the -entire combination fits its criteria of freedom. The Lesser General -Public License permits more lax criteria for linking other code with -the library. - - We call this license the "Lesser" General Public License because it -does Less to protect the user's freedom than the ordinary General -Public License. It also provides other free software developers Less -of an advantage over competing non-free programs. These disadvantages -are the reason we use the ordinary General Public License for many -libraries. However, the Lesser license provides advantages in certain -special circumstances. - - For example, on rare occasions, there may be a special need to -encourage the widest possible use of a certain library, so that it becomes -a de-facto standard. To achieve this, non-free programs must be -allowed to use the library. A more frequent case is that a free -library does the same job as widely used non-free libraries. In this -case, there is little to gain by limiting the free library to free -software only, so we use the Lesser General Public License. - - In other cases, permission to use a particular library in non-free -programs enables a greater number of people to use a large body of -free software. For example, permission to use the GNU C Library in -non-free programs enables many more people to use the whole GNU -operating system, as well as its variant, the GNU/Linux operating -system. - - Although the Lesser General Public License is Less protective of the -users' freedom, it does ensure that the user of a program that is -linked with the Library has the freedom and the wherewithal to run -that program using a modified version of the Library. - - The precise terms and conditions for copying, distribution and -modification follow. Pay close attention to the difference between a -"work based on the library" and a "work that uses the library". The -former contains code derived from the library, whereas the latter must -be combined with the library in order to run. - - GNU LESSER GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License Agreement applies to any software library or other -program which contains a notice placed by the copyright holder or -other authorized party saying it may be distributed under the terms of -this Lesser General Public License (also called "this License"). -Each licensee is addressed as "you". - - A "library" means a collection of software functions and/or data -prepared so as to be conveniently linked with application programs -(which use some of those functions and data) to form executables. - - The "Library", below, refers to any such software library or work -which has been distributed under these terms. A "work based on the -Library" means either the Library or any derivative work under -copyright law: that is to say, a work containing the Library or a -portion of it, either verbatim or with modifications and/or translated -straightforwardly into another language. (Hereinafter, translation is -included without limitation in the term "modification".) - - "Source code" for a work means the preferred form of the work for -making modifications to it. For a library, complete source code means -all the source code for all modules it contains, plus any associated -interface definition files, plus the scripts used to control compilation -and installation of the library. - - Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running a program using the Library is not restricted, and output from -such a program is covered only if its contents constitute a work based -on the Library (independent of the use of the Library in a tool for -writing it). Whether that is true depends on what the Library does -and what the program that uses the Library does. - - 1. You may copy and distribute verbatim copies of the Library's -complete source code as you receive it, in any medium, provided that -you conspicuously and appropriately publish on each copy an -appropriate copyright notice and disclaimer of warranty; keep intact -all the notices that refer to this License and to the absence of any -warranty; and distribute a copy of this License along with the -Library. - - You may charge a fee for the physical act of transferring a copy, -and you may at your option offer warranty protection in exchange for a -fee. - - 2. You may modify your copy or copies of the Library or any portion -of it, thus forming a work based on the Library, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: - - a) The modified work must itself be a software library. - - b) You must cause the files modified to carry prominent notices - stating that you changed the files and the date of any change. - - c) You must cause the whole of the work to be licensed at no - charge to all third parties under the terms of this License. - - d) If a facility in the modified Library refers to a function or a - table of data to be supplied by an application program that uses - the facility, other than as an argument passed when the facility - is invoked, then you must make a good faith effort to ensure that, - in the event an application does not supply such function or - table, the facility still operates, and performs whatever part of - its purpose remains meaningful. - - (For example, a function in a library to compute square roots has - a purpose that is entirely well-defined independent of the - application. Therefore, Subsection 2d requires that any - application-supplied function or table used by this function must - be optional: if the application does not supply it, the square - root function must still compute square roots.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Library, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Library, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote -it. - -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Library. - -In addition, mere aggregation of another work not based on the Library -with the Library (or with a work based on the Library) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - - 3. You may opt to apply the terms of the ordinary GNU General Public -License instead of this License to a given copy of the Library. To do -this, you must alter all the notices that refer to this License, so -that they refer to the ordinary GNU General Public License, version 2, -instead of to this License. (If a newer version than version 2 of the -ordinary GNU General Public License has appeared, then you can specify -that version instead if you wish.) Do not make any other change in -these notices. - - Once this change is made in a given copy, it is irreversible for -that copy, so the ordinary GNU General Public License applies to all -subsequent copies and derivative works made from that copy. - - This option is useful when you wish to copy part of the code of -the Library into a program that is not a library. - - 4. You may copy and distribute the Library (or a portion or -derivative of it, under Section 2) in object code or executable form -under the terms of Sections 1 and 2 above provided that you accompany -it with the complete corresponding machine-readable source code, which -must be distributed under the terms of Sections 1 and 2 above on a -medium customarily used for software interchange. - - If distribution of object code is made by offering access to copy -from a designated place, then offering equivalent access to copy the -source code from the same place satisfies the requirement to -distribute the source code, even though third parties are not -compelled to copy the source along with the object code. - - 5. A program that contains no derivative of any portion of the -Library, but is designed to work with the Library by being compiled or -linked with it, is called a "work that uses the Library". Such a -work, in isolation, is not a derivative work of the Library, and -therefore falls outside the scope of this License. - - However, linking a "work that uses the Library" with the Library -creates an executable that is a derivative of the Library (because it -contains portions of the Library), rather than a "work that uses the -library". The executable is therefore covered by this License. -Section 6 states terms for distribution of such executables. - - When a "work that uses the Library" uses material from a header file -that is part of the Library, the object code for the work may be a -derivative work of the Library even though the source code is not. -Whether this is true is especially significant if the work can be -linked without the Library, or if the work is itself a library. The -threshold for this to be true is not precisely defined by law. - - If such an object file uses only numerical parameters, data -structure layouts and accessors, and small macros and small inline -functions (ten lines or less in length), then the use of the object -file is unrestricted, regardless of whether it is legally a derivative -work. (Executables containing this object code plus portions of the -Library will still fall under Section 6.) - - Otherwise, if the work is a derivative of the Library, you may -distribute the object code for the work under the terms of Section 6. -Any executables containing that work also fall under Section 6, -whether or not they are linked directly with the Library itself. - - 6. As an exception to the Sections above, you may also combine or -link a "work that uses the Library" with the Library to produce a -work containing portions of the Library, and distribute that work -under terms of your choice, provided that the terms permit -modification of the work for the customer's own use and reverse -engineering for debugging such modifications. - - You must give prominent notice with each copy of the work that the -Library is used in it and that the Library and its use are covered by -this License. You must supply a copy of this License. If the work -during execution displays copyright notices, you must include the -copyright notice for the Library among them, as well as a reference -directing the user to the copy of this License. Also, you must do one -of these things: - - a) Accompany the work with the complete corresponding - machine-readable source code for the Library including whatever - changes were used in the work (which must be distributed under - Sections 1 and 2 above); and, if the work is an executable linked - with the Library, with the complete machine-readable "work that - uses the Library", as object code and/or source code, so that the - user can modify the Library and then relink to produce a modified - executable containing the modified Library. (It is understood - that the user who changes the contents of definitions files in the - Library will not necessarily be able to recompile the application - to use the modified definitions.) - - b) Use a suitable shared library mechanism for linking with the - Library. A suitable mechanism is one that (1) uses at run time a - copy of the library already present on the user's computer system, - rather than copying library functions into the executable, and (2) - will operate properly with a modified version of the library, if - the user installs one, as long as the modified version is - interface-compatible with the version that the work was made with. - - c) Accompany the work with a written offer, valid for at - least three years, to give the same user the materials - specified in Subsection 6a, above, for a charge no more - than the cost of performing this distribution. - - d) If distribution of the work is made by offering access to copy - from a designated place, offer equivalent access to copy the above - specified materials from the same place. - - e) Verify that the user has already received a copy of these - materials or that you have already sent this user a copy. - - For an executable, the required form of the "work that uses the -Library" must include any data and utility programs needed for -reproducing the executable from it. However, as a special exception, -the materials to be distributed need not include anything that is -normally distributed (in either source or binary form) with the major -components (compiler, kernel, and so on) of the operating system on -which the executable runs, unless that component itself accompanies -the executable. - - It may happen that this requirement contradicts the license -restrictions of other proprietary libraries that do not normally -accompany the operating system. Such a contradiction means you cannot -use both them and the Library together in an executable that you -distribute. - - 7. You may place library facilities that are a work based on the -Library side-by-side in a single library together with other library -facilities not covered by this License, and distribute such a combined -library, provided that the separate distribution of the work based on -the Library and of the other library facilities is otherwise -permitted, and provided that you do these two things: - - a) Accompany the combined library with a copy of the same work - based on the Library, uncombined with any other library - facilities. This must be distributed under the terms of the - Sections above. - - b) Give prominent notice with the combined library of the fact - that part of it is a work based on the Library, and explaining - where to find the accompanying uncombined form of the same work. - - 8. You may not copy, modify, sublicense, link with, or distribute -the Library except as expressly provided under this License. Any -attempt otherwise to copy, modify, sublicense, link with, or -distribute the Library is void, and will automatically terminate your -rights under this License. However, parties who have received copies, -or rights, from you under this License will not have their licenses -terminated so long as such parties remain in full compliance. - - 9. You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Library or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Library (or any work based on the -Library), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Library or works based on it. - - 10. Each time you redistribute the Library (or any work based on the -Library), the recipient automatically receives a license from the -original licensor to copy, distribute, link with or modify the Library -subject to these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties with -this License. - - 11. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Library at all. For example, if a patent -license would not permit royalty-free redistribution of the Library by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Library. - -If any portion of this section is held invalid or unenforceable under any -particular circumstance, the balance of the section is intended to apply, -and the section as a whole is intended to apply in other circumstances. - -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. - -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - - 12. If the distribution and/or use of the Library is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Library under this License may add -an explicit geographical distribution limitation excluding those countries, -so that distribution is permitted only in or among countries not thus -excluded. In such case, this License incorporates the limitation as if -written in the body of this License. - - 13. The Free Software Foundation may publish revised and/or new -versions of the Lesser General Public License from time to time. -Such new versions will be similar in spirit to the present version, -but may differ in detail to address new problems or concerns. - -Each version is given a distinguishing version number. If the Library -specifies a version number of this License which applies to it and -"any later version", you have the option of following the terms and -conditions either of that version or of any later version published by -the Free Software Foundation. If the Library does not specify a -license version number, you may choose any version ever published by -the Free Software Foundation. - - 14. If you wish to incorporate parts of the Library into other free -programs whose distribution conditions are incompatible with these, -write to the author to ask for permission. For software which is -copyrighted by the Free Software Foundation, write to the Free -Software Foundation; we sometimes make exceptions for this. Our -decision will be guided by the two goals of preserving the free status -of all derivatives of our free software and of promoting the sharing -and reuse of software generally. - - NO WARRANTY - - 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO -WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. -EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR -OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY -KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE -LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME -THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. - - 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN -WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY -AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU -FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR -CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE -LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING -RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A -FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF -SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH -DAMAGES. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Libraries - - If you develop a new library, and you want it to be of the greatest -possible use to the public, we recommend making it free software that -everyone can redistribute and change. You can do so by permitting -redistribution under these terms (or, alternatively, under the terms of the -ordinary General Public License). - - To apply these terms, attach the following notices to the library. It is -safest to attach them to the start of each source file to most effectively -convey the exclusion of warranty; and each file should have at least the -"copyright" line and a pointer to where the full notice is found. - - <one line to give the library's name and a brief idea of what it does.> - Copyright (C) <year> <name of author> - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - -Also add information on how to contact you by electronic and paper mail. - -You should also get your employer (if you work as a programmer) or your -school, if any, to sign a "copyright disclaimer" for the library, if -necessary. Here is a sample; alter the names: - - Yoyodyne, Inc., hereby disclaims all copyright interest in the - library `Frob' (a library for tweaking knobs) written by James Random Hacker. - - <signature of Ty Coon>, 1 April 1990 - Ty Coon, President of Vice - -That's all there is to it! diff --git a/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/sigma/vmw-guestinfo/LICENSE b/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/sigma/vmw-guestinfo/LICENSE deleted file mode 100644 index 9fc536b2..00000000 --- a/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/sigma/vmw-guestinfo/LICENSE +++ /dev/null @@ -1,3 +0,0 @@ -The package vmw-guestinfo is dual-licensed under the terms of: -- LGPL 2.1 and no later version (see LGPL.txt) -- CDDL 1.0 and no later version (see CDDL.txt) diff --git a/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/sigma/vmw-guestinfo/README b/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/sigma/vmw-guestinfo/README deleted file mode 100644 index 3d8f5535..00000000 --- a/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/sigma/vmw-guestinfo/README +++ /dev/null @@ -1,3 +0,0 @@ -This package provides access to the guestinfo variables exposed to a VMware virtual machine. - -see examples/main.go for an example diff --git a/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/sigma/vmw-guestinfo/bridge/backdoor.c b/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/sigma/vmw-guestinfo/bridge/backdoor.c deleted file mode 100644 index 2e10fdef..00000000 --- a/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/sigma/vmw-guestinfo/bridge/backdoor.c +++ /dev/null @@ -1,272 +0,0 @@ -/********************************************************* - * Copyright (C) 1999-2015 VMware, Inc. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation version 2.1 and no later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the Lesser GNU General Public - * License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - *********************************************************/ - -/********************************************************* - * The contents of this file are subject to the terms of the Common - * Development and Distribution License (the "License") version 1.0 - * and no later version. You may not use this file except in - * compliance with the License. - * - * You can obtain a copy of the License at - * http://www.opensource.org/licenses/cddl1.php - * - * See the License for the specific language governing permissions - * and limitations under the License. - * - *********************************************************/ - -/* - * backdoor.c -- - * - * First layer of the internal communication channel between guest - * applications and vmware - * - * This is the backdoor. By using special ports of the virtual I/O space, - * and the virtual CPU registers, a guest application can send a - * synchroneous basic request to vmware, and vmware can reply to it. - */ - -#ifdef __cplusplus -extern "C" { -#endif - -#include "backdoor_def.h" -#include "backdoor.h" -#include "backdoorInt.h" - -#if defined(BACKDOOR_DEBUG) && defined(USERLEVEL) -#if defined(__KERNEL__) || defined(_KERNEL) -#else -# include "debug.h" -#endif -# include <stdio.h> -# define BACKDOOR_LOG(args) Debug args -# define BACKDOOR_LOG_PROTO_STRUCT(x) BackdoorPrintProtoStruct((x)) -# define BACKDOOR_LOG_HB_PROTO_STRUCT(x) BackdoorPrintHbProtoStruct((x)) - - -/* - *---------------------------------------------------------------------------- - * - * BackdoorPrintProtoStruct -- - * BackdoorPrintHbProtoStruct -- - * - * Print the contents of the specified backdoor protocol structure via - * printf. - * - * Results: - * None. - * - * Side effects: - * Output to stdout. - * - *---------------------------------------------------------------------------- - */ - -void -BackdoorPrintProtoStruct(Backdoor_proto *myBp) -{ - Debug("magic 0x%08x, command %d, size %"FMTSZ"u, port %d\n", - myBp->in.ax.word, myBp->in.cx.halfs.low, - myBp->in.size, myBp->in.dx.halfs.low); - -#ifndef VM_X86_64 - Debug("ax %#x, " - "bx %#x, " - "cx %#x, " - "dx %#x, " - "si %#x, " - "di %#x\n", - myBp->out.ax.word, - myBp->out.bx.word, - myBp->out.cx.word, - myBp->out.dx.word, - myBp->out.si.word, - myBp->out.di.word); -#else - Debug("ax %#"FMT64"x, " - "bx %#"FMT64"x, " - "cx %#"FMT64"x, " - "dx %#"FMT64"x, " - "si %#"FMT64"x, " - "di %#"FMT64"x\n", - myBp->out.ax.quad, - myBp->out.bx.quad, - myBp->out.cx.quad, - myBp->out.dx.quad, - myBp->out.si.quad, - myBp->out.di.quad); -#endif -} - - -void -BackdoorPrintHbProtoStruct(Backdoor_proto_hb *myBp) -{ - Debug("magic 0x%08x, command %d, size %"FMTSZ"u, port %d, " - "srcAddr %"FMTSZ"u, dstAddr %"FMTSZ"u\n", - myBp->in.ax.word, myBp->in.bx.halfs.low, myBp->in.size, - myBp->in.dx.halfs.low, myBp->in.srcAddr, myBp->in.dstAddr); - -#ifndef VM_X86_64 - Debug("ax %#x, " - "bx %#x, " - "cx %#x, " - "dx %#x, " - "si %#x, " - "di %#x, " - "bp %#x\n", - myBp->out.ax.word, - myBp->out.bx.word, - myBp->out.cx.word, - myBp->out.dx.word, - myBp->out.si.word, - myBp->out.di.word, - myBp->out.bp.word); -#else - Debug("ax %#"FMT64"x, " - "bx %#"FMT64"x, " - "cx %#"FMT64"x, " - "dx %#"FMT64"x, " - "si %#"FMT64"x, " - "di %#"FMT64"x, " - "bp %#"FMT64"x\n", - myBp->out.ax.quad, - myBp->out.bx.quad, - myBp->out.cx.quad, - myBp->out.dx.quad, - myBp->out.si.quad, - myBp->out.di.quad, - myBp->out.bp.quad); -#endif -} - -#else -# define BACKDOOR_LOG(args) -# define BACKDOOR_LOG_PROTO_STRUCT(x) -# define BACKDOOR_LOG_HB_PROTO_STRUCT(x) -#endif - - -/* - *----------------------------------------------------------------------------- - * - * Backdoor -- - * - * Send a low-bandwidth basic request (16 bytes) to vmware, and return its - * reply (24 bytes). - * - * Result: - * None - * - * Side-effects: - * None - * - *----------------------------------------------------------------------------- - */ - -void -Backdoor(Backdoor_proto *myBp) // IN/OUT -{ - ASSERT(myBp); - - myBp->in.ax.word = BDOOR_MAGIC; - myBp->in.dx.halfs.low = BDOOR_PORT; - - BACKDOOR_LOG(("Backdoor: before ")); - BACKDOOR_LOG_PROTO_STRUCT(myBp); - - Backdoor_InOut(myBp); - - BACKDOOR_LOG(("Backdoor: after ")); - BACKDOOR_LOG_PROTO_STRUCT(myBp); -} - - -/* - *----------------------------------------------------------------------------- - * - * Backdoor_HbOut -- - * - * Send a high-bandwidth basic request to vmware, and return its - * reply. - * - * Result: - * The host-side response is returned via the IN/OUT parameter. - * - * Side-effects: - * Pokes the high-bandwidth backdoor. - * - *----------------------------------------------------------------------------- - */ - -void -Backdoor_HbOut(Backdoor_proto_hb *myBp) // IN/OUT -{ - ASSERT(myBp); - - myBp->in.ax.word = BDOOR_MAGIC; - myBp->in.dx.halfs.low = BDOORHB_PORT; - - BACKDOOR_LOG(("Backdoor_HbOut: before ")); - BACKDOOR_LOG_HB_PROTO_STRUCT(myBp); - - BackdoorHbOut(myBp); - - BACKDOOR_LOG(("Backdoor_HbOut: after ")); - BACKDOOR_LOG_HB_PROTO_STRUCT(myBp); -} - - -/* - *----------------------------------------------------------------------------- - * - * Backdoor_HbIn -- - * - * Send a basic request to vmware, and return its high-bandwidth - * reply - * - * Result: - * Host-side response returned via the IN/OUT parameter. - * - * Side-effects: - * Pokes the high-bandwidth backdoor. - * - *----------------------------------------------------------------------------- - */ - -void -Backdoor_HbIn(Backdoor_proto_hb *myBp) // IN/OUT -{ - ASSERT(myBp); - - myBp->in.ax.word = BDOOR_MAGIC; - myBp->in.dx.halfs.low = BDOORHB_PORT; - - BACKDOOR_LOG(("Backdoor_HbIn: before ")); - BACKDOOR_LOG_HB_PROTO_STRUCT(myBp); - - BackdoorHbIn(myBp); - - BACKDOOR_LOG(("Backdoor_HbIn: after ")); - BACKDOOR_LOG_HB_PROTO_STRUCT(myBp); -} - -#ifdef __cplusplus -} -#endif diff --git a/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/sigma/vmw-guestinfo/bridge/backdoor_386.c b/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/sigma/vmw-guestinfo/bridge/backdoor_386.c deleted file mode 100644 index d402cb00..00000000 --- a/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/sigma/vmw-guestinfo/bridge/backdoor_386.c +++ /dev/null @@ -1,235 +0,0 @@ -/********************************************************* - * Copyright (C) 2005-2015 VMware, Inc. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation version 2.1 and no later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the Lesser GNU General Public - * License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - *********************************************************/ - -/********************************************************* - * The contents of this file are subject to the terms of the Common - * Development and Distribution License (the "License") version 1.0 - * and no later version. You may not use this file except in - * compliance with the License. - * - * You can obtain a copy of the License at - * http://www.opensource.org/licenses/cddl1.php - * - * See the License for the specific language governing permissions - * and limitations under the License. - * - *********************************************************/ - -/* - * backdoorGcc32.c -- - * - * Implements the real work for guest-side backdoor for GCC, 32-bit - * target (supports inline ASM, GAS syntax). The asm sections are marked - * volatile since vmware can change the registers content without the - * compiler knowing it. - * - * XXX - * I tried to write this more cleanly, but: - * - There is no way to specify an "ebp" constraint - * - "ebp" is ignored when specified as cloberred register - * - gas barfs when there is more than 10 operands - * - gas 2.7.2.3, depending on the order of the operands, can - * mis-assemble without any warning - * --hpreg - * - * Note that the problems with gas noted above might longer be relevant - * now that we've upgraded most of our compiler versions. - * --rrdharan - */ - -#ifdef __cplusplus -extern "C" { -#endif - -#include "backdoor.h" -#include "backdoorInt.h" - -/* - *---------------------------------------------------------------------------- - * - * Backdoor_InOut -- - * - * Send a low-bandwidth basic request (16 bytes) to vmware, and return its - * reply (24 bytes). - * - * Results: - * Host-side response returned in bp IN/OUT parameter. - * - * Side effects: - * Pokes the backdoor. - * - *---------------------------------------------------------------------------- - */ - -void -Backdoor_InOut(Backdoor_proto *myBp) // IN/OUT -{ - uint32 dummy; - - __asm__ __volatile__( -#ifdef __PIC__ - "pushl %%ebx" "\n\t" -#endif - "pushl %%eax" "\n\t" - "movl 20(%%eax), %%edi" "\n\t" - "movl 16(%%eax), %%esi" "\n\t" - "movl 12(%%eax), %%edx" "\n\t" - "movl 8(%%eax), %%ecx" "\n\t" - "movl 4(%%eax), %%ebx" "\n\t" - "movl (%%eax), %%eax" "\n\t" - "inl %%dx, %%eax" "\n\t" - "xchgl %%eax, (%%esp)" "\n\t" - "movl %%edi, 20(%%eax)" "\n\t" - "movl %%esi, 16(%%eax)" "\n\t" - "movl %%edx, 12(%%eax)" "\n\t" - "movl %%ecx, 8(%%eax)" "\n\t" - "movl %%ebx, 4(%%eax)" "\n\t" - "popl (%%eax)" "\n\t" -#ifdef __PIC__ - "popl %%ebx" "\n\t" -#endif - : "=a" (dummy) - : "0" (myBp) - /* - * vmware can modify the whole VM state without the compiler knowing - * it. So far it does not modify EFLAGS. --hpreg - */ - : -#ifndef __PIC__ - "ebx", -#endif - "ecx", "edx", "esi", "edi", "memory" - ); -} - - -/* - *----------------------------------------------------------------------------- - * - * BackdoorHbIn -- - * BackdoorHbOut -- - * - * Send a high-bandwidth basic request to vmware, and return its - * reply. - * - * Results: - * Host-side response returned in bp IN/OUT parameter. - * - * Side-effects: - * Pokes the high-bandwidth backdoor port. - * - *----------------------------------------------------------------------------- - */ - -void -BackdoorHbIn(Backdoor_proto_hb *myBp) // IN/OUT -{ - uint32 dummy; - - __asm__ __volatile__( -#ifdef __PIC__ - "pushl %%ebx" "\n\t" -#endif - "pushl %%ebp" "\n\t" - - "pushl %%eax" "\n\t" - "movl 24(%%eax), %%ebp" "\n\t" - "movl 20(%%eax), %%edi" "\n\t" - "movl 16(%%eax), %%esi" "\n\t" - "movl 12(%%eax), %%edx" "\n\t" - "movl 8(%%eax), %%ecx" "\n\t" - "movl 4(%%eax), %%ebx" "\n\t" - "movl (%%eax), %%eax" "\n\t" - "cld" "\n\t" - "rep; insb" "\n\t" - "xchgl %%eax, (%%esp)" "\n\t" - "movl %%ebp, 24(%%eax)" "\n\t" - "movl %%edi, 20(%%eax)" "\n\t" - "movl %%esi, 16(%%eax)" "\n\t" - "movl %%edx, 12(%%eax)" "\n\t" - "movl %%ecx, 8(%%eax)" "\n\t" - "movl %%ebx, 4(%%eax)" "\n\t" - "popl (%%eax)" "\n\t" - - "popl %%ebp" "\n\t" -#ifdef __PIC__ - "popl %%ebx" "\n\t" -#endif - : "=a" (dummy) - : "0" (myBp) - /* - * vmware can modify the whole VM state without the compiler knowing - * it. --hpreg - */ - : -#ifndef __PIC__ - "ebx", -#endif - "ecx", "edx", "esi", "edi", "memory", "cc" - ); -} - - -void -BackdoorHbOut(Backdoor_proto_hb *myBp) // IN/OUT -{ - uint32 dummy; - - __asm__ __volatile__( -#ifdef __PIC__ - "pushl %%ebx" "\n\t" -#endif - "pushl %%ebp" "\n\t" - - "pushl %%eax" "\n\t" - "movl 24(%%eax), %%ebp" "\n\t" - "movl 20(%%eax), %%edi" "\n\t" - "movl 16(%%eax), %%esi" "\n\t" - "movl 12(%%eax), %%edx" "\n\t" - "movl 8(%%eax), %%ecx" "\n\t" - "movl 4(%%eax), %%ebx" "\n\t" - "movl (%%eax), %%eax" "\n\t" - "cld" "\n\t" - "rep; outsb" "\n\t" - "xchgl %%eax, (%%esp)" "\n\t" - "movl %%ebp, 24(%%eax)" "\n\t" - "movl %%edi, 20(%%eax)" "\n\t" - "movl %%esi, 16(%%eax)" "\n\t" - "movl %%edx, 12(%%eax)" "\n\t" - "movl %%ecx, 8(%%eax)" "\n\t" - "movl %%ebx, 4(%%eax)" "\n\t" - "popl (%%eax)" "\n\t" - - "popl %%ebp" "\n\t" -#ifdef __PIC__ - "popl %%ebx" "\n\t" -#endif - : "=a" (dummy) - : "0" (myBp) - : -#ifndef __PIC__ - "ebx", -#endif - "ecx", "edx", "esi", "edi", "memory", "cc" - ); -} - -#ifdef __cplusplus -} -#endif - diff --git a/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/sigma/vmw-guestinfo/bridge/backdoor_amd64.c b/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/sigma/vmw-guestinfo/bridge/backdoor_amd64.c deleted file mode 100644 index 551b7cd0..00000000 --- a/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/sigma/vmw-guestinfo/bridge/backdoor_amd64.c +++ /dev/null @@ -1,243 +0,0 @@ -/********************************************************* - * Copyright (C) 2005-2015 VMware, Inc. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation version 2.1 and no later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the Lesser GNU General Public - * License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - *********************************************************/ - -/********************************************************* - * The contents of this file are subject to the terms of the Common - * Development and Distribution License (the "License") version 1.0 - * and no later version. You may not use this file except in - * compliance with the License. - * - * You can obtain a copy of the License at - * http://www.opensource.org/licenses/cddl1.php - * - * See the License for the specific language governing permissions - * and limitations under the License. - * - *********************************************************/ - -/* - * backdoorGcc64.c -- - * - * Implements the real work for guest-side backdoor for GCC, 64-bit - * target (supports inline ASM, GAS syntax). The asm sections are marked - * volatile since vmware can change the registers content without the - * compiler knowing it. - * - * See backdoorGCC32.c (from which this code was mostly copied) for - * details on why the ASM is written this way. Also note that it might be - * possible to write the asm blocks using the symbolic operand specifiers - * in such a way that the same asm would generate correct code for both - * 32-bit and 64-bit targets, but I'm too lazy to figure it all out. - * --rrdharan - */ -#ifdef __cplusplus -extern "C" { -#endif - -#include "backdoor.h" -#include "backdoorInt.h" - - -/* - *---------------------------------------------------------------------------- - * - * Backdoor_InOut -- - * - * Send a low-bandwidth basic request (16 bytes) to vmware, and return its - * reply (24 bytes). - * - * Results: - * Host-side response returned in bp IN/OUT parameter. - * - * Side effects: - * Pokes the backdoor. - * - *---------------------------------------------------------------------------- - */ - -void -Backdoor_InOut(Backdoor_proto *myBp) // IN/OUT -{ - uint64 dummy; - - __asm__ __volatile__( -#ifdef __APPLE__ - /* - * Save %rbx on the stack because the Mac OS GCC doesn't want us to - * clobber it - it erroneously thinks %rbx is the PIC register. - * (Radar bug 7304232) - */ - "pushq %%rbx" "\n\t" -#endif - "pushq %%rax" "\n\t" - "movq 40(%%rax), %%rdi" "\n\t" - "movq 32(%%rax), %%rsi" "\n\t" - "movq 24(%%rax), %%rdx" "\n\t" - "movq 16(%%rax), %%rcx" "\n\t" - "movq 8(%%rax), %%rbx" "\n\t" - "movq (%%rax), %%rax" "\n\t" - "inl %%dx, %%eax" "\n\t" /* NB: There is no inq instruction */ - "xchgq %%rax, (%%rsp)" "\n\t" - "movq %%rdi, 40(%%rax)" "\n\t" - "movq %%rsi, 32(%%rax)" "\n\t" - "movq %%rdx, 24(%%rax)" "\n\t" - "movq %%rcx, 16(%%rax)" "\n\t" - "movq %%rbx, 8(%%rax)" "\n\t" - "popq (%%rax)" "\n\t" -#ifdef __APPLE__ - "popq %%rbx" "\n\t" -#endif - : "=a" (dummy) - : "0" (myBp) - /* - * vmware can modify the whole VM state without the compiler knowing - * it. So far it does not modify EFLAGS. --hpreg - */ - : -#ifndef __APPLE__ - /* %rbx is unchanged at the end of the function on Mac OS. */ - "rbx", -#endif - "rcx", "rdx", "rsi", "rdi", "memory" - ); -} - - -/* - *----------------------------------------------------------------------------- - * - * BackdoorHbIn -- - * BackdoorHbOut -- - * - * Send a high-bandwidth basic request to vmware, and return its - * reply. - * - * Results: - * Host-side response returned in bp IN/OUT parameter. - * - * Side-effects: - * Pokes the high-bandwidth backdoor port. - * - *----------------------------------------------------------------------------- - */ - -void -BackdoorHbIn(Backdoor_proto_hb *myBp) // IN/OUT -{ - uint64 dummy; - - __asm__ __volatile__( - "pushq %%rbp" "\n\t" -#ifdef __APPLE__ - /* - * Save %rbx on the stack because the Mac OS GCC doesn't want us to - * clobber it - it erroneously thinks %rbx is the PIC register. - * (Radar bug 7304232) - */ - "pushq %%rbx" "\n\t" -#endif - "pushq %%rax" "\n\t" - "movq 48(%%rax), %%rbp" "\n\t" - "movq 40(%%rax), %%rdi" "\n\t" - "movq 32(%%rax), %%rsi" "\n\t" - "movq 24(%%rax), %%rdx" "\n\t" - "movq 16(%%rax), %%rcx" "\n\t" - "movq 8(%%rax), %%rbx" "\n\t" - "movq (%%rax), %%rax" "\n\t" - "cld" "\n\t" - "rep; insb" "\n\t" - "xchgq %%rax, (%%rsp)" "\n\t" - "movq %%rbp, 48(%%rax)" "\n\t" - "movq %%rdi, 40(%%rax)" "\n\t" - "movq %%rsi, 32(%%rax)" "\n\t" - "movq %%rdx, 24(%%rax)" "\n\t" - "movq %%rcx, 16(%%rax)" "\n\t" - "movq %%rbx, 8(%%rax)" "\n\t" - "popq (%%rax)" "\n\t" -#ifdef __APPLE__ - "popq %%rbx" "\n\t" -#endif - "popq %%rbp" - : "=a" (dummy) - : "0" (myBp) - /* - * vmware can modify the whole VM state without the compiler knowing - * it. --hpreg - */ - : -#ifndef __APPLE__ - /* %rbx is unchanged at the end of the function on Mac OS. */ - "rbx", -#endif - "rcx", "rdx", "rsi", "rdi", "memory", "cc" - ); -} - - -void -BackdoorHbOut(Backdoor_proto_hb *myBp) // IN/OUT -{ - uint64 dummy; - - __asm__ __volatile__( - "pushq %%rbp" "\n\t" -#ifdef __APPLE__ - /* - * Save %rbx on the stack because the Mac OS GCC doesn't want us to - * clobber it - it erroneously thinks %rbx is the PIC register. - * (Radar bug 7304232) - */ - "pushq %%rbx" "\n\t" -#endif - "pushq %%rax" "\n\t" - "movq 48(%%rax), %%rbp" "\n\t" - "movq 40(%%rax), %%rdi" "\n\t" - "movq 32(%%rax), %%rsi" "\n\t" - "movq 24(%%rax), %%rdx" "\n\t" - "movq 16(%%rax), %%rcx" "\n\t" - "movq 8(%%rax), %%rbx" "\n\t" - "movq (%%rax), %%rax" "\n\t" - "cld" "\n\t" - "rep; outsb" "\n\t" - "xchgq %%rax, (%%rsp)" "\n\t" - "movq %%rbp, 48(%%rax)" "\n\t" - "movq %%rdi, 40(%%rax)" "\n\t" - "movq %%rsi, 32(%%rax)" "\n\t" - "movq %%rdx, 24(%%rax)" "\n\t" - "movq %%rcx, 16(%%rax)" "\n\t" - "movq %%rbx, 8(%%rax)" "\n\t" - "popq (%%rax)" "\n\t" -#ifdef __APPLE__ - "popq %%rbx" "\n\t" -#endif - "popq %%rbp" - : "=a" (dummy) - : "0" (myBp) - : -#ifndef __APPLE__ - /* %rbx is unchanged at the end of the function on Mac OS. */ - "rbx", -#endif - "rcx", "rdx", "rsi", "rdi", "memory", "cc" - ); -} - - -#ifdef __cplusplus -} -#endif diff --git a/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/sigma/vmw-guestinfo/bridge/bridge.go b/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/sigma/vmw-guestinfo/bridge/bridge.go deleted file mode 100644 index 981dad7d..00000000 --- a/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/sigma/vmw-guestinfo/bridge/bridge.go +++ /dev/null @@ -1,46 +0,0 @@ -package bridge - -/* -#cgo CFLAGS: -I../include -#include <stdlib.h> -#include "message.h" -void Warning(const char *fmt, ...) {} -void Debug(const char *fmt, ...) {} -void Panic(const char *fmt, ...) {} -void Log(const char *fmt, ...) {} -*/ -import "C" -import "unsafe" - -// MessageChannel provides a channel to pass information from/to the hypervisor -type MessageChannel *C.struct_Message_Channel - -// MessageOpen creates a new MessageChannel -func MessageOpen(proto uint32) MessageChannel { - return C.Message_Open(C.uint32(proto)) -} - -// MessageClose closes a MessageChannel -func MessageClose(c MessageChannel) bool { - status := C.Message_Close(c) - return status != 0 -} - -// MessageSend sends a request through a MessageChannel -func MessageSend(c MessageChannel, request []byte) bool { - buffer := (*C.uchar)(unsafe.Pointer(&request[0])) - status := C.Message_Send(c, buffer, (C.size_t)(C.int(len(request)))) - return status != 0 -} - -// MessageReceive receives a response through a MessageChannel -func MessageReceive(c MessageChannel) ([]byte, bool) { - var reply *C.uchar - var replyLen C.size_t - defer C.free(unsafe.Pointer(reply)) - - status := C.Message_Receive(c, &reply, &replyLen) - - res := C.GoBytes(unsafe.Pointer(reply), (C.int)(replyLen)) - return res, status != 0 -} diff --git a/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/sigma/vmw-guestinfo/bridge/message.c b/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/sigma/vmw-guestinfo/bridge/message.c deleted file mode 100644 index b73a1075..00000000 --- a/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/sigma/vmw-guestinfo/bridge/message.c +++ /dev/null @@ -1,604 +0,0 @@ -/********************************************************* - * Copyright (C) 1999-2015 VMware, Inc. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation version 2.1 and no later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the Lesser GNU General Public - * License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - *********************************************************/ - -/********************************************************* - * The contents of this file are subject to the terms of the Common - * Development and Distribution License (the "License") version 1.0 - * and no later version. You may not use this file except in - * compliance with the License. - * - * You can obtain a copy of the License at - * http://www.opensource.org/licenses/cddl1.php - * - * See the License for the specific language governing permissions - * and limitations under the License. - * - *********************************************************/ - -/* - * message.c -- - * - * Second layer of the internal communication channel between guest - * applications and vmware - * - * Build a generic messaging system between guest applications and vmware. - * - * The protocol is not completely symmetrical, because: - * . basic requests can only be sent by guest applications (when vmware - * wants to post a message to a guest application, the message will be - * really fetched only when the guest application will poll for new - * available messages) - * . several guest applications can talk to vmware, while the contrary is - * not true - * - * Operations that are not atomic (in terms of number of backdoor calls) - * can be aborted by vmware if a checkpoint/restore occurs in the middle of - * such an operation. This layer takes care of retrying those operations. - */ - -#ifdef __cplusplus -extern "C" { -#endif - -#if defined(__KERNEL__) || defined(_KERNEL) || defined(KERNEL) -# include "kernelStubs.h" -#else -# include <stdio.h> -# include <stdlib.h> -#endif - -#include "backdoor_def.h" -#include "guest_msg_def.h" -#include "backdoor.h" -#include "message.h" - - -#if defined(MESSAGE_DEBUG) -# define MESSAGE_LOG(...) Warning(__VA_ARGS__) -#else -# define MESSAGE_LOG(...) -#endif - -/* The channel object */ -struct Message_Channel { - /* Identifier */ - uint16 id; - - /* Reception buffer */ - /* Data */ - unsigned char *in; - /* Allocated size */ - size_t inAlloc; - - /* The cookie */ - uint32 cookieHigh; - uint32 cookieLow; -}; - - -/* - *----------------------------------------------------------------------------- - * - * Message_Open -- - * - * Open a communication channel - * - * Result: - * An allocated Message_Channel on success - * NULL on failure - * - * Side-effects: - * None - * - *----------------------------------------------------------------------------- - */ - -Message_Channel * -Message_Open(uint32 proto) // IN -{ - Message_Channel *chan; - uint32 flags; - Backdoor_proto bp; - - chan = (Message_Channel *)malloc(sizeof(*chan)); - if (chan == NULL) { - goto error_quit; - } - - flags = GUESTMSG_FLAG_COOKIE; -retry: - /* IN: Type */ - bp.in.cx.halfs.high = MESSAGE_TYPE_OPEN; - /* IN: Magic number of the protocol and flags */ - bp.in.size = proto | flags; - - bp.in.cx.halfs.low = BDOOR_CMD_MESSAGE; - Backdoor(&bp); - - /* OUT: Status */ - if ((bp.in.cx.halfs.high & MESSAGE_STATUS_SUCCESS) == 0) { - if (flags) { - /* Cookies not supported. Fall back to no cookie. --hpreg */ - flags = 0; - goto retry; - } - - MESSAGE_LOG("Message: Unable to open a communication channel\n"); - goto error_quit; - } - - /* OUT: Id and cookie */ - chan->id = bp.in.dx.halfs.high; - chan->cookieHigh = bp.out.si.word; - chan->cookieLow = bp.out.di.word; - - /* Initialize the channel */ - chan->in = NULL; - chan->inAlloc = 0; - - return chan; - -error_quit: - free(chan); - chan = NULL; - return NULL; -} - - -/* - *----------------------------------------------------------------------------- - * - * Message_Send -- - * - * Send a message over a communication channel - * - * Result: - * TRUE on success - * FALSE on failure (the message is discarded by vmware) - * - * Side-effects: - * None - * - *----------------------------------------------------------------------------- - */ - -Bool -Message_Send(Message_Channel *chan, // IN/OUT - const unsigned char *buf, // IN - size_t bufSize) // IN -{ - const unsigned char *myBuf; - size_t myBufSize; - Backdoor_proto bp; - -retry: - myBuf = buf; - myBufSize = bufSize; - - /* - * Send the size. - */ - - /* IN: Type */ - bp.in.cx.halfs.high = MESSAGE_TYPE_SENDSIZE; - /* IN: Id and cookie */ - bp.in.dx.halfs.high = chan->id; - bp.in.si.word = chan->cookieHigh; - bp.in.di.word = chan->cookieLow; - /* IN: Size */ - bp.in.size = myBufSize; - - bp.in.cx.halfs.low = BDOOR_CMD_MESSAGE; - Backdoor(&bp); - - /* OUT: Status */ - if ((bp.in.cx.halfs.high & MESSAGE_STATUS_SUCCESS) == 0) { - MESSAGE_LOG("Message: Unable to send a message over the communication " - "channel %u\n", chan->id); - return FALSE; - } - - if (bp.in.cx.halfs.high & MESSAGE_STATUS_HB) { - /* - * High-bandwidth backdoor port supported. Send the message in one - * backdoor operation. --hpreg - */ - - if (myBufSize) { - Backdoor_proto_hb bphb; - - bphb.in.bx.halfs.low = BDOORHB_CMD_MESSAGE; - bphb.in.bx.halfs.high = MESSAGE_STATUS_SUCCESS; - bphb.in.dx.halfs.high = chan->id; - bphb.in.bp.word = chan->cookieHigh; - bphb.in.dstAddr = chan->cookieLow; - bphb.in.size = myBufSize; - bphb.in.srcAddr = (uintptr_t) myBuf; - Backdoor_HbOut(&bphb); - if ((bphb.in.bx.halfs.high & MESSAGE_STATUS_SUCCESS) == 0) { - if ((bphb.in.bx.halfs.high & MESSAGE_STATUS_CPT) != 0) { - /* A checkpoint occurred. Retry the operation. --hpreg */ - goto retry; - } - - MESSAGE_LOG("Message: Unable to send a message over the " - "communication channel %u\n", chan->id); - return FALSE; - } - } - } else { - /* - * High-bandwidth backdoor port not supported. Send the message, 4 bytes - * at a time. --hpreg - */ - - for (;;) { - if (myBufSize == 0) { - /* We are done */ - break; - } - - /* IN: Type */ - bp.in.cx.halfs.high = MESSAGE_TYPE_SENDPAYLOAD; - /* IN: Id and cookie */ - bp.in.dx.halfs.high = chan->id; - bp.in.si.word = chan->cookieHigh; - bp.in.di.word = chan->cookieLow; - /* IN: Piece of message */ - /* - * Beware in case we are not allowed to read extra bytes beyond the - * end of the buffer. - */ - switch (myBufSize) { - case 1: - bp.in.size = myBuf[0]; - myBufSize -= 1; - break; - case 2: - bp.in.size = myBuf[0] | myBuf[1] << 8; - myBufSize -= 2; - break; - case 3: - bp.in.size = myBuf[0] | myBuf[1] << 8 | myBuf[2] << 16; - myBufSize -= 3; - break; - default: - bp.in.size = *(const uint32 *)myBuf; - myBufSize -= 4; - break; - } - - bp.in.cx.halfs.low = BDOOR_CMD_MESSAGE; - Backdoor(&bp); - - /* OUT: Status */ - if ((bp.in.cx.halfs.high & MESSAGE_STATUS_SUCCESS) == 0) { - if ((bp.in.cx.halfs.high & MESSAGE_STATUS_CPT) != 0) { - /* A checkpoint occurred. Retry the operation. --hpreg */ - goto retry; - } - - MESSAGE_LOG("Message: Unable to send a message over the " - "communication channel %u\n", chan->id); - return FALSE; - } - - myBuf += 4; - } - } - - return TRUE; -} - - -/* - *----------------------------------------------------------------------------- - * - * Message_Receive -- - * - * If vmware has posted a message for this channel, retrieve it - * - * Result: - * TRUE on success (bufSize is 0 if there is no message) - * FALSE on failure - * - * Side-effects: - * None - * - *----------------------------------------------------------------------------- - */ - -Bool -Message_Receive(Message_Channel *chan, // IN/OUT - unsigned char **buf, // OUT - size_t *bufSize) // OUT -{ - Backdoor_proto bp; - size_t myBufSize; - unsigned char *myBuf; - -retry: - /* - * Is there a message waiting for our retrieval? - */ - - /* IN: Type */ - bp.in.cx.halfs.high = MESSAGE_TYPE_RECVSIZE; - /* IN: Id and cookie */ - bp.in.dx.halfs.high = chan->id; - bp.in.si.word = chan->cookieHigh; - bp.in.di.word = chan->cookieLow; - - bp.in.cx.halfs.low = BDOOR_CMD_MESSAGE; - Backdoor(&bp); - - /* OUT: Status */ - if ((bp.in.cx.halfs.high & MESSAGE_STATUS_SUCCESS) == 0) { - MESSAGE_LOG("Message: Unable to poll for messages over the " - "communication channel %u\n", chan->id); - return FALSE; - } - - if ((bp.in.cx.halfs.high & MESSAGE_STATUS_DORECV) == 0) { - /* No message to retrieve */ - *bufSize = 0; - return TRUE; - } - - /* - * Receive the size. - */ - - /* OUT: Type */ - if (bp.in.dx.halfs.high != MESSAGE_TYPE_SENDSIZE) { - MESSAGE_LOG("Message: Protocol error. Expected a " - "MESSAGE_TYPE_SENDSIZE request from vmware\n"); - return FALSE; - } - - /* OUT: Size */ - myBufSize = bp.out.bx.word; - - /* - * Allocate an extra byte for a trailing NUL character. The code that will - * deal with this message may not know about binary strings, and may expect - * a C string instead. --hpreg - */ - if (myBufSize + 1 > chan->inAlloc) { - myBuf = (unsigned char *)realloc(chan->in, myBufSize + 1); - if (myBuf == NULL) { - MESSAGE_LOG("Message: Not enough memory to receive a message over " - "the communication channel %u\n", chan->id); - goto error_quit; - } - - chan->in = myBuf; - chan->inAlloc = myBufSize + 1; - } - *bufSize = myBufSize; - myBuf = *buf = chan->in; - - if (bp.in.cx.halfs.high & MESSAGE_STATUS_HB) { - /* - * High-bandwidth backdoor port supported. Receive the message in one - * backdoor operation. --hpreg - */ - - if (myBufSize) { - Backdoor_proto_hb bphb; - - bphb.in.bx.halfs.low = BDOORHB_CMD_MESSAGE; - bphb.in.bx.halfs.high = MESSAGE_STATUS_SUCCESS; - bphb.in.dx.halfs.high = chan->id; - bphb.in.srcAddr = chan->cookieHigh; - bphb.in.bp.word = chan->cookieLow; - bphb.in.size = myBufSize; - bphb.in.dstAddr = (uintptr_t) myBuf; - Backdoor_HbIn(&bphb); - if ((bphb.in.bx.halfs.high & MESSAGE_STATUS_SUCCESS) == 0) { - if ((bphb.in.bx.halfs.high & MESSAGE_STATUS_CPT) != 0) { - /* A checkpoint occurred. Retry the operation. --hpreg */ - goto retry; - } - - MESSAGE_LOG("Message: Unable to receive a message over the " - "communication channel %u\n", chan->id); - goto error_quit; - } - } - } else { - /* - * High-bandwidth backdoor port not supported. Receive the message, 4 - * bytes at a time. --hpreg - */ - - for (;;) { - if (myBufSize == 0) { - /* We are done */ - break; - } - - /* IN: Type */ - bp.in.cx.halfs.high = MESSAGE_TYPE_RECVPAYLOAD; - /* IN: Id and cookie */ - bp.in.dx.halfs.high = chan->id; - bp.in.si.word = chan->cookieHigh; - bp.in.di.word = chan->cookieLow; - /* IN: Status for the previous request (that succeeded) */ - bp.in.size = MESSAGE_STATUS_SUCCESS; - - bp.in.cx.halfs.low = BDOOR_CMD_MESSAGE; - Backdoor(&bp); - - /* OUT: Status */ - if ((bp.in.cx.halfs.high & MESSAGE_STATUS_SUCCESS) == 0) { - if ((bp.in.cx.halfs.high & MESSAGE_STATUS_CPT) != 0) { - /* A checkpoint occurred. Retry the operation. --hpreg */ - goto retry; - } - - MESSAGE_LOG("Message: Unable to receive a message over the " - "communication channel %u\n", chan->id); - goto error_quit; - } - - /* OUT: Type */ - if (bp.in.dx.halfs.high != MESSAGE_TYPE_SENDPAYLOAD) { - MESSAGE_LOG("Message: Protocol error. Expected a " - "MESSAGE_TYPE_SENDPAYLOAD from vmware\n"); - goto error_quit; - } - - /* OUT: Piece of message */ - /* - * Beware in case we are not allowed to write extra bytes beyond the - * end of the buffer. --hpreg - */ - switch (myBufSize) { - case 1: - myBuf[0] = bp.out.bx.word & 0xff; - myBufSize -= 1; - break; - case 2: - myBuf[0] = bp.out.bx.word & 0xff; - myBuf[1] = (bp.out.bx.word >> 8) & 0xff; - myBufSize -= 2; - break; - case 3: - myBuf[0] = bp.out.bx.word & 0xff; - myBuf[1] = (bp.out.bx.word >> 8) & 0xff; - myBuf[2] = (bp.out.bx.word >> 16) & 0xff; - myBufSize -= 3; - break; - default: - *(uint32 *)myBuf = bp.out.bx.word; - myBufSize -= 4; - break; - } - - myBuf += 4; - } - } - - /* Write a trailing NUL just after the message. --hpreg */ - chan->in[*bufSize] = '\0'; - - /* IN: Type */ - bp.in.cx.halfs.high = MESSAGE_TYPE_RECVSTATUS; - /* IN: Id and cookie */ - bp.in.dx.halfs.high = chan->id; - bp.in.si.word = chan->cookieHigh; - bp.in.di.word = chan->cookieLow; - /* IN: Status for the previous request (that succeeded) */ - bp.in.size = MESSAGE_STATUS_SUCCESS; - - bp.in.cx.halfs.low = BDOOR_CMD_MESSAGE; - Backdoor(&bp); - - /* OUT: Status */ - if ((bp.in.cx.halfs.high & MESSAGE_STATUS_SUCCESS) == 0) { - if ((bp.in.cx.halfs.high & MESSAGE_STATUS_CPT) != 0) { - /* A checkpoint occurred. Retry the operation. --hpreg */ - goto retry; - } - - MESSAGE_LOG("Message: Unable to receive a message over the " - "communication channel %u\n", chan->id); - goto error_quit; - } - - return TRUE; - -error_quit: - /* IN: Type */ - if (myBufSize == 0) { - bp.in.cx.halfs.high = MESSAGE_TYPE_RECVSTATUS; - } else { - bp.in.cx.halfs.high = MESSAGE_TYPE_RECVPAYLOAD; - } - /* IN: Id and cookie */ - bp.in.dx.halfs.high = chan->id; - bp.in.si.word = chan->cookieHigh; - bp.in.di.word = chan->cookieLow; - /* IN: Status for the previous request (that failed) */ - bp.in.size = 0; - - bp.in.cx.halfs.low = BDOOR_CMD_MESSAGE; - Backdoor(&bp); - - /* OUT: Status */ - if ((bp.in.cx.halfs.high & MESSAGE_STATUS_SUCCESS) == 0) { - MESSAGE_LOG("Message: Unable to signal an error of reception over the " - "communication channel %u\n", chan->id); - return FALSE; - } - - return FALSE; -} - - -/* - *----------------------------------------------------------------------------- - * - * Message_Close -- - * - * Close a communication channel - * - * Result: - * TRUE on success, the channel is destroyed - * FALSE on failure - * - * Side-effects: - * None - * - *----------------------------------------------------------------------------- - */ - -Bool -Message_Close(Message_Channel *chan) // IN/OUT -{ - Backdoor_proto bp; - Bool ret = TRUE; - - /* IN: Type */ - bp.in.cx.halfs.high = MESSAGE_TYPE_CLOSE; - /* IN: Id and cookie */ - bp.in.dx.halfs.high = chan->id; - bp.in.si.word = chan->cookieHigh; - bp.in.di.word = chan->cookieLow; - - bp.in.cx.halfs.low = BDOOR_CMD_MESSAGE; - Backdoor(&bp); - - /* OUT: Status */ - if ((bp.in.cx.halfs.high & MESSAGE_STATUS_SUCCESS) == 0) { - MESSAGE_LOG("Message: Unable to close the communication channel %u\n", - chan->id); - ret = FALSE; - } - - free(chan->in); - chan->in = NULL; - - free(chan); - return ret; -} - -#ifdef __cplusplus -} -#endif diff --git a/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/sigma/vmw-guestinfo/examples/main.go b/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/sigma/vmw-guestinfo/examples/main.go deleted file mode 100644 index d9553906..00000000 --- a/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/sigma/vmw-guestinfo/examples/main.go +++ /dev/null @@ -1,27 +0,0 @@ -package main - -import ( - "fmt" - - "github.com/sigma/vmw-guestinfo/rpcvmx" - "github.com/sigma/vmw-guestinfo/vmcheck" -) - -func main() { - if !vmcheck.IsVirtualWorld() { - fmt.Println("not in a virtual world... :(") - return - } - - config := rpcvmx.NewConfig() - - fmt.Println(config.SetString("foo", "bar")) - fmt.Println(config.String("foo", "foo")) - - fmt.Println(config.SetInt("foo", 3)) - fmt.Println(config.Int("foo", 0)) - - fmt.Println(config.SetBool("foo", false)) - fmt.Println(config.Bool("foo", true)) - -} diff --git a/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/sigma/vmw-guestinfo/include/backdoor.h b/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/sigma/vmw-guestinfo/include/backdoor.h deleted file mode 100644 index ab95db41..00000000 --- a/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/sigma/vmw-guestinfo/include/backdoor.h +++ /dev/null @@ -1,60 +0,0 @@ -/********************************************************* - * Copyright (C) 1999-2015 VMware, Inc. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation version 2.1 and no later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the Lesser GNU General Public - * License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - *********************************************************/ - -/********************************************************* - * The contents of this file are subject to the terms of the Common - * Development and Distribution License (the "License") version 1.0 - * and no later version. You may not use this file except in - * compliance with the License. - * - * You can obtain a copy of the License at - * http://www.opensource.org/licenses/cddl1.php - * - * See the License for the specific language governing permissions - * and limitations under the License. - * - *********************************************************/ - -/* - * backdoor.h -- - * - * First layer of the internal communication channel between guest - * applications and vmware - */ - -#ifndef _BACKDOOR_H_ -#define _BACKDOOR_H_ - -#include "vm_basic_types.h" -#include "vm_assert.h" - -#include "backdoor_types.h" - -void -Backdoor(Backdoor_proto *bp); // IN/OUT - -void -Backdoor_InOut(Backdoor_proto *bp); // IN/OUT - -void -Backdoor_HbOut(Backdoor_proto_hb *bp); // IN/OUT - -void -Backdoor_HbIn(Backdoor_proto_hb *bp); // IN/OUT - -#endif /* _BACKDOOR_H_ */ diff --git a/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/sigma/vmw-guestinfo/include/backdoorInt.h b/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/sigma/vmw-guestinfo/include/backdoorInt.h deleted file mode 100644 index 18e6f0b9..00000000 --- a/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/sigma/vmw-guestinfo/include/backdoorInt.h +++ /dev/null @@ -1,40 +0,0 @@ -/********************************************************* - * Copyright (C) 2005-2015 VMware, Inc. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation version 2.1 and no later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the Lesser GNU General Public - * License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - *********************************************************/ - -/********************************************************* - * The contents of this file are subject to the terms of the Common - * Development and Distribution License (the "License") version 1.0 - * and no later version. You may not use this file except in - * compliance with the License. - * - * You can obtain a copy of the License at - * http://www.opensource.org/licenses/cddl1.php - * - * See the License for the specific language governing permissions - * and limitations under the License. - * - *********************************************************/ - -/* - * backdoorInt.h -- - * - * Internal function prototypes for the real backdoor work. - */ - -void BackdoorHbIn(Backdoor_proto_hb *bp); -void BackdoorHbOut(Backdoor_proto_hb *bp); diff --git a/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/sigma/vmw-guestinfo/include/backdoor_def.h b/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/sigma/vmw-guestinfo/include/backdoor_def.h deleted file mode 100644 index 6d797ed3..00000000 --- a/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/sigma/vmw-guestinfo/include/backdoor_def.h +++ /dev/null @@ -1,259 +0,0 @@ -/********************************************************* - * Copyright (C) 1998-2015 VMware, Inc. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation version 2.1 and no later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the Lesser GNU General Public - * License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - *********************************************************/ - -/********************************************************* - * The contents of this file are subject to the terms of the Common - * Development and Distribution License (the "License") version 1.0 - * and no later version. You may not use this file except in - * compliance with the License. - * - * You can obtain a copy of the License at - * http://www.opensource.org/licenses/cddl1.php - * - * See the License for the specific language governing permissions - * and limitations under the License. - * - *********************************************************/ - -/* - * backdoor_def.h -- - * - * This contains backdoor defines that can be included from - * an assembly language file. - */ - - - -#ifndef _BACKDOOR_DEF_H_ -#define _BACKDOOR_DEF_H_ - -/* - * If you want to add a new low-level backdoor call for a guest userland - * application, please consider using the GuestRpc mechanism instead. --hpreg - */ - -#define BDOOR_MAGIC 0x564D5868 - -/* Low-bandwidth backdoor port. --hpreg */ - -#define BDOOR_PORT 0x5658 - -#define BDOOR_CMD_GETMHZ 1 -/* - * BDOOR_CMD_APMFUNCTION is used by: - * - * o The FrobOS code, which instead should either program the virtual chipset - * (like the new BIOS code does, matthias offered to implement that), or not - * use any VM-specific code (which requires that we correctly implement - * "power off on CLI HLT" for SMP VMs, boris offered to implement that) - * - * o The old BIOS code, which will soon be jettisoned - * - * --hpreg - */ -#define BDOOR_CMD_APMFUNCTION 2 /* CPL0 only. */ -#define BDOOR_CMD_GETDISKGEO 3 -#define BDOOR_CMD_GETPTRLOCATION 4 -#define BDOOR_CMD_SETPTRLOCATION 5 -#define BDOOR_CMD_GETSELLENGTH 6 -#define BDOOR_CMD_GETNEXTPIECE 7 -#define BDOOR_CMD_SETSELLENGTH 8 -#define BDOOR_CMD_SETNEXTPIECE 9 -#define BDOOR_CMD_GETVERSION 10 -#define BDOOR_CMD_GETDEVICELISTELEMENT 11 -#define BDOOR_CMD_TOGGLEDEVICE 12 -#define BDOOR_CMD_GETGUIOPTIONS 13 -#define BDOOR_CMD_SETGUIOPTIONS 14 -#define BDOOR_CMD_GETSCREENSIZE 15 -#define BDOOR_CMD_MONITOR_CONTROL 16 /* Disabled by default. */ -#define BDOOR_CMD_GETHWVERSION 17 -#define BDOOR_CMD_OSNOTFOUND 18 /* CPL0 only. */ -#define BDOOR_CMD_GETUUID 19 -#define BDOOR_CMD_GETMEMSIZE 20 -#define BDOOR_CMD_HOSTCOPY 21 /* Devel only. */ -//#define BDOOR_CMD_SERVICE_VM 22 /* Not in use. Never shipped. */ -#define BDOOR_CMD_GETTIME 23 /* Deprecated -> GETTIMEFULL. */ -#define BDOOR_CMD_STOPCATCHUP 24 -#define BDOOR_CMD_PUTCHR 25 /* Disabled by default. */ -#define BDOOR_CMD_ENABLE_MSG 26 /* Devel only. */ -#define BDOOR_CMD_GOTO_TCL 27 /* Devel only. */ -#define BDOOR_CMD_INITPCIOPROM 28 /* CPL 0 only. */ -//#define BDOOR_CMD_INT13 29 /* Not in use. */ -#define BDOOR_CMD_MESSAGE 30 -#define BDOOR_CMD_SIDT 31 -#define BDOOR_CMD_SGDT 32 -#define BDOOR_CMD_SLDT_STR 33 -#define BDOOR_CMD_ISACPIDISABLED 34 -//#define BDOOR_CMD_TOE 35 /* Not in use. */ -#define BDOOR_CMD_ISMOUSEABSOLUTE 36 -#define BDOOR_CMD_PATCH_SMBIOS_STRUCTS 37 /* CPL 0 only. */ -#define BDOOR_CMD_MAPMEM 38 /* Devel only */ -#define BDOOR_CMD_ABSPOINTER_DATA 39 -#define BDOOR_CMD_ABSPOINTER_STATUS 40 -#define BDOOR_CMD_ABSPOINTER_COMMAND 41 -//#define BDOOR_CMD_TIMER_SPONGE 42 /* Not in use. */ -#define BDOOR_CMD_PATCH_ACPI_TABLES 43 /* CPL 0 only. */ -//#define BDOOR_CMD_DEVEL_FAKEHARDWARE 44 /* Not in use. */ -#define BDOOR_CMD_GETHZ 45 -#define BDOOR_CMD_GETTIMEFULL 46 -//#define BDOOR_CMD_STATELOGGER 47 /* Not in use. */ -#define BDOOR_CMD_CHECKFORCEBIOSSETUP 48 /* CPL 0 only. */ -#define BDOOR_CMD_LAZYTIMEREMULATION 49 /* CPL 0 only. */ -#define BDOOR_CMD_BIOSBBS 50 /* CPL 0 only. */ -//#define BDOOR_CMD_VASSERT 51 /* Not in use. */ -#define BDOOR_CMD_ISGOSDARWIN 52 -#define BDOOR_CMD_DEBUGEVENT 53 -#define BDOOR_CMD_OSNOTMACOSXSERVER 54 /* CPL 0 only. */ -#define BDOOR_CMD_GETTIMEFULL_WITH_LAG 55 -#define BDOOR_CMD_ACPI_HOTPLUG_DEVICE 56 /* Devel only. */ -#define BDOOR_CMD_ACPI_HOTPLUG_MEMORY 57 /* Devel only. */ -#define BDOOR_CMD_ACPI_HOTPLUG_CBRET 58 /* Devel only. */ -//#define BDOOR_CMD_GET_HOST_VIDEO_MODES 59 /* Not in use. */ -#define BDOOR_CMD_ACPI_HOTPLUG_CPU 60 /* Devel only. */ -//#define BDOOR_CMD_USB_HOTPLUG_MOUSE 61 /* Not in use. Never shipped. */ -#define BDOOR_CMD_XPMODE 62 /* CPL 0 only. */ -#define BDOOR_CMD_NESTING_CONTROL 63 -#define BDOOR_CMD_FIRMWARE_INIT 64 /* CPL 0 only. */ -#define BDOOR_CMD_FIRMWARE_ACPI_SERVICES 65 /* CPL 0 only. */ -# define BDOOR_CMD_FAS_GET_TABLE_SIZE 0 -# define BDOOR_CMD_FAS_GET_TABLE_DATA 1 -# define BDOOR_CMD_FAS_GET_PLATFORM_NAME 2 -# define BDOOR_CMD_FAS_GET_PCIE_OSC_MASK 3 -# define BDOOR_CMD_FAS_GET_APIC_ROUTING 4 -# define BDOOR_CMD_FAS_GET_TABLE_SKIP 5 -# define BDOOR_CMD_FAS_GET_SLEEP_ENABLES 6 -# define BDOOR_CMD_FAS_GET_HARD_RESET_ENABLE 7 -#define BDOOR_CMD_SENDPSHAREHINTS 66 /* Not in use. Deprecated. */ -#define BDOOR_CMD_ENABLE_USB_MOUSE 67 -#define BDOOR_CMD_GET_VCPU_INFO 68 -# define BDOOR_CMD_VCPU_SLC64 0 -# define BDOOR_CMD_VCPU_SYNC_VTSCS 1 -# define BDOOR_CMD_VCPU_HV_REPLAY_OK 2 -# define BDOOR_CMD_VCPU_LEGACY_X2APIC_OK 3 -# define BDOOR_CMD_VCPU_MMIO_HONORS_PAT 4 -# define BDOOR_CMD_VCPU_RESERVED 31 -#define BDOOR_CMD_EFI_SERIALCON_CONFIG 69 /* CPL 0 only. */ -#define BDOOR_CMD_BUG328986 70 /* CPL 0 only. */ -#define BDOOR_CMD_FIRMWARE_ERROR 71 /* CPL 0 only. */ -# define BDOOR_CMD_FE_INSUFFICIENT_MEM 0 -# define BDOOR_CMD_FE_EXCEPTION 1 -#define BDOOR_CMD_VMK_INFO 72 -#define BDOOR_CMD_EFI_BOOT_CONFIG 73 /* CPL 0 only. */ -# define BDOOR_CMD_EBC_LEGACYBOOT_ENABLED 0 -# define BDOOR_CMD_EBC_GET_ORDER 1 -# define BDOOR_CMD_EBC_SHELL_ACTIVE 2 -# define BDOOR_CMD_EBC_GET_NETWORK_BOOT_PROTOCOL 3 -#define BDOOR_CMD_GET_HW_MODEL 74 /* CPL 0 only. */ -#define BDOOR_CMD_GET_SVGA_CAPABILITIES 75 /* CPL 0 only. */ -#define BDOOR_CMD_GET_FORCE_X2APIC 76 /* CPL 0 only */ -#define BDOOR_CMD_SET_PCI_HOLE 77 /* CPL 0 only */ -#define BDOOR_CMD_GET_PCI_HOLE 78 /* CPL 0 only */ -#define BDOOR_CMD_GET_PCI_BAR 79 /* CPL 0 only */ -#define BDOOR_CMD_SHOULD_GENERATE_SYSTEMID 80 /* CPL 0 only */ -#define BDOOR_CMD_READ_DEBUG_FILE 81 /* Devel only. */ -#define BDOOR_CMD_SCREENSHOT 82 /* Devel only. */ -#define BDOOR_CMD_INJECT_KEY 83 /* Devel only. */ -#define BDOOR_CMD_INJECT_MOUSE 84 /* Devel only. */ -#define BDOOR_CMD_MKS_GUEST_STATS 85 /* CPL 0 only. */ -# define BDOOR_CMD_MKSGS_RESET 0 -# define BDOOR_CMD_MKSGS_ADD_PPN 1 -# define BDOOR_CMD_MKSGS_REMOVE_PPN 2 -#define BDOOR_CMD_ABSPOINTER_RESTRICT 86 -#define BDOOR_CMD_GUESTINTEGRITY 87 -# define BDOOR_CMD_GI_SETUP 0 -# define BDOOR_CMD_GI_REMOVE 1 -#define BDOOR_CMD_MKSSTATS_SNAPSHOT 88 /* Devel only. */ -# define BDOOR_CMD_MKSSTATS_START 0 -# define BDOOR_CMD_MKSSTATS_STOP 1 -#define BDOOR_CMD_MAX 89 - - -/* - * IMPORTANT NOTE: When modifying the behavior of an existing backdoor command, - * you must adhere to the semantics expected by the oldest Tools who use that - * command. Specifically, do not alter the way in which the command modifies - * the registers. Otherwise backwards compatibility will suffer. - */ - -/* Nesting control operations */ - -#define NESTING_CONTROL_RESTRICT_BACKDOOR 0 -#define NESTING_CONTROL_OPEN_BACKDOOR 1 -#define NESTING_CONTROL_QUERY 2 -#define NESTING_CONTROL_MAX 2 - -/* EFI Boot Order options, nibble-sized. */ -#define EFI_BOOT_ORDER_TYPE_EFI 0x0 -#define EFI_BOOT_ORDER_TYPE_LEGACY 0x1 -#define EFI_BOOT_ORDER_TYPE_NONE 0xf - -#define BDOOR_NETWORK_BOOT_PROTOCOL_NONE 0x0 -#define BDOOR_NETWORK_BOOT_PROTOCOL_IPV4 0x1 -#define BDOOR_NETWORK_BOOT_PROTOCOL_IPV6 0x2 - -/* High-bandwidth backdoor port. --hpreg */ - -#define BDOORHB_PORT 0x5659 - -#define BDOORHB_CMD_MESSAGE 0 -#define BDOORHB_CMD_VASSERT 1 -#define BDOORHB_CMD_MAX 2 - -/* - * There is another backdoor which allows access to certain TSC-related - * values using otherwise illegal PMC indices when the pseudo_perfctr - * control flag is set. - */ - -#define BDOOR_PMC_HW_TSC 0x10000 -#define BDOOR_PMC_REAL_NS 0x10001 -#define BDOOR_PMC_APPARENT_NS 0x10002 -#define BDOOR_PMC_PSEUDO_TSC 0x10003 - -#define IS_BDOOR_PMC(index) (((index) | 3) == 0x10003) -#define BDOOR_CMD(ecx) ((ecx) & 0xffff) - -/* Sub commands for BDOOR_CMD_VMK_INFO */ -#define BDOOR_CMD_VMK_INFO_ENTRY 1 - -#ifdef VMM -/* - *---------------------------------------------------------------------- - * - * Backdoor_CmdRequiresFullyValidVCPU -- - * - * A few backdoor commands require the full VCPU to be valid - * (including GDTR, IDTR, TR and LDTR). The rest get read/write - * access to GPRs and read access to Segment registers (selectors). - * - * Result: - * True iff VECX contains a command that require the full VCPU to - * be valid. - * - *---------------------------------------------------------------------- - */ -static INLINE Bool -Backdoor_CmdRequiresFullyValidVCPU(unsigned cmd) -{ - return cmd == BDOOR_CMD_SIDT || - cmd == BDOOR_CMD_SGDT || - cmd == BDOOR_CMD_SLDT_STR; -} -#endif - -#endif diff --git a/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/sigma/vmw-guestinfo/include/backdoor_types.h b/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/sigma/vmw-guestinfo/include/backdoor_types.h deleted file mode 100644 index 3f772dee..00000000 --- a/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/sigma/vmw-guestinfo/include/backdoor_types.h +++ /dev/null @@ -1,132 +0,0 @@ -/********************************************************* - * Copyright (C) 1999-2015 VMware, Inc. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation version 2.1 and no later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the Lesser GNU General Public - * License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - *********************************************************/ - -/********************************************************* - * The contents of this file are subject to the terms of the Common - * Development and Distribution License (the "License") version 1.0 - * and no later version. You may not use this file except in - * compliance with the License. - * - * You can obtain a copy of the License at - * http://www.opensource.org/licenses/cddl1.php - * - * See the License for the specific language governing permissions - * and limitations under the License. - * - *********************************************************/ - -/* - * backdoor_types.h -- - * - * Type definitions for backdoor interaction code. - */ - -#ifndef _BACKDOOR_TYPES_H_ -#define _BACKDOOR_TYPES_H_ - -#ifndef VM_I386 -#error The backdoor protocol is only supported on x86 architectures. -#endif - -/* - * These #defines are intended for defining register structs as part of - * existing named unions. If the union should encapsulate the register - * (and nothing else), use DECLARE_REG_NAMED_STRUCT defined below. - */ - -#define DECLARE_REG32_STRUCT \ - struct { \ - uint16 low; \ - uint16 high; \ - } halfs; \ - uint32 word - -#define DECLARE_REG64_STRUCT \ - DECLARE_REG32_STRUCT; \ - struct { \ - uint32 low; \ - uint32 high; \ - } words; \ - uint64 quad - -#ifndef VM_X86_64 -#define DECLARE_REG_STRUCT DECLARE_REG32_STRUCT -#else -#define DECLARE_REG_STRUCT DECLARE_REG64_STRUCT -#endif - -#define DECLARE_REG_NAMED_STRUCT(_r) \ - union { DECLARE_REG_STRUCT; } _r - -/* - * Some of the registers are expressed by semantic name, because if they were - * expressed as register structs declared above, we could only address them - * by fixed size (half-word, word, quad, etc.) instead of by varying size - * (size_t, uintptr_t). - * - * To be cleaner, these registers are expressed ONLY by semantic name, - * rather than by a union of the semantic name and a register struct. - */ -typedef union { - struct { - DECLARE_REG_NAMED_STRUCT(ax); - size_t size; /* Register bx. */ - DECLARE_REG_NAMED_STRUCT(cx); - DECLARE_REG_NAMED_STRUCT(dx); - DECLARE_REG_NAMED_STRUCT(si); - DECLARE_REG_NAMED_STRUCT(di); - } in; - struct { - DECLARE_REG_NAMED_STRUCT(ax); - DECLARE_REG_NAMED_STRUCT(bx); - DECLARE_REG_NAMED_STRUCT(cx); - DECLARE_REG_NAMED_STRUCT(dx); - DECLARE_REG_NAMED_STRUCT(si); - DECLARE_REG_NAMED_STRUCT(di); - } out; -} Backdoor_proto; - -typedef union { - struct { - DECLARE_REG_NAMED_STRUCT(ax); - DECLARE_REG_NAMED_STRUCT(bx); - size_t size; /* Register cx. */ - DECLARE_REG_NAMED_STRUCT(dx); - uintptr_t srcAddr; /* Register si. */ - uintptr_t dstAddr; /* Register di. */ - DECLARE_REG_NAMED_STRUCT(bp); - } in; - struct { - DECLARE_REG_NAMED_STRUCT(ax); - DECLARE_REG_NAMED_STRUCT(bx); - DECLARE_REG_NAMED_STRUCT(cx); - DECLARE_REG_NAMED_STRUCT(dx); - DECLARE_REG_NAMED_STRUCT(si); - DECLARE_REG_NAMED_STRUCT(di); - DECLARE_REG_NAMED_STRUCT(bp); - } out; -} Backdoor_proto_hb; - -MY_ASSERTS(BACKDOOR_STRUCT_SIZES, - ASSERT_ON_COMPILE(sizeof(Backdoor_proto) == 6 * sizeof(uintptr_t)); - ASSERT_ON_COMPILE(sizeof(Backdoor_proto_hb) == 7 * sizeof(uintptr_t)); -) - -#undef DECLARE_REG_STRUCT - -#endif /* _BACKDOOR_TYPES_H_ */ diff --git a/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/sigma/vmw-guestinfo/include/community_source.h b/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/sigma/vmw-guestinfo/include/community_source.h deleted file mode 100644 index 7db224a2..00000000 --- a/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/sigma/vmw-guestinfo/include/community_source.h +++ /dev/null @@ -1,70 +0,0 @@ -/********************************************************* - * Copyright (C) 2009-2015 VMware, Inc. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation version 2.1 and no later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the Lesser GNU General Public - * License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - *********************************************************/ - -/********************************************************* - * The contents of this file are subject to the terms of the Common - * Development and Distribution License (the "License") version 1.0 - * and no later version. You may not use this file except in - * compliance with the License. - * - * You can obtain a copy of the License at - * http://www.opensource.org/licenses/cddl1.php - * - * See the License for the specific language governing permissions - * and limitations under the License. - * - *********************************************************/ - -/* - * community_source.h -- - * - * Macros for excluding source code from community. - */ - -#ifndef _COMMUNITY_SOURCE_H_ -#define _COMMUNITY_SOURCE_H_ - -/* - * Convenience macro for COMMUNITY_SOURCE - */ -#undef EXCLUDE_COMMUNITY_SOURCE -#ifdef COMMUNITY_SOURCE - #define EXCLUDE_COMMUNITY_SOURCE(x) -#else - #define EXCLUDE_COMMUNITY_SOURCE(x) x -#endif - -#undef COMMUNITY_SOURCE_AMD_SECRET -#if !defined(COMMUNITY_SOURCE) || defined(AMD_SOURCE) -/* - * It's ok to include AMD_SECRET source code for non-Community Source, - * or for drops directed at AMD. - */ - #define COMMUNITY_SOURCE_AMD_SECRET -#endif - -#undef COMMUNITY_SOURCE_INTEL_SECRET -#if !defined(COMMUNITY_SOURCE) || defined(INTEL_SOURCE) -/* - * It's ok to include INTEL_SECRET source code for non-Community Source, - * or for drops directed at Intel. - */ - #define COMMUNITY_SOURCE_INTEL_SECRET -#endif - -#endif diff --git a/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/sigma/vmw-guestinfo/include/guest_msg_def.h b/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/sigma/vmw-guestinfo/include/guest_msg_def.h deleted file mode 100644 index c0d0497a..00000000 --- a/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/sigma/vmw-guestinfo/include/guest_msg_def.h +++ /dev/null @@ -1,100 +0,0 @@ -/********************************************************* - * Copyright (C) 1998-2015 VMware, Inc. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation version 2.1 and no later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the Lesser GNU General Public - * License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - *********************************************************/ - -/********************************************************* - * The contents of this file are subject to the terms of the Common - * Development and Distribution License (the "License") version 1.0 - * and no later version. You may not use this file except in - * compliance with the License. - * - * You can obtain a copy of the License at - * http://www.opensource.org/licenses/cddl1.php - * - * See the License for the specific language governing permissions - * and limitations under the License. - * - *********************************************************/ - -/* - * guest_msg_def.h -- - * - * Second layer of the internal communication channel between guest - * applications and vmware - * - */ - -#ifndef _GUEST_MSG_DEF_H_ -#define _GUEST_MSG_DEF_H_ - -/* Basic request types */ -typedef enum { - MESSAGE_TYPE_OPEN, - MESSAGE_TYPE_SENDSIZE, - MESSAGE_TYPE_SENDPAYLOAD, - MESSAGE_TYPE_RECVSIZE, - MESSAGE_TYPE_RECVPAYLOAD, - MESSAGE_TYPE_RECVSTATUS, - MESSAGE_TYPE_CLOSE, -} MessageType; - - -/* Reply statuses */ -/* The basic request succeeded */ -#define MESSAGE_STATUS_SUCCESS 0x0001 -/* vmware has a message available for its party */ -#define MESSAGE_STATUS_DORECV 0x0002 -/* The channel has been closed */ -#define MESSAGE_STATUS_CLOSED 0x0004 -/* vmware removed the message before the party fetched it */ -#define MESSAGE_STATUS_UNSENT 0x0008 -/* A checkpoint occurred */ -#define MESSAGE_STATUS_CPT 0x0010 -/* An underlying device is powering off */ -#define MESSAGE_STATUS_POWEROFF 0x0020 -/* vmware has detected a timeout on the channel */ -#define MESSAGE_STATUS_TIMEOUT 0x0040 -/* vmware supports high-bandwidth for sending and receiving the payload */ -#define MESSAGE_STATUS_HB 0x0080 - -/* - * This mask defines the status bits that the guest is allowed to set; - * we use this to mask out all other bits when receiving the status - * from the guest. Otherwise, the guest can manipulate VMX state by - * setting status bits that are only supposed to be changed by the - * VMX. See bug 45385. - */ -#define MESSAGE_STATUS_GUEST_MASK MESSAGE_STATUS_SUCCESS - -/* - * Max number of channels. - * Unfortunately this has to be public because the monitor part - * of the backdoor needs it for its trivial-case optimization. [greg] - */ -#define GUESTMSG_MAX_CHANNEL 8 - -/* Flags to open a channel. --hpreg */ -#define GUESTMSG_FLAG_COOKIE 0x80000000 -#define GUESTMSG_FLAG_ALL GUESTMSG_FLAG_COOKIE - -/* - * Maximum size of incoming message. This is to prevent denial of host service - * attacks from guest applications. - */ -#define GUESTMSG_MAX_IN_SIZE (64 * 1024) - -#endif /* _GUEST_MSG_DEF_H_ */ diff --git a/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/sigma/vmw-guestinfo/include/message.h b/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/sigma/vmw-guestinfo/include/message.h deleted file mode 100644 index 3637e58e..00000000 --- a/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/sigma/vmw-guestinfo/include/message.h +++ /dev/null @@ -1,72 +0,0 @@ -/********************************************************* - * Copyright (C) 1999-2015 VMware, Inc. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation version 2.1 and no later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the Lesser GNU General Public - * License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - *********************************************************/ - -/********************************************************* - * The contents of this file are subject to the terms of the Common - * Development and Distribution License (the "License") version 1.0 - * and no later version. You may not use this file except in - * compliance with the License. - * - * You can obtain a copy of the License at - * http://www.opensource.org/licenses/cddl1.php - * - * See the License for the specific language governing permissions - * and limitations under the License. - * - *********************************************************/ - -/* - * message.h -- - * - * Second layer of the internal communication channel between guest - * applications and vmware - */ - -#ifndef __MESSAGE_H__ -# define __MESSAGE_H__ - -#ifdef __cplusplus -extern "C" { -#endif - -#include "vm_basic_types.h" - - -typedef struct Message_Channel Message_Channel; - -Message_Channel * -Message_Open(uint32 proto); // IN - -Bool -Message_Send(Message_Channel *chan, // IN/OUT - const unsigned char *buf, // IN - size_t bufSize); // IN - -Bool -Message_Receive(Message_Channel *chan, // IN/OUT - unsigned char **buf, // OUT - size_t *bufSize); // OUT - -Bool -Message_Close(Message_Channel *chan); // IN/OUT - -#ifdef __cplusplus -} -#endif - -#endif /* __MESSAGE_H__ */ diff --git a/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/sigma/vmw-guestinfo/include/vm_assert.h b/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/sigma/vmw-guestinfo/include/vm_assert.h deleted file mode 100644 index b2cffa9a..00000000 --- a/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/sigma/vmw-guestinfo/include/vm_assert.h +++ /dev/null @@ -1,364 +0,0 @@ -/********************************************************* - * Copyright (C) 1998-2015 VMware, Inc. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation version 2.1 and no later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the Lesser GNU General Public - * License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - *********************************************************/ - -/********************************************************* - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - *********************************************************/ - -/********************************************************* - * The contents of this file are subject to the terms of the Common - * Development and Distribution License (the "License") version 1.0 - * and no later version. You may not use this file except in - * compliance with the License. - * - * You can obtain a copy of the License at - * http://www.opensource.org/licenses/cddl1.php - * - * See the License for the specific language governing permissions - * and limitations under the License. - * - *********************************************************/ - -/* - * vm_assert.h -- - * - * The basic assertion facility for all VMware code. - * - * For proper use, see bora/doc/assert and - * http://vmweb.vmware.com/~mts/WebSite/guide/programming/asserts.html. - */ - -#ifndef _VM_ASSERT_H_ -#define _VM_ASSERT_H_ - -// XXX not necessary except some places include vm_assert.h improperly -#include "vm_basic_types.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/* - * Some bits of vmcore are used in VMKernel code and cannot have - * the VMKERNEL define due to other header dependencies. - */ -#if defined(VMKERNEL) && !defined(VMKPANIC) -#define VMKPANIC 1 -#endif - -/* - * Internal macros, functions, and strings - * - * The monitor wants to save space at call sites, so it has specialized - * functions for each situation. User level wants to save on implementation - * so it uses generic functions. - */ - -#if !defined VMM || defined MONITOR_APP // { - -#if defined (VMKPANIC) -#include "vmk_assert.h" -#else /* !VMKPANIC */ -#define _ASSERT_PANIC(name) \ - Panic(_##name##Fmt "\n", __FILE__, __LINE__) -#define _ASSERT_PANIC_BUG(bug, name) \ - Panic(_##name##Fmt " bugNr=%d\n", __FILE__, __LINE__, bug) -#define _ASSERT_PANIC_NORETURN(name) \ - Panic(_##name##Fmt "\n", __FILE__, __LINE__) -#define _ASSERT_PANIC_BUG_NORETURN(bug, name) \ - Panic(_##name##Fmt " bugNr=%d\n", __FILE__, __LINE__, bug) -#endif /* VMKPANIC */ - -#endif // } - - -// These strings don't have newline so that a bug can be tacked on. -#define _AssertPanicFmt "PANIC %s:%d" -#define _AssertAssertFmt "ASSERT %s:%d" -#define _AssertVerifyFmt "VERIFY %s:%d" -#define _AssertNotImplementedFmt "NOT_IMPLEMENTED %s:%d" -#define _AssertNotReachedFmt "NOT_REACHED %s:%d" -#define _AssertMemAllocFmt "MEM_ALLOC %s:%d" -#define _AssertNotTestedFmt "NOT_TESTED %s:%d" - - -/* - * Panic and log functions - */ - -void Log(const char *fmt, ...) PRINTF_DECL(1, 2); -void Warning(const char *fmt, ...) PRINTF_DECL(1, 2); -#if defined VMKPANIC -void Panic_SaveRegs(void); - -#ifdef VMX86_DEBUG -void Panic_NoSave(const char *fmt, ...) PRINTF_DECL(1, 2); -#else -NORETURN void Panic_NoSave(const char *fmt, ...) PRINTF_DECL(1, 2); -#endif - -NORETURN void Panic_NoSaveNoReturn(const char *fmt, ...) PRINTF_DECL(1, 2); - -#define Panic(fmt...) do { \ - Panic_SaveRegs(); \ - Panic_NoSave(fmt); \ -} while(0) - -#define Panic_NoReturn(fmt...) do { \ - Panic_SaveRegs(); \ - Panic_NoSaveNoReturn(fmt); \ -} while(0) - -#else -NORETURN void Panic(const char *fmt, ...) PRINTF_DECL(1, 2); -#endif - -void LogThrottled(uint32 *count, const char *fmt, ...) PRINTF_DECL(2, 3); -void WarningThrottled(uint32 *count, const char *fmt, ...) PRINTF_DECL(2, 3); - - -#ifndef ASSERT_IFNOT - /* - * PR 271512: When compiling with gcc, catch assignments inside an ASSERT. - * - * 'UNLIKELY' is defined with __builtin_expect, which does not warn when - * passed an assignment (gcc bug 36050). To get around this, we put 'cond' - * in an 'if' statement and make sure it never gets executed by putting - * that inside of 'if (0)'. We use gcc's statement expression syntax to - * make ASSERT an expression because some code uses it that way. - * - * Since statement expression syntax is a gcc extension and since it's - * not clear if this is a problem with other compilers, the ASSERT - * definition was not changed for them. Using a bare 'cond' with the - * ternary operator may provide a solution. - */ - - #ifdef __GNUC__ - #define ASSERT_IFNOT(cond, panic) \ - ({if (UNLIKELY(!(cond))) { panic; if (0) { if (cond) {;}}} (void)0;}) - #else - #define ASSERT_IFNOT(cond, panic) \ - (UNLIKELY(!(cond)) ? (panic) : (void)0) - #endif -#endif - - -/* - * Assert, panic, and log macros - * - * Some of these are redefined below undef !VMX86_DEBUG. - * ASSERT() is special cased because of interaction with Windows DDK. - */ - -#if defined VMX86_DEBUG -#undef ASSERT -#define ASSERT(cond) ASSERT_IFNOT(cond, _ASSERT_PANIC(AssertAssert)) -#define ASSERT_BUG(bug, cond) \ - ASSERT_IFNOT(cond, _ASSERT_PANIC_BUG(bug, AssertAssert)) -#endif - -#undef VERIFY -#define VERIFY(cond) \ - ASSERT_IFNOT(cond, _ASSERT_PANIC_NORETURN(AssertVerify)) -#define VERIFY_BUG(bug, cond) \ - ASSERT_IFNOT(cond, _ASSERT_PANIC_BUG_NORETURN(bug, AssertVerify)) - -#define PANIC() _ASSERT_PANIC(AssertPanic) -#define PANIC_BUG(bug) _ASSERT_PANIC_BUG(bug, AssertPanic) - -#define ASSERT_NOT_IMPLEMENTED(cond) \ - ASSERT_IFNOT(cond, NOT_IMPLEMENTED()) -#define ASSERT_NOT_IMPLEMENTED_BUG(bug, cond) \ - ASSERT_IFNOT(cond, NOT_IMPLEMENTED_BUG(bug)) - -#if defined VMKPANIC || defined VMM -#define NOT_IMPLEMENTED() _ASSERT_PANIC_NORETURN(AssertNotImplemented) -#else -#define NOT_IMPLEMENTED() _ASSERT_PANIC(AssertNotImplemented) -#endif - -#if defined VMM -#define NOT_IMPLEMENTED_BUG(bug) \ - _ASSERT_PANIC_BUG_NORETURN(bug, AssertNotImplemented) -#else -#define NOT_IMPLEMENTED_BUG(bug) _ASSERT_PANIC_BUG(bug, AssertNotImplemented) -#endif - -#if defined VMKPANIC || defined VMM -#define NOT_REACHED() _ASSERT_PANIC_NORETURN(AssertNotReached) -#else -#define NOT_REACHED() _ASSERT_PANIC(AssertNotReached) -#endif - -#define ASSERT_MEM_ALLOC(cond) \ - ASSERT_IFNOT(cond, _ASSERT_PANIC(AssertMemAlloc)) - -#ifdef VMX86_DEVEL -#define ASSERT_DEVEL(cond) ASSERT(cond) -#define NOT_TESTED() Warning(_AssertNotTestedFmt "\n", __FILE__, __LINE__) -#else -#define ASSERT_DEVEL(cond) ((void)0) -#define NOT_TESTED() Log(_AssertNotTestedFmt "\n", __FILE__, __LINE__) -#endif - -#define ASSERT_NO_INTERRUPTS() ASSERT(!INTERRUPTS_ENABLED()) -#define ASSERT_HAS_INTERRUPTS() ASSERT(INTERRUPTS_ENABLED()) - -#define ASSERT_NOT_TESTED(cond) (UNLIKELY(!(cond)) ? NOT_TESTED() : (void)0) -#define NOT_TESTED_ONCE() DO_ONCE(NOT_TESTED()) - -#define NOT_TESTED_1024() \ - do { \ - static uint16 count = 0; \ - if (UNLIKELY(count == 0)) { NOT_TESTED(); } \ - count = (count + 1) & 1023; \ - } while (0) - -#define LOG_ONCE(_s) DO_ONCE(Log _s) - - -/* - * Redefine macros that are only in debug versions - */ - -#if !defined VMX86_DEBUG // { - -#undef ASSERT -#define ASSERT(cond) ((void)0) -#define ASSERT_BUG(bug, cond) ((void)0) - -/* - * Expand NOT_REACHED() as appropriate for each situation. - * - * Mainly, we want the compiler to infer the same control-flow - * information as it would from Panic(). Otherwise, different - * compilation options will lead to different control-flow-derived - * errors, causing some make targets to fail while others succeed. - * - * VC++ has the __assume() built-in function which we don't trust - * (see bug 43485); gcc has no such construct; we just panic in - * userlevel code. The monitor doesn't want to pay the size penalty - * (measured at 212 bytes for the release vmm for a minimal infinite - * loop; panic would cost even more) so it does without and lives - * with the inconsistency. - */ - -#if defined VMKPANIC || defined VMM -#undef NOT_REACHED -#if defined __GNUC__ && (__GNUC__ > 4 || __GNUC__ == 4 && __GNUC_MINOR__ >= 5) -#define NOT_REACHED() (__builtin_unreachable()) -#else -#define NOT_REACHED() ((void)0) -#endif -#else -// keep debug definition -#endif - -#undef LOG_UNEXPECTED -#define LOG_UNEXPECTED(bug) ((void)0) - -#undef ASSERT_NOT_TESTED -#define ASSERT_NOT_TESTED(cond) ((void)0) -#undef NOT_TESTED -#define NOT_TESTED() ((void)0) -#undef NOT_TESTED_ONCE -#define NOT_TESTED_ONCE() ((void)0) -#undef NOT_TESTED_1024 -#define NOT_TESTED_1024() ((void)0) - -#endif // !VMX86_DEBUG } - - -/* - * Compile-time assertions. - * - * ASSERT_ON_COMPILE does not use the common - * switch (0) { case 0: case (e): ; } trick because some compilers (e.g. MSVC) - * generate code for it. - * - * The implementation uses both enum and typedef because the typedef alone is - * insufficient; gcc allows arrays to be declared with non-constant expressions - * (even in typedefs, where it makes no sense). - * - * NOTE: if GCC ever changes so that it ignores unused types altogether, this - * assert might not fire! We explicitly mark it as unused because GCC 4.8+ - * uses -Wunused-local-typedefs as part of -Wall, which means the typedef will - * generate a warning. - */ - -#if defined(_Static_assert) || defined(__cplusplus) || \ - !defined(__GNUC__) || __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 6) -#define ASSERT_ON_COMPILE(e) \ - do { \ - enum { AssertOnCompileMisused = ((e) ? 1 : -1) }; \ - UNUSED_TYPE(typedef char AssertOnCompileFailed[AssertOnCompileMisused]); \ - } while (0) -#else -#define ASSERT_ON_COMPILE(e) \ - do { \ - _Static_assert(e, #e); \ - } while (0); -#endif - -/* - * To put an ASSERT_ON_COMPILE() outside a function, wrap it - * in MY_ASSERTS(). The first parameter must be unique in - * each .c file where it appears. For example, - * - * MY_ASSERTS(FS3_INT, - * ASSERT_ON_COMPILE(sizeof(FS3_DiskLock) == 128); - * ASSERT_ON_COMPILE(sizeof(FS3_DiskLockReserved) == DISK_BLOCK_SIZE); - * ASSERT_ON_COMPILE(sizeof(FS3_DiskBlock) == DISK_BLOCK_SIZE); - * ASSERT_ON_COMPILE(sizeof(Hardware_DMIUUID) == 16); - * ) - * - * Caution: ASSERT() within MY_ASSERTS() is silently ignored. - * The same goes for anything else not evaluated at compile time. - */ - -#define MY_ASSERTS(name, assertions) \ - static INLINE void name(void) { \ - assertions \ - } - -#ifdef __cplusplus -} /* extern "C" */ -#endif - -#endif /* ifndef _VM_ASSERT_H_ */ diff --git a/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/sigma/vmw-guestinfo/include/vm_basic_types.h b/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/sigma/vmw-guestinfo/include/vm_basic_types.h deleted file mode 100644 index b568d597..00000000 --- a/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/sigma/vmw-guestinfo/include/vm_basic_types.h +++ /dev/null @@ -1,1186 +0,0 @@ -/********************************************************* - * Copyright (C) 1998-2015 VMware, Inc. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation version 2.1 and no later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the Lesser GNU General Public - * License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - *********************************************************/ - -/********************************************************* - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - *********************************************************/ - -/********************************************************* - * The contents of this file are subject to the terms of the Common - * Development and Distribution License (the "License") version 1.0 - * and no later version. You may not use this file except in - * compliance with the License. - * - * You can obtain a copy of the License at - * http://www.opensource.org/licenses/cddl1.php - * - * See the License for the specific language governing permissions - * and limitations under the License. - * - *********************************************************/ - -/* - * - * vm_basic_types.h -- - * - * basic data types. - */ - - -#ifndef _VM_BASIC_TYPES_H_ -#define _VM_BASIC_TYPES_H_ - -/* STRICT ANSI means the Xserver build and X defines Bool differently. */ -#if !defined(_XTYPEDEF_BOOL) && \ - (!defined(__STRICT_ANSI__) || defined(__FreeBSD__) || defined(__MINGW32__)) -#define _XTYPEDEF_BOOL -typedef char Bool; -#endif - -#ifndef FALSE -#define FALSE 0 -#endif - -#ifndef TRUE -#define TRUE 1 -#endif - -#define IsBool(x) (((x) & ~1) == 0) -#define IsBool2(x, y) ((((x) | (y)) & ~1) == 0) - -/* - * Macros __i386__ and __ia64 are intrinsically defined by GCC - */ -#if defined _MSC_VER && defined _M_X64 -# define __x86_64__ -#elif defined _MSC_VER && defined _M_IX86 -# define __i386__ -#endif - -/* - * Setup a bunch of defines for instruction set architecture (ISA) related - * properties. - * - * For compiler types/size: - * - * - VM_32BIT for a 32-bit ISA (with the same C compiler types/sizes as 32-bit - * x86/ARM). - * - VM_64BIT for a 64-bit ISA (with the same C compiler types/sizes as 64-bit - * x86/ARM). - * - * For a given <arch> in {X86, ARM}: - * - * - VM_<arch>_32 for the 32-bit variant. - * - VM_<arch>_64 for the 64-bit variant. - * - VM_<arch>_ANY for any variant of <arch>. - * - * VM_X86_ANY is synonymous with the confusing and deprecated VM_I386 (which - * should really be VM_X86_32). - */ - -#ifdef __i386__ -/* VM_I386 is historically synonymous with VM_X86_ANY in bora, but misleading, - * since it is confused with the __i386__ gcc but defined for both 32- and - * 64-bit x86. We retain it here for legacy compatibility. - */ -#define VM_I386 -#define VM_X86_32 -#define VM_X86_ANY -#define VM_32BIT -#endif - -#ifdef __x86_64__ -#define VM_X86_64 -#define VM_I386 -#define VM_X86_ANY -#define VM_64BIT -#define vm_x86_64 (1) -#else -#define vm_x86_64 (0) -#endif - -#ifdef __arm__ -#define VM_ARM_32 -#define VM_ARM_ANY -#define VM_32BIT -#endif - -#ifdef __aarch64__ -#define VM_ARM_64 -#define VM_ARM_ANY -#define VM_64BIT -#define vm_arm_64 (1) -#else -#define vm_arm_64 (0) -#endif - -#ifdef _MSC_VER - -#pragma warning (3 :4505) // unreferenced local function -#pragma warning (disable :4018) // signed/unsigned mismatch -#pragma warning (disable :4761) // integral size mismatch in argument; conversion supplied -#pragma warning (disable :4305) // truncation from 'const int' to 'short' -#pragma warning (disable :4244) // conversion from 'unsigned short' to 'unsigned char' -#pragma warning (disable :4267) // truncation of 'size_t' -#pragma warning (disable :4146) // unary minus operator applied to unsigned type, result still unsigned -#pragma warning (disable :4142) // benign redefinition of type - -#endif - -#if defined(__linux__) && defined(__cplusplus) && __cplusplus >= 201103L - -/* - * We're using stdint.h instead of cstdint below because of libstdcpp.cpp. - * It looks like a C++ file. When being preprocessed all the C++ specific - * defines(e.g. __cplusplus) are set, but the C++ include paths are not. - */ -#include <stdint.h> - -typedef char Bool; - -typedef uint64_t uint64; -typedef int64_t int64; -typedef uint32_t uint32; -typedef int32_t int32; -typedef uint16_t uint16; -typedef int16_t int16; -typedef uint8_t uint8; -typedef int8_t int8; - -typedef uint64 BA; -typedef uint64 MA; -typedef uint32 MPN32; - -#elif defined(__APPLE__) || defined(HAVE_STDINT_H) - -/* - * TODO: This is a C99 standard header. We should be able to test for - * #if __STDC_VERSION__ >= 199901L, but that breaks the Netware build - * (which doesn't have stdint.h). - */ - -#include <stdint.h> - -typedef uint64_t uint64; -typedef int64_t int64; -typedef uint32_t uint32; -typedef int32_t int32; -typedef uint16_t uint16; -typedef int16_t int16; -typedef uint8_t uint8; -typedef int8_t int8; - -/* - * Note: C does not specify whether char is signed or unsigned, and - * both gcc and msvc implement processor-specific signedness. With - * three types: - * typeof(char) != typeof(signed char) != typeof(unsigned char) - * - * Be careful here, because gcc (4.0.1 and others) likes to warn about - * conversions between signed char * and char *. - */ - -#else /* !HAVE_STDINT_H */ - -#ifdef _MSC_VER - -typedef unsigned __int64 uint64; -typedef signed __int64 int64; - -#elif __GNUC__ -/* The Xserver source compiles with -ansi -pendantic */ -# if !defined(__STRICT_ANSI__) || defined(__FreeBSD__) -# if defined(VM_X86_64) || defined(VM_ARM_64) -typedef unsigned long uint64; -typedef long int64; -# else -typedef unsigned long long uint64; -typedef long long int64; -# endif -# endif -#else -# error - Need compiler define for int64/uint64 -#endif /* _MSC_VER */ - -typedef unsigned int uint32; -typedef unsigned short uint16; -typedef unsigned char uint8; - -typedef int int32; -typedef short int16; -typedef signed char int8; - -#endif /* HAVE_STDINT_H */ - -/* - * FreeBSD (for the tools build) unconditionally defines these in - * sys/inttypes.h so don't redefine them if this file has already - * been included. [greg] - * - * This applies to Solaris as well. - */ - -/* - * Before trying to do the includes based on OS defines, see if we can use - * feature-based defines to get as much functionality as possible - */ - -#ifdef HAVE_INTTYPES_H -#include <inttypes.h> -#endif -#ifdef HAVE_SYS_TYPES_H -#include <sys/types.h> -#endif -#ifdef HAVE_SYS_INTTYPES_H -#include <sys/inttypes.h> -#endif -#ifdef HAVE_STDLIB_H -#include <stdlib.h> -#endif - -#ifdef __FreeBSD__ -#include <sys/param.h> /* For __FreeBSD_version */ -#endif - -#if !defined(USING_AUTOCONF) -# if defined(__FreeBSD__) || defined(sun) -# ifdef KLD_MODULE -# include <sys/types.h> -# else -# if __FreeBSD_version >= 500043 -# if !defined(VMKERNEL) -# include <inttypes.h> -# endif -# include <sys/types.h> -# else -# include <sys/inttypes.h> -# endif -# endif -# elif defined __APPLE__ -# if KERNEL -# include <sys/unistd.h> -# include <sys/types.h> /* mostly for size_t */ -# include <stdint.h> -# else -# include <unistd.h> -# include <inttypes.h> -# include <stdlib.h> -# include <stdint.h> -# endif -# elif defined __ANDROID__ -# include <stdint.h> -# else -# if !defined(__intptr_t_defined) && !defined(intptr_t) -# ifdef VM_I386 -# define __intptr_t_defined -# if defined(VM_X86_64) -typedef int64 intptr_t; -# else -typedef int32 intptr_t; -# endif -# elif defined(VM_ARM_64) -# define __intptr_t_defined -typedef int64 intptr_t; -# elif defined(__arm__) -# define __intptr_t_defined -typedef int32 intptr_t; -# endif -# endif - -# ifndef _STDINT_H -# ifdef VM_I386 -# if defined(VM_X86_64) -typedef uint64 uintptr_t; -# else -typedef uint32 uintptr_t; -# endif -# elif defined(VM_ARM_64) -typedef uint64 uintptr_t; -# elif defined(__arm__) -typedef uint32 uintptr_t; -# endif -# endif -# endif -#endif - - -/* - * Time - * XXX These should be cleaned up. -- edward - */ - -typedef int64 VmTimeType; /* Time in microseconds */ -typedef int64 VmTimeRealClock; /* Real clock kept in microseconds */ -typedef int64 VmTimeVirtualClock; /* Virtual Clock kept in CPU cycles */ - -/* - * Printf format specifiers for size_t and 64-bit number. - * Use them like this: - * printf("%" FMT64 "d\n", big); - * The spaces are important for C++11 compatibility. - * - * FMTH is for handles/fds. - */ - -#ifdef _MSC_VER - #define FMT64 "I64" - #ifdef VM_X86_64 - #define FMTSZ "I64" - #define FMTPD "I64" - #define FMTH "I64" - #else - #define FMTSZ "I" - #define FMTPD "I" - #define FMTH "I" - #endif -#elif defined __APPLE__ - /* Mac OS hosts use the same formatters for 32- and 64-bit. */ - #define FMT64 "ll" - #if KERNEL - #define FMTSZ "l" - #else - #define FMTSZ "z" - #endif - #define FMTPD "l" - #define FMTH "" -#elif __GNUC__ - #define FMTH "" - #if defined(N_PLAT_NLM) || defined(sun) || \ - (defined(__FreeBSD__) && (__FreeBSD__ + 0) && ((__FreeBSD__ + 0) < 5)) - /* - * Why (__FreeBSD__ + 0)? See bug 141008. - * Yes, we really need to test both (__FreeBSD__ + 0) and - * ((__FreeBSD__ + 0) < 5). No, we can't remove "+ 0" from - * ((__FreeBSD__ + 0) < 5). - */ - #if defined(VM_X86_64) || defined(VM_ARM_64) - #define FMTSZ "l" - #define FMTPD "l" - #else - #define FMTSZ "" - #define FMTPD "" - #endif - #elif defined(__linux__) \ - || (defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE >= 200112L) \ - || (defined(_POSIX_VERSION) && _POSIX_VERSION >= 200112L) \ - || (defined(_POSIX2_VERSION) && _POSIX2_VERSION >= 200112L) - /* BSD, Linux */ - #define FMTSZ "z" - - #if defined(VM_X86_64) || defined(VM_ARM_64) - #define FMTPD "l" - #else - #define FMTPD "" - #endif - #else - /* Systems with a pre-C99 libc */ - #define FMTSZ "Z" - #if defined(VM_X86_64) || defined(VM_ARM_64) - #define FMTPD "l" - #else - #define FMTPD "" - #endif - #endif - #if defined(VM_X86_64) || defined(VM_ARM_64) - #define FMT64 "l" - #elif defined(sun) || defined(__FreeBSD__) - #define FMT64 "ll" - #else - #define FMT64 "L" - #endif -#else - #error - Need compiler define for FMT64 and FMTSZ -#endif - -/* - * Suffix for 64-bit constants. Use it like this: - * CONST64(0x7fffffffffffffff) for signed or - * CONST64U(0x7fffffffffffffff) for unsigned. - * - * 2004.08.30(thutt): - * The vmcore/asm64/gen* programs are compiled as 32-bit - * applications, but must handle 64 bit constants. If the - * 64-bit-constant defining macros are already defined, the - * definition will not be overwritten. - */ - -#if !defined(CONST64) || !defined(CONST64U) -#ifdef _MSC_VER -#define CONST64(c) c##I64 -#define CONST64U(c) c##uI64 -#elif defined __APPLE__ -#define CONST64(c) c##LL -#define CONST64U(c) c##uLL -#elif __GNUC__ -#if defined(VM_X86_64) || defined(VM_ARM_64) -#define CONST64(c) c##L -#define CONST64U(c) c##uL -#else -#define CONST64(c) c##LL -#define CONST64U(c) c##uLL -#endif -#else -#error - Need compiler define for CONST64 -#endif -#endif - -/* - * Use CONST3264/CONST3264U if you want a constant to be - * treated as a 32-bit number on 32-bit compiles and - * a 64-bit number on 64-bit compiles. Useful in the case - * of shifts, like (CONST3264U(1) << x), where x could be - * more than 31 on a 64-bit compile. - */ - -#if defined(VM_X86_64) || defined(VM_ARM_64) - #define CONST3264(a) CONST64(a) - #define CONST3264U(a) CONST64U(a) -#else - #define CONST3264(a) (a) - #define CONST3264U(a) (a) -#endif - -#define MIN_INT8 ((int8)0x80) -#define MAX_INT8 ((int8)0x7f) - -#define MIN_UINT8 ((uint8)0) -#define MAX_UINT8 ((uint8)0xff) - -#define MIN_INT16 ((int16)0x8000) -#define MAX_INT16 ((int16)0x7fff) - -#define MIN_UINT16 ((uint16)0) -#define MAX_UINT16 ((uint16)0xffff) - -#define MIN_INT32 ((int32)0x80000000) -#define MAX_INT32 ((int32)0x7fffffff) - -#define MIN_UINT32 ((uint32)0) -#define MAX_UINT32 ((uint32)0xffffffff) - -#define MIN_INT64 (CONST64(0x8000000000000000)) -#define MAX_INT64 (CONST64(0x7fffffffffffffff)) - -#define MIN_UINT64 (CONST64U(0)) -#define MAX_UINT64 (CONST64U(0xffffffffffffffff)) - -typedef uint8 *TCA; /* Pointer into TC (usually). */ - -/* - * Type big enough to hold an integer between 0..100 - */ -typedef uint8 Percent; -#define AsPercent(v) ((Percent)(v)) - - -typedef uintptr_t VA; -typedef uintptr_t VPN; - -typedef uint64 PA; -typedef uint32 PPN; - -typedef uint64 TPA; -typedef uint32 TPPN; - -typedef uint64 PhysMemOff; -typedef uint64 PhysMemSize; - -/* The Xserver source compiles with -ansi -pendantic */ -#ifndef __STRICT_ANSI__ -typedef uint64 BA; -#endif - -#ifdef VMKERNEL -typedef void *BPN; -#else -typedef uint64 BPN; -#endif - -#define UINT64_2_BPN(u) ((BPN)(u)) -#define BPN_2_UINT64(b) ((uint64)(b)) - -typedef uint32 PageNum; -typedef unsigned MemHandle; -typedef unsigned int IoHandle; -typedef int32 World_ID; - -/* !! do not alter the definition of INVALID_WORLD_ID without ensuring - * that the values defined in both bora/public/vm_basic_types.h and - * lib/vprobe/vm_basic_types.h are the same. Additionally, the definition - * of VMK_INVALID_WORLD_ID in vmkapi_world.h also must be defined with - * the same value - */ - -#define INVALID_WORLD_ID ((World_ID)0) - -typedef World_ID User_CartelID; -#define INVALID_CARTEL_ID INVALID_WORLD_ID - -typedef User_CartelID User_SessionID; -#define INVALID_SESSION_ID INVALID_CARTEL_ID - -typedef User_CartelID User_CartelGroupID; -#define INVALID_CARTELGROUP_ID INVALID_CARTEL_ID - -typedef uint32 Worldlet_ID; -#define INVALID_WORLDLET_ID ((Worldlet_ID)-1) - -typedef int8 Reg8; -typedef int16 Reg16; -typedef int32 Reg32; -typedef int64 Reg64; - -typedef uint8 UReg8; -typedef uint16 UReg16; -typedef uint32 UReg32; -typedef uint64 UReg64; - -#if defined(VMM) || defined(COREQUERY) || defined(EXTDECODER) || \ - defined (VMKERNEL) || defined (VMKBOOT) -typedef Reg64 Reg; -typedef UReg64 UReg; -#endif -/* The Xserver source compiles with -ansi -pendantic */ -#ifndef __STRICT_ANSI__ -typedef uint64 MA; -typedef uint32 MPN32; -#endif - -/* - * This type should be used for variables that contain sector - * position/quantity. - */ -typedef uint64 SectorType; - -/* - * Linear address - */ - -typedef uintptr_t LA; -typedef uintptr_t LPN; -#define LA_2_LPN(_la) ((_la) >> PAGE_SHIFT) -#define LPN_2_LA(_lpn) ((_lpn) << PAGE_SHIFT) - -#define LAST_LPN ((((LA) 1) << (8 * sizeof(LA) - PAGE_SHIFT)) - 1) -#define LAST_LPN32 ((((LA32)1) << (8 * sizeof(LA32) - PAGE_SHIFT)) - 1) -#define LAST_LPN64 ((((LA64)1) << (8 * sizeof(LA64) - PAGE_SHIFT)) - 1) - -/* Valid bits in a LPN. */ -#define LPN_MASK LAST_LPN -#define LPN_MASK32 LAST_LPN32 -#define LPN_MASK64 LAST_LPN64 - -/* - * On 64 bit platform, address and page number types default - * to 64 bit. When we need to represent a 32 bit address, we use - * types defined below. - * - * On 32 bit platform, the following types are the same as the - * default types. - */ -typedef uint32 VA32; -typedef uint32 VPN32; -typedef uint32 LA32; -typedef uint32 LPN32; -typedef uint32 PA32; -typedef uint32 PPN32; - -/* - * On 64 bit platform, the following types are the same as the - * default types. - */ -typedef uint64 VA64; -typedef uint64 VPN64; -typedef uint64 LA64; -typedef uint64 LPN64; -typedef uint64 PA64; -typedef uint64 PPN64; -typedef uint64 MA64; -typedef uint64 MPN; - -/* - * IO device DMA virtual address and page number (translated by IOMMU to - * MA/MPN). IOPN can be in the inclusive range 0 -> MAX_IOPN. - */ -typedef uint64 IOA; -typedef uint64 IOPN; - -/* - * VA typedefs for user world apps. - */ -typedef VA32 UserVA32; -typedef VA64 UserVA64; -typedef UserVA64 UserVAConst; /* Userspace ptr to data that we may only read. */ -typedef UserVA32 UserVA32Const; /* Userspace ptr to data that we may only read. */ -typedef UserVA64 UserVA64Const; /* Used by 64-bit syscalls until conversion is finished. */ -#ifdef VMKERNEL -typedef UserVA64 UserVA; -#else -typedef void * UserVA; -#endif - - -#define MAX_PPN_BITS 31 -#define MAX_PPN (((PPN)1 << MAX_PPN_BITS) - 1) /* Maximal observable PPN value. */ -#define INVALID_PPN ((PPN)0xffffffff) -#define APIC_INVALID_PPN ((PPN)0xfffffffe) - -#define INVALID_BPN ((BPN)0x000000ffffffffffull) - -#define MPN38_MASK ((1ull << 38) - 1) - -#define RESERVED_MPN ((MPN)0) -#define INVALID_MPN ((MPN)MPN38_MASK) -#define MEMREF_MPN ((MPN)MPN38_MASK - 1) -#define RELEASED_MPN ((MPN)MPN38_MASK - 2) - -/* account for special MPNs defined above */ -#define MAX_MPN ((MPN)MPN38_MASK - 3) /* 50 bits of address space */ - -#define INVALID_IOPN ((IOPN)-1) -#define MAX_IOPN (INVALID_IOPN - 1) - -#define INVALID_LPN ((LPN)-1) -#define INVALID_VPN ((VPN)-1) -#define INVALID_LPN64 ((LPN64)-1) -#define INVALID_PAGENUM ((PageNum)-1) - -/* - * Format modifier for printing VA, LA, and VPN. - * Use them like this: Log("%#" FMTLA "x\n", laddr) - */ - -#if defined(VMM) || defined(FROBOS64) || vm_x86_64 || vm_arm_64 || defined __APPLE__ -# define FMTLA "l" -# define FMTVA "l" -# define FMTVPN "l" -#else -# define FMTLA "" -# define FMTVA "" -# define FMTVPN "" -#endif - -#ifndef EXTERN -#define EXTERN extern -#endif -#define CONST const - - -#ifndef INLINE -# ifdef _MSC_VER -# define INLINE __inline -# else -# define INLINE inline -# endif -#endif - - -/* - * Annotation for data that may be exported into a DLL and used by other - * apps that load that DLL and import the data. - */ -#if defined(_WIN32) && defined(VMX86_IMPORT_DLLDATA) -# define VMX86_EXTERN_DATA extern __declspec(dllimport) -#else // !_WIN32 -# define VMX86_EXTERN_DATA extern -#endif - -#ifdef _WIN32 - -/* under windows, __declspec(thread) is supported since VS 2003 */ -#define __thread __declspec(thread) - -#else - -/* - * under other platforms instead, __thread is supported by gcc since - * version 3.3.1 and by clang since version 3.x - */ - -#endif - - -/* - * Due to the wonderful "registry redirection" feature introduced in - * 64-bit Windows, if you access any key under HKLM\Software in 64-bit - * code, you need to open/create/delete that key with - * VMKEY_WOW64_32KEY if you want a consistent view with 32-bit code. - */ - -#ifdef _WIN32 -#ifdef _WIN64 -#define VMW_KEY_WOW64_32KEY KEY_WOW64_32KEY -#else -#define VMW_KEY_WOW64_32KEY 0x0 -#endif -#endif - - -/* - * At present, we effectively require a compiler that is at least - * gcc-3.3 (circa 2003). Enforce this here, various things below - * this line depend upon it. - * - * In practice, most things presently compile with gcc-4.1 or gcc-4.4. - * The various linux kernel modules may use older (gcc-3.3) compilers. - */ -#if defined __GNUC__ && (__GNUC__ < 3 || (__GNUC__ == 3 && __GNUC_MINOR__ < 3)) -#error "gcc version is too old to compile assembly, need gcc-3.3 or better" -#endif - - -/* - * Consider the following reasons functions are inlined: - * - * 1) inlined for performance reasons - * 2) inlined because it's a single-use function - * - * Functions which meet only condition 2 should be marked with this - * inline macro; It is not critical to be inlined (but there is a - * code-space & runtime savings by doing so), so when other callers - * are added the inline-ness should be removed. - */ - -#if defined __GNUC__ -/* - * Starting at version 3.3, gcc does not always inline functions marked - * 'inline' (it depends on their size and other factors). To force gcc - * to inline a function, one must use the __always_inline__ attribute. - * This attribute should be used sparingly and with care. It is usually - * preferable to let gcc make its own inlining decisions - */ -# define INLINE_ALWAYS INLINE __attribute__((__always_inline__)) -#else -# define INLINE_ALWAYS INLINE -#endif -#define INLINE_SINGLE_CALLER INLINE_ALWAYS - -/* - * Used when a hard guaranteed of no inlining is needed. Very few - * instances need this since the absence of INLINE is a good hint - * that gcc will not do inlining. - */ - -#if defined(__GNUC__) -#define ABSOLUTELY_NOINLINE __attribute__((__noinline__)) -#elif defined(_MSC_VER) -#define ABSOLUTELY_NOINLINE __declspec(noinline) -#endif - -/* - * Used when a function has no effects except the return value and the - * return value depends only on the parameters and/or global variables - * Such a function can be subject to common subexpression elimination - * and loop optimization just as an arithmetic operator would be. - */ - -#if defined(__GNUC__) && (defined(VMM) || defined (VMKERNEL)) -#define SIDE_EFFECT_FREE __attribute__((__pure__)) -#else -#define SIDE_EFFECT_FREE -#endif - -/* - * Used when a function exmaines no input other than its arguments and - * has no side effects other than its return value. Stronger than - * SIDE_EFFECT_FREE as the function is not allowed to read from global - * memory. - */ - -#if defined(__GNUC__) && (defined(VMM) || defined (VMKERNEL)) -#define CONST_FUNCTION __attribute__((__const__)) -#else -#define CONST_FUNCTION -#endif - -/* - * Attributes placed on function declarations to tell the compiler - * that the function never returns. - */ - -#ifdef _MSC_VER -#define NORETURN __declspec(noreturn) -#elif defined __GNUC__ -#define NORETURN __attribute__((__noreturn__)) -#else -#define NORETURN -#endif - -/* - * Static profiling hints for functions. - * A function can be either hot, cold, or neither. - * It is an error to specify both hot and cold for the same function. - * Note that there is no annotation for "neither." - */ - -#if defined __GNUC__ && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)) -#define HOT __attribute__((hot)) -#define COLD __attribute__((cold)) -#else -#define HOT -#define COLD -#endif - -/* - * Branch prediction hints: - * LIKELY(exp) - Expression exp is likely TRUE. - * UNLIKELY(exp) - Expression exp is likely FALSE. - * Usage example: - * if (LIKELY(excCode == EXC_NONE)) { - * or - * if (UNLIKELY(REAL_MODE(vc))) { - * - * We know how to predict branches on gcc3 and later (hopefully), - * all others we don't so we do nothing. - */ - -#if defined __GNUC__ -/* - * gcc3 uses __builtin_expect() to inform the compiler of an expected value. - * We use this to inform the static branch predictor. The '!!' in LIKELY - * will convert any !=0 to a 1. - */ -#define LIKELY(_exp) __builtin_expect(!!(_exp), 1) -#define UNLIKELY(_exp) __builtin_expect((_exp), 0) -#else -#define LIKELY(_exp) (_exp) -#define UNLIKELY(_exp) (_exp) -#endif - -/* - * GCC's argument checking for printf-like functions - * This is conditional until we have replaced all `"%x", void *' - * with `"0x%08x", (uint32) void *'. Note that %p prints different things - * on different platforms. Argument checking is enabled for the - * vmkernel, which has already been cleansed. - * - * fmtPos is the position of the format string argument, beginning at 1 - * varPos is the position of the variable argument, beginning at 1 - */ - -#if defined(__GNUC__) -# define PRINTF_DECL(fmtPos, varPos) __attribute__((__format__(__printf__, fmtPos, varPos))) -#else -# define PRINTF_DECL(fmtPos, varPos) -#endif - -#if defined(__GNUC__) -# define SCANF_DECL(fmtPos, varPos) __attribute__((__format__(__scanf__, fmtPos, varPos))) -#else -# define SCANF_DECL(fmtPos, varPos) -#endif - -/* - * UNUSED_PARAM should surround the parameter name and type declaration, - * e.g. "int MyFunction(int var1, UNUSED_PARAM(int var2))" - * - */ - -#ifndef UNUSED_PARAM -# if defined(__GNUC__) -# define UNUSED_PARAM(_parm) _parm __attribute__((__unused__)) -# else -# define UNUSED_PARAM(_parm) _parm -# endif -#endif - -#ifndef UNUSED_TYPE -// XXX _Pragma would better but doesn't always work right now. -# define UNUSED_TYPE(_parm) UNUSED_PARAM(_parm) -#endif - -#ifndef UNUSED_VARIABLE -// XXX is there a better way? -# define UNUSED_VARIABLE(_var) (void)_var -#endif - -/* - * gcc can warn us if we're ignoring returns - */ -#if defined(__GNUC__) -# define MUST_CHECK_RETURN __attribute__((warn_unused_result)) -#else -# define MUST_CHECK_RETURN -#endif - -/* - * ALIGNED specifies minimum alignment in "n" bytes. - */ - -#ifdef __GNUC__ -#define ALIGNED(n) __attribute__((__aligned__(n))) -#else -#define ALIGNED(n) -#endif - -/* - * Once upon a time, this was used to silence compiler warnings that - * get generated when the compiler thinks that a function returns - * when it is marked noreturn. Don't do it. Use NOT_REACHED(). - */ - -#define INFINITE_LOOP() do { } while (1) - -/* - * On FreeBSD (for the tools build), size_t is typedef'd if _BSD_SIZE_T_ - * is defined. Use the same logic here so we don't define it twice. [greg] - */ -#ifdef __FreeBSD__ -# ifdef _BSD_SIZE_T_ -# undef _BSD_SIZE_T_ -# ifdef VM_I386 -# ifdef VM_X86_64 - typedef uint64 size_t; -# else - typedef uint32 size_t; -# endif -# endif /* VM_I386 */ -# endif - -# ifdef _BSD_SSIZE_T_ -# undef _BSD_SSIZE_T_ -# ifdef VM_I386 -# ifdef VM_X86_64 - typedef int64 ssize_t; -# else - typedef int32 ssize_t; -# endif -# endif /* VM_I386 */ -# endif - -#else -# if !defined(_SIZE_T) && !defined(_SIZE_T_DEFINED) -# ifdef VM_I386 -# define _SIZE_T -# ifdef VM_X86_64 - typedef uint64 size_t; -# else - typedef uint32 size_t; -# endif -# elif defined(VM_ARM_64) -# define _SIZE_T - typedef uint64 size_t; -# elif defined(__arm__) -# define _SIZE_T - typedef uint32 size_t; -# endif -# endif - -# if !defined(FROBOS) && !defined(_SSIZE_T) && !defined(_SSIZE_T_) && \ - !defined(ssize_t) && !defined(__ssize_t_defined) && \ - !defined(_SSIZE_T_DECLARED) && !defined(_SSIZE_T_DEFINED) && \ - !defined(_SSIZE_T_DEFINED_) -# ifdef VM_I386 -# define _SSIZE_T -# define __ssize_t_defined -# define _SSIZE_T_DECLARED -# define _SSIZE_T_DEFINED_ -# ifdef VM_X86_64 - typedef int64 ssize_t; -# else - typedef int32 ssize_t; -# endif -# elif defined(VM_ARM_64) -# define _SSIZE_T -# define __ssize_t_defined -# define _SSIZE_T_DECLARED -# define _SSIZE_T_DEFINED_ - typedef int64 ssize_t; -# elif defined(__arm__) -# define _SSIZE_T -# define __ssize_t_defined -# define _SSIZE_T_DECLARED -# define _SSIZE_T_DEFINED_ - typedef int32 ssize_t; -# endif -# endif - -#endif - -/* - * Format modifier for printing pid_t. On sun the pid_t is a ulong, but on - * Linux it's an int. - * Use this like this: printf("The pid is %" FMTPID ".\n", pid); - */ -#ifdef sun -# ifdef VM_X86_64 -# define FMTPID "d" -# else -# define FMTPID "lu" -# endif -#else -# define FMTPID "d" -#endif - -/* - * Format modifier for printing uid_t. On Solaris 10 and earlier, uid_t - * is a ulong, but on other platforms it's an unsigned int. - * Use this like this: printf("The uid is %" FMTUID ".\n", uid); - */ -#if defined(sun) && !defined(SOL11) -# ifdef VM_X86_64 -# define FMTUID "u" -# else -# define FMTUID "lu" -# endif -#else -# define FMTUID "u" -#endif - -/* - * Format modifier for printing mode_t. On sun the mode_t is a ulong, but on - * Linux it's an int. - * Use this like this: printf("The mode is %" FMTMODE ".\n", mode); - */ -#ifdef sun -# ifdef VM_X86_64 -# define FMTMODE "o" -# else -# define FMTMODE "lo" -# endif -#else -# define FMTMODE "o" -#endif - -/* - * Format modifier for printing time_t. Most platforms define a time_t to be - * a long int, but on FreeBSD (as of 5.0, it seems), the time_t is a signed - * size quantity. Refer to the definition of FMTSZ to see why we need silly - * preprocessor arithmetic. - * Use this like this: printf("The mode is %" FMTTIME ".\n", time); - */ -#if defined(__FreeBSD__) && (__FreeBSD__ + 0) && ((__FreeBSD__ + 0) >= 5) -# define FMTTIME FMTSZ"d" -#else -# if defined(_MSC_VER) -# ifndef _SAFETIME_H_ -# if (_MSC_VER < 1400) || defined(_USE_32BIT_TIME_T) -# define FMTTIME "ld" -# else -# define FMTTIME FMT64"d" -# endif -# else -# ifndef FMTTIME -# error "safetime.h did not define FMTTIME" -# endif -# endif -# else -# define FMTTIME "ld" -# endif -#endif - -#ifdef __APPLE__ -/* - * Format specifier for all these annoying types such as {S,U}Int32 - * which are 'long' in 32-bit builds - * and 'int' in 64-bit builds. - */ -# ifdef __LP64__ -# define FMTLI "" -# else -# define FMTLI "l" -# endif - -/* - * Format specifier for all these annoying types such as NS[U]Integer - * which are 'int' in 32-bit builds - * and 'long' in 64-bit builds. - */ -# ifdef __LP64__ -# define FMTIL "l" -# else -# define FMTIL "" -# endif -#endif - - -/* - * Define MXSemaHandle here so both vmmon and vmx see this definition. - */ - -#ifdef _WIN32 -typedef uintptr_t MXSemaHandle; -#else -typedef int MXSemaHandle; -#endif - -/* - * Define type for poll device handles. - */ - -typedef int64 PollDevHandle; - -/* - * Define the utf16_t type. - */ - -#if defined(_WIN32) && defined(_NATIVE_WCHAR_T_DEFINED) -typedef wchar_t utf16_t; -#else -typedef uint16 utf16_t; -#endif - -/* - * Define for point and rectangle types. Defined here so they - * can be used by other externally facing headers in bora/public. - */ - -typedef struct VMPoint { - int x, y; -} VMPoint; - -#if defined _WIN32 && defined USERLEVEL -struct tagRECT; -typedef struct tagRECT VMRect; -#else -typedef struct VMRect { - int left; - int top; - int right; - int bottom; -} VMRect; -#endif - -/* - * ranked locks "everywhere" - */ - -typedef uint32 MX_Rank; - -#endif /* _VM_BASIC_TYPES_H_ */ diff --git a/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/sigma/vmw-guestinfo/include/vmware.h b/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/sigma/vmw-guestinfo/include/vmware.h deleted file mode 100644 index 02e08a16..00000000 --- a/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/sigma/vmw-guestinfo/include/vmware.h +++ /dev/null @@ -1,87 +0,0 @@ -/********************************************************* - * Copyright (C) 2003-2015 VMware, Inc. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation version 2.1 and no later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the Lesser GNU General Public - * License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - *********************************************************/ - -/********************************************************* - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - *********************************************************/ - -/********************************************************* - * The contents of this file are subject to the terms of the Common - * Development and Distribution License (the "License") version 1.0 - * and no later version. You may not use this file except in - * compliance with the License. - * - * You can obtain a copy of the License at - * http://www.opensource.org/licenses/cddl1.php - * - * See the License for the specific language governing permissions - * and limitations under the License. - * - *********************************************************/ - -/* - * vmware.h -- - * - * Standard include file for VMware source code. - */ - -#ifndef _VMWARE_H_ -#define _VMWARE_H_ - -#include "vm_basic_types.h" -#include "vm_basic_defs.h" -#include "vm_assert.h" - -/* - * Global error codes. Currently used internally, but may be exported - * to customers one day, like VM_E_XXX in vmcontrol_constants.h - */ - -typedef enum VMwareStatus { - VMWARE_STATUS_SUCCESS, /* success */ - VMWARE_STATUS_ERROR, /* generic error */ - VMWARE_STATUS_NOMEM, /* generic memory allocation error */ - VMWARE_STATUS_INSUFFICIENT_RESOURCES, /* internal or system resource limit exceeded */ - VMWARE_STATUS_INVALID_ARGS /* invalid arguments */ -} VMwareStatus; - -#define VMWARE_SUCCESS(s) ((s) == VMWARE_STATUS_SUCCESS) - - -#endif // ifndef _VMWARE_H_ diff --git a/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/sigma/vmw-guestinfo/message/message.go b/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/sigma/vmw-guestinfo/message/message.go deleted file mode 100644 index e61359a9..00000000 --- a/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/sigma/vmw-guestinfo/message/message.go +++ /dev/null @@ -1,57 +0,0 @@ -package message - -import ( - "errors" - - "github.com/sigma/vmw-guestinfo/bridge" -) - -var ( - // ErrChannelOpen represents a failure to open a channel - ErrChannelOpen = errors.New("could not open channel") - // ErrChannelClose represents a failure to close a channel - ErrChannelClose = errors.New("could not close channel") - // ErrRpciSend represents a failure to send a message - ErrRpciSend = errors.New("unable to send RPCI command") - // ErrRpciReceive represents a failure to receive a message - ErrRpciReceive = errors.New("unable to receive RPCI command result") -) - -// Channel is a communication channel between hypervisor and virtual machine -type Channel struct { - privChan bridge.MessageChannel -} - -// NewChannel opens a new channel -func NewChannel(proto uint32) (*Channel, error) { - if channel := bridge.MessageOpen(proto); channel != nil { - return &Channel{ - privChan: channel, - }, nil - } - return nil, ErrChannelOpen -} - -// Close the channel -func (c *Channel) Close() error { - if status := bridge.MessageClose(bridge.MessageChannel(c.privChan)); status { - return nil - } - return ErrChannelClose -} - -// Send a request -func (c *Channel) Send(request []byte) error { - if status := bridge.MessageSend(bridge.MessageChannel(c.privChan), request); status { - return nil - } - return ErrRpciSend -} - -// Receive a response -func (c *Channel) Receive() ([]byte, error) { - if res, status := bridge.MessageReceive(bridge.MessageChannel(c.privChan)); status { - return res, nil - } - return nil, ErrRpciReceive -} diff --git a/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/sigma/vmw-guestinfo/rpcout/rpcout.go b/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/sigma/vmw-guestinfo/rpcout/rpcout.go deleted file mode 100644 index 294edd1a..00000000 --- a/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/sigma/vmw-guestinfo/rpcout/rpcout.go +++ /dev/null @@ -1,79 +0,0 @@ -package rpcout - -import ( - "errors" - "fmt" - - "github.com/sigma/vmw-guestinfo/message" -) - -// ErrRpciFormat represents an invalid result format -var ErrRpciFormat = errors.New("invalid format for RPCI command result") - -const rpciProtocolNum uint32 = 0x49435052 - -// SendOne is a command-oriented wrapper for SendOneRaw -func SendOne(format string, a ...interface{}) (reply []byte, ok bool, err error) { - request := fmt.Sprintf(format, a...) - return SendOneRaw([]byte(request)) -} - -// SendOneRaw uses a throw-away RPCOut to send a request -func SendOneRaw(request []byte) (reply []byte, ok bool, err error) { - out := &RPCOut{} - if err = out.Start(); err != nil { - return - } - if reply, ok, err = out.Send(request); err != nil { - return - } - if err = out.Stop(); err != nil { - return - } - return -} - -// RPCOut is an ougoing connection from the VM to the hypervisor -type RPCOut struct { - channel *message.Channel -} - -// Start opens the connection -func (out *RPCOut) Start() error { - channel, err := message.NewChannel(rpciProtocolNum) - if err != nil { - return err - } - out.channel = channel - return nil -} - -// Stop closes the connection -func (out *RPCOut) Stop() error { - err := out.channel.Close() - out.channel = nil - return err -} - -// Send emits a request and receives a response -func (out *RPCOut) Send(request []byte) (reply []byte, ok bool, err error) { - if err = out.channel.Send(request); err != nil { - return - } - - var resp []byte - if resp, err = out.channel.Receive(); err != nil { - return - } - - switch string(resp[:2]) { - case "0 ": - reply = resp[2:] - case "1 ": - reply = resp[2:] - ok = true - default: - err = ErrRpciFormat - } - return -} diff --git a/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/sigma/vmw-guestinfo/rpcvmx/rpcvmx.go b/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/sigma/vmw-guestinfo/rpcvmx/rpcvmx.go deleted file mode 100644 index 50330b5c..00000000 --- a/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/sigma/vmw-guestinfo/rpcvmx/rpcvmx.go +++ /dev/null @@ -1,72 +0,0 @@ -package rpcvmx - -import ( - "fmt" - "strconv" - - "github.com/sigma/vmw-guestinfo/rpcout" -) - -// Config gives access to the vmx config through the VMware backdoor -type Config struct{} - -// NewConfig creates a new Config object -func NewConfig() *Config { - return &Config{} -} - -// String returns the config string in the guestinfo.* namespace -func (c *Config) String(key string, defaultValue string) (string, error) { - out, ok, err := rpcout.SendOne("info-get guestinfo.%s", key) - if err != nil { - return "", err - } else if !ok { - return defaultValue, nil - } - return string(out), nil -} - -// Bool returns the config boolean in the guestinfo.* namespace -func (c *Config) Bool(key string, defaultValue bool) (bool, error) { - val, err := c.String(key, fmt.Sprintf("%t", defaultValue)) - if err != nil { - return false, err - } - res, err := strconv.ParseBool(val) - if err != nil { - return defaultValue, nil - } - return res, nil -} - -// Int returns the config integer in the guestinfo.* namespace -func (c *Config) Int(key string, defaultValue int) (int, error) { - val, err := c.String(key, "") - if err != nil { - return 0, err - } - res, err := strconv.Atoi(val) - if err != nil { - return defaultValue, nil - } - return res, nil -} - -// SetString sets the guestinfo.KEY with the string VALUE -func (c *Config) SetString(key string, value string) error { - _, _, err := rpcout.SendOne("info-set guestinfo.%s %s", key, value) - if err != nil { - return err - } - return nil -} - -// SetString sets the guestinfo.KEY with the bool VALUE -func (c *Config) SetBool(key string, value bool) error { - return c.SetString(key, strconv.FormatBool(value)) -} - -// SetString sets the guestinfo.KEY with the int VALUE -func (c *Config) SetInt(key string, value int) error { - return c.SetString(key, strconv.Itoa(value)) -} diff --git a/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/sigma/vmw-guestinfo/vmcheck/vmcheck.go b/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/sigma/vmw-guestinfo/vmcheck/vmcheck.go deleted file mode 100644 index ef3733dd..00000000 --- a/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/sigma/vmw-guestinfo/vmcheck/vmcheck.go +++ /dev/null @@ -1,10 +0,0 @@ -package vmcheck - -import ( - "github.com/sigma/bdoor" -) - -// IsVirtualWorld returns whether the code is running in a VMware virtual machine or no -func IsVirtualWorld() bool { - return bdoor.HypervisorPortCheck() -} diff --git a/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/sigma/vmw-ovflib/README b/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/sigma/vmw-ovflib/README deleted file mode 100644 index 0ae7be7c..00000000 --- a/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/sigma/vmw-ovflib/README +++ /dev/null @@ -1 +0,0 @@ -minimal support for parsing OVF environment diff --git a/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/sigma/vmw-ovflib/ovf.go b/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/sigma/vmw-ovflib/ovf.go deleted file mode 100644 index ad4228ee..00000000 --- a/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/sigma/vmw-ovflib/ovf.go +++ /dev/null @@ -1,42 +0,0 @@ -package ovf - -import ( - "encoding/xml" - "log" -) - -type environment struct { - Platform platform `xml:"PlatformSection"` - Properties []property `xml:"PropertySection>Property"` -} - -type platform struct { - Kind string `xml:"Kind"` - Version string `xml:"Version"` - Vendor string `xml:"Vendor"` - Locale string `xml:"Locale"` -} - -type property struct { - Key string `xml:"key,attr"` - Value string `xml:"value,attr"` -} - -type OvfEnvironment struct { - Platform platform - Properties map[string]string -} - -func ReadEnvironment(doc []byte) *OvfEnvironment { - var env environment - if err := xml.Unmarshal(doc, &env); err != nil { - log.Fatalln(err) - } - - dict := make(map[string]string) - for _, p := range env.Properties { - dict[p.Key] = p.Value - } - return &OvfEnvironment{Properties: dict, - Platform: env.Platform} -} diff --git a/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/sigma/vmw-ovflib/ovf_test.go b/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/sigma/vmw-ovflib/ovf_test.go deleted file mode 100644 index 690e70cf..00000000 --- a/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/sigma/vmw-ovflib/ovf_test.go +++ /dev/null @@ -1,110 +0,0 @@ -package ovf - -import ( - "testing" - - . "github.com/smartystreets/goconvey/convey" -) - -var data_vsphere = []byte(`<?xml version="1.0" encoding="UTF-8"?> -<Environment - xmlns="http://schemas.dmtf.org/ovf/environment/1" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xmlns:oe="http://schemas.dmtf.org/ovf/environment/1" - xmlns:ve="http://www.vmware.com/schema/ovfenv" - oe:id="" - ve:vCenterId="vm-12345"> - <PlatformSection> - <Kind>VMware ESXi</Kind> - <Version>5.5.0</Version> - <Vendor>VMware, Inc.</Vendor> - <Locale>en</Locale> - </PlatformSection> - <PropertySection> - <Property oe:key="foo" oe:value="42"/> - <Property oe:key="bar" oe:value="0"/> - </PropertySection> - <ve:EthernetAdapterSection> - <ve:Adapter ve:mac="00:00:00:00:00:00" ve:network="foo" ve:unitNumber="7"/> - </ve:EthernetAdapterSection> -</Environment>`) - -var data_vapprun = []byte(`<?xml version="1.0" encoding="UTF-8"?> -<Environment xmlns="http://schemas.dmtf.org/ovf/environment/1" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xmlns:oe="http://schemas.dmtf.org/ovf/environment/1" - oe:id="CoreOS-vmw"> - <PlatformSection> - <Kind>vapprun</Kind> - <Version>1.0</Version> - <Vendor>VMware, Inc.</Vendor> - <Locale>en_US</Locale> - </PlatformSection> - <PropertySection> - <Property oe:key="foo" oe:value="42"/> - <Property oe:key="bar" oe:value="0"/> - <Property oe:key="guestinfo.user_data.url" oe:value="https://gist.githubusercontent.com/sigma/5a64aac1693da9ca70d2/raw/plop.yaml"/> - <Property oe:key="guestinfo.user_data.doc" oe:value=""/> - <Property oe:key="guestinfo.meta_data.url" oe:value=""/> - <Property oe:key="guestinfo.meta_data.doc" oe:value=""/> - </PropertySection> -</Environment>`) - -func TestOvfEnvProperties(t *testing.T) { - - var testerFunc = func(env_str []byte) func() { - return func() { - env := ReadEnvironment(env_str) - props := env.Properties - - var val string - var ok bool - Convey(`Property "foo"`, func() { - val, ok = props["foo"] - So(ok, ShouldBeTrue) - So(val, ShouldEqual, "42") - }) - - Convey(`Property "bar"`, func() { - val, ok = props["bar"] - So(ok, ShouldBeTrue) - So(val, ShouldEqual, "0") - }) - } - } - - Convey("With vAppRun environment", t, testerFunc(data_vapprun)) - Convey("With vSphere environment", t, testerFunc(data_vsphere)) -} - -func TestOvfEnvPlatform(t *testing.T) { - Convey("With vSphere environment", t, func() { - env := ReadEnvironment(data_vsphere) - platform := env.Platform - - So(platform.Kind, ShouldEqual, "VMware ESXi") - So(platform.Version, ShouldEqual, "5.5.0") - So(platform.Vendor, ShouldEqual, "VMware, Inc.") - So(platform.Locale, ShouldEqual, "en") - }) -} - -func TestVappRunUserDataUrl(t *testing.T) { - Convey("With vAppRun environment", t, func() { - env := ReadEnvironment(data_vapprun) - props := env.Properties - - var val string - var ok bool - - val, ok = props["guestinfo.user_data.url"] - So(ok, ShouldBeTrue) - So(val, ShouldEqual, "https://gist.githubusercontent.com/sigma/5a64aac1693da9ca70d2/raw/plop.yaml") - }) -} - -func TestInvalidData(t *testing.T) { - Convey("With invalid data", t, func() { - ReadEnvironment(append(data_vsphere, []byte("garbage")...)) - }) -} diff --git a/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/tarm/goserial/LICENSE b/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/tarm/goserial/LICENSE deleted file mode 100644 index 6a66aea5..00000000 --- a/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/tarm/goserial/LICENSE +++ /dev/null @@ -1,27 +0,0 @@ -Copyright (c) 2009 The Go Authors. All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - - * Redistributions of source code must retain the above copyright -notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above -copyright notice, this list of conditions and the following disclaimer -in the documentation and/or other materials provided with the -distribution. - * Neither the name of Google Inc. nor the names of its -contributors may be used to endorse or promote products derived from -this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/tarm/goserial/README.md b/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/tarm/goserial/README.md deleted file mode 100644 index becec661..00000000 --- a/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/tarm/goserial/README.md +++ /dev/null @@ -1,63 +0,0 @@ -GoSerial -======== -A simple go package to allow you to read and write from the -serial port as a stream of bytes. - -Details -------- -It aims to have the same API on all platforms, including windows. As -an added bonus, the windows package does not use cgo, so you can cross -compile for windows from another platform. Unfortunately goinstall -does not currently let you cross compile so you will have to do it -manually: - - GOOS=windows make clean install - -Currently there is very little in the way of configurability. You can -set the baud rate. Then you can Read(), Write(), or Close() the -connection. Read() will block until at least one byte is returned. -Write is the same. There is currently no exposed way to set the -timeouts, though patches are welcome. - -Currently all ports are opened with 8 data bits, 1 stop bit, no -parity, no hardware flow control, and no software flow control. This -works fine for many real devices and many faux serial devices -including usb-to-serial converters and bluetooth serial ports. - -You may Read() and Write() simulantiously on the same connection (from -different goroutines). - -Usage ------ -```go -package main - -import ( - "github.com/tarm/goserial" - "log" -) - -func main() { - c := &serial.Config{Name: "COM45", Baud: 115200} - s, err := serial.OpenPort(c) - if err != nil { - log.Fatal(err) - } - - n, err := s.Write([]byte("test")) - if err != nil { - log.Fatal(err) - } - - buf := make([]byte, 128) - n, err = s.Read(buf) - if err != nil { - log.Fatal(err) - } - log.Print("%q", buf[:n]) -} -``` - -Possible Future Work --------------------- -- better tests (loopback etc) diff --git a/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/tarm/goserial/basic_test.go b/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/tarm/goserial/basic_test.go deleted file mode 100644 index 3a722248..00000000 --- a/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/tarm/goserial/basic_test.go +++ /dev/null @@ -1,61 +0,0 @@ -package serial - -import ( - "testing" - "time" -) - -func TestConnection(t *testing.T) { - c0 := &Config{Name: "/dev/ttyUSB0", Baud: 115200} - c1 := &Config{Name: "/dev/ttyUSB1", Baud: 115200} - - s1, err := OpenPort(c0) - if err != nil { - t.Fatal(err) - } - - s2, err := OpenPort(c1) - if err != nil { - t.Fatal(err) - } - - ch := make(chan int, 1) - go func() { - buf := make([]byte, 128) - var readCount int - for { - n, err := s2.Read(buf) - if err != nil { - t.Fatal(err) - } - readCount++ - t.Logf("Read %v %v bytes: % 02x %s", readCount, n, buf[:n], buf[:n]) - select { - case <-ch: - ch <- readCount - close(ch) - default: - } - } - }() - - if _, err = s1.Write([]byte("hello")); err != nil { - t.Fatal(err) - } - if _, err = s1.Write([]byte(" ")); err != nil { - t.Fatal(err) - } - time.Sleep(time.Second) - if _, err = s1.Write([]byte("world")); err != nil { - t.Fatal(err) - } - time.Sleep(time.Second / 10) - - ch <- 0 - s1.Write([]byte(" ")) // We could be blocked in the read without this - c := <-ch - exp := 5 - if c >= exp { - t.Fatalf("Expected less than %v read, got %v", exp, c) - } -} diff --git a/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/tarm/goserial/serial.go b/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/tarm/goserial/serial.go deleted file mode 100644 index 7a404be8..00000000 --- a/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/tarm/goserial/serial.go +++ /dev/null @@ -1,99 +0,0 @@ -/* -Goserial is a simple go package to allow you to read and write from -the serial port as a stream of bytes. - -It aims to have the same API on all platforms, including windows. As -an added bonus, the windows package does not use cgo, so you can cross -compile for windows from another platform. Unfortunately goinstall -does not currently let you cross compile so you will have to do it -manually: - - GOOS=windows make clean install - -Currently there is very little in the way of configurability. You can -set the baud rate. Then you can Read(), Write(), or Close() the -connection. Read() will block until at least one byte is returned. -Write is the same. There is currently no exposed way to set the -timeouts, though patches are welcome. - -Currently all ports are opened with 8 data bits, 1 stop bit, no -parity, no hardware flow control, and no software flow control. This -works fine for many real devices and many faux serial devices -including usb-to-serial converters and bluetooth serial ports. - -You may Read() and Write() simulantiously on the same connection (from -different goroutines). - -Example usage: - - package main - - import ( - "github.com/tarm/goserial" - "log" - ) - - func main() { - c := &serial.Config{Name: "COM5", Baud: 115200} - s, err := serial.OpenPort(c) - if err != nil { - log.Fatal(err) - } - - n, err := s.Write([]byte("test")) - if err != nil { - log.Fatal(err) - } - - buf := make([]byte, 128) - n, err = s.Read(buf) - if err != nil { - log.Fatal(err) - } - log.Print("%q", buf[:n]) - } -*/ -package serial - -import "io" - -// Config contains the information needed to open a serial port. -// -// Currently few options are implemented, but more may be added in the -// future (patches welcome), so it is recommended that you create a -// new config addressing the fields by name rather than by order. -// -// For example: -// -// c0 := &serial.Config{Name: "COM45", Baud: 115200} -// or -// c1 := new(serial.Config) -// c1.Name = "/dev/tty.usbserial" -// c1.Baud = 115200 -// -type Config struct { - Name string - Baud int - - // Size int // 0 get translated to 8 - // Parity SomeNewTypeToGetCorrectDefaultOf_None - // StopBits SomeNewTypeToGetCorrectDefaultOf_1 - - // RTSFlowControl bool - // DTRFlowControl bool - // XONFlowControl bool - - // CRLFTranslate bool - // TimeoutStuff int -} - -// OpenPort opens a serial port with the specified configuration -func OpenPort(c *Config) (io.ReadWriteCloser, error) { - return openPort(c.Name, c.Baud) -} - -// func Flush() - -// func SendBreak() - -// func RegisterBreakHandler(func()) diff --git a/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/tarm/goserial/serial_linux.go b/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/tarm/goserial/serial_linux.go deleted file mode 100644 index 2366f2c5..00000000 --- a/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/tarm/goserial/serial_linux.go +++ /dev/null @@ -1,90 +0,0 @@ -// +build linux,!cgo - -package serial - -import ( - "io" - "os" - "syscall" - "unsafe" -) - -func openPort(name string, baud int) (rwc io.ReadWriteCloser, err error) { - - var bauds = map[int]uint32{ - 50: syscall.B50, - 75: syscall.B75, - 110: syscall.B110, - 134: syscall.B134, - 150: syscall.B150, - 200: syscall.B200, - 300: syscall.B300, - 600: syscall.B600, - 1200: syscall.B1200, - 1800: syscall.B1800, - 2400: syscall.B2400, - 4800: syscall.B4800, - 9600: syscall.B9600, - 19200: syscall.B19200, - 38400: syscall.B38400, - 57600: syscall.B57600, - 115200: syscall.B115200, - 230400: syscall.B230400, - 460800: syscall.B460800, - 500000: syscall.B500000, - 576000: syscall.B576000, - 921600: syscall.B921600, - 1000000: syscall.B1000000, - 1152000: syscall.B1152000, - 1500000: syscall.B1500000, - 2000000: syscall.B2000000, - 2500000: syscall.B2500000, - 3000000: syscall.B3000000, - 3500000: syscall.B3500000, - 4000000: syscall.B4000000, - } - - rate := bauds[baud] - - if rate == 0 { - return - } - - f, err := os.OpenFile(name, syscall.O_RDWR|syscall.O_NOCTTY|syscall.O_NONBLOCK, 0666) - if err != nil { - return nil, err - } - - defer func() { - if err != nil && f != nil { - f.Close() - } - }() - - fd := f.Fd() - t := syscall.Termios{ - Iflag: syscall.IGNPAR, - Cflag: syscall.CS8 | syscall.CREAD | syscall.CLOCAL | rate, - Cc: [32]uint8{syscall.VMIN: 1}, - Ispeed: rate, - Ospeed: rate, - } - - if _, _, errno := syscall.Syscall6( - syscall.SYS_IOCTL, - uintptr(fd), - uintptr(syscall.TCSETS), - uintptr(unsafe.Pointer(&t)), - 0, - 0, - 0, - ); errno != 0 { - return nil, errno - } - - if err = syscall.SetNonblock(int(fd), false); err != nil { - return - } - - return f, nil -} diff --git a/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/tarm/goserial/serial_posix.go b/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/tarm/goserial/serial_posix.go deleted file mode 100644 index 2eeb608a..00000000 --- a/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/tarm/goserial/serial_posix.go +++ /dev/null @@ -1,107 +0,0 @@ -// +build !windows,cgo - -package serial - -// #include <termios.h> -// #include <unistd.h> -import "C" - -// TODO: Maybe change to using syscall package + ioctl instead of cgo - -import ( - "errors" - "fmt" - "io" - "os" - "syscall" - //"unsafe" -) - -func openPort(name string, baud int) (rwc io.ReadWriteCloser, err error) { - f, err := os.OpenFile(name, syscall.O_RDWR|syscall.O_NOCTTY|syscall.O_NONBLOCK, 0666) - if err != nil { - return - } - - fd := C.int(f.Fd()) - if C.isatty(fd) != 1 { - f.Close() - return nil, errors.New("File is not a tty") - } - - var st C.struct_termios - _, err = C.tcgetattr(fd, &st) - if err != nil { - f.Close() - return nil, err - } - var speed C.speed_t - switch baud { - case 115200: - speed = C.B115200 - case 57600: - speed = C.B57600 - case 38400: - speed = C.B38400 - case 19200: - speed = C.B19200 - case 9600: - speed = C.B9600 - case 4800: - speed = C.B4800 - case 2400: - speed = C.B2400 - default: - f.Close() - return nil, fmt.Errorf("Unknown baud rate %v", baud) - } - - _, err = C.cfsetispeed(&st, speed) - if err != nil { - f.Close() - return nil, err - } - _, err = C.cfsetospeed(&st, speed) - if err != nil { - f.Close() - return nil, err - } - - // Select local mode - st.c_cflag |= (C.CLOCAL | C.CREAD) - - // Select raw mode - st.c_lflag &= ^C.tcflag_t(C.ICANON | C.ECHO | C.ECHOE | C.ISIG) - st.c_oflag &= ^C.tcflag_t(C.OPOST) - - _, err = C.tcsetattr(fd, C.TCSANOW, &st) - if err != nil { - f.Close() - return nil, err - } - - //fmt.Println("Tweaking", name) - r1, _, e := syscall.Syscall(syscall.SYS_FCNTL, - uintptr(f.Fd()), - uintptr(syscall.F_SETFL), - uintptr(0)) - if e != 0 || r1 != 0 { - s := fmt.Sprint("Clearing NONBLOCK syscall error:", e, r1) - f.Close() - return nil, errors.New(s) - } - - /* - r1, _, e = syscall.Syscall(syscall.SYS_IOCTL, - uintptr(f.Fd()), - uintptr(0x80045402), // IOSSIOSPEED - uintptr(unsafe.Pointer(&baud))); - if e != 0 || r1 != 0 { - s := fmt.Sprint("Baudrate syscall error:", e, r1) - f.Close() - return nil, os.NewError(s) - } - */ - - return f, nil -} diff --git a/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/tarm/goserial/serial_windows.go b/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/tarm/goserial/serial_windows.go deleted file mode 100644 index 76e0a307..00000000 --- a/vendor/github.com/coreos/coreos-cloudinit/vendor/github.com/tarm/goserial/serial_windows.go +++ /dev/null @@ -1,263 +0,0 @@ -// +build windows - -package serial - -import ( - "fmt" - "io" - "os" - "sync" - "syscall" - "unsafe" -) - -type serialPort struct { - f *os.File - fd syscall.Handle - rl sync.Mutex - wl sync.Mutex - ro *syscall.Overlapped - wo *syscall.Overlapped -} - -type structDCB struct { - DCBlength, BaudRate uint32 - flags [4]byte - wReserved, XonLim, XoffLim uint16 - ByteSize, Parity, StopBits byte - XonChar, XoffChar, ErrorChar, EofChar, EvtChar byte - wReserved1 uint16 -} - -type structTimeouts struct { - ReadIntervalTimeout uint32 - ReadTotalTimeoutMultiplier uint32 - ReadTotalTimeoutConstant uint32 - WriteTotalTimeoutMultiplier uint32 - WriteTotalTimeoutConstant uint32 -} - -func openPort(name string, baud int) (rwc io.ReadWriteCloser, err error) { - if len(name) > 0 && name[0] != '\\' { - name = "\\\\.\\" + name - } - - h, err := syscall.CreateFile(syscall.StringToUTF16Ptr(name), - syscall.GENERIC_READ|syscall.GENERIC_WRITE, - 0, - nil, - syscall.OPEN_EXISTING, - syscall.FILE_ATTRIBUTE_NORMAL|syscall.FILE_FLAG_OVERLAPPED, - 0) - if err != nil { - return nil, err - } - f := os.NewFile(uintptr(h), name) - defer func() { - if err != nil { - f.Close() - } - }() - - if err = setCommState(h, baud); err != nil { - return - } - if err = setupComm(h, 64, 64); err != nil { - return - } - if err = setCommTimeouts(h); err != nil { - return - } - if err = setCommMask(h); err != nil { - return - } - - ro, err := newOverlapped() - if err != nil { - return - } - wo, err := newOverlapped() - if err != nil { - return - } - port := new(serialPort) - port.f = f - port.fd = h - port.ro = ro - port.wo = wo - - return port, nil -} - -func (p *serialPort) Close() error { - return p.f.Close() -} - -func (p *serialPort) Write(buf []byte) (int, error) { - p.wl.Lock() - defer p.wl.Unlock() - - if err := resetEvent(p.wo.HEvent); err != nil { - return 0, err - } - var n uint32 - err := syscall.WriteFile(p.fd, buf, &n, p.wo) - if err != nil && err != syscall.ERROR_IO_PENDING { - return int(n), err - } - return getOverlappedResult(p.fd, p.wo) -} - -func (p *serialPort) Read(buf []byte) (int, error) { - if p == nil || p.f == nil { - return 0, fmt.Errorf("Invalid port on read %v %v", p, p.f) - } - - p.rl.Lock() - defer p.rl.Unlock() - - if err := resetEvent(p.ro.HEvent); err != nil { - return 0, err - } - var done uint32 - err := syscall.ReadFile(p.fd, buf, &done, p.ro) - if err != nil && err != syscall.ERROR_IO_PENDING { - return int(done), err - } - return getOverlappedResult(p.fd, p.ro) -} - -var ( - nSetCommState, - nSetCommTimeouts, - nSetCommMask, - nSetupComm, - nGetOverlappedResult, - nCreateEvent, - nResetEvent uintptr -) - -func init() { - k32, err := syscall.LoadLibrary("kernel32.dll") - if err != nil { - panic("LoadLibrary " + err.Error()) - } - defer syscall.FreeLibrary(k32) - - nSetCommState = getProcAddr(k32, "SetCommState") - nSetCommTimeouts = getProcAddr(k32, "SetCommTimeouts") - nSetCommMask = getProcAddr(k32, "SetCommMask") - nSetupComm = getProcAddr(k32, "SetupComm") - nGetOverlappedResult = getProcAddr(k32, "GetOverlappedResult") - nCreateEvent = getProcAddr(k32, "CreateEventW") - nResetEvent = getProcAddr(k32, "ResetEvent") -} - -func getProcAddr(lib syscall.Handle, name string) uintptr { - addr, err := syscall.GetProcAddress(lib, name) - if err != nil { - panic(name + " " + err.Error()) - } - return addr -} - -func setCommState(h syscall.Handle, baud int) error { - var params structDCB - params.DCBlength = uint32(unsafe.Sizeof(params)) - - params.flags[0] = 0x01 // fBinary - params.flags[0] |= 0x10 // Assert DSR - - params.BaudRate = uint32(baud) - params.ByteSize = 8 - - r, _, err := syscall.Syscall(nSetCommState, 2, uintptr(h), uintptr(unsafe.Pointer(¶ms)), 0) - if r == 0 { - return err - } - return nil -} - -func setCommTimeouts(h syscall.Handle) error { - var timeouts structTimeouts - const MAXDWORD = 1<<32 - 1 - timeouts.ReadIntervalTimeout = MAXDWORD - timeouts.ReadTotalTimeoutMultiplier = MAXDWORD - timeouts.ReadTotalTimeoutConstant = MAXDWORD - 1 - - /* From http://msdn.microsoft.com/en-us/library/aa363190(v=VS.85).aspx - - For blocking I/O see below: - - Remarks: - - If an application sets ReadIntervalTimeout and - ReadTotalTimeoutMultiplier to MAXDWORD and sets - ReadTotalTimeoutConstant to a value greater than zero and - less than MAXDWORD, one of the following occurs when the - ReadFile function is called: - - If there are any bytes in the input buffer, ReadFile returns - immediately with the bytes in the buffer. - - If there are no bytes in the input buffer, ReadFile waits - until a byte arrives and then returns immediately. - - If no bytes arrive within the time specified by - ReadTotalTimeoutConstant, ReadFile times out. - */ - - r, _, err := syscall.Syscall(nSetCommTimeouts, 2, uintptr(h), uintptr(unsafe.Pointer(&timeouts)), 0) - if r == 0 { - return err - } - return nil -} - -func setupComm(h syscall.Handle, in, out int) error { - r, _, err := syscall.Syscall(nSetupComm, 3, uintptr(h), uintptr(in), uintptr(out)) - if r == 0 { - return err - } - return nil -} - -func setCommMask(h syscall.Handle) error { - const EV_RXCHAR = 0x0001 - r, _, err := syscall.Syscall(nSetCommMask, 2, uintptr(h), EV_RXCHAR, 0) - if r == 0 { - return err - } - return nil -} - -func resetEvent(h syscall.Handle) error { - r, _, err := syscall.Syscall(nResetEvent, 1, uintptr(h), 0, 0) - if r == 0 { - return err - } - return nil -} - -func newOverlapped() (*syscall.Overlapped, error) { - var overlapped syscall.Overlapped - r, _, err := syscall.Syscall6(nCreateEvent, 4, 0, 1, 0, 0, 0, 0) - if r == 0 { - return nil, err - } - overlapped.HEvent = syscall.Handle(r) - return &overlapped, nil -} - -func getOverlappedResult(h syscall.Handle, overlapped *syscall.Overlapped) (int, error) { - var n int - r, _, err := syscall.Syscall6(nGetOverlappedResult, 4, - uintptr(h), - uintptr(unsafe.Pointer(overlapped)), - uintptr(unsafe.Pointer(&n)), 1, 0, 0) - if r == 0 { - return n, err - } - - return n, nil -}